From 4923d066d786602443d2081c86b1c2adf221f9b2 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Thu, 2 Feb 2023 11:51:34 -0600 Subject: [PATCH] Remove deprecated `Matrix.new` --- graphblas/core/matrix.py | 8 -------- graphblas/core/scalar.py | 9 --------- graphblas/core/vector.py | 8 -------- graphblas/tests/test_matrix.py | 12 +++--------- graphblas/tests/test_scalar.py | 4 ++-- graphblas/tests/test_vector.py | 4 ++-- 6 files changed, 7 insertions(+), 38 deletions(-) diff --git a/graphblas/core/matrix.py b/graphblas/core/matrix.py index 9dbfd2320..046a57361 100644 --- a/graphblas/core/matrix.py +++ b/graphblas/core/matrix.py @@ -761,14 +761,6 @@ def get(self, row, col, default=None): "Indices should get a single element, which will be extracted as a Python scalar." ) - @classmethod - def new(cls, dtype, nrows=0, ncols=0, *, name=None): - warnings.warn( - "`Matrix.new(...)` is deprecated; please use `Matrix(...)` instead.", - DeprecationWarning, - ) - return Matrix(dtype, nrows, ncols, name=name) - @classmethod def from_values( cls, diff --git a/graphblas/core/scalar.py b/graphblas/core/scalar.py index cc34e27e2..459f9d648 100644 --- a/graphblas/core/scalar.py +++ b/graphblas/core/scalar.py @@ -1,5 +1,4 @@ import itertools -import warnings import numpy as np @@ -480,14 +479,6 @@ def get(self, default=None): """ return default if self._is_empty else self.value - @classmethod - def new(cls, dtype, *, is_cscalar=False, name=None): - warnings.warn( - "`Scalar.new(...)` is deprecated; please use `Scalar(...)` instead.", - DeprecationWarning, - ) - return Scalar(dtype, is_cscalar=is_cscalar, name=name) - @classmethod def from_value(cls, value, dtype=None, *, is_cscalar=False, name=None): """Create a new Scalar from a value. diff --git a/graphblas/core/vector.py b/graphblas/core/vector.py index e0d55cc99..908cfc6cf 100644 --- a/graphblas/core/vector.py +++ b/graphblas/core/vector.py @@ -648,14 +648,6 @@ def get(self, index, default=None): "A single index should be given, and the result will be a Python scalar." ) - @classmethod - def new(cls, dtype, size=0, *, name=None): - warnings.warn( - "`Vector.new(...)` is deprecated; please use `Vector(...)` instead.", - DeprecationWarning, - ) - return Vector(dtype, size, name=name) - @classmethod def from_values(cls, indices, values, dtype=None, *, size=None, dup_op=None, name=None): """Create a new Vector from indices and values. diff --git a/graphblas/tests/test_matrix.py b/graphblas/tests/test_matrix.py index 57bf6e5e3..ec11a2b39 100644 --- a/graphblas/tests/test_matrix.py +++ b/graphblas/tests/test_matrix.py @@ -557,7 +557,7 @@ def test_extract_input_mask(): expected[[0, 1]].new(input_mask=M.S) with pytest.raises(TypeError, match="Mask object must be type Vector"): expected(input_mask=M.S) << expected[[0, 1]] - with pytest.raises(TypeError, match=r"new\(\) got an unexpected keyword argument 'input_mask'"): + with pytest.raises(AttributeError, match="new"): A.new(input_mask=M.S) with pytest.raises(TypeError, match="`input_mask` argument may only be used for extract"): A(input_mask=M.S) << A.apply(unary.ainv) @@ -2918,7 +2918,7 @@ def test_expr_is_like_matrix(A): "_extract_element", } # Make sure signatures actually match - skip = {"__init__", "__repr__", "_repr_html_", "new"} + skip = {"__init__", "__repr__", "_repr_html_"} for expr in [binary.times(B & B), B & B, B.T]: print(type(expr).__name__) for attr, val in inspect.getmembers(expr): @@ -2971,7 +2971,7 @@ def test_index_expr_is_like_matrix(A): "methods, then you may need to run `python -m graphblas.core.infixmethods`." ) # Make sure signatures actually match. `update` has different docstring. - skip = {"__call__", "__init__", "__repr__", "_repr_html_", "new", "update"} + skip = {"__call__", "__init__", "__repr__", "_repr_html_", "update"} for attr, val in inspect.getmembers(B[[0, 1], [0, 1]]): if attr in skip or not isinstance(val, types.MethodType) or not hasattr(B, attr): continue @@ -3503,12 +3503,6 @@ def test_deprecated(A): A.ss.selectk_rowwise("first", 3) with pytest.warns(DeprecationWarning): A.ss.selectk_columnwise("first", 3) - with pytest.warns(DeprecationWarning): - Matrix.new(int) - with pytest.warns(DeprecationWarning): - Vector.new(int) - with pytest.warns(DeprecationWarning): - Scalar.new(int) with pytest.warns(DeprecationWarning): A.to_values() with pytest.warns(DeprecationWarning): diff --git a/graphblas/tests/test_scalar.py b/graphblas/tests/test_scalar.py index 04cc0e900..6ee70311c 100644 --- a/graphblas/tests/test_scalar.py +++ b/graphblas/tests/test_scalar.py @@ -367,7 +367,7 @@ def test_expr_is_like_scalar(s): assert attrs - infix_attrs == expected assert attrs - scalar_infix_attrs == expected # Make sure signatures actually match. `expr.dup` has `**opts` - skip = {"__init__", "__repr__", "_repr_html_", "new", "dup"} + skip = {"__init__", "__repr__", "_repr_html_", "dup"} for expr in [v.inner(v), v @ v, t & t]: print(type(expr).__name__) for attr, val in inspect.getmembers(expr): @@ -406,7 +406,7 @@ def test_index_expr_is_like_scalar(s): "methods, then you may need to run `python -m graphblas.core.infixmethods`." ) # Make sure signatures actually match. `update` has different docstring. - skip = {"__call__", "__init__", "__repr__", "_repr_html_", "new", "update", "dup"} + skip = {"__call__", "__init__", "__repr__", "_repr_html_", "update", "dup"} for attr, val in inspect.getmembers(v[0]): if attr in skip or not isinstance(val, types.MethodType) or not hasattr(s, attr): continue diff --git a/graphblas/tests/test_vector.py b/graphblas/tests/test_vector.py index c7f90c10c..fd0d08b5d 100644 --- a/graphblas/tests/test_vector.py +++ b/graphblas/tests/test_vector.py @@ -1630,7 +1630,7 @@ def test_expr_is_like_vector(v): ) assert attrs - infix_attrs == expected # Make sure signatures actually match - skip = {"__init__", "__repr__", "_repr_html_", "new"} + skip = {"__init__", "__repr__", "_repr_html_"} for expr in [binary.times(w & w), w & w]: print(type(expr).__name__) for attr, val in inspect.getmembers(expr): @@ -1675,7 +1675,7 @@ def test_index_expr_is_like_vector(v): "methods, then you may need to run `python -m graphblas.core.infixmethods`." ) # Make sure signatures actually match. `update` has different docstring. - skip = {"__call__", "__init__", "__repr__", "_repr_html_", "new", "update"} + skip = {"__call__", "__init__", "__repr__", "_repr_html_", "update"} for attr, val in inspect.getmembers(w[[0, 1]]): if attr in skip or not isinstance(val, types.MethodType) or not hasattr(w, attr): continue