eelbrain.Var

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

Container for scalar data.

Parameters:
x : array_like

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

name : str | None

Name of the variable

info : dict

Info dictionary. The “longname” entry is used for display purposes.

repeat : int | array of 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.

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.

Attributes:
x : numpy.ndarray

The data stored in the Var.

name : None | str

The Var’s name.

Methods

abs(self[, name]) Return a Var with the absolute value.
aggregate(self, x[, func, name]) Summarize cases within cells of x
argmax(self) numpy.argmax()
argmin(self) numpy.argmin()
argsort(self[, kind]) numpy.argsort()
as_factor(self[, labels, name, random]) Convert the Var into a Factor
astype(self, dtype) Copy of the Var with data cast to the specified type
copy(self[, name]) Return a deep copy
count(self) Count the number of occurrence of each value
diff(self[, 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(self, value) v.index(value) returns an array of indices where v equals value
isany(self, *values) Boolean index, True where the Var is equal to one of the values
isin(self, values) Boolean index, True where the Var value is in values
isnan(self) Return boolean Var indicating location of NaN values
isnot(self, *values) Boolean index, True where the Var is not equal to one of the values
isnotin(self, values) Boolean index, True where the Var value is not in values
log(self[, base, name]) Element-wise log
max(self) The highest value
mean(self) The mean
min(self) The smallest value
repeat(self, repeats[, name]) Repeat each element repeats times
sort_index(self[, descending]) Create an index that could be used to sort the Var.
split(self[, n, name]) A Factor splitting y into n categories with equal number of cases
std(self) The standard deviation
sum(self) The sum over all values
tile(self, repeats[, name]) Construct a Var by repeating self repeats times