Checking Table.copy() method (where specified)
(self)
| 5828 | self.assertEqual(table1.filters.fletcher32, table2.filters.fletcher32) |
| 5829 | |
| 5830 | def test02_copy(self): |
| 5831 | """Checking Table.copy() method (where specified)""" |
| 5832 | |
| 5833 | if common.verbose: |
| 5834 | print("\n", "-=" * 30) |
| 5835 | print("Running %s.test02_copy..." % self.__class__.__name__) |
| 5836 | |
| 5837 | # Create a recarray |
| 5838 | r = np.rec.array( |
| 5839 | [(b"dbe", 456, 1.2), (b"de", 2, 1.3)], |
| 5840 | names="col1,col2,col3", |
| 5841 | formats="S3,i4,f8", |
| 5842 | aligned=self.aligned, |
| 5843 | ) |
| 5844 | # Save it in a table: |
| 5845 | table1 = self.h5file.create_table( |
| 5846 | self.h5file.root, "table1", r, "title table1" |
| 5847 | ) |
| 5848 | |
| 5849 | if self.close: |
| 5850 | if common.verbose: |
| 5851 | print("(closing file version)") |
| 5852 | self._reopen(mode="a") |
| 5853 | table1 = self.h5file.root.table1 |
| 5854 | |
| 5855 | # Copy to another table in another group |
| 5856 | group1 = self.h5file.create_group("/", "group1") |
| 5857 | table2 = table1.copy(group1, "table2") |
| 5858 | |
| 5859 | if self.close: |
| 5860 | if common.verbose: |
| 5861 | print("(closing file version)") |
| 5862 | self._reopen() |
| 5863 | table1 = self.h5file.root.table1 |
| 5864 | table2 = self.h5file.root.group1.table2 |
| 5865 | |
| 5866 | if common.verbose: |
| 5867 | print("table1-->", table1.read()) |
| 5868 | print("table2-->", table2.read()) |
| 5869 | print("attrs table1-->", repr(table1.attrs)) |
| 5870 | print("attrs table2-->", repr(table2.attrs)) |
| 5871 | |
| 5872 | # Check that all the elements are equal |
| 5873 | for row1 in table1: |
| 5874 | nrow = row1.nrow # current row |
| 5875 | for colname in table1.colnames: |
| 5876 | # Both ways to compare work well |
| 5877 | # self.assertEqual(row1[colname], table2[nrow][colname)) |
| 5878 | self.assertEqual( |
| 5879 | row1[colname], table2.read(nrow, field=colname)[0] |
| 5880 | ) |
| 5881 | |
| 5882 | # Assert other properties in table |
| 5883 | self.assertEqual(table1.nrows, table2.nrows) |
| 5884 | self.assertEqual(table1.shape, table2.shape) |
| 5885 | self.assertEqual(table1.colnames, table2.colnames) |
| 5886 | self.assertEqual(table1.coldtypes, table2.coldtypes) |
| 5887 | self.assertEqualColinstances(table1, table2) |
nothing calls this directly
no test coverage detected