Checking modifying table columns (single column, step)
(self)
| 5530 | self.assertEqual(table.nrows, 4) |
| 5531 | |
| 5532 | def test09c(self): |
| 5533 | """Checking modifying table columns (single column, step)""" |
| 5534 | |
| 5535 | if common.verbose: |
| 5536 | print("\n", "-=" * 30) |
| 5537 | print("Running %s.test09c..." % self.__class__.__name__) |
| 5538 | |
| 5539 | # Create a new table: |
| 5540 | table = self.h5file.create_table(self.h5file.root, "recarray", Rec) |
| 5541 | |
| 5542 | # append new rows |
| 5543 | r = np.rec.array( |
| 5544 | [(456, b"dbe", 1.2), (2, b"ded", 1.3)], formats="i4,S3,f8" |
| 5545 | ) |
| 5546 | table.append(r) |
| 5547 | table.append([(457, b"db1", 1.2), (5, b"de1", 1.3)]) |
| 5548 | # Modify a couple of columns |
| 5549 | columns = np.rec.array([("aaa", 1.2), ("bbb", 0.1)], formats="S3,f8") |
| 5550 | table.modify_columns( |
| 5551 | start=1, step=2, columns=columns, names=["col2", "col3"] |
| 5552 | ) |
| 5553 | # Create the modified recarray |
| 5554 | r1 = np.rec.array( |
| 5555 | [ |
| 5556 | (456, "dbe", 1.2), |
| 5557 | (2, "aaa", 1.2), |
| 5558 | (457, "db1", 1.2), |
| 5559 | (5, "bbb", 0.1), |
| 5560 | ], |
| 5561 | formats="i4,S3,f8", |
| 5562 | names="col1,col2,col3", |
| 5563 | ) |
| 5564 | # Read the modified table |
| 5565 | if self.reopen: |
| 5566 | self._reopen() |
| 5567 | table = self.h5file.root.recarray |
| 5568 | r2 = table.read() |
| 5569 | if common.verbose: |
| 5570 | print("Original table-->", repr(r2)) |
| 5571 | print("Should look like-->", repr(r1)) |
| 5572 | self.assertEqual(r1.tobytes(), r2.tobytes()) |
| 5573 | self.assertEqual(table.nrows, 4) |
| 5574 | |
| 5575 | def test09d(self): |
| 5576 | """Checking modifying table columns (multiple columns, step)""" |
nothing calls this directly
no test coverage detected