pyuncertainnumber.characterisation.utils¶
Classes¶
a template for jsonify general (dataclass) object |
|
a bespoke JSON encoder for the PBA object |
|
a bespoke JSON encoder for the UncertainNumber object |
Functions¶
|
a shortcut function to save plot to visualization dir |
|
plot the CDF return the quantile |
|
|
|
plot the empirical CDF given samples |
|
|
|
|
|
significant digits representation |
|
detects if a string representation of a list |
|
detects if a syntactically wrong specification of a list |
|
|
|
|
|
|
|
convert a percentage into a float number |
|
|
|
convert an array from a dictionary into a list |
|
Module Contents¶
- pyuncertainnumber.characterisation.utils.save2Vis(figname)¶
a shortcut function to save plot to visualization dir
Note
We simply assume that every repo will have a ‘visulizations’ dir under the root directory
- pyuncertainnumber.characterisation.utils.tranform_ecdf(s, display=False, **kwargs)¶
plot the CDF return the quantile
- Parameters:
s – sample
- pyuncertainnumber.characterisation.utils.pl_pcdf(dist: type[scipy.stats.rv_continuous | scipy.stats.rv_discrete], ax=None, title=None, **kwargs)¶
- pyuncertainnumber.characterisation.utils.pl_ecdf(s, ax=None, return_value=False, **kwargs)¶
plot the empirical CDF given samples
- Parameters:
s (array-like) – sample which can be either raw data or deviates as a representation of dist construct
- pyuncertainnumber.characterisation.utils.to_database(dict_list, db_name, col_name)¶
- pyuncertainnumber.characterisation.utils.cd_root_dir(depth=0)¶
- pyuncertainnumber.characterisation.utils.sgnumber(user_input: str) list¶
significant digits representation
number plus or minus its significant-digit imprecision
- pyuncertainnumber.characterisation.utils.initial_list_checking(text)¶
detects if a string representation of a list
- pyuncertainnumber.characterisation.utils.bad_list_checking(text)¶
detects if a syntactically wrong specification of a list
- pyuncertainnumber.characterisation.utils.PlusMinus_parser(txt)¶
- pyuncertainnumber.characterisation.utils.parser4(text)¶
- pyuncertainnumber.characterisation.utils.percentage_finder(txt)¶
- pyuncertainnumber.characterisation.utils.percentage_converter(txt)¶
convert a percentage into a float number
Note
force only 1 percentage
- class pyuncertainnumber.characterisation.utils.EnhancedJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)¶
Bases:
json.JSONEncodera template for jsonify general (dataclass) object
#TODO Interval object in not json serializable
- default(o)¶
Implement this method in a subclass such that it returns a serializable object for
o, or calls the base implementation (to raise aTypeError).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return super().default(o)
- class pyuncertainnumber.characterisation.utils.PBAEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)¶
Bases:
json.JSONEncodera bespoke JSON encoder for the PBA object
- default(o)¶
Implement this method in a subclass such that it returns a serializable object for
o, or calls the base implementation (to raise aTypeError).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return super().default(o)
- class pyuncertainnumber.characterisation.utils.UNEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)¶
Bases:
json.JSONEncodera bespoke JSON encoder for the UncertainNumber object
Note
Currently I’m treating the JSON data represent of a UN object
the same as the __repr__ method. But this can be changed later on to show more explicitly the strucutre of pbox or distribution # TODO prettify the JSON output to be explicit e.g. ‘essence’: ‘interval’, ‘interval_initialisation’: [2, 3] to shown as ‘interval’ with lower end and upper end distribution to shown as the type and parameters; e.g. ‘distribution’: ‘normal’, ‘parameters’: [2, 3]
- default(o)¶
Implement this method in a subclass such that it returns a serializable object for
o, or calls the base implementation (to raise aTypeError).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return super().default(o)
- pyuncertainnumber.characterisation.utils.get_concise_repr(a_dict)¶
- pyuncertainnumber.characterisation.utils.array2list(a_dict)¶
convert an array from a dictionary into a list
- pyuncertainnumber.characterisation.utils.entries_to_remove(remove_entries, the_dict)¶