Add choice in allowed distrib
This commit is contained in:
parent
2899ef9170
commit
96f3a2a3d0
@ -38,7 +38,7 @@ class Dataset(list):
|
|||||||
""" Generate a random list of value
|
""" Generate a random list of value
|
||||||
|
|
||||||
:param length: length of the dataset
|
:param length: length of the dataset
|
||||||
:param distrib: Distribution of the data set. It can be a function or string from ["randint", "uniform", "gauss"]
|
:param distrib: Distribution of the data set. It can be a function or string from ["randint", "uniform", "gauss", "choice"]
|
||||||
:param rd_args: arguments to pass to distrib
|
:param rd_args: arguments to pass to distrib
|
||||||
:param nbr_format: function which format value
|
:param nbr_format: function which format value
|
||||||
:param v_min: minimum accepted value
|
:param v_min: minimum accepted value
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#/usr/bin/env python
|
#/usr/bin/env python
|
||||||
# -*- coding:Utf-8 -*-
|
# -*- coding:Utf-8 -*-
|
||||||
|
|
||||||
from random import randint, uniform, gauss
|
from random import randint, uniform, gauss, choice
|
||||||
|
|
||||||
|
|
||||||
def random_generator(length,\
|
def random_generator(length,\
|
||||||
@ -12,7 +12,7 @@ def random_generator(length,\
|
|||||||
""" Generate a random list of value
|
""" Generate a random list of value
|
||||||
|
|
||||||
:param length: length of the dataset
|
:param length: length of the dataset
|
||||||
:param distrib: Distribution of the data set. It can be a function or string from ["randint", "uniform", "gauss"]
|
:param distrib: Distribution of the data set. It can be a function or string from ["randint", "uniform", "gauss", "choice"]
|
||||||
:param rd_args: arguments to pass to distrib
|
:param rd_args: arguments to pass to distrib
|
||||||
:param nbr_format: function which format value
|
:param nbr_format: function which format value
|
||||||
:param v_min: minimum accepted value
|
:param v_min: minimum accepted value
|
||||||
@ -44,7 +44,7 @@ def random_generator(length,\
|
|||||||
validate = lambda x : v1(x) and v2(x)
|
validate = lambda x : v1(x) and v2(x)
|
||||||
|
|
||||||
# get distrib function
|
# get distrib function
|
||||||
distribs = {"gauss": gauss, "uniform": uniform, "randint":randint}
|
distribs = {"gauss": gauss, "uniform": uniform, "randint":randint, "choice":choice}
|
||||||
try:
|
try:
|
||||||
distrib(*rd_args)
|
distrib(*rd_args)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
|
Loading…
Reference in New Issue
Block a user