Skip to content

Commit 8e180f4

Browse files
authored
Merge pull request #1586 from NeuralEnsemble/black-formatting
Black formatting
2 parents b17979a + 2f007e0 commit 8e180f4

File tree

4 files changed

+27
-30
lines changed

4 files changed

+27
-30
lines changed

neo/core/spiketrain.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,8 @@ def normalize_times_array(times, units=None, dtype=None, copy=None):
194194
"""
195195

196196
if copy is not None:
197-
raise ValueError(
198-
"`copy` is now deprecated in Neo due to removal in NumPy 2.0 and will be removed in 0.15.0."
199-
)
200-
197+
raise ValueError("`copy` is now deprecated in Neo due to removal in NumPy 2.0 and will be removed in 0.15.0.")
198+
201199
if dtype is None:
202200
if not hasattr(times, "dtype"):
203201
dtype = float
@@ -218,14 +216,20 @@ def normalize_times_array(times, units=None, dtype=None, copy=None):
218216
units = None # units will be taken from times, avoids copying
219217
else:
220218
raise ValueError("cannot rescale and return view")
221-
222219

223220
# check to make sure the units are time
224221
# this approach is orders of magnitude faster than comparing the
225222
# reference dimensionality
226223
if len(dim) != 1 or list(dim.values())[0] != 1 or not isinstance(list(dim.keys())[0], pq.UnitTime):
227224
ValueError(f"Units have dimensions {dim.simplified}, not [time]")
228-
return pq.Quantity(times, units=units, dtype=dtype,), dim
225+
return (
226+
pq.Quantity(
227+
times,
228+
units=units,
229+
dtype=dtype,
230+
),
231+
dim,
232+
)
229233

230234

231235
class SpikeTrain(DataObject):
@@ -807,19 +811,19 @@ def time_shift(self, t_shift):
807811
t_stop = self.t_stop + t_shift
808812
t_start = self.t_start + t_shift
809813
new_st = SpikeTrain(
810-
times=times,
811-
t_stop=t_stop,
812-
units=self.unit,
813-
sampling_rate=self.sampling_rate,
814-
t_start=t_start,
815-
waveforms=self.waveforms,
816-
left_sweep=self.left_sweep,
817-
name=self.name,
818-
file_origin=self.file_origin,
819-
description=self.description,
820-
array_annotations=deepcopy(self.array_annotations),
821-
**self.annotations,
822-
)
814+
times=times,
815+
t_stop=t_stop,
816+
units=self.unit,
817+
sampling_rate=self.sampling_rate,
818+
t_start=t_start,
819+
waveforms=self.waveforms,
820+
left_sweep=self.left_sweep,
821+
name=self.name,
822+
file_origin=self.file_origin,
823+
description=self.description,
824+
array_annotations=deepcopy(self.array_annotations),
825+
**self.annotations,
826+
)
823827

824828
# Here we can safely copy the array annotations since we know that
825829
# the length of the SpikeTrain does not change.

neo/rawio/plexonrawio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def _parse_header(self):
157157

158158
upper_byte_of_5_byte_timestamp = int(bl_header["UpperByteOf5ByteTimestamp"])
159159
bl_header_timestamp = int(bl_header["TimeStamp"])
160-
self._last_timestamps = upper_byte_of_5_byte_timestamp * 2**32 + bl_header_timestamp
160+
self._last_timestamps = upper_byte_of_5_byte_timestamp * 2**32 + bl_header_timestamp
161161

162162
# ... and finalize them in self._data_blocks
163163
# for a faster access depending on type (1, 4, 5)

neo/test/coretest/test_analogsignal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +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-
135134
def test__create_with_additional_argument(self):
136135
signal = AnalogSignal(
137136
[1, 2, 3], units="mV", sampling_rate=1 * pq.kHz, file_origin="crack.txt", ratname="Nicolas"
@@ -1762,6 +1761,7 @@ def test__pickle_2d(self):
17621761
fobj.close()
17631762
os.remove("./pickle")
17641763

1764+
17651765
class TestAnalogSignalSampling(unittest.TestCase):
17661766
def test___get_sampling_rate__period_none_rate_none_ValueError(self):
17671767
sampling_rate = None

neo/test/coretest/test_spiketrain.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ def test__create_from_list_no_start_stop_units(self):
236236
self.result_spike_check(train1, st_out, t_start_out, t_stop_out, dtype, units)
237237
self.result_spike_check(train2, st_out, t_start_out, t_stop_out, dtype, units)
238238

239-
240239
def test__create_from_array(self):
241240
times = np.arange(10)
242241
t_start = 0.0 * pq.s
@@ -297,7 +296,6 @@ def test__create_from_array_no_start_stop_units_with_dtype(self):
297296
self.result_spike_check(train1, st_out, t_start_out, t_stop_out, dtype, units)
298297
self.result_spike_check(train2, st_out, t_start_out, t_stop_out, dtype, units)
299298

300-
301299
def test__create_from_quantity_array(self):
302300
times = np.arange(10) * pq.ms
303301
t_start = 0.0 * pq.s
@@ -328,7 +326,6 @@ def test__create_from_quantity_array_with_dtype(self):
328326
self.result_spike_check(train1, st_out, t_start_out, t_stop_out, dtype, units)
329327
self.result_spike_check(train2, st_out, t_start_out, t_stop_out, dtype, units)
330328

331-
332329
def test__create_from_quantity_array_no_start_stop_units(self):
333330
times = np.arange(10) * pq.ms
334331
t_start = 0.0
@@ -359,7 +356,6 @@ def test__create_from_quantity_array_no_start_stop_units_with_dtype(self):
359356
self.result_spike_check(train1, st_out, t_start_out, t_stop_out, dtype, units)
360357
self.result_spike_check(train2, st_out, t_start_out, t_stop_out, dtype, units)
361358

362-
363359
def test__create_from_list_without_units_should_raise_ValueError(self):
364360
times = range(10)
365361
t_start = 0.0 * pq.s
@@ -1229,7 +1225,7 @@ def test_correct_times(self):
12291225
self.assertIsInstance(result.array_annotations, ArrayDict)
12301226

12311227
def test_rescaling_units(self):
1232-
train3 = self.train1.duplicate_with_new_data(signal=(self.train1.times.magnitude/1000) * pq.millisecond)
1228+
train3 = self.train1.duplicate_with_new_data(signal=(self.train1.times.magnitude / 1000) * pq.millisecond)
12331229
train3.segment = self.train1.segment
12341230
train3.array_annotate(**self.arr_ann1)
12351231
# Array annotations merge warning was already tested, can be ignored now
@@ -1495,7 +1491,6 @@ def test_array_annotations(self):
14951491

14961492
class TestChanging(unittest.TestCase):
14971493

1498-
14991494
# now we test default behavior here so change false to None
15001495
def test_change_with_default(self):
15011496
# Changing spike train also changes data, because it is a view
@@ -1524,7 +1519,6 @@ def test_change_and_rescale_true(self):
15241519
data = [3, 4, 5] * pq.s
15251520
self.assertRaises(ValueError, SpikeTrain, data, units="ms", t_stop=10000)
15261521

1527-
15281522
def test_change_and_data_not_quantity(self):
15291523
# Changing spike train also changes data, because it is a view
15301524
# Data source is array
@@ -1542,7 +1536,6 @@ def test__dtype_change(self):
15421536
data = np.array([3, 4, 5])
15431537
self.assertRaises(ValueError, SpikeTrain, data, units="sec", t_stop=101, dtype=np.float64)
15441538

1545-
15461539
def test_changing_slice_changes_original_spiketrain(self):
15471540
# If we slice a spiketrain and then change the slice, the
15481541
# original spiketrain should change.
@@ -1848,7 +1841,7 @@ def test__pretty(self):
18481841

18491842

18501843
class TestMiscellaneous(unittest.TestCase):
1851-
1844+
18521845
def test_as_array(self):
18531846
data = np.arange(10.0)
18541847
st = SpikeTrain(data, t_stop=10.0, units="ms")

0 commit comments

Comments
 (0)