-
Notifications
You must be signed in to change notification settings - Fork 45
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
Fix syntax warnings #556
base: main
Are you sure you want to change the base?
Fix syntax warnings #556
Conversation
* Correct invalid escape sequences in string literals. * Use "!=" instead of "is not" for integer comparison.
Thanks for the PR @tueda! I'm traveling at the moment and so just seeing this, but I can review it tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hola
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hola
/home/tueda/work/madminer/madminer/utils/interfaces/mg.py:268: SyntaxWarning: invalid escape sequence '$'
replacement_command = """sed -e 's@$mgprocdir@'"$mgprocdir"'@' {}/{} > {}/{}""".format(
/home/tueda/work/madminer/madminer/fisherinformation/geometry.py:164: SyntaxWarning: invalid escape sequence '\p'
"""
/home/tueda/work/madminer/madminer/fisherinformation/geometry.py:187: SyntaxWarning: invalid escape sequence '\p'
"""
/home/tueda/work/madminer/madminer/fisherinformation/geometry.py:349: SyntaxWarning: "is not" with 'int' literal. Did you mean "!="?
if self.dimension is not 2:
With Python 3.12 (w/o
.pyc
cache files in__pycache__
), by importingmadminer
,I got the following warnings:
This patch resolves these warnings.
The last warning
SyntaxWarning: "is not" with 'int' literal
may need some explanation: indeed, I expect the current code to work correctly due to CPython's optimization of small integers (from-5
to256
),but using
is
for integer comparison in general can lead to incorrect results. For example, the following code gives a counterintuitive result: