py-geometry-utils 0.5.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,37 @@
1
+ name: Build project
2
+
3
+ on:
4
+ push:
5
+ branches: [ "**" ]
6
+ pull_request:
7
+ branches: [ "**" ]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ build:
14
+ name: Build & test project on ${{ matrix.os }}, Python ${{ matrix.python-version }}
15
+ runs-on: ${{ matrix.os }}
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ os: [ 'ubuntu-latest', 'windows-latest', 'macos-latest' ]
20
+ python-version: [ '3.12', '3.13', '3.14' ]
21
+
22
+ steps:
23
+ - uses: actions/checkout@v7
24
+ - name: Set up Python
25
+ uses: actions/setup-python@v6
26
+ with:
27
+ python-version: ${{ matrix.python-version }}
28
+ architecture: x64
29
+ - name: Install project
30
+ run: |
31
+ python -m pip install --upgrade pip
32
+ pip install .
33
+ - name: Install test dependencies
34
+ run: pip install .[dev]
35
+ - name: Test
36
+ run: |
37
+ pytest -v --doctest-modules
@@ -0,0 +1,77 @@
1
+ name: Publish Python distribution to PyPI and TestPyPI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - 'ci/*'
7
+ release:
8
+ types: [published]
9
+
10
+ jobs:
11
+ build:
12
+ name: Build distribution
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - uses: actions/checkout@v6
17
+ with:
18
+ persist-credentials: false
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v6
21
+ with:
22
+ python-version: "3.x"
23
+ - name: Install pypa/build
24
+ run: >-
25
+ python3 -m
26
+ pip install
27
+ build
28
+ --user
29
+ - name: Build binary wheel and source tarball
30
+ run: python3 -m build
31
+ - name: Store distributions
32
+ uses: actions/upload-artifact@v5
33
+ with:
34
+ name: python-package-distributions
35
+ path: dist/
36
+
37
+ publish-to-testpypi:
38
+ name: Publish to TestPyPI
39
+ needs:
40
+ - build
41
+ runs-on: ubuntu-latest
42
+ environment:
43
+ name: testpypi
44
+ url: https://test.pypi.org/p/py-geometry-utils
45
+ permissions:
46
+ id-token: write
47
+ steps:
48
+ - name: Download all the dists
49
+ uses: actions/download-artifact@v6
50
+ with:
51
+ name: python-package-distributions
52
+ path: dist/
53
+ - name: Publish distribution to TestPyPI
54
+ uses: pypa/gh-action-pypi-publish@release/v1
55
+ with:
56
+ verbose: true
57
+ repository-url: https://test.pypi.org/legacy/
58
+
59
+ publish-to-pypi:
60
+ name: Publish to production PyPI
61
+ if: startswith(github.ref, 'refs/tags/')
62
+ needs:
63
+ - build
64
+ runs-on: ubuntu-latest
65
+ environment:
66
+ name: pypi
67
+ url: https://pypi.org/p/py-geometry-utils
68
+ permissions:
69
+ id-token: write
70
+ steps:
71
+ - name: Download all the dists
72
+ uses: actions/download-artifact@v6
73
+ with:
74
+ name: python-package-distributions
75
+ path: dist/
76
+ - name: Publish distribution to PyPI
77
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,36 @@
1
+ name: Lint and type check
2
+
3
+ on:
4
+ push:
5
+ branches: [ "**" ]
6
+ pull_request:
7
+ branches: [ "**" ]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ build:
14
+ name: Lint and type check
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ matrix:
18
+ python-version: [ '3.12', '3.13', '3.14' ]
19
+
20
+ steps:
21
+ - uses: actions/checkout@v7
22
+ - name: Set up Python
23
+ uses: actions/setup-python@v6
24
+ with:
25
+ python-version: ${{ matrix.python-version }}
26
+ architecture: x64
27
+ - name: Install project + dependencies
28
+ run: |
29
+ python -m pip install --upgrade pip
30
+ pip install .[dev]
31
+ - name: Check with ty
32
+ run: |
33
+ ty check .
34
+ - name: Lint with ruff
35
+ run: |
36
+ ruff check .
@@ -0,0 +1,17 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ _build/
6
+ dist/
7
+ wheels/
8
+ *.egg-info
9
+
10
+ # Virtual environments
11
+ .venv/
12
+
13
+ # Cache dirs
14
+ .*cache*/
15
+
16
+ /_*
17
+ _html/
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,23 @@
1
+ # .readthedocs.yaml
2
+ # Read the Docs configuration file
3
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4
+
5
+ # Required
6
+ version: 2
7
+
8
+ # Set the OS, Python version and other tools you might need
9
+ build:
10
+ os: ubuntu-24.04
11
+ tools:
12
+ python: "3.13"
13
+
14
+ # Build documentation in the "docs/" directory with Sphinx
15
+ sphinx:
16
+ configuration: docs/conf.py
17
+
18
+ python:
19
+ install:
20
+ - method: pip
21
+ path: .
22
+ extra_requirements:
23
+ - docs
@@ -0,0 +1,114 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ This project uses [towncrier](https://towncrier.readthedocs.io) to generate release notes.
9
+
10
+ <!-- towncrier release notes start -->
11
+
12
+ ## [0.5.0] - 2026-08-02
13
+
14
+ ### Added
15
+
16
+ - Added method `Coord2._compare()` to handle all comparisons except `==`
17
+ - Added method `Coord2.zip_with()`
18
+ - Added method `Grid2.zip_with()
19
+ - Added method `Rect.zip_with()
20
+ - Added support for `# testcheck: ignore` comments on class definitions
21
+ - Added type alias `Tuple2`
22
+ - Added type alias `Tuple4`
23
+
24
+ ### Changed
25
+
26
+ - Initializing `Grid2` with an out-of-bounds `origin` value no longer raises an
27
+ error (#7)
28
+ - "steps" methods will yield no steps when `Grid2.origin` is out of bounds
29
+ - Attribute `tests.check.FunctionFinder.functions` now uses `ast.ClassDef`
30
+ nodes for keys instead of class name strings
31
+ - Rename `tests.check.FUNC_IGNORE_REGEX` to `IGNORE_REGEX`
32
+ - Renamed parameter `value` to `other` in `Coord2` methods `__eq__`, `__ge__`,
33
+ `__gt__`, `__le__`, and `__lt__` for consistency with other methods
34
+ - `Coord2` comparison methods `__ge__`, `__gt__`, `__le__`, and `__lt__` all
35
+ now `Coord2._compare()` instead of implementing the logic in themselves
36
+ - `Coord2` objects are now always truthy, removed `__bool__` implementation
37
+ - `tests.check.make_test_name()` now adds a prefix for private (and not magic)
38
+ methods
39
+
40
+ ### Removed
41
+
42
+ - Removed method `Coord2.binop()`
43
+ - Removed type alias `BinaryOp`
44
+
45
+ ## [0.4.0] - 2026-07-30
46
+
47
+ ### Added
48
+
49
+ - Added property `Coord2.mutable` (#6)
50
+ - Added property `Rect.mutable` (#6)
51
+ - Added property `Grid2.mutable` (#6)
52
+ - Added optional parameter `mut` to `Coord2.__init__()` (#6)
53
+ - Added optional parameter `mut` to `Rect.__init__()` (#6)
54
+ - Added optional parameter `mut` to `Grid2.__init__()` (#6)
55
+ - Added override method `Grid2.from_size()`
56
+ - Allows setting the `step` and `origin` of the resulting instance
57
+ - Added function `util.partition()` (#6)
58
+
59
+ ### Changed
60
+
61
+ - `Coord2`, `Rect`, and `Grid2` are now "immutable" by default, and must be
62
+ initialized with `mut=True` to modify their attributes
63
+ - `Coord2` attributes `x` and `y` are now properties
64
+ - Values can only be set if `Coord2` was initialized with `mut=True` (#6)
65
+ - `Rect` attributes `x1`, `y1`, `x2`, and `y2` are now properties
66
+ - Values can only be set if `Rect` was initialized with `mut=True` (#6)
67
+ - `Grid2` attributes `step` and `origin` are now properties
68
+ - Values can only be set if `Grid2` was initialized with `mut=True` (#6)
69
+ - `Grid2.step` and `Grid2.origin` are now properties, value is automatically
70
+ coerced to `Coord2` when setting
71
+
72
+ ## [0.3.0]
73
+
74
+ ### Added
75
+
76
+ - Added parameter `inf` to method `Grid2.steps_x()`
77
+ - Added parameter `inf` to method `Grid2.steps_y()`
78
+ - Added method `Coord2.snap_to_grid()`
79
+ - Implemented `__copy__` for `Coord2` (#1)
80
+ - Implemented `__str__` for `Coord2`
81
+ - Implemented `__copy__` for `Rect` (#1)
82
+ - Implemented `__copy__` for `Grid2` (#1)
83
+ - Implemented `__deepcopy__` for `Grid2` (#1)
84
+ - Added function `util.take_n()`
85
+
86
+ ### Changed
87
+
88
+ - `Grid2` is now a subclass of `Rect`
89
+ - `Grid2.__str__()` now includes step and origin values instead of just the rectangle coordiantes
90
+ - `Grid2.steps()` now yields coordinates even if the X or Y of the step value is 0, in which case
91
+ the corresponding value of the grid's origin coordinate is used for that value of the yielded
92
+ coordinates
93
+ - `util.snap_num()` parameter `mult` is now typed as `float`
94
+ - `util.snap_num()` return type is now `float`
95
+ - `util.snap_num()` parameter `snap_fn` is now optional (defaults to the built-in `round` function)
96
+
97
+ ## [0.2.0] - 2026-07-22
98
+
99
+ ### Added
100
+
101
+ - Added method `Coord2.distance()`
102
+ - Calculates euclidean or taxicab distance between two coordinates depending on the `mode` parameter
103
+ - Added method `Grid2.project()`
104
+ - Returns a coordinate in the same relative position to the `other` grid as it was to `self`
105
+ - Can be useful for plotting points from a grid with a negative x1 or y1 value onto an image which
106
+ requires using a grid whose top-left is 0, 0
107
+ - Added property `Rect.bottom_left`
108
+ - Added property `Rect.bottom_right`
109
+ - Added property `Rect.top_left`
110
+ - Added property `Rect.top_right`
111
+
112
+ ## [0.1.0] - 2026-07-21
113
+
114
+ Initial beta release.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Seth "Violet" Gibbs
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,41 @@
1
+ Metadata-Version: 2.4
2
+ Name: py-geometry-utils
3
+ Version: 0.5.0
4
+ Summary: Utilities for working with coordinates and rectangles/grids.
5
+ Project-URL: Homepage, https://github.com/svioletg/py-geometry-utils
6
+ Project-URL: Repository, https://github.com/svioletg/py-geometry-utils
7
+ Project-URL: Documentation, https://py-geometry-utils.readthedocs.io/en/latest/
8
+ Project-URL: Changelog, https://github.com/svioletg/py-geometry-utils/blob/main/CHANGELOG.md
9
+ Project-URL: Issues, https://github.com/svioletg/py-geometry-utils/issues
10
+ Author: Seth 'Violet' Gibbs
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Requires-Python: >=3.12
19
+ Provides-Extra: dev
20
+ Requires-Dist: py-maybetype>=0.14.0; extra == 'dev'
21
+ Requires-Dist: pytest>=9.1.1; extra == 'dev'
22
+ Requires-Dist: ruff>=0.15.22; extra == 'dev'
23
+ Requires-Dist: towncrier>=25.8.0; extra == 'dev'
24
+ Requires-Dist: ty>=0.0.61; extra == 'dev'
25
+ Provides-Extra: docs
26
+ Requires-Dist: furo>=2025.12.19; extra == 'docs'
27
+ Requires-Dist: myst-parser>=5.1.0; extra == 'docs'
28
+ Requires-Dist: sphinx-autobuild>=2025.8.25; extra == 'docs'
29
+ Requires-Dist: sphinx>=9.1; extra == 'docs'
30
+ Description-Content-Type: text/markdown
31
+
32
+ # py-geometry-utils
33
+
34
+ Provides utilities for working with coordinates, rectangles, and grids.
35
+
36
+ Initially [part of a different project](https://github.com/svioletg/py-squaremap-combiner/blob/47f30bffb5de121fbf5ce17621ce3b8127cd36c3/src/squaremap_combine/geo.py),
37
+ I wanted to use it in a few other projects so I decided to separate it out into its own package.
38
+
39
+ Documentation: <https://py-geometry-utils.readthedocs.io/en/latest/>
40
+
41
+ Changelog: <https://github.com/svioletg/py-geometry-utils/blob/main/CHANGELOG.md>
@@ -0,0 +1,10 @@
1
+ # py-geometry-utils
2
+
3
+ Provides utilities for working with coordinates, rectangles, and grids.
4
+
5
+ Initially [part of a different project](https://github.com/svioletg/py-squaremap-combiner/blob/47f30bffb5de121fbf5ce17621ce3b8127cd36c3/src/squaremap_combine/geo.py),
6
+ I wanted to use it in a few other projects so I decided to separate it out into its own package.
7
+
8
+ Documentation: <https://py-geometry-utils.readthedocs.io/en/latest/>
9
+
10
+ Changelog: <https://github.com/svioletg/py-geometry-utils/blob/main/CHANGELOG.md>
@@ -0,0 +1 @@
1
+ !.gitignore
@@ -0,0 +1,5 @@
1
+ Changelog
2
+ ===========
3
+
4
+ .. include:: ../CHANGELOG.md
5
+ :parser: myst_parser.sphinx_
@@ -0,0 +1,39 @@
1
+ from geometry import __version__ # noqa: D100, INP001
2
+
3
+ # Configuration file for the Sphinx documentation builder.
4
+ #
5
+ # For the full list of built-in configuration values, see the documentation:
6
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
7
+
8
+ # -- Project information -----------------------------------------------------
9
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
10
+
11
+ project = 'py-geometry-utils'
12
+ author = "Seth 'Violet' Gibbs"
13
+ release = __version__
14
+
15
+ # -- General configuration ---------------------------------------------------
16
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
17
+
18
+ extensions = [
19
+ 'sphinx.ext.autodoc',
20
+ 'myst_parser',
21
+ ]
22
+
23
+ autodoc_member_order = 'bysource'
24
+ autodoc_default_options = {
25
+ 'exclude-members': '__weakref__',
26
+ }
27
+
28
+ templates_path = ['_templates']
29
+ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
30
+
31
+ # -- Options for HTML output -------------------------------------------------
32
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
33
+
34
+ html_theme = 'furo'
35
+ html_static_path = ['_static']
36
+
37
+ rst_prolog = f"""
38
+ .. |project| replace:: {project}
39
+ """
@@ -0,0 +1,17 @@
1
+ |project| documentation
2
+ ===============================
3
+
4
+ .. toctree::
5
+ :maxdepth: 2
6
+ :caption: Contents:
7
+
8
+ readme.rst
9
+ changelog.rst
10
+ reference/index.rst
11
+ reference/util.rst
12
+
13
+ Indices and tables
14
+ ==================
15
+
16
+ * :ref:`genindex`
17
+ * :ref:`modindex`
@@ -0,0 +1,5 @@
1
+ README
2
+ ===========
3
+
4
+ .. include:: ../README.md
5
+ :parser: myst_parser.sphinx_
@@ -0,0 +1,9 @@
1
+ .. py:module:: geometry
2
+ .. py:currentmodule:: geometry
3
+
4
+ :py:mod:`~geometry` module
5
+ ========================================
6
+
7
+ .. automodule:: geometry
8
+ :members:
9
+ :special-members:
@@ -0,0 +1,9 @@
1
+ .. py:module:: geometry.util
2
+ .. py:currentmodule:: geometry.util
3
+
4
+ :py:mod:`~geometry.util` module
5
+ ========================================
6
+
7
+ .. automodule:: geometry.util
8
+ :members:
9
+ :special-members: