Data integrity during recovery (string objects)
(self)
| 330 | Path(filename).unlink() |
| 331 | |
| 332 | def test00b_char_atom_shape_args(self): |
| 333 | """Data integrity during recovery (string objects)""" |
| 334 | |
| 335 | a = self.tupleChar |
| 336 | |
| 337 | filename = tempfile.mktemp(".h5") |
| 338 | try: |
| 339 | # Create an instance of HDF5 file |
| 340 | with tb.open_file(filename, mode="w") as fileh: |
| 341 | nparr = np.asarray(a) |
| 342 | atom = tb.Atom.from_dtype(nparr.dtype) |
| 343 | shape = nparr.shape |
| 344 | if nparr.dtype.byteorder in (">", "<"): |
| 345 | byteorder = tb.utils.byteorders[nparr.dtype.byteorder] |
| 346 | else: |
| 347 | byteorder = None |
| 348 | |
| 349 | ptarr = fileh.create_array( |
| 350 | fileh.root, |
| 351 | "somearray", |
| 352 | atom=atom, |
| 353 | shape=shape, |
| 354 | byteorder=byteorder, |
| 355 | title="Some array", |
| 356 | ) |
| 357 | self.assertEqual(shape, ptarr.shape) |
| 358 | self.assertEqual(atom, ptarr.atom) |
| 359 | ptarr[...] = a |
| 360 | |
| 361 | # Re-open the file in read-only mode |
| 362 | with tb.open_file(filename, mode="r") as fileh: |
| 363 | # Read the saved array |
| 364 | b = np.empty_like(a) |
| 365 | if fileh.root.somearray.flavor != "numpy": |
| 366 | self.assertRaises( |
| 367 | TypeError, lambda: fileh.root.somearray.read(out=b) |
| 368 | ) |
| 369 | else: |
| 370 | fileh.root.somearray.read(out=b) |
| 371 | self.assertIsInstance(b, np.ndarray) |
| 372 | finally: |
| 373 | # Then, delete the file |
| 374 | Path(filename).unlink() |
| 375 | |
| 376 | def setup01_char_nc(self): |
| 377 | """Data integrity during recovery (non-contiguous character objects)""" |
nothing calls this directly
no test coverage detected