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

Method generate_decimal_list

python/benchmarks/common.py:158–169  ·  view source on GitHub ↗

Generate a list of Python Decimals with *none_prob* probability of an entry being None (or NaN if *use_nan* is true).

(self, n, none_prob=DEFAULT_NONE_PROB,
                              use_nan=False)

Source from the content-addressed store, hash-verified

156 return data
157
158 def generate_decimal_list(self, n, none_prob=DEFAULT_NONE_PROB,
159 use_nan=False):
160 """
161 Generate a list of Python Decimals with *none_prob* probability of
162 an entry being None (or NaN if *use_nan* is true).
163 """
164 data = [decimal.Decimal('%.9f' % f)
165 for f in self.rnd.uniform(0.0, 1.0, n)]
166 assert len(data) == n
167 self.sprinkle(data, none_prob,
168 value=decimal.Decimal('nan') if use_nan else None)
169 return data
170
171 def generate_object_list(self, n, none_prob=DEFAULT_NONE_PROB):
172 """

Callers 1

setupMethod · 0.95

Calls 3

sprinkleMethod · 0.95
lenFunction · 0.85
DecimalMethod · 0.45

Tested by

no test coverage detected