expit 1.0.14__py3-none-any.whl → 1.0.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- expit/core/__init__.py +1 -0
- expit/tests/__init__.py +6 -1
- expit/tests/test_TestFunction.py +48 -0
- expit/tests/{test_easy.py → test_TestMainCommand.py} +14 -43
- {expit-1.0.14.dist-info → expit-1.0.16.dist-info}/METADATA +1 -1
- expit-1.0.16.dist-info/RECORD +11 -0
- {expit-1.0.14.dist-info → expit-1.0.16.dist-info}/WHEEL +1 -1
- expit-1.0.14.dist-info/RECORD +0 -10
- {expit-1.0.14.dist-info → expit-1.0.16.dist-info}/licenses/LICENSE.txt +0 -0
- {expit-1.0.14.dist-info → expit-1.0.16.dist-info}/top_level.txt +0 -0
expit/core/__init__.py
CHANGED
expit/tests/__init__.py
CHANGED
|
@@ -3,7 +3,12 @@ import unittest
|
|
|
3
3
|
__all__ = ["test"]
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
def test():
|
|
6
|
+
def test() -> unittest.TextTestResult:
|
|
7
|
+
loader: unittest.TestLoader
|
|
8
|
+
tests: unittest.TestSuite
|
|
9
|
+
runner: unittest.TextTestRunner
|
|
10
|
+
result: unittest.TextTestResult
|
|
11
|
+
|
|
7
12
|
loader = unittest.TestLoader()
|
|
8
13
|
tests = loader.discover(start_dir="expit.tests")
|
|
9
14
|
runner = unittest.TextTestRunner()
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import math
|
|
2
|
+
import sys
|
|
3
|
+
import unittest
|
|
4
|
+
from typing import *
|
|
5
|
+
|
|
6
|
+
from expit.core import function
|
|
7
|
+
|
|
8
|
+
__all__ = ["TestFunction"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TestFunction(unittest.TestCase):
|
|
12
|
+
def test_function_regular_values(self: Self) -> None:
|
|
13
|
+
# Test regular values of x
|
|
14
|
+
self.assertAlmostEqual(function(0), 0.5)
|
|
15
|
+
self.assertAlmostEqual(function(1), 1 / (1 + math.exp(-1)), places=5)
|
|
16
|
+
self.assertAlmostEqual(function(-1), 1 / (1 + math.exp(1)), places=5)
|
|
17
|
+
|
|
18
|
+
def test_function_large_positive(self: Self) -> None:
|
|
19
|
+
# Test large positive values of x (result should approach 1)
|
|
20
|
+
self.assertAlmostEqual(function(100), 1.0, places=5)
|
|
21
|
+
self.assertAlmostEqual(function(1000), 1.0, places=5)
|
|
22
|
+
|
|
23
|
+
def test_function_large_negative(self: Self) -> None:
|
|
24
|
+
# Test large negative values of x (result should approach 0)
|
|
25
|
+
self.assertAlmostEqual(function(-100), 0.0, places=5)
|
|
26
|
+
self.assertAlmostEqual(function(-1000), 0.0, places=5)
|
|
27
|
+
|
|
28
|
+
def test_function_overflow(self: Self) -> None:
|
|
29
|
+
# Test overflow values to ensure they are handled without errors
|
|
30
|
+
self.assertAlmostEqual(function(sys.float_info.max), 1.0, places=5)
|
|
31
|
+
self.assertAlmostEqual(function(-sys.float_info.max), 0.0, places=5)
|
|
32
|
+
|
|
33
|
+
def test_function_infinity(self: Self) -> None:
|
|
34
|
+
# Test positive and negative infinity inputs
|
|
35
|
+
self.assertEqual(function(float("inf")), 1.0)
|
|
36
|
+
self.assertEqual(function(float("-inf")), 0.0)
|
|
37
|
+
|
|
38
|
+
def test_function_nan(self: Self) -> None:
|
|
39
|
+
# Test NaN input; behavior may vary, but we can ensure it doesn't throw an error
|
|
40
|
+
result: Any
|
|
41
|
+
result = function(float("nan"))
|
|
42
|
+
self.assertTrue(
|
|
43
|
+
math.isnan(result) or result in [0.0, 1.0]
|
|
44
|
+
) # Depending on interpretation, could be NaN, 0, or 1
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if __name__ == "__main__":
|
|
48
|
+
unittest.main()
|
|
@@ -1,56 +1,22 @@
|
|
|
1
|
-
import math
|
|
2
1
|
import sys
|
|
3
2
|
import unittest
|
|
4
|
-
from
|
|
3
|
+
from typing import *
|
|
5
4
|
|
|
6
5
|
from click.testing import CliRunner
|
|
7
6
|
|
|
8
|
-
# Import the script's components
|
|
9
7
|
from expit.core import function, main
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
class TestFunction(unittest.TestCase):
|
|
13
|
-
def test_function_regular_values(self):
|
|
14
|
-
# Test regular values of x
|
|
15
|
-
self.assertAlmostEqual(function(0), 0.5)
|
|
16
|
-
self.assertAlmostEqual(function(1), 1 / (1 + math.exp(-1)), places=5)
|
|
17
|
-
self.assertAlmostEqual(function(-1), 1 / (1 + math.exp(1)), places=5)
|
|
18
|
-
|
|
19
|
-
def test_function_large_positive(self):
|
|
20
|
-
# Test large positive values of x (result should approach 1)
|
|
21
|
-
self.assertAlmostEqual(function(100), 1.0, places=5)
|
|
22
|
-
self.assertAlmostEqual(function(1000), 1.0, places=5)
|
|
23
|
-
|
|
24
|
-
def test_function_large_negative(self):
|
|
25
|
-
# Test large negative values of x (result should approach 0)
|
|
26
|
-
self.assertAlmostEqual(function(-100), 0.0, places=5)
|
|
27
|
-
self.assertAlmostEqual(function(-1000), 0.0, places=5)
|
|
28
|
-
|
|
29
|
-
def test_function_overflow(self):
|
|
30
|
-
# Test overflow values to ensure they are handled without errors
|
|
31
|
-
self.assertAlmostEqual(function(sys.float_info.max), 1.0, places=5)
|
|
32
|
-
self.assertAlmostEqual(function(-sys.float_info.max), 0.0, places=5)
|
|
33
|
-
|
|
34
|
-
def test_function_infinity(self):
|
|
35
|
-
# Test positive and negative infinity inputs
|
|
36
|
-
self.assertEqual(function(float("inf")), 1.0)
|
|
37
|
-
self.assertEqual(function(float("-inf")), 0.0)
|
|
38
|
-
|
|
39
|
-
def test_function_nan(self):
|
|
40
|
-
# Test NaN input; behavior may vary, but we can ensure it doesn't throw an error
|
|
41
|
-
result = function(float("nan"))
|
|
42
|
-
self.assertTrue(
|
|
43
|
-
math.isnan(result) or result in [0.0, 1.0]
|
|
44
|
-
) # Depending on interpretation, could be NaN, 0, or 1
|
|
9
|
+
__all__ = ["TestMainCommand"]
|
|
45
10
|
|
|
46
11
|
|
|
47
12
|
class TestMainCommand(unittest.TestCase):
|
|
48
|
-
def setUp(self):
|
|
13
|
+
def setUp(self: Self) -> None:
|
|
49
14
|
# Set up CliRunner for Click command-line testing
|
|
50
15
|
self.runner = CliRunner()
|
|
51
16
|
|
|
52
|
-
def test_main_help_option(self):
|
|
17
|
+
def test_main_help_option(self: Self) -> None:
|
|
53
18
|
# Test help option (-h, --help) to ensure it displays usage information
|
|
19
|
+
result: Any
|
|
54
20
|
result = self.runner.invoke(main, ["--help"])
|
|
55
21
|
self.assertEqual(result.exit_code, 0)
|
|
56
22
|
self.assertIn("Usage", result.output)
|
|
@@ -61,8 +27,9 @@ class TestMainCommand(unittest.TestCase):
|
|
|
61
27
|
self.assertIn("Usage", result.output)
|
|
62
28
|
self.assertIn("applies the expit function to x", result.output)
|
|
63
29
|
|
|
64
|
-
def test_main_version_option(self):
|
|
30
|
+
def test_main_version_option(self: Self) -> None:
|
|
65
31
|
# Test version option (-V, --version) to check version output
|
|
32
|
+
result: Any
|
|
66
33
|
result = self.runner.invoke(main, ["--version"])
|
|
67
34
|
self.assertEqual(result.exit_code, 0)
|
|
68
35
|
self.assertIn("version", result.output.lower())
|
|
@@ -71,8 +38,10 @@ class TestMainCommand(unittest.TestCase):
|
|
|
71
38
|
self.assertEqual(result.exit_code, 0)
|
|
72
39
|
self.assertIn("version", result.output.lower())
|
|
73
40
|
|
|
74
|
-
def test_main_valid_input(self):
|
|
41
|
+
def test_main_valid_input(self: Self) -> None:
|
|
75
42
|
# Test main function with a valid float input, checking output
|
|
43
|
+
expected_output: str
|
|
44
|
+
result: Any
|
|
76
45
|
result = self.runner.invoke(main, ["1"])
|
|
77
46
|
expected_output = f"{function(1)}\n"
|
|
78
47
|
self.assertEqual(result.exit_code, 0)
|
|
@@ -83,8 +52,9 @@ class TestMainCommand(unittest.TestCase):
|
|
|
83
52
|
self.assertEqual(result.exit_code, 0)
|
|
84
53
|
self.assertEqual(result.output, expected_output)
|
|
85
54
|
|
|
86
|
-
def test_main_edge_case(self):
|
|
55
|
+
def test_main_edge_case(self: Self) -> None:
|
|
87
56
|
# Test main function with extreme float inputs
|
|
57
|
+
result: Any
|
|
88
58
|
result = self.runner.invoke(main, [str(sys.float_info.max)])
|
|
89
59
|
self.assertEqual(result.exit_code, 0)
|
|
90
60
|
self.assertEqual(result.output, f"{function(sys.float_info.max)}\n")
|
|
@@ -93,8 +63,9 @@ class TestMainCommand(unittest.TestCase):
|
|
|
93
63
|
self.assertEqual(result.exit_code, 0)
|
|
94
64
|
self.assertEqual(result.output, f"{function(-sys.float_info.max)}\n")
|
|
95
65
|
|
|
96
|
-
def test_main_invalid_input(self):
|
|
66
|
+
def test_main_invalid_input(self: Self) -> None:
|
|
97
67
|
# Test main function with invalid input, expecting an error
|
|
68
|
+
result: Any
|
|
98
69
|
result = self.runner.invoke(main, ["abc"])
|
|
99
70
|
self.assertNotEqual(result.exit_code, 0)
|
|
100
71
|
self.assertIn("Invalid value for 'X'", result.output)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
expit/__init__.py,sha256=_6zfbxGbD_Ca4EPx7eJ7h7SU1L6QXdBe9MkpSu5tzvU,90
|
|
2
|
+
expit/__main__.py,sha256=vtuVmp_tcHYg_kJhOYt6cRPinFrpMR4yV_6b8tx4n-Q,62
|
|
3
|
+
expit/core/__init__.py,sha256=zc2Awfi0MtQqte6twFtBja13SFthVHiSH2szxTVLrr8,596
|
|
4
|
+
expit/tests/__init__.py,sha256=AiXgKs2dcJ__sgxBaLsblxxZvoV_yfhA3TGthxK3Zn8,388
|
|
5
|
+
expit/tests/test_TestFunction.py,sha256=L04T2TVS6EOaUHHq_959DBIKaCXnUVYkAGPdBpsvLdw,1848
|
|
6
|
+
expit/tests/test_TestMainCommand.py,sha256=RsBRRcEa1tZSEUUHQlSRKFqqEXTt5PBz4m2kcl3Y-Qc,2814
|
|
7
|
+
expit-1.0.16.dist-info/licenses/LICENSE.txt,sha256=4_wW1qomV3dbE2RahXvz_BOPr_JNzdKxC90VCXXc74o,1086
|
|
8
|
+
expit-1.0.16.dist-info/METADATA,sha256=qIMNSUfVJJzuFyw-YBbVmaOmwCLmUs3494zm6VesGzw,2372
|
|
9
|
+
expit-1.0.16.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
10
|
+
expit-1.0.16.dist-info/top_level.txt,sha256=WDTulZQtgreaVuxzGQhRWdINPuLlCvMWl0gGgmVnsa0,6
|
|
11
|
+
expit-1.0.16.dist-info/RECORD,,
|
expit-1.0.14.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
expit/__init__.py,sha256=_6zfbxGbD_Ca4EPx7eJ7h7SU1L6QXdBe9MkpSu5tzvU,90
|
|
2
|
-
expit/__main__.py,sha256=vtuVmp_tcHYg_kJhOYt6cRPinFrpMR4yV_6b8tx4n-Q,62
|
|
3
|
-
expit/core/__init__.py,sha256=6F3b0e67BrPF_LUHDdu6FcnrIE1-y0H8wU5OQL82XNE,583
|
|
4
|
-
expit/tests/__init__.py,sha256=vTK8DNdf2ozNTfNEtgxXbhfdrjc8h5LgTdY9jmUHPd4,226
|
|
5
|
-
expit/tests/test_easy.py,sha256=9dmpNM9_Lfa5t4UFZlAGIWjI1dJAWcRYjHNmyw9H96k,4200
|
|
6
|
-
expit-1.0.14.dist-info/licenses/LICENSE.txt,sha256=4_wW1qomV3dbE2RahXvz_BOPr_JNzdKxC90VCXXc74o,1086
|
|
7
|
-
expit-1.0.14.dist-info/METADATA,sha256=TiE3iKbnY1EP0x6g8ddgxJPx3Z2ZzVb8UJRq6WER5kk,2372
|
|
8
|
-
expit-1.0.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
-
expit-1.0.14.dist-info/top_level.txt,sha256=WDTulZQtgreaVuxzGQhRWdINPuLlCvMWl0gGgmVnsa0,6
|
|
10
|
-
expit-1.0.14.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|