Skip to content

Commit 62953ce

Browse files
committed
delete old tests, pq copy removal
1 parent 251f365 commit 62953ce

File tree

4 files changed

+6
-188
lines changed

4 files changed

+6
-188
lines changed

neo/core/spiketrain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def normalize_times_array(times, units=None, dtype=None, copy=None):
225225
# reference dimensionality
226226
if len(dim) != 1 or list(dim.values())[0] != 1 or not isinstance(list(dim.keys())[0], pq.UnitTime):
227227
ValueError(f"Units have dimensions {dim.simplified}, not [time]")
228-
return pq.Quantity(times, units=units, dtype=dtype, copy=copy), dim
228+
return pq.Quantity(times, units=units, dtype=dtype,), dim
229229

230230

231231
class SpikeTrain(DataObject):

neo/io/neurosharectypesio.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ def read_segment(self, import_neuroshare_segment=True, lazy=False):
224224
total_read += pdwContCount.value
225225

226226
try:
227-
signal = pq.Quantity(pData, units=pAnalogInfo.szUnits.decode(), copy=False)
227+
signal = pq.Quantity(pData, units=pAnalogInfo.szUnits.decode())
228228
unit_annotation = None
229229
except LookupError:
230-
signal = pq.Quantity(pData, units="dimensionless", copy=False)
230+
signal = pq.Quantity(pData, units="dimensionless")
231231
unit_annotation = pAnalogInfo.szUnits.decode()
232232

233233
# t_start
@@ -292,9 +292,9 @@ def read_segment(self, import_neuroshare_segment=True, lazy=False):
292292
waveforms[dwIndex, :, :] = pData[: nsample * nsource].reshape(nsample, nsource).transpose()
293293

