Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions .github/workflows/test-rasterstats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,17 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- 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
run: |
python -m pip install pip --upgrade
python -m pip install -e .[dev]
python -m pip install -e ".[dev]"
- name: Test all packages
run: |
pytest
- name: Test with older packages
run: |
python -m pip uninstall --yes geopandas
python -m pip install "fiona<1.9" "shapely<2.0"
pytest
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Utilities",
"Topic :: Scientific/Engineering :: GIS",
]
Expand Down
6 changes: 4 additions & 2 deletions src/rasterstats/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def gen_zonal_stats(
for pctile in [s for s in stats if s.startswith("percentile_")]:
q = get_percentile(pctile)
pctarr = masked.compressed()
feature_stats[pctile] = np.percentile(pctarr, q)
feature_stats[pctile] = float(np.percentile(pctarr, q))

if "nodata" in stats or "nan" in stats:
featmasked = np.ma.MaskedArray(fsrc.array, mask=(~rv_array))
Expand All @@ -286,7 +286,9 @@ def gen_zonal_stats(
for stat_name, stat_func in add_stats.items():
n_params = len(inspect.signature(stat_func).parameters.keys())
if n_params == 3:
feature_stats[stat_name] = stat_func(masked, feat["properties"], rv_array)
feature_stats[stat_name] = stat_func(
masked, feat["properties"], rv_array
)
# backwards compatible with two-argument function
elif n_params == 2:
feature_stats[stat_name] = stat_func(masked, feat["properties"])
Expand Down