You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorials/getting-started.ipynb
+16-12Lines changed: 16 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -83,7 +83,6 @@
83
83
"metadata": {},
84
84
"outputs": [],
85
85
"source": [
86
-
"@egraph.class_\n",
87
86
"class Dim(Expr):\n",
88
87
"\"\"\"\n",
89
88
" A dimension of a matix.\n",
@@ -108,16 +107,17 @@
108
107
"tags": []
109
108
},
110
109
"source": [
111
-
"As you can see, you must wrap any class with the `egraph.class_` to register\n",
112
-
"it with the egraph and be able to use it like a Python class.\n",
110
+
"As you can see, you can define a class that inherits from `Expr` to create\n",
111
+
"a new type in the e-graph. The class will be automatically registered when you use it.\n",
113
112
"\n",
114
113
"### Testing in a notebook\n",
115
114
"\n",
116
115
"We can try out this by [creating a new notebook](https://code.visualstudio.com/docs/datascience/jupyter-notebooks#_create-or-open-a-jupyter-notebook) which imports this file:\n",
117
116
"\n",
118
117
"```python\n",
119
118
"from matrix import *\n",
120
-
"```\n"
119
+
"```\n",
120
+
""
121
121
]
122
122
},
123
123
{
@@ -408,7 +408,8 @@
408
408
}
409
409
],
410
410
"source": [
411
-
"egraph.simplify(res, 10)"
411
+
"egraph.run(10)\n",
412
+
"egraph.extract(res)\n"
412
413
]
413
414
},
414
415
{
@@ -429,7 +430,6 @@
429
430
"metadata": {},
430
431
"outputs": [],
431
432
"source": [
432
-
"@egraph.class_\n",
433
433
"class Matrix(Expr):\n",
434
434
" @classmethod\n",
435
435
" def identity(cls, dim: Dim) -> Matrix:\n",
@@ -459,7 +459,7 @@
459
459
"\"\"\"\n",
460
460
"\n",
461
461
"\n",
462
-
"@egraph.function\n",
462
+
"@function\n",
463
463
"def kron(a: Matrix, b: Matrix) -> Matrix:\n",
464
464
"\"\"\"\n",
465
465
" Kronecker product of two matrices.\n",
@@ -530,8 +530,10 @@
530
530
"x = Matrix.identity(Dim.named(\"x\"))\n",
531
531
"y = Matrix.identity(Dim.named(\"y\"))\n",
532
532
"x_mult_y = x @ y\n",
533
-
"print(egraph.simplify(x_mult_y.ncols(), 10))\n",
534
-
"print(egraph.simplify(x_mult_y.nrows(), 10))"
533
+
"egraph.run(10)\n",
534
+
"print(egraph.extract(x_mult_y.ncols()))\n",
535
+
"egraph.run(10)\n",
536
+
"print(egraph.extract(x_mult_y.nrows()))"
535
537
]
536
538
},
537
539
{
@@ -1096,7 +1098,8 @@
1096
1098
")\n",
1097
1099
"# Create an example which should equal the kronecker product of A and B\n",
1098
1100
"ex1 = kron(Matrix.identity(n), B) @ kron(A, Matrix.identity(m))\n",
1099
-
"egraph.simplify(ex1, 20)"
1101
+
"egraph.run(20)\n",
1102
+
"egraph.extract(ex1)\n"
1100
1103
]
1101
1104
},
1102
1105
{
@@ -1209,7 +1212,8 @@
1209
1212
],
1210
1213
"source": [
1211
1214
"ex2 = kron(Matrix.identity(p), C) @ kron(A, Matrix.identity(m))\n",
0 commit comments