Skip to content

Commit

Permalink
Fixing and noting change in HISTORY.
Browse files Browse the repository at this point in the history
  • Loading branch information
phargogh committed Sep 1, 2023
1 parent 879fd70 commit 0fc2daf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions HISTORY.rst
Expand Up @@ -37,6 +37,10 @@ Unreleased Changes
where the function would raise an Exception when the target raster path was
provided as a filename only, not within a directory, even though the parent
directory could be inferred. https://github.com/natcap/pygeoprocessing/issues/313
* Fixing a bug where the statistics worker in
``pygeoprocessing.raster_calculator`` may return a complex value. This is
only an issue when pygeoprocessing is compiled against Cython 3.0.0 and
later. https://github.com/natcap/pygeoprocessing/issues/342

2.4.0 (2023-03-03)
------------------
Expand Down
5 changes: 5 additions & 0 deletions src/pygeoprocessing/geoprocessing.py
Expand Up @@ -610,6 +610,11 @@ def raster_calculator(
payload = stats_worker_queue.get(True, max_timeout)
if payload is not None:
target_min, target_max, target_mean, target_stddev = payload
# In Cython 3.0.0+, taking a square root may return a complex.
# Using only the real component of the complex value mimics the
# C behavior that we expect from our stats worker.
if isinstance(target_stddev, complex):
target_stddev = target_stddev.real
target_band.SetStatistics(
float(target_min), float(target_max), float(target_mean),
float(target_stddev))
Expand Down

0 comments on commit 0fc2daf

Please sign in to comment.