Skip to content

Commit

Permalink
deploy: 086b4f3
Browse files Browse the repository at this point in the history
  • Loading branch information
TShapinsky committed Nov 2, 2023
1 parent 06ac0a4 commit 37e336b
Show file tree
Hide file tree
Showing 14 changed files with 1,039 additions and 994 deletions.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
Binary file modified .doctrees/guides/ingress-bacnet-to-brick.doctree
Binary file not shown.
Binary file not shown.
Binary file modified .doctrees/tutorials/model_correction.doctree
Binary file not shown.
Binary file modified .doctrees/tutorials/model_creation.doctree
Binary file not shown.
36 changes: 36 additions & 0 deletions _modules/buildingmotif/shape_builder/shape.html
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,42 @@ <h1>Source code for buildingmotif.shape_builder.shape</h1><div class="highlight"
<span class="sd"> :type nodes: Union[List[Node], Tuple[Node, ...]]</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">Shape</span><span class="p">()</span><span class="o">.</span><span class="n">XONE</span><span class="p">(</span><span class="o">*</span><span class="n">nodes</span><span class="p">)</span></div>


<div class="viewcode-block" id="shape_from_graph"><a class="viewcode-back" href="../../../reference/apidoc/_autosummary/buildingmotif.shape_builder.shape.html#buildingmotif.shape_builder.shape.shape_from_graph">[docs]</a><span class="k">def</span> <span class="nf">shape_from_graph</span><span class="p">(</span><span class="n">graph</span><span class="p">:</span> <span class="n">Graph</span><span class="p">,</span> <span class="n">shape_uri</span><span class="p">:</span> <span class="n">URIRef</span><span class="p">,</span> <span class="n">depth</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">20</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="s2">&quot;Shape&quot;</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Extract Shape from Graph by URIRef.</span>
<span class="sd"> This method extracts the shape and all associated shapes into a Shape object which maintains most context needed to</span>
<span class="sd"> run the shape in isolation.</span>

<span class="sd"> Returns subgraph of &quot;graph&quot; containing triples relevant to the shape.</span>

<span class="sd"> Algorithm:</span>
<span class="sd"> 1. Create empty shape with uri of shape_uri</span>
<span class="sd"> 2. Add cbd of shape_uri to empty shape</span>
<span class="sd"> 3. For each object in cbd check if it is of type NodeShape or PropertyShape</span>
<span class="sd"> 4. If object is a shape call this function on it and add it to this shape</span>

<span class="sd"> :param graph: graph from which to extract shape</span>
<span class="sd"> :type graph: Graph</span>
<span class="sd"> :param shape_uri: URIRef of shape to extract</span>
<span class="sd"> :type shape_uri: URIRef</span>
<span class="sd"> :param depth: maximum recursive depth</span>
<span class="sd"> :type depth: int&quot;&quot;&quot;</span>
<span class="n">shape</span> <span class="o">=</span> <span class="n">Shape</span><span class="p">(</span><span class="n">shape_uri</span><span class="p">)</span>
<span class="k">if</span> <span class="n">depth</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">return</span> <span class="n">shape</span>
<span class="n">shape</span> <span class="o">+=</span> <span class="n">graph</span><span class="o">.</span><span class="n">cbd</span><span class="p">(</span><span class="n">shape_uri</span><span class="p">)</span>
<span class="n">triples</span> <span class="o">=</span> <span class="n">shape</span><span class="o">.</span><span class="n">triples</span><span class="p">((</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">))</span>

<span class="k">def</span> <span class="nf">is_node_shape</span><span class="p">(</span><span class="n">uri</span><span class="p">:</span> <span class="n">URIRef</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
<span class="n">types</span> <span class="o">=</span> <span class="p">[</span><span class="nb">type</span> <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="nb">type</span> <span class="ow">in</span> <span class="n">graph</span><span class="o">.</span><span class="n">triples</span><span class="p">((</span><span class="n">uri</span><span class="p">,</span> <span class="n">A</span><span class="p">,</span> <span class="kc">None</span><span class="p">))]</span>
<span class="k">return</span> <span class="n">SH</span><span class="p">[</span><span class="s2">&quot;NodeShape&quot;</span><span class="p">]</span> <span class="ow">in</span> <span class="n">types</span> <span class="ow">or</span> <span class="n">SH</span><span class="p">[</span><span class="s2">&quot;PropertyShape&quot;</span><span class="p">]</span> <span class="ow">in</span> <span class="n">types</span>

<span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">triples</span><span class="p">:</span>
<span class="k">if</span> <span class="n">is_node_shape</span><span class="p">(</span><span class="n">o</span><span class="p">):</span>
<span class="n">shape</span> <span class="o">+=</span> <span class="n">shape_from_graph</span><span class="p">(</span><span class="n">graph</span><span class="p">,</span> <span class="n">o</span><span class="p">,</span> <span class="n">depth</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>

<span class="k">return</span> <span class="n">shape</span></div>
</pre></div>

</article>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ buildingmotif.shape\_builder.shape
NOT
OR
XONE
shape_from_graph



Expand Down
2 changes: 2 additions & 0 deletions genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,8 @@ <h2 id="S">S</h2>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/apidoc/_autosummary/buildingmotif.dataclasses.validation.html#buildingmotif.dataclasses.validation.ValidationContext.shape_collections">shape_collections (ValidationContext attribute)</a>
</li>
<li><a href="reference/apidoc/_autosummary/buildingmotif.shape_builder.shape.html#buildingmotif.shape_builder.shape.shape_from_graph">shape_from_graph() (in module buildingmotif.shape_builder.shape)</a>
</li>
<li><a href="reference/apidoc/_autosummary/buildingmotif.dataclasses.shape_collection.html#buildingmotif.dataclasses.shape_collection.ShapeCollection">ShapeCollection (class in buildingmotif.dataclasses.shape_collection)</a>
</li>
Expand Down
Loading

0 comments on commit 37e336b

Please sign in to comment.