MCPcopy Create free account
hub / github.com/PyTables/PyTables / initRecArray

Method initRecArray

tables/tests/test_tables.py:142–209  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

140 self.h5file.close()
141
142 def initRecArray(self):
143 record = self.recordtemplate
144 row = record[0]
145 buflist = []
146 # Fill the recarray
147 for i in range(self.expectedrows):
148 tmplist = []
149 var1 = "%04d" % (self.expectedrows - i)
150 tmplist.append(var1)
151 var2 = i
152 tmplist.append(var2)
153 var3 = i % self.maxshort
154 tmplist.append(var3)
155 if isinstance(row["var4"], np.ndarray):
156 tmplist.append([float(i), float(i * i)])
157 else:
158 tmplist.append(float(i))
159 if isinstance(row["var5"], np.ndarray):
160 tmplist.append(np.array((float(i),) * 4))
161 else:
162 tmplist.append(float(i))
163 # var6 will be like var3 but byteswaped
164 tmplist.append(((var3 >> 8) & 0xFF) + ((var3 << 8) & 0xFF00))
165 var7 = var1[-1]
166 tmplist.append(var7)
167 if isinstance(row["var8"], np.ndarray):
168 tmplist.append([0, 10]) # should be equivalent to [0,1]
169 else:
170 tmplist.append(10) # should be equivalent to 1
171 if isinstance(row["var9"], np.ndarray):
172 tmplist.append([0.0 + float(i) * 1j, float(i) + 0.0j])
173 else:
174 tmplist.append(float(i) + 0j)
175 if isinstance(row["var10"], np.ndarray):
176 tmplist.append([float(i) + 0j, 1 + float(i) * 1j])
177 else:
178 tmplist.append(1 + float(i) * 1j)
179 if hasattr(tb, "Float16Col"):
180 if isinstance(row["var11"], np.ndarray):
181 tmplist.append(np.array((float(i),) * 4))
182 else:
183 tmplist.append(float(i))
184 if hasattr(tb, "Float96Col"):
185 if isinstance(row["var12"], np.ndarray):
186 tmplist.append(np.array((float(i),) * 4))
187 else:
188 tmplist.append(float(i))
189 if hasattr(tb, "Float128Col"):
190 if isinstance(row["var13"], np.ndarray):
191 tmplist.append(np.array((float(i),) * 4))
192 else:
193 tmplist.append(float(i))
194 if hasattr(tb, "Complex192Col"):
195 if isinstance(row["var14"], np.ndarray):
196 tmplist.append([float(i) + 0j, 1 + float(i) * 1j])
197 else:
198 tmplist.append(1 + float(i) * 1j)
199 if hasattr(tb, "Complex256Col"):

Callers 1

populateFileMethod · 0.95

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected