pyquantity 0.1.15__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.
- pyquantity-0.1.15/LICENSE +21 -0
- pyquantity-0.1.15/PKG-INFO +118 -0
- pyquantity-0.1.15/README.md +78 -0
- pyquantity-0.1.15/pyproject.toml +124 -0
- pyquantity-0.1.15/setup.cfg +4 -0
- pyquantity-0.1.15/setup.py +62 -0
- pyquantity-0.1.15/src/pyquantity/__init__.py +29 -0
- pyquantity-0.1.15/src/pyquantity/context.py +513 -0
- pyquantity-0.1.15/src/pyquantity/core.py +1185 -0
- pyquantity-0.1.15/src/pyquantity/parser.py +464 -0
- pyquantity-0.1.15/src/pyquantity.egg-info/PKG-INFO +118 -0
- pyquantity-0.1.15/src/pyquantity.egg-info/SOURCES.txt +19 -0
- pyquantity-0.1.15/src/pyquantity.egg-info/dependency_links.txt +1 -0
- pyquantity-0.1.15/src/pyquantity.egg-info/requires.txt +12 -0
- pyquantity-0.1.15/src/pyquantity.egg-info/top_level.txt +1 -0
- pyquantity-0.1.15/tests/test_context.py +383 -0
- pyquantity-0.1.15/tests/test_core.py +529 -0
- pyquantity-0.1.15/tests/test_core_deep_coverage.py +344 -0
- pyquantity-0.1.15/tests/test_core_final_coverage.py +290 -0
- pyquantity-0.1.15/tests/test_edge_cases.py +450 -0
- pyquantity-0.1.15/tests/test_parser.py +429 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 odysseu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyquantity
|
|
3
|
+
Version: 0.1.15
|
|
4
|
+
Summary: A modern Python package for quantity calculations
|
|
5
|
+
Home-page: https://github.com/odysseu/pyquantity
|
|
6
|
+
Author: Odysseu
|
|
7
|
+
Author-email: Odysseu <uboucherie1@gmail.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/odysseu/pyquantity
|
|
10
|
+
Project-URL: Documentation, https://github.com/odysseu/pyquantity#readme
|
|
11
|
+
Project-URL: Repository, https://github.com/odysseu/pyquantity.git
|
|
12
|
+
Project-URL: Issues, https://github.com/odysseu/pyquantity/issues
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: black>=26.1.0; extra == "dev"
|
|
27
|
+
Requires-Dist: isort>=7.0.0; extra == "dev"
|
|
28
|
+
Requires-Dist: mypy>=1.19.1; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest>=9.0.2; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-cov>=7.0.0; extra == "dev"
|
|
31
|
+
Requires-Dist: ruff>=0.15.1; extra == "dev"
|
|
32
|
+
Requires-Dist: build>=1.4.0; extra == "dev"
|
|
33
|
+
Requires-Dist: sphinx>=7.2.6; extra == "dev"
|
|
34
|
+
Requires-Dist: furo>=2025.12.19; extra == "dev"
|
|
35
|
+
Requires-Dist: myst-parser>=5.0.0; extra == "dev"
|
|
36
|
+
Dynamic: author
|
|
37
|
+
Dynamic: home-page
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
Dynamic: requires-python
|
|
40
|
+
|
|
41
|
+
# PyQuantity
|
|
42
|
+
|
|
43
|
+
[](https://github.com/odysseu/pyquantity/actions/workflows/ci.yml)
|
|
44
|
+

|
|
45
|
+

|
|
46
|
+

|
|
47
|
+

|
|
48
|
+

|
|
49
|
+

|
|
50
|
+
[](https://github.com/psf/black)
|
|
51
|
+
|
|
52
|
+
A Python package for quantity calculations with unit support and dimensional analysis.
|
|
53
|
+
|
|
54
|
+
**Test Coverage**: 
|
|
55
|
+
|
|
56
|
+
## Features
|
|
57
|
+
|
|
58
|
+
- Comprehensive unit systems with 60+ base dimensions
|
|
59
|
+
- 1000+ derived units including mechanical, electrical, and thermal units
|
|
60
|
+
- Full SI prefix support from yocto to yotta
|
|
61
|
+
- Contextual measurements with built-in database
|
|
62
|
+
- Natural language parsing for quantity extraction
|
|
63
|
+
- Advanced physics calculations
|
|
64
|
+
- Type hints and comprehensive documentation
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install pyquantity
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Requirements:**
|
|
73
|
+
- Python 3.10 or higher (following [Python's version support policy, mostly](https://devguide.python.org/versions/))
|
|
74
|
+
|
|
75
|
+
**For Developers:**
|
|
76
|
+
```bash
|
|
77
|
+
pip install -e ".[dev]"
|
|
78
|
+
python test_with_coverage.py
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Quick Start
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from pyquantity import Quantity, get_measurement, parse_quantity
|
|
85
|
+
|
|
86
|
+
# Basic quantity operations
|
|
87
|
+
length = Quantity(5.0, "meter")
|
|
88
|
+
width = Quantity(3.0, "meter")
|
|
89
|
+
area = length * width
|
|
90
|
+
|
|
91
|
+
# Unit conversion
|
|
92
|
+
distance = Quantity(1.5, "kilometer")
|
|
93
|
+
distance_m = distance.convert("meter")
|
|
94
|
+
|
|
95
|
+
# Contextual measurements
|
|
96
|
+
bath = get_measurement("normal bath")
|
|
97
|
+
cup = get_measurement("cup")
|
|
98
|
+
cups_in_bath = bath / cup
|
|
99
|
+
|
|
100
|
+
# Natural language parsing
|
|
101
|
+
text = "A car traveling at 120 km/h for 2.5 hours"
|
|
102
|
+
quantities = parse_quantity(text)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Documentation
|
|
106
|
+
|
|
107
|
+
- [Usage Guide](docs/usage_guide.md)
|
|
108
|
+
- [Advanced Features](docs/advanced_features.md)
|
|
109
|
+
- [API Reference](docs/api_reference.md)
|
|
110
|
+
- [Examples](example_usage.py)
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
MIT License - See [LICENSE](LICENSE) for details.
|
|
115
|
+
|
|
116
|
+
## Contributing
|
|
117
|
+
|
|
118
|
+
Contributions are welcome!
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# PyQuantity
|
|
2
|
+
|
|
3
|
+
[](https://github.com/odysseu/pyquantity/actions/workflows/ci.yml)
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+
[](https://github.com/psf/black)
|
|
11
|
+
|
|
12
|
+
A Python package for quantity calculations with unit support and dimensional analysis.
|
|
13
|
+
|
|
14
|
+
**Test Coverage**: 
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- Comprehensive unit systems with 60+ base dimensions
|
|
19
|
+
- 1000+ derived units including mechanical, electrical, and thermal units
|
|
20
|
+
- Full SI prefix support from yocto to yotta
|
|
21
|
+
- Contextual measurements with built-in database
|
|
22
|
+
- Natural language parsing for quantity extraction
|
|
23
|
+
- Advanced physics calculations
|
|
24
|
+
- Type hints and comprehensive documentation
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install pyquantity
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Requirements:**
|
|
33
|
+
- Python 3.10 or higher (following [Python's version support policy, mostly](https://devguide.python.org/versions/))
|
|
34
|
+
|
|
35
|
+
**For Developers:**
|
|
36
|
+
```bash
|
|
37
|
+
pip install -e ".[dev]"
|
|
38
|
+
python test_with_coverage.py
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Quick Start
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from pyquantity import Quantity, get_measurement, parse_quantity
|
|
45
|
+
|
|
46
|
+
# Basic quantity operations
|
|
47
|
+
length = Quantity(5.0, "meter")
|
|
48
|
+
width = Quantity(3.0, "meter")
|
|
49
|
+
area = length * width
|
|
50
|
+
|
|
51
|
+
# Unit conversion
|
|
52
|
+
distance = Quantity(1.5, "kilometer")
|
|
53
|
+
distance_m = distance.convert("meter")
|
|
54
|
+
|
|
55
|
+
# Contextual measurements
|
|
56
|
+
bath = get_measurement("normal bath")
|
|
57
|
+
cup = get_measurement("cup")
|
|
58
|
+
cups_in_bath = bath / cup
|
|
59
|
+
|
|
60
|
+
# Natural language parsing
|
|
61
|
+
text = "A car traveling at 120 km/h for 2.5 hours"
|
|
62
|
+
quantities = parse_quantity(text)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Documentation
|
|
66
|
+
|
|
67
|
+
- [Usage Guide](docs/usage_guide.md)
|
|
68
|
+
- [Advanced Features](docs/advanced_features.md)
|
|
69
|
+
- [API Reference](docs/api_reference.md)
|
|
70
|
+
- [Examples](example_usage.py)
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
MIT License - See [LICENSE](LICENSE) for details.
|
|
75
|
+
|
|
76
|
+
## Contributing
|
|
77
|
+
|
|
78
|
+
Contributions are welcome!
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=80.9.0", "wheel>=0.46.3"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pyquantity"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "A modern Python package for quantity calculations"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Odysseu", email = "uboucherie1@gmail.com"}
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Programming Language :: Python :: 3.14",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://github.com/odysseu/pyquantity"
|
|
29
|
+
Documentation = "https://github.com/odysseu/pyquantity#readme"
|
|
30
|
+
Repository = "https://github.com/odysseu/pyquantity.git"
|
|
31
|
+
Issues = "https://github.com/odysseu/pyquantity/issues"
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
dev = [
|
|
35
|
+
"black>=26.1.0",
|
|
36
|
+
"isort>=7.0.0",
|
|
37
|
+
"mypy>=1.19.1",
|
|
38
|
+
"pytest>=9.0.2",
|
|
39
|
+
"pytest-cov>=7.0.0",
|
|
40
|
+
"ruff>=0.15.1",
|
|
41
|
+
"build>=1.4.0",
|
|
42
|
+
"sphinx>=7.2.6",
|
|
43
|
+
"furo>=2025.12.19",
|
|
44
|
+
"myst-parser>=5.0.0",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[tool.setuptools]
|
|
48
|
+
package-dir = {"" = "src"}
|
|
49
|
+
|
|
50
|
+
[tool.setuptools.packages.find]
|
|
51
|
+
where = ["src"]
|
|
52
|
+
|
|
53
|
+
[tool.setuptools.dynamic]
|
|
54
|
+
version = {attr = "pyquantity.__version__"}
|
|
55
|
+
|
|
56
|
+
[tool.black]
|
|
57
|
+
line-length = 88
|
|
58
|
+
target-version = ['py310', 'py311', 'py312', 'py313', 'py314']
|
|
59
|
+
include = '\.pyi?$'
|
|
60
|
+
exclude = '''
|
|
61
|
+
/(
|
|
62
|
+
\.eggs
|
|
63
|
+
| \.git
|
|
64
|
+
| \.hg
|
|
65
|
+
| \.mypy_cache
|
|
66
|
+
| \.tox
|
|
67
|
+
| \.venv
|
|
68
|
+
| _build
|
|
69
|
+
| buck-out
|
|
70
|
+
| build
|
|
71
|
+
| dist
|
|
72
|
+
)/
|
|
73
|
+
'''
|
|
74
|
+
|
|
75
|
+
[tool.isort]
|
|
76
|
+
profile = "black"
|
|
77
|
+
line_length = 88
|
|
78
|
+
multi_line_output = 3
|
|
79
|
+
include_trailing_comma = true
|
|
80
|
+
force_grid_wrap = 0
|
|
81
|
+
use_parentheses = true
|
|
82
|
+
ensure_newline_before_comments = true
|
|
83
|
+
|
|
84
|
+
[tool.mypy]
|
|
85
|
+
python_version = "3.10"
|
|
86
|
+
warn_return_any = true
|
|
87
|
+
warn_unused_configs = true
|
|
88
|
+
disallow_untyped_defs = true
|
|
89
|
+
exclude = ["build/", "dist/"]
|
|
90
|
+
|
|
91
|
+
[tool.pytest.ini_options]
|
|
92
|
+
python_files = "test_*.py"
|
|
93
|
+
testpaths = ["tests"]
|
|
94
|
+
addopts = "--cov=pyquantity --cov-report=term-missing --cov-report=html --cov-report=xml"
|
|
95
|
+
|
|
96
|
+
[tool.coverage.run]
|
|
97
|
+
source = ["src"]
|
|
98
|
+
branch = true
|
|
99
|
+
|
|
100
|
+
[tool.coverage.report]
|
|
101
|
+
show_missing = true
|
|
102
|
+
fail_under = 70
|
|
103
|
+
|
|
104
|
+
[tool.ruff]
|
|
105
|
+
line-length = 88
|
|
106
|
+
|
|
107
|
+
[tool.ruff.lint]
|
|
108
|
+
select = [
|
|
109
|
+
"E", # pycodestyle errors
|
|
110
|
+
"W", # pycodestyle warnings
|
|
111
|
+
"F", # pyflakes
|
|
112
|
+
"I", # isort
|
|
113
|
+
"B", # flake8-bugbear
|
|
114
|
+
"C4", # flake8-comprehensions
|
|
115
|
+
"UP", # pyupgrade
|
|
116
|
+
]
|
|
117
|
+
ignore = [
|
|
118
|
+
"E501", # line too long, handled by black
|
|
119
|
+
"B008", # do not perform function calls in argument defaults
|
|
120
|
+
"C901", # too complex
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
[tool.ruff.lint.per-file-ignores]
|
|
124
|
+
"tests/*" = ["S101"] # allow assert statements in tests
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
"""
|
|
3
|
+
Setup script for PyQuantity package.
|
|
4
|
+
|
|
5
|
+
This setup.py file is provided for backward compatibility and to support
|
|
6
|
+
certain build tools that still expect it. The primary configuration is
|
|
7
|
+
in pyproject.toml following PEP 621.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import re
|
|
11
|
+
|
|
12
|
+
from setuptools import setup
|
|
13
|
+
|
|
14
|
+
# Read the long description from README.md
|
|
15
|
+
with open("README.md", encoding="utf-8") as f:
|
|
16
|
+
long_description = f.read()
|
|
17
|
+
|
|
18
|
+
# Read version from __init__.py to avoid duplication
|
|
19
|
+
def get_version():
|
|
20
|
+
with open("src/pyquantity/__init__.py", encoding="utf-8") as f:
|
|
21
|
+
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", f.read(), re.M)
|
|
22
|
+
if version_match:
|
|
23
|
+
return version_match.group(1)
|
|
24
|
+
raise RuntimeError("Unable to find version string.")
|
|
25
|
+
|
|
26
|
+
setup(
|
|
27
|
+
# Basic package information (also defined in pyproject.toml for PEP 621)
|
|
28
|
+
name="pyquantity",
|
|
29
|
+
version=get_version(),
|
|
30
|
+
description="A modern Python package for quantity calculations",
|
|
31
|
+
long_description=long_description,
|
|
32
|
+
long_description_content_type="text/markdown",
|
|
33
|
+
author="Odysseu",
|
|
34
|
+
author_email="uboucherie1@gmail.com",
|
|
35
|
+
url="https://github.com/odysseu/pyquantity",
|
|
36
|
+
|
|
37
|
+
# Package structure
|
|
38
|
+
package_dir={"": "src"},
|
|
39
|
+
packages=["pyquantity"],
|
|
40
|
+
python_requires=">=3.10",
|
|
41
|
+
|
|
42
|
+
# Classifiers
|
|
43
|
+
classifiers=[
|
|
44
|
+
"Development Status :: 3 - Alpha",
|
|
45
|
+
"Intended Audience :: Developers",
|
|
46
|
+
"License :: OSI Approved :: MIT License",
|
|
47
|
+
"Programming Language :: Python :: 3",
|
|
48
|
+
"Programming Language :: Python :: 3.10",
|
|
49
|
+
"Programming Language :: Python :: 3.11",
|
|
50
|
+
"Programming Language :: Python :: 3.12",
|
|
51
|
+
"Programming Language :: Python :: 3.13",
|
|
52
|
+
"Programming Language :: Python :: 3.14",
|
|
53
|
+
],
|
|
54
|
+
|
|
55
|
+
# Project URLs
|
|
56
|
+
project_urls={
|
|
57
|
+
"Homepage": "https://github.com/odysseu/pyquantity",
|
|
58
|
+
"Documentation": "https://github.com/odysseu/pyquantity#readme",
|
|
59
|
+
"Repository": "https://github.com/odysseu/pyquantity.git",
|
|
60
|
+
"Issues": "https://github.com/odysseu/pyquantity/issues",
|
|
61
|
+
},
|
|
62
|
+
)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""
|
|
2
|
+
pyquantity - A modern Python package for quantity calculations.
|
|
3
|
+
|
|
4
|
+
This package provides tools for working with physical quantities, units,
|
|
5
|
+
and dimensional analysis.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "0.1.15"
|
|
9
|
+
__author__ = "odysseu"
|
|
10
|
+
__email__ = "uboucherie1@gmail.com"
|
|
11
|
+
__license__ = "MIT"
|
|
12
|
+
|
|
13
|
+
from .context import (
|
|
14
|
+
MeasurementDatabase,
|
|
15
|
+
UnitParser,
|
|
16
|
+
extract_quantities,
|
|
17
|
+
find_units_in_text,
|
|
18
|
+
get_measurement,
|
|
19
|
+
parse_quantity,
|
|
20
|
+
)
|
|
21
|
+
from .core import Dimension, Quantity, UnitSystem
|
|
22
|
+
from .parser import QuantityParser, parse_quantities
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"Quantity", "Dimension", "UnitSystem",
|
|
26
|
+
"QuantityParser", "parse_quantities",
|
|
27
|
+
"MeasurementDatabase", "UnitParser",
|
|
28
|
+
"get_measurement", "parse_quantity", "extract_quantities", "find_units_in_text"
|
|
29
|
+
]
|