Skip to content
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

Merged
merged 4 commits into from Apr 9, 2019
Merged

Conversation

timj
Copy link
Member

@timj timj commented Apr 3, 2019

This means that "key in header" is not a sufficient test.

timj added 3 commits April 3, 2019 13:15
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):

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?

Copy link
Member Author

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.

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):

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):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And again here.

@timj timj merged commit c339726 into master Apr 9, 2019
@timj timj deleted the tickets/DM-18748 branch April 9, 2019 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants