Skip to content
Snippets Groups Projects
Commit 8b6d7c69 authored by Martin Lange's avatar Martin Lange
Browse files

fix error logging, fix docs for and ref to component's __getitem__

parent 092c03a5
No related branches found
No related tags found
1 merge request!148Check missing components in composition
Pipeline #124592 passed with stages
in 2 minutes and 46 seconds
......@@ -80,7 +80,7 @@ An input can be connected to an output using either ``>>`` (as in the examples),
generator.outputs["Value"] >> plot.inputs["Value"]
generator.outputs["Value"].chain(consumer.inputs["Value"])
As a shortcut, slots can be accessed by the component's ``[]`` operator directly (see :meth:`.IComponent.__getitem__`):
As a shortcut, slots can be accessed by the component's ``[]`` operator directly (see :meth:`.Component.__getitem__`):
.. code-block:: Python
......
......@@ -31,7 +31,7 @@ class Component(IComponent, Loggable, ABC):
See :doc:`/finam-book/development/special_components`.
For components with a time step, use :class:`.TimeComponent`.
Derived classes overwrite these methods
Derived classes overwrite these methods:
* :meth:`._initialize`
* :meth:`._connect`
......@@ -289,17 +289,18 @@ class Component(IComponent, Loggable, ABC):
Raises
------
ValueError
If the name occurs in the inputs as well as the outputs
KeyError
If the name occurs neither in the inputs nor the outputs
If the name occurs in the inputs as well as the outputs,
or neither in the inputs nor the outputs.
"""
if name in self.inputs:
if name in self.outputs:
msg = f"Name `{name}` exists in inputs as well as outputs of component {self.name}"
if self.status == ComponentStatus.CREATED:
raise KeyError(msg)
with ErrorLogger(self.logger):
raise KeyError(
f"Name `{name}` exists in inputs as well as outputs of component {self.name}"
)
raise KeyError(msg)
return self.inputs[name]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment