Skip to content

Commit

Permalink
Make Tiled compatible with numpy 2.0 (#758)
Browse files Browse the repository at this point in the history
* Fix deprecated usage in tests.

* Fix deprecated usage in vendored scikit-image code

* Update CHANGELOG

* Install blosc2 on supported version of Python only.
  • Loading branch information
danielballan authored Jun 18, 2024
1 parent f5c8a5e commit bc1926f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ Write the date in place of the "Unreleased" in the case a new version is release

# Changelog

## Unreleased

### Changed

- Minor implementation changes were necessary to make Tiled compatible with
Numpy 2.0.

## v0.1.0b3 (2024-06-04)

### Added
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ all = [
"asyncpg",
"appdirs",
"awkward >=2.4.3",
"blosc2",
"blosc2; python_version >= '3.10'",
"cachetools",
"dask",
"dask[array]",
Expand Down Expand Up @@ -106,7 +106,7 @@ array = [
client = [
"appdirs",
"awkward >=2.4.3",
"blosc2",
"blosc2; python_version >= '3.10'",
"dask[array]",
"dask[dataframe]",
"entrypoints",
Expand All @@ -131,7 +131,7 @@ client = [
# These are used by the client/server to more efficiently compress.
# They fall back to gzip (which is slower) if these are not installed.
compression = [
"blosc2",
"blosc2; python_version >= '3.10'",
"lz4",
"zstandard",
]
Expand Down Expand Up @@ -228,7 +228,7 @@ server = [
"asgi-correlation-id",
"asyncpg",
"awkward >=2.4.3",
"blosc2",
"blosc2; python_version >= '3.10'",
"cachetools",
"dask",
"dask[array]",
Expand Down
6 changes: 3 additions & 3 deletions tiled/_tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
inf_tree = MapAdapter(
{
"example": ArrayAdapter.from_array(
numpy.array([0, 1, numpy.NAN, -numpy.Inf, numpy.Inf]),
metadata={"infinity": math.inf, "-infinity": -math.inf, "nan": numpy.NAN},
numpy.array([0, 1, numpy.nan, -numpy.inf, numpy.inf]),
metadata={"infinity": math.inf, "-infinity": -math.inf, "nan": numpy.nan},
)
},
metadata={"infinity": math.inf, "-infinity": -math.inf, "nan": numpy.NAN},
metadata={"infinity": math.inf, "-infinity": -math.inf, "nan": numpy.nan},
)
arr_with_zero_dim = numpy.array([]).reshape((0, 100, 1, 10))
# Suppress RuntimeWarning: divide by zero encountered in true_divide
Expand Down
2 changes: 2 additions & 0 deletions tiled/_tests/test_decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def client():


def test_zstd(client):
pytest.importorskip("zstandard")
with record_history() as h:
client["compresses_well"]
(response,) = h.responses
Expand All @@ -32,6 +33,7 @@ def test_zstd(client):


def test_blosc2(client):
pytest.importorskip("blosc2")
ac = client["compresses_well"]
with record_history() as h:
ac[:]
Expand Down
3 changes: 1 addition & 2 deletions tiled/serialization/image_serializer_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
bool: (False, True),
np.bool_: (False, True),
float: (-1, 1),
np.float_: (-1, 1),
np.float16: (-1, 1),
np.float32: (-1, 1),
np.float64: (-1, 1),
Expand Down Expand Up @@ -210,7 +209,7 @@ def _convert(image, dtype, force_copy=False, uniform=False):
# is a subclass of that type (e.g. `np.floating` will allow
# `float32` and `float64` arrays through)

if np.issubdtype(dtype_in, np.obj2sctype(dtype)):
if np.issubdtype(dtype_in, np.dtype(dtype).type):
if force_copy:
image = image.copy()
return image
Expand Down

0 comments on commit bc1926f

Please sign in to comment.