eelbrain.Var

class eelbrain.Var(x, name=None, info=None, repeat=1, tile=1)

Container for scalar data.

Parameters:
  • x (ArrayLike) – Data; is converted with np.asarray(x). Multidimensional arrays are flattened as long as only 1 dimension is longer than 1.

  • name (str) – Name of the variable

  • info (dict) – Info dictionary. The “longname” entry is used for display purposes.

  • repeat (Union[ArrayLike, int]) – repeat each element in x, either a constant or a different number for each element.

  • tile (int) – Repeat x as a whole tile many times.

Variables:
  • x (numpy.ndarray) – The data stored in the Var.

  • name (None | str) – The Var’s name.

Notes

While Var objects support a few basic operations in a numpy-like fashion (+, -, *, /, //), their Var.x attribute provides access to the corresponding numpy.array which can be used for anything more complicated. Var.x can be read and modified, but should not be replaced.

Methods

abs([name])

Return a Var with the absolute value.

aggregate(x[, func, name])

Summarize cases within cells of x

argmax()

Index of the largest value

argmin()

Index of the smallest value

argsort([kind])

numpy.argsort()

as_factor([labels, name, random])

Convert the Var into a Factor

astype(dtype)

Copy of the Var with data cast to the specified type

copy([name])

Return a deep copy

count()

Count the number of occurrence of each value

diff([to_end, to_begin, name])

The differences between consecutive values

from_apply(base, func[, name, info])

Construct a Var instance by applying a function to each value in a base

from_dict(base, values[, name, default, info])

Construct a Var object by mapping base to values.

index(value)

v.index(value) returns an array of indices where v equals value

isany(*values)

Boolean index, True where the Var is equal to one of the values

isin(values)

Boolean index, True where the Var value is in values

isnan()

Return boolean Var indicating location of NaN values

isnot(*values)

Boolean index, True where the Var is not equal to one of the values

isnotin(values)

Boolean index, True where the Var value is not in values

log([base, name])

Element-wise log

max()

The largest value

mean()

The mean

min()

The smallest value

repeat(repeats[, name])

Repeat each element repeats times

sort_index([descending])

Create an index that could be used to sort the Var.

split([n, labels, name])

A Factor splitting y into n categories with equal number of cases

std([ddof])

The standard deviation

sum()

The sum over all values

tile(repeats[, name])

Construct a Var by repeating self repeats times

var([ddof])

The variance