Checking modifying one column (single column version, recarray, modify_column)
(self)
| 1294 | self.assertEqual(table.nrows, 4) |
| 1295 | |
| 1296 | def test08b2(self): |
| 1297 | """Checking modifying one column (single column version, recarray, |
| 1298 | modify_column)""" |
| 1299 | |
| 1300 | if common.verbose: |
| 1301 | print("\n", "-=" * 30) |
| 1302 | print("Running %s.test08b2..." % self.__class__.__name__) |
| 1303 | |
| 1304 | # Create a new table: |
| 1305 | table = self.h5file.create_table(self.h5file.root, "recarray", Rec) |
| 1306 | |
| 1307 | # Append new rows |
| 1308 | s0, s1, s2, s3 = ["dbe"] * 3, ["ded"] * 3, ["db1"] * 3, ["de1"] * 3 |
| 1309 | f0, f1, f2, f3 = ( |
| 1310 | [[1.2] * 2] * 3, |
| 1311 | [[1.3] * 2] * 3, |
| 1312 | [[1.4] * 2] * 3, |
| 1313 | [[1.5] * 2] * 3, |
| 1314 | ) |
| 1315 | r = np.rec.array( |
| 1316 | [([456, 457], s0, f0), ([2, 3], s1, f1)], |
| 1317 | formats="(2,)i4,(3,)S3,(3,2)f8", |
| 1318 | ) |
| 1319 | table.append(r) |
| 1320 | table.append([([457, 458], s2, f2), ([5, 6], s3, f3)]) |
| 1321 | |
| 1322 | # Modify just one existing column |
| 1323 | columns = np.rec.fromarrays( |
| 1324 | np.array([[[2, 3], [3, 4], [4, 5]]]), formats="i4" |
| 1325 | ) |
| 1326 | table.modify_column(start=1, column=columns, colname="col1") |
| 1327 | |
| 1328 | # Create the modified recarray |
| 1329 | r1 = np.rec.array( |
| 1330 | [ |
| 1331 | ([456, 457], s0, f0), |
| 1332 | ([2, 3], s1, f1), |
| 1333 | ([3, 4], s2, f2), |
| 1334 | ([4, 5], s3, f3), |
| 1335 | ], |
| 1336 | formats="(2,)i4,(3,)S3,(3,2)f8", |
| 1337 | names="col1,col2,col3", |
| 1338 | ) |
| 1339 | |
| 1340 | # Read the modified table |
| 1341 | r2 = table.read() |
| 1342 | if common.verbose: |
| 1343 | print("Original table-->", repr(r2)) |
| 1344 | print("Should look like-->", repr(r1)) |
| 1345 | self.assertEqual(r1.tobytes(), r2.tobytes()) |
| 1346 | self.assertEqual(table.nrows, 4) |
| 1347 | |
| 1348 | |
| 1349 | class DefaultValues(common.TempFileMixin, common.PyTablesTestCase): |
nothing calls this directly
no test coverage detected