faninsar.Loops#

class faninsar.Loops(loops: list, sort: bool = True)[source]#

Bases: object

Loops class to handle loops with multiple acquisitions.

__init__(loops: list, sort: bool = True) None[source]#

Initialize the loops class.

Parameters:
  • loops (list) – a list containing Loop objects.

  • sort (bool, optional) – Whether to sort the loops. Default is True.

Methods

__init__(loops[, sort])

Initialize the loops class.

sort([ascending, inplace])

Sort the loops.

to_matrix([dtype])

Return a design matrix describes the relationship between loops and pairs.

Attributes

diagonal_pairs

All diagonal pairs in the loops.

edge_pairs

All edge pairs in the loops.

loops

The loops in the numpy array format.

names

The names (str format) of the loops.

pairs

All pairs in the loops.

shape

The shape of the loops array with format of (n_loops, n_pairs).

sort(ascending: bool = True, inplace: bool = True) Loops | None[source]#

Sort the loops.

Parameters:
  • ascending (bool, optional) – Whether to sort the loops ascending. Default is True.

  • inplace (bool, optional) – Whether to sort the loops in place. if False, return the sorted loops. Default is True.

to_matrix(dtype: DTypeLike = None) NDArray[np.number][source]#

Return a design matrix describes the relationship between loops and pairs.

The rows and columns of this matrix are loops and pairs respectively. The values of the matrix are 1 for the edge pairs, -1 for the diagonal pairs, and 0 otherwise.

property diagonal_pairs: Pairs#

All diagonal pairs in the loops.

property edge_pairs: Pairs#

All edge pairs in the loops.

property loops: NDArray[np.object_]#

The loops in the numpy array format.

property names: NDArray[np.str_]#

The names (str format) of the loops.

property pairs: Pairs#

All pairs in the loops.

property shape: tuple[int, int]#

The shape of the loops array with format of (n_loops, n_pairs).