Skip to content

Commit

Permalink
Allow newer numpy versions (#697)
Browse files Browse the repository at this point in the history
* allow newer numpy versions
* fix types
* Merge branch 'master' of github.com:scalableminds/webknossos-libs into allow-new-numpy
* do not use numpy.typing module which was introduced in 1.20 to remain backwards compatible
* Merge branch 'master' into allow-new-numpy
  • Loading branch information
daniel-wer authored Apr 20, 2022
1 parent 2c68b98 commit eea6d2d
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 44 deletions.
68 changes: 31 additions & 37 deletions wkcuber/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wkcuber/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ GitPython = "^3.0.5"
imagecodecs = "^2020.5.30"
natsort = "^6.2.0"
nibabel = "^2.5.1"
numpy = "1.19.5"
numpy = "^1.19.5"
pillow = ">=6.2.1,<9.0.0"
requests = "^2.22.0"
scikit-image = "^0.18.3"
Expand Down
12 changes: 8 additions & 4 deletions wkcuber/tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,20 @@ def test_element_class_conversion(tmp_path: Path) -> None:

refresh_metadata(test_wkw_path)

check_element_class_of_layer(test_wkw_path, "prediction", "float", np.float32)
check_element_class_of_layer(test_wkw_path, "segmentation", "double", np.float64)
check_element_class_of_layer(test_wkw_path, "color", "uint24", np.uint8)
check_element_class_of_layer(
test_wkw_path, "prediction", "float", np.dtype(np.float32)
)
check_element_class_of_layer(
test_wkw_path, "segmentation", "double", np.dtype(np.float64)
)
check_element_class_of_layer(test_wkw_path, "color", "uint24", np.dtype(np.uint8))


def check_element_class_of_layer(
test_wkw_path: Path,
layer_name: str,
expected_element_class: str,
expected_dtype: type,
expected_dtype: np.dtype,
) -> None:
datasource_properties = read_datasource_properties(test_wkw_path)
layer_to_check = None
Expand Down
1 change: 0 additions & 1 deletion wkcuber/wkcuber/convert_nifti.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ def convert_nifti(
# Writing wkw compressed requires files of shape (shard_size, shard_size, shard_size)
# Pad data accordingly
padding_offset = shard_size - np.array(cube_data.shape[1:4]) % shard_size
padding_offset = (0, 0, 0)
cube_data = np.pad(
cube_data,
(
Expand Down
2 changes: 1 addition & 1 deletion wkcuber/wkcuber/convert_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def _raw_chunk_converter(
flip_axes: Optional[Union[int, Tuple[int, ...]]],
) -> None:
logging.info(f"Conversion of {bounding_box.topleft}")
source_data = np.memmap(
source_data: np.memmap = np.memmap(
source_raw_path, dtype=input_dtype, mode="r", shape=(1,) + shape, order=order
)

Expand Down

0 comments on commit eea6d2d

Please sign in to comment.