Skip to content

Remove deprecated Matrix.new #380

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 2 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions graphblas/core/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 0 additions & 9 deletions graphblas/core/scalar.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import itertools
import warnings

import numpy as np

Expand Down Expand Up @@ -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.
Expand Down
8 changes: 0 additions & 8 deletions graphblas/core/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 3 additions & 9 deletions graphblas/tests/test_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions graphblas/tests/test_scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions graphblas/tests/test_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down