-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add functionality to allow user to modify abundances #258
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #258 +/- ##
==========================================
+ Coverage 91.90% 92.00% +0.09%
==========================================
Files 38 38
Lines 2718 2752 +34
==========================================
+ Hits 2498 2532 +34
Misses 220 220 ☔ View full report in Codecov by Sentry. |
One caveat: the user can change the abundance of an individual ion without updating it for the whole element. I'm not sure whether that's worth fixing? That is,
The abundance of an ion need not be the same for the other ions, or for the element. User beware! This could be changed easily by updating all the ions simultaneously, if preferred. |
The missing abundance test is failing because I've instantiated abundance in the |
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.
Thanks for tackling this. I've left a few suggestions that I think will clear things up and also fix the test. This also needs a test for the case of instantiating an ion with a scalar value of the abundance. This has proved to be a little thornier than I thought!
The one complication of this that I didn't anticipate is how this affects _instance_kwargs
. The _instance_kwargs
property is just a convenience property for sort-of-serializing the input arguments used to create that instance, including the abundance information. As it currently stands in this PR, a custom abundance value will not be passed to a new instance created with _instance_kwargs
because in that case, an entry is not created in self._dset_names
. We could of course just add abundance
to _instance_kwargs
, but just doing this means information about abundance dataset (if any) was used. I would suggest adding a check in _instance_kwargs
that checks if there is an abundance
key in _dset_names
and if there is, passes this value in as 'abundance'
in _instance_kwargs
and if not, just pass abundance
. The logic that gets applied in the setter in the new instance then takes care of the rest. This behavior should also get a test.
That's partially just the price we pay for using Python (i.e. no actually private variables). Although, honestly I'm not too worried here. An We could add a check in |
I made one further change to the
|
Thanks for your patience with this. I think this PR just needs three more things:
I'm also happy to add these if you don't have time to do so. |
Right, lots to keep to track of! Hopefully this latest one covers the rest. I added tests for all three of these . . . . . . and now I'm stumped. Why is it not finding the photospheric abundance set? Works just fine in the terminal. |
It's because the tests are run on a minimal version of the database in order to reduce the amount of time spent building the HDF5 database every time the tests are run. When you run the tests on your machine, you're probably using your prebuilt version of the database. The full list of files inlcuded in the test database is in I also fixed up some of the tests that I had previously written that used the old |
Thanks for your work on this and for your patience! |
Fixes #237
This PR adds a setter for the
abundance
property on theIon
andElement
objects such that a user can supply a custom value of the abundance when creating the object or set theabundance
property after instantiation.Please review, and check whether there's any additional logic worth adding.
Looks functional: