Checking EArray.copy() method (user attributes copied)
(self)
| 2150 | self.assertEqual(array2.title, "title array2") |
| 2151 | |
| 2152 | def test05_copy(self): |
| 2153 | """Checking EArray.copy() method (user attributes copied)""" |
| 2154 | |
| 2155 | if common.verbose: |
| 2156 | print("\n", "-=" * 30) |
| 2157 | print("Running %s.test05_copy..." % self.__class__.__name__) |
| 2158 | |
| 2159 | # Create an EArray |
| 2160 | atom = tb.Int16Atom() |
| 2161 | array1 = self.h5file.create_earray( |
| 2162 | self.h5file.root, |
| 2163 | "array1", |
| 2164 | atom=atom, |
| 2165 | shape=(0, 2), |
| 2166 | title="title array1", |
| 2167 | ) |
| 2168 | array1.append(np.array([[456, 2], [3, 457]], dtype="int16")) |
| 2169 | # Append some user attrs |
| 2170 | array1.attrs.attr1 = "attr1" |
| 2171 | array1.attrs.attr2 = 2 |
| 2172 | |
| 2173 | if self.close: |
| 2174 | if common.verbose: |
| 2175 | print("(closing file version)") |
| 2176 | self._reopen(mode="a") |
| 2177 | array1 = self.h5file.root.array1 |
| 2178 | |
| 2179 | # Copy it to another Array |
| 2180 | array2 = array1.copy("/", "array2", copyuserattrs=1) |
| 2181 | |
| 2182 | if self.close: |
| 2183 | if common.verbose: |
| 2184 | print("(closing file version)") |
| 2185 | self._reopen() |
| 2186 | array1 = self.h5file.root.array1 |
| 2187 | array2 = self.h5file.root.array2 |
| 2188 | |
| 2189 | if common.verbose: |
| 2190 | print("attrs array1-->", repr(array1.attrs)) |
| 2191 | print("attrs array2-->", repr(array2.attrs)) |
| 2192 | |
| 2193 | # Assert user attributes |
| 2194 | self.assertEqual(array2.attrs.attr1, "attr1") |
| 2195 | self.assertEqual(array2.attrs.attr2, 2) |
| 2196 | |
| 2197 | def test05b_copy(self): |
| 2198 | """Checking EArray.copy() method (user attributes not copied)""" |
nothing calls this directly
no test coverage detected