Skip to content

Commit 5e3c0b3

Browse files
committed
fix some failing tests related to pretty-printing
1 parent 2d63e18 commit 5e3c0b3

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

neo/core/spiketrain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ def __init__(self, times, t_stop, units=None, dtype=None, copy=True,
347347

348348
def _repr_pretty_(self, pp, cycle):
349349
waveforms = ""
350-
if self.waveforms:
351-
waveforms = "with waveforms"
350+
if self.waveforms is not None:
351+
waveforms = " with waveforms"
352352
pp.text(f"{self.__class__.__name__} containing {self.size} spikes{waveforms}; "
353353
f"units {self.units.dimensionality.string}; datatype {self.dtype} ")
354354
if self._has_repr_pretty_attrs_():

neo/test/coretest/test_epoch.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,10 @@ def test__pretty(self):
206206
assert_neo_object_is_compliant(epc)
207207

208208
prepr = pretty(epc)
209-
targ = ("Epoch\nname: '%s'\ndescription: '%s'\nannotations: %s"
210-
"" % (epc.name, epc.description, pretty(epc.annotations)))
209+
targ = (f"Epoch containing {len(epc)} epochs with labels; "
210+
f"time units {epc.units.dimensionality.string}; datatype float64 "
211+
f"\nname: '{epc.name}'\ndescription: '{epc.description}'"
212+
f"\nannotations: {pretty(epc.annotations)}")
211213

212214
self.assertEqual(prepr, targ)
213215

neo/test/coretest/test_event.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,10 @@ def test__pretty(self):
473473
assert_neo_object_is_compliant(evt)
474474

475475
prepr = pretty(evt)
476-
targ = ("Event\nname: '%s'\ndescription: '%s'\nannotations: %s"
477-
"" % (evt.name, evt.description, pretty(evt.annotations)))
476+
targ = (f"Event containing {len(evt)} events with labels; "
477+
f"time units {evt.units.dimensionality.string}; datatype float64 "
478+
f"\nname: '{evt.name}'\ndescription: '{evt.description}'"
479+
f"\nannotations: {pretty(evt.annotations)}")
478480

479481
self.assertEqual(prepr, targ)
480482

neo/test/coretest/test_spiketrain.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,6 +1973,12 @@ def test__pretty(self):
19731973
res = pretty(self.train1)
19741974
targ = ("SpikeTrain\n" + "name: '%s'\ndescription: '%s'\nannotations: %s"
19751975
"" % (self.name1, self.description1, pretty(self.ann1)))
1976+
targ = (f"SpikeTrain containing {len(self.train1)} spikes with waveforms; "
1977+
f"units {self.train1.units.dimensionality.string}; datatype float64 "
1978+
f"\nname: '{self.name1}'\ndescription: '{self.description1}'"
1979+
f"\nannotations: {pretty(self.ann1)}"
1980+
f"\ntime: {self.train1.t_start} to {self.train1.t_stop}")
1981+
19761982
self.assertEqual(res, targ)
19771983

19781984

0 commit comments

Comments
 (0)