Skip to content

Deprecate unused units.format.Unscaled format - #14417

Merged
mhvk merged 1 commit into
astropy:mainfrom
mhvk:units-format-deprecate-unscaled
Feb 20, 2023
Merged

mhvk merged 1 commit into
astropy:mainfrom
mhvk:units-format-deprecate-unscaled

Conversation

@mhvk

@mhvk mhvk commented Feb 19, 2023 •

Copy link
Copy Markdown
Contributor

Description

This pull request is to deprecate the unused "unscaled" format in units. I split this off from #14416 since on looking at that PR again, I realized it is just becoming very long and hard to see the logic. Plus, one should not really have API changes in refactoring PRs.

@mhvk mhvk added units API change PRs and issues that change an existing API, possibly requiring a deprecation period labels Feb 19, 2023
@mhvk mhvk added this to the v5.3 milestone Feb 19, 2023
@mhvk
mhvk requested review from nstarman and olebole February 19, 2023 18:35
@github-actions

github-actions Bot commented Feb 19, 2023 •

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • 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. Codestyle issues can be fixed by the bot.
  • 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 this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • Is a milestone set? Milestone must be set but we cannot check for it on Actions; 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.

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just a few in-line comments to help review.

if isinstance(unit, core.CompositeUnit):
parts = []

if cls._show_scale and unit.scale != 1:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removing this means I can refactor to_string elsewhere. But here really it just serves to make everything else independent of the deprecated Unscaled class.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My understanding of a separate deprecatation PR would be to have one just with the @deprecated flag in (and some followups like removed tests). Is there a specific reason to have other code changes here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it is OK, as here it really helps to ensure that once the deprecation period is over, all one has to do is to remove the class (one could argue about the test, but since I just added it, I think it is fine to remove it already!).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OK, thanks.

_show_scale = False
@classmethod
def to_string(cls, unit):
if unit.scale != 1:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This just ensures there is no scale to show.

"format_spec, string",
[
("generic", "dB(1 / m)"),
("unscaled", "dB(1 / m)"),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was added only in #14413, so no big loss to remove it. Otherwise, "unscaled" was not used at all!

@mhvk mhvk added units and removed units labels Feb 19, 2023

@olebole olebole left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is quite useful (I didn't fully understand the use of that formatting); so 👍

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am approving by proxy but will let someone else do the merge. Thanks, everyone!

@mhvk
mhvk merged commit e3fa58e into astropy:main Feb 20, 2023
@mhvk
mhvk deleted the units-format-deprecate-unscaled branch February 20, 2023 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API change PRs and issues that change an existing API, possibly requiring a deprecation period units

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants