Skip to content

Commit

Permalink
Merge pull request #1617 from zm711/fix-dep-error
Browse files Browse the repository at this point in the history
Improve `copy` deprecation message
  • Loading branch information
alejoe91 authored Jan 17, 2025
2 parents d722b0b + ea8e7fc commit 7f6e973
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
7 changes: 5 additions & 2 deletions neo/core/analogsignal.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ def __new__(
"""
if copy is not None:
raise ValueError(
"`copy` is now deprecated in Neo due to removal in NumPy 2.0 and will be removed in 0.15.0."
"`copy` is now deprecated in Neo due to removal in Quantites to support Numpy 2.0. "
"In order to facilitate the deprecation copy can be set to None but will raise an "
"error if set to True/False since this will silently do nothing. This argument will be completely "
"removed in Neo 0.15.0. Please update your code base as necessary."
)

signal = cls._rescale(signal, units=units)
Expand All @@ -210,7 +213,7 @@ def __new__(
obj.shape = (-1, 1)

if t_start is None:
raise ValueError("t_start cannot be None")
raise ValueError("`t_start` cannot be None")
obj._t_start = t_start

obj._sampling_rate = _get_sampling_rate(sampling_rate, sampling_period)
Expand Down
5 changes: 4 additions & 1 deletion neo/core/imagesequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ def __new__(

if copy is not None:
raise ValueError(
"`copy` is now deprecated in Neo due to removal in NumPy 2.0 and will be removed in 0.15.0."
"`copy` is now deprecated in Neo due to removal in Quantites to support Numpy 2.0. "
"In order to facilitate the deprecation copy can be set to None but will raise an "
"error if set to True/False since this will silently do nothing. This argument will be completely "
"removed in Neo 0.15.0. Please update your code base as necessary."
)

if spatial_scale is None:
Expand Down
5 changes: 4 additions & 1 deletion neo/core/irregularlysampledsignal.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ def __new__(

if copy is not None:
raise ValueError(
"`copy` is now deprecated in Neo due to removal in NumPy 2.0 and will be removed in 0.15.0."
"`copy` is now deprecated in Neo due to removal in Quantites to support Numpy 2.0. "
"In order to facilitate the deprecation copy can be set to None but will raise an "
"error if set to True/False since this will silently do nothing. This argument will be completely "
"removed in Neo 0.15.0. Please update your code base as necessary."
)

signal = cls._rescale(signal, units=units)
Expand Down
12 changes: 10 additions & 2 deletions neo/core/spiketrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,12 @@ def normalize_times_array(times, units=None, dtype=None, copy=None):
"""

if copy is not None:
raise ValueError("`copy` is now deprecated in Neo due to removal in NumPy 2.0 and will be removed in 0.15.0.")
raise ValueError(
"`copy` is now deprecated in Neo due to removal in Quantites to support Numpy 2.0. "
"In order to facilitate the deprecation copy can be set to None but will raise an "
"error if set to True/False since this will silently do nothing. This argument will be completely "
"removed in Neo 0.15.0. Please update your code base as necessary."
)

if dtype is None:
if not hasattr(times, "dtype"):
Expand Down Expand Up @@ -352,7 +357,10 @@ def __new__(
"""
if copy is not None:
raise ValueError(
"`copy` is now deprecated in Neo due to removal in NumPy 2.0 and will be removed in 0.15.0."
"`copy` is now deprecated in Neo due to removal in Quantites to support Numpy 2.0. "
"In order to facilitate the deprecation copy can be set to None but will raise an "
"error if set to True/False since this will silently do nothing. This argument will be completely "
"removed in Neo 0.15.0. Please update your code base as necessary."
)

if len(times) != 0 and waveforms is not None and len(times) != waveforms.shape[0]:
Expand Down

0 comments on commit 7f6e973

Please sign in to comment.