Checking a large number of fields in tables
(self)
| 134 | self.assertEqual(arr.get_attr("TITLE"), "t" * titlelength) |
| 135 | |
| 136 | def test04_maxFields(self): |
| 137 | """Checking a large number of fields in tables""" |
| 138 | |
| 139 | # The number of fields for a table |
| 140 | varnumber = tb.parameters.MAX_COLUMNS |
| 141 | |
| 142 | varnames = [] |
| 143 | for i in range(varnumber): |
| 144 | varnames.append("int%d" % i) |
| 145 | |
| 146 | # Build a dictionary with the types as values and varnames as keys |
| 147 | recordDict = {} |
| 148 | i = 0 |
| 149 | for varname in varnames: |
| 150 | recordDict[varname] = tb.Col.from_type("int32", dflt=1, pos=i) |
| 151 | i += 1 |
| 152 | # Append this entry to indicate the alignment! |
| 153 | recordDict["_v_align"] = "=" |
| 154 | table = self.h5file.create_table( |
| 155 | self.root, "table", recordDict, "MetaRecord instance" |
| 156 | ) |
| 157 | row = table.row |
| 158 | listrows = [] |
| 159 | # Write 10 records |
| 160 | for j in range(10): |
| 161 | rowlist = [] |
| 162 | for i in range(len(table.colnames)): |
| 163 | row[varnames[i]] = i * j |
| 164 | rowlist.append(i * j) |
| 165 | |
| 166 | row.append() |
| 167 | listrows.append(tuple(rowlist)) |
| 168 | |
| 169 | # write data on disk |
| 170 | table.flush() |
| 171 | |
| 172 | # Read all the data as a list |
| 173 | listout = table.read().tolist() |
| 174 | |
| 175 | # Compare the input rowlist and output row list. They should |
| 176 | # be equal. |
| 177 | if common.verbose: |
| 178 | print("Original row list:", listrows[-1]) |
| 179 | print("Retrieved row list:", listout[-1]) |
| 180 | self.assertEqual(listrows, listout) |
| 181 | |
| 182 | # The next limitation has been released. A warning is still there, though |
| 183 | def test05_maxFieldsExceeded(self): |
nothing calls this directly
no test coverage detected