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

Addition of isInstance test of BackendSerial #4773

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

talagayev
Copy link
Member

@talagayev talagayev commented Oct 29, 2024

Fixes #4657

Changes made in this Pull Request:

  • Addition of test_instance_serial_backend to test_base.py to check that the function works and the instance is correct

Currently I just create a variable of BackendSerial for serial_backend , which I use in FrameAnalysis(u.trajectory).run to display that it runs with the backend=serial_backend and also then check the correct instance of serial_backend

I wasn't sure here if I should check the instance of backend of the run() in FrameAnalysis(u.trajectory).run(backend=serial_backend), since then I would need to modify the code to get the instance of backend from run()

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

Developers certificate of origin


📚 Documentation preview 📚: https://mdanalysis--4773.org.readthedocs.build/en/4773/

Addition of test for serial backend instance
@pep8speaks
Copy link

pep8speaks commented Oct 29, 2024

Hello @talagayev! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-10-29 12:14:35 UTC

Copy link

codecov bot commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.63%. Comparing base (e776f12) to head (8a54898).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4773      +/-   ##
===========================================
- Coverage    93.66%   93.63%   -0.03%     
===========================================
  Files          177      189      +12     
  Lines        21726    22792    +1066     
  Branches      3052     3052              
===========================================
+ Hits         20349    21342     +993     
- Misses         930     1003      +73     
  Partials       447      447              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

unsupported_backend=True
)

assert isinstance(serial_backend, backends.BackendSerial)
Copy link
Member

Choose a reason for hiding this comment

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

To me this test looks a bit self-referential. You are creating a backends.BackendSerial and then just checking that said object is indeed backends.BackendSerial. Could you please elaborate a bit more what is the intent here? I might be missing something...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes the idea is the checking of this part of the code:

https://github.com/talagayev/mdanalysis/blob/8a5489804d2b62c76f6909034b8a43cd6ff1a65d/package/MDAnalysis/analysis/base.py#L776-L780

but I was not sure if the Issue idea was to test assert that backends.BackendSerial runs as an input and assert the input, which is the current case or if the Idea is to test the backend in FrameAnalysis(u.trajectory).run

https://github.com/talagayev/mdanalysis/blob/8a5489804d2b62c76f6909034b8a43cd6ff1a65d/testsuite/MDAnalysisTests/analysis/test_base.py#L293-L298

So yes, looks confusing the pytest, since I am not sure which should be tested, that it works with backends.BackendSerial or the isinstance(backend, BackendSerial)

If it is the latter, then I would modify the pytest

my bad for making it a little bit confusing here 🙈

Copy link
Member

Choose a reason for hiding this comment

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

Thank you for the clarification. To test the part of the code you linked, what I would do is to use pytest.raises to make sure an exception is thrown when the backend is not serial.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah I see, yes that makes sense, I will then adjust the PR accordingly :)

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.

Add tests checking instance of Backend when progressbar is supposed to be displayed
3 participants