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

Fix bug in PCA trajectory iteration -- avoid explicit usage of self.start #4423

Merged
merged 11 commits into from
Jan 20, 2024

Conversation

marinegor
Copy link
Contributor

@marinegor marinegor commented Jan 12, 2024

This fixes a bug which made impossible the
Fixes #4425

Changes made in this Pull Request:

  • access first frame in trajectory with self._sliced_trajectory[0] instead of self._trajectory[self.start], since self.start is None if run is initiated with a.run(frames=[1,2]).

PR Checklist

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

Developers certificate of origin


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

@pep8speaks
Copy link

pep8speaks commented Jan 12, 2024

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

Line 145:78: W291 trailing whitespace

Comment last updated at 2024-01-18 16:56:20 UTC

Copy link

github-actions bot commented Jan 12, 2024

Linter Bot Results:

Hi @marinegor! 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 ⚠️ Possible failure

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/7573356413/job/20625313741


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

fix formatting changes
Copy link

codecov bot commented Jan 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (24abb16) 93.36% compared to head (7e915a4) 93.36%.

Additional details and impacted files
@@            Coverage Diff             @@
##           develop    #4423     +/-   ##
==========================================
  Coverage    93.36%   93.36%             
==========================================
  Files          171      185     +14     
  Lines        21736    22850   +1114     
  Branches      4012     4012             
==========================================
+ Hits         20293    21334   +1041     
- Misses         954     1027     +73     
  Partials       489      489             

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

@hmacdope
Copy link
Member

Could you also raise an issue @marinegor just so we have a record of what went wrong?

@marinegor
Copy link
Contributor Author

hi @hmacdope , I raised the issue -- should I do anything else?
I'm not sure if the discussion above is regarding this PR, especially since I feel I can't contribute much to it😁

@marinegor
Copy link
Contributor Author

So anyway, I added versionchanged to the class documentation describing what's going on -- hopefully that'll be enough for the PR!

Copy link
Member

@hmacdope hmacdope left a comment

Choose a reason for hiding this comment

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

@marinegor could you add

When using mean selections, the first frame of the selected trajectory slice is used as a reference.

To the main docstring of PCA class? other than that looks good.

described by #4425 and fixed by #4423). Previously, behaviour was to
manually iterate through ``self._trajectory``, which starting #3415 that
introduced ``frames`` is wrong, and should use ``self._sliced_trajectory``.
It is now fixed.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
It is now fixed.

@marinegor
Copy link
Contributor Author

@hmacdope done both (applied suggestion in my commit)

Copy link
Member

@hmacdope hmacdope left a comment

Choose a reason for hiding this comment

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

I will approve but would love a review from @IAlibay before going ahead and merging. Well done @marinegor!

@IAlibay
Copy link
Member

IAlibay commented Jan 17, 2024

@hmacdope happy to have a quick look tomorrow, could you do a review request for me please? (sorry I'm on phone)

@hmacdope
Copy link
Member

@hmacdope happy to have a quick look tomorrow, could you do a review request for me please? (sorry I'm on phone)

I think you are already requested.

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.

Couple of small change suggestions, otherwise lgtm!

package/CHANGELOG Outdated Show resolved Hide resolved
@@ -142,7 +142,8 @@ class PCA(AnalysisBase):
generates the principal components of the backbone of the atomgroup and
then transforms those atomgroup coordinates by the direction of those
variances. Please refer to the :ref:`PCA-tutorial` for more detailed
instructions.
instructions. When using mean selections, the first frame of the selected
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 great thanks!

package/MDAnalysis/analysis/pca.py Outdated Show resolved Hide resolved
testsuite/MDAnalysisTests/analysis/test_pca.py Outdated Show resolved Hide resolved
@marinegor
Copy link
Contributor Author

@IAlibay

Since it's a bit of a smoke test of "will this work", and we don't assert on anything, could you add mean=True explicitly here?

Actually, mean=None (=the default option) ensures I run this part of the code afaik (I checked it with `assert False on L286). So I reverted back to my version of the test.

@IAlibay
Copy link
Member

IAlibay commented Jan 18, 2024

@IAlibay

Since it's a bit of a smoke test of "will this work", and we don't assert on anything, could you add mean=True explicitly here?

Actually, mean=None (=the default option) ensures I run this part of the code afaik (I checked it with `assert False on L286). So I reverted back to my version of the test.

Sorry maybe I didn't explain my point well enough - None currently has that behaviour, but given we want to ensure it's always going to be called forever into the future, then setting True may be better.

That being said - I'm not particularly too fussed here, it's just nice to enforce a branch decision rather than rely on defaults.

@marinegor
Copy link
Contributor Author

@IAlibay I see what you mean now -- added explicit frames=None here.
Btw, I firmly believe all the tests are ok but something wrong with the CI💔

@RMeli
Copy link
Member

RMeli commented Jan 20, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@RMeli
Copy link
Member

RMeli commented Jan 20, 2024

Btw, I firmly believe all the tests are ok but something wrong with the CI💔

Looked like a timeout. Re-running Azure Pipelines completed successfully.

@RMeli RMeli merged commit 8ec8c32 into MDAnalysis:develop Jan 20, 2024
23 checks passed
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.

analysis.pca.PCA can't be run with frames=...
5 participants