Skip to content

Commit

Permalink
Merge pull request #1329 from zm711/numpy-updates
Browse files Browse the repository at this point in the history
Update calls to NumPy dtypes being removed in NumPy 2.0
  • Loading branch information
apdavison authored Oct 10, 2023
2 parents 340b022 + 2c0cca5 commit 3652a24
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion neo/core/analogsignal.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ def concatenate(self, *signals, overwrite=False, padding=False):
if padding is not False:
logger.warning('Signals will be padded using {}.'.format(padding))
if padding is True:
padding = np.NaN * units
padding = np.nan * units
if isinstance(padding, pq.Quantity):
padding = padding.rescale(units).magnitude
else:
Expand Down
2 changes: 1 addition & 1 deletion neo/test/coretest/test_analogsignal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ def test_concatenate_padding_True(self):

result = signal1.concatenate(signal2, overwrite=False, padding=True)
assert_array_equal(
np.array([0, 1, 2, 3, np.NaN, np.NaN, np.NaN, 4, 5, 6]).reshape((-1, 1)),
np.array([0, 1, 2, 3, np.nan, np.nan, np.nan, 4, 5, 6]).reshape((-1, 1)),
result.magnitude)

def test_concatenate_padding_quantity(self):
Expand Down
4 changes: 2 additions & 2 deletions neo/test/coretest/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ def test_numpy_array_uint64(self):

def test_numpy_array_float(self):
'''test to make sure float type numpy arrays are accepted'''
value = np.array([1, 2, 3, 4, 5], dtype=np.float_)
value = np.array([1, 2, 3, 4, 5], dtype=np.float64)
self.base.annotate(data=value)
result = {'data': value}
self.assertDictEqual(result, self.base.annotations)
Expand Down Expand Up @@ -1041,7 +1041,7 @@ def test_numpy_scalar_uint64(self):

def test_numpy_scalar_float(self):
'''test to make sure float type numpy scalars are accepted'''
value = np.array(99, dtype=np.float_)
value = np.array(99, dtype=np.float64)
self.base.annotate(data=value)
result = {'data': value}
self.assertDictEqual(result, self.base.annotations)
Expand Down
4 changes: 2 additions & 2 deletions neo/test/coretest/test_spiketrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,8 @@ def test_defaults(self):
train2 = _new_spiketrain(SpikeTrain, [3, 4, 5], units='sec', t_stop=10.0)
assert_neo_object_is_compliant(train1)
assert_neo_object_is_compliant(train2)
self.assertEqual(train1.dtype, np.float_)
self.assertEqual(train2.dtype, np.float_)
self.assertEqual(train1.dtype, np.float64)
self.assertEqual(train2.dtype, np.float64)
self.assertEqual(train1.sampling_rate, 1.0 * pq.Hz)
self.assertEqual(train2.sampling_rate, 1.0 * pq.Hz)
self.assertEqual(train1.waveforms, None)
Expand Down
2 changes: 1 addition & 1 deletion neo/test/iotest/test_nestio.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def test_read_float(self):
t_stop=500. * pq.ms,
lazy=False, id_column_gdf=0, time_column_gdf=1)
sts = seg.spiketrains
self.assertTrue(all([s.magnitude.dtype == np.float_ for s in sts]))
self.assertTrue(all([s.magnitude.dtype == np.float64 for s in sts]))

def test_values(self):
"""
Expand Down

0 comments on commit 3652a24

Please sign in to comment.