294294
sptr = SpikeTrain(
295-
times=pq.Quantity(times, units="s", copy=False),
295+
times=pq.Quantity(times, units="s",
296296
t_stop=times.max(),
297-
waveforms=pq.Quantity(waveforms, units=str(pdwSegmentInfo.szUnits), copy=False),
297+
waveforms=pq.Quantity(waveforms, units=str(pdwSegmentInfo.szUnits)),
298298
left_sweep=nsample / 2.0 / float(pdwSegmentInfo.dSampleRate) * pq.s,
299299
sampling_rate=float(pdwSegmentInfo.dSampleRate) * pq.Hz,
300300
name=str(entityInfo.szEntityLabel),

neo/test/coretest/test_analogsignal.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -131,31 +131,6 @@ def test__create_inconsistent_sampling_rate_and_period_ValueError(self):
131131
data = np.arange(10.0) * pq.mV
132132
self.assertRaises(ValueError, AnalogSignal, data, sampling_rate=1 * pq.kHz, sampling_period=5 * pq.s)
133133

134-
# to be removed after testing in CI
135-
#def test__create_with_copy_true_should_return_copy(self):
136-
# data = np.arange(10.0) * pq.mV
137-
# rate = 5000 * pq.Hz
138-
# signal = AnalogSignal(data, copy=True, sampling_rate=rate)
139-
# data[3] = 99 * pq.mV
140-
# assert_neo_object_is_compliant(signal)
141-
# self.assertNotEqual(signal[3, 0], 99 * pq.mV)
142-
143-
#def test__create_with_copy_false_should_return_view(self):
144-
# data = np.arange(10.0) * pq.mV
145-
# rate = 5000 * pq.Hz
146-
# signal = AnalogSignal(data, copy=False, sampling_rate=rate)
147-
# data[3] = 99 * pq.mV
148-
# assert_neo_object_is_compliant(signal)
149-
# self.assertEqual(signal[3, 0], 99 * pq.mV)
150-
151-
#def test__create2D_with_copy_false_should_return_view(self):
152-
# data = np.arange(10.0) * pq.mV
153-
# data = data.reshape((5, 2))
154-
# rate = 5000 * pq.Hz
155-
# signal = AnalogSignal(data, copy=False, sampling_rate=rate)
156-
# data[3, 0] = 99 * pq.mV
157-
# assert_neo_object_is_compliant(signal)
158-
# self.assertEqual(signal[3, 0], 99 * pq.mV)
159134

160135
def test__create_with_additional_argument(self):
161136
signal = AnalogSignal(

neo/test/coretest/test_spiketrain.py

Lines changed: 1 addition & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,33 +1542,6 @@ def test__dtype_change(self):
15421542
data = np.array([3, 4, 5])
15431543
self.assertRaises(ValueError, SpikeTrain, data, units="sec", t_stop=101, dtype=np.float64)
15441544

1545-
# need to remove for numpy 2.0 and quantities
1546-
#def test_change_with_copy_true_and_data_not_quantity(self):
1547-
# Changing spike train does not change data
1548-
# Data source is array
1549-
# Array and quantity are tested separately because copy default
1550-
# is different for these two.
1551-
# data = [3, 4, 5]
1552-
# train = SpikeTrain(data, units="sec", copy=True, t_stop=123.4)
1553-
# train[0] = 99 * pq.s
1554-
# assert_neo_object_is_compliant(train)
1555-
# self.assertEqual(train[0], 99 * pq.s)
1556-
# self.assertEqual(data[0], 3)
1557-
1558-
#def test_changing_slice_changes_original_spiketrain(self):
1559-
# If we slice a spiketrain and then change the slice, the
1560-
# original spiketrain should change.
1561-
# Whether the original data source changes is dependent on the
1562-
# copy parameter.
1563-
# This is compatible with both np and quantity default behavior.
1564-
# data = [3, 4, 5] * pq.s
1565-
# train = SpikeTrain(data, copy=True, t_stop=99.9)
1566-
# result = train[1:3]
1567-
# result[0] = 99 * pq.s
1568-
# assert_neo_object_is_compliant(train)
1569-
# self.assertEqual(train[1], 99 * pq.s)
1570-
# self.assertEqual(result[0], 99 * pq.s)
1571-
# self.assertEqual(data[1], 4 * pq.s)
15721545

15731546
def test_changing_slice_changes_original_spiketrain(self):
15741547
# If we slice a spiketrain and then change the slice, the
@@ -1875,137 +1848,7 @@ def test__pretty(self):
18751848

18761849

18771850
class TestMiscellaneous(unittest.TestCase):
1878-
# we can't do any of this construction since we lose copy = True
1879-
"""
1880-
def test__different_dtype_for_t_start_and_array(self):
1881-
data = np.array([0, 9.9999999], dtype=np.float64) * pq.s
1882-
data16 = data.astype(np.float16)
1883-
data32 = data.astype(np.float32)
1884-
data64 = data.astype(np.float64)
1885-
t_start = data[0]
1886-
t_stop = data[1]
1887-
t_start16 = data[0].astype(dtype=np.float16)
1888-
t_stop16 = data[1].astype(dtype=np.float16)
1889-
t_start32 = data[0].astype(dtype=np.float32)
1890-
t_stop32 = data[1].astype(dtype=np.float32)
1891-
t_start64 = data[0].astype(dtype=np.float64)
1892-
t_stop64 = data[1].astype(dtype=np.float64)
1893-
t_start_custom = 0.0
1894-
t_stop_custom = 10.0
1895-
t_start_custom16 = np.array(t_start_custom, dtype=np.float16)
1896-
t_stop_custom16 = np.array(t_stop_custom, dtype=np.float16)
1897-
t_start_custom32 = np.array(t_start_custom, dtype=np.float32)
1898-
t_stop_custom32 = np.array(t_stop_custom, dtype=np.float32)
1899-
t_start_custom64 = np.array(t_start_custom, dtype=np.float64)
1900-
t_stop_custom64 = np.array(t_stop_custom, dtype=np.float64)
1901-
1902-
# This is OK.
1903-
train = SpikeTrain(data64, copy=True, t_start=t_start, t_stop=t_stop)
1904-
assert_neo_object_is_compliant(train)
1905-
1906-
train = SpikeTrain(data16, copy=True, t_start=t_start, t_stop=t_stop, dtype=np.float16)
1907-
assert_neo_object_is_compliant(train)
1908-
train = SpikeTrain(data16, copy=True, t_start=t_start, t_stop=t_stop, dtype=np.float32)
1909-
assert_neo_object_is_compliant(train)
1910-
1911-
train = SpikeTrain(data32, copy=True, t_start=t_start, t_stop=t_stop, dtype=np.float16)
1912-
assert_neo_object_is_compliant(train)
1913-
train = SpikeTrain(data32, copy=True, t_start=t_start, t_stop=t_stop, dtype=np.float32)
1914-
assert_neo_object_is_compliant(train)
1915-
1916-
train = SpikeTrain(data32, copy=True, t_start=t_start16, t_stop=t_stop16)
1917-
assert_neo_object_is_compliant(train)
1918-
train = SpikeTrain(data32, copy=True, t_start=t_start16, t_stop=t_stop16, dtype=np.float16)
1919-
assert_neo_object_is_compliant(train)
1920-
train = SpikeTrain(data32, copy=True, t_start=t_start16, t_stop=t_stop16, dtype=np.float32)
1921-
assert_neo_object_is_compliant(train)
1922-
train = SpikeTrain(data32, copy=True, t_start=t_start16, t_stop=t_stop16, dtype=np.float64)
1923-
assert_neo_object_is_compliant(train)
1924-
1925-
train = SpikeTrain(data32, copy=True, t_start=t_start32, t_stop=t_stop32)
1926-
assert_neo_object_is_compliant(train)
1927-
train = SpikeTrain(data32, copy=True, t_start=t_start32, t_stop=t_stop32, dtype=np.float16)
1928-
assert_neo_object_is_compliant(train)
1929-
train = SpikeTrain(data32, copy=True, t_start=t_start32, t_stop=t_stop32, dtype=np.float32)
1930-
assert_neo_object_is_compliant(train)
1931-
train = SpikeTrain(data32, copy=True, t_start=t_start32, t_stop=t_stop32, dtype=np.float64)
1932-
assert_neo_object_is_compliant(train)
1933-
1934-
train = SpikeTrain(data32, copy=True, t_start=t_start64, t_stop=t_stop64, dtype=np.float16)
1935-
assert_neo_object_is_compliant(train)
1936-
train = SpikeTrain(data32, copy=True, t_start=t_start64, t_stop=t_stop64, dtype=np.float32)
1937-
assert_neo_object_is_compliant(train)
1938-
1939-
train = SpikeTrain(data16, copy=True, t_start=t_start_custom, t_stop=t_stop_custom)
1940-
assert_neo_object_is_compliant(train)
1941-
train = SpikeTrain(data16, copy=True, t_start=t_start_custom, t_stop=t_stop_custom, dtype=np.float16)
1942-
assert_neo_object_is_compliant(train)
1943-
train = SpikeTrain(data16, copy=True, t_start=t_start_custom, t_stop=t_stop_custom, dtype=np.float32)
1944-
assert_neo_object_is_compliant(train)
1945-
train = SpikeTrain(data16, copy=True, t_start=t_start_custom, t_stop=t_stop_custom, dtype=np.float64)
1946-
assert_neo_object_is_compliant(train)
1947-
1948-
train = SpikeTrain(data32, copy=True, t_start=t_start_custom, t_stop=t_stop_custom)
1949-
assert_neo_object_is_compliant(train)
1950-
train = SpikeTrain(data32, copy=True, t_start=t_start_custom, t_stop=t_stop_custom, dtype=np.float16)
1951-
assert_neo_object_is_compliant(train)
1952-
train = SpikeTrain(data32, copy=True, t_start=t_start_custom, t_stop=t_stop_custom, dtype=np.float32)
1953-
assert_neo_object_is_compliant(train)
1954-
train = SpikeTrain(data32, copy=True, t_start=t_start_custom, t_stop=t_stop_custom, dtype=np.float64)
1955-
assert_neo_object_is_compliant(train)
1956-
1957-
train = SpikeTrain(data16, copy=True, t_start=t_start_custom, t_stop=t_stop_custom)
1958-
assert_neo_object_is_compliant(train)
1959-
train = SpikeTrain(data16, copy=True, t_start=t_start_custom, t_stop=t_stop_custom, dtype=np.float16)
1960-
assert_neo_object_is_compliant(train)
1961-
train = SpikeTrain(data16, copy=True, t_start=t_start_custom, t_stop=t_stop_custom, dtype=np.float32)
1962-
assert_neo_object_is_compliant(train)
1963-
train = SpikeTrain(data16, copy=True, t_start=t_start_custom, t_stop=t_stop_custom, dtype=np.float64)
1964-
assert_neo_object_is_compliant(train)
1965-
1966-
train = SpikeTrain(data32, copy=True, t_start=t_start_custom16, t_stop=t_stop_custom16)
1967-
assert_neo_object_is_compliant(train)
1968-
train = SpikeTrain(data32, copy=True, t_start=t_start_custom16, t_stop=t_stop_custom16, dtype=np.float16)
1969-
assert_neo_object_is_compliant(train)
1970-
train = SpikeTrain(data32, copy=True, t_start=t_start_custom16, t_stop=t_stop_custom16, dtype=np.float32)
1971-
assert_neo_object_is_compliant(train)
1972-
train = SpikeTrain(data32, copy=True, t_start=t_start_custom16, t_stop=t_stop_custom16, dtype=np.float64)
1973-
assert_neo_object_is_compliant(train)
1974-
1975-
train = SpikeTrain(data32, copy=True, t_start=t_start_custom32, t_stop=t_stop_custom32)
1976-
assert_neo_object_is_compliant(train)
1977-
train = SpikeTrain(data32, copy=True, t_start=t_start_custom32, t_stop=t_stop_custom32, dtype=np.float16)
1978-
assert_neo_object_is_compliant(train)
1979-
train = SpikeTrain(data32, copy=True, t_start=t_start_custom32, t_stop=t_stop_custom32, dtype=np.float32)
1980-
assert_neo_object_is_compliant(train)
1981-
train = SpikeTrain(data32, copy=True, t_start=t_start_custom32, t_stop=t_stop_custom32, dtype=np.float64)
1982-
assert_neo_object_is_compliant(train)
1983-
1984-
train = SpikeTrain(data32, copy=True, t_start=t_start_custom64, t_stop=t_stop_custom64)
1985-
assert_neo_object_is_compliant(train)
1986-
train = SpikeTrain(data32, copy=True, t_start=t_start_custom64, t_stop=t_stop_custom64, dtype=np.float16)
1987-
assert_neo_object_is_compliant(train)
1988-
train = SpikeTrain(data32, copy=True, t_start=t_start_custom64, t_stop=t_stop_custom64, dtype=np.float32)
1989-
assert_neo_object_is_compliant(train)
1990-
train = SpikeTrain(data32, copy=True, t_start=t_start_custom64, t_stop=t_stop_custom64, dtype=np.float64)
1991-
assert_neo_object_is_compliant(train)
1992-
1993-
# This use to bug - see ticket #38
1994-
train = SpikeTrain(data16, copy=True, t_start=t_start, t_stop=t_stop)
1995-
assert_neo_object_is_compliant(train)
1996-
train = SpikeTrain(data16, copy=True, t_start=t_start, t_stop=t_stop, dtype=np.float64)
1997-
assert_neo_object_is_compliant(train)
1998-
1999-
train = SpikeTrain(data32, copy=True, t_start=t_start, t_stop=t_stop)
2000-
assert_neo_object_is_compliant(train)
2001-
train = SpikeTrain(data32, copy=True, t_start=t_start, t_stop=t_stop, dtype=np.float64)
2002-
assert_neo_object_is_compliant(train)
2003-
2004-
train = SpikeTrain(data32, copy=True, t_start=t_start64, t_stop=t_stop64)
2005-
assert_neo_object_is_compliant(train)
2006-
train = SpikeTrain(data32, copy=True, t_start=t_start64, t_stop=t_stop64, dtype=np.float64)
2007-
assert_neo_object_is_compliant(train)
2008-
"""
1851+
20091852
def test_as_array(self):
20101853
data = np.arange(10.0)
20111854
st = SpikeTrain(data, t_stop=10.0, units="ms")

0 commit comments

Comments
 (0)