-
Notifications
You must be signed in to change notification settings - Fork 52
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
Minor xspec additions #2215
Minor xspec additions #2215
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2215 +/- ##
==========================================
+ Coverage 87.44% 87.47% +0.02%
==========================================
Files 84 84
Lines 29848 29860 +12
Branches 3833 3831 -2
==========================================
+ Hits 26101 26119 +18
+ Misses 3637 3631 -6
Partials 110 110
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
There is no functional change to the tests, it is just the way the tests are written (the issue is whether the ui symbol is known to have the load_[xs]table_model routines).
b419578
to
2d3f88e
Compare
2d3f88e
to
eccb93c
Compare
Change the test_set_xsstate_missing_key so that it called once per key to check, using a parametrized argument, rather than do them all at once. This makes the code slightly cleaner (no need to copy the test dict) and allows testing all keys even when one fails, at the expense of probably being slightly slower.
Since the return type depends on the arguments sent to the routine, we can provide more-precise typing. Update to use Python 3.10 syntax (e.g. no need for Optional and Union). It's not 100% clear from the typing documentation whether you should, or need to, type the non-overloaded definition (I am reading proposed changes to the documentation that doesn't make it clear); however, if you don't set them then the annotations do not get set and so they don't appear in help output. It also avoids an error reported by pyright, so it seems worth doing. Also add an example to the documentation for get_xsabund. In looking at the XSPEC abundances, I noted that we did not document the "felc" table, so do so for set_xsabund. In doing this I re-arranged the list in the documentation so it's in alphabetical order (ascending).
Allow the filename argument to read_xstable_model to be a Path object as well as a str. To support typing this code I changed the creation of the XSTableModel so that the call is explicit (in matching the data that has just been read in to the constructor call) rather than just using *cols. There should be no functional change in behavior here.
eeaf7a5
to
40a509a
Compare
Previously set_xsstate required all the settings to be present before it could work. This has its advantages, but does limit things as you can't restore the state if Sherpa has added a new field. So, we now just process those fields that are available and skip those that are not. As part of this work the internals to the XSPEC module have changed to use a single dictionary for storing the data we need to record the XSPEC state, rather than having multiple (two) variables for this. This is in part because the current XSPEC interface that Sherpa uses does not allow Sherpa to ask XSPEC what its state is, so the code has to try and record these changes.
40a509a
to
8fb00fe
Compare
Co-authored-by: Hans Moritz Günther <[email protected]>
Change the name from 'key' to 'miss_key', to make sure it is distinct from 'key', which gets its value changed within the routine.
I don't see any functional change, only a renaming from |
Because it separates the input argument (that is parametrized, aka |
Makes sense - and that subtlety also explains why I didn't notice the change on review, when Gh highlights just the changes lines and not the others where the word "key" also appears. |
Summary
Minor changes to the XSPEC module, including added documentation to the set_xsabund routine to note the availability of the "felc" table, and set_xsstate no-longer requires all fields to be present.
Details
This is a small subset of the changes from #1615 that do not require changing the C++ interface. The changes are (not in order, and not per commit):
Path
object as well as a string; this is an "internal" routine so it is not going to change most people's livessherpa/astro/xspec/__init.py
to use Python 10 syntax (can avoidUnion
andOptional
)get_xsabund
help(set_xsabund)
will see the types