ronantakizawa/codereview-bench huggingface dataset:
Repository: numpy/numpy
File: tools/write_release.py (Python)

Code before:
        with open(fn_path, 'rb') as f:
            m = hash_func(f.read())
        checksums.append(f"{m.hexdigest()}  {fn}")
    return checksums


def write_release(version):
    """
    Copy the <version>-notes.rst file to the OUTPUT_DIR, append
    the md5 and sha256 hashes of the wheels and sdist, and produce
    README.rst and README.md files.

    Parameters
    ----------
    version: str
       Release version, e.g., '2.3.2', etc.

    Returns
    -------
    None.

    """
    notes = Path(f"{NOTES_DIR}/{version}-notes.rst")
    wheel_dir = Path(f"{OUTPUT_DIR}/installers")
    target_md = Path(f"{OUTPUT_DIR}/{OUTPUT_FILE}.md")
    target_rst = Path(f"{OUTPUT_DIR}/{OUTPUT_FILE}.rst")
    
    os.system(f"cp {notes} {target_rst}")

    with open(str(target_rst), 'a') as f:
        f.writelines(textwrap.dedent(
            """
            Checksums
            =========

            MD5
            ---
            ::

            """))
        f.writelines([f'    {c}\n' for c in compute_hash(wheel_dir, md5)])

        f.writelines(textwrap.dedent(
            """
            SHA256
            ------
            ::

            """))
        f.writelines([f'    {c}\n' for c in compute_hash(wheel_dir, sha256)])


Review comment (suggestion):
nitpick:

```suggestion
    notes = Path(NOTES_DIR) / f"{version}-notes.rst"
    wheel_dir = Path(OUTPUT_DIR) / "installers"
    target_md = Path(OUTPUT_DIR) / f"{OUTPUT_FILE}.md"
    target_rst = Path(OUTPUT_DIR) / f"{OUTPUT_FILE}.rst"
```

but I suppose this could be cleaned up a bit by defining `NOTES_DIR` etc. directly as a `Path`

Code after:
        checksums.append(f"{m.hexdigest()}  {fn}")
    return checksums


