idmtools_calibra.utilities.encoding module

class idmtools_calibra.utilities.encoding.NumpyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: JSONEncoder

default(obj)[source]

If input object is an ndarray it will be converted into a dict holding dtype, shape and the data, base64 encoded.

class idmtools_calibra.utilities.encoding.GeneralEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: NumpyEncoder

default(obj)[source]

If input object is an ndarray it will be converted into a dict holding dtype, shape and the data, base64 encoded.

idmtools_calibra.utilities.encoding.json_numpy_obj_hook(dct)[source]

Decodes a previously encoded numpy ndarray with proper shape and dtype.

Parameters:

dct – (dict) json encoded ndarray

Returns:

(ndarray) if input was an encoded ndarray

idmtools_calibra.utilities.encoding.cast_number(val)[source]

Try casting the value to float/int returns str if cannot :param val: the value to cast :return: value casted