nat-calculator 0.1.0__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.
@@ -0,0 +1,32 @@
1
+ Metadata-Version: 2.4
2
+ Name: nat-calculator
3
+ Version: 0.1.0
4
+ Summary: A simple Python calculator package
5
+ Author: nat
6
+ License: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3 :: Only
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+
14
+ # Calculator Tools Package
15
+
16
+ A modular, reusable Python package for basic arithmetic operations, statistical calculations, temperature conversions, unit conversions, and custom error handling.
17
+
18
+ ---
19
+
20
+ ## 📁 Package Structure
21
+
22
+ ```text
23
+ calculator_project/
24
+ │
25
+ ├── calculator_tools/ # Core package directory
26
+ │ ├── __init__.py # Package initialization & exports
27
+ │ ├── arithmetic.py # Math operations (+, -, *, /, %)
28
+ │ ├── statistics.py # Statistical utility functions
29
+ │ ├── converter.py # Temperature & distance converters
30
+ │ └── exceptions.py # Custom exception classes
31
+ │
32
+ └── main.py # Demonstration script
@@ -0,0 +1,19 @@
1
+ # Calculator Tools Package
2
+
3
+ A modular, reusable Python package for basic arithmetic operations, statistical calculations, temperature conversions, unit conversions, and custom error handling.
4
+
5
+ ---
6
+
7
+ ## 📁 Package Structure
8
+
9
+ ```text
10
+ calculator_project/
11
+ │
12
+ ├── calculator_tools/ # Core package directory
13
+ │ ├── __init__.py # Package initialization & exports
14
+ │ ├── arithmetic.py # Math operations (+, -, *, /, %)
15
+ │ ├── statistics.py # Statistical utility functions
16
+ │ ├── converter.py # Temperature & distance converters
17
+ │ └── exceptions.py # Custom exception classes
18
+ │
19
+ └── main.py # Demonstration script
@@ -0,0 +1,11 @@
1
+ # Expose selected components directly at the package level
2
+ from .arithmetic import add, subtract, multiply, divide, percentage
3
+ from .statistics import calculate_average
4
+ from .converter import celsius_to_fahrenheit, km_to_miles
5
+ from .exceptions import InvalidOperationError
6
+
7
+ __all__ = [
8
+ 'add', 'subtract', 'multiply', 'divide', 'percentage',
9
+ 'calculate_average', 'celsius_to_fahrenheit', 'km_to_miles',
10
+ 'InvalidOperationError'
11
+ ]
@@ -0,0 +1,30 @@
1
+ from .exceptions import InvalidOperationError
2
+
3
+ def add(a: float, b: float) -> float:
4
+ _validate_number(a, b)
5
+ return a + b
6
+
7
+ def subtract(a: float, b: float) -> float:
8
+ _validate_number(a, b)
9
+ return a - b
10
+
11
+ def multiply(a: float, b: float) -> float:
12
+ _validate_number(a, b)
13
+ return a * b
14
+
15
+ def divide(a: float, b: float) -> float:
16
+ _validate_number(a, b)
17
+ if b == 0:
18
+ raise InvalidOperationError("Division by zero is not allowed.")
19
+ return a / b
20
+
21
+ def percentage(part: float, total: float) -> float:
22
+ _validate_number(part, total)
23
+ if total <= 0:
24
+ raise InvalidOperationError("Total must be greater than zero for percentage calculation.")
25
+ return (part / total) * 100
26
+
27
+ def _validate_number(*args):
28
+ for arg in args:
29
+ if not isinstance(arg, (int, float)) or isinstance(arg, bool):
30
+ raise InvalidOperationError(f"Invalid input '{arg}'. Expected a real number.")
@@ -0,0 +1,15 @@
1
+ from .exceptions import InvalidOperationError
2
+
3
+ def celsius_to_fahrenheit(celsius: float) -> float:
4
+ _validate_number(celsius)
5
+ return (celsius * 9/5) + 32
6
+
7
+ def km_to_miles(km: float) -> float:
8
+ _validate_number(km)
9
+ if km < 0:
10
+ raise InvalidOperationError("Distance cannot be negative.")
11
+ return km * 0.621371
12
+
13
+ def _validate_number(val):
14
+ if not isinstance(val, (int, float)) or isinstance(val, bool):
15
+ raise InvalidOperationError(f"Invalid value '{val}'. Expected a real number.")
@@ -0,0 +1,3 @@
1
+ class InvalidOperationError(Exception):
2
+ """Custom exception for invalid operations or input types."""
3
+ pass
@@ -0,0 +1,14 @@
1
+ from typing import List
2
+ from .exceptions import InvalidOperationError
3
+
4
+ def calculate_average(numbers: List[float]) -> float:
5
+ if not isinstance(numbers, list):
6
+ raise InvalidOperationError("Input must be a list of numbers.")
7
+ if not numbers:
8
+ raise InvalidOperationError("Cannot calculate average of an empty list.")
9
+
10
+ for num in numbers:
11
+ if not isinstance(num, (int, float)) or isinstance(num, bool):
12
+ raise InvalidOperationError(f"Invalid element '{num}' in list. Expected numbers only.")
13
+
14
+ return sum(numbers) / len(numbers)
@@ -0,0 +1,32 @@
1
+ Metadata-Version: 2.4
2
+ Name: nat-calculator
3
+ Version: 0.1.0
4
+ Summary: A simple Python calculator package
5
+ Author: nat
6
+ License: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3 :: Only
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+
14
+ # Calculator Tools Package
15
+
16
+ A modular, reusable Python package for basic arithmetic operations, statistical calculations, temperature conversions, unit conversions, and custom error handling.
17
+
18
+ ---
19
+
20
+ ## 📁 Package Structure
21
+
22
+ ```text
23
+ calculator_project/
24
+ │
25
+ ├── calculator_tools/ # Core package directory
26
+ │ ├── __init__.py # Package initialization & exports
27
+ │ ├── arithmetic.py # Math operations (+, -, *, /, %)
28
+ │ ├── statistics.py # Statistical utility functions
29
+ │ ├── converter.py # Temperature & distance converters
30
+ │ └── exceptions.py # Custom exception classes
31
+ │
32
+ └── main.py # Demonstration script
@@ -0,0 +1,11 @@
1
+ README.md
2
+ pyproject.toml
3
+ calculator_tools/__init__.py
4
+ calculator_tools/arithmetic.py
5
+ calculator_tools/converter.py
6
+ calculator_tools/exceptions.py
7
+ calculator_tools/statistics.py
8
+ nat_calculator.egg-info/PKG-INFO
9
+ nat_calculator.egg-info/SOURCES.txt
10
+ nat_calculator.egg-info/dependency_links.txt
11
+ nat_calculator.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ calculator_tools
@@ -0,0 +1,23 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "nat-calculator"
7
+ version = "0.1.0"
8
+ description = "A simple Python calculator package"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = {text = "MIT"}
12
+ authors = [
13
+ {name = "nat"}
14
+ ]
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3 :: Only",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent"
20
+ ]
21
+
22
+ [tool.setuptools.packages.find]
23
+ include = ["calculator_tools*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+