Skip to content

Commit

Permalink
deploy: 45e5b2e
Browse files Browse the repository at this point in the history
  • Loading branch information
olynch committed Nov 14, 2023
1 parent c596a99 commit 6e6a784
Show file tree
Hide file tree
Showing 11 changed files with 251 additions and 55 deletions.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
Binary file modified .doctrees/usage/acsets.doctree
Binary file not shown.
Binary file modified .doctrees/usage/petris.doctree
Binary file not shown.
39 changes: 26 additions & 13 deletions _modules/acsets/acsets.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,12 @@ <h1>Source code for acsets.acsets</h1><div class="highlight"><pre>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;The name of the object&quot;</span><span class="p">)</span>
<span class="n">title</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="n">description</span><span class="o">=</span><span class="s2">&quot;The human-readable label for the object&quot;</span><span class="p">)</span>
<span class="n">description</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="n">description</span><span class="o">=</span><span class="s2">&quot;A long-form description of the object&quot;</span><span class="p">)</span>
<span class="n">title</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span>
<span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;The human-readable label for the object&quot;</span>
<span class="p">)</span>
<span class="n">description</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span>
<span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;A long-form description of the object&quot;</span>
<span class="p">)</span>

<div class="viewcode-block" id="Ob.Config">
<a class="viewcode-back" href="../../usage/acsets.html#acsets.acsets.Ob.Config">[docs]</a>
Expand All @@ -139,11 +143,15 @@ <h1>Source code for acsets.acsets</h1><div class="highlight"><pre>
<span class="sd"> and `Hom(&quot;tgt&quot;, E, V)`.</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="n">description</span><span class="o">=</span><span class="s2">&quot;The name of the morphism.&quot;</span><span class="p">)</span>
<span class="n">dom</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s2">&quot;domain&quot;</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;The object of the domain.&quot;</span><span class="p">)</span>
<span class="n">codom</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s2">&quot;codomain&quot;</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;The object of the codomain.&quot;</span><span class="p">)</span>
<span class="n">title</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="n">description</span><span class="o">=</span><span class="s2">&quot;The human-readable label for the morphism&quot;</span><span class="p">)</span>
<span class="n">description</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="n">description</span><span class="o">=</span><span class="s2">&quot;A long-form description of the morphism&quot;</span><span class="p">)</span>
<span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;The name of the morphism.&quot;</span><span class="p">)</span>
<span class="n">dom</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="s2">&quot;domain&quot;</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;The object of the domain.&quot;</span><span class="p">)</span>
<span class="n">codom</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="s2">&quot;codomain&quot;</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;The object of the codomain.&quot;</span><span class="p">)</span>
<span class="n">title</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span>
<span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;The human-readable label for the morphism&quot;</span>
<span class="p">)</span>
<span class="n">description</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span>
<span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;A long-form description of the morphism&quot;</span>
<span class="p">)</span>

<div class="viewcode-block" id="Hom.dom_string">
<a class="viewcode-back" href="../../usage/acsets.html#acsets.acsets.Hom.dom_string">[docs]</a>
Expand Down Expand Up @@ -209,9 +217,10 @@ <h1>Source code for acsets.acsets</h1><div class="highlight"><pre>
<span class="sd"> transition, for instance, has a tuple of strings as its name.</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="n">description</span><span class="o">=</span><span class="s2">&quot;The name of the attribute type.&quot;</span><span class="p">)</span>
<span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;The name of the attribute type.&quot;</span><span class="p">)</span>
<span class="n">ty</span><span class="p">:</span> <span class="nb">type</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span>
<span class="n">description</span><span class="o">=</span><span class="s2">&quot;The type assigned to the attribute type. Use a string referring to the Python type&quot;</span>
<span class="o">...</span><span class="p">,</span>
<span class="n">description</span><span class="o">=</span><span class="s2">&quot;The type assigned to the attribute type. Use a string referring to the Python type&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="n">title</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
<span class="n">description</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
Expand Down Expand Up @@ -248,9 +257,9 @@ <h1>Source code for acsets.acsets</h1><div class="highlight"><pre>
<span class="sd"> which is the attribute that stores the name of a species in a Petri net.</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s2">&quot;name&quot;</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;The name of the attribute.&quot;</span><span class="p">)</span>
<span class="n">dom</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s2">&quot;domain&quot;</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;The object in the domain.&quot;</span><span class="p">)</span>
<span class="n">codom</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s2">&quot;codomain&quot;</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;The attribute type in the codomain&quot;</span><span class="p">)</span>
<span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="s2">&quot;name&quot;</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;The name of the attribute.&quot;</span><span class="p">)</span>
<span class="n">dom</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="s2">&quot;domain&quot;</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;The object in the domain.&quot;</span><span class="p">)</span>
<span class="n">codom</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">Field</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="s2">&quot;codomain&quot;</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;The attribute type in the codomain&quot;</span><span class="p">)</span>
<span class="n">title</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
<span class="n">description</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>

