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

Fixing some doctests. #4118

Merged
merged 10 commits into from
Apr 11, 2023
Merged

Fixing some doctests. #4118

merged 10 commits into from
Apr 11, 2023

Conversation

AHMED-salah00
Copy link
Contributor

@AHMED-salah00 AHMED-salah00 commented Apr 7, 2023

Portion of #3925

Changes made in this Pull Request:

Fixed the doctests in the following files:

  • core/universe.py.
  • lib/transformations.py.
  • lib/util.py.

PR Checklist

  • Docs?
  • Issue raised/referenced?

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

@github-actions
Copy link

github-actions bot commented Apr 7, 2023

Linter Bot Results:

Hi @AHMED-salah00! Thanks for making this PR. We linted your code and found the following:

Some issues were found with the formatting of your code.

Code Location Outcome
main package ⚠️ Possible failure
testsuite ✅ Passed

Please have a look at the darker-main-code and darker-test-code steps here for more details: https://github.com/MDAnalysis/mdanalysis/actions/runs/4664925964/jobs/8257693131


Please note: The black linter is purely informational, you can safely ignore these outcomes if there are no flake8 failures!

@codecov
Copy link

codecov bot commented Apr 7, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (fd978d2) 93.59% compared to head (08fc182) 93.59%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4118   +/-   ##
========================================
  Coverage    93.59%   93.59%           
========================================
  Files          192      192           
  Lines        25134    25134           
  Branches      4056     4056           
========================================
  Hits         23524    23524           
  Misses        1092     1092           
  Partials       518      518           
Impacted Files Coverage Δ
package/MDAnalysis/core/universe.py 97.26% <ø> (ø)
package/MDAnalysis/lib/transformations.py 78.49% <ø> (ø)
package/MDAnalysis/lib/util.py 89.65% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -109,6 +109,7 @@
Examples
--------

>>> from MDAnalysis.lib.transformations import identity_matrix
Copy link
Member

Choose a reason for hiding this comment

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

What about the other functions such as rotation_matrix, euler_from_matrix, ...? (Same comment applies elsewhere).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I really didn't take that in mind. I will import them too.

Copy link
Member

@RMeli RMeli Apr 10, 2023

Choose a reason for hiding this comment

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

@AHMED-salah00 I took me a while to figure this out, but #3997 added the doctests to CI. These never fail, so you need to dig them up yourself and see.

For this PR, you can go under the "Checks" tab, look for the "build_docs" test under the "GH Actions CI" menu on the left, and then look at (expand) the "doctest" phase. If you search for lib/transformations.py you can see the current failures (due to missing rotation_matrix, etc.). You can do the same for the other files you touched in this PR and hopefully fix all the current issues.

@MDAnalysis/coredevs I think here it would be more useful to have CI tests that can be incrementally turned on (instead of a single CI test for everything that never fails) when a file is addressed and fixed, so that we can ensure a PR is OK (by turning on the checks for the current files) and more importantly that no more issues are re-introduced later on. Would this be possible with doctests?

Copy link
Member

Choose a reason for hiding this comment

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

Not easily afaik - at least not with the current way we're invoking things (coming up with more complex solutions might take a while). I think the original suggestion was for reviewers to compare against the last merge commit and see if the numbers went up or down.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @RMeli for this found lots of failing docs here :)

Copy link
Member

Choose a reason for hiding this comment

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

Indeed. =) Please focus only on one or a few files at a time, to keep PRs of reasonable size (thus easier to review and merge). For the current PR I'd fix all the issues in the files you already touched:

  • core/universe.py
  • lib/transformations.py
  • lib/util.py

@@ -109,6 +109,7 @@
Examples
--------

>>> from MDAnalysis.lib.transformations import identity_matrix
Copy link
Member

@RMeli RMeli Apr 10, 2023

Choose a reason for hiding this comment

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

@AHMED-salah00 I took me a while to figure this out, but #3997 added the doctests to CI. These never fail, so you need to dig them up yourself and see.

For this PR, you can go under the "Checks" tab, look for the "build_docs" test under the "GH Actions CI" menu on the left, and then look at (expand) the "doctest" phase. If you search for lib/transformations.py you can see the current failures (due to missing rotation_matrix, etc.). You can do the same for the other files you touched in this PR and hopefully fix all the current issues.

