Skip to content

Apply black style to test_Restriction.py, version 19.10b0. - #2833

Merged
peterjc merged 2 commits into
biopython:masterfrom
svalqui:issue_2552_Test_Restriction
Apr 14, 2020
Merged

peterjc merged 2 commits into
biopython:masterfrom
svalqui:issue_2552_Test_Restriction

Conversation

@svalqui

@svalqui svalqui commented Apr 6, 2020

Copy link
Copy Markdown
Contributor

This pull request addresses issue #2552

  • 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.rst file, have run flake8 locally, and
    understand that AppVeyor and TravisCI will be used to confirm the Biopython unit
    tests and style checks pass with these changes.

  • I have added my name to the alphabetical contributors listings in the files
    NEWS.rst and CONTRIB.rst as part of this pull request, am listed
    already, or do not wish to be listed. (This acknowledgement is optional.)

This PR applies black style to test_Restriction.py. few changes but should be fine to merge.

@codecov

codecov Bot commented Apr 6, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #2833 into master will decrease coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2833      +/-   ##
==========================================
- Coverage   84.16%   84.15%   -0.01%     
==========================================
  Files         319      319              
  Lines       50201    50201              
==========================================
- Hits        42251    42247       -4     
- Misses       7950     7954       +4     
Impacted Files Coverage Δ
Bio/Application/__init__.py 85.65% <0.00%> (-1.20%) ⬇️
Bio/Entrez/Parser.py 82.58% <0.00%> (-0.16%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1ca6e9...1e8ce70. Read the comment docs.

Comment thread Tests/test_Restriction.py
EarI,
SnaI,
SphI,
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My personal preference would be:

from Bio.Restriction import Acc65I
...
from Bio.Restriction import SphI

See discussion on #2828 - we have yet to agree any particular style, so this is fine for now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My personal preference would be to let it stand as it was, but let black do what black wants to do here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, leave it as is for now - we can settle any preferred import style later on the linked issue.

@peterjc
peterjc requested a review from MarkusPiotrowski April 6, 2020 21:47
Comment thread Tests/test_Restriction.py Outdated
self.assertEqual(
str(FormattedSeq(Seq("GATC"))), "FormattedSeq(Seq('GATC'), linear=True)"
)
self.assertFalse(FormattedSeq(Seq("GATC")) == FormattedSeq(Seq("TAGC")))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@svalqui Sorry for this request, although not black-related but still style-related: Can you change all assertFalse(a==b) and assertTrue(a==b) into assertNotEqual(a, b) and assertEqual(a, b)?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not only here but in the whole file?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Logged #2835 for the wider issue, but happy for you to fix this file as part of this pull request, or leave it for later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated, but left one that doesn't pass the test.

    self.assertNotEqual(Acc65I, Asp718I)
AssertionError: Acc65I == Asp718I

I think is mean to use assertNotEqual.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a special thing within Bio.Restriction, __eq__ (==) and __ne__ (!=) have been overriden with different meanings. In this case Acc65I and Asp718I are neither equal (they are not the same enzyme) nor not equal (they are isoschizomers, doing exactly the same thing).
Thus assertFalse is the only method which allows to test both. OK.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd forgotten about that quirk. Best or at least standard practise is __eq__ and __ne__ give the negation of each other, but as here that isn't required.

@ajsmith ajsmith Jun 29, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@peterjc @MarkusPiotrowski Perhaps I'm new here, but is there any reason why the __ne__ operator is used to check for isoschizomer-ness? It doesn't seem very convenient if it confuses the linter and tests (and potentially humans too). When I first saw this behavior in the tests, I thought it was a bug.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would agree in hindsight this was a poor design choice. We have been looking at replacing the entirety of the old restriction digest module anyway.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@peterjc Thank you for the clarification, and I look forward to seeing the new design!

Comment thread Tests/test_Restriction.py
EarI,
SnaI,
SphI,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My personal preference would be to let it stand as it was, but let black do what black wants to do here.

@MarkusPiotrowski MarkusPiotrowski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you!

@peterjc
peterjc merged commit 40cf049 into biopython:master Apr 14, 2020
@peterjc

peterjc commented Apr 14, 2020

Copy link
Copy Markdown
Member

Thank you both

@peterjc peterjc mentioned this pull request May 1, 2020
2 of 3 tasks
@svalqui
svalqui deleted the issue_2552_Test_Restriction branch May 3, 2020 21:44
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