class TestSomaReportPopulation(unittest.TestCase): def setUp(self): path = os.path.join(PATH, "somas.h5") self.test_obj = SomaReportReader(path) def test_get_all_population(self): self.assertEqual(self.test_obj.get_populations_names(), ['All', 'soma1', 'soma2']) def test_get_population(self): self.assertTrue(isinstance(self.test_obj['All'], SomaReportPopulation)) def test_get_inexistant_population(self): self.assertRaises(RuntimeError, self.test_obj.__getitem__, 'foobar') def test_get_reports_from_population(self): self.assertEqual(self.test_obj['All'].times, (0., 1., 0.1)) self.assertEqual(self.test_obj['All'].time_units, 'ms') self.assertEqual(self.test_obj['All'].data_units, 'mV') self.assertTrue(self.test_obj['All'].sorted) self.assertEqual(len(self.test_obj['All'].get().data), 20) # Number of nodes sel = self.test_obj['All'].get(node_ids=[13, 14], tstart=0.8, tstop=1.0) self.assertEqual(len(sel.index), 2) # Number of timestamp (0.8 and 0.9) self.assertEqual(list(sel.data.keys()), [13, 14])
def test_path_ctor(): # make sure constructors that take file paths can use pathlib.Path path = pathlib.Path(PATH) NodeStorage(path / 'nodes1.h5') EdgeStorage(path / 'edges1.h5') SpikeReader(path / 'spikes.h5') SomaReportReader(path / 'somas.h5') ElementReportReader(path / 'elements.h5')
def test_path_ctor(): # make sure constructors that take file paths can use pathlib.Path path = pathlib.Path(PATH) NodeStorage(path / 'nodes1.h5') EdgeStorage(path / 'edges1.h5') SpikeReader(path / 'spikes.h5') SomaReportReader(path / 'somas.h5') ElementReportReader(path / 'elements.h5') NodeSets.from_file(path / 'node_sets.json') CircuitConfig.from_file(path / 'config/circuit_config.json')
class TestSomaReportPopulation(unittest.TestCase): def setUp(self): path = os.path.join(PATH, "somas.h5") self.test_obj = SomaReportReader(path) def test_get_all_population(self): self.assertEqual(self.test_obj.get_population_names(), ['All', 'soma1', 'soma2']) def test_get_population(self): self.assertTrue(isinstance(self.test_obj['All'], SomaReportPopulation)) def test_get_inexistant_population(self): self.assertRaises(RuntimeError, self.test_obj.__getitem__, 'foobar') def test_get_reports_from_population(self): self.assertEqual(self.test_obj['All'].times, (0., 1., 0.1)) self.assertEqual(self.test_obj['All'].time_units, 'ms') self.assertEqual(self.test_obj['All'].data_units, 'mV') self.assertFalse(self.test_obj['All'].sorted) self.assertEqual(len(self.test_obj['All'].get().ids), 20) # Number of nodes self.assertEqual(len(self.test_obj['All'].get().times), 10) # number of times self.assertEqual(len(self.test_obj['All'].get().data), 10) # should be the same sel = self.test_obj['All'].get(node_ids=[13, 14], tstart=0.8, tstop=1.0) self.assertEqual(len(sel.times), 2) # Number of timestamp (0.8 and 0.9) keys = sel.ids keys_ref = np.asarray([13, 14]) self.assertTrue((keys == keys_ref).all()) np.testing.assert_allclose(sel.data, [[13.8, 14.8], [13.9, 14.9]]) sel_all = self.test_obj['All'].get() keys_all = sel_all.ids keys_all_ref = np.asarray([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ]) self.assertTrue((keys_all == keys_all_ref).all()) sel_empty = self.test_obj['All'].get(node_ids=[]) np.testing.assert_allclose(sel_empty.data, np.empty(shape=(0, 0))) def test_get_node_id_element_id_mapping(self): self.assertEqual( self.test_obj['All'].get_node_id_element_id_mapping([[3, 5]]), [3, 4])
def setUp(self): path = os.path.join(PATH, "somas.h5") self.test_obj = SomaReportReader(path)