Checking earray with offset numpy strings appends.
(self)
| 1439 | self.rootgroup = self.h5file.root |
| 1440 | |
| 1441 | def test01a_String(self): |
| 1442 | """Checking earray with offset numpy strings appends.""" |
| 1443 | |
| 1444 | root = self.rootgroup |
| 1445 | if common.verbose: |
| 1446 | print("\n", "-=" * 30) |
| 1447 | print("Running %s.test01a_StringAtom..." % self.__class__.__name__) |
| 1448 | |
| 1449 | earray = self.h5file.create_earray( |
| 1450 | root, |
| 1451 | "strings", |
| 1452 | atom=tb.StringAtom(itemsize=3), |
| 1453 | shape=(0, 2, 2), |
| 1454 | title="Array of strings", |
| 1455 | ) |
| 1456 | a = np.array([[["a", "b"], ["123", "45"], ["45", "123"]]], dtype="S3") |
| 1457 | earray.append(a[:, 1:]) |
| 1458 | a = np.array([[["s", "a"], ["ab", "f"], ["s", "abc"], ["abc", "f"]]]) |
| 1459 | earray.append(a[:, 2:]) |
| 1460 | |
| 1461 | # Read all the rows: |
| 1462 | row = earray.read() |
| 1463 | if common.verbose: |
| 1464 | print("Object read:", row) |
| 1465 | print("Nrows in", earray._v_pathname, ":", earray.nrows) |
| 1466 | print("Second row in earray ==>", row[1].tolist()) |
| 1467 | |
| 1468 | self.assertEqual(earray.nrows, 2) |
| 1469 | self.assertEqual(row[0].tolist(), [[b"123", b"45"], [b"45", b"123"]]) |
| 1470 | self.assertEqual(row[1].tolist(), [[b"s", b"abc"], [b"abc", b"f"]]) |
| 1471 | self.assertEqual(len(row[0]), 2) |
| 1472 | self.assertEqual(len(row[1]), 2) |
| 1473 | |
| 1474 | def test01b_String(self): |
| 1475 | """Checking earray with strided numpy strings appends.""" |
nothing calls this directly
no test coverage detected