-
Notifications
You must be signed in to change notification settings - Fork 26
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
Simplify feature bounds using np.nan instead of masking #283
Conversation
Partially masked arrays are not well supported, and required elaborate workaround for pretty printing. Here we use a structured array type, and represent "fixed" bounds with np.nan instead of masking. I.e. non is interpreted as the same as negative or positive infinity, unless both bound are nan, which indicates a fixed parameter.
A normal masked column using structured numpy arrays and nan for both bounds when fixed now suffices.
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 fully support the main concept of this pull request. The ('val' 'min' 'max') datatype feels nice and explicit. Much better than the cryptic 3-tuples from before (where you always had to index on 0, 1, or 2 to addres the needed value)
There are some mistakes, but I fixed them myself to see how the code would continue.
I got it working up to where the Features table is loaded. But the new data type and way of addressing the values, makes it so the code in base.py
no longer works. I /could/ try to fix the base.py code. But would very much like to avoid this, as we will remove it soon...
While working on the representation, I also stamped out the f.meta['pahfit_format']='.2f'
f['wavelength'].meta['pahfit_format']='.3f' yielding:
To be documented somewhere. |
It looks like all of this is working as intended. At least until the actual until the Features -> astropy model part. We cannot really make all the tests succeed for this, without revising all the pieces of code that directly address the Features table (I tried to make things work for a bit, but there are more of these than I expected). Especially, I cannot justify revising all of base.py just to make the tests work, since I aim to delete it soon, when replaced by APFitter. If we merge this, then we will have to continue in this broken state until I have integrated and adapted APFitter. I suggest we merge the units pull request first (the extended version I just suggested, #284 ). In that case, the tests are still working, at least on my machine. And the plot rework #281 too. After that, we can do the big break: merge this, and then include my internal API rework (which will be easier to adapt to the new Features format). |
This sounds good. What type of updates to APFitter do you mean? |
Things that do not work anymore
The new columns are a structured array, instead of a regular 2D array, so there are some restrictions. |
Also do not worry about soon-to-be-forgotten |
Partially masked arrays are not really well supported, and required elaborate workarounds for pretty printing. Here we switch to using a structured array type (
val
,min
,max
fields), and represent "fixed" bounds with a pair ofnp.nan
values formin
andmax
, instead of masking them. I.e.nan
is interpreted as the same as negative or positive infinity, unless both bounds arenan
, which indicates a fixed parameter."Fully open" (unconstrained) bounds are expressed just as before, with
(-np.inf, np.inf)
. But in general: don't do those ;).