Skip to content

Commit 5d58448

Browse files
committed
remove types in datasets
1 parent 252ad94 commit 5d58448

File tree

5 files changed

+23
-31
lines changed

5 files changed

+23
-31
lines changed

minitorch/datasets.py

+18-28
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import List, Tuple
55

66

7-
def make_pts(N: int) -> List[Tuple[float, float]]:
7+
def make_pts(N):
88
X = []
99
for i in range(N):
1010
x_1 = random.random()
@@ -20,7 +20,7 @@ class Graph:
2020
y: List[int]
2121

2222

23-
def simple(N: int) -> Graph:
23+
def simple(N):
2424
X = make_pts(N)
2525
y = []
2626
for x_1, x_2 in X:
@@ -29,7 +29,7 @@ def simple(N: int) -> Graph:
2929
return Graph(N, X, y)
3030

3131

32-
def diag(N: int) -> Graph:
32+
def diag(N):
3333
X = make_pts(N)
3434
y = []
3535
for x_1, x_2 in X:
@@ -38,7 +38,7 @@ def diag(N: int) -> Graph:
3838
return Graph(N, X, y)
3939

4040

41-
def split(N: int) -> Graph:
41+
def split(N):
4242
X = make_pts(N)
4343
y = []
4444
for x_1, x_2 in X:
@@ -47,49 +47,39 @@ def split(N: int) -> Graph:
4747
return Graph(N, X, y)
4848

4949

50-
def xor(N: int) -> Graph:
50+
def xor(N):
5151
X = make_pts(N)
5252
y = []
5353
for x_1, x_2 in X:
54-
y1 = 1 if ((x_1 < 0.5 and x_2 > 0.5) or (x_1 > 0.5 and x_2 < 0.5)) else 0
54+
y1 = 1 if x_1 < 0.5 and x_2 > 0.5 or x_1 > 0.5 and x_2 < 0.5 else 0
5555
y.append(y1)
5656
return Graph(N, X, y)
5757

5858

59-
def circle(N: int) -> Graph:
59+
def circle(N):
6060
X = make_pts(N)
6161
y = []
6262
for x_1, x_2 in X:
63-
x1, x2 = (x_1 - 0.5, x_2 - 0.5)
63+
x1, x2 = x_1 - 0.5, x_2 - 0.5
6464
y1 = 1 if x1 * x1 + x2 * x2 > 0.1 else 0
6565
y.append(y1)
6666
return Graph(N, X, y)
6767

6868

69-
def spiral(N: int) -> Graph:
70-
def x(t: float) -> float:
69+
def spiral(N):
70+
71+
def x(t):
7172
return t * math.cos(t) / 20.0
7273

73-
def y(t: float) -> float:
74+
def y(t):
7475
return t * math.sin(t) / 20.0
75-
76-
X = [
77-
(x(10.0 * (float(i) / (N // 2))) + 0.5, y(10.0 * (float(i) / (N // 2))) + 0.5)
78-
for i in range(5 + 0, 5 + N // 2)
79-
]
80-
X = X + [
81-
(y(-10.0 * (float(i) / (N // 2))) + 0.5, x(-10.0 * (float(i) / (N // 2))) + 0.5)
82-
for i in range(5 + 0, 5 + N // 2)
83-
]
76+
X = [(x(10.0 * (float(i) / (N // 2))) + 0.5, y(10.0 * (float(i) / (N //
77+
2))) + 0.5) for i in range(5 + 0, 5 + N // 2)]
78+
X = X + [(y(-10.0 * (float(i) / (N // 2))) + 0.5, x(-10.0 * (float(i) /
79+
(N // 2))) + 0.5) for i in range(5 + 0, 5 + N // 2)]
8480
y2 = [0] * (N // 2) + [1] * (N // 2)
8581
return Graph(N, X, y2)
8682

8783

88-
datasets = {
89-
"Simple": simple,
90-
"Diag": diag,
91-
"Split": split,
92-
"Xor": xor,
93-
"Circle": circle,
94-
"Spiral": spiral,
95-
}
84+
datasets = {'Simple': simple, 'Diag': diag, 'Split': split, 'Xor': xor,
85+
'Circle': circle, 'Spiral': spiral}

project/app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
st.sidebar.markdown(
2020
"""
2121
<h1 style="font-size:30pt; float: left; margin-right: 20px; margin-top: 1px;">MiniTorch</h1>{}
22-
""".format(get_img_tag("https://minitorch.github.io/_images/match.png", width="40")),
22+
""".format(get_img_tag("https://minitorch.github.io/logo-sm.png", width="40")),
2323
unsafe_allow_html=True,
2424
)
2525

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ ignore = [
8989
"D401",
9090
"D105",
9191
"D415",
92+
"D402",
9293
"D205",
9394
"D100",
9495
"D101",

requirements.extra.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
datasets==2.4.0
22
embeddings==0.0.8
3-
networkx==2.4
43
plotly==4.14.3
54
pydot==1.4.1
65
python-mnist
76
streamlit==1.12.0
87
streamlit-ace
98
torch
109
watchdog==1.0.2
10+
altair==4.2.2
11+
networkx==3.3

tests/strategies.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515

1616
def assert_close(a: float, b: float) -> None:
17-
assert minitorch.is_close(a, b), "Failure x=%f y=%f" % (a, b)
17+
assert minitorch.operators.is_close(a, b), "Failure x=%f y=%f" % (a, b)

0 commit comments

Comments
 (0)