Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

DEP: Deprecate ma.round_ and add warning test#28899

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
dineshcsdev wants to merge6 commits intonumpy:main
base:main
Choose a base branch
Loading
fromdineshcsdev:fix-ma-round-deprecation

Conversation

dineshcsdev
Copy link

@dineshcsdevdineshcsdev commentedMay 4, 2025
edited
Loading

Deprecate ma.round_ and add warning test

@jorenhamjorenham changed the titleDeprecate ma.round_ and add warning testDEP: Deprecate ma.round_ and add warning testMay 4, 2025
Copy link
Member

@mattipmattip left a comment

Choose a reason for hiding this comment

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

You can run locally to fix the failing tests.

with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
ma.round_([1.234, 2.345])
assert any("deprecated" in str(warning.message) for warning in w), "No deprecation warning!"
Copy link
Member

Choose a reason for hiding this comment

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

Rather than adding here, add to numpy/_core/tests/test_deprecations.py

Copy link
Contributor

Choose a reason for hiding this comment

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

There may also be less boilierplate via i.e,with pytest.deprecated_call(match='deprecated'):

Copy link
Member

Choose a reason for hiding this comment

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

This should be deleted

@dineshcsdev
Copy link
Author

I’ve removed the separate test_round_warning.py file and moved the test into numpy/core/tests/test_deprecations.py as suggested.
The test now uses pytest.deprecated_call(match="deprecated") to reduce boilerplate.

@ngoldbaum
Copy link
Member

Please try to build numpy and run the tests locally before pushing to run CI. Usingspin helps with this.

This also needs a release note.

@ngoldbaumngoldbaum added the 56 - Needs Release Note.Needs an entry in doc/release/upcoming_changes labelMay 5, 2025
@dineshcsdev
Copy link
Author

Thanks for the feedback! 🙌
I’ll work on building NumPy locally and run the tests using spin before pushing again.
Also, I’ll add the missing release note in the correct format as per the NumPy release note guidelines.

Will update the PR shortly.

Copy link
Member

@mattipmattip left a comment

Choose a reason for hiding this comment

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

Please run the tests locally before pushing a git change.

Comment on lines 1 to 2
Deprecate `ma.round_` function
------------------------------
Copy link
Member

Choose a reason for hiding this comment

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

RST needs two quotes.

Suggested change
Deprecate `ma.round_` function
------------------------------
Deprecate ``ma.round_``
-----------------------

with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
ma.round_([1.234, 2.345])
assert any("deprecated" in str(warning.message) for warning in w), "No deprecation warning!"
Copy link
Member

Choose a reason for hiding this comment

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

This should be deleted

@@ -7,6 +7,9 @@
import pytest
import tempfile
import re
import numpy.ma as ma


Copy link
Member

Choose a reason for hiding this comment

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

Linting complains about too many blank lines here

Copy link
Member

Choose a reason for hiding this comment

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

The extra line is causing linting failures. Please fix.

@@ -8176,8 +8176,13 @@ def round_(a, decimals=0, out=None):
return out


round = round_
Copy link
Member

Choose a reason for hiding this comment

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

On line 8123 above you need to change the function name fromround_ toround

Copy link
Member

Choose a reason for hiding this comment

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

You also need to examine and change the documentation to useround instead ofround_. See the Examples section starting on line 8146.

@dineshcsdev
Copy link
Author

I've addressed all the feedback:

  1. Fixed the RST format in the release note with proper double backticks
  2. Fixed the function implementation in core.py to properly deprecateround_ and redirect toround
  3. Fixed the spacing issue in test_deprecations.py
  4. Built and tested locally with spin

Thank you for your guidance!

Copy link
Member

@jorenhamjorenham left a comment

Choose a reason for hiding this comment

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

It would help to also announce the deprecation in the typing stubs:

numpy/numpy/ma/core.pyi

Lines 1294 to 1295 inde784cd

defround_(a,decimals=...,out=...): ...
round=round_

You can use the@deprecated decorator fromtyping_extensions for this (docs).
Be careful to only deprecateround_, and not alsoround

@dineshcsdev
Copy link
Author

@jorenham your issue changed to another pr due to some technical issue I'm sorry about that you can view here Dinesh-0813:fix-deprecate-ma-round#28917 sorry for the trouble

jorenham reacted with thumbs up emoji

@jorenhamjorenham mentioned this pull requestMay 7, 2025
Copy link
Member

@mattipmattip left a comment

Choose a reason for hiding this comment

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

You should check the reasons CI is failing, and fix them. I pointed out a few, there may be more.

@@ -7,6 +7,9 @@
import pytest
import tempfile
import re
import numpy.ma as ma


Copy link
Member

Choose a reason for hiding this comment

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

The extra line is causing linting failures. Please fix.

@@ -8176,8 +8176,13 @@ def round_(a, decimals=0, out=None):
return out


round = round_
Copy link
Member

Choose a reason for hiding this comment

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

You also need to examine and change the documentation to useround instead ofround_. See the Examples section starting on line 8146.

@dineshcsdev
Copy link
Author

This PR renames the internal functionround_ toround innumpy.ma.core, aligning it with NumPy's naming conventions and improving clarity. Associated docstrings and usages have been updated accordingly.

@mattip
Copy link
Member

Tests are still failing. Also please add the necessary changes to typing.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@mattipmattipmattip left review comments

@jorenhamjorenhamjorenham left review comments

@tylerjereddytylerjereddyAwaiting requested review from tylerjereddy

Assignees
No one assigned
Labels
07 - Deprecation56 - Needs Release Note.Needs an entry in doc/release/upcoming_changescomponent: numpy.mamasked arrays
Projects
Status: Pending authors' response
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@dineshcsdev@ngoldbaum@mattip@jorenham@tylerjereddy

[8]ページ先頭

©2009-2025 Movatter.jp