Repository navigation
Vector division broken in python 3.x #1914 - #1920
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1920 +/- ##
==========================================
+ Coverage 85.02% 85.04% +0.01%
==========================================
Files 310 311 +1
Lines 49934 50127 +193
==========================================
+ Hits 42457 42630 +173
- Misses 7477 7497 +20
Continue to review full report at Codecov.
|
|
Looks good - I'll allow a few days in case @etal or any of the other PDB experts wants to comment, but hope to merge this during the coming week. |
|
I'm not familiar with the github pull requests and the code check 😑 |
|
@platinhom it was new to me once, and Github improves it over time - so I keep learning by doing. |
lennax
left a comment
There was a problem hiding this comment.
Looks like a reasonable way to fix this problem. Two optional comments.
| a = self._ar / numpy.array(x) | ||
| return Vector(a) | ||
|
|
||
| __truediv__ = __div__ |
There was a problem hiding this comment.
What if we do the opposite? Rename the current method to __truediv__ and assign __div__ = __truediv__. That way, when we drop 2.x support, we can just remove __div__.
There was a problem hiding this comment.
That seems a worthwhile improvement.
| """Confirm division works.""" | ||
| from Bio.PDB.Vector import Vector | ||
| v = Vector(2, 2, 2) / 2 | ||
| self.assertEqual(repr(v), "<Vector 1.00, 1.00, 1.00>") |
There was a problem hiding this comment.
I'm probably being too picky but this test wouldn't fail if the vector was somehow divided using floor division then cast to int. I'd use example numbers that would look even more strange if floor division were used (e.g. the classic 1 // 2 == 0).
There was a problem hiding this comment.
I wondered that too - this would be clearer, good idea.
|
Sorry, I would have merged this as is, but if you're willing to polish this further based on @lennax's useful comments, that'd be even better. |
Based on review comment from Lenna
Based on review comment from Lenna
|
The tests passed, but GitHub seems a bit slow to show that. Odd. |
|
Changes applied - thank you both! |
Original author Thomas Hamelryck (when the file was called Bio/PDB/Vector.py) and all the contributors since as tracked with version control have agreed: - Adhemar Zerlotini (@azneto) biopython#1412 (comment) - Bertrand Caron (@bertrand-caron) biopython#494 (comment) - Brian Osborne (@bosborne) biopython#898 (comment) - Christian Brueffer (@cbrueffer) biopython#898 (comment) - Brad Chapman (@chapmanb) http://mailman.open-bio.org/pipermail/biopython-dev/2013-July/019903.html - Connor McCoy (@cmccoy) biopython#898 (comment) - Eric Talevich (@etal) biopython#898 (comment) - Francesco Gastaldello (@Gasta88) biopython#1063 - Hom (@platinhom) biopython#1920 - Joe Greener (@jgreener64) biopython#1393 - Michiel de Hoon (@mdehoon) biopython#898 (comment) - @morrme biopython#1172 (comment) - Peter Cock (@peterjc) biopython#898 (comment) - Ralf Stephan (@rwst) biopython#1900 - Rasmus Fonseca (@fonseca.rasmus) biopython#1171 (comment) - Sergei Lebedev (@superbobry) biopython#898 (comment) - Sergio Valqui (@svalqui) biopython#1749 - Thomas Hamelryck (CVS username nisse) https://mailman.open-bio.org/pipermail/biopython/2018-September/016546.html
Original author Thomas Hamelryck (when the file was called Bio/PDB/Vector.py) and all the contributors since as tracked with version control have agreed: - Adhemar Zerlotini (@azneto) #1412 (comment) - Bertrand Caron (@bertrand-caron) #494 (comment) - Brian Osborne (@bosborne) #898 (comment) - Christian Brueffer (@cbrueffer) #898 (comment) - Brad Chapman (@chapmanb) http://mailman.open-bio.org/pipermail/biopython-dev/2013-July/019903.html - Connor McCoy (@cmccoy) #898 (comment) - Eric Talevich (@etal) #898 (comment) - Francesco Gastaldello (@Gasta88) #1063 - Hom (@platinhom) #1920 - Joe Greener (@jgreener64) #1393 - Michiel de Hoon (@mdehoon) #898 (comment) - @morrme #1172 (comment) - Peter Cock (@peterjc) #898 (comment) - Ralf Stephan (@rwst) #1900 - Rasmus Fonseca (@fonseca.rasmus) #1171 (comment) - Sergei Lebedev (@superbobry) #898 (comment) - Sergio Valqui (@svalqui) #1749 - Thomas Hamelryck (CVS username nisse) https://mailman.open-bio.org/pipermail/biopython/2018-September/016546.html
This pull request addresses issue #1914
I hereby agree to dual licence this and any previous contributions under both
the Biopython License Agreement AND the BSD 3-Clause License.
I have read the
CONTRIBUTING.rstfile and understand that AppVeyor andTravisCI will be used to confirm the Biopython unit tests and
flake8stylechecks pass with these changes.
I have added my name to the alphabetical contributors listings in the files
NEWS.rstandCONTRIB.rstas part of this pull request, am listedalready, or do not wish to be listed. (This acknowledgement is optional.)