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

Method test04_copy

tables/tests/test_earray.py:2110–2150  ·  view source on GitHub ↗

Checking EArray.copy() method (checking title copying)

(self)

Source from the content-addressed store, hash-verified

2108 self.assertEqual(str(array1.atom), str(array2.atom))
2109
2110 def test04_copy(self):
2111 """Checking EArray.copy() method (checking title copying)"""
2112
2113 if common.verbose:
2114 print("\n", "-=" * 30)
2115 print("Running %s.test04_copy..." % self.__class__.__name__)
2116
2117 # Create an EArray
2118 atom = tb.Int16Atom()
2119 array1 = self.h5file.create_earray(
2120 self.h5file.root,
2121 "array1",
2122 atom=atom,
2123 shape=(0, 2),
2124 title="title array1",
2125 )
2126 array1.append(np.array([[456, 2], [3, 457]], dtype="int16"))
2127 # Append some user attrs
2128 array1.attrs.attr1 = "attr1"
2129 array1.attrs.attr2 = 2
2130
2131 if self.close:
2132 if common.verbose:
2133 print("(closing file version)")
2134 self._reopen(mode="a")
2135 array1 = self.h5file.root.array1
2136
2137 # Copy it to another Array
2138 array2 = array1.copy("/", "array2", title="title array2")
2139
2140 if self.close:
2141 if common.verbose:
2142 print("(closing file version)")
2143 self._reopen()
2144 array1 = self.h5file.root.array1
2145 array2 = self.h5file.root.array2
2146
2147 # Assert user attributes
2148 if common.verbose:
2149 print("title of destination array-->", array2.title)
2150 self.assertEqual(array2.title, "title array2")
2151
2152 def test05_copy(self):
2153 """Checking EArray.copy() method (user attributes copied)"""

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected