From 15d86a36d8c274e484db746638909bbdee89646d Mon Sep 17 00:00:00 2001 From: Divya Thanasekaran Date: Mon, 13 Feb 2023 14:22:28 -0800 Subject: [PATCH] test commit, function for sign --- project_name/feature_sign.py | 2 ++ project_name/tests/test_sign.py | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 project_name/feature_sign.py create mode 100644 project_name/tests/test_sign.py diff --git a/project_name/feature_sign.py b/project_name/feature_sign.py new file mode 100644 index 0000000..06d4fdd --- /dev/null +++ b/project_name/feature_sign.py @@ -0,0 +1,2 @@ +def sign_func(value: float) -> float: + return -1 if value < 0 else 1 diff --git a/project_name/tests/test_sign.py b/project_name/tests/test_sign.py new file mode 100644 index 0000000..6fc37e4 --- /dev/null +++ b/project_name/tests/test_sign.py @@ -0,0 +1,23 @@ +import pytest +import numpy as np + +from ..feature_sign import sign_func + + +def test_simple_sign_func(): + assert sign_func(-100000.346) == -1 + + +@pytest.mark.parametrize( + "value, expected", + [ + (0, 1), + (10000.0, 1), + (-345236.78, -1) + ] +) + +def test_sign_func(value: float, expected: float): + sign_val = sign_func(value) + expected = np.sign(value) + assert expected==sign_val