Utility module

Utility functions.

physicslab.utility.permutation_sign(array)[source]

Computes permutation sign of given array.

Relative to ordered array, see: \(sgn(\sigma) = (-1)^{\sum_{0 \le i<j<n}(\sigma_i>\sigma_j)}\)

Note

For permutation relative to another ordering, use the following identity: \(sgn(\pi_1 \circ \pi_2) = sgn(\pi_1)\cdot sgn(\pi_2)\)

Parameters

array (list) – Input array (iterable)

Returns

Permutation parity sign is either (+1) or (-1)

Return type

int

physicslab.utility.squarificate(iterable, filler=None)[source]

Reshape 1D iterable into squarish 2D array.

Mainly use with physicslab.ui.plot_grid(), if the positions are arbitrary.
Example: reshape list of 10 filenames into 3x4 array. The two new elements will be populated by filler.
Parameters
  • iterable (list, numpy.ndarray) – Source 1D iterable.

  • filler (object, optional) – Value to pad the array with, defaults to None

Raises
Returns

Modified array

Return type

numpy.ndarray

physicslab.utility.get_name(df)[source]

Find DataFrame name.

Parameters

df (pandas.DataFrame or pandas.Series) – Input

Returns

Name or None if name does not exist

Return type

str or None

class physicslab.utility._ColumnsBase[source]

Abstract base class for physicslab.experiment.[Any].Columns classes.

classmethod list_all_names()[source]
Return type

list[str]