def write_release(version):
    """
    Copy the <version>-notes.rst file to the OUTPUT_DIR, append
    the md5 and sha256 hashes of the wheels and sdist, and produce
    README.rst and README.md files.

    Parameters
    ----------
    version: str
       Release version, e.g., '2.3.2', etc.

    Returns
    -------
    None.

    """
    notes = Path(NOTES_DIR) / f"{version}-notes.rst"
    wheel_dir = Path(OUTPUT_DIR) / "installers"
    target_md = Path(OUTPUT_DIR) / f"{OUTPUT_FILE}.md"
    target_rst = Path(OUTPUT_DIR) / f"{OUTPUT_FILE}.rst"

    os.system(f"cp {notes} {target_rst}")

    with open(str(target_rst), 'a') as f:
        f.writelines(textwrap.dedent(
            """
            Checksums
            =========

            MD5
            ---
            ::

            """))
        f.writelines([f'    {c}\n' for c in compute_hash(wheel_dir, md5)])

        f.writelines(textwrap.dedent(
            """
            SHA256
            ------
            ::

            """))
        f.writelines([f'    {c}\n' for c in compute_hash(wheel_dir, sha256)])

    # translate README.rst to md for posting on GitHub
    subprocess.run(
Repository: numpy/numpy
File: numpy/typing/tests/data/reveal/ma.pyi (Python)

Code before:
from typing import Any, Literal, TypeAlias, TypeVar, assert_type, NoReturn, Generic

import numpy as np
from numpy import dtype, generic
from numpy._typing import NDArray, _AnyShape

_ScalarT = TypeVar("_ScalarT", bound=generic)
_ScalarT_co = TypeVar("_ScalarT_co", bound=generic, covariant=True)
MaskedArray: TypeAlias = np.ma.MaskedArray[_AnyShape, dtype[_ScalarT]]
_Array1D: TypeAlias = np.ndarray[tuple[int], np.dtype[_ScalarT]]

class MaskedArraySubclass(MaskedArray[_ScalarT_co]): ...

class IntoMaskedArraySubClass(Generic[_ScalarT_co]):
    def __array__(self) -> MaskedArraySubclass[_ScalarT_co]:
        ...

MaskedArraySubclassC: TypeAlias = MaskedArraySubclass[np.complex128]

AR_b: NDArray[np.bool]
AR_f4: NDArray[np.float32]
AR_u4: NDArray[np.uint32]
AR_dt64: NDArray[np.datetime64]
AR_td64: NDArray[np.timedelta64]
AR_o: NDArray[np.timedelta64]

AR_LIKE_b: list[bool]
AR_LIKE_u: list[np.uint32]
AR_LIKE_i: list[int]
AR_LIKE_f: list[float]
AR_LIKE_c: list[complex]
AR_LIKE_td64: list[np.timedelta64]
AR_LIKE_dt64: list[np.datetime64]
AR_LIKE_o: list[np.object_]
AR_number: NDArray[np.number]

MAR_c8: MaskedArray[np.complex64]
MAR_c16: MaskedArray[np.complex128]
MAR_b: MaskedArray[np.bool]
MAR_f4: MaskedArray[np.float32]
MAR_f8: MaskedArray[np.float64]

Review comment (suggestion):
```suggestion
    def __array__(self) -> MaskedArraySubclass[_ScalarT_co]: ...
```

(the `Into*` in the name makes me think that you know rust, is that correct :P ?)

Code after:
from typing import Any, Generic, Literal, NoReturn, TypeAlias, TypeVar, assert_type

import numpy as np
from numpy import dtype, generic
from numpy._typing import NDArray, _AnyShape

_ScalarT = TypeVar("_ScalarT", bound=generic)
_ScalarT_co = TypeVar("_ScalarT_co", bound=generic, covariant=True)
MaskedArray: TypeAlias = np.ma.MaskedArray[_AnyShape, dtype[_ScalarT]]
_Array1D: TypeAlias = np.ndarray[tuple[int], np.dtype[_ScalarT]]

class MaskedArraySubclass(MaskedArray[_ScalarT_co]): ...

class IntoMaskedArraySubClass(Generic[_ScalarT_co]):
    def __array__(self) -> MaskedArraySubclass[_ScalarT_co]: ...

MaskedArraySubclassC: TypeAlias = MaskedArraySubclass[np.complex128]

AR_b: NDArray[np.bool]
AR_f4: NDArray[np.float32]
AR_u4: NDArray[np.uint32]
AR_dt64: NDArray[np.datetime64]
AR_td64: NDArray[np.timedelta64]
AR_o: NDArray[np.timedelta64]

AR_LIKE_b: list[bool]
AR_LIKE_u: list[np.uint32]
AR_LIKE_i: list[int]
AR_LIKE_f: list[float]
AR_LIKE_c: list[complex]
AR_LIKE_td64: list[np.timedelta64]
AR_LIKE_dt64: list[np.datetime64]
AR_LIKE_o: list[np.object_]
AR_number: NDArray[np.number]

MAR_c8: MaskedArray[np.complex64]
MAR_c16: MaskedArray[np.complex128]
MAR_b: MaskedArray[np.bool]
MAR_f4: MaskedArray[np.float32]
MAR_f8: MaskedArray[np.float64]
MAR_i8: MaskedArray[np.int64]
Repository: numpy/numpy
File: numpy/typing/tests/data/reveal/ma.pyi (Python)

Code before:
from typing import Any, Literal, TypeAlias, TypeVar, assert_type, NoReturn, Generic

import numpy as np
from numpy import dtype, generic
from numpy._typing import NDArray, _AnyShape

_ScalarT = TypeVar("_ScalarT", bound=generic)
_ScalarT_co = TypeVar("_ScalarT_co", bound=generic, covariant=True)
MaskedArray: TypeAlias = np.ma.MaskedArray[_AnyShape, dtype[_ScalarT]]
_Array1D: TypeAlias = np.ndarray[tuple[int], np.dtype[_ScalarT]]

class MaskedArraySubclass(MaskedArray[_ScalarT_co]): ...

class IntoMaskedArraySubClass(Generic[_ScalarT_co]):
    def __array__(self) -> MaskedArraySubclass[_ScalarT_co]: ...

MaskedArraySubclassC: TypeAlias = MaskedArraySubclass[np.complex128]

AR_b: NDArray[np.bool]
AR_f4: NDArray[np.float32]
AR_u4: NDArray[np.uint32]
AR_dt64: NDArray[np.datetime64]
AR_td64: NDArray[np.timedelta64]
AR_o: NDArray[np.timedelta64]

AR_LIKE_b: list[bool]

Review comment (suggestion):
nit

```suggestion
from typing import Any, Generic, Literal, NoReturn, TypeAlias, TypeVar, assert_type
```

Code after:
from typing import Any, Generic, Literal, NoReturn, TypeAlias, TypeVar, assert_type

import numpy as np
from numpy import dtype, generic
from numpy._typing import NDArray, _AnyShape

_ScalarT = TypeVar("_ScalarT", bound=generic)
_ScalarT_co = TypeVar("_ScalarT_co", bound=generic, covariant=True)
MaskedArray: TypeAlias = np.ma.MaskedArray[_AnyShape, dtype[_ScalarT]]
_Array1D: TypeAlias = np.ndarray[tuple[int], np.dtype[_ScalarT]]

class MaskedArraySubclass(MaskedArray[_ScalarT_co]): ...

class IntoMaskedArraySubClass(Generic[_ScalarT_co]):
    def __array__(self) -> MaskedArraySubclass[_ScalarT_co]: ...

MaskedArraySubclassC: TypeAlias = MaskedArraySubclass[np.complex128]

AR_b: NDArray[np.bool]
AR_f4: NDArray[np.float32]
AR_u4: NDArray[np.uint32]
AR_dt64: NDArray[np.datetime64]
AR_td64: NDArray[np.timedelta64]
AR_o: NDArray[np.timedelta64]

AR_LIKE_b: list[bool]
Repository: numpy/numpy
File: numpy/ma/core.pyi (Python)

Code before:
# pyright: reportIncompatibleMethodOverride=false
# ruff: noqa: ANN001, ANN002, ANN003, ANN201, ANN202 ANN204, ANN401

from _typeshed import Incomplete
from collections.abc import Sequence
from typing import (
    Any,
    Literal,
    Never,
    NoReturn,
    Self,
    SupportsIndex,
    TypeAlias,
    overload,
)
from typing_extensions import TypeIs, TypeVar

import numpy as np
from numpy import (
    _AnyShapeT,
    _ArrayInt_co,
    _HasDType,
    _HasDTypeWithRealAndImag,
    _ModeKind,
    _OrderACF,
    _OrderKACF,
    _PartitionKind,
    _SortKind,
    _ToIndices,
    amax,
    amin,
    bool_,
    bytes_,
    character,
    complex128,
    complexfloating,
    datetime64,
    dtype,
    dtypes,
    expand_dims,
    float16,
    float32,
    float64,
    floating,
    generic,
    inexact,

Review comment (bug):
[nit] This `NDArray[integer | np.bool]` is simple enough to inline here, given that it's only used twice (in `__init__.pyi` that's 30x). Importing private type-aliases like these can be risky, as it's not obvious that you should check for references to some private type alias if you rename or remove it (I believe I recently introduced a bug like this, which you managed to track down if I remember correctly?).

Code after:
# pyright: reportIncompatibleMethodOverride=false
# ruff: noqa: ANN001, ANN002, ANN003, ANN201, ANN202 ANN204, ANN401

from _typeshed import Incomplete
from collections.abc import Sequence
from typing import (
    Any,
    Literal,
    Never,
    NoReturn,
    Self,
    SupportsIndex,
    TypeAlias,
    overload,
)
from typing_extensions import TypeIs, TypeVar

import numpy as np
from numpy import (
    _AnyShapeT,
    _HasDType,
    _HasDTypeWithRealAndImag,
    _ModeKind,
    _OrderACF,
    _OrderKACF,
    _PartitionKind,
    _SortKind,
    _ToIndices,
    amax,
    amin,
    bool_,
    bytes_,
    character,
    complex128,
    complexfloating,
    datetime64,
    dtype,
    dtypes,
    expand_dims,
    float16,
    float32,
    float64,
    floating,
    generic,
    inexact,
    int8,
Repository: numpy/numpy
File: numpy/ma/core.pyi (Python)

Code before:

from _typeshed import Incomplete
from collections.abc import Sequence
from typing import (
    Any,
    Literal,
    Never,
    NoReturn,
    Self,
    SupportsIndex,
    TypeAlias,
    overload,
)
from typing_extensions import TypeIs, TypeVar

import numpy as np
from numpy import (
    _AnyShapeT,
    _ArrayInt_co,
    _HasDType,
    _HasDTypeWithRealAndImag,
    _ModeKind,
    _OrderACF,
    _OrderKACF,
    _PartitionKind,
    _SortKind,
    _ToIndices,
    amax,
    amin,
    bool_,
    bytes_,
    character,
    complex128,
    complexfloating,
    datetime64,
    dtype,
    dtypes,
    expand_dims,
    float16,
    float32,
    float64,
    floating,
    generic,
    inexact,
    int8,
    int64,
    int_,
    integer,
    intp,
    ndarray,
    number,

Review comment (suggestion):
This one is a lot beefier, so IMO it's fine to keep this one. (Although it's probably cleaner to put this and others like it in `numpy._typing`, but that's not very high on the priority list, and of course out-of-scope)

Code after:

from _typeshed import Incomplete
from collections.abc import Sequence
from typing import (
    Any,
    Literal,
    Never,
    NoReturn,
    Self,
    SupportsIndex,
    TypeAlias,
    overload,
)
from typing_extensions import TypeIs, TypeVar

import numpy as np
from numpy import (
    _AnyShapeT,
    _HasDType,
    _HasDTypeWithRealAndImag,
    _ModeKind,
    _OrderACF,
    _OrderKACF,
    _PartitionKind,
    _SortKind,
    _ToIndices,
    amax,
    amin,
    bool_,
    bytes_,
    character,
    complex128,
    complexfloating,
    datetime64,
    dtype,
    dtypes,
    expand_dims,
    float16,
    float32,
    float64,
    floating,
    generic,
    inexact,
    int8,
    int64,
    int_,
    integer,
    intp,
    ndarray,
    number,
    object_,
Repository: numpy/numpy
File: numpy/ma/core.pyi (Python)

Code before:
    *,
    stable: Literal[False] | None = False,
) -> _ArrayT: ...
@overload
def sort(
    a: ArrayLike,
    axis: SupportsIndex = -1,
    kind: _SortKind | None = None,
    order: str | Sequence[str] | None = None,
    endwith: bool | None = True,
    fill_value: _ScalarLike_co | None = None,
    *,
    stable: Literal[False] | None = False,
) -> NDArray[Any]: ...
@overload
def compressed(x: _ArrayLike[_ScalarT_co]) -> _Array1D[_ScalarT_co]: ...
@overload
def compressed(x: ArrayLike) -> _Array1D[Any]: ...
def concatenate(arrays, axis=0): ...
def diag(v, k=0): ...
def left_shift(a, n): ...
def right_shift(a, n): ...
def put(a: NDArray[Any], indices: _ArrayLikeInt_co, values: ArrayLike, mode: _ModeKind = 'raise') -> None: ...
def putmask(a: NDArray[Any], mask: _ArrayLikeBool_co, values: ArrayLike) -> None: ...
def transpose(a, axes=None): ...
def reshape(a, new_shape, order='C'): ...
def resize(x, new_shape): ...
def ndim(obj: ArrayLike) -> int: ...
def shape(obj): ...
def size(obj: ArrayLike, axis: SupportsIndex | None = None) -> int: ...
def diff(a, /, n=1, axis=-1, prepend=..., append=...): ...
def where(condition, x=..., y=...): ...
def choose(indices, choices, out=None, mode='raise'): ...
def round_(a, decimals=0, out=None): ...
round = round_

def inner(a, b): ...
innerproduct = inner

def outer(a, b): ...
outerproduct = outer

def correlate(a, v, mode='valid', propagate_mask=True): ...
def convolve(a, v, mode='full', propagate_mask=True): ...

def allequal(a: ArrayLike, b: ArrayLike, fill_value: bool = True) -> bool: ...

def allclose(a: ArrayLike, b: ArrayLike, masked_equal: bool = True, rtol: float = 1e-5, atol: float = 1e-8) -> bool: ...

def asarray(a, dtype=None, order=None): ...
def asanyarray(a, dtype=None): ...

Review comment (suggestion):
I realize that there are some existing `'` quotes here and there, but `"` is used way more often. I'm kinda surprised that ruff accepts this though 🤔

```suggestion
def reshape(a, new_shape, order="C"): ...
```

Code after:
    *,
    keepdims: bool | _NoValueType = ...,
) -> _ArrayT: ...

minimum: _extrema_operation
maximum: _extrema_operation

@overload
def take(
    a: _ArrayLike[_ScalarT],
    indices: _IntLike_co,
    axis: None = None,
    out: None = None,
    mode: _ModeKind = "raise"
) -> _ScalarT: ...
@overload
def take(
    a: _ArrayLike[_ScalarT],
    indices: _ArrayLikeInt_co,
    axis: SupportsIndex | None = None,
    out: None = None,
    mode: _ModeKind = "raise",
) -> _MaskedArray[_ScalarT]: ...
@overload
def take(
    a: ArrayLike,
    indices: _IntLike_co,
    axis: SupportsIndex | None = None,
    out: None = None,
    mode: _ModeKind = "raise",
) -> Any: ...
@overload
def take(
    a: ArrayLike,
    indices: _ArrayLikeInt_co,
    axis: SupportsIndex | None = None,
    out: None = None,
    mode: _ModeKind = "raise",
) -> _MaskedArray[Any]: ...
@overload
def take(
    a: ArrayLike,
    indices: _ArrayLikeInt_co,
    axis: SupportsIndex | None,
    out: _ArrayT,
    mode: _ModeKind = "raise",
) -> _ArrayT: ...
@overload
def take(
    a: ArrayLike,
    indices: _ArrayLikeInt_co,
Repository: numpy/numpy
File: numpy/ma/extras.pyi (Python)

Code before:
    "in1d",
    "intersect1d",
    "isin",
    "mask_cols",
    "mask_rowcols",
    "mask_rows",
    "masked_all",
    "masked_all_like",
    "median",
    "mr_",
    "ndenumerate",
    "notmasked_contiguous",
    "notmasked_edges",
    "polyfit",
    "row_stack",
    "setdiff1d",
    "setxor1d",
    "stack",
    "union1d",
    "unique",
    "vander",
    "vstack",
]

def count_masked(arr, axis=None): ...
def masked_all(shape, dtype=...): ...
def masked_all_like(arr): ...

class _fromnxfunction:
    __name__: Incomplete
    __doc__: Incomplete
    def __init__(self, funcname) -> None: ...
    def getdoc(self): ...
    def __call__(self, *args, **params): ...

class _fromnxfunction_single(_fromnxfunction):
    def __call__(self, x, *args, **params): ...

class _fromnxfunction_seq(_fromnxfunction):
    def __call__(self, x, *args, **params): ...

class _fromnxfunction_allargs(_fromnxfunction):
    def __call__(self, *args, **params): ...

atleast_1d: _fromnxfunction_allargs
atleast_2d: _fromnxfunction_allargs
atleast_3d: _fromnxfunction_allargs

vstack: _fromnxfunction_seq
row_stack: _fromnxfunction_seq
hstack: _fromnxfunction_seq

Review comment (suggestion):
Ruff `PYI014` wouldn't accept this I think, which is pretty arbitrary if you ask me.

```suggestion
def masked_all(shape, dtype=float): ...  # noqa: PYI014
```

Code after:
    "in1d",
    "intersect1d",
    "isin",
    "mask_cols",
    "mask_rowcols",
    "mask_rows",
    "masked_all",
    "masked_all_like",
    "median",
    "mr_",
    "ndenumerate",
    "notmasked_contiguous",
    "notmasked_edges",
    "polyfit",
    "row_stack",
    "setdiff1d",
    "setxor1d",
    "stack",
    "union1d",
    "unique",
    "vander",
    "vstack",
]

def count_masked(arr, axis=None): ...
def masked_all(shape, dtype=float): ...  # noqa: PYI014
def masked_all_like(arr): ...

class _fromnxfunction:
    __name__: Incomplete
    __doc__: Incomplete
    def __init__(self, funcname) -> None: ...
    def getdoc(self): ...
    def __call__(self, *args, **params): ...

class _fromnxfunction_single(_fromnxfunction):
    def __call__(self, x, *args, **params): ...

class _fromnxfunction_seq(_fromnxfunction):
    def __call__(self, x, *args, **params): ...

class _fromnxfunction_allargs(_fromnxfunction):
    def __call__(self, *args, **params): ...

atleast_1d: _fromnxfunction_allargs
atleast_2d: _fromnxfunction_allargs
atleast_3d: _fromnxfunction_allargs

vstack: _fromnxfunction_seq
row_stack: _fromnxfunction_seq
hstack: _fromnxfunction_seq
Repository: numpy/numpy
File: numpy/ma/mrecords.pyi (Python)

Code before:
    formats=None,
    names=None,
    titles=None,
    aligned=False,
    byteorder=None,
    fill_value=None,
): ...

