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
Add kwargs to to_mapping
#12710
Add kwargs to to_mapping
#12710
Conversation
👋 Thank you for your draft pull request! Do you know that you can use |
Add ``cosmology_as_str`` and ``move_from_meta`` to customize how the cosmology class and metadata are returned, respectively. Signed-off-by: Nathaniel Starkman (@nstarman) <nstarkman@protonmail.com>
91a38b9
to
2f06ec0
Compare
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.
Looks good apart from something unrelated to this PR (so your choice whether to fix it here or elsewhere)
astropy/cosmology/io/mapping.py
Outdated
>>> from astropy.cosmology import Planck18 | ||
>>> Planck18.to_format('mapping', move_from_meta=True) | ||
{'cosmology': <class 'astropy.cosmology.flrw.FlatLambdaCDM'>, | ||
'name': 'Planck18', 'Oc0': 0.2607, 'n': 0.9665, 'sigma8': 0.8102, ... | ||
""" | ||
if not issubclass(cls, (dict, Mapping)): | ||
raise TypeError(f"'cls' must be a (sub)class of dict or Mapping, not {type(cls)}") |
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.
Here, since cls
is a class, type
is misplaced, right?
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.
Yes. thanks! I'll fix it here.
Co-authored-by: Marten van Kerkwijk <mhvk@astro.utoronto.ca> Signed-off-by: Nathaniel Starkman (@nstarman) <nstarkman@protonmail.com>
Add
cosmology_as_str
andmove_from_meta
to customize how the cosmology class and metadata are returned, respectively.Signed-off-by: Nathaniel Starkman (@nstarman) nstarkman@protonmail.com
Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
Extra CI
label.no-changelog-entry-needed
label. If this is a manual backport, use theskip-changelog-checks
label unless special changelog handling is necessary.astropy-bot
check might be missing; do not let the green checkmark fool you.backport-X.Y.x
label(s) before merge.