copulas package

Module contents

Top-level package for Copulas.

exception copulas.NotFittedError[source]

Bases: Exception

NotFittedError class.

copulas.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.get_instance(obj, **kwargs)[source]

Create new instance of the obj argument.

Parameters

obj (str, type, instance) –

copulas.get_qualified_name(_object)[source]

Return the Fully Qualified Name from an instance or class.

copulas.random_state(function)[source]

Set the random state before calling the function.

Parameters

function (Callable) – The function to wrap around.

copulas.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.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.store_args(__init__)[source]

Save *args and **kwargs used in the __init__ of a copula.

Parameters

__init__ (callable) – __init__ function to store their arguments.

Returns

Decorated __init__ function.

Return type

callable

copulas.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.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