Skip to content

register structured units with yaml serialization - #12492

Merged
mhvk merged 1 commit into
astropy:mainfrom
nstarman:units-structured-to-yaml
Nov 18, 2021
Merged

mhvk merged 1 commit into
astropy:mainfrom
nstarman:units-structured-to-yaml

Conversation

@nstarman

@nstarman nstarman commented Nov 18, 2021 •

Copy link
Copy Markdown
Member

This fixes the structured unit serialization.
Doing the same for a numpy.void will take a separate commit.

The following work

from astropy.io.misc.yaml import dump, load
import astropy.units as u
unit = u.Unit("(eV, eV, m)")
dump(unit)
arr = u.Quantity([(0, 0, 0.6), ], u.Unit("(eV, eV, m)"))
dump(arr)

This does not

arr = u.Quantity((0, 0, 0.6), u.Unit("(eV, eV, m)"))
dump(arr)

Fixes #12485

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.

Co-authored-by: Marten van Kerkwijk <[email protected]>
Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
@nstarman
nstarman force-pushed the units-structured-to-yaml branch from ad354b5 to a58cad0 Compare November 18, 2021 06:24
@nstarman
nstarman requested a review from mhvk November 18, 2021 06:24
@nstarman nstarman added this to the v5.1 milestone Nov 18, 2021

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good! The failures are unrelated, so approved! The numpy.void issue seems separate, as Quantity((1., 2.), dtype='f8,f8', unit=u.m) fails too. Would you mind raising a separate issue for it?

@mhvk
mhvk merged commit de53bdc into astropy:main Nov 18, 2021
@mhvk

mhvk commented Nov 18, 2021

Copy link
Copy Markdown
Contributor

Damn, why do I think about this only after merging? Isn't this really a bugfix?

@nstarman

Copy link
Copy Markdown
Member Author

I suppose it is. Backport?

@nstarman
nstarman deleted the units-structured-to-yaml branch November 18, 2021 19:11
@nstarman

nstarman commented Nov 18, 2021 •

Copy link
Copy Markdown
Member Author

I suppose that also requires changing the changelog fragment to a bug fix

@mhvk

mhvk commented Dec 3, 2021

Copy link
Copy Markdown
Contributor

@meeseeksdev backport to v5.0.x

meeseeksmachine pushed a commit to meeseeksmachine/astropy that referenced this pull request Dec 3, 2021
@mhvk mhvk added the units label Dec 3, 2021
mhvk added a commit that referenced this pull request Dec 3, 2021
…492-on-v5.0.x

Backport PR #12492 on branch v5.0.x (register structured units with yaml serialization)
@astrofrog

Copy link
Copy Markdown
Member

For the record, the news fragment of this should have been updated to be of type 'bugfix' - I'll make the change for this one.

@astrofrog astrofrog mentioned this pull request Jan 20, 2022
9 tasks
@nstarman

Copy link
Copy Markdown
Member Author

Thanks!

astrofrog added a commit to astrofrog/astropy that referenced this pull request Jan 22, 2022
@astrofrog astrofrog mentioned this pull request Jan 22, 2022
7 of 9 tasks
mhvk added a commit that referenced this pull request Jan 22, 2022
meeseeksmachine pushed a commit to meeseeksmachine/astropy that referenced this pull request Jan 22, 2022
pllim added a commit that referenced this pull request Jan 22, 2022
…772-on-v5.0.x

Backport PR #12772 on branch v5.0.x (Fix changelog fragment type for #12492)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Structured units cannot be yaml serialized

4 participants