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

Method test02_copy

tables/tests/test_earray.py:1900–1954  ·  view source on GitHub ↗

Checking EArray.copy() method (where specified)

(self)

Source from the content-addressed store, hash-verified

1898 self.assertEqual(str(array1.atom), str(array2.atom))
1899
1900 def test02_copy(self):
1901 """Checking EArray.copy() method (where specified)"""
1902
1903 if common.verbose:
1904 print("\n", "-=" * 30)
1905 print("Running %s.test02_copy..." % self.__class__.__name__)
1906
1907 # Create an EArray
1908 atom = tb.Int16Atom()
1909 array1 = self.h5file.create_earray(
1910 self.h5file.root,
1911 "array1",
1912 atom=atom,
1913 shape=(0, 2),
1914 title="title array1",
1915 )
1916 array1.append(np.array([[456, 2], [3, 457]], dtype="int16"))
1917
1918 if self.close:
1919 if common.verbose:
1920 print("(closing file version)")
1921 self._reopen(mode="a")
1922 array1 = self.h5file.root.array1
1923
1924 # Copy to another location
1925 group1 = self.h5file.create_group("/", "group1")
1926 array2 = array1.copy(group1, "array2")
1927
1928 if self.close:
1929 if common.verbose:
1930 print("(closing file version)")
1931 self._reopen()
1932 array1 = self.h5file.root.array1
1933 array2 = self.h5file.root.group1.array2
1934
1935 if common.verbose:
1936 print("array1-->", array1.read())
1937 print("array2-->", array2.read())
1938 # print("dirs-->", dir(array1), dir(array2))
1939 print("attrs array1-->", repr(array1.attrs))
1940 print("attrs array2-->", repr(array2.attrs))
1941
1942 # Check that all the elements are equal
1943 self.assertTrue(common.allequal(array1.read(), array2.read()))
1944
1945 # Assert other properties in array
1946 self.assertEqual(array1.nrows, array2.nrows)
1947 self.assertEqual(array1.shape, array2.shape)
1948 self.assertEqual(array1.extdim, array2.extdim)
1949 self.assertEqual(array1.flavor, array2.flavor)
1950 self.assertEqual(array1.atom.dtype, array2.atom.dtype)
1951 self.assertEqual(array1.atom.type, array2.atom.type)
1952 self.assertEqual(array1.atom.itemsize, array2.atom.itemsize)
1953 self.assertEqual(array1.title, array2.title)
1954 self.assertEqual(str(array1.atom), str(array2.atom))
1955
1956 def test03a_copy(self):
1957 """Checking EArray.copy() method (python flavor)"""

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected