Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_properties(self):
reader = morphio.SpikeReportReader(self.filename)
# assertAlmostEqual fails due to a float <-> double conversion error
assert(round(reader.end_time - 9.975, 6) == 0)
# Until some read operation beyond the end is performed the report is
# not ended
assert(not reader.has_ended)
# numpy.nextafter(reader.end_time) should be sufficient, but the result
# can't be distinguished from end_time after demoted to float in the C++
# side.
spikes = reader.get_spikes(0, float("inf"))
assert(reader.has_ended)
def test_get_spikes_bad(self):
reader = morphio.SpikeReportReader(self.filename)
self.assertRaises(RuntimeError, lambda: reader.get_spikes(0, 0))
self.assertRaises(RuntimeError, lambda: reader.get_spikes(0, -1))
def test_get_spikes_filtered(self):
gids = {1, 10, 100}
reader = morphio.SpikeReportReader(self.filename, gids)
spikes = reader.get_spikes(0, float("inf"))
for time, gid in spikes:
assert(gid in gids)
def test_get_spikes(self):
reader = morphio.SpikeReportReader(self.filename)
spikes = reader.get_spikes(-10, 0)
assert(len(spikes) == 0)
spikes = reader.get_spikes(1, 5)
assert(spikes[0][0] >= 1)
assert(spikes[-1][0] < 5)
spikes = reader.get_spikes(7, 9)
assert(spikes[0][0] >= 7)
assert(spikes[-1][0] < 9)
self.assertRaises(RuntimeError, lambda: morphio.SpikeReportReader("foo"))
def test_creation(self):
reader = morphio.SpikeReportReader(self.filename)