Skip to content

Remove np.ndarray.ptp() mention from the docs - #16583

Merged
mhvk merged 1 commit into
astropy:mainfrom
eerovaher:rm-ndarray-ptp-mention
Jun 18, 2024
Merged

mhvk merged 1 commit into
astropy:mainfrom
eerovaher:rm-ndarray-ptp-mention

Conversation

@eerovaher

Copy link
Copy Markdown
Member

Description

The numpy.ndarray.ptp() method was removed in 2.0, so trying to refer to it is causing documentation build failures.

This should be backported, but astropy 6.1.1 has already been released and the branch and milestone for 6.1.2 has not been created yet.

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

The `numpy.ndarray.ptp()` method was removed in 2.0, so trying to refer
to it is causing documentation build failures.
@github-actions

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 instructions for rebase and squash.
  • 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?
  • 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.

Comment thread astropy/time/core.py
This is similar to :meth:`~numpy.ndarray.ptp`, but adapted to ensure
that the full precision given by the two doubles ``jd1`` and ``jd2``
is used.
This method is similar to the :func:`numpy.ptp` function, but

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.

good catch, though I'm thinking the phrasing might become increasingly confusing as numpy 1.x fades away in usage. How about this ?

Suggested change
This method is similar to the :func:`numpy.ptp` function, but
This method is similar to the :func:`numpy.ptp` legacy function, but

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The np.ndarray.ptp() method has been removed, but the np.ptp() function is still there and I am not aware of any plans to remove it, so it's not a legacy function.

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.

see ? it is confusing 😅
(thanks for clarifying)

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.

Yes, not a legacy function. However, since we are deprecating this method, perhaps the text should still be adjusted. How about,

This method is meant to mimic the same method on `~numpy.ndarray`, but
adapted to ensure that the full precision given by the two doubles
``jd1`` and ``jd2`` is used. It is deprecated when using numpy 2.0, since
the `~numpy.ndarray` method has been removed in that version.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We should not mention deprecations in docstrings because our deprecated decorator edits docstrings automatically. If the default text deprecated adds to the docstring is not good enough then a custom text should be specified through the decorator's message argument.

This pull request was meant to be a quick fix to prevent documentation builds from failing, so discussing how to phrase the deprecation message delays merging and causes problems in other pull requests.

@saimn saimn added this to the v6.1.2 milestone Jun 17, 2024
@saimn

saimn commented Jun 17, 2024

Copy link
Copy Markdown
Contributor

I created the v6.1.2 milestone.

@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.

Yes, thanks! A slight suggested edit to the docstring in-line.

Comment thread astropy/time/core.py
This is similar to :meth:`~numpy.ndarray.ptp`, but adapted to ensure
that the full precision given by the two doubles ``jd1`` and ``jd2``
is used.
This method is similar to the :func:`numpy.ptp` function, but

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.

Yes, not a legacy function. However, since we are deprecating this method, perhaps the text should still be adjusted. How about,

This method is meant to mimic the same method on `~numpy.ndarray`, but
adapted to ensure that the full precision given by the two doubles
``jd1`` and ``jd2`` is used. It is deprecated when using numpy 2.0, since
the `~numpy.ndarray` method has been removed in that version.

@mhvk

mhvk commented Jun 18, 2024

Copy link
Copy Markdown
Contributor

In #16583 (reference) @neutrinoceros mentioned that perhaps we should just have deprecated .ptp() unconditionally and suggested changing it to that state here. I'm fine with that for 6.1.2, but also fine with just leaving things as they are.

@eerovaher

Copy link
Copy Markdown
Member Author

For the users of astropy 6.1.0 or 6.1.1 who are using numpy < 2.0 the TimeBase.ptp() method is not deprecated. If we deprecate the method unconditionally in 6.1.2 and those users upgrade astropy but not numpy then they will have a brand new deprecation in a bugfix release. That would go against APE 2, so we should not do that. We should instead deprecate TimeBase.ptp() unconditionally starting from 6.2.0, but that can't be done in this pull request because this needs to be backported to prevent documentation build failures in the v6.1.x branch. Deprecating in 6.2.0 would not be a problem for users who have already started using numpy 2.0 because they will just see a longer deprecation period, which does not break any rules.

@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.

@eerovaher - you're right on all points - let's get this in!

@mhvk
mhvk merged commit 5d1b667 into astropy:main Jun 18, 2024
meeseeksmachine pushed a commit to meeseeksmachine/astropy that referenced this pull request Jun 18, 2024
@eerovaher
eerovaher deleted the rm-ndarray-ptp-mention branch June 18, 2024 14:35
eerovaher added a commit that referenced this pull request Jun 18, 2024
…583-on-v6.1.x

Backport PR #16583 on branch v6.1.x (Remove `np.ndarray.ptp()` mention from the docs)
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.

4 participants