copulas.utils module
Utils module.
- copulas.utils.check_valid_values(function)[source]
Raise an exception if the given values are not supported.
- Parameters:
function (callable) – Method whose unique argument is a numpy.array-like object.
- Returns:
Decorated function
- Return type:
callable
- Raises:
ValueError – If there are missing or invalid values or if the dataset is empty.
- copulas.utils.get_instance(obj, **kwargs)[source]
Create new instance of the
objargument.- Parameters:
obj (str, type, instance)
- copulas.utils.get_qualified_name(_object)[source]
Return the Fully Qualified Name from an instance or class.
- copulas.utils.random_state(function)[source]
Set the random state before calling the function.
- Parameters:
function (Callable) – The function to wrap around.
- copulas.utils.scalarize(function)[source]
Allow methods that only accepts 1-d vectors to work with scalars.
- Parameters:
function (callable) – Function that accepts and returns vectors.
- Returns:
Decorated function that accepts and returns scalars.
- Return type:
callable
- copulas.utils.set_random_state(random_state, set_model_random_state)[source]
Context manager for managing the random state.
- Parameters:
random_state (int or np.random.RandomState) – The random seed or RandomState.
set_model_random_state (function) – Function to set the random state on the model.
- copulas.utils.store_args(__init__)[source]
Save
*argsand**kwargsused in the__init__of a copula.- Parameters:
__init__ (callable) –
__init__function to store their arguments.- Returns:
Decorated
__init__function.- Return type:
callable
- copulas.utils.validate_random_state(random_state)[source]
Validate random state argument.
- Parameters:
random_state (int, numpy.random.RandomState, tuple, or None) – Seed or RandomState for the random generator.
- Output:
numpy.random.RandomState
- copulas.utils.vectorize(function)[source]
Allow a method that only accepts scalars to accept vectors too.
This decorator has two different behaviors depending on the dimensionality of the array passed as an argument:
1-d array
It will work under the assumption that the function argument is a callable with signature:
function(self, X, *args, **kwargs)
where X is an scalar magnitude.
In this case the arguments of the input array will be given one at a time, and both the input and output of the decorated function will have shape (n,).
2-d array
It will work under the assumption that the function argument is a callable with signature:
function(self, X0, ..., Xj, *args, **kwargs)
where Xi are scalar magnitudes.
It will pass the contents of each row unpacked on each call. The input is espected to have shape (n, j), the output a shape of (n,)
It will return a function that is guaranteed to return a numpy.array.
- Parameters:
function (callable) – Function that only accept and return scalars.
- Returns:
Decorated function that can accept and return
numpy.array.- Return type:
callable