Skip to content

Commit

Permalink
Create SummationDecapode.json (#33)
Browse files Browse the repository at this point in the history
* Create SummationDecapode.json

* Update SummationDecapode.json

fill in title and description fields

* use ty key in SummationDecapode.json

* Export to jsonschema

* Update setup.cfg

* Update conf.py

* Update conf.py

* Update

---------

Co-authored-by: Charles Tapley Hoyt <[email protected]>
  • Loading branch information
jpfairbanks and cthoyt authored Sep 27, 2023
1 parent 8f35a6a commit 8571a09
Show file tree
Hide file tree
Showing 5 changed files with 344 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"https://docs.python.org/3/": None,
"python": ("https://docs.python.org/3/", None),
}

autoclass_content = "both"
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ keywords =

[options]
install_requires =
pydantic
# TODO your requirements go here
pydantic<2.0

# Random options
zip_safe = false
Expand Down
154 changes: 154 additions & 0 deletions src/acsets/schemas/catlab/SummationDecapode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"version": {
"ACSets": "0.0.0",
"Catlab": "0.0.0",
"ACSetSchema": "0.0.1"
},
"Ob": [
{
"name": "Var",
"description": null,
"title": "Variable"
},
{
"name": "TVar",
"description": null,
"title": "Tangent Variable"
},
{
"name": "Op1",
"description": null,
"title": "Unary Operation"
},
{
"name": "Op2",
"description": null,
"title": "Bianry Operation"
},
{
"name": "Σ",
"description": null,
"title": "Summation"
},
{
"name": "Summand",
"description": null,
"title": "Summand"
}
],
"Hom": [
{
"name": "src",
"codom": "Var",
"dom": "Op1",
"description": null,
"title": "Source"
},
{
"name": "tgt",
"codom": "Var",
"dom": "Op1",
"description": null,
"title": "Target"
},
{
"name": "proj1",
"codom": "Var",
"dom": "Op2",
"description": null,
"title": "First Argument"
},
{
"name": "proj2",
"codom": "Var",
"dom": "Op2",
"description": null,
"title": "Second Argument"
},
{
"name": "res",
"codom": "Var",
"dom": "Op2",
"description": null,
"title": "Result"
},
{
"name": "incl",
"codom": "Var",
"dom": "TVar",
"description": null,
"title": "Inclusion of Tangent Variables"
},
{
"name": "summand",
"codom": "Var",
"dom": "Summand",
"description": null,
"title": "summand"
},
{
"name": "summation",
"codom": "Σ",
"dom": "Summand",
"description": null,
"title": "summation"
},
{
"name": "sum",
"codom": "Var",
"dom": "Σ",
"description": null,
"title": "result of summation"
}
],
"AttrType": [
{
"name": "Type",
"description": "The DEC type of a variable, not a python type",
"title": "Variable Type",
"ty": "str"
},
{
"name": "Operator",
"description": "The DEC operator name",
"title": "Operator",
"ty": "str"
},
{
"name": "Name",
"description": null,
"title": "Name",
"ty": "str"
}
],
"Attr": [
{
"name": "op1",
"codom": "Operator",
"dom": "Op1",
"description": null,
"title": "Operation"
},
{
"name": "op2",
"codom": "Operator",
"dom": "Op2",
"description": null,
"title": "Binary Operation"
},
{
"name": "type",
"codom": "Type",
"dom": "Var",
"description": null,
"title": "Variable Type"
},
{
"name": "name",
"codom": "Name",
"dom": "Var",
"description": null,
"title": "Variable Name"
}
]
}
40 changes: 40 additions & 0 deletions src/acsets/schemas/catlab_to_jsonschema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""This script turns all the catlab schemata into json schemata"""

from pathlib import Path
from acsets import (
CATLAB_SCHEMAS_DIRECTORY,
ACSet,
Attr,
AttrType,
CatlabSchema,
Hom,
Ob,
petris,
Schema,
)

HERE = Path(__file__).parent.resolve()
CATLAB = HERE.joinpath("catlab")
JSONSCHEMA = HERE.joinpath("jsonschema")


def main():
"""Convert any Catlab schemas into JSON schemas"""
for catlab_path in CATLAB.glob("*.json"):
jsonschema_path = JSONSCHEMA.joinpath(catlab_path.name)
if jsonschema_path.is_file():
continue
print(f"Parsing Catlab Schema from {catlab_path}")
catlab_schema = CatlabSchema.parse_file(catlab_path)
print("Getting Schema from Catlab schema")
schema = Schema.from_catlab(catlab_path.name, catlab_schema)
schema.write_schema(
jsonschema_path,
uri="https://raw.githubusercontent.com/AlgebraicJulia/py-acsets/main/src/acsets/{}".format(
Path(jsonschema_path).relative_to(HERE)
),
)


if __name__ == "__main__":
main()
148 changes: 148 additions & 0 deletions src/acsets/schemas/jsonschema/SummationDecapode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"$id": "https://raw.githubusercontent.com/AlgebraicJulia/py-acsets/main/src/acsets/jsonschema/SummationDecapode.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"Op1": {
"properties": {
"op1": {
"title": "Op1",
"type": "string"
},
"src": {
"title": "Src",
"type": "integer"
},
"tgt": {
"title": "Tgt",
"type": "integer"
}
},
"title": "Op1",
"type": "object"
},
"Op2": {
"properties": {
"op2": {
"title": "Op2",
"type": "string"
},
"proj1": {
"title": "Proj1",
"type": "integer"
},
"proj2": {
"title": "Proj2",
"type": "integer"
},
"res": {
"title": "Res",
"type": "integer"
}
},
"title": "Op2",
"type": "object"
},
"Summand": {
"properties": {
"summand": {
"title": "Summand",
"type": "integer"
},
"summation": {
"title": "Summation",
"type": "integer"
}
},
"title": "Summand",
"type": "object"
},
"TVar": {
"properties": {
"incl": {
"title": "Incl",
"type": "integer"
}
},
"title": "TVar",
"type": "object"
},
"Var": {
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"type": {
"title": "Type",
"type": "string"
}
},
"title": "Var",
"type": "object"
},
"_": {
"properties": {
"sum": {
"title": "Sum",
"type": "integer"
}
},
"title": "Σ",
"type": "object"
}
},
"properties": {
"Op1": {
"items": {
"$ref": "#/definitions/Op1"
},
"title": "Op1",
"type": "array"
},
"Op2": {
"items": {
"$ref": "#/definitions/Op2"
},
"title": "Op2",
"type": "array"
},
"Summand": {
"items": {
"$ref": "#/definitions/Summand"
},
"title": "Summand",
"type": "array"
},
"TVar": {
"items": {
"$ref": "#/definitions/TVar"
},
"title": "Tvar",
"type": "array"
},
"Var": {
"items": {
"$ref": "#/definitions/Var"
},
"title": "Var",
"type": "array"
},
"Σ": {
"items": {
"$ref": "#/definitions/_"
},
"title": "Σ",
"type": "array"
}
},
"required": [
"Var",
"TVar",
"Op1",
"Op2",
"Σ",
"Summand"
],
"title": "SummationDecapode.json",
"type": "object"
}

0 comments on commit 8571a09

Please sign in to comment.