package emote.utils
Classes
class WeakReference(ReferenceType, Generic[T]):
A typed weak reference.
class LockedResource(Generic[T]):
Context manager for a lock and a resource.
Only giving access to the
resource when locked. Works well when paired with [empyc.types.Ref
]
for primitive types as well.
Usage:
resource = LockedResource([])
with resource as inner_list:
inner_list.append(1)
Methods
def __init__(self, data) -> None
Create a new LockedResource, with the provided data.
Arguments:
data(T)
: The data to lock
def swap(self, new_resource) -> T
Replace the contained resource with the provided new resource, returning the previous resource. This operation is atomic.
Arguments:
new_resource(T)
: The resource to lock after the swap
Returns:
- The previously guarded data
class AtomicContainer:
Container that allows atomic set
, get
, take
operations.
Methods
def __init__(self, initial_data) -> None
Arguments:
initial_data(Any)
def take(self) -> Any
def read(self) -> Any
def set(self, value) -> None
class AtomicInt:
Methods
def __init__(self, value) -> None
def swap(self, value) -> None
def increment(self, value) -> None
Increments the integer and returns the previous value.
Arguments:
value(int)
(default: 1)
class TimedBlock:
Used to track the performance statistics of a block of code, in terms of execution time.
Methods
def __init__(self, tracker_type) -> None
Create a new timed block instance.
Arguments:
tracker_type(Type[StatisticsAccumulator])
: The statistics integrator to use. Defaults to to MovingWindowStats
def mean(self) -> float
Retrieve the mean execution time.
def var(self) -> None
Retrieve the variance of the execution time.
def stats(self) -> None
Retrieve the mean and the variance of execution time.
class BlockTimers:
Methods
def __init__(self, tracker_type) -> None
def scope(self, name) -> TimedBlock
def stats(self) -> None
class MDPSpace:
Fields
-
rewards
:BoxSpace
-
actions
:BoxSpace
-
state
:DictSpace