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
Check for and prevent initialization of NDData with Quantity #2380
Conversation
Seems okay to me for the time being. |
@mwcraig - can you rebase this? |
Closes astropy#2374, though admittedly in an unsatisfactory way.
This is good to go |
I kind of like the alternative you are suggestion to allow a quantity to be passed and do the right thing. @eteq, what do you think? |
A longer-term change would be to allow (but not require) Haven't really thought this through (and probably shouldn't until ccdproc is closer to ready for some external eyes), but the implementation of, say, mask, might look something like this: def mask(self):
try:
return self.data.mask
except AttributeError:
return self._mask |
To clarify, if you want the simple ability to set |
I agree with @astrofrog that this "simple ability" would be a very useful thing - that is, you can give a I think for the longer-term, we either don't want to use |
@eteq @astrofrog -- I put in the ability to initialize with a I decided that it was OK to use an uncertainty without units for a |
I think this behavior all makes sense and looks good to me, @mwcraig - can you update the CHANGES.rst to reflect what it's now doing? @astrofrog, look good to you other than that? |
1 similar comment
I think this behavior all makes sense and looks good to me, @mwcraig - can you update the CHANGES.rst to reflect what it's now doing? @astrofrog, look good to you other than that? |
👍 |
Looks good. Merging! |
Allow initialization of NDData with Quantity
This PR simply raises an error if you try to initialize
NDData
orStdDevUncertainty
with aQuantity
(see #2374)Once I know which release this is targeted for (if any--it may be completely the wrong way to go) I'll add a changelog entry.
I could, if desired, do something a little more sophisticated (and perhaps more sensible) than this, though I don't think what is below is a long-term solution:
NDData
with aQuantity
could set theNDData.data
(as anumpy.ndarray
) andNDData.unit
StdDevUncertainty
withQuantity
could convert that quantity to the units ofStdDevUncertainty.parent_nddata
then setStdDevUncertainty.array
with the result, raising an error ifparent_nddata is None
.