pyogrio 0.11.0__tar.gz → 0.11.1__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.
Potentially problematic release.
This version of pyogrio might be problematic. Click here for more details.
- {pyogrio-0.11.0/pyogrio.egg-info → pyogrio-0.11.1}/PKG-INFO +1 -1
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/__init__.py +3 -1
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/_io.pyx +34 -5
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/_version.py +3 -3
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/test_geopandas_io.py +20 -3
- {pyogrio-0.11.0 → pyogrio-0.11.1/pyogrio.egg-info}/PKG-INFO +1 -1
- {pyogrio-0.11.0 → pyogrio-0.11.1}/LICENSE +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/MANIFEST.in +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/README.md +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/_compat.py +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/_env.py +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/_err.pxd +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/_err.pyx +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/_geometry.pxd +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/_geometry.pyx +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/_io.pxd +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/_ogr.pxd +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/_ogr.pyx +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/_vsi.pxd +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/_vsi.pyx +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/arrow_bridge.h +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/core.py +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/errors.py +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/geopandas.py +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/raw.py +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/__init__.py +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/conftest.py +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/fixtures/README.md +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/fixtures/curve.gpkg +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/fixtures/curvepolygon.gpkg +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/fixtures/line_zm.gpkg +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/fixtures/multisurface.gpkg +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.cpg +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.dbf +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.prj +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.shp +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.shx +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/fixtures/sample.osm.pbf +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/fixtures/test_gpkg_nulls.gpkg +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/test_arrow.py +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/test_core.py +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/test_path.py +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/test_raw_io.py +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/test_util.py +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/util.py +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio.egg-info/SOURCES.txt +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio.egg-info/dependency_links.txt +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio.egg-info/requires.txt +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio.egg-info/top_level.txt +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/pyproject.toml +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/setup.cfg +0 -0
- {pyogrio-0.11.0 → pyogrio-0.11.1}/setup.py +0 -0
|
@@ -4,7 +4,9 @@ try:
|
|
|
4
4
|
# we try importing shapely, to ensure it is imported (and it can load its
|
|
5
5
|
# own GEOS copy) before we load GDAL and its linked GEOS
|
|
6
6
|
import shapely
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
if shapely.__version__ < "2.0.0":
|
|
9
|
+
import shapely.geos
|
|
8
10
|
except Exception:
|
|
9
11
|
pass
|
|
10
12
|
|
|
@@ -771,6 +771,26 @@ cdef apply_geometry_filter(OGRLayerH ogr_layer, wkb):
|
|
|
771
771
|
OGR_G_DestroyGeometry(ogr_geometry)
|
|
772
772
|
|
|
773
773
|
|
|
774
|
+
cdef apply_skip_features(OGRLayerH ogr_layer, int skip_features):
|
|
775
|
+
"""Applies skip_features to layer.
|
|
776
|
+
|
|
777
|
+
Parameters
|
|
778
|
+
----------
|
|
779
|
+
ogr_layer : pointer to open OGR layer
|
|
780
|
+
wskip_features : int
|
|
781
|
+
"""
|
|
782
|
+
err = OGR_L_SetNextByIndex(ogr_layer, skip_features)
|
|
783
|
+
# GDAL can raise an error (depending on the format) for out-of-bound index,
|
|
784
|
+
# but `validate_feature_range()` should ensure we only pass a valid number
|
|
785
|
+
if err != OGRERR_NONE:
|
|
786
|
+
try:
|
|
787
|
+
check_last_error()
|
|
788
|
+
except CPLE_BaseError as exc:
|
|
789
|
+
raise ValueError(str(exc))
|
|
790
|
+
|
|
791
|
+
raise ValueError(f"Applying {skip_features=} raised an error")
|
|
792
|
+
|
|
793
|
+
|
|
774
794
|
cdef validate_feature_range(
|
|
775
795
|
OGRLayerH ogr_layer, int skip_features=0, int max_features=0
|
|
776
796
|
):
|
|
@@ -793,9 +813,9 @@ cdef validate_feature_range(
|
|
|
793
813
|
return 0, 0
|
|
794
814
|
|
|
795
815
|
if skip_features >= feature_count:
|
|
796
|
-
|
|
816
|
+
return 0, 0
|
|
797
817
|
|
|
798
|
-
|
|
818
|
+
if max_features == 0:
|
|
799
819
|
num_features = feature_count - skip_features
|
|
800
820
|
|
|
801
821
|
elif max_features > feature_count:
|
|
@@ -973,7 +993,7 @@ cdef get_features(
|
|
|
973
993
|
OGR_L_ResetReading(ogr_layer)
|
|
974
994
|
|
|
975
995
|
if skip_features > 0:
|
|
976
|
-
|
|
996
|
+
apply_skip_features(ogr_layer, skip_features)
|
|
977
997
|
|
|
978
998
|
if return_fids:
|
|
979
999
|
fid_data = np.empty(shape=(num_features), dtype=np.int64)
|
|
@@ -1148,7 +1168,7 @@ cdef get_bounds(OGRLayerH ogr_layer, int skip_features, int num_features):
|
|
|
1148
1168
|
OGR_L_ResetReading(ogr_layer)
|
|
1149
1169
|
|
|
1150
1170
|
if skip_features > 0:
|
|
1151
|
-
|
|
1171
|
+
apply_skip_features(ogr_layer, skip_features)
|
|
1152
1172
|
|
|
1153
1173
|
fid_data = np.empty(shape=(num_features), dtype=np.int64)
|
|
1154
1174
|
fid_view = fid_data[:]
|
|
@@ -1668,6 +1688,13 @@ def ogr_open_arrow(
|
|
|
1668
1688
|
elif mask is not None:
|
|
1669
1689
|
apply_geometry_filter(ogr_layer, mask)
|
|
1670
1690
|
|
|
1691
|
+
# Limit feature range to available range (cannot use logic of
|
|
1692
|
+
# `validate_feature_range` because max_features is not supported)
|
|
1693
|
+
if skip_features > 0:
|
|
1694
|
+
feature_count = get_feature_count(ogr_layer, 1)
|
|
1695
|
+
if skip_features >= feature_count:
|
|
1696
|
+
skip_features = feature_count
|
|
1697
|
+
|
|
1671
1698
|
# Limit to specified columns
|
|
1672
1699
|
if ignored_fields:
|
|
1673
1700
|
for field in ignored_fields:
|
|
@@ -1704,9 +1731,11 @@ def ogr_open_arrow(
|
|
|
1704
1731
|
if not OGR_L_GetArrowStream(ogr_layer, stream, options):
|
|
1705
1732
|
raise RuntimeError("Failed to open ArrowArrayStream from Layer")
|
|
1706
1733
|
|
|
1707
|
-
if skip_features:
|
|
1734
|
+
if skip_features > 0:
|
|
1708
1735
|
# only supported for GDAL >= 3.8.0; have to do this after getting
|
|
1709
1736
|
# the Arrow stream
|
|
1737
|
+
# use `OGR_L_SetNextByIndex` directly and not `apply_skip_features`
|
|
1738
|
+
# to ignore errors in case skip_features == feature_count
|
|
1710
1739
|
OGR_L_SetNextByIndex(ogr_layer, skip_features)
|
|
1711
1740
|
|
|
1712
1741
|
if use_pyarrow:
|
|
@@ -8,11 +8,11 @@ import json
|
|
|
8
8
|
|
|
9
9
|
version_json = '''
|
|
10
10
|
{
|
|
11
|
-
"date": "2025-
|
|
11
|
+
"date": "2025-08-02T21:41:37+0200",
|
|
12
12
|
"dirty": false,
|
|
13
13
|
"error": null,
|
|
14
|
-
"full-revisionid": "
|
|
15
|
-
"version": "0.11.
|
|
14
|
+
"full-revisionid": "d3ff55ba80ea5f1744d40f7502adec3658d91b15",
|
|
15
|
+
"version": "0.11.1"
|
|
16
16
|
}
|
|
17
17
|
''' # END VERSION_JSON
|
|
18
18
|
|
|
@@ -759,12 +759,22 @@ def test_read_negative_skip_features(naturalearth_lowres, use_arrow):
|
|
|
759
759
|
read_dataframe(naturalearth_lowres, skip_features=-1, use_arrow=use_arrow)
|
|
760
760
|
|
|
761
761
|
|
|
762
|
+
@pytest.mark.parametrize("skip_features", [0, 10, 200])
|
|
762
763
|
@pytest.mark.parametrize("max_features", [10, 100])
|
|
763
|
-
def test_read_max_features(
|
|
764
|
+
def test_read_max_features(
|
|
765
|
+
naturalearth_lowres_all_ext, use_arrow, max_features, skip_features
|
|
766
|
+
):
|
|
764
767
|
ext = naturalearth_lowres_all_ext.suffix
|
|
765
|
-
expected =
|
|
768
|
+
expected = (
|
|
769
|
+
read_dataframe(naturalearth_lowres_all_ext)
|
|
770
|
+
.iloc[skip_features : skip_features + max_features]
|
|
771
|
+
.reset_index(drop=True)
|
|
772
|
+
)
|
|
766
773
|
df = read_dataframe(
|
|
767
|
-
naturalearth_lowres_all_ext,
|
|
774
|
+
naturalearth_lowres_all_ext,
|
|
775
|
+
skip_features=skip_features,
|
|
776
|
+
max_features=max_features,
|
|
777
|
+
use_arrow=use_arrow,
|
|
768
778
|
)
|
|
769
779
|
|
|
770
780
|
assert len(df) == len(expected)
|
|
@@ -775,6 +785,13 @@ def test_read_max_features(naturalearth_lowres_all_ext, use_arrow, max_features)
|
|
|
775
785
|
# In .geojsonl the vertices are reordered, so normalize
|
|
776
786
|
is_jsons = ext == ".geojsonl"
|
|
777
787
|
|
|
788
|
+
if len(expected) == 0 and not use_arrow:
|
|
789
|
+
# for pandas >= 3, the column has string dtype but when reading it as
|
|
790
|
+
# empty result, it gets inferred as object dtype
|
|
791
|
+
expected["continent"] = expected["continent"].astype("object")
|
|
792
|
+
expected["name"] = expected["name"].astype("object")
|
|
793
|
+
expected["iso_a3"] = expected["iso_a3"].astype("object")
|
|
794
|
+
|
|
778
795
|
assert_geodataframe_equal(
|
|
779
796
|
df,
|
|
780
797
|
expected,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.cpg
RENAMED
|
File without changes
|
{pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.dbf
RENAMED
|
File without changes
|
{pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.prj
RENAMED
|
File without changes
|
{pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.shp
RENAMED
|
File without changes
|
{pyogrio-0.11.0 → pyogrio-0.11.1}/pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.shx
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|