MCPcopy Create free account
hub / github.com/PyTables/PyTables / test01_copy

Method test01_copy

tables/tests/test_earray.py:1845–1898  ·  view source on GitHub ↗

Checking EArray.copy() method.

(self)

Source from the content-addressed store, hash-verified

1843class CopyTestCase(common.TempFileMixin, common.PyTablesTestCase):
1844
1845 def test01_copy(self):
1846 """Checking EArray.copy() method."""
1847
1848 if common.verbose:
1849 print("\n", "-=" * 30)
1850 print("Running %s.test01_copy..." % self.__class__.__name__)
1851
1852 # Create an EArray
1853 atom = tb.Int16Atom()
1854 array1 = self.h5file.create_earray(
1855 self.h5file.root,
1856 "array1",
1857 atom=atom,
1858 shape=(0, 2),
1859 title="title array1",
1860 )
1861 array1.append(np.array([[456, 2], [3, 457]], dtype="int16"))
1862
1863 if self.close:
1864 if common.verbose:
1865 print("(closing file version)")
1866 self._reopen(mode="a")
1867 array1 = self.h5file.root.array1
1868
1869 # Copy it to another location
1870 array2 = array1.copy("/", "array2")
1871
1872 if self.close:
1873 if common.verbose:
1874 print("(closing file version)")
1875 self._reopen()
1876 array1 = self.h5file.root.array1
1877 array2 = self.h5file.root.array2
1878
1879 if common.verbose:
1880 print("array1-->", array1.read())
1881 print("array2-->", array2.read())
1882 # print("dirs-->", dir(array1), dir(array2))
1883 print("attrs array1-->", repr(array1.attrs))
1884 print("attrs array2-->", repr(array2.attrs))
1885
1886 # Check that all the elements are equal
1887 self.assertTrue(common.allequal(array1.read(), array2.read()))
1888
1889 # Assert other properties in array
1890 self.assertEqual(array1.nrows, array2.nrows)
1891 self.assertEqual(array1.shape, array2.shape)
1892 self.assertEqual(array1.extdim, array2.extdim)
1893 self.assertEqual(array1.flavor, array2.flavor)
1894 self.assertEqual(array1.atom.dtype, array2.atom.dtype)
1895 self.assertEqual(array1.atom.type, array2.atom.type)
1896 self.assertEqual(array1.atom.itemsize, array2.atom.itemsize)
1897 self.assertEqual(array1.title, array2.title)
1898 self.assertEqual(str(array1.atom), str(array2.atom))
1899
1900 def test02_copy(self):
1901 """Checking EArray.copy() method (where specified)"""

Callers

nothing calls this directly

Calls 5

create_earrayMethod · 0.80
appendMethod · 0.45
_reopenMethod · 0.45
copyMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected