Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
teubert committed Nov 8, 2024
1 parent b83eb78 commit c844aa3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
Binary file modified docs/.doctrees/api_ref/progpy/CompositeModel.doctree
Binary file not shown.
Binary file modified docs/.doctrees/environment.pickle
Binary file not shown.
19 changes: 19 additions & 0 deletions docs/api_ref/progpy/CompositeModel.html
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,25 @@ <h1>CompositeModel<a class="headerlink" href="#compositemodel" title="Permalink
<dd class="field-even"><p><strong>outputs</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.13)"><em>list</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><em>str</em></a><em>]</em>) – Model outputs in format “model_name.output_name”. Must be subset of all outputs from models. If not provided, all outputs will be included.</p>
</dd>
</dl>
<p class="rubric">Example</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">SomeModel</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m2</span> <span class="o">=</span> <span class="n">SomeOtherModel</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">kelvin_to_celcius</span><span class="p">(</span><span class="n">temp_in_kelvin</span><span class="p">):</span>
<span class="gp">&gt;&gt;&gt; </span> <span class="k">return</span> <span class="n">temp_in_kelvin</span> <span class="o">-</span> <span class="mf">273.15</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">connections</span> <span class="o">=</span> <span class="p">[</span>
<span class="gp">&gt;&gt;&gt; </span> <span class="p">(</span><span class="s1">&#39;m1.temp&#39;</span><span class="p">,</span> <span class="s1">&#39;kelvin_to_celcius.temp_in_kelvin&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span> <span class="p">(</span><span class="s1">&#39;kelvin_to_celcius.return&#39;</span><span class="p">,</span> <span class="s1">&#39;m2.temp&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m_composite</span> <span class="o">=</span> <span class="n">CompositeModel</span><span class="p">(</span>
<span class="gp">&gt;&gt;&gt; </span> <span class="p">((</span><span class="s1">&#39;m1&#39;</span><span class="p">,</span> <span class="n">m</span><span class="p">),</span> <span class="p">(</span><span class="s1">&#39;kelvin_to_celcius&#39;</span><span class="p">,</span> <span class="n">kelvin_to_celcius</span><span class="p">),</span> <span class="p">(</span><span class="s1">&#39;m2&#39;</span><span class="p">,</span> <span class="n">m2</span><span class="p">)),</span> <span class="c1"># models</span>
<span class="gp">&gt;&gt;&gt; </span> <span class="n">connections</span><span class="o">=</span><span class="n">connections</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">)</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Model parameters can be set and accessed using the ‘[model].[param]’ format. For example, for composite model m, m[‘foo.bar’] would set the parameter ‘bar’ for the model ‘foo’.</p>
</div>
</dd></dl>

</section>
Expand Down
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion src/progpy/composite_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,21 @@ class CompositeModel(PrognosticsModel):
outputs (list[str]):
Model outputs in format "model_name.output_name". Must be subset of all outputs from models. If not provided, all outputs will be included.
Example:
>>> m = SomeModel()
>>> m2 = SomeOtherModel()
>>> def kelvin_to_celcius(temp_in_kelvin):
>>> return temp_in_kelvin - 273.15
>>> connections = [
>>> ('m1.temp', 'kelvin_to_celcius.temp_in_kelvin')
>>> ('kelvin_to_celcius.return', 'm2.temp')
>>> ]
>>> m_composite = CompositeModel(
>>> (('m1', m), ('kelvin_to_celcius', kelvin_to_celcius), ('m2', m2)), # models
>>> connections=connections
>>> )
.. note:: Model parameters can be set and accessed using the '[model].[param]' format. For example, for composite model m, m['foo.bar'] would set the parameter 'bar' for the model 'foo'.
"""

def __init__(self, models: list, connections: list = [], **kwargs):
Expand Down

0 comments on commit c844aa3

Please sign in to comment.