-
Notifications
You must be signed in to change notification settings - Fork 11
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
Tidy up euphonic.spectra: split into multiple files and lint #359
Conversation
Hmm, at the moment git-blame from the github interface is succesfully tracking the history of lines in spectra.base, but not in spectra.collecions 😞 |
This creates a second copy. Will the git history be preserved? I hope so!
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #359 +/- ##
==========================================
+ Coverage 95.44% 96.03% +0.58%
==========================================
Files 29 31 +2
Lines 4218 4209 -9
Branches 643 641 -2
==========================================
+ Hits 4026 4042 +16
+ Misses 114 95 -19
+ Partials 78 72 -6 ☔ View full report in Codecov by Sentry. |
Test Results 17 files - 1 17 suites - 1 1h 0m 15s ⏱️ - 2m 58s Results for commit 78d756f. ± Comparison against base commit 63a7bdd. This pull request removes 2 and adds 11 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
13e1dc0
to
a2fdf3b
Compare
Second-time lucky! The trick was to "move" the initial file on separate branches and then merge the branches. |
See #360 for why a pylint warning is suppressed, related to a changing function signature. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only major thing is to watch out for shadowing.
I suggest that updates porting the typing to 3.10 style is a separate PR or done through Boy Scout Rule.
euphonic/spectra/collections.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful, as this module shadows the collections
stdlib module within this folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am assuming this is mostly unmodified from the original. If anything's changed, can you highlight it for me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff seems to be working correctly, which is nice! We want to not squash this branch to make sure that keeps working. I'll do a bit of interactive rebasing (i.e. reordering and squashing) to keep the introduced history somewhat manageable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which shadowing scenarios should we worry about? Even in spectra.__init__.py we can from collections import abc
and cannot from collections import Spectrum1DCollection
. It looks like the euphonic.spectra
namespace is keeping things isolated properly.
I suppose in some other file somebody could from euphonic.spectra import collections
but I don't think that will pollute other modules unexpectedly? I can even do it in euphonic/__init__.py without breaking tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it's saying that the entire file has changed (which is true) and I wasn't going to read through every line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it's saying that the entire file has changed (which is true) and I wasn't going to read through every line.
That's odd. I get the folded "large diff" buttons
[screenshot]
which unfold to a proper diff
[screenshot]
I appreciate there's a lot there though, I'm doing a scout of commit history to see if there are any significant changes worth bringing extra attention to.
Note I'm referring to collections.py
not base.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly if in spectra/init.py I try
from . import collections from collections import Spectrum1DCollectionthe first import works and the second one fails; somehow stdlib took priority!
Yeah, the issue I had was from starting the Python interpreter/having PYTHONPATH
in the folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note I'm referring to
collections.py
notbase.py
Gotcha, that one has working blame but diff is less helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the issue I had was from starting the Python interpreter/having
PYTHONPATH
in the folder.
Ah yes, there could be a problem if running things from inside the spectra folder, I hadn't thought about that. I don't expect it will happen to me but it might happen to someone and be quite painful to figure out.
I suppose it could be named spectrum_collection
then. Or just collection
but that's asking for problems with typos...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that provided there's awareness, that's a good start. I'm happy for this to go in.
45093a2
to
e5abce6
Compare
These are mostly pre-existing issues I can't do much about the "too many arguments" on broadening methods as this is established API and would be a breaking change.
We can't fix this until v2 because it would be an API break
- Add missing "bad sequence" cases for Spectrum1DCollection - check bad broadening type in Spectrum1DCollection - Fix typo in test name for Spectrum2DCollection
- Add a missing test docstring - Restore lost docstring parameter to assert_regular_bins
e5abce6
to
15577bb
Compare
Co-authored-by: Jacob Wilkins <[email protected]>
That's interesting, this windows test failure looks similar to the ones we see on Conda-forge https://github.com/pace-neutrons/Euphonic/actions/runs/12948116067/job/36116091358?pr=359#logs And it passes on a re-run 😞 . There seems to be something flaky/non-deterministic going on? But it only ever happens on Windows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy for this to go in once you're happy with the tests, given we're aware of the risk of shadowing, I don't think it'll be a major concern like you say.
Many thanks for review, appreciate this sort of refactor is never much fun to look at! |
Closes #358