From ab5fc73f145385de07c0c0e95652513cf72e1f22 Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 13:46:10 +0000 Subject: [PATCH 01/20] Add 'shapely>=1.7,<2.0' --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 93b887152..b1d2cba54 100644 --- a/setup.py +++ b/setup.py @@ -28,6 +28,7 @@ def get_version(): 'carto>=1.11.3,<2.0', 'jinja2>=2.10.1,<3.0', 'pandas>=0.25.0', + 'shapely>=1.7,<2.0', 'geopandas>=0.6.0,<1.0', 'unidecode>=1.1.0,<2.0', 'semantic_version>=2.8.0,<3' From 2de0acb91939f6bf130ba6a7716821341baca2fa Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 14:20:45 +0000 Subject: [PATCH 02/20] Spliting dependencies --- .github/workflows/cartoframes-ci.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cartoframes-ci.yml b/.github/workflows/cartoframes-ci.yml index eb8b8ef71..0d88e10cf 100644 --- a/.github/workflows/cartoframes-ci.yml +++ b/.github/workflows/cartoframes-ci.yml @@ -25,12 +25,14 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install tox - pip install tox-gh-actions - + - run: echo "Installing dependencies" + - name: Install dependencies (pip) + run: python -m pip install --upgrade pip + - name: Install dependencies (tox) + run: pip install tox + - name: Install dependencies (tox-gh-actions) + run: pip install tox-gh-actions + - run: echo "Dependencies installed" - name: Test with tox run: | tox From 9d3f3eca81bde29a0479705aecbe1107706fac6b Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 14:26:39 +0000 Subject: [PATCH 03/20] Install random library --- .github/workflows/cartoframes-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cartoframes-ci.yml b/.github/workflows/cartoframes-ci.yml index 0d88e10cf..0921e1613 100644 --- a/.github/workflows/cartoframes-ci.yml +++ b/.github/workflows/cartoframes-ci.yml @@ -28,6 +28,8 @@ jobs: - run: echo "Installing dependencies" - name: Install dependencies (pip) run: python -m pip install --upgrade pip + - name: Install dependencies (pandas) + run: pip install pandas - name: Install dependencies (tox) run: pip install tox - name: Install dependencies (tox-gh-actions) From e58c546d58e97d4f6e0aac170f34492652f24112 Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 14:28:56 +0000 Subject: [PATCH 04/20] Try fail fast strategy --- .github/workflows/cartoframes-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cartoframes-ci.yml b/.github/workflows/cartoframes-ci.yml index 0921e1613..1f1e7e6c8 100644 --- a/.github/workflows/cartoframes-ci.yml +++ b/.github/workflows/cartoframes-ci.yml @@ -10,6 +10,7 @@ on: jobs: test: strategy: + fail-fast: false matrix: python-version: [3.5, 3.6, 3.7, 3.8] From 9dda74322315accfdbabc7df1239c5c8bb2889eb Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 14:40:56 +0000 Subject: [PATCH 05/20] Minor fixes --- .github/workflows/cartoframes-ci.yml | 16 ++++++---------- cartoframes/data/observatory/catalog/dataset.py | 5 +++-- cartoframes/io/managers/context_manager.py | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/cartoframes-ci.yml b/.github/workflows/cartoframes-ci.yml index 1f1e7e6c8..2a6277c31 100644 --- a/.github/workflows/cartoframes-ci.yml +++ b/.github/workflows/cartoframes-ci.yml @@ -26,16 +26,12 @@ jobs: with: python-version: ${{ matrix.python-version }} - - run: echo "Installing dependencies" - - name: Install dependencies (pip) - run: python -m pip install --upgrade pip - - name: Install dependencies (pandas) - run: pip install pandas - - name: Install dependencies (tox) - run: pip install tox - - name: Install dependencies (tox-gh-actions) - run: pip install tox-gh-actions - - run: echo "Dependencies installed" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox + pip install tox-gh-actions + - name: Test with tox run: | tox diff --git a/cartoframes/data/observatory/catalog/dataset.py b/cartoframes/data/observatory/catalog/dataset.py index 908786bee..ced41526b 100644 --- a/cartoframes/data/observatory/catalog/dataset.py +++ b/cartoframes/data/observatory/catalog/dataset.py @@ -500,8 +500,9 @@ def subscribe(self, credentials=None): @check_do_enabled def subscription_info(self, credentials=None): - """Get the subscription information of a Dataset, which includes the license, Terms of Service, rights, price, and - estimated time of delivery, among other metadata of interest during the :py:attr:`Dataset.subscription` process. + """Get the subscription information of a Dataset, which includes the license, Terms of Service, rights, price, + and estimated time of delivery, among other metadata of interest during the :py:attr:`Dataset.subscription` + process. Args: credentials (:py:class:`Credentials `, optional): diff --git a/cartoframes/io/managers/context_manager.py b/cartoframes/io/managers/context_manager.py index 360998bd7..ef2b11dc2 100644 --- a/cartoframes/io/managers/context_manager.py +++ b/cartoframes/io/managers/context_manager.py @@ -168,7 +168,7 @@ def has_table(self, table_name, schema=None): def delete_table(self, table_name): query = _drop_table_query(table_name) output = self.execute_query(query) - return not('notices' in output and 'does not exist' in output['notices'][0]) + return not ('notices' in output and 'does not exist' in output['notices'][0]) def _delete_function(self, function_name): query = _drop_function_query(function_name) From 5d5859ac409c3eae8269686ca61fa036b22dcdcd Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 15:36:10 +0000 Subject: [PATCH 06/20] Downgrade markupsafe version --- tox.ini | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tox.ini b/tox.ini index 05fe93d52..78fb0ec40 100644 --- a/tox.ini +++ b/tox.ini @@ -10,6 +10,7 @@ python = [testenv] deps = + markupsafe==2.0.1 flake8 pytest pytest-mock @@ -20,6 +21,7 @@ commands = [testenv:unit] deps = + markupsafe==2.0.1 flake8 pytest pytest-mock @@ -30,6 +32,7 @@ commands = [testenv:e2e] deps = + markupsafe==2.0.1 flake8 pytest commands = @@ -39,6 +42,7 @@ commands = [testenv:cov] deps = + markupsafe==2.0.1 pytest pytest-mock pytest-cov @@ -48,6 +52,7 @@ commands = [testenv:cov-html] deps = + markupsafe==2.0.1 pytest pytest-mock pytest-cov From 76bcb744386fbce5aabe19d55d2289905061c5e8 Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 15:44:43 +0000 Subject: [PATCH 07/20] Try ubuntu 20.04 --- .github/workflows/cartoframes-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cartoframes-ci.yml b/.github/workflows/cartoframes-ci.yml index 2a6277c31..15205c2fc 100644 --- a/.github/workflows/cartoframes-ci.yml +++ b/.github/workflows/cartoframes-ci.yml @@ -16,7 +16,7 @@ jobs: name: Run tests on Python ${{ matrix.python-version }} - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 From b251b74f810500968afeb5d4a9d1b13596925938 Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 15:52:00 +0000 Subject: [PATCH 08/20] Change matrix --- .github/workflows/cartoframes-ci.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cartoframes-ci.yml b/.github/workflows/cartoframes-ci.yml index 15205c2fc..5d75bd16d 100644 --- a/.github/workflows/cartoframes-ci.yml +++ b/.github/workflows/cartoframes-ci.yml @@ -12,11 +12,19 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.5, 3.6, 3.7, 3.8] + include: + - os: ubuntu-20.04 + python-version: 3.5 + - os: ubuntu-20.04 + python-version: 3.6 + - os: ubuntu-latest + python-version: 3.7 + - os: ubuntu-latest + python-version: 3.8 name: Run tests on Python ${{ matrix.python-version }} - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 From cc0237bfdc7c95522ec91a43aaaa33b7937f1e16 Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 16:00:55 +0000 Subject: [PATCH 09/20] Test another version --- .github/workflows/cartoframes-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cartoframes-ci.yml b/.github/workflows/cartoframes-ci.yml index 5d75bd16d..5e0b88dd0 100644 --- a/.github/workflows/cartoframes-ci.yml +++ b/.github/workflows/cartoframes-ci.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-20.04 + - os: ubuntu-18.04 python-version: 3.5 - os: ubuntu-20.04 python-version: 3.6 From 5233119bcc9d1d9e02781d85734029fc3702081c Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 16:37:02 +0000 Subject: [PATCH 10/20] Update versions --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index b1d2cba54..97eca6234 100644 --- a/setup.py +++ b/setup.py @@ -27,9 +27,9 @@ def get_version(): 'appdirs>=1.4.3,<2.0', 'carto>=1.11.3,<2.0', 'jinja2>=2.10.1,<3.0', - 'pandas>=0.25.0', - 'shapely>=1.7,<2.0', - 'geopandas>=0.6.0,<1.0', + 'pandas>=0.25.0,<=1.3.2', + 'shapely>=1.7,<=1.7.1', + 'geopandas>=0.6.0,<=0.9.0', 'unidecode>=1.1.0,<2.0', 'semantic_version>=2.8.0,<3' ] From 72628a93cca6c7180b4e50700ff465a244a9b3cb Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 16:41:51 +0000 Subject: [PATCH 11/20] Update versions --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 97eca6234..93a4e6518 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ def get_version(): 'carto>=1.11.3,<2.0', 'jinja2>=2.10.1,<3.0', 'pandas>=0.25.0,<=1.3.2', - 'shapely>=1.7,<=1.7.1', + 'shapely>=1.7,<=1.8.4', 'geopandas>=0.6.0,<=0.9.0', 'unidecode>=1.1.0,<2.0', 'semantic_version>=2.8.0,<3' From 2cd07ed98a7faa29c841e5134f56b90991267db1 Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 16:44:18 +0000 Subject: [PATCH 12/20] Update versions --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 93a4e6518..fcffedbad 100644 --- a/setup.py +++ b/setup.py @@ -27,9 +27,9 @@ def get_version(): 'appdirs>=1.4.3,<2.0', 'carto>=1.11.3,<2.0', 'jinja2>=2.10.1,<3.0', - 'pandas>=0.25.0,<=1.3.2', - 'shapely>=1.7,<=1.8.4', - 'geopandas>=0.6.0,<=0.9.0', + 'pandas>=0.25.0', + 'shapely>=1.7,<=1.7.1', + 'geopandas>=0.6.0,<1.0', 'unidecode>=1.1.0,<2.0', 'semantic_version>=2.8.0,<3' ] From 98fa23e754f887ba790a4bfccf72e8c5a4884ec2 Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 16:53:46 +0000 Subject: [PATCH 13/20] Update CI versions --- .github/workflows/cartoframes-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cartoframes-ci.yml b/.github/workflows/cartoframes-ci.yml index 5e0b88dd0..f9f172210 100644 --- a/.github/workflows/cartoframes-ci.yml +++ b/.github/workflows/cartoframes-ci.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-18.04 + - os: ubuntu-20.04 python-version: 3.5 - os: ubuntu-20.04 python-version: 3.6 @@ -27,10 +27,10 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From b25601e16b228052387f3886f5fa40f3f70f90d5 Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 16:55:54 +0000 Subject: [PATCH 14/20] Testing options --- .github/workflows/cartoframes-ci.yml | 2 +- tox.ini | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cartoframes-ci.yml b/.github/workflows/cartoframes-ci.yml index f9f172210..67a883951 100644 --- a/.github/workflows/cartoframes-ci.yml +++ b/.github/workflows/cartoframes-ci.yml @@ -15,7 +15,7 @@ jobs: include: - os: ubuntu-20.04 python-version: 3.5 - - os: ubuntu-20.04 + - os: ubuntu-latest python-version: 3.6 - os: ubuntu-latest python-version: 3.7 diff --git a/tox.ini b/tox.ini index 78fb0ec40..e6125685a 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,6 @@ python = [testenv] deps = - markupsafe==2.0.1 flake8 pytest pytest-mock From 985dcac14b724dce45c524cffafb2577e162aef4 Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 16:58:22 +0000 Subject: [PATCH 15/20] Fix dependencies versions --- .github/workflows/cartoframes-ci.yml | 2 +- tox.ini | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cartoframes-ci.yml b/.github/workflows/cartoframes-ci.yml index 67a883951..f9f172210 100644 --- a/.github/workflows/cartoframes-ci.yml +++ b/.github/workflows/cartoframes-ci.yml @@ -15,7 +15,7 @@ jobs: include: - os: ubuntu-20.04 python-version: 3.5 - - os: ubuntu-latest + - os: ubuntu-20.04 python-version: 3.6 - os: ubuntu-latest python-version: 3.7 diff --git a/tox.ini b/tox.ini index e6125685a..cbbc36071 100644 --- a/tox.ini +++ b/tox.ini @@ -10,6 +10,7 @@ python = [testenv] deps = + markupsafe<=2.0.1 flake8 pytest pytest-mock @@ -20,7 +21,7 @@ commands = [testenv:unit] deps = - markupsafe==2.0.1 + markupsafe<=2.0.1 flake8 pytest pytest-mock From 040cc277ff45d5c24ce4e494beb1da2964782554 Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 17:15:14 +0000 Subject: [PATCH 16/20] Add numpy dependency --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index fcffedbad..41f821727 100644 --- a/setup.py +++ b/setup.py @@ -27,6 +27,7 @@ def get_version(): 'appdirs>=1.4.3,<2.0', 'carto>=1.11.3,<2.0', 'jinja2>=2.10.1,<3.0', + 'numpy<=1.24.0', 'pandas>=0.25.0', 'shapely>=1.7,<=1.7.1', 'geopandas>=0.6.0,<1.0', From ce2215df7f258d0debf252aece1414c45a8dfcc4 Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 17:16:59 +0000 Subject: [PATCH 17/20] Fix dependencies versions --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 41f821727..2db982f51 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ def get_version(): 'appdirs>=1.4.3,<2.0', 'carto>=1.11.3,<2.0', 'jinja2>=2.10.1,<3.0', - 'numpy<=1.24.0', + 'numpy<=1.22.4', 'pandas>=0.25.0', 'shapely>=1.7,<=1.7.1', 'geopandas>=0.6.0,<1.0', From 4110baecad8e18a9a910e603e2794d41cbca6ab1 Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Thu, 22 Dec 2022 17:44:19 +0000 Subject: [PATCH 18/20] Update markupsafe versions --- tox.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index cbbc36071..c9d2895e8 100644 --- a/tox.ini +++ b/tox.ini @@ -32,7 +32,7 @@ commands = [testenv:e2e] deps = - markupsafe==2.0.1 + markupsafe<=2.0.1 flake8 pytest commands = @@ -42,7 +42,7 @@ commands = [testenv:cov] deps = - markupsafe==2.0.1 + markupsafe<=2.0.1 pytest pytest-mock pytest-cov @@ -52,7 +52,7 @@ commands = [testenv:cov-html] deps = - markupsafe==2.0.1 + markupsafe<=2.0.1 pytest pytest-mock pytest-cov From bb9c3b58265d4f6e19bc8f3b9619b35e42b2ada1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Mon, 6 Feb 2023 13:01:08 +0100 Subject: [PATCH 19/20] Update dependencies --- Makefile | 2 +- setup.py | 4 ++-- tests/unit/io/test_carto.py | 6 +++--- tox.ini | 5 ----- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 5456d0a20..bc2d8a337 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ init: - pip install -e . + pip install -e .[tests] test: pytest tests/unit/ diff --git a/setup.py b/setup.py index 2db982f51..5f783e75b 100644 --- a/setup.py +++ b/setup.py @@ -26,10 +26,10 @@ def get_version(): REQUIRES = [ 'appdirs>=1.4.3,<2.0', 'carto>=1.11.3,<2.0', + 'markupsafe<=2.0.1', 'jinja2>=2.10.1,<3.0', - 'numpy<=1.22.4', 'pandas>=0.25.0', - 'shapely>=1.7,<=1.7.1', + 'shapely>=1.7,<2.0', 'geopandas>=0.6.0,<1.0', 'unidecode>=1.1.0,<2.0', 'semantic_version>=2.8.0,<3' diff --git a/tests/unit/io/test_carto.py b/tests/unit/io/test_carto.py index b3638f21f..3ff84c626 100644 --- a/tests/unit/io/test_carto.py +++ b/tests/unit/io/test_carto.py @@ -5,7 +5,6 @@ from pandas import Index from geopandas import GeoDataFrame from shapely.geometry import Point -from shapely.geometry.base import BaseGeometry from shapely import wkt from carto.exceptions import CartoException @@ -83,17 +82,18 @@ def test_read_carto_basegeometry_as_null_geom_value(mocker): }) # When - gdf = read_carto('__source__', CREDENTIALS, null_geom_value=BaseGeometry()) + gdf = read_carto('__source__', CREDENTIALS, null_geom_value=None) # Then expected = GeoDataFrame({ 'cartodb_id': [1], 'the_geom': [ - BaseGeometry() + None ] }, geometry='the_geom') cm_mock.assert_called_once_with('__source__', None, None, 3) + print(expected, gdf) assert expected.equals(gdf) assert gdf.crs == 'epsg:4326' diff --git a/tox.ini b/tox.ini index c9d2895e8..05fe93d52 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,6 @@ python = [testenv] deps = - markupsafe<=2.0.1 flake8 pytest pytest-mock @@ -21,7 +20,6 @@ commands = [testenv:unit] deps = - markupsafe<=2.0.1 flake8 pytest pytest-mock @@ -32,7 +30,6 @@ commands = [testenv:e2e] deps = - markupsafe<=2.0.1 flake8 pytest commands = @@ -42,7 +39,6 @@ commands = [testenv:cov] deps = - markupsafe<=2.0.1 pytest pytest-mock pytest-cov @@ -52,7 +48,6 @@ commands = [testenv:cov-html] deps = - markupsafe<=2.0.1 pytest pytest-mock pytest-cov From db76d4dc911a62e171854185dfbd1a40cf02726d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Mon, 6 Feb 2023 13:41:36 +0100 Subject: [PATCH 20/20] Make srid functions compatible with Shapely versions --- Makefile | 4 ++++ cartoframes/utils/geom_utils.py | 19 +++++++++++++++++-- setup.py | 1 - tests/unit/utils/test_geom_utils.py | 20 ++++++++++---------- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index bc2d8a337..b6d32b9b9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,10 @@ init: + pip install -U pip pip install -e .[tests] +lint: + flake8 cartoframes tests + test: pytest tests/unit/ diff --git a/cartoframes/utils/geom_utils.py b/cartoframes/utils/geom_utils.py index dbd8d4cee..b784fed88 100644 --- a/cartoframes/utils/geom_utils.py +++ b/cartoframes/utils/geom_utils.py @@ -218,7 +218,7 @@ def _load_ewkt(egeom): srid, geom = _extract_srid(egeom) ogeom = _load_wkt(geom) if srid: - shapely.geos.lgeos.GEOSSetSRID(ogeom._geom, int(srid)) + ogeom = set_srid(ogeom, int(srid)) return ogeom @@ -241,7 +241,7 @@ def encode_geometry_ewkt(geom, srid=4326): def encode_geometry_ewkb(geom, srid=4326): if isinstance(geom, shapely.geometry.base.BaseGeometry): - shapely.geos.lgeos.GEOSSetSRID(geom._geom, srid) + geom = set_srid(geom, srid) return shapely.wkb.dumps(geom, hex=True, include_srid=True) @@ -272,3 +272,18 @@ def get_crs(gdf): return gdf.crs['init'] else: return str(gdf.crs) + + +def get_srid(geom): + if shapely.__version__ < '2.0': + return shapely.geos.lgeos.GEOSGetSRID(geom._geom) + else: + return shapely.get_srid(geom) + + +def set_srid(geom, srid): + if shapely.__version__ < '2.0': + shapely.geos.lgeos.GEOSSetSRID(geom._geom, int(srid)) + return geom + else: + return shapely.set_srid(geom, int(srid)) diff --git a/setup.py b/setup.py index 5f783e75b..705ab2b05 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,6 @@ def get_version(): 'markupsafe<=2.0.1', 'jinja2>=2.10.1,<3.0', 'pandas>=0.25.0', - 'shapely>=1.7,<2.0', 'geopandas>=0.6.0,<1.0', 'unidecode>=1.1.0,<2.0', 'semantic_version>=2.8.0,<3' diff --git a/tests/unit/utils/test_geom_utils.py b/tests/unit/utils/test_geom_utils.py index 9f0d3734c..51d12730a 100644 --- a/tests/unit/utils/test_geom_utils.py +++ b/tests/unit/utils/test_geom_utils.py @@ -3,12 +3,12 @@ import pandas as pd import geopandas as gpd -from shapely.geos import lgeos from shapely.geometry import Point from cartoframes.utils.geom_utils import (ENC_EWKT, ENC_SHAPELY, ENC_WKB, ENC_WKB_BHEX, ENC_WKB_HEX, ENC_WKT, - decode_geometry, decode_geometry_item, detect_encoding_type) + decode_geometry, decode_geometry_item, + detect_encoding_type, get_srid) class TestGeomUtils(object): @@ -92,38 +92,38 @@ def test_decode_geometry_shapely(self): def test_decode_geometry_wkb(self): geom = decode_geometry_item( b'\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00H\x93@\x00\x00\x00\x00\x00\x9d\xb6@', ENC_WKB) - assert lgeos.GEOSGetSRID(geom._geom) == 0 + assert get_srid(geom) == 0 assert geom.wkb == b'\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00H\x93@\x00\x00\x00\x00\x00\x9d\xb6@' geom = decode_geometry_item( b'\x01\x01\x00\x00 \xe6\x10\x00\x00\x00\x00\x00\x00\x00H\x93@\x00\x00\x00\x00\x00\x9d\xb6@', ENC_WKB) # ext - assert lgeos.GEOSGetSRID(geom._geom) == 4326 + assert get_srid(geom) == 4326 assert geom.wkb == b'\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00H\x93@\x00\x00\x00\x00\x00\x9d\xb6@' def test_decode_geometry_wkb_hex(self): geom = decode_geometry_item('0101000000000000000048934000000000009DB640', ENC_WKB_HEX) - assert lgeos.GEOSGetSRID(geom._geom) == 0 + assert get_srid(geom) == 0 assert geom.wkb_hex == '0101000000000000000048934000000000009DB640' geom = decode_geometry_item('0101000020E6100000000000000048934000000000009DB640', ENC_WKB_HEX) # ext - assert lgeos.GEOSGetSRID(geom._geom) == 4326 + assert get_srid(geom) == 4326 assert geom.wkb_hex == '0101000000000000000048934000000000009DB640' def test_decode_geometry_wkb_bhex(self): geom = decode_geometry_item(b'0101000000000000000048934000000000009DB640', ENC_WKB_BHEX) - assert lgeos.GEOSGetSRID(geom._geom) == 0 + assert get_srid(geom) == 0 assert geom.wkb == b'\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00H\x93@\x00\x00\x00\x00\x00\x9d\xb6@' geom = decode_geometry_item(b'0101000020E6100000000000000048934000000000009DB640', ENC_WKB_BHEX) # ext - assert lgeos.GEOSGetSRID(geom._geom) == 4326 + assert get_srid(geom) == 4326 assert geom.wkb == b'\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00H\x93@\x00\x00\x00\x00\x00\x9d\xb6@' def test_decode_geometry_wkt(self): geom = decode_geometry_item('POINT (1234 5789)', ENC_WKT) - assert lgeos.GEOSGetSRID(geom._geom) == 0 + assert get_srid(geom) == 0 assert geom.wkt == 'POINT (1234 5789)' def test_decode_geometry_ewkt(self): geom = decode_geometry_item('SRID=4326;POINT (1234 5789)', ENC_EWKT) # ext - assert lgeos.GEOSGetSRID(geom._geom) == 4326 + assert get_srid(geom) == 4326 assert geom.wkt == 'POINT (1234 5789)'