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

changes made to obspyIO.py and focalmechplotter.py for string equiva… #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

iceseismic
Copy link

Hi Mark, For some reason in order to get my hashpy to work I had to change the string equivalence checks inside obspyIO.py and focalmechplotter.py ; from "is" to "==" in 3 or 4 places. I'm running under python2.7 myself

@megies
Copy link

megies commented Oct 31, 2015

Feels like this might stem from obspy using future for simultaneous Python2+3 compatibility. Anyway, string values should be compared using == rather than with is, I think.

continue

if (pick.onset is 'impulsive'):
if (pick.onset == 'impulsive'):
Copy link

Choose a reason for hiding this comment

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

Just cosmetics, but those brackets ain't necessary..

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, I was in Fortran mode when I did that 👎

Choose a reason for hiding this comment

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

@megies is correct. use == to compare strings, never is.
is is a much stricter and here unwanted comparison.

@markcwill markcwill self-assigned this Jan 14, 2016
@markcwill
Copy link
Owner

For the case of comparing literals (int, string, etc) w/ variable value bindings, I'm not 100% sure what the difference is in the compiler (object id vs value equiv), but @megies is right, we are after value equiv, and if those strings ever get abstracted out as variables, this would break. Which is probably what future is doing under the hood? This was done in obspy 0.7 or 0.8, before the 2to3, so that's probably the culprit. For the record, our current production is on Ubuntu 14.04.2:

  • python: 2.7.6
  • obspy: 0.9.2
  • hashpy: v0.7.2-3-ga6e9

Anyhoo, thanks! Either pull this into dev, or I'm waiting until I merge dev into master....

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.

4 participants