Skip to content

Commit

Permalink
Merge pull request #1757 from CartoDB/release/1.2.5
Browse files Browse the repository at this point in the history
Release/1.2.5
  • Loading branch information
Shylpx authored Mar 9, 2023
2 parents 21960c1 + 13f0b3e commit 223cbf8
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 28 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/cartoframes-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,27 @@ on:
jobs:
test:
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-latest
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 }}

Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [1.2.5] - 2022-03-09

### Changed

- Add compatibility with shapely>=1.7 (#1755)

## [1.2.4] - 2021-09-02

### Changed
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
init:
pip install -e .
pip install -U pip
pip install -e .[tests]

lint:
flake8 cartoframes tests

test:
pytest tests/unit/
Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ CARTOframes

.. image:: https://github.com/CartoDB/cartoframes/actions/workflows/cartoframes-ci.yml/badge.svg?branch=develop
:target: https://github.com/CartoDB/cartoframes/actions/workflows/cartoframes-ci.yml
.. image:: https://img.shields.io/badge/pypi-v1.2.4-orange
:target: https://pypi.org/project/cartoframes/1.2.4
.. image:: https://img.shields.io/badge/pypi-v1.2.5-orange
:target: https://pypi.org/project/cartoframes/1.2.5

A Python package for integrating `CARTO <https://carto.com/>`__ maps, analysis, and data services into data science workflows.

Expand All @@ -14,11 +14,11 @@ Python data analysis workflows often rely on the de facto standards `pandas <htt
Try it Out
==========

* Stable (1.2.4): |stable|
* Stable (1.2.5): |stable|
* Latest (develop branch): |develop|

.. |stable| image:: https://mybinder.org/badge_logo.svg
:target: https://mybinder.org/v2/gh/cartodb/cartoframes/v1.2.4?filepath=examples
:target: https://mybinder.org/v2/gh/cartodb/cartoframes/v1.2.5?filepath=examples

.. |develop| image:: https://mybinder.org/badge_logo.svg
:target: https://mybinder.org/v2/gh/cartodb/cartoframes/develop?filepath=examples
Expand Down
2 changes: 1 addition & 1 deletion cartoframes/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.2.4'
__version__ = '1.2.5'
5 changes: 3 additions & 2 deletions cartoframes/data/observatory/catalog/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cartoframes.auth.Credentials>`, optional):
Expand Down
2 changes: 1 addition & 1 deletion cartoframes/io/managers/context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 17 additions & 2 deletions cartoframes/utils/geom_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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)


Expand Down Expand Up @@ -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))
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ 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',
'pandas>=0.25.0',
'geopandas>=0.6.0,<1.0',
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/io/test_carto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'

Expand Down
20 changes: 10 additions & 10 deletions tests/unit/utils/test_geom_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)'

0 comments on commit 223cbf8

Please sign in to comment.