def test_get_event_data(self): data = self.data_dict['event_data'] reader = nsdf.NSDFReader(self.filename) file_data = reader.get_event_data('cells', 'spike') self.assertEqual(set(file_data.get_sources()), set(data.get_sources())) self.assertEqual(data.unit, file_data.unit) self.assertEqual(data.name, file_data.name) for src in data.get_sources(): var = data.get_data(src) fvar = file_data.get_data(src) np.testing.assert_allclose(var, fvar)
def test_get_uniform_data(self): reader = nsdf.NSDFReader(self.filename) file_data = reader.get_uniform_data('granule', 'Vm') data = self.data_dict['uniform_data'] self.assertEqual(set(file_data.get_sources()), set(data.get_sources())) self.assertEqual(data.unit, file_data.unit) self.assertEqual(data.name, file_data.name) self.assertEqual(data.tunit, file_data.tunit) self.assertAlmostEqual(data.dt, file_data.dt) for src in data.get_sources(): np.testing.assert_allclose(data.get_data(src), file_data.get_data(src))
def test_get_nonuniform_data(self): data = self.data_dict['nonuniform_data'] reader = nsdf.NSDFReader(self.filename) file_data = reader.get_nonuniform_data('mitral', 'Im') self.assertEqual(set(file_data.get_sources()), set(data.get_sources())) self.assertEqual(data.unit, file_data.unit) self.assertEqual(data.name, file_data.name) self.assertEqual(data.tunit, file_data.tunit) for src in data.get_sources(): var, times = data.get_data(src) fvar, ftimes = file_data.get_data(src) np.testing.assert_allclose(var, fvar) np.testing.assert_allclose(times, ftimes)
def test_attributes(self): reader = nsdf.NSDFReader(self.filename) self.assertEqual(reader.title, self.data_dict['title']) self.assertEqual(reader.description, self.data_dict['description']) for left, right in it.izip_longest(reader.creator, self.data_dict['creator']): self.assertEqual(left, right) for left, right in it.izip_longest(reader.contributor, self.data_dict['contributor']): self.assertEqual(left, right) for left, right in it.izip_longest(reader.software, self.data_dict['software']): self.assertEqual(left, right) for left, right in it.izip_longest(reader.method, self.data_dict['method']): self.assertEqual(left, right) self.assertEqual(reader.tstart, self.data_dict['tstart'].isoformat()) self.assertEqual(reader.tend, self.data_dict['tend'].isoformat()) self.assertEqual(reader.license, self.data_dict['license']) self.assertEqual(reader.rights, self.data_dict['rights'])
def _init_reading(self): reader = nsdf.NSDFReader(self.filename) self.file_datetime = datetime.fromtimestamp(os.stat(self.filename).st_mtime) self.objects_dict = {} return reader
def read_hh_vm(): reader = nsdf.NSDFReader('hh_vm.h5') data = reader.get_uniform_data('compartment_population', 'Vm')