expit 1.0.6__tar.gz → 1.0.8__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: expit
3
- Version: 1.0.6
3
+ Version: 1.0.8
4
4
  Summary: The expit function.
5
5
  Author-email: Johannes <johannes-programming@mailfence.com>
6
6
  License: The MIT License (MIT)
@@ -24,9 +24,12 @@ License: The MIT License (MIT)
24
24
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
25
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
26
  SOFTWARE.
27
- Project-URL: Documentation, https://pypi.org/project/expit/
27
+ Project-URL: Documentation, https://pypi.org/project/expit
28
28
  Project-URL: Download, https://pypi.org/project/expit/#files
29
+ Project-URL: Index, https://pypi.org/project/expit/
29
30
  Project-URL: Source, https://github.com/johannes-programming/expit
31
+ Project-URL: Website, https://expit.johannes-programming.online
32
+ Classifier: Development Status :: 5 - Production/Stable
30
33
  Classifier: License :: OSI Approved :: MIT License
31
34
  Classifier: Programming Language :: Python
32
35
  Classifier: Programming Language :: Python :: 3
@@ -35,56 +38,10 @@ Requires-Python: >=3.11
35
38
  Description-Content-Type: text/x-rst
36
39
  License-File: LICENSE.txt
37
40
  Requires-Dist: click>=8.1.7
41
+ Requires-Dist: preparse>=0.0.2
38
42
 
39
43
  =====
40
44
  expit
41
45
  =====
42
46
 
43
- Overview
44
- --------
45
-
46
- The expit function.
47
-
48
- Installation
49
- ------------
50
-
51
- To install expit, you can use ``pip``. Open your terminal and run:
52
-
53
- .. code-block:: bash
54
-
55
- pip install expit
56
-
57
- Example
58
- -------
59
-
60
- To calculate the function value of 0.42 in the shell:
61
-
62
- .. code-block:: bash
63
-
64
- py -m expit 0.42
65
-
66
- Or inside of a python script:
67
-
68
- .. code-block:: python
69
-
70
- import expit
71
- print(expit.function(0.42))
72
-
73
- License
74
- -------
75
-
76
- This project is licensed under the MIT License.
77
-
78
- Links
79
- -----
80
-
81
- * `Documentation <https://pypi.org/project/expit/>`_
82
- * `Download <https://pypi.org/project/expit/#files>`_
83
- * `Source <https://github.com/johannes-programming/expit>`_
84
-
85
- Credits
86
- -------
87
- * Author: Johannes
88
- * Email: johannes-programming@mailfence.com
89
-
90
- Thank you for using ``expit``!
47
+ Visit the website `https://expit.johannes-programming.online <https://expit.johannes-programming.online>`_ for more information.
expit-1.0.8/README.rst ADDED
@@ -0,0 +1,5 @@
1
+ =====
2
+ expit
3
+ =====
4
+
5
+ Visit the website `https://expit.johannes-programming.online <https://expit.johannes-programming.online>`_ for more information.
@@ -9,6 +9,7 @@ authors = [
9
9
  { email = "johannes-programming@mailfence.com", name = "Johannes" },
10
10
  ]
