[Git][debian-gis-team/python-geojson][upstream] New upstream version 3.1.0
Bas Couwenberg (@sebastic)
gitlab at salsa.debian.org
Mon Nov 6 04:38:57 GMT 2023
Bas Couwenberg pushed to branch upstream at Debian GIS Project / python-geojson
Commits:
39e7aac5 by Bas Couwenberg at 2023-11-06T05:27:08+01:00
New upstream version 3.1.0
- - - - -
15 changed files:
- + .flake8
- + .github/workflows/lint.yml
- .github/workflows/test.yml
- .gitignore
- .pre-commit-config.yaml
- CHANGELOG.rst
- README.rst
- geojson/_version.py
- geojson/examples.py
- geojson/feature.py
- geojson/utils.py
- setup.py
- tests/data.geojson
- tests/test_utils.py
- tox.ini
Changes:
=====================================
.flake8
=====================================
@@ -0,0 +1,2 @@
+[flake8]
+max-line-length = 100
=====================================
.github/workflows/lint.yml
=====================================
@@ -0,0 +1,19 @@
+name: Lint
+
+on: [push, pull_request, workflow_dispatch]
+
+permissions:
+ contents: read
+
+jobs:
+ lint:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout at v3
+
+ - uses: actions/setup-python at v4
+ with:
+ python-version: "3.x"
+
+ - uses: pre-commit/action at v3.0.0
=====================================
.github/workflows/test.yml
=====================================
@@ -1,14 +1,17 @@
name: Test
-on: [push, pull_request]
+on: [push, pull_request, workflow_dispatch]
+
+env:
+ FORCE_COLOR: 1
jobs:
build:
runs-on: ubuntu-latest
strategy:
- max-parallel: 6
+ fail-fast: false
matrix:
- python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', 'pypy-3.8']
+ python-version: ['pypy3.9', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout at v3
@@ -17,30 +20,18 @@ jobs:
uses: actions/setup-python at v4
with:
python-version: ${{ matrix.python-version }}
-
- - name: Get pip cache dir
- id: pip-cache
- run: |
- echo "::set-output name=dir::$(pip cache dir)"
-
- - name: Cache
- uses: actions/cache at v3
- with:
- path: ${{ steps.pip-cache.outputs.dir }}
- key:
- ${{ matrix.os }}-${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.py') }}
- restore-keys: |
- ${{ matrix.os }}-${{ matrix.python-version }}-v1-
+ allow-prereleases: true
+ cache: pip
+ cache-dependency-path: tox.ini
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- python -m pip install --upgrade codecov
+ python -m pip install --upgrade tox
- name: Tests
run: |
- coverage run --branch --source=geojson setup.py test
- coverage xml
+ tox -e py
- name: Upload coverage
uses: codecov/codecov-action at v3
=====================================
.gitignore
=====================================
@@ -6,3 +6,7 @@ sdist/
*.egg-info/
*.egg
.tox/
+.coverage
+coverage.xml
+.idea
+.venv*
=====================================
.pre-commit-config.yaml
=====================================
@@ -2,8 +2,21 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
+ - id: check-case-conflict
- id: check-merge-conflict
- id: check-yaml
+ - id: end-of-file-fixer
+ - id: trailing-whitespace
+
+ - repo: https://github.com/tox-dev/tox-ini-fmt
+ rev: 1.3.1
+ hooks:
+ - id: tox-ini-fmt
+
+ - repo: https://github.com/PyCQA/flake8
+ rev: 6.1.0
+ hooks:
+ - id: flake8
ci:
autoupdate_schedule: quarterly
=====================================
CHANGELOG.rst
=====================================
@@ -2,15 +2,34 @@ Changes
=======
-3.0.1 (2022-02-15)
+3.1.0
+----------
+
+- Add support for Python 3.12
+
+ - https://github.com/jazzband/geojson/pull/222
+ - https://github.com/jazzband/geojson/pull/211
+
+- CI improvements
+
+ - https://github.com/jazzband/geojson/pull/217
+ - https://github.com/jazzband/geojson/pull/212
+ - https://github.com/jazzband/geojson/pull/207
+
+- Unit test improvements
+
+ - https://github.com/jazzband/geojson/pull/215
+ - https://github.com/jazzband/geojson/pull/210
+ - https://github.com/jazzband/geojson/pull/209
+
+3.0.1 (2023-02-15)
------------------
- Add Support for Python 3.11.x minor revisions
- https://github.com/jazzband/geojson/pull/198
-
-3.0.0 (2022-01-26)
+3.0.0 (2023-01-26)
------------------
- Support for Python versions 3.7-3.11 (Python 2 no longer supported)
=====================================
README.rst
=====================================
@@ -26,7 +26,7 @@ This Python library contains:
Installation
------------
-geojson is compatible with Python 3.7 - 3.11. The recommended way to install is via pip_:
+geojson is compatible with Python 3.7 - 3.12. The recommended way to install is via pip_:
.. code::
@@ -288,7 +288,7 @@ coordinates to 6 decimal places (roughly 0.1 meters) by default and can be custo
{"coordinates": [-115.12341234, 37.12341234], "type": "Point"}
-Precision can be set at the package level by setting `geojson.geometry.DEFAULT_PRECISION`
+Precision can be set at the package level by setting `geojson.geometry.DEFAULT_PRECISION`
.. code:: python
@@ -410,7 +410,7 @@ Development
-----------
To build this project, run :code:`python setup.py build`.
-To run the unit tests, run :code:`python setup.py test`.
+To run the unit tests, run :code:`python -m pip install tox && tox`.
To run the style checks, run :code:`flake8` (install `flake8` if needed).
Credits
=====================================
geojson/_version.py
=====================================
@@ -1,2 +1,2 @@
-__version__ = "3.0.1"
+__version__ = "3.1.0"
__version_info__ = tuple(map(int, __version__.split(".")))
=====================================
geojson/examples.py
=====================================
@@ -1,3 +1,9 @@
+"""
+SimpleWebFeature is a working example of a class that satisfies the Python geo
+interface.
+"""
+
+
class SimpleWebFeature:
"""
@@ -36,12 +42,6 @@ class SimpleWebFeature:
__geo_interface__ = property(as_dict)
- """
- Create an instance of SimpleWebFeature from a dict, o. If o does not
- match a Python feature object, simply return o. This function serves as a
- json decoder hook. See coding.load().
- """
-
def create_simple_web_feature(o):
"""
=====================================
geojson/feature.py
=====================================
@@ -1,8 +1,3 @@
-"""
-SimpleWebFeature is a working example of a class that satisfies the Python geo
-interface.
-"""
-
from geojson.base import GeoJSON
=====================================
geojson/utils.py
=====================================
@@ -209,11 +209,11 @@ def generate_random(featureType, numberVertices=3,
return Polygon([points])
def clip(x, min, max):
- if(min > max):
+ if min > max:
return x
- elif(x < min):
+ elif x < min:
return min
- elif(x > max):
+ elif x > max:
return max
else:
return x
@@ -226,3 +226,5 @@ def generate_random(featureType, numberVertices=3,
if featureType == 'Polygon':
return createPoly()
+
+ raise ValueError(f"featureType: {featureType} is not supported.")
=====================================
setup.py
=====================================
@@ -16,18 +16,9 @@ else:
raise RuntimeError(f"Unable to find version string in {VERSIONFILE}.")
-def test_suite():
- import doctest
- import unittest
-
- suite = unittest.TestLoader().discover("tests")
- suite.addTest(doctest.DocFileSuite("README.rst"))
- return suite
-
-
major_version, minor_version = sys.version_info[:2]
-if not (major_version == 3 and 7 <= minor_version <= 11):
- sys.stderr.write("Sorry, only Python 3.7 - 3.11 are "
+if not (major_version == 3 and 7 <= minor_version <= 12):
+ sys.stderr.write("Sorry, only Python 3.7 - 3.12 are "
"supported at this time.\n")
exit(1)
@@ -47,8 +38,7 @@ setup(
package_dir={"geojson": "geojson"},
package_data={"geojson": ["*.rst"]},
install_requires=[],
- test_suite="setup.test_suite",
- python_requires=">=3.7, <3.12",
+ python_requires=">=3.7",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
@@ -62,6 +52,7 @@ setup(
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
+ "Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: GIS",
]
)
=====================================
tests/data.geojson
=====================================
@@ -1,7 +1,7 @@
{
"properties": {
"Ã": "Ã"
- },
+ },
"type": "Feature",
"geometry": null
}
=====================================
tests/test_utils.py
=====================================
@@ -6,7 +6,7 @@ import random
import unittest
import geojson
-from geojson.utils import generate_random
+from geojson.utils import generate_random, map_geometries
def generate_bbox():
@@ -32,6 +32,17 @@ def check_polygon_bbox(polygon, bbox):
return True
+def check_point_bbox(point, bbox):
+ min_lon, min_lat, max_lon, max_lat = bbox
+ eps = 1e-3
+ if (
+ min_lon - eps <= point["coordinates"][0] <= max_lon + eps
+ and min_lat - eps <= point["coordinates"][1] <= max_lat + eps
+ ):
+ return True
+ return False
+
+
class TestGenerateRandom(unittest.TestCase):
def test_simple_polygon(self):
for _ in range(5000):
@@ -48,3 +59,41 @@ class TestGenerateRandom(unittest.TestCase):
self.assertIsInstance(result, geojson.geometry.Polygon)
self.assertTrue(geojson.geometry.check_polygon(result))
self.assertTrue(check_polygon_bbox(result, bbox))
+
+ def test_bbox_point(self):
+ for _ in range(5000):
+ bbox = generate_bbox()
+ result = generate_random("Point", boundingBox=bbox)
+ self.assertIsInstance(result, geojson.geometry.Point)
+ self.assertTrue(geojson.geometry.check_point(result))
+ self.assertTrue(check_point_bbox(result, bbox))
+
+ def test_raise_value_error(self):
+ with self.assertRaises(ValueError):
+ generate_random("MultiPolygon")
+
+
+class TestMapGeometries(unittest.TestCase):
+ def test_with_simple_type(self):
+ new_point = map_geometries(
+ lambda g: geojson.MultiPoint([g["coordinates"]]),
+ geojson.Point((-115.81, 37.24)),
+ )
+ self.assertEqual(new_point, geojson.MultiPoint([(-115.81, 37.24)]))
+
+ def test_with_feature_collection(self):
+ new_point = map_geometries(
+ lambda g: geojson.MultiPoint([g["coordinates"]]),
+ geojson.FeatureCollection([geojson.Point((-115.81, 37.24))]),
+ )
+ self.assertEqual(
+ new_point,
+ geojson.FeatureCollection(
+ [geojson.MultiPoint([geojson.Point((-115.81, 37.24))])]
+ ),
+ )
+
+ def test_raise_value_error(self):
+ invalid_object = geojson.Feature(type="InvalidType")
+ with self.assertRaises(ValueError):
+ map_geometries(lambda g: g, invalid_object)
=====================================
tox.ini
=====================================
@@ -1,10 +1,14 @@
-# Tox (http://tox.testrun.org/) is a tool for running tests
-# in multiple virtualenvs. This configuration file will run the
-# test suite on all supported python versions. To use it, "pip install tox"
-# and then run "tox" from this directory.
-
[tox]
-envlist = py{36,37,38,39,310}, pypy3
+requires =
+ tox>=4.2
+env_list =
+ py{py3, 312, 311, 310, 39, 38, 37}
[testenv]
-commands = {envpython} setup.py test
+deps =
+ pytest
+ pytest-cov
+pass_env =
+ FORCE_COLOR
+commands =
+ {envpython} -m pytest --cov geojson --cov tests --cov-report xml {posargs}
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-geojson/-/commit/39e7aac57ece9ee5c2c968ae66967926c1d0cc92
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-geojson/-/commit/39e7aac57ece9ee5c2c968ae66967926c1d0cc92
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20231106/87cb4b90/attachment-0001.htm>
More information about the Pkg-grass-devel
mailing list