Skip to content

Commit

Permalink
Merge pull request #1672 from girder/numpy-overflow
Browse files Browse the repository at this point in the history
Fix some issues with possible numpy 2.x overflows
  • Loading branch information
manthey authored Oct 9, 2024
2 parents e334643 + 7376de2 commit 8873df9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

- Fix styling images with empty tile layers ([#1650](../../pull/1650))
- Add a guard around sorting item lists ([#1663](../../pull/1663))
- Fix some issues with possible numpy 2.x overflows ([#1672](../../pull/1672))

## 1.29.11

Expand Down
10 changes: 5 additions & 5 deletions large_image/tilesource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,11 +618,11 @@ def histogram( # noqa
if results is None or onlyMinMax:
return results
results['histogram'] = [{
'min': results['min'][idx],
'max': results['max'][idx],
'mean': results['mean'][idx],
'stdev': results['stdev'][idx],
'range': ((results['min'][idx], results['max'][idx] + 1)
'min': float(results['min'][idx]),
'max': float(results['max'][idx]),
'mean': float(results['mean'][idx]),
'stdev': float(results['stdev'][idx]),
'range': ((float(results['min'][idx]), float(results['max'][idx]) + 1)
if histRange is None or histRange == 'round' else histRange),
'hist': None,
'bin_edges': None,
Expand Down
2 changes: 1 addition & 1 deletion sources/pil/large_image_source_pil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def __init__(self, path, maxSize=None, **kwargs): # noqa
except Exception:
msg = 'PIL cannot find loader for this file.'
raise TileSourceError(msg)
maxval = 256 ** math.ceil(math.log(np.max(imgdata) + 1, 256)) - 1
maxval = 256 ** math.ceil(math.log(float(np.max(imgdata)) + 1, 256)) - 1
self._factor = 255.0 / max(maxval, 1)
self._pilImage = PIL.Image.fromarray(np.uint8(np.multiply(
imgdata, self._factor)))
Expand Down

0 comments on commit 8873df9

Please sign in to comment.