Nexus: Rework physical_system.py#6010
Conversation
…ively finish `IonSpecies`
…tronsBase`, update docstrings, add error tests
…s as keys, add hash function for making unordered sets
…init__()`, remove some unnecessary functions
…tem.ae_pp_species()`
…failing `test_pwscf.py` test
…ntially completed
|
A few points upon a first skim:
I suggest we approach these changes in the following way:
|
|
I'll address these point by point.
The vast majority of this PR is in the testing module, which is +1,758/-379. There are another +428 lines of docstrings that I wrote for this, which accounts for 2186 lines. The actual code changes are only ~900 lines, and a not-insignificant amount of that is whitespace changes. This PR is not really a +3008/-1181, it's more like a +900/-900, when judging by actual code.
The testing changes amount to the following (in
To summarize, the only real changes to the testing are
These classes provide an intuitive API, and several useful properties/functions so that developers and users don't need to custom-write their own versions. This makes them more resilient to a refactor since we can maintain the user interface while changing the backend.
The previous API was full of confusing behavior and functions that have been more appropriately relocated to other classes. Some of the functions that were removed are Many functions were simply poorly constructed, e.g. There are more examples I could give, but the new version and the newly available functions are simply far more convenient and produce expected behavior, without the chance for behind the scenes changes to the system. This PR absolutely should not be broken into 3 separate PRs. The total number of lines changed that are actual code changes is much smaller than the displayed +3008/-1181, and it is likely less than a thousand total. The changes to the test functions only make it more robust, and do not change what we were testing before. The primary reason against splitting this PR is that it just leads to messy intermediate times while people could be developing against the new system, and are instead stuck with the old, undocumented, and nebulous version. In the end it just will take longer to tell if anything will actually break existing user code since we will have less time with people using the |
Proposed changes
This PR is a near-total rewrite of
physical_system.pyto remove the previous inheritance tree and replace with more specific classes.Some notable changes are the removal of
Matter,Particle,Particles,Ion, andPseudoIon. These have been replaced withElectrons,Positrons, andIonSpecies. The new classes offer a far less flexible API, which enhances discoverability and clarity.Great care was taken to maintain the behavior of
generate_physical_system, so in theory no user code should be broken by this change, however all I have to go on are the tests.What type(s) of changes does this code introduce?
Does this introduce a breaking change?
What systems has this change been tested on?
Laptop, Fedora Linux 43 (KDE Plasma Desktop Edition)
AMD Ryzen 7 PRO 7840U (8 cores, 16 logical processors)
Checklist