Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some issues with possible numpy 2.x overflows #1672

Merged
merged 1 commit into from
Oct 9, 2024
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
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