def fromrecords(
    reclist,
    dtype=None,
    shape=None,
    formats=None,
    names=None,
    titles=None,
    aligned=False,
    byteorder=None,
    fill_value=None,
    mask=...,
): ...

def fromtextfile(
    fname,
    delimiter=None,
    commentchar='#',
    missingchar='',
    varnames=None,
    vartypes=None,
    # NOTE: deprecated: NumPy 1.22.0, 2021-09-23
    # delimitor=...,
): ...

def addfield(mrecord, newfield, newfieldname=None): ...


Review comment (suggestion):
```suggestion
    commentchar="#",
    missingchar="",
```

Code after:
    formats=None,
    names=None,
    titles=None,
    aligned=False,
    byteorder=None,
    fill_value=None,
): ...

def fromrecords(
    reclist,
    dtype=None,
    shape=None,
    formats=None,
    names=None,
    titles=None,
    aligned=False,
    byteorder=None,
    fill_value=None,
    mask=...,
): ...

def fromtextfile(
    fname,
    delimiter=None,
    commentchar="#",
    missingchar="",
    varnames=None,
    vartypes=None,
    # NOTE: deprecated: NumPy 1.22.0, 2021-09-23
    # delimitor=...,
): ...

def addfield(mrecord, newfield, newfieldname=None): ...
Repository: numpy/numpy
File: numpy/_core/tests/test_deprecations.py (Python)

