Utilities
-
sample_data_utils.utils.infinite()[source]
auto inc generator
-
sample_data_utils.utils.memoize(func)[source]
Decorator that stores function results in a dictionary to be used on the
next time that the same arguments were informed.
-
sample_data_utils.utils.sequence(prefix, cache=None)[source]
generator that returns an unique string
Parameters: |
- prefix – prefix of string
- cache – cache used to store the last used number
|
>>> next(sequence('abc'))
'abc-0'
>>> next(sequence('abc'))
'abc-1'
-
sample_data_utils.utils.unique(func, num_args=0, max_attempts=100, cache=None)[source]
wraps a function so that produce unique results
>>> import random
>>> choices = [1,2]
>>> a = unique(random.choice, 1)
>>> a,b = a(choices), a(choices)
>>> a == b
False