Skip to content

Commit 19094af

Browse files
authored
Merge pull request #5 from ezmsg-org/dev
Minor docs fix and bump ezmsg dependency
2 parents 3c4cb2f + f90250e commit 19094af

6 files changed

Lines changed: 49 additions & 36 deletions

File tree

docs/source/_templates/autosummary/module.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{{ fullname | escape | underline}}
22

33
.. automodule:: {{ fullname }}
4+
:no-members:
45

56
{% block attributes %}
67
{% if attributes %}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ readme = "README.md"
1212
requires-python = ">=3.10"
1313
dynamic = ["version"]
1414
dependencies = [
15-
"ezmsg[axisarray]>=3.7.2",
15+
"ezmsg[axisarray]>=3.7.3",
1616
"typing-extensions>=4.0.0",
1717
]
1818

src/ezmsg/baseproc/composite.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,23 @@ class CompositeProcessor(
171171
typing.Generic[SettingsType, MessageInType, MessageOutType],
172172
):
173173
"""
174-
A processor that chains multiple processor together in a feedforward non-branching graph.
174+
A processor that chains multiple processors together in a feedforward non-branching graph.
175175
The individual processors may be stateless or stateful. The last processor may be a consumer,
176-
otherwise processors must be transformers. Use CompositeProducer if you want the first
177-
processor to be a producer. Concrete subclasses must implement `_initialize_processors`.
178-
Optionally override `_reset_state` if you want adaptive state behaviour.
179-
Example implementation:
180-
181-
class CustomCompositeProcessor(CompositeProcessor[CustomSettings, AxisArray, AxisArray]):
182-
@staticmethod
183-
def _initialize_processors(settings: CustomSettings) -> dict[str, BaseProcessor]:
184-
return {
185-
"stateful_transformer": CustomStatefulProducer(**settings),
186-
"transformer": CustomTransformer(**settings),
187-
}
188-
Where **settings should be replaced with initialisation arguments for each processor.
176+
otherwise processors must be transformers. Use ``CompositeProducer`` if you want the first
177+
processor to be a producer. Concrete subclasses must implement ``_initialize_processors``.
178+
Optionally override ``_reset_state`` if you want adaptive state behaviour.
179+
180+
Example implementation::
181+
182+
class CustomCompositeProcessor(CompositeProcessor[CustomSettings, AxisArray, AxisArray]):
183+
@staticmethod
184+
def _initialize_processors(settings: CustomSettings) -> dict[str, BaseProcessor]:
185+
return {
186+
"stateful_transformer": CustomStatefulProducer(**settings),
187+
"transformer": CustomTransformer(**settings),
188+
}
189+
190+
Where ``**settings`` should be replaced with initialisation arguments for each processor.
189191
"""
190192

191193
def __init__(self, *args, **kwargs) -> None:

src/ezmsg/baseproc/processor.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ class BaseProcessor(ABC, typing.Generic[SettingsType, MessageInType, MessageOutT
4545
"""
4646
Base class for processors. You probably do not want to inherit from this class directly.
4747
Refer instead to the more specific base classes.
48-
* Use :obj:`BaseConsumer` or :obj:`BaseTransformer` for ops that return a result or not, respectively.
49-
* Use :obj:`BaseStatefulProcessor` and its children for operations that require state.
5048
51-
Note that `BaseProcessor` and its children are sync by default. If you need async by defualt, then
52-
override the async methods and call them from the sync methods. Look to `BaseProducer` for examples of
49+
* Use :obj:`BaseConsumer` or :obj:`BaseTransformer` for ops that return a result or not, respectively.
50+
* Use :obj:`BaseStatefulProcessor` and its children for operations that require state.
51+
52+
Note that ``BaseProcessor`` and its children are sync by default. If you need async by default, then
53+
override the async methods and call them from the sync methods. Look to ``BaseProducer`` for examples of
5354
calling async methods from sync methods.
5455
"""
5556

src/ezmsg/baseproc/units.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -179,24 +179,27 @@ class BaseTransformerUnit(
179179
):
180180
"""
181181
Base class for transformer units -- i.e. units that transform input messages into output messages.
182-
Implement a new Unit as follows:
183182
184-
class CustomUnit(BaseTransformerUnit[
185-
CustomTransformerSettings, # SettingsType
186-
AxisArray, # MessageInType
187-
AxisArray, # MessageOutType
188-
CustomTransformer, # TransformerType
189-
]):
190-
SETTINGS = CustomTransformerSettings
183+
Implement a new Unit as follows::
184+
185+
class CustomUnit(BaseTransformerUnit[
186+
CustomTransformerSettings, # SettingsType
187+
AxisArray, # MessageInType
188+
AxisArray, # MessageOutType
189+
CustomTransformer, # TransformerType
190+
]):
191+
SETTINGS = CustomTransformerSettings
191192
192193
... that's all!
193194
194-
Where CustomTransformerSettings and CustomTransformer are custom implementations of:
195-
- ez.Settings for settings
195+
Where ``CustomTransformerSettings`` and ``CustomTransformer`` are custom implementations of:
196+
197+
- ``ez.Settings`` for settings
196198
- One of these transformer types:
197-
* BaseTransformer
198-
* BaseStatefulTransformer
199-
* CompositeProcessor
199+
200+
- ``BaseTransformer``
201+
- ``BaseStatefulTransformer``
202+
- ``CompositeProcessor``
200203
"""
201204

202205
INPUT_SIGNAL = ez.InputStream(MessageInType)

src/ezmsg/baseproc/util/typeresolution.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,23 @@ def resolve_typevar(cls: type, target_typevar: typing.TypeVar) -> type:
5050
def check_message_type_compatibility(type1: TypeLike, type2: TypeLike) -> bool:
5151
"""
5252
Check if two types are compatible for message passing.
53+
5354
Returns True if:
55+
5456
- Both are None/NoneType
5557
- Either is typing.Any
56-
- type1 is a subclass of type2, which includes
57-
- type1 and type2 are concrete types and type1 is a subclass of type2
58-
- type1 is None/NoneType and type2 is typing.Optional, or
59-
- type1 is subtype of the non-None inner type of type2 if type2 is Optional
58+
- type1 is a subclass of type2, which includes:
59+
60+
- type1 and type2 are concrete types and type1 is a subclass of type2
61+
- type1 is None/NoneType and type2 is typing.Optional, or
62+
- type1 is subtype of the non-None inner type of type2 if type2 is Optional
63+
6064
- type1 is a Union/Optional type and all inner types are compatible with type2
65+
6166
Args:
6267
type1: First type to compare
6368
type2: Second type to compare
69+
6470
Returns:
6571
bool: True if the types are compatible, False otherwise
6672
"""

0 commit comments

Comments
 (0)