11
11
  classifiers = [
12
+ "Development Status :: 5 - Production/Stable",
12
13
  "License :: OSI Approved :: MIT License",
13
14
  "Programming Language :: Python",
14
15
  "Programming Language :: Python :: 3",
@@ -16,18 +17,21 @@ classifiers = [
16
17
  ]
17
18
  dependencies = [
18
19
  "click>=8.1.7",
20
+ "preparse>=0.0.2",
19
21
  ]
20
22
  description = "The expit function."
21
23
  keywords = []
22
24
  name = "expit"
23
25
  readme = "README.rst"
24
26
  requires-python = ">=3.11"
25
- version = "1.0.6"
27
+ version = "1.0.8"
26
28
 
27
29
  [project.license]
28
30
  file = "LICENSE.txt"
29
31
 
30
32
  [project.urls]
31
- Documentation = "https://pypi.org/project/expit/"
33
+ Documentation = "https://pypi.org/project/expit"
32
34
  Download = "https://pypi.org/project/expit/#files"
35
+ Index = "https://pypi.org/project/expit/"
33
36
  Source = "https://github.com/johannes-programming/expit"
37
+ Website = "https://expit.johannes-programming.online"
@@ -0,0 +1,5 @@
1
+ from expit.core import *
2
+ from expit.tests import *
3
+
4
+ if __name__ == "__main__":
5
+ main()
@@ -0,0 +1,24 @@
1
+ import math
2
+
3
+ import click
4
+ import preparse
5
+
6
+ __all__ = ["function", "main"]
7
+
8
+
9
+ def function(x: float):
10
+ try:
11
+ p = math.exp(-x)
12
+ except OverflowError:
13
+ p = float("+inf")
14
+ return 1 / (1 + p)
15
+
16
+
17
+ @preparse.PreParser(posix=False).click()
18
+ @click.command(add_help_option=False)
19
+ @click.help_option("-h", "--help")
20
+ @click.version_option(None, "-V", "--version")
21
+ @click.argument("x", type=float)
22
+ def main(x: float):
23
+ """applies the expit function to x"""
24
+ click.echo(function(x))
@@ -0,0 +1,11 @@
1
+ import unittest
2
+
3
+ __all__ = ["test"]
4
+
5
+
6
+ def test():
7
+ loader = unittest.TestLoader()
8
+ tests = loader.discover(start_dir="expit.tests")
9
+ runner = unittest.TextTestRunner()
10
+ result = runner.run(tests)
11
+ return result
@@ -0,0 +1,104 @@
1
+ import math
2
+ import sys
3
+ import unittest
4
+ from unittest.mock import patch
5
+
6
+ from click.testing import CliRunner
7
+
8
+ # Import the script's components
9
+ from expit.core import function, main
10
+
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
45
+
46
+
47
+ class TestMainCommand(unittest.TestCase):
48
+ def setUp(self):
49
+ # Set up CliRunner for Click command-line testing
50
+ self.runner = CliRunner()
51
+
52
+ def test_main_help_option(self):
53
+ # Test help option (-h, --help) to ensure it displays usage information
54
+ result = self.runner.invoke(main, ["--help"])
55
+ self.assertEqual(result.exit_code, 0)
56
+ self.assertIn("Usage", result.output)
57
+ self.assertIn("applies the expit function to x", result.output)
58
+
59
+ result = self.runner.invoke(main, ["-h"])
60
+ self.assertEqual(result.exit_code, 0)
61
+ self.assertIn("Usage", result.output)
62
+ self.assertIn("applies the expit function to x", result.output)
63
+
64
+ def test_main_version_option(self):
65
+ # Test version option (-V, --version) to check version output
66
+ result = self.runner.invoke(main, ["--version"])
67
+ self.assertEqual(result.exit_code, 0)
68
+ self.assertIn("version", result.output.lower())
69
+
70
+ result = self.runner.invoke(main, ["-V"])
71
+ self.assertEqual(result.exit_code, 0)
72
+ self.assertIn("version", result.output.lower())
73
+
74
+ def test_main_valid_input(self):
75
+ # Test main function with a valid float input, checking output
76
+ result = self.runner.invoke(main, ["1"])
77
+ expected_output = f"{function(1)}\n"
78
+ self.assertEqual(result.exit_code, 0)
79
+ self.assertEqual(result.output, expected_output)
80
+
81
+ result = self.runner.invoke(main, ["--", "-1"])
82
+ expected_output = f"{function(-1)}\n"
83
+ self.assertEqual(result.exit_code, 0)
84
+ self.assertEqual(result.output, expected_output)
85
+
86
+ def test_main_edge_case(self):
87
+ # Test main function with extreme float inputs
88
+ result = self.runner.invoke(main, [str(sys.float_info.max)])
89
+ self.assertEqual(result.exit_code, 0)
90
+ self.assertEqual(result.output, f"{function(sys.float_info.max)}\n")
91
+
92
+ result = self.runner.invoke(main, ["--", str(-sys.float_info.max)])
93
+ self.assertEqual(result.exit_code, 0)
94
+ self.assertEqual(result.output, f"{function(-sys.float_info.max)}\n")
95
+
96
+ def test_main_invalid_input(self):
97
+ # Test main function with invalid input, expecting an error
98
+ result = self.runner.invoke(main, ["abc"])
99
+ self.assertNotEqual(result.exit_code, 0)
100
+ self.assertIn("Invalid value for 'X'", result.output)
101
+
102
+
103
+ if __name__ == "__main__":
104
+ unittest.main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: expit
3
- Version: 1.0.6
3
+ Version: 1.0.8
4
4
  Summary: The expit function.
5
5
  Author-email: Johannes <johannes-programming@mailfence.com>
6
6
  License: The MIT License (MIT)
@@ -24,9 +24,12 @@ License: The MIT License (MIT)
24
24
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
25
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
26
  SOFTWARE.
27
- Project-URL: Documentation, https://pypi.org/project/expit/
27
+ Project-URL: Documentation, https://pypi.org/project/expit
28
28
  Project-URL: Download, https://pypi.org/project/expit/#files
29
+ Project-URL: Index, https://pypi.org/project/expit/
29
30
  Project-URL: Source, https://github.com/johannes-programming/expit
31
+ Project-URL: Website, https://expit.johannes-programming.online
32
+ Classifier: Development Status :: 5 - Production/Stable
30
33
  Classifier: License :: OSI Approved :: MIT License
31
34
  Classifier: Programming Language :: Python
32
35
  Classifier: Programming Language :: Python :: 3
@@ -35,56 +38,10 @@ Requires-Python: >=3.11
35
38
  Description-Content-Type: text/x-rst
36
39
  License-File: LICENSE.txt
37
40
  Requires-Dist: click>=8.1.7
41
+ Requires-Dist: preparse>=0.0.2
38
42
 
39
43
  =====
40
44
  expit
41
45
  =====
42
46
 
43
- Overview
44
- --------
45
-
46
- The expit function.
47
-
48
- Installation
49
- ------------
50
-
51
- To install expit, you can use ``pip``. Open your terminal and run:
52
-
53
- .. code-block:: bash
54
-
55
- pip install expit
56
-
57
- Example
58
- -------
59
-
60
- To calculate the function value of 0.42 in the shell:
61
-
62
- .. code-block:: bash
63
-
64
- py -m expit 0.42
65
-
66
- Or inside of a python script:
67
-
68
- .. code-block:: python
69
-
70
- import expit
71
- print(expit.function(0.42))
72
-
73
- License
74
- -------
75
-
76
- This project is licensed under the MIT License.
77
-
78
- Links
79
- -----
80
-
81
- * `Documentation <https://pypi.org/project/expit/>`_
82
- * `Download <https://pypi.org/project/expit/#files>`_
83
- * `Source <https://github.com/johannes-programming/expit>`_
84
-
85
- Credits
86
- -------
87
- * Author: Johannes
88
- * Email: johannes-programming@mailfence.com
89
-
90
- Thank you for using ``expit``!
47
+ Visit the website `https://expit.johannes-programming.online <https://expit.johannes-programming.online>`_ for more information.
@@ -9,4 +9,7 @@ src/expit.egg-info/PKG-INFO
9
9
  src/expit.egg-info/SOURCES.txt
10
10
  src/expit.egg-info/dependency_links.txt
11
11
  src/expit.egg-info/requires.txt
12
- src/expit.egg-info/top_level.txt
12
+ src/expit.egg-info/top_level.txt
13
+ src/expit/core/__init__.py
14
+ src/expit/tests/__init__.py
15
+ src/expit/tests/test_easy.py
@@ -0,0 +1,2 @@
1
+ click>=8.1.7
2
+ preparse>=0.0.2
expit-1.0.6/README.rst DELETED
@@ -1,52 +0,0 @@
1
- =====
2
- expit
3
- =====
4
-
5
- Overview
6
- --------
7
-
8
- The expit function.
9
-
10
- Installation
11
- ------------
12
-
13
- To install expit, you can use ``pip``. Open your terminal and run:
14
-
15
- .. code-block:: bash
16
-
17
- pip install expit
18
-
19
- Example
20
- -------
21
-
22
- To calculate the function value of 0.42 in the shell:
23
-
24
- .. code-block:: bash
25
-
26
- py -m expit 0.42
27
-
28
- Or inside of a python script:
29
-
30
- .. code-block:: python
31
-
32
- import expit
33
- print(expit.function(0.42))
34
-
35
- License
36
- -------
37
-
38
- This project is licensed under the MIT License.
39
-
40
- Links
41
- -----
42
-
43
- * `Documentation <https://pypi.org/project/expit/>`_
44
- * `Download <https://pypi.org/project/expit/#files>`_
45
- * `Source <https://github.com/johannes-programming/expit>`_
46
-
47
- Credits
48
- -------
49
- * Author: Johannes
50
- * Email: johannes-programming@mailfence.com
51
-
52
- Thank you for using ``expit``!
@@ -1,27 +0,0 @@
1
- import math as _math
2
- from importlib.metadata import version as _V
3
-
4
- import click as _click
5
-
6
- try:
7
- __version__ = _V("expit")
8
- except:
9
- __version__ = "UNKNOWN"
10
-
11
-
12
- def function(x: float):
13
- try:
14
- p = _math.exp(-x)
15
- except OverflowError:
16
- p = float("+inf")
17
- return 1 / (1 + p)
18
-
19
-
20
- @_click.command()
21
- @_click.argument("x", help="the argument for the expit function")
22
- def main(x: float):
23
- _click.echo(function(x))
24
-
25
-
26
- if __name__ == "__main__":
27
- main()
@@ -1 +0,0 @@
1
- click>=8.1.7
File without changes
File without changes
File without changes
File without changes