diff --git a/docs/source/finam-book/development/adapters.rst b/docs/source/finam-book/development/adapters.rst index e0ad6484e992aa8a87b0343ec2fffe39af1f6c61..8953d7158ce0fa23f7b45557b02fe0dcb0429f4c 100644 --- a/docs/source/finam-book/development/adapters.rst +++ b/docs/source/finam-book/development/adapters.rst @@ -70,13 +70,14 @@ File ``src/scale.py``: generator.outputs["Value"] >> adapter >> consumer.inputs["Input"] - comp.run(end_time=datetime(2000, 1, 2)) + comp.run(end_time=datetime(2000, 1, 2)) # doctest: +ELLIPSIS print(consumer.data["Input"][0, ...]) .. testoutput:: scale-adapter :hide: + ... 0.5 dimensionless In :meth:`.Adapter._get_data`, we: @@ -238,13 +239,14 @@ In :meth:`.Adapter._get_data`, we can now do the interpolation whenever data is generator.outputs["Value"] >> adapter >> consumer.inputs["Input"] - comp.run(end_time=datetime(2000, 1, 15)) + comp.run(end_time=datetime(2000, 1, 15)) # doctest: +ELLIPSIS print(consumer.data["Input"][0, ...]) .. testoutput:: time-adapter :hide: + ... 15.0 dimensionless In :meth:`.Adapter._get_data`, the following happens: diff --git a/docs/source/finam-book/development/connect_phase.rst b/docs/source/finam-book/development/connect_phase.rst index 0c81772fcda9fdfdcb7ae56dc2e6d5b81d8e3208..fed7eda6f18911ba02ab05edf0307ec9a99d7caa 100644 --- a/docs/source/finam-book/development/connect_phase.rst +++ b/docs/source/finam-book/development/connect_phase.rst @@ -197,7 +197,13 @@ In the most simple case, all metadata is known in :meth:`.Component._initialize` generator.outputs["Output2"] >> simple_conn.inputs["B"] simple_conn.outputs["Area"] >> consumer.inputs["Input"] - comp.connect() + comp.connect() # doctest: +ELLIPSIS + +.. testoutput:: simple-connect + :hide: + + ... + In :meth:`.Component._initialize`, we create inputs and outputs with metadata (here ``grid`` and ``units``). Then, we create the connector with :meth:`.Component.create_connector`. No arguments required here, as there are no dependencies. @@ -284,7 +290,13 @@ and the initial data should be generated from it. generator.outputs["Output2"] >> complex_conn.inputs["B"] complex_conn.outputs["Area"] >> consumer.inputs["Input"] - comp.connect() + comp.connect() # doctest: +ELLIPSIS + +.. testoutput:: complex-connect + :hide: + + ... + In :meth:`.Component._initialize`, we set the ``grid`` of input ``"A"`` to ``None``. It will be filled from the connected output, and becomes available in diff --git a/docs/source/finam-book/development/special_components.rst b/docs/source/finam-book/development/special_components.rst index 9a3ffde43a6b9d28a94094a366b6540611276aa6..17b52a4b70300bdc4f56c036c29549c4c8843b92 100644 --- a/docs/source/finam-book/development/special_components.rst +++ b/docs/source/finam-book/development/special_components.rst @@ -82,8 +82,12 @@ Push-based components can use :class:`.CallbackInput` to get informed about inco generator.outputs["Value"] >> push_comp.inputs["Input"] - comp.run(end_time=datetime(2000, 1, 15)) + comp.run(end_time=datetime(2000, 1, 15)) # doctest: +ELLIPSIS +.. testoutput:: push-component + :hide: + + ... In ``_initialize()``, a :class:`.CallbackInput` is added that calls ``_data_changed()`` when notified about new data. @@ -153,7 +157,12 @@ Push-based components can use :class:`.CallbackOutput` to intercept data pulls. pull_comp.outputs["Output"] >> consumer.inputs["Input"] - comp.run(end_time=datetime(2000, 1, 15)) + comp.run(end_time=datetime(2000, 1, 15)) # doctest: +ELLIPSIS + +.. testoutput:: pull-component + :hide: + + ... In ``_initialize()``, a :class:`.CallbackOutput` is added that calls ``_get_data()`` when pulled. ``_get_data()`` must return the data that would normally be pushed to the output.