From 96f2795f692adf91da495b0783e7d3d09326fad5 Mon Sep 17 00:00:00 2001 From: Genevieve Buckley <30920819+GenevieveBuckley@users.noreply.github.com> Date: Tue, 14 Mar 2023 16:41:26 +1100 Subject: [PATCH] Group all imread functions together in the same file (#290) --- dask_image/imread/__init__.py | 9 ++++++--- dask_image/imread/_utils.py | 8 -------- 2 files changed, 6 insertions(+), 11 deletions(-) delete mode 100644 dask_image/imread/_utils.py diff --git a/dask_image/imread/__init__.py b/dask_image/imread/__init__.py index 3649f147..42cfc262 100644 --- a/dask_image/imread/__init__.py +++ b/dask_image/imread/__init__.py @@ -8,8 +8,6 @@ import pims from tifffile import natural_sorted -from . import _utils - def imread(fname, nframes=1, *, arraytype="numpy"): """ @@ -98,4 +96,9 @@ def _map_read_frame(x, multiple_files, block_info=None, **kwargs): else: i, j = block_info[None]['array-location'][0] - return _utils._read_frame(fn=fn, i=slice(i, j), **kwargs) + return _read_frame(fn=fn, i=slice(i, j), **kwargs) + + +def _read_frame(fn, i, *, arrayfunc=np.asanyarray): + with pims.open(fn) as imgs: + return arrayfunc(imgs[i]) diff --git a/dask_image/imread/_utils.py b/dask_image/imread/_utils.py deleted file mode 100644 index 840233ae..00000000 --- a/dask_image/imread/_utils.py +++ /dev/null @@ -1,8 +0,0 @@ -# -*- coding: utf-8 -*- -import numpy as np -import pims - - -def _read_frame(fn, i, *, arrayfunc=np.asanyarray): - with pims.open(fn) as imgs: - return arrayfunc(imgs[i])