hxtorch.spiking.handle
Defining tensor handles able to hold references to tensors for lazy assignment after hardware data acquisition
Classes
|
Helper class that provides a standard way to create an ABC using inheritance. |
|
Factory for classes which are to be used as custom handles for observable data, depending on the specific observables a module deals with. |
alias of |
|
alias of |
|
alias of |
|
alias of |
Functions
-
hxtorch.spiking.handle.
astuple
(obj, *, tuple_factory=<class 'tuple'>) Return the fields of a dataclass instance as a new tuple of field values.
Example usage:
@dataclass class C: x: int y: int c = C(1, 2) assert astuple(c) == (1, 2)
If given, ‘tuple_factory’ will be used instead of built-in tuple. The function applies recursively to field values that are dataclass instances. This will also look into built-in containers: tuples, lists, and dicts.
-
hxtorch.spiking.handle.
field
(*, default=<dataclasses._MISSING_TYPE object>, default_factory=<dataclasses._MISSING_TYPE object>, init=True, repr=True, hash=None, compare=True, metadata=None, kw_only=<dataclasses._MISSING_TYPE object>) Return an object to identify dataclass fields.
default is the default value of the field. default_factory is a 0-argument function called to initialize a field’s value. If init is true, the field will be a parameter to the class’s __init__() function. If repr is true, the field will be included in the object’s repr(). If hash is true, the field will be included in the object’s hash(). If compare is true, the field will be used in comparison functions. metadata, if specified, must be a mapping which is stored but not otherwise examined by dataclass. If kw_only is true, the field will become a keyword-only parameter to __init__().
It is an error to specify both default and default_factory.
-
hxtorch.spiking.handle.
fields
(class_or_instance) Return a tuple describing the fields of this dataclass.
Accepts a dataclass or an instance of one. Tuple elements are of type Field.
-
hxtorch.spiking.handle.
is_dataclass
(obj) Returns True if obj is a dataclass or an instance of a dataclass.
-
hxtorch.spiking.handle.
make_dataclass
(cls_name, fields, *, bases=(), namespace=None, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False) Return a new dynamically created dataclass.
The dataclass name will be ‘cls_name’. ‘fields’ is an iterable of either (name), (name, type) or (name, type, Field) objects. If type is omitted, use the string ‘typing.Any’. Field objects are created by the equivalent of calling ‘field(name, type [, Field-info])’.:
C = make_dataclass('C', ['x', ('y', int), ('z', int, field(init=False))], bases=(Base,))
is equivalent to:
@dataclass class C(Base): x: 'typing.Any' y: int z: int = field(init=False)
For the bases and namespace parameters, see the builtin type() function.
The parameters init, repr, eq, order, unsafe_hash, and frozen are passed to dataclass().