Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1c1845f

Browse files
committed
TEST: Check IndexedGzipFile ArrayProxys are copied properly
1 parent 65228f0 commit 1c1845f

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

‎nibabel/tests/test_arrayproxy.py‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from .. import __version__
2424
from ..arrayproxy import ArrayProxy, get_obj_dtype, is_proxy, reshape_dataobj
2525
from ..deprecator import ExpiredDeprecationError
26-
from ..nifti1 import Nifti1Header
26+
from ..nifti1 import Nifti1Header, Nifti1Image
2727
from ..openers import ImageOpener
2828
from ..testing import memmap_after_ufunc
2929
from ..tmpdirs import InTemporaryDirectory
@@ -586,3 +586,20 @@ def test_copy():
586586
copied = proxy.copy()
587587
assert islock(copied._lock)
588588
assert proxy._lock is copied._lock
589+
590+
591+
def test_copy_with_indexed_gzip_handle(tmp_path):
592+
indexed_gzip = pytest.importorskip('indexed_gzip')
593+
594+
spec = ((50, 50, 50, 50), np.float32, 352, 1, 0)
595+
data = np.arange(np.prod(spec[0]), dtype=spec[1]).reshape(spec[0])
596+
fname = str(tmp_path / 'test.nii.gz')
597+
Nifti1Image(data, np.eye(4)).to_filename(fname)
598+
599+
with indexed_gzip.IndexedGzipFile(fname) as fobj:
600+
proxy = ArrayProxy(fobj, spec)
601+
copied = proxy.copy()
602+
603+
assert proxy.file_like is copied.file_like
604+
assert np.array_equal(proxy[0, 0, 0], copied[0, 0, 0])
605+
assert np.array_equal(proxy[-1, -1, -1], copied[-1, -1, -1])

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /