bluecellulab.utils

Utility functions used within BlueCellulab.

Functions

run_once(func)

A decorator to ensure a function is only called once.

Classes

CaptureOutput([iterable])

NestedPool([processes, initializer, ...])

Class that represents a MultiProcessing nested pool.

NoDaemonProcess([group, target, name, args, ...])

Class that represents a non-daemon process.

NumpyEncoder(*[, skipkeys, ensure_ascii, ...])

class bluecellulab.utils.CaptureOutput(iterable=(), /)[source]
class bluecellulab.utils.NestedPool(processes=None, initializer=None, initargs=(), maxtasksperchild=None, context=None)[source]

Class that represents a MultiProcessing nested pool.

Process

alias of NoDaemonProcess

class bluecellulab.utils.NoDaemonProcess(group=None, target=None, name=None, args=(), kwargs={})[source]

Class that represents a non-daemon process.

property daemon

Return whether process is a daemon

class bluecellulab.utils.NumpyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]
default(obj)[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 super().default(o)
bluecellulab.utils.run_once(func)[source]

A decorator to ensure a function is only called once.