Skip to content

Commit

Permalink
TEST: Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaikh-Ubaid committed Apr 24, 2023
1 parent 0972054 commit 579b185
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions integration_tests/test_pip_import_01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from lpynn.perceptron import init_perceptron, print_perceptron, normalize_input_vectors, Perceptron, train_dataset
from lptypes import i32, f64

def main0():
p: Perceptron = Perceptron(0, [0.0], 0.0, 0, 0.0, 0.0, 0)
init_perceptron(p, 2, 0.05, 10000, 90.0)
print_perceptron(p)
print("=================================")

input_vectors: list[list[f64]] = [[-1.0, -1.0], [-1.0, 1.0], [1.0, -1.0], [1.0, 1.0]]
outputs: list[i32] = [1, 1, 1, -1]

normalize_input_vectors(input_vectors)
train_dataset(p, input_vectors, outputs)
print_perceptron(p)
print("=================================")

assert p.cur_accuracy > 50.0
assert p.epochs_cnt > 1

def main1():
p: Perceptron = Perceptron(0, [0.0], 0.0, 0, 0.0, 0.0, 0)
init_perceptron(p, 2, 0.05, 10000, 90.0)
print_perceptron(p)
print("=================================")

input_vectors: list[list[f64]] = [[-1.0, -1.0], [-1.0, 1.0], [1.0, -1.0], [1.0, 1.0], [1.5, 1.0]]
outputs: list[i32] = [1, 1, -1, 1, -1]

normalize_input_vectors(input_vectors)
train_dataset(p, input_vectors, outputs)
print_perceptron(p)
print("=================================")

assert p.cur_accuracy > 50.0
assert p.epochs_cnt > 1

main0()
main1()

0 comments on commit 579b185

Please sign in to comment.