Utility functions

Utility functions for the mpes package

@author: R. Patrick Xian

mpes.utils.numFormatConversion(seq, form='int', **kwds)

When length keyword is not specified as an argument, the function returns a format-converted sequence of numbers

The function returns nothing when the conversion fails due to errors

Parameters

seq : 1D numeric array
the numeric array to be converted
form : str | ‘int’
the converted format

Return

numseq : converted numeric type
the format-converted array
mpes.utils.replist(entry, row, column)

Generator of nested lists with identical entries. Generated values are independent of one another.

*Parameters*

entry : numeric/str
repeated item in nested list
row : int
number of rows in nested list
column : int
number of columns in nested list

*Return*

nested list

mpes.utils.revaxis(arr, axis=-1)

Reverse an ndarray along certain axis

Parameters arr : nD numeric array

array to invert
axis : int | -1
the axis along which to invert

Return revarr : nD numeric array

axis-inverted nD array
mpes.utils.shuffleaxis(arr, axes, direction='front')

Move multiple axes of a multidimensional array simultaneously to the front or end of its axis order

*Parameters*

arr : ndarray
array to be shuffled
axes : tuple of int
dimensions to be shuffled
direction : str | ‘front’
direction of shuffling (‘front’ or ‘end’)

*Return*

sharr : ndarray
dimension-shuffled array
mpes.utils.to_odd(num)

Convert a single number to its nearest odd number

Parameters

num : float/int

Return

oddnum : int
the nearest odd number