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

Method test04d_float

tables/tests/test_earray.py:1796–1840  ·  view source on GitHub ↗

Checking earray with byteswapped appends (2, floats, reopen)

(self)

Source from the content-addressed store, hash-verified

1794 self.assertTrue(common.allequal(native, swapped))
1795
1796 def test04d_float(self):
1797 """Checking earray with byteswapped appends (2, floats, reopen)"""
1798
1799 root = self.rootgroup
1800 if common.verbose:
1801 print("\n", "-=" * 30)
1802 print("Running %s.test04d_float..." % self.__class__.__name__)
1803
1804 byteorder = {"little": "big", "big": "little"}[sys.byteorder]
1805 earray = self.h5file.create_earray(
1806 root,
1807 "EAtom",
1808 atom=tb.Float64Atom(),
1809 shape=(0, 3),
1810 title="array of floats",
1811 byteorder=byteorder,
1812 )
1813 self._reopen(mode="a")
1814 earray = self.h5file.get_node("/EAtom")
1815 # Add a native ordered array
1816 a = np.array(
1817 [(0, 0, 0), (1, 0, 3), (1, 1, 1), (3, 3, 3)], dtype="float64"
1818 )
1819 earray.append(a)
1820 # Change the byteorder of the array
1821 a = a.byteswap()
1822 a = a.view(a.dtype.newbyteorder())
1823 # Add a byteswapped array
1824 earray.append(a)
1825
1826 # Read all the rows:
1827 native = earray[:4, :]
1828 swapped = earray[4:, :]
1829 if common.verbose:
1830 print(
1831 "Byteorder native rows:",
1832 tb.utils.byteorders[native.dtype.byteorder],
1833 )
1834 print("Byteorder earray on-disk:", earray.byteorder)
1835
1836 self.assertEqual(
1837 tb.utils.byteorders[native.dtype.byteorder], sys.byteorder
1838 )
1839 self.assertEqual(earray.byteorder, byteorder)
1840 self.assertTrue(common.allequal(native, swapped))
1841
1842
1843class CopyTestCase(common.TempFileMixin, common.PyTablesTestCase):

Callers

nothing calls this directly

Calls 4

create_earrayMethod · 0.80
_reopenMethod · 0.45
get_nodeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected