Skip to content

Commit

Permalink
Fix some DeprecationWarnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
hameerabbasi committed Mar 4, 2024
1 parent 41a1654 commit f54f05a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions sparse/_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import functools
import operator
import warnings
from collections.abc import Iterable
from functools import reduce
from numbers import Integral
Expand Down Expand Up @@ -616,11 +617,17 @@ def get_out_dtype(arr, scalar):


def can_store(dtype, scalar):
return np.array(scalar, dtype=dtype) == np.array(scalar)
try:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
warnings.filterwarnings("error", "out-of-bound", DeprecationWarning)
return np.array(scalar, dtype=dtype) == np.array(scalar)
except ValueError:
return False

Check warning on line 626 in sparse/_utils.py

View check run for this annotation

Codecov / codecov/patch

sparse/_utils.py#L625-L626

Added lines #L625 - L626 were not covered by tests


def is_unsigned_dtype(dtype):
return np.array(-1, dtype=dtype) != np.array(-1)
return np.issubdtype(dtype, np.integer) and np.iinfo(dtype).min == 0


def convert_format(format):
Expand Down

0 comments on commit f54f05a

Please sign in to comment.