Expand Down Expand Up @@ -413,7 +422,11 @@ <h1>Source code for acsets.acsets</h1><div class="highlight"><pre>
<span class="sd"> Returns:</span>
<span class="sd"> The Property value type</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="nb">int</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">prop</span><span class="p">,</span> <span class="n">Hom</span><span class="p">)</span> <span class="k">else</span> <span class="nb">next</span><span class="p">(</span><span class="n">at</span> <span class="k">for</span> <span class="n">at</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">AttrType</span> <span class="k">if</span> <span class="n">at</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="n">prop</span><span class="o">.</span><span class="n">codom</span><span class="p">)</span><span class="o">.</span><span class="n">ty</span></div>
<span class="k">return</span> <span class="p">(</span>
<span class="nb">int</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">prop</span><span class="p">,</span> <span class="n">Hom</span><span class="p">)</span>
<span class="k">else</span> <span class="nb">next</span><span class="p">(</span><span class="n">at</span> <span class="k">for</span> <span class="n">at</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">AttrType</span> <span class="k">if</span> <span class="n">at</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="n">prop</span><span class="o">.</span><span class="n">codom</span><span class="p">)</span><span class="o">.</span><span class="n">ty</span>
<span class="p">)</span></div>


<div class="viewcode-block" id="Schema.valid_value">
Expand Down
34 changes: 34 additions & 0 deletions genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,40 @@ <h2 id="M">M</h2>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="usage/acsets.html#acsets.acsets.Schema.make_schema">make_schema() (Schema method)</a>
</li>
<li><a href="usage/acsets.html#acsets.acsets.Attr.model_config">model_config (Attr attribute)</a>

<ul>
<li><a href="usage/acsets.html#acsets.acsets.AttrType.model_config">(AttrType attribute)</a>
</li>
<li><a href="usage/acsets.html#acsets.acsets.CatlabSchema.model_config">(CatlabSchema attribute)</a>
</li>
<li><a href="usage/acsets.html#acsets.acsets.HashableBaseModel.model_config">(HashableBaseModel attribute)</a>
</li>
<li><a href="usage/acsets.html#acsets.acsets.Hom.model_config">(Hom attribute)</a>
</li>
<li><a href="usage/acsets.html#acsets.acsets.Ob.model_config">(Ob attribute)</a>
</li>
<li><a href="usage/acsets.html#acsets.acsets.VersionSpec.model_config">(VersionSpec attribute)</a>
</li>
</ul></li>
<li><a href="usage/acsets.html#acsets.acsets.Attr.model_fields">model_fields (Attr attribute)</a>

<ul>
<li><a href="usage/acsets.html#acsets.acsets.AttrType.model_fields">(AttrType attribute)</a>
</li>
<li><a href="usage/acsets.html#acsets.acsets.CatlabSchema.model_fields">(CatlabSchema attribute)</a>
</li>
<li><a href="usage/acsets.html#acsets.acsets.HashableBaseModel.model_fields">(HashableBaseModel attribute)</a>
</li>
<li><a href="usage/acsets.html#acsets.acsets.Hom.model_fields">(Hom attribute)</a>
</li>
<li><a href="usage/acsets.html#acsets.acsets.Ob.model_fields">(Ob attribute)</a>
</li>
<li><a href="usage/acsets.html#acsets.acsets.VersionSpec.model_fields">(VersionSpec attribute)</a>
</li>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li>
module

Expand Down
39 changes: 26 additions & 13 deletions lib/acsets/acsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ class Ob(HashableBaseModel):
"""

name: str = Field(..., description="The name of the object")
title: Optional[str] = Field(description="The human-readable label for the object")
description: Optional[str] = Field(description="A long-form description of the object")
title: Optional[str] = Field(
default=None, description="The human-readable label for the object"
)
description: Optional[str] = Field(
default=None, description="A long-form description of the object"
)

class Config:
"""pydantic config"""
Expand All @@ -52,11 +56,15 @@ class Hom(HashableBaseModel):
and `Hom("tgt", E, V)`.
"""

name: str = Field(description="The name of the morphism.")
dom: str = Field(title="domain", description="The object of the domain.")
codom: str = Field(title="codomain", description="The object of the codomain.")
title: Optional[str] = Field(description="The human-readable label for the morphism")
description: Optional[str] = Field(description="A long-form description of the morphism")
name: str = Field(..., description="The name of the morphism.")
dom: str = Field(..., title="domain", description="The object of the domain.")
codom: str = Field(..., title="codomain", description="The object of the codomain.")
title: Optional[str] = Field(
default=None, description="The human-readable label for the morphism"
)
description: Optional[str] = Field(
default=None, description="A long-form description of the morphism"
)

@validator("dom", pre=True)
def dom_string(cls, ob: Union[str, Ob]):
Expand Down Expand Up @@ -110,9 +118,10 @@ class AttrType(HashableBaseModel):
transition, for instance, has a tuple of strings as its name.
"""

name: str = Field(description="The name of the attribute type.")
name: str = Field(..., description="The name of the attribute type.")
ty: type = Field(
description="The type assigned to the attribute type. Use a string referring to the Python type"
...,
description="The type assigned to the attribute type. Use a string referring to the Python type",
)
title: Optional[str] = None
description: Optional[str] = None
Expand Down Expand Up @@ -140,9 +149,9 @@ class Attr(HashableBaseModel):
which is the attribute that stores the name of a species in a Petri net.
"""

name: str = Field(title="name", description="The name of the attribute.")
dom: str = Field(title="domain", description="The object in the domain.")
codom: str = Field(title="codomain", description="The attribute type in the codomain")
name: str = Field(..., title="name", description="The name of the attribute.")
dom: str = Field(..., title="domain", description="The object in the domain.")
codom: str = Field(..., title="codomain", description="The attribute type in the codomain")
title: Optional[str] = None
description: Optional[str] = None

Expand Down Expand Up @@ -279,7 +288,11 @@ def valtype(self, prop: Property):
Returns:
The Property value type
"""
return int if isinstance(prop, Hom) else next(at for at in self.schema.AttrType if at.name == prop.codom).ty
return (
int
if isinstance(prop, Hom)
else next(at for at in self.schema.AttrType if at.name == prop.codom).ty
)

def valid_value(self, prop: Property, val):
"""Verify if a given value is valid for a given property
Expand Down
3 changes: 2 additions & 1 deletion lib/acsets/schemas/catlab_to_jsonschema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""This script turns all the catlab schemata into json schemata"""

from pathlib import Path

from acsets import (
CATLAB_SCHEMAS_DIRECTORY,
ACSet,
Expand All @@ -9,8 +10,8 @@
CatlabSchema,
Hom,
Ob,
petris,
Schema,
petris,
)

HERE = Path(__file__).parent.resolve()
Expand Down
Binary file modified objects.inv
Binary file not shown.
Loading

0 comments on commit 6e6a784

Please sign in to comment.