Skip to content

Commit

Permalink
commit correct notebook outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
TShapinsky committed Nov 5, 2023
1 parent 6977d87 commit 165a60a
Showing 1 changed file with 102 additions and 29 deletions.
131 changes: 102 additions & 29 deletions notebooks/Shape_Builder.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,7 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "ImportError",
"evalue": "cannot import name 'from_graph' from 'buildingmotif.shape_builder.shape' (/Users/tshapins/Documents/Projects/BuildingMOTIF/buildingmotif/shape_builder/shape.py)",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m/Users/tshapins/Documents/Projects/BuildingMOTIF/notebooks/Shape_Builder.ipynb Cell 1\u001b[0m line \u001b[0;36m1\n\u001b[0;32m----> <a href='vscode-notebook-cell:/Users/tshapins/Documents/Projects/BuildingMOTIF/notebooks/Shape_Builder.ipynb#W0sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mbuildingmotif\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mshape_builder\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mshape\u001b[39;00m \u001b[39mimport\u001b[39;00m Shape, NodeShape, PropertyShape, OR, AND, NOT, XONE, from_graph\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/tshapins/Documents/Projects/BuildingMOTIF/notebooks/Shape_Builder.ipynb#W0sZmlsZQ%3D%3D?line=1'>2</a>\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mbuildingmotif\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mnamespaces\u001b[39;00m \u001b[39mimport\u001b[39;00m BRICK, SH, bind_prefixes\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/tshapins/Documents/Projects/BuildingMOTIF/notebooks/Shape_Builder.ipynb#W0sZmlsZQ%3D%3D?line=2'>3</a>\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mrdflib\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mnamespace\u001b[39;00m \u001b[39mimport\u001b[39;00m Namespace\n",
"\u001b[0;31mImportError\u001b[0m: cannot import name 'from_graph' from 'buildingmotif.shape_builder.shape' (/Users/tshapins/Documents/Projects/BuildingMOTIF/buildingmotif/shape_builder/shape.py)"
]
}
],
"outputs": [],
"source": [
"from buildingmotif.shape_builder.shape import Shape, NodeShape, PropertyShape, OR, AND, NOT, XONE, shape_from_graph\n",
"from buildingmotif.namespaces import BRICK, SH, bind_prefixes\n",
Expand All @@ -33,14 +21,67 @@
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'Graph' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m/Users/tshapins/Documents/Projects/BuildingMOTIF/notebooks/Shape_Builder.ipynb Cell 2\u001b[0m line \u001b[0;36m1\n\u001b[0;32m----> <a href='vscode-notebook-cell:/Users/tshapins/Documents/Projects/BuildingMOTIF/notebooks/Shape_Builder.ipynb#W1sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m shapes \u001b[39m=\u001b[39m Graph()\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/tshapins/Documents/Projects/BuildingMOTIF/notebooks/Shape_Builder.ipynb#W1sZmlsZQ%3D%3D?line=1'>2</a>\u001b[0m zone_with_room \u001b[39m=\u001b[39m (NodeShape(SHAPES[\u001b[39m\"\u001b[39m\u001b[39mzone-with-room\u001b[39m\u001b[39m\"\u001b[39m])\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/tshapins/Documents/Projects/BuildingMOTIF/notebooks/Shape_Builder.ipynb#W1sZmlsZQ%3D%3D?line=2'>3</a>\u001b[0m \u001b[39m.\u001b[39mof_class(BRICK[\u001b[39m\"\u001b[39m\u001b[39mHVAC_Zone\u001b[39m\u001b[39m\"\u001b[39m])\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/tshapins/Documents/Projects/BuildingMOTIF/notebooks/Shape_Builder.ipynb#W1sZmlsZQ%3D%3D?line=3'>4</a>\u001b[0m \u001b[39m.\u001b[39mhas_property(PropertyShape()\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/tshapins/Documents/Projects/BuildingMOTIF/notebooks/Shape_Builder.ipynb#W1sZmlsZQ%3D%3D?line=15'>16</a>\u001b[0m )\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/tshapins/Documents/Projects/BuildingMOTIF/notebooks/Shape_Builder.ipynb#W1sZmlsZQ%3D%3D?line=16'>17</a>\u001b[0m ))\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/tshapins/Documents/Projects/BuildingMOTIF/notebooks/Shape_Builder.ipynb#W1sZmlsZQ%3D%3D?line=17'>18</a>\u001b[0m shapes \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m zone_with_room\n",
"\u001b[0;31mNameError\u001b[0m: name 'Graph' is not defined"
"name": "stdout",
"output_type": "stream",
"text": [
"@prefix ns1: <http://www.w3.org/ns/shacl#> .\n",
"@prefix ns2: <https://nrel.gov/BuildingMOTIF/constraints#> .\n",
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n",
"@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n",
"\n",
"<urn:shapes#occupancy-sensor> a ns1:NodeShape ;\n",
" ns1:or ( <urn:shapes#ocupancy-sensor-1> <urn:shapes#occupancy-sensor-2> ) .\n",
"\n",
"<urn:shapes#window-switch> a ns1:NodeShape ;\n",
" ns1:property [ a ns1:PropertyShape ;\n",
" ns1:minCount 0 ;\n",
" ns1:node <urn:shapes#zone-with-room> ;\n",
" ns1:path [ ns1:path-one-or-more <https://brickschema.org/schema/Brick#feeds> ] ] .\n",
"\n",
"<urn:shapes#occupancy-sensor-2> a ns1:PropertyShape ;\n",
" ns1:minCount 0 ;\n",
" ns1:node [ ns1:or ( <urn:shapes#zone-with-occ-sensor> <urn:shapes#room-with-occ-sensor> ) ] ;\n",
" ns1:path [ ns1:path-zero-or-one <https://brickschema.org/schema/Brick#hasPart> ],\n",
" [ ns1:path-one-or-more <https://brickschema.org/schema/Brick#feeds> ] .\n",
"\n",
"<urn:shapes#ocupancy-sensor-1> a ns1:PropertyShape ;\n",
" ns1:class <https://brickschema.org/schema/Brick#Occcupancy_Sensor> ;\n",
" ns1:minCount 0 ;\n",
" ns1:path <https://brickschema.org/schema/Brick#hasPoint> .\n",
"\n",
"<urn:shapes#room-with-occ-sensor> a ns1:NodeShape ;\n",
" ns1:class <https://brickschema.org/schema/Brick#Room> ;\n",
" ns1:property [ a ns1:PropertyShape ;\n",
" ns1:class <https://brickschema.org/schema/Brick#Occupancy_Sensor> ;\n",
" ns1:minCount 1 ;\n",
" ns1:path <https://brickschema.org/schema/Brick#hasPoint> ] ;\n",
" ns2:class <https://brickschema.org/schema/Brick#Room> .\n",
"\n",
"<urn:shapes#zone-with-occ-sensor> a ns1:NodeShape ;\n",
" ns1:class <https://brickschema.org/schema/Brick#HVAC_Zone> ;\n",
" ns1:property [ a ns1:PropertyShape ;\n",
" ns1:class <https://brickschema.org/schema/Brick#Occupancy_Sensor> ;\n",
" ns1:minCount 1 ;\n",
" ns1:path <https://brickschema.org/schema/Brick#hasPoint> ] ;\n",
" ns2:class <https://brickschema.org/schema/Brick#HVAC_Zone> .\n",
"\n",
"<urn:shapes#zone-with-room> a ns1:NodeShape ;\n",
" ns1:class <https://brickschema.org/schema/Brick#HVAC_Zone> ;\n",
" ns1:property [ a ns1:PropertyShape ;\n",
" ns1:minCount 1 ;\n",
" ns1:node [ a ns1:NodeShape ;\n",
" ns1:class <https://brickschema.org/schema/Brick#Room> ;\n",
" ns1:property [ a ns1:PropertyShape ;\n",
" ns1:minCount 1 ;\n",
" ns1:node [ a ns1:NodeShape ;\n",
" ns1:class <https://brickschema.org/schema/Brick#Open_Close_Status> ;\n",
" ns2:class <https://brickschema.org/schema/Brick#Open_Close_Status> ] ;\n",
" ns1:path <https://brickschema.org/schema/Brick#hasPoint> ] ;\n",
" ns2:class <https://brickschema.org/schema/Brick#Room> ] ;\n",
" ns1:path <https://brickschema.org/schema/Brick#hasPart> ] ;\n",
" ns2:class <https://brickschema.org/schema/Brick#HVAC_Zone> .\n",
"\n",
"\n"
]
}
],
Expand Down Expand Up @@ -132,14 +173,46 @@
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'from_graph' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m/Users/tshapins/Documents/Projects/BuildingMOTIF/notebooks/Shape_Builder.ipynb Cell 4\u001b[0m line \u001b[0;36m1\n\u001b[0;32m----> <a href='vscode-notebook-cell:/Users/tshapins/Documents/Projects/BuildingMOTIF/notebooks/Shape_Builder.ipynb#W5sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m \u001b[39mprint\u001b[39m(from_graph(shapes, SHAPES[\u001b[39m\"\u001b[39m\u001b[39moccupancy-sensor\u001b[39m\u001b[39m\"\u001b[39m])\u001b[39m.\u001b[39mserialize(\u001b[39mformat\u001b[39m\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mttl\u001b[39m\u001b[39m\"\u001b[39m))\n",
"\u001b[0;31mNameError\u001b[0m: name 'from_graph' is not defined"
"name": "stdout",
"output_type": "stream",
"text": [
"@prefix brick: <https://brickschema.org/schema/Brick#> .\n",
"@prefix constraint: <https://nrel.gov/BuildingMOTIF/constraints#> .\n",
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n",
"@prefix sh: <http://www.w3.org/ns/shacl#> .\n",
"@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n",
"\n",
"<urn:shapes#occupancy-sensor> a sh:NodeShape ;\n",
" sh:or ( <urn:shapes#ocupancy-sensor-1> <urn:shapes#occupancy-sensor-2> ) .\n",
"\n",
"<urn:shapes#occupancy-sensor-2> a sh:PropertyShape ;\n",
" sh:minCount 0 ;\n",
" sh:node [ sh:or ( <urn:shapes#zone-with-occ-sensor> <urn:shapes#room-with-occ-sensor> ) ] ;\n",
" sh:path [ sh:path-zero-or-one brick:hasPart ],\n",
" [ sh:path-one-or-more brick:feeds ] .\n",
"\n",
"<urn:shapes#ocupancy-sensor-1> a sh:PropertyShape ;\n",
" sh:class brick:Occcupancy_Sensor ;\n",
" sh:minCount 0 ;\n",
" sh:path brick:hasPoint .\n",
"\n",
"<urn:shapes#room-with-occ-sensor> a sh:NodeShape ;\n",
" sh:class brick:Room ;\n",
" sh:property [ a sh:PropertyShape ;\n",
" sh:class brick:Occupancy_Sensor ;\n",
" sh:minCount 1 ;\n",
" sh:path brick:hasPoint ] ;\n",
" constraint:class brick:Room .\n",
"\n",
"<urn:shapes#zone-with-occ-sensor> a sh:NodeShape ;\n",
" sh:class brick:HVAC_Zone ;\n",
" sh:property [ a sh:PropertyShape ;\n",
" sh:class brick:Occupancy_Sensor ;\n",
" sh:minCount 1 ;\n",
" sh:path brick:hasPoint ] ;\n",
" constraint:class brick:HVAC_Zone .\n",
"\n",
"\n"
]
}
],
Expand Down

0 comments on commit 165a60a

Please sign in to comment.