brainbox.core.core

Creates core data types and functions which support all of brainbox.

Functions

intersect2d

Performs intersection on multiple columns arrays a0 and a1 :param a0: :param a1: :return: intesection :return: index of a0 such as intersection = a0[ia, :] :return: index of b0 such as intersection = b0[ib, :]

ismember

equivalent of np.isin but returns indices as in the matlab ismember function returns an array containing logical 1 (true) where the data in A is B also returns the location of members in b such as a[lia] == b[locb] :param a: 1d - array :param b: 1d - array :return: isin, locb

ismember2d

Equivalent of np.isin but returns indices as in the matlab ismember function returns an array containing logical 1 (true) where the data in A is B also returns the location of members in b such as a[lia, :] == b[locb, :] :param a0: 2d array :param a1: 2d array :return: isin, locb

Classes

Bunch

A subclass of dictionary with an additional dot syntax.

TimeSeries

A subclass of dict with dot syntax, enforcement of time stamping

class Bunch(*args, **kwargs)[source]

Bases: dict

A subclass of dictionary with an additional dot syntax.

copy()[source]

Return a new Bunch instance which is a copy of the current Bunch instance.

to_df()[source]

Attempts to returns a pandas.DataFrame if all elements are arrays of the same length Returns the original bunch if it can’t

save(npz_file, compress=False)[source]

Saves a npz file containing the arrays of the bunch.

Parameters
  • npz_file – output file

  • compress – bool (False) use compression

Returns

None

static load(npz_file)[source]

Loads a npz file containing the arrays of the bunch.

Parameters
  • npz_file – output file

  • compress – bool (False) use compression

Returns

Bunch

class TimeSeries(times, values, columns=None, *args, **kwargs)[source]

Bases: dict

A subclass of dict with dot syntax, enforcement of time stamping

copy()[source]

Return a new TimeSeries instance which is a copy of the current TimeSeries instance.

ismember(a, b)[source]

equivalent of np.isin but returns indices as in the matlab ismember function returns an array containing logical 1 (true) where the data in A is B also returns the location of members in b such as a[lia] == b[locb] :param a: 1d - array :param b: 1d - array :return: isin, locb

ismember2d(a0, a1)[source]

Equivalent of np.isin but returns indices as in the matlab ismember function returns an array containing logical 1 (true) where the data in A is B also returns the location of members in b such as a[lia, :] == b[locb, :] :param a0: 2d array :param a1: 2d array :return: isin, locb

intersect2d(a0, a1, assume_unique=False)[source]

Performs intersection on multiple columns arrays a0 and a1 :param a0: :param a1: :return: intesection :return: index of a0 such as intersection = a0[ia, :] :return: index of b0 such as intersection = b0[ib, :]