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
DM-18748: Header items can be present but undefined #17
Conversation
This means that "key in header" is not a sufficient test. Add new support methods to base class to allow translators to test for present and defined in one go.
Otherwise the nice ordered dict mapping to a FITS header will be sorted alphabetically in the YAML file.
|
||
return True | ||
|
||
def is_key_ok(self, keyword): |
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 imagine there is some clever reason that explains why this is necessary/different to is_keyword_defined()
, but as it stands, both the docstrings, and the fact that this just directly calls is_keyword_defined()
seems odd to me. Is this just a pass-through with a more descriptive method name to allow for neater extension in the future, should it be needed, or something?
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.
There have to be two different methods because I need the can_translate
methods to be able to do the same definedness checks. I'm happy to change the names. is_keyword_defined
is a static method that can be used by class methods. is_key_ok
is for instances of translations.
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.
No no, it's fine, that makes sense, thanks!
@@ -82,7 +82,7 @@ def can_translate(cls, header, filename=None): | |||
return header["INSTRUME"] == "Hyper Suprime-Cam" | |||
|
|||
for k in ("EXP-ID", "FRAMEID"): | |||
if k in header: | |||
if cls.is_keyword_defined(header, k): |
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.
Why do you call is_keyword_defined()
here and not is_key_ok()
like everywhere else? (I realise this is an odd question having just asserted that there is no difference in functionality)
@@ -80,7 +80,7 @@ def can_translate(cls, header, filename=None): | |||
return header["INSTRUME"] == "SuprimeCam" | |||
|
|||
for k in ("EXP-ID", "FRAMEID"): | |||
if k in header: | |||
if cls.is_keyword_defined(header, k): |
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.
And again here.
This means that "key in header" is not a sufficient test.