Code before:
        def assign_to_index():
            arr.flat[True] = 10

        self.assert_deprecated(assign_to_index)


class TestFlatiterIndexingFloatIndex(_DeprecationTestCase):
    # Deprecated in NumPy 2.4, 2025-07
    message = r"Invalid non-array indices for iterator objects"

    def test_float_index_deprecated(self):
        arr = np.arange(3)
        # float indices on flat iterators are deprecated
        self.assert_deprecated(lambda: arr.flat[[1.]])

    def test_float_assign_index_deprecated(self):
        arr = np.arange(3)

        def assign_to_index():
            arr.flat[[1.]] = 10

        self.assert_deprecated(assign_to_index)


class TestWarningUtilityDeprecations(_DeprecationTestCase):
    # Deprecation in NumPy 2.5, 2025-08
    message = r"NumPy warning suppression and assertion utilities are deprecated."

    def test_assert_warns_deprecated(self):
        def use_assert_warns():
            with np.testing.assert_warns(RuntimeWarning):
                warnings.warn("foo", RuntimeWarning, stacklevel=1)

        self.assert_deprecated(use_assert_warns)

    def test_suppress_warnings_deprecated(self):
        def use_suppress_warnings():
            with np.testing.suppress_warnings() as sup:
                sup.filter(RuntimeWarning, 'invalid value encountered in divide')

        self.assert_deprecated(use_suppress_warnings)


