From fbb585ecd1c0380b37c776cc9c0e6721fb50ad8f Mon Sep 17 00:00:00 2001 From: Martin Lange <martin.lange@ufz.de> Date: Thu, 8 Dec 2022 15:08:32 +0100 Subject: [PATCH] fix doctests for new logging in INFO --- docs/source/finam-book/development/adapters.rst | 6 ++++-- .../finam-book/development/connect_phase.rst | 16 ++++++++++++++-- .../development/special_components.rst | 13 +++++++++++-- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/docs/source/finam-book/development/adapters.rst b/docs/source/finam-book/development/adapters.rst index e0ad6484..8953d715 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 0c81772f..fed7eda6 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 9a3ffde4..17b52a4b 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. -- GitLab