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

DEPR: deprecate astropy.utils.console.terminal_size and stop using it internally #16045

Merged
merged 1 commit into from Feb 16, 2024

Conversation

neutrinoceros
Copy link
Contributor

Description

Since this doesn't seem controversial
Fixes #16042
Currently based onto #16040 to avoid an implicit merge conflict.

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

Copy link

github-actions bot commented Feb 15, 2024

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?
  • 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.

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?

@neutrinoceros
Copy link
Contributor Author

failures are real. Let me check if I can fix that easily.

@neutrinoceros
Copy link
Contributor Author

I fixed the worst ones but there are still a lot and I'm not sure they're actually fixable. Maybe the solution is simply not to deprecate this function.

@neutrinoceros
Copy link
Contributor Author

whoops, I missed that get_terminal_size gave (columns, lines), and terminal_size does the reversed. Should be good now ? 🤞🏻

@neutrinoceros neutrinoceros force-pushed the utils/console/depr/terminal_size branch 2 times, most recently from aa3811d to 2284446 Compare February 15, 2024 11:28
@neutrinoceros
Copy link
Contributor Author

2 remaining failures in Table.pprint tests, that I think are due to slight differences in what the replacement function returns. Without looking too deeply into it, I would assume the function from the standard lib is more reliable so the change could be considered a bug fix. Otherwise it's likely possible to force bug-for-bug compatibility.

@pllim pllim added this to the v6.1.0 milestone Feb 15, 2024
@pllim pllim added the API change PRs and issues that change an existing API, possibly requiring a deprecation period label Feb 15, 2024
@mhvk
Copy link
Contributor

mhvk commented Feb 15, 2024

I think it is OK to adjust the doctests. To be honest, showing 1 line before the ... and 2 after seems better than 1 and 3 (2 and 2 would perhaps be more logical, but, really, no big deal...

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 all good to me! I don't know if you'd want further feedback (maybe @taldcroft, since it is used in table?), but it looks all good to me.

@@ -69,7 +69,6 @@ Time series are specialized kinds of |Table| objects::
2009-05-02T00:48:32.291 6.632337e-04 ... 1.5272264e-03 -1.4998110e-03
2009-05-02T00:49:31.149 6.632584e-04 ... 1.5193661e-03 -1.5074468e-03
... ... ... ... ...
2009-05-11T17:58:22.526 1.014493e-03 ... 3.6121816e-03 3.1950327e-03
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, the usual annoyance that, sadly, doctests just stop when an error is encountered, so you don't necessarily get all of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah that's why I needed two iterations ! thanks for clarifying this !

@mhvk mhvk added the Bug label Feb 15, 2024
@mhvk mhvk marked this pull request as ready for review February 15, 2024 18:55
@mhvk mhvk requested a review from taldcroft as a code owner February 15, 2024 18:55
Copy link
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

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

Cannot merge this until the diff from #16040 is taken back out.

@pllim
Copy link
Member

pllim commented Feb 15, 2024

#16040 is merged. Please rebase. Thanks!

@neutrinoceros
Copy link
Contributor Author

rebased !

@saimn
Copy link
Contributor

saimn commented Feb 16, 2024

whoops, I missed that get_terminal_size gave (columns, lines), and terminal_size does the reversed. Should be good now ?

Also they disagree by 1:

In [3]: shutil.get_terminal_size()
Out[3]: os.terminal_size(columns=96, lines=46)

In [4]: from astropy.utils import console

In [5]: console.terminal_size()
Out[5]: (40, 95)

It seems shutil.get_terminal_size is right, here I can print 96 characters on one line.

@neutrinoceros
Copy link
Contributor Author

yes this is what I hinted to in #16045 (comment) (I could have been more explicit). I think this is also why some doctests adjustments are required.
Actually one of them is still failing, let me switch to draft until I get it back to green.

@neutrinoceros neutrinoceros marked this pull request as draft February 16, 2024 08:06
@@ -270,31 +268,29 @@ time — this returns a |BinnedTimeSeries|::
>>> ts_binned = aggregate_downsample(ts_folded, time_bin_size=0.03 * u.day) # doctest: +REMOTE_DATA +IGNORE_WARNINGS
>>> ts_binned # doctest: +FLOAT_CMP +REMOTE_DATA
<BinnedTimeSeries length=74>
time_bin_start time_bin_size ... pos_corr2 sap_flux_norm
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you're seeing this in split diff, you might be wondering what the actual difference is (it certainly wasn't obvious to me).
What's changed is that some horizontal whitespace was removed on the "pix" column because the row that got removed happened to be have most demanding value in terms of horizontal space (namely, -2.2798192730988376e-05). This is slightly easier to see in unified diff view.

@neutrinoceros
Copy link
Contributor Author

ready at last !

@neutrinoceros neutrinoceros marked this pull request as ready for review February 16, 2024 08:36
@neutrinoceros neutrinoceros changed the title DEPR: deprecate astropy.utils.console.terminal_size DEPR: deprecate astropy.utils.console.terminal_size and stop using it internally Feb 16, 2024
Copy link
Member

@taldcroft taldcroft left a comment

Choose a reason for hiding this comment

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

Looks fine to me.

@taldcroft
Copy link
Member

@mhvk - just curious why you labeled this as a bug?

@mhvk mhvk removed the Bug label Feb 16, 2024
@mhvk
Copy link
Contributor

mhvk commented Feb 16, 2024

Oops, my mistake - I saw a fixes ... and assumed there was also a bug involved. Now removed.

@mhvk
Copy link
Contributor

mhvk commented Feb 16, 2024

@pllim - I think this one is ready (it was rebased following your request); could you check? (And go ahead and merge if it is all OK!)

Copy link
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

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

LGTM now. Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Ehem... US English spells as "favor" but I'll let this slide. 😉

(This is not a serious comment. We traditionally have unresolved debates on US vs UK English.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sure I mix US and UK flavours all the time, so I'm neutral ! (or maybe just inconsistent ?)

@pllim pllim merged commit 89d99f3 into astropy:main Feb 16, 2024
26 of 27 checks passed
@neutrinoceros neutrinoceros deleted the utils/console/depr/terminal_size branch February 17, 2024 09:11
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 table utils
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DEPR: should we deprecate astropy.utils.console.terminal_size ?
5 participants