MCPcopy Create free account
hub / github.com/apache/arrow / generate_dict_list

Method generate_dict_list

python/benchmarks/common.py:258–282  ·  view source on GitHub ↗

Generate a list of dicts with random values. Each dict has the form `{'u': int value, 'v': float value, 'w': bool value}`

(self, n, none_prob=DEFAULT_NONE_PROB)

Source from the content-addressed store, hash-verified

256 return tuples
257
258 def generate_dict_list(self, n, none_prob=DEFAULT_NONE_PROB):
259 """
260 Generate a list of dicts with random values.
261 Each dict has the form
262
263 `{'u': int value, 'v': float value, 'w': bool value}`
264 """
265 ints = self.generate_int_list(n, none_prob=none_prob)
266 floats = self.generate_float_list(n, none_prob=none_prob)
267 bools = self.generate_bool_list(n, none_prob=none_prob)
268 dicts = []
269 # Keep half the Nones, omit the other half
270 keep_nones = itertools.cycle([True, False])
271 for u, v, w in zip(ints, floats, bools):
272 d = {}
273 if u is not None or next(keep_nones):
274 d['u'] = u
275 if v is not None or next(keep_nones):
276 d['v'] = v
277 if w is not None or next(keep_nones):
278 d['w'] = w
279 dicts.append(d)
280 self.sprinkle_nones(dicts, none_prob)
281 assert len(dicts) == n
282 return dicts
283
284 def get_type_and_builtins(self, n, type_name):
285 """

Callers 1

generate_tuple_listMethod · 0.95

Calls 6

generate_int_listMethod · 0.95
generate_float_listMethod · 0.95
generate_bool_listMethod · 0.95
sprinkle_nonesMethod · 0.95
lenFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected