Esempio n. 1
0
 def test_recursive_create_dataset(self):
     g = memh5.MemGroup()
     data = np.arange(10)
     g.create_dataset("a/ra", data=data)
     self.assertTrue(memh5.is_group(g["a"]))
     self.assertTrue(np.all(g["a/ra"][:] == data))
     g["a"].create_dataset("/ra", data=data)
     print g.keys()
     self.assertTrue(np.all(g["ra"][:] == data))
Esempio n. 2
0
 def test_recursive_create_dataset(self):
     g = memh5.MemGroup()
     data = np.arange(10)
     g.create_dataset('a/ra', data=data)
     self.assertTrue(memh5.is_group(g['a']))
     self.assertTrue(np.all(g['a/ra'][:] == data))
     g['a'].create_dataset('/ra', data=data)
     print g.keys()
     self.assertTrue(np.all(g['ra'][:] == data))
Esempio n. 3
0
 def assertGroupsEqual(self, a, b):
     self.assertEqual(list(a.keys()), list(b.keys()))
     self.assertAttrsEqual(a.attrs, b.attrs)
     for key in a.keys():
         this_a = a[key]
         this_b = b[key]
         if not memh5.is_group(a[key]):
             self.assertAttrsEqual(this_a.attrs, this_b.attrs)
             self.assertTrue(np.allclose(this_a, this_b))
         else:
             self.assertGroupsEqual(this_a, this_b)
Esempio n. 4
0
 def assertGroupsEqual(self, a, b):
     self.assertEqual(a.keys(), b.keys())
     self.assertAttrsEqual(a.attrs, b.attrs)
     for key in a.keys():
         this_a = a[key]
         this_b = b[key]
         if not memh5.is_group(a[key]):
             self.assertAttrsEqual(this_a.attrs, this_b.attrs)
             self.assertTrue(np.allclose(this_a, this_b))
         else:
             self.assertGroupsEqual(this_a, this_b)
Esempio n. 5
0
    def test_recursive_create_dataset(self):
        g = memh5.MemGroup()
        data = np.arange(10)
        g.create_dataset("a/ra", data=data)
        self.assertTrue(memh5.is_group(g["a"]))
        self.assertTrue(np.all(g["a/ra"][:] == data))
        g["a"].create_dataset("/ra", data=data)
        self.assertTrue(np.all(g["ra"][:] == data))
        self.assertIsInstance(g["a/ra"].parent, memh5.MemGroup)

        # Check that d keeps g in scope.
        d = g["a/ra"]
        del g
        gc.collect()
        self.assertTrue(np.all(d.file["ra"][:] == data))
Esempio n. 6
0
    def test_recursive_create_dataset(self):
        g = memh5.MemGroup()
        data = np.arange(10)
        g.create_dataset('a/ra', data=data)
        self.assertTrue(memh5.is_group(g['a']))
        self.assertTrue(np.all(g['a/ra'][:] == data))
        g['a'].create_dataset('/ra', data=data)
        self.assertTrue(np.all(g['ra'][:] == data))
        self.assertIsInstance(g['a/ra'].parent, memh5.MemGroup)

        # Check that d keeps g in scope.
        d = g['a/ra']
        del g
        gc.collect()
        self.assertTrue(np.all(d.file['ra'][:] == data))
Esempio n. 7
0
    def datasets(self):
        """Return the datasets in this container.

        Do not try to add a new dataset by assigning to an item of this
        property. Use `create_dataset` instead.

        Returns
        -------
        datasets : read only dictionary
            Entries are :mod:`caput.memh5` datasets.

        """
        out = {}
        for name, value in self._data.iteritems():
            if not memh5.is_group(value):
                out[name] = value
        return memh5.ro_dict(out)