Skip to content

Commit a507c7f

Browse files
committed
TEST: Add assert and finalize test_pkg_lnn.py
1 parent 779ff70 commit a507c7f

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .perceptron_main import init_perceptron, train_dataset, test_perceptron, normalize_input_vectors, print_perceptron
1+
from .perceptron_main import init_perceptron, train_dataset, test_perceptron, normalize_input_vectors, print_perceptron, Perceptron

integration_tests/test_pkg_lnn.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
from lnn.perceptron import init_perceptron, print_perceptron, normalize_input_vectors
2-
1+
from lnn.perceptron import init_perceptron, print_perceptron, normalize_input_vectors, Perceptron, train_dataset
32
from lpython import i32, f64
43

5-
6-
74
def main0():
8-
print("hi")
9-
# p: Perceptron
10-
# init_perceptron(p, 5, 0.05, 100000, 90.0)
11-
# print_perceptron(p)
12-
input_vectors: list[list[f64]] = [[-15.0, -10.0], [-10.0, 10.0], [15.0, -10.0], [10.0, 10.0]]
5+
p: Perceptron
6+
init_perceptron(p, 2, 0.05, 10000, 90.0)
7+
print_perceptron(p)
8+
print("=================================")
9+
10+
input_vectors: list[list[f64]] = [[-1.0, -1.0], [-1.0, 1.0], [1.0, -1.0], [1.0, 1.0]]
1311
outputs: list[i32] = [1, 1, 1, -1]
1412

1513
normalize_input_vectors(input_vectors)
16-
print(input_vectors)
14+
train_dataset(p, input_vectors, outputs)
15+
print_perceptron(p)
16+
17+
assert p.cur_accuracy > 50.0
18+
assert p.epochs_cnt > 1
19+
1720
main0()

0 commit comments

Comments
 (0)