Skip to content

Commit

Permalink
Remove deprecated numpy aliases/functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mstimberg committed Sep 7, 2023
1 parent e8f05c6 commit 402b642
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions brian2/core/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_dtype(obj):
if hasattr(obj, "dtype"):
return obj.dtype
else:
return np.obj2sctype(type(obj))
return np.dtype(type(obj))


def get_dtype_str(val):
Expand Down Expand Up @@ -353,11 +353,11 @@ def __init__(self, name, value, dimensions=DIMENSIONLESS, owner=None):
# Use standard Python types if possible for numpy scalars
if getattr(value, "shape", None) == () and hasattr(value, "dtype"):
numpy_type = value.dtype
if np.can_cast(numpy_type, np.int_):
if np.can_cast(numpy_type, int):
value = int(value)
elif np.can_cast(numpy_type, np.float_):
elif np.can_cast(numpy_type, float):
value = float(value)
elif np.can_cast(numpy_type, np.complex_):
elif np.can_cast(numpy_type, complex):
value = complex(value)
elif value is np.True_:
value = True
Expand Down
2 changes: 1 addition & 1 deletion brian2/groups/neurongroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ def __setattr__(self, key, value):
if value.index is not None:
try:
index_array = np.asarray(value.index)
if not np.issubsctype(index_array.dtype, int):
if not np.issubdtype(index_array.dtype, int):
raise TypeError()
except TypeError:
raise TypeError(
Expand Down
2 changes: 1 addition & 1 deletion brian2/units/fundamentalunits.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ def __new__(cls, arr, dim=None, dtype=None, copy=False, force_quantity=False):
subarr = np.array(arr, dtype=dtype, copy=copy).view(cls)

# We only want numerical datatypes
if not np.issubclass_(np.dtype(subarr.dtype).type, (np.number, np.bool_)):
if not issubclass(np.dtype(subarr.dtype).type, (np.number, np.bool_)):
raise TypeError("Quantities can only be created from numerical data.")

# If a dimension is given, force this dimension
Expand Down

0 comments on commit 402b642

Please sign in to comment.