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