Review comment (suggestion):
```suggestion
    # Deprecation in NumPy 2.4, 2025-08
```

Code after:
        def assign_to_index():
            arr.flat[True] = 10

        self.assert_deprecated(assign_to_index)


class TestFlatiterIndexingFloatIndex(_DeprecationTestCase):
    # Deprecated in NumPy 2.4, 2025-07
    message = r"Invalid non-array indices for iterator objects"

    def test_float_index_deprecated(self):
        arr = np.arange(3)
        # float indices on flat iterators are deprecated
        self.assert_deprecated(lambda: arr.flat[[1.]])

    def test_float_assign_index_deprecated(self):
        arr = np.arange(3)

        def assign_to_index():
            arr.flat[[1.]] = 10

        self.assert_deprecated(assign_to_index)


class TestWarningUtilityDeprecations(_DeprecationTestCase):
    # Deprecation in NumPy 2.4, 2025-08
    message = r"NumPy warning suppression and assertion utilities are deprecated."

    def test_assert_warns_deprecated(self):
        def use_assert_warns():
            with np.testing.assert_warns(RuntimeWarning):
                warnings.warn("foo", RuntimeWarning, stacklevel=1)

        self.assert_deprecated(use_assert_warns)

    def test_suppress_warnings_deprecated(self):
        def use_suppress_warnings():
            with np.testing.suppress_warnings() as sup:
                sup.filter(RuntimeWarning, 'invalid value encountered in divide')

        self.assert_deprecated(use_suppress_warnings)