cleverly.bases.UserBasis#

class cleverly.bases.UserBasis(function: Callable[[Any], Any], terms: tuple[str, ...], columns: tuple[str, ...], basis_kind: Literal['known', 'estimated'] | None = None)[source]#

A basis written as a function of the modifier rows, with its declaration.

function(frame) returns the (n, p) design. A callable can close over any estimate and no code can inspect a closure, so whether it is a known function is a declaration: basis_kind="known" states that the function was fixed without reading this study’s rows. None and "estimated" are refused when a model is declared.

Parameters:
functioncallable()

frame -> (n, p) array.

termstuple of str

One name per column.

columnstuple of str

The modifier columns the function reads.

basis_kind{“known”, “estimated”} or None

The declaration.

Methods#

UserBasis.evaluate(frame: Any, modifiers: Modifiers | None = None) → ndarray[source]#

function at the checked modifier rows.

Parameters:
framedataframe or mapping

Rows holding the modifier columns.

modifiersModifiers, optional

The declared schema; the rows are checked against it first.

Returns:
ndarray

The design.

UserBasis.truncate(k: int) → UserBasis[source]#

Return this basis: a written basis has one size.

Parameters:
kint

A size of at least one.

Returns:
UserBasis

This basis.

Attributes#

UserBasis.basis_kind: Literal['known', 'estimated'] | None = None#
UserBasis.max_size#

1: a written basis has one size.

UserBasis.n_terms#

The number of design columns.

UserBasis.function: Callable[[Any], Any]#
UserBasis.terms: tuple[str, ...]#
UserBasis.columns: tuple[str, ...]#