def check(self, data): foo = Foo(data) with h5tmp() as f: writer = Writer(f) writer.dict('data', data=data) reader = Reader(f) data_bis = reader.dict('data') self.assertDictEqual(data, data_bis)
def test_dict(self): data = {1:'one', 'two': 2, 'tree': [1,2,'three']} foo = Foo(data) with h5tmp() as f: writer = Writer(f) writer.yaml('data', data=data) reader = Reader(f) data_bis = reader.yaml('data') self.assertDictEqual(data, data_bis)
def test_int(self): data = np.arange(5) foo = Foo(data) with h5tmp() as f: writer = Writer(f) writer.array('data', data=data) reader = Reader(f) data_bis = reader.array('data') np.testing.assert_array_equal(data, data_bis)
def check(self, data): foo = {'data': data} bar = {} with h5tmp() as f: writer = Writer(f, from_dict=foo) writer.dict('data') reader = Reader(f, to_dict=bar) data_bis = reader.dict('data') self.assertDictEqual(data, data_bis)
def test_int(self): data = 5 foo = Foo(data) with h5tmp() as f: writer = Writer(f) writer.scalar('data', data=data) reader = Reader(f) data_bis = reader.scalar('data') self.assertEqual(data, data_bis)
def check(self, data): foo = Foo(data) bar = Bar() with h5tmp() as f: writer = Writer(f, from_object=foo) writer.dict('data') reader = Reader(f, to_object=bar) reader.dict('data') self.assertDictEqual(foo.data, bar.data)
def test_int(self): data = np.arange(5) foo = {'data': data} bar = {} with h5tmp() as f: writer = Writer(f, from_dict=foo) writer.array('data') reader = Reader(f, to_dict=bar) data_bis = reader.array('data') np.testing.assert_array_equal(data, data_bis)
def test_int(self): data = np.arange(5) foo = Foo(data) bar = Bar() with h5tmp() as f: writer = Writer(f, from_object=foo) writer.array('data') reader = Reader(f, to_object=bar) reader.array('data') np.testing.assert_array_equal(foo.data, bar.data)
def test_dict(self): data = {1:'one', 'two': 2, 'tree': [1,2,'three']} foo = Foo(data) bar = Bar() with h5tmp() as f: writer = Writer(f, from_object=foo) writer.yaml('data') reader = Reader(f, to_object=bar) reader.yaml('data') self.assertDictEqual(foo.data, bar.data)
def test_int(self): data = 5 foo = {'data': data} bar = {} with h5tmp() as f: writer = Writer(f, from_dict=foo) writer.scalar('data') reader = Reader(f, to_dict=bar) data_bis = reader.scalar('data') self.assertEqual(data, data_bis)
def test_dict(self): data = {1:'one', 'two': 2, 'tree': [1,2,'three']} foo = {'data': data} bar = {} with h5tmp() as f: writer = Writer(f, from_dict=foo) writer.yaml('data') reader = Reader(f, to_dict=bar) data_bis = reader.yaml('data') self.assertDictEqual(data, data_bis)
def test_int(self): data = 5 foo = Foo(data) bar = Bar() with h5tmp() as f: writer = Writer(f, from_object=foo) writer.scalar('data') reader = Reader(f, to_object=bar) reader.scalar('data') self.assertEqual(foo.data, bar.data)
def test_int2array(self): data = {12: np.array([1,2]), 34: np.array([3,4])} foo = Foo(data) with h5tmp() as f: writer = Writer(f) writer.dict('data', data=data) reader = Reader(f) data_bis = reader.dict('data') for array1, array2 in zip(data.values(), data_bis.values()): np.testing.assert_array_equal(array1, array2)
def test_int2array(self): data = {12: np.array([1,2]), 34: np.array([3,4])} foo = {'data': data} bar = {} with h5tmp() as f: writer = Writer(f, from_dict=foo) writer.dict('data') reader = Reader(f, to_dict=bar) data_bis = reader.dict('data') for array1, array2 in zip(data.values(), data_bis.values()): np.testing.assert_array_equal(array1, array2)
def test_array(self): data = [ np.array([1,5,2]), np.array([6,0]), np.array([]), np.array([1,3,4]), np.array([7,]) ] foo = Foo(data) with h5tmp() as f: writer = Writer(f) writer.crs('data', data=data) reader = Reader(f) data_bis = reader.crs('data') for array1, array2 in zip(data, data_bis): np.testing.assert_array_equal(array1, array2)
def test_int2array(self): data = {12: np.array([1,2]), 34: np.array([3,4])} foo = Foo(data) bar = Bar() with h5tmp() as f: writer = Writer(f, from_object=foo) writer.dict('data') reader = Reader(f, to_object=bar) reader.dict('data') np.testing.assert_array_equal(foo.data[12], bar.data[12]) np.testing.assert_array_equal(foo.data[34], bar.data[34])
def test_array(self): data = [ np.array([1,5,2]), np.array([6,0]), np.array([]), np.array([1,3,4]), np.array([7,]) ] foo = {'data': data} bar = {} with h5tmp() as f: writer = Writer(f, from_dict=foo) writer.crs('data') reader = Reader(f, to_dict=bar) data_bis = reader.crs('data') for array1, array2 in zip(data, data_bis): np.testing.assert_array_equal(array1, array2)
def test_array(self): data = [ np.array([1,5,2]), np.array([6,0]), np.array([]), np.array([1,3,4]), np.array([7,]) ] foo = Foo(data) bar = Bar() with h5tmp() as f: writer = Writer(f, from_object=foo) writer.crs('data') reader = Reader(f, to_object=bar) reader.crs('data') np.testing.assert_array_equal(foo.data[0], bar.data[0]) np.testing.assert_array_equal(foo.data[1], bar.data[1]) np.testing.assert_array_equal(foo.data[2], bar.data[2]) np.testing.assert_array_equal(foo.data[3], bar.data[3]) np.testing.assert_array_equal(foo.data[4], bar.data[4])