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

fixing issue #234 of ZXLive #234

Merged
merged 2 commits into from
Jul 16, 2024
Merged

Conversation

lia-approves
Copy link
Contributor

For Poly, there is not a sensible value to set denominator to, so this checks if the phase type is Poly before checking the denominator value. Addresses zxcalc/zxlive#234
With @hm919

@@ -54,7 +55,7 @@ def string_to_phase(string: str, g: Union[BaseGraph,'GraphDiff']) -> Union[Fract
elif '/' in s:
a, b = s.split("/", 2)
if not a:
return Fraction(1, int(b))
return Fraction(int(1), int(b))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just for visual consistency (to aid readers of the code), or does this change actually have an effect?

Copy link
Contributor Author

@lia-approves lia-approves Jun 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change from 1 to int(1) actually has an effect. For some reason I don't understand, I presume some obscure typing convention that could be platform dependent, there is a bug that setting the phase of a node in ZXLive to "2a+b" automatically converts to "0a+b". Oddly, changing this line here fixes this so that it actually stays as "2a+b". This was the case on at least two devices. I don't know where if there is some typechecking somewhere in the codebase or elsewhere to see if something is of type int, or why python doesn't by default have 1 be of type int, or maybe there's different int types,...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, wow. This warrants a comment in the code with this explanation so that it isn't accidentally removed by a person or tool later which mistakenly thinks this is a noop.

@jvdwetering jvdwetering merged commit d861a13 into zxcalc:master Jul 16, 2024
3 checks passed
jvdwetering added a commit that referenced this pull request Jul 16, 2024
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

Successfully merging this pull request may close these issues.

3 participants