Skip to content

Navigation Menu

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

Appearance settings

MAINT: Hide decorator from pytest traceback #28510

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

Merged
merged 1 commit into from
Mar 14, 2025

Conversation

charris
Copy link
Member

@charris charris commented Mar 14, 2025

Backport of #28211.

Currently it points the user to the internal numpy function

kwargs = {'strict': False}, old_name = 'y', new_name = 'desired'

    @functools.wraps(fun)
    def wrapper(*args, **kwargs):
        for old_name, new_name in zip(old_names, new_names):
            if old_name in kwargs:
                if dep_version:
                    end_version = dep_version.split('.')
                    end_version[1] = str(int(end_version[1]) + 2)
                    end_version = '.'.join(end_version)
                    msg = (f"Use of keyword argument `{old_name}` is "
                           f"deprecated and replaced by `{new_name}`. "
                           f"Support for `{old_name}` will be removed "
                           f"in NumPy {end_version}.")
                    warnings.warn(msg, DeprecationWarning, stacklevel=2)
                if new_name in kwargs:
                    msg = (f"{fun.__name__}() got multiple values for "
                           f"argument now known as `{new_name}`")
                    raise TypeError(msg)
                kwargs[new_name] = kwargs.pop(old_name)
>       return fun(*args, **kwargs)
E       AssertionError:
E       Arrays are not equal
E
E       (shapes (2, 2, 200, 200), (2, 2, 800, 800) mismatch)
E        ACTUAL: array([[[[0, 0, 0, ..., 0, 0, 0],
E                [0, 0, 0, ..., 0, 0, 0],
E                [0, 0, 0, ..., 0, 0, 0],...
E        DESIRED: array([[[[0, 0, 0, ..., 0, 0, 0],
E                [0, 0, 0, ..., 0, 0, 0],
E                [0, 0, 0, ..., 0, 0, 0],...

../../miniforge3/envs/dev/lib/python3.10/site-packages/numpy/_utils/__init__.py:85: AssertionError

Whit this PR:

>       np.testing.assert_equal(data, other)
E       AssertionError:
E       Arrays are not equal
E
E       (shapes (2, 2, 200, 200), (2, 2, 800, 800) mismatch)
E        ACTUAL: array([[[[0, 0, 0, ..., 0, 0, 0],
E                [0, 0, 0, ..., 0, 0, 0],
E                [0, 0, 0, ..., 0, 0, 0],...
E        DESIRED: array([[[[0, 0, 0, ..., 0, 0, 0],
E                [0, 0, 0, ..., 0, 0, 0],
E                [0, 0, 0, ..., 0, 0, 0],...

tests/my_test.py:190: AssertionError

Currently it points the user to the internal numpy function

```
kwargs = {'strict': False}, old_name = 'y', new_name = 'desired'

    @functools.wraps(fun)
    def wrapper(*args, **kwargs):
        for old_name, new_name in zip(old_names, new_names):
            if old_name in kwargs:
                if dep_version:
                    end_version = dep_version.split('.')
                    end_version[1] = str(int(end_version[1]) + 2)
                    end_version = '.'.join(end_version)
                    msg = (f"Use of keyword argument `{old_name}` is "
                           f"deprecated and replaced by `{new_name}`. "
                           f"Support for `{old_name}` will be removed "
                           f"in NumPy {end_version}.")
                    warnings.warn(msg, DeprecationWarning, stacklevel=2)
                if new_name in kwargs:
                    msg = (f"{fun.__name__}() got multiple values for "
                           f"argument now known as `{new_name}`")
                    raise TypeError(msg)
                kwargs[new_name] = kwargs.pop(old_name)
>       return fun(*args, **kwargs)
E       AssertionError:
E       Arrays are not equal
E
E       (shapes (2, 2, 200, 200), (2, 2, 800, 800) mismatch)
E        ACTUAL: array([[[[0, 0, 0, ..., 0, 0, 0],
E                [0, 0, 0, ..., 0, 0, 0],
E                [0, 0, 0, ..., 0, 0, 0],...
E        DESIRED: array([[[[0, 0, 0, ..., 0, 0, 0],
E                [0, 0, 0, ..., 0, 0, 0],
E                [0, 0, 0, ..., 0, 0, 0],...

../../miniforge3/envs/dev/lib/python3.10/site-packages/numpy/_utils/__init__.py:85: AssertionError
```
@charris charris added this to the 2.2.4 release milestone Mar 14, 2025
@charris charris added the 08 - Backport Used to tag backport PRs label Mar 14, 2025
@charris charris merged commit 03d8f36 into numpy:maintenance/2.2.x Mar 14, 2025
70 checks passed
@charris charris deleted the backport-28211 branch March 14, 2025 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
03 - Maintenance 08 - Backport Used to tag backport PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.