Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoiding differing expressions that look the same #315

Open
wwitzel opened this issue Oct 5, 2023 · 2 comments
Open

Avoiding differing expressions that look the same #315

wwitzel opened this issue Oct 5, 2023 · 2 comments
Assignees

Comments

@wwitzel
Copy link
Collaborator

wwitzel commented Oct 5, 2023

It can be very confusing when two expressions look the same but are actually different. Here are two things we can do to avoid this problem.

  1. When checking to see if a parameter should be relabeled in order to avoid a scoping violation, we could check against the string/latex display of the contained sub-expressions rather than just looking for explicit Variable collisions. An example of this came up recently where there was a "collision" between var_ket_psi and ket_psi. They appear the same but are different types of expressions. This solution would avoid that issue.
  2. More generally we could check expressions as they are generating their formatted display to see if there are any sub-expressions that have the same display but are different. If so, we could generate some kind of warning or raise an exception.
@wwitzel wwitzel self-assigned this Oct 5, 2023
@wdcraft01
Copy link
Collaborator

I like the pro-activeness of (2) (i.e. checking expressions for duplicated display formats). My inclination would be to generate an alert or warning rather than an exception. I also worry a little about the computational overhead of doing such checking.

@wwitzel
Copy link
Collaborator Author

wwitzel commented Oct 5, 2023

I think it can be done efficiently, but you have to be careful about it. What I'm thinking is that you store a dictionary that maps latex/strings to expressions, updating this dictionary whenever an expression generates its latex/string representation. But I haven't fully thought this through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants