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)\)
-
physicslab.utility.
squarificate
(iterable, filler=None)[source]¶ Reshape 1D
iterable
into squarish 2D array.Mainly use withphysicslab.ui.plot_grid()
, if the positions are arbitrary.Example: reshapelist
of 10 filenames into 3x4 array. The two new elements will be populated byfiller
.- Parameters
iterable (list, numpy.ndarray) – Source 1D iterable.
filler (object, optional) – Value to pad the array with, defaults to None
- Raises
NotImplementedError – If
iterable
is array-likeValueError – If
iterable
has more than one dimension
- Returns
Modified array
- Return type
-
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