Skip to content

Commit e6913eb

Browse files
committed
step_func2
1 parent b4b9717 commit e6913eb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

step_function.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import numpy as np
2+
import matplotlib.pyplot as plt
23

34
def step_function(x):
4-
y = x > 0
5-
print(y)
6-
return y.astype(np.int)
5+
return np.array(x > 0, dtype=np.int)
76

8-
res = step_function(np.array([0,1,3]))
9-
print(res)
7+
x = np.arange(-5.0, 5.0, 0.1)
8+
y = step_function(x)
9+
plt.plot(x, y)
10+
plt.ylim(-0.1, 1.1)
11+
plt.show()

0 commit comments

Comments
 (0)