Checking combinations of arrays with groups It also uses arrays ranks which ranges until 10.
(self)
| 224 | """ |
| 225 | |
| 226 | def test00_iterativeGroups(self): |
| 227 | """Checking combinations of arrays with groups |
| 228 | |
| 229 | It also uses arrays ranks which ranges until 10. |
| 230 | |
| 231 | """ |
| 232 | |
| 233 | if common.verbose: |
| 234 | print("\n", "-=" * 30) |
| 235 | print( |
| 236 | "Running %s.test00_iterativeGroups..." |
| 237 | % self.__class__.__name__ |
| 238 | ) |
| 239 | |
| 240 | # Get the root group |
| 241 | group = self.h5file.root |
| 242 | |
| 243 | i = 1 |
| 244 | for typecode in typecodes: |
| 245 | # Create an array of typecode, with incrementally bigger ranges |
| 246 | a = np.ones((2,) * i, typecode) |
| 247 | # Save it on the HDF5 file |
| 248 | dsetname = "array_" + typecode |
| 249 | if common.verbose: |
| 250 | print("Creating dataset:", group._g_join(dsetname)) |
| 251 | self.h5file.create_array(group, dsetname, a, "Large array") |
| 252 | # Create a new group |
| 253 | group = self.h5file.create_group(group, "group" + str(i)) |
| 254 | # increment the range for next iteration |
| 255 | i += 1 |
| 256 | |
| 257 | self._reopen() |
| 258 | |
| 259 | # Get the root group |
| 260 | group = self.h5file.root |
| 261 | |
| 262 | # Get the metadata on the previosly saved arrays |
| 263 | for i in range(1, len(typecodes)): |
| 264 | # Create an array for later comparison |
| 265 | a = np.ones((2,) * i, typecodes[i - 1]) |
| 266 | # Get the dset object hanging from group |
| 267 | dset = getattr(group, "array_" + typecodes[i - 1]) |
| 268 | # Get the actual array |
| 269 | b = dset.read() |
| 270 | if not common.allequal(a, b, "numpy") and common.verbose: |
| 271 | print("Array a original. Shape: ==>", a.shape) |
| 272 | print("Array a original. Data: ==>", a) |
| 273 | print("Info from dataset:", dset._v_pathname) |
| 274 | print(" shape ==>", dset.shape, end=" ") |
| 275 | print(" dtype ==> %s" % dset.dtype) |
| 276 | print("Array b read from file. Shape: ==>", b.shape, end=" ") |
| 277 | print(". Type ==> %s" % b.dtype.char) |
| 278 | |
| 279 | self.assertEqual(a.shape, b.shape) |
| 280 | if np.dtype("l").itemsize == 4: |
| 281 | if a.dtype.char == "i" or a.dtype.char == "l": |
| 282 | # Special expection. We have no way to distinguish between |
| 283 | # "l" and "i" typecode, and we can consider them the same |
nothing calls this directly
no test coverage detected