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

Method test01b_String

tables/tests/test_earray.py:1474–1505  ·  view source on GitHub ↗

Checking earray with strided numpy strings appends.

(self)

Source from the content-addressed store, hash-verified

1472 self.assertEqual(len(row[1]), 2)
1473
1474 def test01b_String(self):
1475 """Checking earray with strided numpy strings appends."""
1476
1477 root = self.rootgroup
1478 if common.verbose:
1479 print("\n", "-=" * 30)
1480 print("Running %s.test01b_StringAtom..." % self.__class__.__name__)
1481
1482 earray = self.h5file.create_earray(
1483 root,
1484 "strings",
1485 atom=tb.StringAtom(itemsize=3),
1486 shape=(0, 2, 2),
1487 title="Array of strings",
1488 )
1489 a = np.array([[["a", "b"], ["123", "45"], ["45", "123"]]], dtype="S3")
1490 earray.append(a[:, ::2])
1491 a = np.array([[["s", "a"], ["ab", "f"], ["s", "abc"], ["abc", "f"]]])
1492 earray.append(a[:, ::2])
1493
1494 # Read all the rows:
1495 row = earray.read()
1496 if common.verbose:
1497 print("Object read:", row)
1498 print("Nrows in", earray._v_pathname, ":", earray.nrows)
1499 print("Second row in earray ==>", row[1].tolist())
1500
1501 self.assertEqual(earray.nrows, 2)
1502 self.assertEqual(row[0].tolist(), [[b"a", b"b"], [b"45", b"123"]])
1503 self.assertEqual(row[1].tolist(), [[b"s", b"a"], [b"s", b"abc"]])
1504 self.assertEqual(len(row[0]), 2)
1505 self.assertEqual(len(row[1]), 2)
1506
1507 def test02a_int(self):
1508 """Checking earray with offset NumPy ints appends."""

Callers

nothing calls this directly

Calls 3

create_earrayMethod · 0.80
appendMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected