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

Method test02a_int

tables/tests/test_carray.py:1509–1551  ·  view source on GitHub ↗

Checking carray with offset NumPy ints appends.

(self)

Source from the content-addressed store, hash-verified

1507 self.assertEqual(len(data[1]), 2)
1508
1509 def test02a_int(self):
1510 """Checking carray with offset NumPy ints appends."""
1511
1512 root = self.rootgroup
1513 if common.verbose:
1514 print("\n", "-=" * 30)
1515 print("Running %s.test02a_int..." % self.__class__.__name__)
1516
1517 shape = (3, 3)
1518
1519 # Create a string atom
1520 carray = self.h5file.create_carray(
1521 root,
1522 "CAtom",
1523 atom=tb.Int32Atom(),
1524 shape=shape,
1525 title="array of ints",
1526 chunkshape=(1, 3),
1527 )
1528 a = np.array(
1529 [(0, 0, 0), (1, 0, 3), (1, 1, 1), (0, 0, 0)], dtype="int32"
1530 )
1531 carray[0:2] = a[2:] # Introduce an offset
1532 a = np.array([(1, 1, 1), (-1, 0, 0)], dtype="int32")
1533 carray[2:3] = a[1:] # Introduce an offset
1534
1535 # Read all the rows:
1536 data = carray.read()
1537 if common.verbose:
1538 print("Object read:", data)
1539 print("Nrows in", carray._v_pathname, ":", carray.nrows)
1540 print("Third row in carray ==>", data[2])
1541
1542 self.assertEqual(carray.nrows, 3)
1543 self.assertTrue(
1544 common.allequal(data[0], np.array([1, 1, 1], dtype="int32"))
1545 )
1546 self.assertTrue(
1547 common.allequal(data[1], np.array([0, 0, 0], dtype="int32"))
1548 )
1549 self.assertTrue(
1550 common.allequal(data[2], np.array([-1, 0, 0], dtype="int32"))
1551 )
1552
1553 def test02b_int(self):
1554 """Checking carray with strided NumPy ints appends."""

Callers

nothing calls this directly

Calls 2

create_carrayMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected