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

Support callable fix_values in _ValidHDU.req_cards #5938

Open
tbabej opened this issue Apr 3, 2017 · 0 comments
Open

Support callable fix_values in _ValidHDU.req_cards #5938

tbabej opened this issue Apr 3, 2017 · 0 comments
Labels

Comments

@tbabej
Copy link
Contributor

tbabej commented Apr 3, 2017

This is a follow up for #5935.

The API of the _ValidHDU.req_cards method requires a fix_value, which is then, however, encapsulated inside a function (see code snipped below). In some cases (i.e. #5935) a dynamic fix_value is useful, but to do that one has to precompute it using a function call, only to have the result encapsulated inside another function.

From astropy/io/fits/hdu/base.py:1155

    if fixable:
        def fix(self=self, keyword=keyword, val=fix_value):
            self._header[keyword] = fix_value

    errs.append(self.run_option(option, err_text=err_text,
                fix_text=fix_text, fix=fix, fixable=fixable))

Instead of performing this convoluted function wrapping-unwrapping the req_cards could check if fix_value is a callable, and if it is, it would be interpreted as the method performing the fix itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants