-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
NDData and NDDataBase Refactor #4270
Conversation
Summary:
I think this is mostly added functionality and should be backwards compatible, except for the But I now know, that some of these changes will be somehow controversial so I would be very happy about comments. |
return self._uncertainty | ||
|
||
@property | ||
def uncertainty_type(self): |
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.
Is the idea here that eventually every NDData
object would have an uncertainty, defaulting to UnknownUncertainty
, eventually? Otherwise it seems like leaving the uncertainty_type
a property of the uncertainty would be easier.
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.
Ah, right, UnknownUncertainty
is at the top of the file.
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.
The uncertainty_type
property was just a convenience I used while I tested the UnknownUncertainty
. I thought I deleted it before pushing - but I forgot.
@wkerzendorf -- could you please take a look at this one? Looks mostly straightforward to me, the one big change is to wrap the uncertainty in an |
@MSeifert04 -- once again, thanks. I gave this a quick look tonight and didn't see any problems with the code, but I'm not sure about dropping the requirement that the uncertainty have an It sounds, though, like your solution is to wrap an uncertainty that does not have an |
@mwcraig - Yes, your summary about the I got the idea from #3714 where @wkerzendorf proposed just such an uncertainty and I modified it a bit to match my Thanks for looking over it! |
I'll have some time tomorrow to take a longer look at the others, and to put a call out on the astropy-dev list for code reviews. I know a bunch of people are at ADASS this week... |
saved in _uncertainty has an uncertainty_type but it's unknown :-) | ||
""" | ||
if isinstance(self._uncertainty, UnknownUncertainty): | ||
return self._uncertainty.array |
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.
Recommend switching this back to return self._uncertainty
In the Hangouts meeting @wkerzendorf and @mwcraig suggested some changes. The current push reflects these:
I skipped the documentation update for now. |
@MSeifert04 -- could you please go ahead and do the documentation changes too (should be minimal, I think, for this one)? |
@mwcraig - I edited the documentation files to reflect the changes and included a section with a summary of the changes. I'm not very happy with the wording, just let me know if anything should be edited. |
|
||
`~astropy.nddata.NDDataBase`: | ||
|
||
+ `NDDataBase.uncertainty.getter`: is now abstract. |
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.
This and the line below are causing the sphinx failures because there is no getter
or setter
method.
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.
Won't be an issue, though, if this just moves to the changelog.
@MSeifert04 -- looks really good, just a few minor inline comments. Most of the bullet points you added to |
by default False. If it is True all other parameters are copied before saving | ||
them as attributes. If False the parameters are only copied if there is no | ||
way of saving them as reference. | ||
+ the ``data`` parameter allows now also ``Masked_Quantity`` objects |
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 don't think Quantity
can be masked yet?
if no ``uncertainty_type`` attribute is present in the uncertainty instead | ||
of raising an Exception. | ||
|
||
- the uncertainty_type of the uncertainty must not be a string |
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.
- Capitalize "the"
- Double backticks around
uncertainty_type
- "must not be anymore." -> "is no longer required to be, but..."
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.
@eteq -- this is a change from what was originally described in the APE but seems sensible to @wkerzendorf and I. IIRC you had strong feelings about this so wanted to point it out.
@MSeifert04 -- looking good, just some minor changes in the changelog entries. |
Apart from the changes, I just found that there is a descriptor lingering in the Since this is completly identical to the meta handling (except that that it implements a setter which isn't present until now) in Would look something like this
|
I think this is a very good idea. and you can subclass this to make the arithmetic operations on them. |
But this PR does not deal with meta, right? Did we merge one of them? |
@MSeifert04 -- could you please open a separate issue to remind us to look at moving metadata to the one in utils? That way we can get this merged sooner but still remember we need to come back to the issue. |
@mwcraig I've opened a seperate issue and will make a seperate PR as soon as this is merged. |
@MSeifert04 -- looks like this just needs a rebase (probably related to the changelog) then it is ready to merge. |
nd = NDData([1, 2, 3], meta={}) | ||
assert len(nd.meta) == 0 | ||
nd = NDData([1, 2, 3]) | ||
assert isinstance(nd.meta, OrderedDict) |
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.
This is where the test failures are happening:
_______________________________ test_param_meta ________________________________
def test_param_meta():
# everything dict-like is allowed
with pytest.raises(TypeError):
NDData([1], meta=3)
nd = NDData([1, 2, 3], meta={})
assert len(nd.meta) == 0
nd = NDData([1, 2, 3])
> assert isinstance(nd.meta, OrderedDict)
E assert isinstance(OrderedDict(), OrderedDict)
E + where OrderedDict() = NDData([1, 2, 3]).meta
Note to self: also checked this with ccdproc and nothing broke... |
🎉 Thanks again for this @MSeifert04! |
NDData and NDDataBase Refactor
This is the refactor of
NDDataBase
andNDData
(from #4234). More comments will follow as soon as I get the splitted parts to work.edit 12/22/2015 to add checklist for completion:
uncertainty_type
(ping list notifying about this)UnknownUncertainty
is created byNDData