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

Method test03b_float

tables/tests/test_earray.py:1625–1660  ·  view source on GitHub ↗

Checking earray with byteswapped appends (floats)

(self)

Source from the content-addressed store, hash-verified

1623 self.assertTrue(common.allequal(native, swapped))
1624
1625 def test03b_float(self):
1626 """Checking earray with byteswapped appends (floats)"""
1627
1628 root = self.rootgroup
1629 if common.verbose:
1630 print("\n", "-=" * 30)
1631 print("Running %s.test03b_float..." % self.__class__.__name__)
1632
1633 earray = self.h5file.create_earray(
1634 root,
1635 "EAtom",
1636 atom=tb.Float64Atom(),
1637 shape=(0, 3),
1638 title="array of floats",
1639 )
1640 # Add a native ordered array
1641 a = np.array(
1642 [(0, 0, 0), (1, 0, 3), (1, 1, 1), (3, 3, 3)], dtype="float64"
1643 )
1644 earray.append(a)
1645 # Change the byteorder of the array
1646 a = a.byteswap()
1647 a = a.view(a.dtype.newbyteorder())
1648 # Add a byteswapped array
1649 earray.append(a)
1650
1651 # Read all the rows:
1652 native = earray[:4, :]
1653 swapped = earray[4:, :]
1654 if common.verbose:
1655 print("Native rows:", native)
1656 print("Byteorder native rows:", native.dtype.byteorder)
1657 print("Swapped rows:", swapped)
1658 print("Byteorder swapped rows:", swapped.dtype.byteorder)
1659
1660 self.assertTrue(common.allequal(native, swapped))
1661
1662 def test04a_int(self):
1663 """Checking earray with byteswapped appends (2, ints)"""

Callers

nothing calls this directly

Calls 2

create_earrayMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected