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

Method test09a_getStrings

tables/tests/test_numpy.py:1159–1180  ·  view source on GitHub ↗

Checking the return of string columns with spaces.

(self)

Source from the content-addressed store, hash-verified

1157 self.assertTrue(common.allequal(ycol, data, "numpy"))
1158
1159 def test09a_getStrings(self):
1160 """Checking the return of string columns with spaces."""
1161
1162 if self.close:
1163 self._reopen(mode="a")
1164 table = self.h5file.root.table
1165 rdata = table.get_where_list('color == b"ab"')
1166 data = table.read_coordinates(rdata)
1167 if common.verbose:
1168 print("Type of read:", type(data))
1169 print("Description of the record:", data.dtype.descr)
1170 print("First 3 elements of read:", data[:3])
1171
1172 # Check that both NumPy objects are equal
1173 self.assertIsInstance(data, np.ndarray)
1174
1175 # Check that all columns have been selected
1176 self.assertEqual(len(data), 100)
1177
1178 # Finally, check that the contents are ok
1179 for idata in data["color"]:
1180 self.assertEqual(idata, np.array("ab", dtype="|S4"))
1181
1182 def test09b_getStrings(self):
1183 """Checking the return of string columns with spaces.

Callers

nothing calls this directly

Calls 3

get_where_listMethod · 0.80
read_coordinatesMethod · 0.80
_reopenMethod · 0.45

Tested by

no test coverage detected