From 4eb9625b2589a09d6e1bb0026d53420849dcfec0 Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Mon, 27 Nov 2023 18:20:45 +0000 Subject: [PATCH 01/25] Update version number to 1.3.0 --- docs/HISTORY.rst | 4 ++++ pygeoif/about.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/HISTORY.rst b/docs/HISTORY.rst index 6e5c9718..0f0331ed 100644 --- a/docs/HISTORY.rst +++ b/docs/HISTORY.rst @@ -1,6 +1,10 @@ Changelog ========= +1.3.0 (unreleased) +------------------ + + 1.2.0 (2023/11/27) ------------------ diff --git a/pygeoif/about.py b/pygeoif/about.py index 10c86489..9145bc88 100644 --- a/pygeoif/about.py +++ b/pygeoif/about.py @@ -3,4 +3,4 @@ The only purpose of this module is to provide a version number for the package. """ -__version__ = "1.2.0" +__version__ = "1.3.0" From 9bba3370b92fd2d79e0fc62a6099de6eaa67ef85 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Dec 2023 18:23:15 +0000 Subject: [PATCH 02/25] Bump actions/setup-python from 4 to 5 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/run-all-tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-all-tests.yml b/.github/workflows/run-all-tests.yml index 75891c36..4cf1a2cd 100644 --- a/.github/workflows/run-all-tests.yml +++ b/.github/workflows/run-all-tests.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -41,7 +41,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -71,7 +71,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.pypy-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.pypy-version }} - name: Install dependencies @@ -90,7 +90,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.12 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.12 - name: Install pypa/build From dd79541f90def221453960ce30d7164cb79abd3e Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Thu, 7 Dec 2023 09:25:36 +0000 Subject: [PATCH 03/25] Add GraalPy workflow for running tests --- .github/workflows/run-all-tests.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/run-all-tests.yml b/.github/workflows/run-all-tests.yml index 4cf1a2cd..472a5b4c 100644 --- a/.github/workflows/run-all-tests.yml +++ b/.github/workflows/run-all-tests.yml @@ -82,6 +82,25 @@ jobs: run: | pytest tests + graalpy: + runs-on: ubuntu-latest + strategy: + matrix: + graalpy-version: ['graalpy-22.3'] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.graalpy-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.graalpy-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e ".[tests]" + - name: Test with pytest + run: | + pytest tests + publish: if: "github.event_name == 'push' && github.repository == 'cleder/pygeoif'" needs: [cpython, static-tests, pypy] From 526383b4894a9d7e99c6893b85c6d3571bbbca64 Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Thu, 7 Dec 2023 09:29:26 +0000 Subject: [PATCH 04/25] Remove graalpy test job --- .github/workflows/run-all-tests.yml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/.github/workflows/run-all-tests.yml b/.github/workflows/run-all-tests.yml index 472a5b4c..4cf1a2cd 100644 --- a/.github/workflows/run-all-tests.yml +++ b/.github/workflows/run-all-tests.yml @@ -82,25 +82,6 @@ jobs: run: | pytest tests - graalpy: - runs-on: ubuntu-latest - strategy: - matrix: - graalpy-version: ['graalpy-22.3'] - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.graalpy-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.graalpy-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install -e ".[tests]" - - name: Test with pytest - run: | - pytest tests - publish: if: "github.event_name == 'push' && github.repository == 'cleder/pygeoif'" needs: [cpython, static-tests, pypy] From a835eac194f111a29e0490f1254f24bd81d156e1 Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Thu, 7 Dec 2023 09:30:41 +0000 Subject: [PATCH 05/25] Add GraalPy workflow for running tests --- .github/workflows/run-all-tests.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/run-all-tests.yml b/.github/workflows/run-all-tests.yml index 4cf1a2cd..1ac83615 100644 --- a/.github/workflows/run-all-tests.yml +++ b/.github/workflows/run-all-tests.yml @@ -82,6 +82,25 @@ jobs: run: | pytest tests + graalpy: + runs-on: ubuntu-latest + strategy: + matrix: + graalpy-version: ['graalpy-22.3'] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.graalpy-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.graalpy-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install pytest + - name: Test with pytest + run: | + pytest tests + publish: if: "github.event_name == 'push' && github.repository == 'cleder/pygeoif'" needs: [cpython, static-tests, pypy] From 370a2fb7fc177b4dfd7c9ef7c70997fab290a9d5 Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Thu, 7 Dec 2023 09:33:13 +0000 Subject: [PATCH 06/25] Add typing_extensions to pytest dependencies --- .github/workflows/run-all-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-all-tests.yml b/.github/workflows/run-all-tests.yml index 1ac83615..b0a01d25 100644 --- a/.github/workflows/run-all-tests.yml +++ b/.github/workflows/run-all-tests.yml @@ -96,7 +96,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest + python -m pip install pytest typing_extensions - name: Test with pytest run: | pytest tests From 78b3e64e689fdcd7ed4db965fad840fd30cf06f5 Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Thu, 7 Dec 2023 09:35:52 +0000 Subject: [PATCH 07/25] Remove graalpy workflow --- .github/workflows/run-all-tests.yml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/.github/workflows/run-all-tests.yml b/.github/workflows/run-all-tests.yml index b0a01d25..4cf1a2cd 100644 --- a/.github/workflows/run-all-tests.yml +++ b/.github/workflows/run-all-tests.yml @@ -82,25 +82,6 @@ jobs: run: | pytest tests - graalpy: - runs-on: ubuntu-latest - strategy: - matrix: - graalpy-version: ['graalpy-22.3'] - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.graalpy-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.graalpy-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install pytest typing_extensions - - name: Test with pytest - run: | - pytest tests - publish: if: "github.event_name == 'push' && github.repository == 'cleder/pygeoif'" needs: [cpython, static-tests, pypy] From 68bd2516b904111b455e4d75448a6ea5adf444aa Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Sat, 9 Dec 2023 12:25:50 +0000 Subject: [PATCH 08/25] Add Codium AI PR Agent workflow --- .github/dependabot.yml | 2 -- .github/workflows/pr_agent.yml | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/pr_agent.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 10902aec..335e8c0a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,5 +1,3 @@ -# Set update schedule for GitHub Actions - version: 2 updates: - package-ecosystem: "github-actions" diff --git a/.github/workflows/pr_agent.yml b/.github/workflows/pr_agent.yml new file mode 100644 index 00000000..74742d7b --- /dev/null +++ b/.github/workflows/pr_agent.yml @@ -0,0 +1,15 @@ +on: [pull_request, issue_comment] +jobs: + pr_agent_job: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + contents: write + name: Run pr agent on every pull request, respond to user comments + steps: + - name: PR Agent action step + uses: Codium-ai/pr-agent@main + env: + OPENAI_KEY: ${{ secrets.OPENAI_KEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 970e01613a4a2396dc7258274a57faa97cfe1f63 Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Sat, 9 Dec 2023 19:26:29 +0000 Subject: [PATCH 09/25] Refactor __geo_interface__ to use property --- pygeoif/types.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pygeoif/types.py b/pygeoif/types.py index e9de16f6..9738b64f 100644 --- a/pygeoif/types.py +++ b/pygeoif/types.py @@ -87,13 +87,17 @@ class GeoFeatureCollectionInterface(TypedDict): class GeoType(Protocol): """Any compatible type that implements the __geo_interface__.""" - __geo_interface__: GeoInterface + @property + def __geo_interface__(self) -> GeoInterface: + """Return the GeoInterface.""" class GeoCollectionType(Protocol): """Any compatible type that implements the __geo_interface__.""" - __geo_interface__: GeoCollectionInterface + @property + def __geo_interface__(self) -> GeoCollectionInterface: + """Return the GeoInterface.""" __all__ = [ From ca80b82279a53d5141a22543df445ff4fd452cf3 Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Sat, 9 Dec 2023 21:11:29 +0000 Subject: [PATCH 10/25] Add badges and update classifiers --- README.rst | 12 ++++++++++++ pyproject.toml | 1 + 2 files changed, 13 insertions(+) diff --git a/README.rst b/README.rst index 64873415..bd03e620 100644 --- a/README.rst +++ b/README.rst @@ -76,6 +76,18 @@ It was written to provide clean and python only geometries for fastkml_ :target: https://pypi.python.org/pypi/pygeoif/ :alt: Supported Python implementations +.. image:: https://img.shields.io/pypi/v/pygeoif.svg + :target: https://pypi.python.org/pypi/pygeoif/ + :alt: Latest Version + +.. image:: https://img.shields.io/pypi/l/pygeoif.svg + :target: https://pypi.python.org/pypi/pygeoif/ + :alt: License + +.. image:: https://img.shields.io/pypi/dm/pygeoif.svg + :target: https://pypi.python.org/pypi/pygeoif/ + :alt: Downloads + Installation ------------ diff --git a/pyproject.toml b/pyproject.toml index 7a3bee81..54ccfb08 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,6 +25,7 @@ classifiers = [ "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Scientific/Engineering :: GIS", + "Typing :: Typed", ] dependencies = [ "typing_extensions", From f1aeb9206eefe19db7b0d656f0b40a414de77188 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 16:36:44 +0000 Subject: [PATCH 11/25] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pycqa/isort: 5.12.0 → 5.13.0](https://github.com/pycqa/isort/compare/5.12.0...5.13.0) - [github.com/astral-sh/ruff-pre-commit: v0.1.6 → v0.1.7](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.6...v0.1.7) - [github.com/python-jsonschema/check-jsonschema: 0.27.2 → 0.27.3](https://github.com/python-jsonschema/check-jsonschema/compare/0.27.2...0.27.3) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 258362e7..218229e0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,7 +32,7 @@ repos: hooks: - id: absolufy-imports - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.0 hooks: - id: isort - repo: https://github.com/psf/black @@ -40,7 +40,7 @@ repos: hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.1.6' + rev: 'v0.1.7' hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] @@ -84,7 +84,7 @@ repos: hooks: - id: pyprojectsort - repo: https://github.com/python-jsonschema/check-jsonschema - rev: "0.27.2" + rev: "0.27.3" hooks: - id: check-github-workflows - id: check-github-actions From 2cdb9b6a93ef31390175cec72a2e635f4191bee7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Dec 2023 18:50:21 +0000 Subject: [PATCH 12/25] Bump github/codeql-action from 2 to 3 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/v2...v3) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2721ebe9..e94c741a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -54,7 +54,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -68,5 +68,5 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 ... From 3f415e81588a7c08f60c51046f5a95515de9fcf3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 16:36:33 +0000 Subject: [PATCH 13/25] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pycqa/isort: 5.13.0 → 5.13.2](https://github.com/pycqa/isort/compare/5.13.0...5.13.2) - [github.com/psf/black: 23.11.0 → 23.12.0](https://github.com/psf/black/compare/23.11.0...23.12.0) - [github.com/astral-sh/ruff-pre-commit: v0.1.7 → v0.1.8](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.7...v0.1.8) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 218229e0..e317a8be 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,15 +32,15 @@ repos: hooks: - id: absolufy-imports - repo: https://github.com/pycqa/isort - rev: 5.13.0 + rev: 5.13.2 hooks: - id: isort - repo: https://github.com/psf/black - rev: 23.11.0 + rev: 23.12.0 hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.1.7' + rev: 'v0.1.8' hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From 58f05875fa817fae78d3c86074b892efdc407ef6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Dec 2023 16:36:19 +0000 Subject: [PATCH 14/25] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.12.0 → 23.12.1](https://github.com/psf/black/compare/23.12.0...23.12.1) - [github.com/astral-sh/ruff-pre-commit: v0.1.8 → v0.1.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.8...v0.1.9) - [github.com/pre-commit/mirrors-mypy: v1.7.1 → v1.8.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.7.1...v1.8.0) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e317a8be..395be40b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,11 +36,11 @@ repos: hooks: - id: isort - repo: https://github.com/psf/black - rev: 23.12.0 + rev: 23.12.1 hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.1.8' + rev: 'v0.1.9' hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] @@ -68,7 +68,7 @@ repos: - flake8-typing-imports - flake8-use-fstring - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.7.1 + rev: v1.8.0 hooks: - id: mypy # - repo: https://github.com/Lucas-C/pre-commit-hooks-markup From b338a550d2aa0d580771c5954357d093939193f1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 16:36:19 +0000 Subject: [PATCH 15/25] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.9 → v0.1.11](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.9...v0.1.11) - [github.com/PyCQA/flake8: 6.1.0 → 7.0.0](https://github.com/PyCQA/flake8/compare/6.1.0...7.0.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 395be40b..755dbbf6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,12 +40,12 @@ repos: hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.1.9' + rev: 'v0.1.11' hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 + rev: 7.0.0 hooks: - id: flake8 additional_dependencies: From 04d54eecdb22c9613d40c036d1b00c7b8d52ccf5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 16:34:31 +0000 Subject: [PATCH 16/25] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.11 → v0.1.13](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.11...v0.1.13) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 755dbbf6..3af190b4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,7 +40,7 @@ repos: hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.1.11' + rev: 'v0.1.13' hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From b6c6d7adb87e57b3854af80811f81d7003fc5f41 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 16:34:52 +0000 Subject: [PATCH 17/25] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pygeoif/feature.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygeoif/feature.py b/pygeoif/feature.py index 633d51d6..0669d181 100644 --- a/pygeoif/feature.py +++ b/pygeoif/feature.py @@ -110,7 +110,7 @@ def __repr__(self) -> str: ) @property - def id(self) -> Optional[Union[str, int]]: # noqa: A003 + def id(self) -> Optional[Union[str, int]]: """Return the id of the feature.""" return self._feature_id From d2a6f44d6c0a6fa28311c945603e0593eb886bee Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 16:34:38 +0000 Subject: [PATCH 18/25] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.13 → v0.1.14](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.13...v0.1.14) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3af190b4..1edd0dde 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,7 +40,7 @@ repos: hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.1.13' + rev: 'v0.1.14' hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From 4b4b4a6bc0c61d6c1e8e5a738747da6e7497bffa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 16:35:34 +0000 Subject: [PATCH 19/25] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.12.1 → 24.1.1](https://github.com/psf/black/compare/23.12.1...24.1.1) - [github.com/abravalheri/validate-pyproject: v0.15 → v0.16](https://github.com/abravalheri/validate-pyproject/compare/v0.15...v0.16) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1edd0dde..a93bf37f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,7 +36,7 @@ repos: hooks: - id: isort - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit @@ -76,7 +76,7 @@ repos: # hooks: # - id: rst-linter - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.15 + rev: v0.16 hooks: - id: validate-pyproject - repo: https://github.com/kieran-ryan/pyprojectsort From b816406a6e7b19193588686e0f202828e873deff Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 16:38:57 +0000 Subject: [PATCH 20/25] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mutmut_config.py | 1 + pygeoif/about.py | 1 + tests/test_base.py | 1 + tests/test_feature.py | 1 + tests/test_functions.py | 1 + tests/test_line.py | 1 + tests/test_linear_ring.py | 1 + tests/test_multiline.py | 1 + tests/test_multipoint.py | 1 + tests/test_multipolygon.py | 1 + tests/test_point.py | 1 + tests/test_polygon.py | 1 + 12 files changed, 12 insertions(+) diff --git a/mutmut_config.py b/mutmut_config.py index d99f99de..9436f1e0 100644 --- a/mutmut_config.py +++ b/mutmut_config.py @@ -1,4 +1,5 @@ """Mutmut configuration.""" + from typing import Protocol files_to_mutate = [ diff --git a/pygeoif/about.py b/pygeoif/about.py index 9145bc88..29e2e3a5 100644 --- a/pygeoif/about.py +++ b/pygeoif/about.py @@ -3,4 +3,5 @@ The only purpose of this module is to provide a version number for the package. """ + __version__ = "1.3.0" diff --git a/tests/test_base.py b/tests/test_base.py index af98c21b..961f4beb 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -1,4 +1,5 @@ """Test Baseclass.""" + from unittest import mock import pytest diff --git a/tests/test_feature.py b/tests/test_feature.py index 6e3fa3ac..641dcae6 100644 --- a/tests/test_feature.py +++ b/tests/test_feature.py @@ -1,4 +1,5 @@ """Test Feature and FeatureCollection.""" + import unittest import pytest diff --git a/tests/test_functions.py b/tests/test_functions.py index e1441a22..23715543 100644 --- a/tests/test_functions.py +++ b/tests/test_functions.py @@ -1,4 +1,5 @@ """Test geometric functions.""" + import itertools import math import random diff --git a/tests/test_line.py b/tests/test_line.py index 6cc60f40..2d32ea31 100644 --- a/tests/test_line.py +++ b/tests/test_line.py @@ -1,4 +1,5 @@ """Test LineString.""" + from unittest import mock import pytest diff --git a/tests/test_linear_ring.py b/tests/test_linear_ring.py index 8e4d3c9b..586cb14e 100644 --- a/tests/test_linear_ring.py +++ b/tests/test_linear_ring.py @@ -1,4 +1,5 @@ """Test LinearRing.""" + from unittest import mock import pytest diff --git a/tests/test_multiline.py b/tests/test_multiline.py index 40d14280..46f396e9 100644 --- a/tests/test_multiline.py +++ b/tests/test_multiline.py @@ -1,4 +1,5 @@ """Test MultiLineString.""" + from pygeoif import geometry diff --git a/tests/test_multipoint.py b/tests/test_multipoint.py index 693bad36..04c3705d 100644 --- a/tests/test_multipoint.py +++ b/tests/test_multipoint.py @@ -1,4 +1,5 @@ """Test MultiPoint.""" + import pytest from pygeoif import geometry diff --git a/tests/test_multipolygon.py b/tests/test_multipolygon.py index 967b8fee..c0322bc1 100644 --- a/tests/test_multipolygon.py +++ b/tests/test_multipolygon.py @@ -1,4 +1,5 @@ """Test MultiPolygon.""" + from pygeoif import geometry diff --git a/tests/test_point.py b/tests/test_point.py index 33a3fb93..9d91682d 100644 --- a/tests/test_point.py +++ b/tests/test_point.py @@ -1,4 +1,5 @@ """Test Point.""" + import math from unittest import mock diff --git a/tests/test_polygon.py b/tests/test_polygon.py index 4ef462d3..9aa5b8f5 100644 --- a/tests/test_polygon.py +++ b/tests/test_polygon.py @@ -1,4 +1,5 @@ """Test Polygon.""" + from unittest import mock from pygeoif import geometry From 24a9eb51d3f380ae5068f871e61fdcfd54b92572 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 31 Jan 2024 18:33:00 +0000 Subject: [PATCH 21/25] Bump codecov/codecov-action from 3 to 4 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3 to 4. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v3...v4) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/run-all-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-all-tests.yml b/.github/workflows/run-all-tests.yml index 4cf1a2cd..a9497063 100644 --- a/.github/workflows/run-all-tests.yml +++ b/.github/workflows/run-all-tests.yml @@ -26,7 +26,7 @@ jobs: pytest tests --cov=tests --cov=pygeoif --cov-report=xml - name: "Upload coverage to Codecov" if: ${{ matrix.python-version==3.11 }} - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: fail_ci_if_error: true verbose: true From d56649385ddc1b2c363781b0ed8083a1ee0ac4c6 Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Thu, 1 Feb 2024 10:00:37 +0000 Subject: [PATCH 22/25] use secrets token --- .github/workflows/run-all-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-all-tests.yml b/.github/workflows/run-all-tests.yml index a9497063..a5baf17b 100644 --- a/.github/workflows/run-all-tests.yml +++ b/.github/workflows/run-all-tests.yml @@ -30,7 +30,7 @@ jobs: with: fail_ci_if_error: true verbose: true - token: ${{ env.CODECOV_TOKEN }} + token: ${{ secrets.CODECOV_TOKEN }} static-tests: runs-on: ubuntu-latest From dd6042c547a769cae10377942d5c657a66fc351f Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Fri, 2 Feb 2024 16:35:24 +0000 Subject: [PATCH 23/25] ruff fix --- pygeoif/factories.py | 3 +++ pygeoif/feature.py | 2 ++ pygeoif/geometry.py | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/pygeoif/factories.py b/pygeoif/factories.py index b0f61450..ff8e32ee 100644 --- a/pygeoif/factories.py +++ b/pygeoif/factories.py @@ -130,6 +130,7 @@ def shape( >>> geom2 = shape(geom) >>> geom == geom2 True + """ type_map = { "Point": Point, @@ -173,6 +174,7 @@ def num(number: str) -> float: Returns ------- float or an integer if the string can be converted to an integer + """ f = float(number) return int(f) if int(f) == f else f @@ -328,6 +330,7 @@ def mapping( >>> pt = Point(0, 0) >>> mapping(pt) {'type': 'Point', 'bbox': (0, 0, 0, 0), 'coordinates': (0, 0)} + """ return ob.__geo_interface__ diff --git a/pygeoif/feature.py b/pygeoif/feature.py index 0669d181..90747f29 100644 --- a/pygeoif/feature.py +++ b/pygeoif/feature.py @@ -75,6 +75,7 @@ class Feature: {'Name': 'Sample Point', 'Other': 'Other Data'} >>> a.properties['Name'] 'Sample Point' + """ def __init__( @@ -168,6 +169,7 @@ class FeatureCollection: {'geometry': {'type': 'Point', 'coordinates': (1.0, -1.0)}, 'type': 'Feature', 'properties': {'Other': 'Other Data2', 'Name': 'Sample Point2'}}]} + """ def __init__(self, features: Sequence[Feature]) -> None: diff --git a/pygeoif/geometry.py b/pygeoif/geometry.py index 9b862777..b4f4e4ad 100644 --- a/pygeoif/geometry.py +++ b/pygeoif/geometry.py @@ -233,6 +233,7 @@ class Point(_Geometry): -1.0 >>> p.x 1.0 + """ _geoms: PointType @@ -245,6 +246,7 @@ def __init__(self, x: float, y: float, z: Optional[float] = None) -> None: ---------- 2 or 3 coordinate parameters: x, y, [z] : float Easting, northing, and elevation. + """ object.__setattr__( self, @@ -339,6 +341,7 @@ class LineString(_Geometry): ---------- geoms : sequence A sequence of Points + """ _geoms: Tuple[Point, ...] @@ -357,6 +360,7 @@ def __init__(self, coordinates: LineType) -> None: Create a line with two segments >>> a = LineString([(0, 0), (1, 0), (1, 1)]) + """ object.__setattr__(self, "_geoms", self._set_geoms(coordinates)) @@ -475,6 +479,7 @@ def __init__(self, coordinates: LineType) -> None: ---- coordinates (Sequence): A sequence of (x, y [,z]) numeric coordinate pairs or triples + """ super().__init__(coordinates) if not self.is_empty and self._geoms[0].coords != self._geoms[-1].coords: @@ -536,6 +541,7 @@ class Polygon(_Geometry): The ring which bounds the positive space of the polygon. interiors : sequence A sequence of rings which bound all existing holes. + """ _geoms: Tuple[LinearRing, ...] @@ -562,6 +568,7 @@ def __init__( >>> coords = ((0., 0.), (0., 1.), (1., 1.), (1., 0.), (0., 0.)) >>> polygon = Polygon(coords) + """ interiors = tuple(LinearRing(hole) for hole in holes) if holes else () exterior = LinearRing(shell) @@ -747,6 +754,7 @@ class MultiPoint(_MultiGeometry): ---------- geoms : sequence A sequence of Points + """ _geoms: Tuple[Point, ...] @@ -772,6 +780,7 @@ def __init__(self, points: Sequence[PointType], unique: bool = False) -> None: 2 >>> type(ob.geoms[0]) == Point True + """ if unique: points = set(points) # type: ignore [assignment] @@ -825,6 +834,7 @@ class MultiLineString(_MultiGeometry): ---------- geoms : sequence A sequence of LineStrings + """ _geoms: Tuple[LineString, ...] @@ -846,6 +856,7 @@ def __init__(self, lines: Sequence[LineType], unique: bool = False) -> None: Construct a collection containing one line string. >>> lines = MultiLineString( [[[0.0, 0.0], [1.0, 2.0]]] ) + """ if unique: lines = {tuple(line) for line in lines} # type: ignore [assignment] @@ -909,6 +920,7 @@ class MultiPolygon(_MultiGeometry): ---------- geoms : sequence A sequence of `Polygon` instances + """ _geoms: Tuple[Polygon, ...] @@ -942,6 +954,7 @@ def __init__(self, polygons: Sequence[PolygonType], unique: bool = False) -> Non 1 >>> type(ob.geoms[0]) == Polygon True + """ if unique: polygons = set(polygons) # type: ignore [assignment] @@ -1045,6 +1058,7 @@ class isn't generally supported by ordinary GIS sw (viewers and so on). So {'type': 'GeometryCollection', 'geometries': [{'type': 'Point', 'coordinates': (1.0, -1.0)}, {'type': 'Point', 'coordinates': (1.0, -1.0)}]} + """ _geoms: Tuple[Union[Geometry, "GeometryCollection"], ...] @@ -1059,6 +1073,7 @@ def __init__( Args: ---- geometries (Iterable[Geometry] + """ object.__setattr__(self, "_geoms", tuple(geom for geom in geometries if geom)) @@ -1099,6 +1114,7 @@ def __len__(self) -> int: Returns ------- int: Number of geometries in the collection. + """ return len(self._geoms) From 4e22a3628dce5cbaec157acaec96441ae8399e3e Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Fri, 2 Feb 2024 16:58:14 +0000 Subject: [PATCH 24/25] Update test directory link in README.rst and ruff lint sections in pyproject.toml --- README.rst | 2 +- pyproject.toml | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index bd03e620..a32bbdd1 100644 --- a/README.rst +++ b/README.rst @@ -115,7 +115,7 @@ Example You find more examples in the -`tests `_ +`tests `_ directory which cover every aspect of pygeoif or in fastkml_. Classes diff --git a/pyproject.toml b/pyproject.toml index 54ccfb08..8de74719 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -154,6 +154,9 @@ reportMissingTypeStubs = true [tool.ruff] fix = true +target-version = "py38" + +[tool.ruff.lint] ignore = [ "ANN101", "ANN102", @@ -221,12 +224,11 @@ select = [ "W", "YTT", ] -target-version = "py38" -[tool.ruff.isort] +[tool.ruff.lint.isort] force-single-line = true -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "pygeoif/factories.py" = [ "SLF001", ] From 29094d3cd6560fdeccc51cbca5c413960367d941 Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Sun, 4 Feb 2024 15:50:33 +0000 Subject: [PATCH 25/25] Remove maybe_valid, stricter is_empty --- pygeoif/geometry.py | 69 ++--------------------------------- tests/test_factories.py | 1 - tests/test_line.py | 20 +--------- tests/test_linear_ring.py | 40 -------------------- tests/test_polygon.py | 77 --------------------------------------- 5 files changed, 4 insertions(+), 203 deletions(-) diff --git a/pygeoif/geometry.py b/pygeoif/geometry.py index b4f4e4ad..4586212f 100644 --- a/pygeoif/geometry.py +++ b/pygeoif/geometry.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2012 -2023 Christian Ledermann +# Copyright (C) 2012 -2024 Christian Ledermann # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -383,26 +383,15 @@ def is_empty(self) -> bool: """ Return if this geometry is empty. - A Linestring is considered empty when it has less than 2 points. + A Linestring is considered empty when it has no points. """ - return len(self._geoms) < 2 # noqa: PLR2004 + return len(self._geoms) == 0 @property def has_z(self) -> Optional[bool]: """Return True if the geometry's coordinate sequence(s) have z values.""" return self._geoms[0].has_z if self.geoms else None - @property - def maybe_valid(self) -> bool: - """ - Check validity of the coordinates. - - Returns False if the coordinates collapse to a single Point. - This only highlights obvious problems with this geometry. - Even if this test passes the geometry may still be invalid. - """ - return len({p.coords[0] for p in self._geoms}) > 1 - @property def _wkt_coords(self) -> str: return ", ".join(point._wkt_coords for point in self.geoms) # noqa: SLF001 @@ -506,26 +495,6 @@ def is_ccw(self) -> bool: """Return True if the ring is oriented counter clock-wise.""" return signed_area(self.coords) >= 0 - @property - def maybe_valid(self) -> bool: - """ - Check validity of the coordinates. - - This only highlights obvious problems with this geometry. - Even if this test passes the geometry may still be invalid. - """ - if self.has_z: - msg = "Validation is only implemented for 2D coordinates" - raise DimensionError(msg) - min_x, min_y, max_x, max_y = self.bounds # type: ignore [misc] - if min_x == max_x or min_y == max_y: - return False - try: - _, area = centroid(self.coords) - except ZeroDivisionError: - return False - return math.isclose(a=area, b=signed_area(self.coords)) - class Polygon(_Geometry): """ @@ -619,22 +588,6 @@ def has_z(self) -> Optional[bool]: """Return True if the geometry's coordinate sequence(s) have z values.""" return self._geoms[0].has_z - @property - def maybe_valid(self) -> bool: - """ - Check validity of the coordinates. - - This only highlights obvious problems with this geometry. - Even if this test passes the geometry may still be invalid. - """ - if not self._check_interior_bounds(): - return False - return ( - all(interior.maybe_valid for interior in self.interiors) - if self.exterior.maybe_valid - else False - ) - @property def _wkt_coords(self) -> str: ec = self.exterior._wkt_coords # noqa: SLF001 @@ -672,22 +625,6 @@ def _from_dict(cls, geo_interface: GeoInterface) -> "Polygon": holes=cast(Tuple[LineType], geo_interface["coordinates"][1:]), ) - def _check_interior_bounds(self) -> bool: - """Check that the bounding boxes of holes are inside the bounds of the shell.""" - bounds = self.bounds - if not bounds: - return False - for interior in self.interiors: - i_box = cast(Bounds, interior.bounds) - if ( - bounds[0] > i_box[0] - or bounds[1] > i_box[1] - or bounds[2] < i_box[2] - or bounds[3] < i_box[3] - ): - return False - return True - def _get_bounds(self) -> Bounds: return self.exterior._get_bounds() # noqa: SLF001 diff --git a/tests/test_factories.py b/tests/test_factories.py index 71994ac1..f56528bc 100644 --- a/tests/test_factories.py +++ b/tests/test_factories.py @@ -94,7 +94,6 @@ def test_force_2d_polygon() -> None: ((0.5, 0.5), (0.5, 1.5), (1.5, 1.5), (1.5, 0.5), (0.5, 0.5)), ) assert not p2d.has_z - assert p.maybe_valid == p2d.maybe_valid # 3d to 2d external = [(0, 0, 1), (0, 2, 1), (2, 2, 1), (2, 0, 1), (0, 0, 1)] diff --git a/tests/test_line.py b/tests/test_line.py index 2d32ea31..0665a430 100644 --- a/tests/test_line.py +++ b/tests/test_line.py @@ -191,24 +191,6 @@ def test_from_coordinates() -> None: assert geometry.LineString.from_coordinates(line.coords) == line -def test_maybe_valid() -> None: - line = geometry.LineString([(0, 0), (1, 0)]) - - assert line.maybe_valid - - -def test_maybe_valid_point() -> None: - line = geometry.LineString([(0, 0), (0, 0)]) - - assert not line.maybe_valid - - -def test_maybe_empty() -> None: - line = geometry.LineString([]) - - assert not line.maybe_valid - - def test_empty() -> None: line = geometry.LineString([]) @@ -218,7 +200,7 @@ def test_empty() -> None: def test_empty_1_pt() -> None: line = geometry.LineString([(0, 0)]) - assert line.is_empty + assert not line.is_empty def test_repr_empty() -> None: diff --git a/tests/test_linear_ring.py b/tests/test_linear_ring.py index 586cb14e..8e59f68c 100644 --- a/tests/test_linear_ring.py +++ b/tests/test_linear_ring.py @@ -151,46 +151,6 @@ def test_convex_hull_linear_ring() -> None: assert line.convex_hull == geometry.Polygon([(0, 0), (1, 0), (2, 2), (0, 0)]) -def test_maybe_valid_crossing() -> None: - line = geometry.LinearRing([(0, 0), (1, 0), (1, 1), (0, -1)]) - - assert not line.maybe_valid - - -def test_maybe_valid_no_area() -> None: - line = geometry.LinearRing([(0, 0), (1, 1)]) - - assert not line.maybe_valid - - -def test_maybe_valid_x_line() -> None: - line = geometry.LinearRing([(0, 2), (1, 2)]) - - assert not line.maybe_valid - - -def test_maybe_valid_y_line() -> None: - line = geometry.LinearRing([(3, 0), (3, 1)]) - - assert not line.maybe_valid - - -def test_maybe_valid_happy() -> None: - line = geometry.LinearRing([(0, 0), (1, 0), (1, 1), (0, 0)]) - - assert line.maybe_valid - - -def test_valid_3d() -> None: - line = geometry.LinearRing([(0, 0, 1), (2, 0, 2), (2, 2, 0), (0, 2, 0)]) - - with pytest.raises( - exceptions.DimensionError, - match="^Validation is only implemented for 2D coordinates$", - ): - assert line.maybe_valid - - def test_is_ccw() -> None: line = geometry.LinearRing([(0, 0), (1, 0), (1, 1), (0, 0)]) diff --git a/tests/test_polygon.py b/tests/test_polygon.py index 9aa5b8f5..8b17c1c2 100644 --- a/tests/test_polygon.py +++ b/tests/test_polygon.py @@ -250,77 +250,6 @@ def test_from_coordinates_with_holes() -> None: assert geometry.Polygon.from_coordinates(polygon.coords) == polygon -def test_maybe_valid() -> None: - e = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)] - i = [(0.5, 0.5), (1, 1), (0.5, 1)] - polygon = geometry.Polygon(e, [i]) - - assert polygon.maybe_valid - - -def test_maybe_valid_touching_hole() -> None: - """A Hole may touch an exterior at one point.""" - e = [(0, 0), (0, 4), (4, 4), (4, 0)] - interiors_gen = (((1, 1), (2, 3), e[pt]) for pt in range(len(e))) - for polygon in (geometry.Polygon(e, [interior]) for interior in interiors_gen): - assert polygon.maybe_valid - - -def test_is_invalid_hole_too_big_y() -> None: - """A Hole may not cross an exterior.""" - e = [(0, 0), (0, 4), (4, 4), (4, 0)] - outside = ( - (-1, -1), - (-1, 5), - (5, 5), - (5, -1), - (-1, 0), - (-1, 4), - (5, 4), - (5, 0), - (0, -1), - (0, 5), - (4, 5), - (4, -1), - ) - interiors_gen = ( - ((1 + (i & 1), 1), (3, 3 - (i & 1)), outside[i]) for i in range(len(e)) - ) - for polygon in (geometry.Polygon(e, [interior]) for interior in interiors_gen): - assert not polygon.maybe_valid - - -def test_is_invalid_hole_too_big_x() -> None: - e = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)] - i = [(0.5, 0.5), (3, 1), (0.5, 1)] - polygon = geometry.Polygon(e, [i]) - - assert not polygon.maybe_valid - - -def test_is_invalid_hole_too_big_min() -> None: - e = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)] - i = [(-0.5, -0.5), (3, 1), (0.5, 1)] - polygon = geometry.Polygon(e, [i]) - - assert not polygon.maybe_valid - - -def test_is_invalid_exterior() -> None: - e = [(0, 0), (1, 0), (1, 1), (0, -1), (0, 0)] - polygon = geometry.Polygon(e) - - assert not polygon.maybe_valid - - -def test_is_invalid_interior() -> None: - e = [(-2, -2), (-2, 2), (2, 2), (2, -2), (-2, -2)] - i = [(0, 0), (1, 0), (1, 1), (0, -1), (0, 0)] - polygon = geometry.Polygon(e, [i]) - - assert not polygon.maybe_valid - - def test_empty() -> None: polygon = geometry.Polygon([]) @@ -343,9 +272,3 @@ def test_empty_bounds() -> None: polygon = geometry.Polygon([]) assert polygon.bounds == () - - -def test_maybe_valid_empty() -> None: - polygon = geometry.Polygon([]) - - assert not polygon.maybe_valid