@MDAnalysis/coredevs I think here it would be more useful to have CI tests that can be incrementally turned on (instead of a single CI test for everything that never fails) when a file is addressed and fixed, so that we can ensure a PR is OK (by turning on the checks for the current files) and more importantly that no more issues are re-introduced later on. Would this be possible with doctests?

@AHMED-salah00 AHMED-salah00 requested a review from RMeli April 10, 2023 19:25
Copy link
Member

@RMeli RMeli left a comment

Choose a reason for hiding this comment

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

lib/transformations.py LGTM:

Document: documentation_pages/lib/transformations
-------------------------------------------------
1 items passed all tests:
 160 tests in default
160 tests in 1 items.
160 passed and 0 failed.
Test passed.

For the other two files, there are still several test failing. I commented on the ones close to or related to the code you changed, but there are others as you can see in the log (especially in lib.util.py). Please double check and fix them.

@@ -1416,9 +1419,9 @@ def from_smiles(cls, smiles, sanitize=True, addHs=True,
To use a different conformer generation algorithm, like ETKDGv3:

>>> u = mda.Universe.from_smiles('CCO', rdkit_kwargs=dict(
params=AllChem.ETKDGv3()))
... params=AllChem.ETKDGv3()))
Copy link
Member

Choose a reason for hiding this comment

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

/home/runner/work/mdanalysis/mdanalysis/package/doc/sphinx/source/../../../MDAnalysis/core/universe.py.rst: WARNING: ignoring invalid doctest code: ">>> u = mda.Universe.from_smiles('CCO', rdkit_kwargs=dict(\n    ... params=AllChem.ETKDGv3()))\n>>> u.trajectory\n<RDKitReader with 10 frames of 9 atoms>"

Please format properly, so that this line is not invalid.

Comment on lines 809 to 810
>>> u.add_TopologyAttr('bfactors')
>>> u.atoms.bfactors
Copy link
Member

Choose a reason for hiding this comment

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

This is unrelated to your changes, therefore feel free to ignore the following comment if you don't want to address it in this PR or at all.

I can see from the log that there are some warnings because bfactors has been deprecated (and will be removed in 3.0).

/home/runner/work/mdanalysis/mdanalysis/package/MDAnalysis/core/universe.py:828: DeprecationWarning: The bfactor topology attribute is only provided as an alias to the tempfactor attribute. It will be removed in 3.0. Please use the tempfactor attribute instead.

If you want/have time you could fix this warning as well (which will become an error down the line) by replacing bfactor with tempfactor (and bfactors with tempfactors).

package/MDAnalysis/lib/util.py Show resolved Hide resolved
@@ -109,6 +109,8 @@
Examples
--------

>>> from MDAnalysis.lib.transformations import *
>>> import numpy
Copy link
Member

Choose a reason for hiding this comment

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

I think if would be better to change the whole test to be consistent with the others and use import numpy as np.

@RMeli RMeli self-assigned this Apr 10, 2023
Copy link
Member

@RMeli RMeli left a comment

Choose a reason for hiding this comment

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

Document: documentation_pages/core/universe
-------------------------------------------
1 items passed all tests:
  24 tests in default
24 tests in 1 items.
24 passed and 0 failed.
Test passed.
Document: documentation_pages/lib/transformations
-------------------------------------------------
1 items passed all tests:
 160 tests in default
160 tests in 1 items.
160 passed and 0 failed.
Test passed.
Document: documentation_pages/lib/util
--------------------------------------
1 items passed all tests:
  30 tests in default
30 tests in 1 items.
30 passed and 0 failed.
Test passed.

LGTM, thanks @AHMED-salah00

@RMeli RMeli requested a review from IAlibay April 11, 2023 09:34
Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

lgtm!

@IAlibay IAlibay merged commit 210e05c into MDAnalysis:develop Apr 11, 2023
@AHMED-salah00 AHMED-salah00 deleted the doctests branch April 11, 2023 15:50
@github-staff github-staff deleted a comment from AHMED-salah00 Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants