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

Add kwargs to to_mapping #12710

Merged
merged 2 commits into from Jan 11, 2022

Conversation

nstarman
Copy link
Member

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

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.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see "When to rebase and squash commits".
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the Extra CI label.
  • Is a change log needed? If yes, did the change log check pass? If no, add the no-changelog-entry-needed label. If this is a manual backport, use the skip-changelog-checks label unless special changelog handling is necessary.
  • Is a milestone set? Milestone must be set but astropy-bot check might be missing; do not let the green checkmark fool you.
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate backport-X.Y.x label(s) before merge.

@nstarman nstarman added this to the v5.1 milestone Jan 10, 2022
@nstarman nstarman added this to In progress (PR) in Cosmology, the Expansion via automation Jan 10, 2022
@github-actions
Copy link

👋 Thank you for your draft pull request! Do you know that you can use [ci skip] or [skip ci] in your commit messages to skip running continuous integration tests until you are ready?

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>
@nstarman nstarman requested a review from mhvk January 10, 2022 21:34
@nstarman nstarman force-pushed the cosmo-add-arguments-to-to_mapping branch from 91a38b9 to 2f06ec0 Compare January 10, 2022 21:34
@nstarman nstarman marked this pull request as ready for review January 10, 2022 21:34
Copy link
Contributor

@mhvk mhvk left a 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)

>>> 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)}")
Copy link
Contributor

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?

Copy link
Member Author

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.

Cosmology, the Expansion automation moved this from In progress (PR) to Reviewer approved Jan 10, 2022
Co-authored-by: Marten van Kerkwijk <mhvk@astro.utoronto.ca>
Signed-off-by: Nathaniel Starkman (@nstarman) <nstarkman@protonmail.com>
@nstarman nstarman added the 💤 merge-when-ci-passes Do not use: We have auto-merge option now. label Jan 10, 2022
@nstarman nstarman merged commit 78f9ff9 into astropy:main Jan 11, 2022
Cosmology, the Expansion automation moved this from Reviewer approved to Done Jan 11, 2022
@nstarman nstarman deleted the cosmo-add-arguments-to-to_mapping branch January 11, 2022 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cosmology 💤 merge-when-ci-passes Do not use: We have auto-merge option now.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants