Checking modifying one column (single column version)
(self)
| 5231 | ) |
| 5232 | |
| 5233 | def test08a(self): |
| 5234 | """Checking modifying one column (single column version)""" |
| 5235 | |
| 5236 | if common.verbose: |
| 5237 | print("\n", "-=" * 30) |
| 5238 | print("Running %s.test08a..." % self.__class__.__name__) |
| 5239 | |
| 5240 | # Create a new table: |
| 5241 | table = self.h5file.create_table(self.h5file.root, "recarray", Rec) |
| 5242 | |
| 5243 | # append new rows |
| 5244 | r = np.rec.array( |
| 5245 | [(456, b"dbe", 1.2), (2, b"ded", 1.3)], formats="i4,S3,f8" |
| 5246 | ) |
| 5247 | table.append(r) |
| 5248 | table.append([(457, b"db1", 1.2), (5, b"de1", 1.3)]) |
| 5249 | |
| 5250 | # Modify just one existing column |
| 5251 | table.modify_columns(start=1, columns=[[2, 3, 4]], names=["col1"]) |
| 5252 | # Create the modified recarray |
| 5253 | r1 = np.rec.array( |
| 5254 | [ |
| 5255 | (456, b"dbe", 1.2), |
| 5256 | (2, b"ded", 1.3), |
| 5257 | (3, b"db1", 1.2), |
| 5258 | (4, b"de1", 1.3), |
| 5259 | ], |
| 5260 | formats="i4,S3,f8", |
| 5261 | names="col1,col2,col3", |
| 5262 | ) |
| 5263 | # Read the modified table |
| 5264 | if self.reopen: |
| 5265 | self._reopen() |
| 5266 | table = self.h5file.root.recarray |
| 5267 | r2 = table.read() |
| 5268 | if common.verbose: |
| 5269 | print("Original table-->", repr(r2)) |
| 5270 | print("Should look like-->", repr(r1)) |
| 5271 | self.assertEqual(r1.tobytes(), r2.tobytes()) |
| 5272 | self.assertEqual(table.nrows, 4) |
| 5273 | |
| 5274 | def test08a2(self): |
| 5275 | """Checking modifying one column (single column version, |
nothing calls this directly
no test coverage detected