From 579b18506887057f738f7cc565447b25ea088cb3 Mon Sep 17 00:00:00 2001 From: Shaikh Ubaid Date: Mon, 24 Apr 2023 05:49:31 +0530 Subject: [PATCH] TEST: Add test case --- integration_tests/test_pip_import_01.py | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 integration_tests/test_pip_import_01.py diff --git a/integration_tests/test_pip_import_01.py b/integration_tests/test_pip_import_01.py new file mode 100644 index 0000000000..7ce361707d --- /dev/null +++ b/integration_tests/test_pip_import_01.py @@ -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()