pycomex package

Subpackages

Submodules

pycomex.cli module

Console script for pycomex.

class pycomex.cli.ExperimentCLI(name: str, experiments_path: str, experiments_base_path: Optional[str] = None, version: str = '0.0.0', additional_help: str = '', **kwargs)[source]

Bases: Group

callback(version)[source]
discover_experiments()[source]
experiment_info = <Command info>
list_experiments = <Command list>
run_experiment = <Command run>
pycomex.cli.section(string: str, length: int, padding: int = 2)[source]
pycomex.cli.subsection(string: str, length: int, padding: int = 2)[source]

pycomex.experiment module

This is a module level docstring

pycomex.util module

Utility methods

class pycomex.util.CustomJsonEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: JSONEncoder

custom json encoder class which is used when encoding the experiment data into a persistent json file.

This specific class implements the serialization of numpy arrays for example which makes it possible to commit numpy arrays to the experiment storage without causing an exception.

default(value)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

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 JSONEncoder.default(self, o)
class pycomex.util.Empty[source]

Bases: object

class pycomex.util.RecordCode(stack_index: int = 2, initial_stack_index: int = 1, skip=False)[source]

Bases: object

INDENT_SPACES = 4

This class can be used as a context manager to record code.

CHANGES 12.09.2022

Previously this class worked like this: In the __enter__ method a frameinfo supplied the line number at which the context starts and then the same was done in __exit__ and with Python 3.8 this actually worked The two methods returned the correct line numbers. But as of Python 3.10, this no longer works because the __exit__ method now ALSO returns just the line number of where the context manager starts.

But since we can still get the start line reliably, we just have to extract the code with some string processing now: With the starting line we know the indent of this context manager and can then record all the code which follows it in one level of indent deeper.

get_frame_info()[source]
exception pycomex.util.SkipExecution[source]

Bases: Exception

class pycomex.util.Skippable[source]

Bases: object

pycomex.util.dict_value_sort(data: dict, key: Optional[str] = None, reverse: bool = False, k: Optional[int] = None)[source]
pycomex.util.get_version()[source]

pycomex.work module

class pycomex.work.AbstractWorkTracker(total_work: int)[source]

Bases: object

property completed_work
estimate() float[source]
set_total_work(total_work: int)[source]
start() None[source]
update(n: int = 1, weight: float = 1.0) None[source]
class pycomex.work.NaiveWorkTracker(total_work: int)[source]

Bases: AbstractWorkTracker

estimate() float[source]

Module contents

Top-level package for pycomex.