utils

class pymethods.utils.Descriptor(name: str)

Base descriptor class

class pymethods.utils.LockedDescriptor(name: str)
class pymethods.utils.NoInputFunctionAlias(name: str, store=False)
pymethods.utils.cummulative_decompose(iterable: Iterable) → List

decompose an itearble cummutavely, for example, cummulative_decompose(‘string’) = [‘s’, ‘st’, ‘str’,…]

Args:

iterable (Iterable): an iterable object

Returns:

List: list of the cummulatively decomposed iterable

class pymethods.utils.IsSubsetString(main_string: str, case_sensitive=False)
case_sensitive
property decomposed_string
main_string
class pymethods.utils.IsAny(*comaprison_objects: Iterable[Union[type, object]])
abstract check(obj: object, comparison: type) → bool

abstract method that compares obj to comparison,

Args:

obj (object): object to be checked comparison (type): type to compare with

Raises:

NotImplementedError:

Returns:

bool: True if passes checks else False

comaprison_objects
class pymethods.utils.Isinstance(*comaprison_objects: Iterable[Union[type, object]])
check(obj: object, comparison: type) → bool

Isinstance

test if obj is an instance of the comparison type

Args:

obj (object): object to be checked comparison (type): type to compare with

Returns:

bool: True if instance

comaprison_objects
class pymethods.utils.Issubclass(*comaprison_objects: Iterable[Union[type, object]])
check(obj: object, comparison: type) → bool

Issubclass

test if obj is a subclass of the comparison type

Args:

obj (object): object to be checked comparison (type): type to compare with

Returns:

bool: True if subclass

comaprison_objects
pymethods.utils.is_none(obj: object) → bool

check if the obj is None

Args:

obj (object):

Returns:

bool: True if None

class pymethods.utils.Isin(*comaprison_objects: Iterable[Union[type, object]])
check(obj: object, comparison: Iterable) → bool

Isinany

check if the object is in any of the self.comaprison_objects

Args:

IsAny ([type]): [description] obj (object): [description] comparison (Iterable): [description]

comaprison_objects
pymethods.utils.hex_memory(obj: object)
class pymethods.utils.SequentialFunction(*args)
class pymethods.utils.AliasDict(alias_names: Iterable[Hashable], obj: object)
register_key(key: Hashable) → None

Registers a new key in the dictionary. Speed up lookup of strings by interning its values https://en.wikipedia.org/wiki/String_interning this is done by storing only a single copy of each distinc string value

Args:
key (Hashable): hashable object to

register as new key

class pymethods.utils.LenDimShape(axis: Union[int, str])
set_dim_extractor() → None
pymethods.utils.len_dim_shape_axis(obj: object, axis=0) → int

Find the len of the dimension of array or object with shape property containing a __len__ method. Ferformed along specified axis

Args:

obj (object): [description] axis (int, optional): dimension to find the length of. Defaults to 0.

Returns:

int: [description]

pymethods.utils.len_dim_shape_longest(obj: object) → int

len_dim_shape_longest [summary]

Find the len of the longest dimension of array or object with shape property that contains a __len__ method

Args:
array (object): object containing a shape

property with a len method

Returns:

int: len of shape

pymethods.utils.len_dim_shape_shortest(obj: object) → int

Find the len of the shortest dimension of array or object with shape property that contains a __len__ method

Args:
array (object): object containing a shape

property with a len method

Returns:

int: len of shape

pymethods.utils.is_1d(vectors: numpy.array) → bool

check if the object is 1 dimensional

Args:

vectors (np.array): array to check

Returns:

bool: True if the data is 1d False if not

pymethods.utils.len_shape(obj: object) → int

len the length of the shape of an object

Args:
obj (object): object with shape

property

Returns:

int: the length of the shape

pymethods.utils.make_column(vectors: numpy.ndarray) → numpy.ndarray

convert a vector into column vector. This assumes that the vector has lenshape 1 otherwise it is passed directly

Args:

vectors (np.ndarray):

Returns:

np.ndarray:

pymethods.utils.make_row(vectors: numpy.ndarray) → numpy.ndarray

convert a vector into row vector. This assumes that the vector has lenshape 1 otherwise it is passed directly

Args:

vectors (np.ndarray):

Returns:

np.ndarray:

pymethods.utils.chunk_iterable(indexable: Iterable, num_chunk: int, callbacks=None) → list

For some iterable generate num_chunk, approximately even number of chunks

Args:

iterable (Iterable): an iterable to be chunked num_chunk (int): total number of chunks to generate callbacks (Iterable[Callable]): an iterable containing callable methods

which take two arguments (indexed, indexable). These callbacks operate over these indexable values and outputs the values of the current chunk

Returns:

list: a list of lists of chunks from the iterabel

pymethods.utils.enumerate_chunk(iterable: Iterable, num: int) → list
pymethods.utils.sort_pair_list_and_extract_items(mp_list: list) → list

sort_and_extract_mp_list

A list when enumerated and zipped has the form:

[(key, item_1),…, (key, item_n)]

This method sorts the input list by the key and extracts a list of the items.

Args:

mp_list (list): enumerated zipped list

Returns:

list: the sorted list of items

pymethods.utils.memory_size(array: numpy.ndarray, out='bytes')
pymethods.utils.time_func(func, *args, **kwargs)
pymethods.utils.gap_space(start, lim, gap)
pymethods.utils.make_odd(input)