-
Notifications
You must be signed in to change notification settings - Fork 7
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
Enable to add similar elements #196
base: master
Are you sure you want to change the base?
Conversation
Tests will not pass (after the latest commit e536dcd) if not sorted(orig_elems). Why is that and should it be sorted? potku/tests/unit/test_element.py Lines 64 to 82 in 96cf37b
|
modules/element.py
Outdated
if self.sequence is None and other.sequence is not None: | ||
return True | ||
|
||
if self.isotope is not None and other.isotope is None: | ||
if self.sequence is not None and other.sequence is None: |
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.
These should be after the isotope comparisons, not instead of them.
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.
Sorry, I do not understand what you suggest.
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.
How is this different from this?
Similar to self.isotope
:
if self.sequence is None and other.sequence is not None: | |
return True | |
if self.isotope is not None and other.isotope is None: | |
if self.sequence is not None and other.sequence is None: | |
def __lt__(self, other): | |
# ... | |
# Elements that have no sequence number come before elements that do | |
if self.sequence is None and other.sequence is not None: | |
return True | |
if self.sequence is not None and other.sequence is None: | |
return False | |
return str(self) < str(other) |
Originally posted by @tpitkanen in #196 (comment)
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.
Elements were originally compared by member variables in this order:
- symbol
- isotope
- (
str
conversion)
Now they are compared:
- symbol
- sequence
- (
str
conversion)
But they should be compared:
- symbol
- isotope
- sequence
- (
str
conversion)
Also, I'm not sure if just comparing str(self) < str(other)
at the end works now that there's self.sequence
.
|
- symbol - isotope - sequence - (str conversion)
Fix comparison
I checked this pull request again while merging the open PRs and noticed the following:
More importantly, I reconsidered the risk/reward ratio of this feature. While being able to add similar elements is useful, the Even if the code doesn't break, the effects of the new I don't think this feature should be added after all. It's too much work and code complexity for its benefits. (Ping for the corresponding issue: #194) |
Solves #194