uid
stringlengths
24
24
split
stringclasses
1 value
category
stringclasses
2 values
content
stringlengths
5
482k
signature
stringlengths
1
14k
suffix
stringlengths
1
482k
prefix
stringlengths
9
14k
prefix_token_count
int64
3
5.01k
prefix_token_budget
int64
64
256
element_token_count
int64
1
292k
signature_token_count
int64
1
5.01k
prefix_context_token_count
int64
0
255
repo
stringlengths
7
112
path
stringlengths
4
208
language
stringclasses
1 value
name
stringlengths
1
218
qualname
stringlengths
1
218
start_line
int64
1
26.7k
end_line
int64
1
26.7k
signature_start_line
int64
1
26.7k
signature_end_line
int64
1
26.7k
source_hash
stringlengths
40
40
source_dataset
stringclasses
1 value
source_split
stringclasses
1 value
e9ebc1f1ad34e8543c7b031d
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_imagej_focal1(): """Test read ImageJ 205x434x425 uint8.""" fname = private_file('imagej/focal1.tif') with TiffFile(fname) as tif: assert tif.is_imagej assert tif.byteorder == '>' assert len(tif.pages) == 205 asser...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_imagej_focal1():
"""Test read ImageJ 205x434x425 uint8.""" fname = private_file('imagej/focal1.tif') with TiffFile(fname) as tif: assert tif.is_imagej assert tif.byteorder == '>' assert len(tif.pages) == 205 assert len(tif.series) == 1 # assert page properties page = tif.pages...
812, 1755, 648) assert_decode_method(page) assert_aszarr_method(series, data) assert_aszarr_method(series, data, chunkmode='page') # don't squeeze data = tif.asarray(squeeze=False) assert data.shape == (1, 1, 3, 32, 31, 1) assert_aszarr_method(series, data, squeez...
123
123
410
22
101
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_imagej_focal1
test_read_imagej_focal1
8,251
8,289
8,251
8,252
b75898cac7d39544e1cd242033c2c746b9a8895f
bigcode/the-stack
train
2f69656b255b6680de8a7e79
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_filehandle_openfile(): """Test FileHandle from open file.""" with open(FILEHANDLE_NAME, 'rb') as fhandle: with FileHandle(fhandle) as fh: assert fh.name == 'test_FileHandle.bin' assert fh.is_file assert_filehand...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_filehandle_openfile():
"""Test FileHandle from open file.""" with open(FILEHANDLE_NAME, 'rb') as fhandle: with FileHandle(fhandle) as fh: assert fh.name == 'test_FileHandle.bin' assert fh.is_file assert_filehandle(fh) assert not fhandle.closed
HANDLE_OFFSET, size=FILEHANDLE_LENGTH ) as fh: assert fh.name == 'Unnamed binary stream' assert not fh.is_file assert_filehandle(fh, offset=FILEHANDLE_OFFSET) @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_filehandle_openfile():
64
64
84
20
44
bioturing/tifffile
tests/test_tifffile.py
Python
test_filehandle_openfile
test_filehandle_openfile
3,493
3,501
3,493
3,494
0920636cea4c8d170ef06078f4b6c3a123435732
bigcode/the-stack
train
00cfcacc9ce27303d4920644
train
function
def test_func_squeeze_axes(): """Test squeeze_axes function.""" assert squeeze_axes((5, 1, 2, 1, 1), 'TZYXC') == ((5, 2, 1), 'TYX') assert squeeze_axes((1,), 'Y') == ((1,), 'Y') assert squeeze_axes((1,), 'Q') == ((1,), 'Q') assert squeeze_axes((1, 1), 'PQ') == ((1,), 'Q')
def test_func_squeeze_axes():
"""Test squeeze_axes function.""" assert squeeze_axes((5, 1, 2, 1, 1), 'TZYXC') == ((5, 2, 1), 'TYX') assert squeeze_axes((1,), 'Y') == ((1,), 'Y') assert squeeze_axes((1,), 'Q') == ((1,), 'Q') assert squeeze_axes((1, 1), 'PQ') == ((1,), 'Q')
(1) == (1,) assert sequence([1]) == [1] def test_func_product(): """Test product function.""" assert product([2**8, 2**30]) == 274877906944 assert product([]) == 1 def test_func_squeeze_axes():
64
64
106
7
56
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_squeeze_axes
test_func_squeeze_axes
2,589
2,594
2,589
2,589
17ebe4058f7f16d6bf048956f3b606cf62ae4150
bigcode/the-stack
train
b43e146d4e86258593aec872
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_embed_mm_filehandle(): """Test embedded MicroManager TIFF from FileHandle.""" with FileHandle(EMBED_NAME, offset=EMBED_OFFSET1, size=EMBED_SIZE1) as fh: with TiffFile(fh) as tif: assert_embed_micromanager(tif)
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_embed_mm_filehandle():
"""Test embedded MicroManager TIFF from FileHandle.""" with FileHandle(EMBED_NAME, offset=EMBED_OFFSET1, size=EMBED_SIZE1) as fh: with TiffFile(fh) as tif: assert_embed_micromanager(tif)
, 'rb') as fh: fh.seek(EMBED_OFFSET1) with TiffFile(fh, size=EMBED_SIZE1) as tif: assert_embed_micromanager(tif) @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_embed_mm_filehandle():
64
64
78
20
44
bioturing/tifffile
tests/test_tifffile.py
Python
test_embed_mm_filehandle
test_embed_mm_filehandle
14,001
14,006
14,001
14,002
6b763b95169c3d28be3ca948d2676c3c82229d70
bigcode/the-stack
train
4977cec743b48c675334fabf
train
function
@pytest.mark.skipif( SKIP_HTTP or SKIP_ZARR or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON, ) @pytest.mark.parametrize('version', [0, 1]) def test_write_fsspec(version): """Test write fsspec for multi-series OME-TIFF.""" try: from imagecodecs.numcodecs import register_codecs except Im...
@pytest.mark.skipif( SKIP_HTTP or SKIP_ZARR or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON, ) @pytest.mark.parametrize('version', [0, 1]) def test_write_fsspec(version):
"""Test write fsspec for multi-series OME-TIFF.""" try: from imagecodecs.numcodecs import register_codecs except ImportError: register_codecs = None else: register_codecs('imagecodecs_delta', verbose=False) data0 = random_data(numpy.uint8, (3, 252, 244)) data1 = random_d...
assert_array_equal( data1, imread(fname, key=range(105), series=2).reshape(data1.shape) ) assert_array_equal( data1[0], imread(fname, key=slice(107, 122)).reshape(data1[0].shape), ) def assert_fsspec(url, data, target_protocol='http'): """Assert fsspec ...
256
256
962
54
202
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_fsspec
test_write_fsspec
12,873
12,973
12,873
12,878
8e8bce13a461e3489bceb6be6a8275350a7723b3
bigcode/the-stack
train
4064971970086d8763c9c6da
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_sequence_name_list(): """Test TiffSequence with list of file names without pattern.""" fname = [ private_file('TiffSequence/AT3_1m4_01.tif'), private_file('TiffSequence/AT3_1m4_10.tif'), ] tifs = TiffSequence(fname,...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_sequence_name_list():
"""Test TiffSequence with list of file names without pattern.""" fname = [ private_file('TiffSequence/AT3_1m4_01.tif'), private_file('TiffSequence/AT3_1m4_10.tif'), ] tifs = TiffSequence(fname, pattern=None) assert len(tifs) == 2 assert tifs.shape == (2,) assert tifs.axes == ...
256] == 135 if not SKIP_ZARR: with tifs.aszarr() as store: assert_array_equal(data, zarr.open(store, mode='r')) @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_sequence_name_list():
65
66
221
24
41
bioturing/tifffile
tests/test_tifffile.py
Python
test_sequence_name_list
test_sequence_name_list
14,052
14,071
14,052
14,053
1d823a2d69d6d72fa50f82c3f51d943c593f44d8
bigcode/the-stack
train
d21ad712d30f0465ce1cb867
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_imagej_first_instar_brain(): """Test read ImageJ 56x256x256x3 ZYXS.""" fname = private_file('imagej/first-instar-brain.tif') with TiffFile(fname) as tif: assert tif.is_imagej assert tif.byteorder == '>' assert len(tif.pag...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_imagej_first_instar_brain():
"""Test read ImageJ 56x256x256x3 ZYXS.""" fname = private_file('imagej/first-instar-brain.tif') with TiffFile(fname) as tif: assert tif.is_imagej assert tif.byteorder == '>' assert len(tif.pages) == 56 assert len(tif.series) == 1 # assert page properties page ...
assert data[113, 97, 61] == 255 assert_aszarr_method(series, data) # don't squeeze data = tif.asarray(squeeze=False) assert data.shape == (114, 1, 1, 1, 154, 121, 1) assert_aszarr_method(series, data, squeeze=False) assert__str__(tif) @pytest.mark.skipif(SKIP_PRI...
112
112
374
24
88
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_imagej_first_instar_brain
test_read_imagej_first_instar_brain
8,509
8,544
8,509
8,510
316b0364b476b39730873c82aedcbe6338f069cd
bigcode/the-stack
train
ea33f6caed727e27144d9013
train
function
def test_write_bitspersample_fail(): """Test write with packints fails.""" data = numpy.arange(32 * 32 * 3, dtype=numpy.uint32).reshape((32, 32, 3)) with TempFileName('write_bitspersample_fail') as fname: with TiffWriter(fname) as tif: # not working with compression with pyte...
def test_write_bitspersample_fail():
"""Test write with packints fails.""" data = numpy.arange(32 * 32 * 3, dtype=numpy.uint32).reshape((32, 32, 3)) with TempFileName('write_bitspersample_fail') as fname: with TiffWriter(fname) as tif: # not working with compression with pytest.raises(ValueError): ...
as fname: # TODO: enable all cases once imagecodecs.packints_encode works if bps == dtype.itemsize * 8: imwrite(fname, data, bitspersample=bps, photometric=RGB) assert_array_equal(imread(fname), data) else: with pytest.raises(NotImplementedError): ...
106
106
355
8
98
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_bitspersample_fail
test_write_bitspersample_fail
10,530
10,575
10,530
10,530
228ea511068e783cbc2d5c930c456d42f144a7f6
bigcode/the-stack
train
c1697333fef6322a170d0d83
train
function
@pytest.mark.parametrize( 'shape, storedshape, dtype, axes, error', [ # separate and contig ((32, 32), (1, 2, 1, 32, 32, 2), numpy.uint8, None, ValueError), # depth ((32, 32, 32), (1, 1, 32, 32, 32, 1), numpy.uint8, None, OmeXmlError), # dtype ((32, 32), (1, 1, 1,...
@pytest.mark.parametrize( 'shape, storedshape, dtype, axes, error', [ # separate and contig ((32, 32), (1, 2, 1, 32, 32, 2), numpy.uint8, None, ValueError), # depth ((32, 32, 32), (1, 1, 32, 32, 32, 1), numpy.uint8, None, OmeXmlError), # dtype ((32, 32), (1, 1, 1,...
"""Test OmeXml class failures.""" metadata = {'axes': axes} if axes else {} ox = OmeXml() with pytest.raises(error): ox.addimage(dtype, shape, storedshape, **metadata)
@pytest.mark.parametrize( 'shape, storedshape, dtype, axes, error', [ # separate and contig ((32, 32), (1, 2, 1, 32, 32, 2), numpy.uint8, None, ValueError), # depth ((32, 32, 32), (1, 1, 32, 32, 32, 1), numpy.uint8, None, OmeXmlError), # dtype ((32, 32), (1, 1, 1,...
975
256
1,021
975
0
bioturing/tifffile
tests/test_tifffile.py
Python
test_class_omexml_fail
test_class_omexml_fail
2,009
2,083
2,009
2,078
6c00720e43dbf0cf4f586a18b605db273b1d8fbb
bigcode/the-stack
train
70950237cadd824a48fdacec
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_embed_mm_filename(): """Test embedded MicroManager TIFF from file name.""" with TiffFile(EMBED_NAME, offset=EMBED_OFFSET1, size=EMBED_SIZE1) as tif: assert_embed_micromanager(tif)
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_embed_mm_filename():
"""Test embedded MicroManager TIFF from file name.""" with TiffFile(EMBED_NAME, offset=EMBED_OFFSET1, size=EMBED_SIZE1) as tif: assert_embed_micromanager(tif)
as fh: fh2 = BytesIO(fh.read()) with TiffFile(fh2, offset=EMBED_OFFSET, size=EMBED_SIZE) as tif: assert_embed_tif(tif) @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_embed_mm_filename():
64
64
67
19
45
bioturing/tifffile
tests/test_tifffile.py
Python
test_embed_mm_filename
test_embed_mm_filename
13,977
13,981
13,977
13,978
088956861270d66448540f94605425aab8c31ac1
bigcode/the-stack
train
484a53d6dfa45a19a6307fc7
train
function
@pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_read_ndpi_cmu1(): """Test read Hamamatsu NDPI slide, JPEG.""" fname = private_file('HamamatsuNDPI/CMU-1.ndpi') with TiffFile(fname) as tif: assert tif.is_ndpi assert len(tif.pages) == 5 ...
@pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_read_ndpi_cmu1():
"""Test read Hamamatsu NDPI slide, JPEG.""" fname = private_file('HamamatsuNDPI/CMU-1.ndpi') with TiffFile(fname) as tif: assert tif.is_ndpi assert len(tif.pages) == 5 assert len(tif.series) == 2 for page in tif.pages: assert page.ndpi_tags['Model'] == 'NanoZoomer...
, 1112, 1148) assert data.dtype == numpy.uint16 assert data[4, 64, 128] == 98 assert_aszarr_method(tif, data) assert__str__(tif) @pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_read_ndpi_cmu1():
90
90
303
37
53
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_ndpi_cmu1
test_read_ndpi_cmu1
6,537
6,565
6,537
6,540
2acab2b23aca3b652c3f9ee9f9880006d0f110ff
bigcode/the-stack
train
98958ff780df67d63779950b
train
function
@pytest.mark.skipif(SKIP_CODECS, reason=REASON) @pytest.mark.parametrize('dtype', [numpy.uint16, numpy.float32]) def test_write_compression_predictor_tiled(dtype): """Test write horizontal differencing with tiles.""" dtype = numpy.dtype(dtype) data = WRITE_DATA.astype(dtype) with TempFileName(f'compress...
@pytest.mark.skipif(SKIP_CODECS, reason=REASON) @pytest.mark.parametrize('dtype', [numpy.uint16, numpy.float32]) def test_write_compression_predictor_tiled(dtype):
"""Test write horizontal differencing with tiles.""" dtype = numpy.dtype(dtype) data = WRITE_DATA.astype(dtype) with TempFileName(f'compression_tiled_predictor_{dtype}') as fname: imwrite( fname, data, compression=ADOBE_DEFLATE, predictor=True, ...
ength == 219 assert page.samplesperpixel == 3 image = tif.asarray() assert_array_equal(data, image) assert_aszarr_method(tif, image) assert__str__(tif) @pytest.mark.skipif(SKIP_CODECS, reason=REASON) @pytest.mark.parametrize('dtype', [numpy.uint16, numpy.float...
88
88
295
40
48
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_compression_predictor_tiled
test_write_compression_predictor_tiled
11,065
11,097
11,065
11,067
0821961590fbc484324e6ace36aa561a630004b7
bigcode/the-stack
train
e177478e9b13463c14c2010b
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_ome_time_series(): """Test read OME time-series of images.""" # 3D (7 time points) fname = public_file('OME/bioformats-artificial/time-series.ome.tiff') with TiffFile(fname) as tif: assert tif.is_ome assert tif.byteorder == '>...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_ome_time_series():
"""Test read OME time-series of images.""" # 3D (7 time points) fname = public_file('OME/bioformats-artificial/time-series.ome.tiff') with TiffFile(fname) as tif: assert tif.is_ome assert tif.byteorder == '>' assert len(tif.pages) == 7 assert len(tif.series) == 1 ...
.is_multifile # assert data data = tif.asarray() assert isinstance(data, numpy.ndarray) assert data.shape == (3, 5, 167, 439) assert data.dtype == numpy.int8 assert data[2, 4, 158, 428] == 91 assert_aszarr_method(tif, data) assert__str__(tif) @pytest.mark....
109
109
365
21
88
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_ome_time_series
test_read_ome_time_series
7,208
7,242
7,208
7,209
8ccc62e122e8a0a5595632a8f8e52c7292801dfa
bigcode/the-stack
train
da08cfbe31123b3add5505fe
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_read_freeimage(): """Test read 3 series in 3 pages RGB LZW.""" fname = private_file('freeimage.tif') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 3 assert len(tif.series) == ...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_read_freeimage():
"""Test read 3 series in 3 pages RGB LZW.""" fname = private_file('freeimage.tif') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 3 assert len(tif.series) == 3 for i, shape in enumerate(((100, 600), (379, 574), (689, 636))): seri...
10) assert data.dtype == numpy.float32 assert round(abs(data[9, 9] - 223.1648712158203), 7) == 0 assert_aszarr_method(tif, data, series=3) assert__str__(tif) @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_read_freeimage():
86
86
287
24
62
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_freeimage
test_read_freeimage
4,637
4,664
4,637
4,638
80fc18db1c2b014122d48ec9f167fb78c64f2c70
bigcode/the-stack
train
9a72d0a478e59ca96cc3377f
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_issue_lzw_corrupt(): """Test decoding corrupted LZW segment raises RuntimeError.""" # reported by S Richter on 2020.2.17 fname = private_file('issues/lzw_corrupt.tiff') with pytest.raises(RuntimeError): with TiffFile(fname)...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_issue_lzw_corrupt():
"""Test decoding corrupted LZW segment raises RuntimeError.""" # reported by S Richter on 2020.2.17 fname = private_file('issues/lzw_corrupt.tiff') with pytest.raises(RuntimeError): with TiffFile(fname) as tif: tif.asarray()
*.tif', container=fname, pattern=None) as tifs: im = tifs.asarray() assert im[9, 256, 256] == 135 @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_issue_lzw_corrupt():
64
64
88
26
37
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_lzw_corrupt
test_issue_lzw_corrupt
1,036
1,043
1,036
1,037
e77361ece318ba917d87c6a4f820e2dee3e78aa4
bigcode/the-stack
train
c358e0fe3284281cf0dc35a7
train
function
def test_issue_imagej_colormap(): """Test writing 32-bit imagej file with colormap.""" # https://github.com/cgohlke/tifffile/issues/115 colormap = numpy.vstack( [ numpy.zeros(256, dtype='uint16'), numpy.arange(0, 2**16, 2**8, dtype='uint16'), numpy.arange(0, 2**16...
def test_issue_imagej_colormap():
"""Test writing 32-bit imagej file with colormap.""" # https://github.com/cgohlke/tifffile/issues/115 colormap = numpy.vstack( [ numpy.zeros(256, dtype='uint16'), numpy.arange(0, 2**16, 2**8, dtype='uint16'), numpy.arange(0, 2**16, 2**8, dtype='uint16'), ]...
description' assert page.description1 == '' assert page.tags.get(270).value == '1st description' assert page.tags.get(270, index=1).value == b'\1\128\0' assert page.tags.get(270, index=2).value == b'\2\128\0' def test_issue_imagej_colormap():
76
76
254
8
68
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_imagej_colormap
test_issue_imagej_colormap
1,657
1,680
1,657
1,657
c0aca01c52a68033b1e5d0c3635eeeb35a3ac462
bigcode/the-stack
train
ffae2c6b94b7b228f01c99bc
train
function
@pytest.mark.parametrize( 'args', [ (0, 0), (1, 1), (2, NONE), (3, ADOBE_DEFLATE), (4, 'zlib'), (5, 'zlib', 5), (6, 'zlib', 5, {'out': None}), (7, 'zlib', None, {'level': 5}), ], ) def test_write_compression_args(args): """Test compression ...
@pytest.mark.parametrize( 'args', [ (0, 0), (1, 1), (2, NONE), (3, ADOBE_DEFLATE), (4, 'zlib'), (5, 'zlib', 5), (6, 'zlib', 5, {'out': None}), (7, 'zlib', None, {'level': 5}), ], ) def test_write_compression_args(args):
"""Test compression parameter.""" i = args[0] compressionargs = args[1:] compressed = compressionargs[0] not in (0, 1, NONE) if len(compressionargs) == 1: compressionargs = compressionargs[0] data = WRITE_DATA with TempFileName(f'compression_args_{i}') as fname: imwrite(fnam...
@pytest.mark.parametrize( 'args', [ (0, 0), (1, 1), (2, NONE), (3, ADOBE_DEFLATE), (4, 'zlib'), (5, 'zlib', 5), (6, 'zlib', 5, {'out': None}), (7, 'zlib', None, {'level': 5}), ], ) def test_write_compression_args(args):
103
102
341
103
0
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_compression_args
test_write_compression_args
10,640
10,677
10,640
10,653
373bd200b3c154dd259c4f484658101938483182
bigcode/the-stack
train
476ebb21e2bf08857fc2a218
train
function
def test_write_imagej_voxel_size(): """Test write ImageJ with xyz voxel size 2.6755x2.6755x3.9474 µm^3.""" data = numpy.zeros((4, 256, 256), dtype=numpy.float32) data.shape = 4, 1, 256, 256 with TempFileName('imagej_voxel_size') as fname: imwrite( fname, data, ...
def test_write_imagej_voxel_size():
"""Test write ImageJ with xyz voxel size 2.6755x2.6755x3.9474 µm^3.""" data = numpy.zeros((4, 256, 256), dtype=numpy.float32) data.shape = 4, 1, 256, 256 with TempFileName('imagej_voxel_size') as fname: imwrite( fname, data, imagej=True, resolution...
str(shape).replace(' ', '') ) with TempFileName(fname) as fname: imwrite(fname, data, byteorder=byteorder, imagej=True) image = imread(fname) assert_array_equal(data.squeeze(), image.squeeze()) # TODO: assert_aszarr_method assert_valid_tiff(fname) def test_write_imagej_v...
79
79
264
9
70
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_imagej_voxel_size
test_write_imagej_voxel_size
13,100
13,122
13,100
13,100
f9c24a611628321706f4b78dd791debf89450db5
bigcode/the-stack
train
5f5f83fca09975d1f5b74c6a
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_read_srtm_20_13(): """Test read 6000x6000 int16 GDAL.""" fname = private_file('large/srtm_20_13.tif') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.series) == ...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_read_srtm_20_13():
"""Test read 6000x6000 int16 GDAL.""" fname = private_file('large/srtm_20_13.tif') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.series) == 1 # assert page properties page = tif.pages[0] assert page.is_conti...
assert data.shape == (18710, 13228) assert data.dtype == numpy.bool8 assert data[0, 0] is numpy.bool8(True) assert data[5000, 5000] is numpy.bool8(False) if not SKIP_LARGE: assert_aszarr_method(tif, data) assert__str__(tif) @pytest.mark.skipif(SKIP_PRIVATE or SKIP_LA...
109
109
366
29
80
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_srtm_20_13
test_read_srtm_20_13
5,525
5,559
5,525
5,526
137e646a4bfb1c90e616135df69bcb767a14a2ea
bigcode/the-stack
train
6696bdcf4f03985ba3f902ea
train
function
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_read_generic_series(): """Test read 4 series in 6 pages.""" fname = public_file('tifffile/generic_series.tif') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 6 assert len(tif.se...
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_read_generic_series():
"""Test read 4 series in 6 pages.""" fname = public_file('tifffile/generic_series.tif') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 6 assert len(tif.series) == 4 # assert series 0 properties series = tif.series[0] assert s...
assert len(tif.series) == 1 # assert page properties page = tif.pages[0] assert page.photometric == RGB assert page.compression == NONE assert page.imagewidth == 64 assert page.imagelength == 64 assert page.bitspersample == (5, 6, 5) assert page.sa...
256
256
883
24
232
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_generic_series
test_read_generic_series
4,553
4,634
4,553
4,554
4842ccaa6d1b39f36f583a4d7d769bed9cf02f17
bigcode/the-stack
train
a903e8e2f43d83f65b94b452
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_geotiff_cint16(): """Test read complex integer images.""" fname = private_file('geotiff/cint16.tif') with TiffFile(fname) as tif: assert tif.is_geotiff assert tif.byteorder == '<' assert len(tif.pages) == 1 assert...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_geotiff_cint16():
"""Test read complex integer images.""" fname = private_file('geotiff/cint16.tif') with TiffFile(fname) as tif: assert tif.is_geotiff assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.series) == 1 # assert page properties page = tif.pages[0...
_array_almost_equal( tags['ModelPixelScale'], [195.509321, 198.32184, 0] ) assert_aszarr_method(page) assert__str__(tif) @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_geotiff_cint16():
68
68
228
23
45
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_geotiff_cint16
test_read_geotiff_cint16
9,109
9,131
9,109
9,110
3efcb96827e857dd93e3f71d667ca28ae91ea6f4
bigcode/the-stack
train
058d066e1c064dc8515ad167
train
function
def test_func_subresolution(): """Test subresolution function.""" class a: dtype = numpy.uint8 axes = 'QzyxS' shape = (3, 256, 512, 1024, 4) class b: dtype = numpy.uint8 axes = 'QzyxS' shape = (3, 128, 256, 512, 4) assert subresolution(a, a) == 0 as...
def test_func_subresolution():
"""Test subresolution function.""" class a: dtype = numpy.uint8 axes = 'QzyxS' shape = (3, 256, 512, 1024, 4) class b: dtype = numpy.uint8 axes = 'QzyxS' shape = (3, 128, 256, 512, 4) assert subresolution(a, a) == 0 assert subresolution(a, b) == 1 ...
'Q') == ((1,), 'Q') assert squeeze_axes((1, 1), 'PQ') == ((1,), 'Q') def test_func_transpose_axes(): """Test transpose_axes function.""" assert transpose_axes( numpy.zeros((2, 3, 4, 5)), 'TYXC', asaxes='CTZYX' ).shape == (5, 2, 1, 3, 4) def test_func_subresolution():
100
100
336
6
94
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_subresolution
test_func_subresolution
2,604
2,632
2,604
2,604
d086329b911a9a31c02ac4e39c0477b1ef3d1504
bigcode/the-stack
train
fe276f29afe6d2c3363c1182
train
function
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_read_lzw_12bit_table(): """Test read lzw-full-12-bit-table.tif. Also test RowsPerStrip > ImageLength. """ fname = public_file('twelvemonkeys/tiff/lzw-full-12-bit-table.tif') with TiffFile(fname) as tif: assert len(tif....
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_read_lzw_12bit_table():
"""Test read lzw-full-12-bit-table.tif. Also test RowsPerStrip > ImageLength. """ fname = public_file('twelvemonkeys/tiff/lzw-full-12-bit-table.tif') with TiffFile(fname) as tif: assert len(tif.series) == 1 assert len(tif.pages) == 1 page = tif.pages[0] assert page....
16 assert round(abs(data[138, 475] - 40), 7) == 0 assert_aszarr_method(tif, data, key=478) assert__str__(tif, 0) @pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_read_lzw_12bit_table():
78
78
261
28
50
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_lzw_12bit_table
test_read_lzw_12bit_table
4,699
4,724
4,699
4,700
5545d5abed5018f9ac6ee5a8bd58358105934171
bigcode/the-stack
train
e96dd7045b4a0ee8156149d6
train
function
@pytest.mark.skipif(SKIP_HTTP, reason=REASON) def test_filehandle_seekable(): """Test FileHandle must be seekable.""" from urllib.request import HTTPHandler, build_opener opener = build_opener(HTTPHandler()) opener.addheaders = [('User-Agent', 'test_tifffile.py')] try: fh = opener.open(URL ...
@pytest.mark.skipif(SKIP_HTTP, reason=REASON) def test_filehandle_seekable():
"""Test FileHandle must be seekable.""" from urllib.request import HTTPHandler, build_opener opener = build_opener(HTTPHandler()) opener.addheaders = [('User-Agent', 'test_tifffile.py')] try: fh = opener.open(URL + 'data/test_http.tif') except OSError: pytest.skip(URL + 'data/te...
assert memmap if fh.is_file: assert_array_equal( fh.memmap_array(numpy.uint8, 255, pad), numpy.arange(255, dtype=numpy.uint8), ) @pytest.mark.skipif(SKIP_HTTP, reason=REASON) def test_filehandle_seekable():
64
64
116
20
44
bioturing/tifffile
tests/test_tifffile.py
Python
test_filehandle_seekable
test_filehandle_seekable
3,406
3,419
3,406
3,407
9c1d2ba2c32f9f80aa60b40934e3368ea1186ca0
bigcode/the-stack
train
29e10a302f2d44b10dd444b1
train
function
def test_func_excel_datetime(): """Test excel_datetime function.""" assert excel_datetime(40237.029999999795) == ( datetime.datetime(2010, 2, 28, 0, 43, 11, 999982) )
def test_func_excel_datetime():
"""Test excel_datetime function.""" assert excel_datetime(40237.029999999795) == ( datetime.datetime(2010, 2, 28, 0, 43, 11, 999982) )
_func_julian_datetime(): """Test julian_datetime function.""" assert julian_datetime(2451576, 54362783) == ( datetime.datetime(2000, 2, 2, 15, 6, 2, 783) ) def test_func_excel_datetime():
64
64
56
6
58
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_excel_datetime
test_func_excel_datetime
2,545
2,549
2,545
2,545
5377b0960181356e9fed2c67ef7a75d8ba1f0e38
bigcode/the-stack
train
cf49111b0f7de4481ffeb333
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_write_append_lsm(): """Test fail to append to LSM file.""" fname = private_file('lsm/take1.lsm') with pytest.raises(ValueError): with TiffWriter(fname, append=True): pass
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_write_append_lsm():
"""Test fail to append to LSM file.""" fname = private_file('lsm/take1.lsm') with pytest.raises(ValueError): with TiffWriter(fname, append=True): pass
: with open(fname, 'wb') as fh: fh.write(b'not a TIFF file') with pytest.raises(TiffFileError): with TiffWriter(fname, append=True): pass @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_write_append_lsm():
64
64
65
20
43
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_append_lsm
test_write_append_lsm
10,047
10,053
10,047
10,048
0081a57e3d71d095c3d1984904f6c24a37b45fda
bigcode/the-stack
train
110cd0194ce7fa8f34c2b849
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_depend_czi2tif(): """Test czifile.czi2tif.""" from czifile.czifile import CziFile, czi2tif fname = private_file('CZI/pollen.czi') with CziFile(fname) as czi: metadata = czi.metadata() data = czi.asarray().squeeze() ...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_depend_czi2tif():
"""Test czifile.czi2tif.""" from czifile.czifile import CziFile, czi2tif fname = private_file('CZI/pollen.czi') with CziFile(fname) as czi: metadata = czi.metadata() data = czi.asarray().squeeze() with TempFileName('czi2tif') as tif: czi2tif(fname, tif, bigtiff=False) ...
1) assert data.dtype == numpy.uint8 assert data[0, 0, 52, 182, 182, 0] == 10 @pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_depend_czi2tif():
64
64
181
27
36
bioturing/tifffile
tests/test_tifffile.py
Python
test_depend_czi2tif
test_depend_czi2tif
14,286
14,304
14,286
14,287
0b95d41d7cab89ca8379711a3d78d55f1bf39aa8
bigcode/the-stack
train
03c9a757fcacbcad75e5cb38
train
function
@pytest.mark.skipif(SKIP_LARGE, reason=REASON) def test_write_bigtiff(): """Test write 5GB BigTiff file.""" data = numpy.empty((640, 1024, 1024), dtype=numpy.float64) data[:] = numpy.arange(640, dtype=numpy.float64).reshape(-1, 1, 1) with TempFileName('bigtiff') as fname: # TiffWriter should fai...
@pytest.mark.skipif(SKIP_LARGE, reason=REASON) def test_write_bigtiff():
"""Test write 5GB BigTiff file.""" data = numpy.empty((640, 1024, 1024), dtype=numpy.float64) data[:] = numpy.arange(640, dtype=numpy.float64).reshape(-1, 1, 1) with TempFileName('bigtiff') as fname: # TiffWriter should fail without bigtiff parameter with pytest.raises(ValueError): ...
4), dtype=numpy.uint8) with TempFileName('3gb', remove=False) as fname: imwrite(fname, data) del data assert_valid_tiff(fname) # assert file with TiffFile(fname) as tif: assert not tif.is_bigtiff @pytest.mark.skipif(SKIP_LARGE, reason=REASON) def test_write_bigtif...
86
86
288
21
64
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_bigtiff
test_write_bigtiff
12,649
12,677
12,649
12,650
13b4f12ca02ff75fd85140de8d0746407f0d80c2
bigcode/the-stack
train
cfeb29799a2ead6e7cd70fca
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_micromanager(caplog): """Test fallback to ImageJ metadata if OME series fails.""" # https://github.com/cgohlke/tifffile/issues/54 # https://forum.image.sc/t/47567/9 # OME-XML does not contain reference to master file # file has corrupte...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_micromanager(caplog):
"""Test fallback to ImageJ metadata if OME series fails.""" # https://github.com/cgohlke/tifffile/issues/54 # https://forum.image.sc/t/47567/9 # OME-XML does not contain reference to master file # file has corrupted MicroManager DisplaySettings metadata fname = private_file( 'OME/' ...
ificial/4D-series.ome.tiff') with open(fname, 'rb') as fh: mm = mmap.mmap(fh.fileno(), 0, access=mmap.ACCESS_READ) assert_array_equal(imread(mm), imread(fname)) mm.close() @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_micromanager(caplog):
80
80
269
23
57
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_micromanager
test_issue_micromanager
1,114
1,135
1,114
1,115
304a4c793ec1299e9819d917347bab968b1459c1
bigcode/the-stack
train
1f86cd29e214b7a448131728
train
function
def test_write_volumetric_tiled_planar_rgb(): """Test write 5D array as grayscale volumes.""" shape = (2, 3, 256, 64, 96) data = numpy.empty(shape, dtype=numpy.uint8) data[:] = numpy.arange(256, dtype=numpy.uint8).reshape(1, 1, -1, 1, 1) with TempFileName('volumetric_tiled_planar_rgb') as fname: ...
def test_write_volumetric_tiled_planar_rgb():
"""Test write 5D array as grayscale volumes.""" shape = (2, 3, 256, 64, 96) data = numpy.empty(shape, dtype=numpy.uint8) data[:] = numpy.arange(256, dtype=numpy.uint8).reshape(1, 1, -1, 1, 1) with TempFileName('volumetric_tiled_planar_rgb') as fname: imwrite( fname, d...
width == 96 assert page.imagelength == 64 assert page.imagedepth == 16 assert page.tilewidth == 64 assert page.tilelength == 64 assert page.tiledepth == 1 assert page.samplesperpixel == 3 image = tif.asarray() assert_array_e...
108
108
362
12
96
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_volumetric_tiled_planar_rgb
test_write_volumetric_tiled_planar_rgb
12,316
12,353
12,316
12,316
afc80d6a22bd32cdebfbbc347551980664605ac0
bigcode/the-stack
train
d35792f75415516b22ba0e92
train
function
def test_func_product(): """Test product function.""" assert product([2**8, 2**30]) == 274877906944 assert product([]) == 1
def test_func_product():
"""Test product function.""" assert product([2**8, 2**30]) == 274877906944 assert product([]) == 1
\n\x01\x00') == b'string\x00string\n' assert stripascii(b'\x00') == b'' def test_func_sequence(): """Test sequence function.""" assert sequence(1) == (1,) assert sequence([1]) == [1] def test_func_product():
64
64
40
5
59
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_product
test_func_product
2,583
2,586
2,583
2,583
bbb06e55d26047bef10f87fe2327f0bea68dcaa8
bigcode/the-stack
train
9979cbb31825b57098130295
train
function
@pytest.mark.parametrize('mmap', [False, True]) @pytest.mark.parametrize('truncate', [False, True]) def test_write_imagej_hyperstack(truncate, mmap): """Test write ImageJ hyperstack.""" shape = (5, 6, 7, 49, 61, 3) data = numpy.empty(shape, dtype=numpy.uint8) data[:] = numpy.arange(210, dtype=numpy.uint...
@pytest.mark.parametrize('mmap', [False, True]) @pytest.mark.parametrize('truncate', [False, True]) def test_write_imagej_hyperstack(truncate, mmap):
"""Test write ImageJ hyperstack.""" shape = (5, 6, 7, 49, 61, 3) data = numpy.empty(shape, dtype=numpy.uint8) data[:] = numpy.arange(210, dtype=numpy.uint8).reshape(5, 6, 7, 1, 1, 1) _truncate = ['', '_trunc'][truncate] _memmap = ['', '_memmap'][mmap] with TempFileName(f'imagej_hyperstack{_...
ImageJ'] assert ijmetadata2['mode'] == ijmetadata['mode'] assert ijmetadata2['Info'] == ijmetadata['Info'] assert ijmetadata2['ROI'] == ijmetadata['ROI'] assert ijmetadata2['Overlays'] == ijmetadata['Overlays'] assert ijmetadata2['Ranges'] == ijmetadata['Ranges'] assert ijmetadata2['Labels'] == ...
156
156
520
36
120
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_imagej_hyperstack
test_write_imagej_hyperstack
13,248
13,303
13,248
13,250
c5d59b5d8d0e79179ce4f45bb419b0ba794c1adc
bigcode/the-stack
train
5fa7e97b3c470a680b8a072e
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_sequence_oif_series(): """Test TiffSequence with files from Olympus OIF, memory mapped.""" fname = private_file( 'oif/MB231cell1_paxgfp_PDMSgasket_PMMAflat_30nm_378sli.oif.files/*.tif' ) tifs = TiffSequence(fname, pattern='axes') asse...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_sequence_oif_series():
"""Test TiffSequence with files from Olympus OIF, memory mapped.""" fname = private_file( 'oif/MB231cell1_paxgfp_PDMSgasket_PMMAflat_30nm_378sli.oif.files/*.tif' ) tifs = TiffSequence(fname, pattern='axes') assert len(tifs) == 756 assert tifs.shape == (2, 378) assert tifs.axes == 'CZ...
numpy.uint8 assert data[1, 256, 256] == 135 if not SKIP_ZARR: with tifs.aszarr() as store: assert_array_equal(data, zarr.open(store, mode='r')) @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_sequence_oif_series():
74
75
250
20
54
bioturing/tifffile
tests/test_tifffile.py
Python
test_sequence_oif_series
test_sequence_oif_series
14,074
14,094
14,074
14,075
1e839fea8e435220609113b3bd61f99f0cd96fe4
bigcode/the-stack
train
d5da85ac5301617357bae5f2
train
function
def test_write_append_imwrite(): """Test append using imwrite.""" data = random_data(numpy.uint8, (21, 31)) with TempFileName('imwrite_append') as fname: imwrite(fname, data, metadata=None) for _ in range(3): imwrite(fname, data, append=True, metadata=None) a = imread(fna...
def test_write_append_imwrite():
"""Test append using imwrite.""" data = random_data(numpy.uint8, (21, 31)) with TempFileName('imwrite_append') as fname: imwrite(fname, data, metadata=None) for _ in range(3): imwrite(fname, data, append=True, metadata=None) a = imread(fname) assert a.shape == (4,...
reason=REASON) def test_write_append_lsm(): """Test fail to append to LSM file.""" fname = private_file('lsm/take1.lsm') with pytest.raises(ValueError): with TiffWriter(fname, append=True): pass def test_write_append_imwrite():
64
64
106
7
56
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_append_imwrite
test_write_append_imwrite
10,056
10,065
10,056
10,056
091e000914cdfef6d20265d045360c77db917357
bigcode/the-stack
train
ed98bb2b9dc98f10927c49d5
train
function
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_read_quad_tile(): """Test read 384x512 RGB uint8 LZW tiled.""" # Strips and tiles defined in same page fname = public_file('juicypixels/quad-tile.tif') with TiffFile(fname) as tif: assert__str__(tif) assert tif.byteo...
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_read_quad_tile():
"""Test read 384x512 RGB uint8 LZW tiled.""" # Strips and tiles defined in same page fname = public_file('juicypixels/quad-tile.tif') with TiffFile(fname) as tif: assert__str__(tif) assert tif.byteorder == '>' assert len(tif.pages) == 1 assert len(tif.series) == 1 ...
' # assert data data = tif.asarray() assert isinstance(data, numpy.ndarray) assert data.flags['C_CONTIGUOUS'] assert data.shape == (384, 512, 3) assert data.dtype == numpy.uint8 assert tuple(data[309, 460, :]) == (0, 163, 187) assert_aszarr_method(tif, dat...
117
117
390
24
93
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_quad_tile
test_read_quad_tile
4,275
4,311
4,275
4,276
a85cfbbb38fd49b86fb7de0a851819b26dae5c49
bigcode/the-stack
train
2b14e1c35562d68985966565
train
function
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_issue_jpeg_ia(): """Test JPEG compressed intensity image with alpha channel.""" # no extrasamples! fname = private_file('issues/jpeg_ia.tiff') with TiffFile(fname) as tif: page = tif.pages[0] ...
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_issue_jpeg_ia():
"""Test JPEG compressed intensity image with alpha channel.""" # no extrasamples! fname = private_file('issues/jpeg_ia.tiff') with TiffFile(fname) as tif: page = tif.pages[0] assert page.compression == JPEG assert_array_equal( page.asarray(), numpy.array([...
page = tif.pages[0] assert page.compression == 0 # invalid assert__str__(tif) @pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_issue_jpeg_ia():
64
64
134
36
28
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_jpeg_ia
test_issue_jpeg_ia
495
509
495
498
5ab60671e50f1c6e6e7b7d874502ac36d9baa20d
bigcode/the-stack
train
4dc024b62c861e8402284358
train
function
@pytest.mark.skipif(SKIP_CODECS, reason=REASON) def test_write_compression_lerc(): """Test write LERC compression.""" if not hasattr(imagecodecs, 'LERC'): pytest.skip('LERC codec missing') data = WRITE_DATA.astype(numpy.uint16).reshape((219, 301, 3)) with TempFileName('compression_lerc') as fnam...
@pytest.mark.skipif(SKIP_CODECS, reason=REASON) def test_write_compression_lerc():
"""Test write LERC compression.""" if not hasattr(imagecodecs, 'LERC'): pytest.skip('LERC codec missing') data = WRITE_DATA.astype(numpy.uint16).reshape((219, 301, 3)) with TempFileName('compression_lerc') as fname: imwrite(fname, data, compression=LERC, photometric=RGB) assert_v...
219 assert page.samplesperpixel == 3 image = tif.asarray() assert_array_equal(data, image) assert_aszarr_method(tif, image) assert__str__(tif) @pytest.mark.skipif(SKIP_CODECS, reason=REASON) def test_write_compression_lerc():
67
67
224
22
45
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_compression_lerc
test_write_compression_lerc
10,920
10,941
10,920
10,921
f35d7d09794e452d0003067c65a2b93b9d9de0a4
bigcode/the-stack
train
ad6f1c6096fe09e1b5717aee
train
function
def test_write_minisblack_contig(): """Test write contig minisblack.""" data = random_data(numpy.uint8, (219, 301, 3)) with TempFileName('minisblack_contig') as fname: imwrite(fname, data, photometric=MINISBLACK) assert_valid_tiff(fname) with TiffFile(fname) as tif: asser...
def test_write_minisblack_contig():
"""Test write contig minisblack.""" data = random_data(numpy.uint8, (219, 301, 3)) with TempFileName('minisblack_contig') as fname: imwrite(fname, data, photometric=MINISBLACK) assert_valid_tiff(fname) with TiffFile(fname) as tif: assert len(tif.pages) == 219 ...
301 assert page.imagelength == 219 assert page.samplesperpixel == 1 image = tif.asarray() assert_array_equal(data, image) assert_aszarr_method(tif, image) assert__str__(tif) def test_write_minisblack_contig():
64
64
189
9
55
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_minisblack_contig
test_write_minisblack_contig
11,643
11,661
11,643
11,643
0b9ee096d67f36f51ec84354d96c95517c3e5ce9
bigcode/the-stack
train
87c5b193a462f5d83b9f0143
train
function
def data_file(pathname, base, expand=True): """Return path to test file(s).""" path = os.path.join(base, *pathname.split('/')) if expand and any(i in path for i in '*?'): return glob.glob(path) return path
def data_file(pathname, base, expand=True):
"""Return path to test file(s).""" path = os.path.join(base, *pathname.split('/')) if expand and any(i in path for i in '*?'): return glob.glob(path) return path
= True def config(): """Return test configuration.""" this = sys.modules[__name__] return ' | '.join( a for a in dir(this) if a.startswith('SKIP_') and getattr(this, a) ) def data_file(pathname, base, expand=True):
64
64
58
11
53
bioturing/tifffile
tests/test_tifffile.py
Python
data_file
data_file
285
290
285
285
05d6265a448966b75e30a17354cf6df58c8bb533
bigcode/the-stack
train
9dfe5154455c0fac9d3bc3fc
train
function
@pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_read_jpeg_baboon(): """Test JPEG compression.""" fname = private_file('baboon.tiff') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(ti...
@pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_read_jpeg_baboon():
"""Test JPEG compression.""" fname = private_file('baboon.tiff') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.series) == 1 # assert page properties page = tif.pages[0] assert 'JPEGTables' in page.tags ...
assert page.bitspersample == 8 assert page.samplesperpixel == 3 # assert data with pytest.raises(NotImplementedError): page.asarray() assert__str__(tif) @pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_read_jpeg_baboon():
81
81
273
37
44
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_jpeg_baboon
test_read_jpeg_baboon
4,794
4,823
4,794
4,797
b3c501fd419992e29bcfbfa9f0ae1005065ef659
bigcode/the-stack
train
1c292d2ab0d0fe1d1c9f4103
train
function
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or SKIP_LARGE or not imagecodecs.JPEG, reason=REASON, ) def test_read_jpeg_lsb2msb(): """Test read huge tiled, JPEG compressed, with lsb2msb specified. Also test JPEG with RGB photometric. """ fname = private_file('large/jpeg_lsb2msb.tif') w...
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or SKIP_LARGE or not imagecodecs.JPEG, reason=REASON, ) def test_read_jpeg_lsb2msb():
"""Test read huge tiled, JPEG compressed, with lsb2msb specified. Also test JPEG with RGB photometric. """ fname = private_file('large/jpeg_lsb2msb.tif') with TiffFile(fname) as tif: assert len(tif.pages) == 1 page = tif.pages[0] assert page.compression == JPEG asse...
6) # YCBCR (1752, 1836, 2000) assert_aszarr_method(tif, image) assert__str__(tif) @pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or SKIP_LARGE or not imagecodecs.JPEG, reason=REASON, ) def test_read_jpeg_lsb2msb():
83
83
279
45
38
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_jpeg_lsb2msb
test_read_jpeg_lsb2msb
4,905
4,932
4,905
4,909
63e465ded22635b204e9a2d366edb900a0893867
bigcode/the-stack
train
88798b7a05ab606b083ed6d3
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_gimp_f4(): """Test read float32 with horizontal predictor by GIMP.""" fname = public_file('tifffile/gimp_f4.tiff') with TiffFile(fname) as tif: assert len(tif.pages) == 1 page = tif.pages[0] assert page.compression == ADOB...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_gimp_f4():
"""Test read float32 with horizontal predictor by GIMP.""" fname = public_file('tifffile/gimp_f4.tiff') with TiffFile(fname) as tif: assert len(tif.pages) == 1 page = tif.pages[0] assert page.compression == ADOBE_DEFLATE assert page.photometric == RGB assert page.pred...
'] assert tuple(image[110, 110]) == (23308, 17303, 41160) assert_aszarr_method(tif, image) assert__str__(tif) @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_gimp_f4():
64
64
213
21
43
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_gimp_f4
test_read_gimp_f4
3,865
3,884
3,865
3,866
b6f4d64539a9bc208990f0b31ef1c18e2f4c4b48
bigcode/the-stack
train
5609500d9ddb9e7db4cedc9d
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_cramps_tile(): """Test read 800x607 uint8, raw, volumetric, tiled.""" fname = public_file('juicypixels/cramps-tile.tif') with TiffFile(fname) as tif: assert tif.byteorder == '>' assert len(tif.pages) == 1 assert len(tif.se...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_cramps_tile():
"""Test read 800x607 uint8, raw, volumetric, tiled.""" fname = public_file('juicypixels/cramps-tile.tif') with TiffFile(fname) as tif: assert tif.byteorder == '>' assert len(tif.pages) == 1 assert len(tif.series) == 1 # assert page properties page = tif.pages[0] ...
' # assert data data = tif.asarray() assert isinstance(data, numpy.ndarray) assert data.flags['C_CONTIGUOUS'] assert data.shape == (607, 800) assert data.dtype == numpy.uint8 assert data[273, 426] == 34 assert_aszarr_method(tif, data) assert__str__...
103
103
344
20
83
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_cramps_tile
test_read_cramps_tile
4,140
4,175
4,140
4,141
b589b0d1c1fc27677c62f5190f6c32a368bd4f1f
bigcode/the-stack
train
6318c9e6d8d39a49f0c44e50
train
function
def assert_filehandle(fh, offset=0): """Assert filehandle can read test_FileHandle.bin.""" size = FILEHANDLE_SIZE - 2 * offset pad = 999 - offset assert fh.size == size assert fh.tell() == 0 assert fh.read(4) == b'\x01\x01\x01\x01' fh.seek(pad - 4) assert fh.tell() == pad - 4 assert ...
def assert_filehandle(fh, offset=0):
"""Assert filehandle can read test_FileHandle.bin.""" size = FILEHANDLE_SIZE - 2 * offset pad = 999 - offset assert fh.size == size assert fh.tell() == 0 assert fh.read(4) == b'\x01\x01\x01\x01' fh.seek(pad - 4) assert fh.tell() == pad - 4 assert fh.read(4) == b'\x01\x01\x01\x01' ...
fh.tell()) # buffer numpy.ones(999, dtype=numpy.uint8).tofile(fh) # micromanager print('micromanager start', fh.tell()) with open('data/public/tifffile/micromanager.tif', 'rb') as tif: fh.write(tif.read()) print('micromanager end', fh.tell()) # buffer...
114
114
380
11
103
bioturing/tifffile
tests/test_tifffile.py
Python
assert_filehandle
assert_filehandle
3,368
3,403
3,368
3,368
30e50b5ff9666852441a0523c05fa74840ec6ce9
bigcode/the-stack
train
b128b13e6e83a116a3b2c3e8
train
function
def test_write_ome_enable(): """Test OME-TIFF enabling.""" data = numpy.zeros((32, 32), dtype=numpy.uint8) with TempFileName('write_ome_enable.ome') as fname: imwrite(fname, data) with TiffFile(fname) as tif: assert tif.is_ome imwrite(fname, data, description='not OME') ...
def test_write_ome_enable():
"""Test OME-TIFF enabling.""" data = numpy.zeros((32, 32), dtype=numpy.uint8) with TempFileName('write_ome_enable.ome') as fname: imwrite(fname, data) with TiffFile(fname) as tif: assert tif.is_ome imwrite(fname, data, description='not OME') with TiffFile(fname) a...
image = tif.asarray() omexml = tif.ome_metadata if axes: assert tif.series[0].axes == squeeze_axes(shape, axes)[-1] assert_array_equal(data.squeeze(), image.squeeze()) assert_aszarr_method(tif, image) assert_valid_omexml(omexml) ...
86
86
288
7
79
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_ome_enable
test_write_ome_enable
13,450
13,479
13,450
13,450
b200b312ba29fccfe448402adf512ce41b87474c
bigcode/the-stack
train
dfb9c71a8d5f5be715ea7b8e
train
function
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_embed_tif_filename(): """Test embedded TIFF from filename.""" with TiffFile(EMBED_NAME, offset=EMBED_OFFSET, size=EMBED_SIZE) as tif: assert_embed_tif(tif)
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_embed_tif_filename():
"""Test embedded TIFF from filename.""" with TiffFile(EMBED_NAME, offset=EMBED_OFFSET, size=EMBED_SIZE) as tif: assert_embed_tif(tif)
== numpy.dtype('<u2') assert data[4, 2, 511, 511] == 1602 del data assert__str__(tif) @pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_embed_tif_filename():
64
64
66
25
39
bioturing/tifffile
tests/test_tifffile.py
Python
test_embed_tif_filename
test_embed_tif_filename
13,936
13,940
13,936
13,937
3419da71374c6d0260fdd54b2d241c25b7d48106
bigcode/the-stack
train
d3851459436d45e8cd3091a2
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_read_scanimage_2gb(): """Test read ScanImage non-BigTIFF > 2 GB. https://github.com/MouseLand/suite2p/issues/149 """ fname = private_file('ScanImage/M161209TH_01__001.tif') with TiffFile(fname) as tif: assert tif.is_sc...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_read_scanimage_2gb():
"""Test read ScanImage non-BigTIFF > 2 GB. https://github.com/MouseLand/suite2p/issues/149 """ fname = private_file('ScanImage/M161209TH_01__001.tif') with TiffFile(fname) as tif: assert tif.is_scanimage assert len(tif.pages) == 5980 assert len(tif.series) == 1 # no...
_scanimage assert page.is_contiguous assert page.compression == NONE assert page.imagewidth == 256 assert page.imagelength == 256 assert page.bitspersample == 16 assert page.samplesperpixel == 1 # description tags metadata = scanimage_description_metadata(...
131
131
437
27
104
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_scanimage_2gb
test_read_scanimage_2gb
6,970
7,013
6,970
6,971
eebe64654e3e7216880134ec1b61ed3ab8a13673
bigcode/the-stack
train
dd6171c72009262b1453fc0c
train
function
@pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEGXR, reason=REASON ) def test_read_ndpi_jpegxr(): """Test read Hamamatsu NDPI slide with JPEG XR compression.""" # https://downloads.openmicroscopy.org/images/Hamamatsu-NDPI/hamamatsu/ fname = private_file('HamamatsuNDPI/DM0014 - 2020...
@pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEGXR, reason=REASON ) def test_read_ndpi_jpegxr():
"""Test read Hamamatsu NDPI slide with JPEG XR compression.""" # https://downloads.openmicroscopy.org/images/Hamamatsu-NDPI/hamamatsu/ fname = private_file('HamamatsuNDPI/DM0014 - 2020-04-02 10.25.21.ndpi') with TiffFile(fname) as tif: assert tif.is_ndpi assert len(tif.pages) == 6 ...
s[2].shape == (25920, 47040, 3) assert series.levels[3].shape == (12960, 23520, 3) assert series.levels[4].shape == (6480, 11760, 3) assert series.levels[5].shape == (3240, 5880, 3) data = series.levels[5].asarray() assert tuple(data[1000, 1000]) == (222, 165, 200) # cann...
200
200
669
38
162
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_ndpi_jpegxr
test_read_ndpi_jpegxr
6,673
6,729
6,673
6,676
f781da4423fcd819c2cc425b30d869783a776d0f
bigcode/the-stack
train
fae8d0ae0dc010c4321ed964
train
function
def test_write_resolution_float(): """Test write float Resolution tag.""" data = random_data(numpy.uint8, (2, 219, 301)) resolution = (92.0, 92.0) with TempFileName('resolution_float') as fname: imwrite(fname, data, resolution=resolution) assert_valid_tiff(fname) with TiffFile(fn...
def test_write_resolution_float():
"""Test write float Resolution tag.""" data = random_data(numpy.uint8, (2, 219, 301)) resolution = (92.0, 92.0) with TempFileName('resolution_float') as fname: imwrite(fname, data, resolution=resolution) assert_valid_tiff(fname) with TiffFile(fname) as tif: assert len...
_tiff(fname) with TiffFile(fname) as tif: assert len(tif.pages) == 2 assert tif.pages[0].software == software assert 'Software' not in tif.pages[1].tags assert__str__(tif) def test_write_resolution_float():
64
64
185
6
58
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_resolution_float
test_write_resolution_float
10,467
10,480
10,467
10,467
5300f3d4570e69f10b3aa06e83ec18523e2213ca
bigcode/the-stack
train
52d88781e236272382c703fa
train
function
def test_write_compression_rowsperstrip(): """Test write rowsperstrip with compression.""" data = WRITE_DATA with TempFileName('compression_rowsperstrip') as fname: imwrite( fname, data, compression=ADOBE_DEFLATE, rowsperstrip=32, photometr...
def test_write_compression_rowsperstrip():
"""Test write rowsperstrip with compression.""" data = WRITE_DATA with TempFileName('compression_rowsperstrip') as fname: imwrite( fname, data, compression=ADOBE_DEFLATE, rowsperstrip=32, photometric=RGB, ) assert_valid_tiff...
page.imagewidth == uncompressed.size assert page.imagelength == 7 assert page.samplesperpixel == 1 image = tif.asarray() assert_array_equal(data, image) assert_aszarr_method(tif, image) assert__str__(tif) def test_write_compression_rowsperstrip():...
70
70
234
9
61
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_compression_rowsperstrip
test_write_compression_rowsperstrip
10,976
11,003
10,976
10,976
07d683e1fb97dc0261e76543e959815e4fea90ec
bigcode/the-stack
train
b759e185664e6f77273ebc59
train
function
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_embed_tif_bytesio(): """Test embedded TIFF from BytesIO.""" with open(EMBED_NAME, 'rb') as fh: fh2 = BytesIO(fh.read()) with TiffFile(fh2, offset=EMBED_OFFSET, size=EMBED_SIZE) as tif: assert_embed_tif(tif)
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_embed_tif_bytesio():
"""Test embedded TIFF from BytesIO.""" with open(EMBED_NAME, 'rb') as fh: fh2 = BytesIO(fh.read()) with TiffFile(fh2, offset=EMBED_OFFSET, size=EMBED_SIZE) as tif: assert_embed_tif(tif)
EMBED_NAME, offset=EMBED_OFFSET, size=EMBED_SIZE) as fh: with TiffFile(fh) as tif: assert_embed_tif(tif) @pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_embed_tif_bytesio():
64
64
91
26
38
bioturing/tifffile
tests/test_tifffile.py
Python
test_embed_tif_bytesio
test_embed_tif_bytesio
13,968
13,974
13,968
13,969
8f0dc99a780f9eeaddc2e61f932daf2e4c0a2199
bigcode/the-stack
train
43cf7fa06a7274ac477bfdba
train
function
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_embed_tif_filehandle(): """Test embedded TIFF from FileHandle.""" with FileHandle(EMBED_NAME, offset=EMBED_OFFSET, size=EMBED_SIZE) as fh: with TiffFile(fh) as tif: assert_embed_tif(tif)
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_embed_tif_filehandle():
"""Test embedded TIFF from FileHandle.""" with FileHandle(EMBED_NAME, offset=EMBED_OFFSET, size=EMBED_SIZE) as fh: with TiffFile(fh) as tif: assert_embed_tif(tif)
rb') as fh: fh.seek(EMBED_OFFSET) with TiffFile(fh, size=EMBED_SIZE) as tif: assert_embed_tif(tif) @pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_embed_tif_filehandle():
64
64
78
26
38
bioturing/tifffile
tests/test_tifffile.py
Python
test_embed_tif_filehandle
test_embed_tif_filehandle
13,960
13,965
13,960
13,961
e4316a63fe4772252a07e71ed64572dbd9867167
bigcode/the-stack
train
9ed90b0f9d4820bce1b34b34
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_read_lsm_carpet(): """Test read LSM: ZCTYX (time series x-y), 72000 pages.""" # reads very slowly, ensure colormap is not applied fname = private_file('lsm/Cardarelli_carpet_3.lsm') with TiffFile(fname) as tif: assert tif.is...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_read_lsm_carpet():
"""Test read LSM: ZCTYX (time series x-y), 72000 pages.""" # reads very slowly, ensure colormap is not applied fname = private_file('lsm/Cardarelli_carpet_3.lsm') with TiffFile(fname) as tif: assert tif.is_lsm assert tif.byteorder == '<' assert len(tif.pages) == 72000 ass...
tags = tif.lsm_metadata assert tags['DimensionX'] == 512 assert tags['DimensionY'] == 512 assert tags['DimensionZ'] == 54 assert tags['DimensionTime'] == 5 assert tags['DimensionChannels'] == 32 # assert lsm_scan_info tags tags = tif.lsm_metadata['ScanInfo...
157
157
524
26
131
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_lsm_carpet
test_read_lsm_carpet
5,833
5,879
5,833
5,834
4485d31196d56c4622279ff761e9a9896918fe68
bigcode/the-stack
train
755cd53adb7c9f7af1d3323f
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_embed_mm_bytesio(): """Test embedded MicroManager TIFF from BytesIO.""" with open(EMBED_NAME, 'rb') as fh: fh2 = BytesIO(fh.read()) with TiffFile(fh2, offset=EMBED_OFFSET1, size=EMBED_SIZE1) as tif: assert_embed_micromanager(tif)
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_embed_mm_bytesio():
"""Test embedded MicroManager TIFF from BytesIO.""" with open(EMBED_NAME, 'rb') as fh: fh2 = BytesIO(fh.read()) with TiffFile(fh2, offset=EMBED_OFFSET1, size=EMBED_SIZE1) as tif: assert_embed_micromanager(tif)
Handle(EMBED_NAME, offset=EMBED_OFFSET1, size=EMBED_SIZE1) as fh: with TiffFile(fh) as tif: assert_embed_micromanager(tif) @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_embed_mm_bytesio():
64
64
91
20
44
bioturing/tifffile
tests/test_tifffile.py
Python
test_embed_mm_bytesio
test_embed_mm_bytesio
14,009
14,015
14,009
14,010
d5e5587de4af35bc50561789136c4e91ca5d4341
bigcode/the-stack
train
3d603bcf9f437bea2801634e
train
function
def test_write_tileiter(): """Test write tiles from iterator.""" data = numpy.arange(3 * 4 * 16 * 16, dtype=numpy.uint16).reshape( (3 * 4, 16, 16) ) def tiles(): for i in range(data.shape[0]): yield data[i] with TempFileName('write_tileiter') as fname: with pyt...
def test_write_tileiter():
"""Test write tiles from iterator.""" data = numpy.arange(3 * 4 * 16 * 16, dtype=numpy.uint16).reshape( (3 * 4, 16, 16) ) def tiles(): for i in range(data.shape[0]): yield data[i] with TempFileName('write_tileiter') as fname: with pytest.raises(StopIteration): ...
.is_contiguous assert page.planarconfig == CONTIG assert page.photometric == RGB assert not page.is_volumetric assert page.imagewidth == 301 assert page.imagelength == 219 assert page.tilewidth == 64 assert page.tilelength == 96 ...
117
117
393
6
111
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_tileiter
test_write_tileiter
12,074
12,132
12,074
12,074
8e413b9d775759a99f40910d6615f10620b5c824
bigcode/the-stack
train
d5690eac293063e5a1eece42
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_stk_10xcalib(): """Test read MetaMorph STK two planes, not Z or T series.""" fname = private_file('stk/10xcalib.stk') with TiffFile(fname) as tif: assert tif.is_stk assert tif.byteorder == '<' assert len(tif.pages) == 1 ...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_stk_10xcalib():
"""Test read MetaMorph STK two planes, not Z or T series.""" fname = private_file('stk/10xcalib.stk') with TiffFile(fname) as tif: assert tif.is_stk assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.series) == 1 # assert page properties pag...
, 298) assert series.dtype == numpy.uint8 assert series.axes == 'IYX' # corrupt time_created # assert data data = tif.asarray() assert isinstance(data, numpy.ndarray) assert data.shape == (79, 322, 298) assert data.dtype == numpy.uint8 assert data[43, 180...
129
129
430
24
105
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_stk_10xcalib
test_read_stk_10xcalib
6,408
6,447
6,408
6,409
7ab41f1b0bef1d21325a0f4858e3c9234bc15232
bigcode/the-stack
train
da970c194a9071bbb2b9c4e0
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) @pytest.mark.parametrize( 'method', ['manual', 'copy', 'iter', 'compression', 'xml'] ) def test_write_ome_methods(method): """Test re-write OME-TIFF.""" # 4D (7 time points, 5 focal planes) fname = public_file('OME/bioformats-artificial/4D-series.ome.tiff'...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) @pytest.mark.parametrize( 'method', ['manual', 'copy', 'iter', 'compression', 'xml'] ) def test_write_ome_methods(method):
"""Test re-write OME-TIFF.""" # 4D (7 time points, 5 focal planes) fname = public_file('OME/bioformats-artificial/4D-series.ome.tiff') with TiffFile(fname) as tif: series = tif.series[0] data = series.asarray() dtype = data.dtype shape = data.shape axes = series.a...
description='not OME') with TiffFile(fname) as tif: assert not tif.is_ome with pytest.warns(UserWarning): imwrite(fname, data, description='not OME', ome=True) with TiffFile(fname) as tif: assert tif.is_ome imwrite(fname, data, imagej=True) wi...
253
253
844
45
207
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_ome_methods
test_write_ome_methods
13,482
13,598
13,482
13,486
8d3a34131689d0ce1ba213a7ba8a4a26a93a37ec
bigcode/the-stack
train
bcc3d1344ed9d03a132ff769
train
function
@pytest.mark.skipif(SKIP_BE, reason=REASON) def test_write_write_bigendian(): """Test write big endian file.""" # also test memory mapping non-native byte order data = random_data(numpy.float32, (2, 3, 219, 301)).newbyteorder() data = numpy.nan_to_num(data, copy=False) with TempFileName('write_bigen...
@pytest.mark.skipif(SKIP_BE, reason=REASON) def test_write_write_bigendian():
"""Test write big endian file.""" # also test memory mapping non-native byte order data = random_data(numpy.float32, (2, 3, 219, 301)).newbyteorder() data = numpy.nan_to_num(data, copy=False) with TempFileName('write_bigendian') as fname: imwrite(fname, data, planarconfig=SEPARATE, photometr...
1 page = tif.pages[0] assert page.is_contiguous assert page.planarconfig == SEPARATE assert page.photometric == RGB assert page.imagewidth == 301 assert page.imagelength == 219 assert page.samplesperpixel == 3 assert page.r...
182
182
608
21
161
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_write_bigendian
test_write_write_bigendian
11,133
11,195
11,133
11,134
82ebdc2f7270d1d90416c3d58db0de0ea471d1aa
bigcode/the-stack
train
3241b97a3b7df7cacdf8dec6
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_imagej_flybrain(): """Test read ImageJ 57x256x256 RGB.""" fname = private_file('imagej/flybrain.tif') with TiffFile(fname) as tif: assert tif.is_imagej assert tif.byteorder == '>' assert len(tif.pages) == 57 asser...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_imagej_flybrain():
"""Test read ImageJ 57x256x256 RGB.""" fname = private_file('imagej/flybrain.tif') with TiffFile(fname) as tif: assert tif.is_imagej assert tif.byteorder == '>' assert len(tif.pages) == 57 assert len(tif.series) == 1 # hyperstack # assert page properties page...
== numpy.uint16 assert tuple(data[255, 336]) == (440, 378, 298) assert_aszarr_method(series, data) assert_aszarr_method(series, data, chunkmode='page') # don't squeeze data = tif.asarray(squeeze=False) assert data.shape == (1, 1, 1, 512, 672, 3) assert_aszarr_met...
130
130
434
22
108
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_imagej_flybrain
test_read_imagej_flybrain
8,334
8,372
8,334
8,335
00ee4dedb77dd880a0f772f8e5473eb79c3b2c18
bigcode/the-stack
train
abe92a2af085177d89042688
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_read_lena_le_f32_lzw_planar(): """Test read little endian, LZW, float32 horizontal differencing.""" fname = private_file('PS/lena_le_f32_lzw_planar.tif') with TiffFile(fname, is_imagej=False) as tif: assert tif.byteorder == '<'...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_read_lena_le_f32_lzw_planar():
"""Test read little endian, LZW, float32 horizontal differencing.""" fname = private_file('PS/lena_le_f32_lzw_planar.tif') with TiffFile(fname, is_imagej=False) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.series) == 1 assert not tif.is_imagej...
(512, 512, 3) assert data.dtype == numpy.float32 assert_array_almost_equal( data[256, 256], (0.456386, 0.052867, 0.064795) ) assert_aszarr_method(tif, data, series=0) assert__str__(tif) @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_read_len...
107
107
358
31
76
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_lena_le_f32_lzw_planar
test_read_lena_le_f32_lzw_planar
5,286
5,319
5,286
5,287
85d06a99fe22e0ec90448771d21f6f1e80f8f1c6
bigcode/the-stack
train
f06b4bbcdcaa976473ead486
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_read_lena_be_f32_deflate_contig(): """Test read big endian, float32 horizontal differencing, deflate.""" fname = private_file('PS/lena_be_f32_deflate_contig.tif') with TiffFile(fname, is_imagej=False) as tif: assert tif.byteord...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_read_lena_be_f32_deflate_contig():
"""Test read big endian, float32 horizontal differencing, deflate.""" fname = private_file('PS/lena_be_f32_deflate_contig.tif') with TiffFile(fname, is_imagej=False) as tif: assert tif.byteorder == '>' assert len(tif.pages) == 1 assert len(tif.series) == 1 assert not tif.is_i...
512) assert data.dtype == numpy.float16 assert_array_almost_equal( data[:, 256, 256], (0.4563, 0.052856, 0.064819) ) assert_aszarr_method(tif, data, series=0) assert_decode_method(page) assert__str__(tif) @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reaso...
108
108
361
31
77
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_lena_be_f32_deflate_contig
test_read_lena_be_f32_deflate_contig
5,250
5,283
5,250
5,251
bb7d9a3028e6eccb3be7e208b27fa8921d1cb6f2
bigcode/the-stack
train
d8848c73caa81ecbd1f1017a
train
function
def test_write_resolution_unit(): """Test write Resolution tag unit.""" data = random_data(numpy.uint8, (219, 301)) resolution = (92.0, (9200, 100), None) with TempFileName('resolution_unit') as fname: imwrite(fname, data, resolution=resolution) assert_valid_tiff(fname) with Tiff...
def test_write_resolution_unit():
"""Test write Resolution tag unit.""" data = random_data(numpy.uint8, (219, 301)) resolution = (92.0, (9200, 100), None) with TempFileName('resolution_unit') as fname: imwrite(fname, data, resolution=resolution) assert_valid_tiff(fname) with TiffFile(fname) as tif: as...
iffFile(fname) as tif: assert len(tif.pages) == 1 assert tif.pages[0].tags['XResolution'].value == (300, 1) assert tif.pages[0].tags['YResolution'].value == (300, 1) def test_write_resolution_unit():
64
64
163
6
58
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_resolution_unit
test_write_resolution_unit
10,496
10,508
10,496
10,496
9009e6c7d59418f2fbd0acc9fe77ec5c54866954
bigcode/the-stack
train
82246e96ed97279ab955bfff
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_stk_zseries(): """Test read MetaMorph STK z-series.""" fname = private_file('stk/zseries.stk') with TiffFile(fname) as tif: assert tif.is_stk assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.s...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_stk_zseries():
"""Test read MetaMorph STK z-series.""" fname = private_file('stk/zseries.stk') with TiffFile(fname) as tif: assert tif.is_stk assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.series) == 1 # assert page properties page = tif.pages[0] ...
ometric == RGB assert page.compression == LZW assert page.imagewidth == 512 assert page.imagelength == 512 assert page.bitspersample == 16 assert page.samplesperpixel == 2 page = tif.pages[834] assert isinstance(page, TiffFrame) assert page.dataoffsets == ...
166
166
554
21
145
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_stk_zseries
test_read_stk_zseries
6,205
6,254
6,205
6,206
445efc7e7f5521c9f39e7b793bb500d7ea8c4f2f
bigcode/the-stack
train
f947e68f33db18213f125d50
train
function
def test_func_memmap_fail(): """Test non-native byteorder can not be memory mapped.""" with TempFileName('memmap_fail') as fname: with pytest.raises(ValueError): memmap( fname, shape=(16, 16), dtype=numpy.float32, byteorder='>' ...
def test_func_memmap_fail():
"""Test non-native byteorder can not be memory mapped.""" with TempFileName('memmap_fail') as fname: with pytest.raises(ValueError): memmap( fname, shape=(16, 16), dtype=numpy.float32, byteorder='>' if sys.byteorder == 'little' ...
del im # can not memory-map compressed array with pytest.raises(ValueError): memmap( fname, shape=(16, 16), dtype=numpy.float32, append=True, compression=ADOBE_DEFLATE, ) def test_func_memmap_fail():...
64
64
80
7
57
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_memmap_fail
test_func_memmap_fail
2,359
2,368
2,359
2,359
a6e1b72a875a1918c787239ecbeb9c5759b15623
bigcode/the-stack
train
d81542007636fc1372e304be
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_filehandle_offset(): """Test FileHandle from other FileHandle with offset.""" with FileHandle(FILEHANDLE_NAME, 'rb') as fhandle: with FileHandle( fhandle, offset=FILEHANDLE_OFFSET, size=FILEHANDLE_LENGTH ) as fh: as...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_filehandle_offset():
"""Test FileHandle from other FileHandle with offset.""" with FileHandle(FILEHANDLE_NAME, 'rb') as fhandle: with FileHandle( fhandle, offset=FILEHANDLE_OFFSET, size=FILEHANDLE_LENGTH ) as fh: assert fh.name == 'test_FileHandle@333.bin' assert fh.is_file ...
as fhandle: with FileHandle(fhandle) as fh: assert fh.name == 'test_FileHandle.bin' assert fh.is_file assert_filehandle(fh) assert not fhandle.closed @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_filehandle_offset():
64
64
111
19
44
bioturing/tifffile
tests/test_tifffile.py
Python
test_filehandle_offset
test_filehandle_offset
3,528
3,538
3,528
3,529
3087dc385ad426f8b98def7aef354f359e264fc1
bigcode/the-stack
train
88805cd044d79a5869c25e72
train
function
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS or SKIP_EXTENDED, reason=REASON) @pytest.mark.parametrize('fname', TIGER_FILES, ids=TIGER_IDS) def test_read_tigers(fname): """Test tiger images from GraphicsMagick.""" # ftp://ftp.graphicsmagick.org/pub/tiff-samples with TiffFile(fname) as tif: byteord...
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS or SKIP_EXTENDED, reason=REASON) @pytest.mark.parametrize('fname', TIGER_FILES, ids=TIGER_IDS) def test_read_tigers(fname):
"""Test tiger images from GraphicsMagick.""" # ftp://ftp.graphicsmagick.org/pub/tiff-samples with TiffFile(fname) as tif: byteorder = {'le': '<', 'be': '>'}[os.path.split(fname)[0][-2:]] databits = int(fname.rsplit('.tif')[0][-2:]) # assert file properties assert_file_flags(...
== '\\\\localhost\\Data\\Data' assert_filehandle(fh) ############################################################################### # Test reading specific files if SKIP_EXTENDED or SKIP_PRIVATE: TIGER_FILES = [] TIGER_IDS = [] else: TIGER_FILES = ( public_file('graphicsmagick.org/be/*...
208
209
698
46
162
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_tigers
test_read_tigers
3,590
3,667
3,590
3,592
dfaa5634a8c81e856777e272e921641bbb0f4369
bigcode/the-stack
train
a55f920676c620489cbaa8e3
train
function
def test_write_auto_rgba_contig(): """Test write auto contig RGBA.""" data = random_data(numpy.uint8, (219, 301, 4)) with TempFileName('auto_rgba_contig') as fname: imwrite(fname, data) # photometric=RGB assert_valid_tiff(fname) with TiffFile(fname) as tif: assert len(ti...
def test_write_auto_rgba_contig():
"""Test write auto contig RGBA.""" data = random_data(numpy.uint8, (219, 301, 4)) with TempFileName('auto_rgba_contig') as fname: imwrite(fname, data) # photometric=RGB assert_valid_tiff(fname) with TiffFile(fname) as tif: assert len(tif.pages) == 1 page = ti...
301 assert page.imagelength == 219 assert page.samplesperpixel == 3 image = tif.asarray() assert_array_equal(data, image) assert_aszarr_method(tif, image) assert__str__(tif) def test_write_auto_rgba_contig():
64
64
205
9
55
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_auto_rgba_contig
test_write_auto_rgba_contig
11,813
11,832
11,813
11,813
5f113fde52d22908e98c309659f1a79a4b4fd23c
bigcode/the-stack
train
a23fb700ed964d4a1c0991c5
train
function
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_issue_ojpeg_preview(): """Test read JPEGInterchangeFormat from RAW image.""" # https://github.com/cgohlke/tifffile/issues/93 fname = private_file('RAW/RAW_NIKON_D3X.NEF') with TiffFile(fname) as tif:...
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_issue_ojpeg_preview():
"""Test read JPEGInterchangeFormat from RAW image.""" # https://github.com/cgohlke/tifffile/issues/93 fname = private_file('RAW/RAW_NIKON_D3X.NEF') with TiffFile(fname) as tif: assert len(tif.pages) == 1 page = tif.pages[0] assert page.compression == NONE assert page.sh...
2) assert page.dtype == numpy.uint16 assert page.photometric == MINISWHITE assert page.compression == OJPEG # SOF3 data = page.asarray() assert tuple(data[2000, 1500]) == (1759, 2467) assert_aszarr_method(page, data) @pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS ...
109
109
364
36
73
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_ojpeg_preview
test_issue_ojpeg_preview
1,226
1,262
1,226
1,229
550931f10f7007d6523025cb0674dee4baae9064
bigcode/the-stack
train
0756d8f7ef632d3fd4bb0bf7
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_ome_z_series(): """Test read OME volume.""" # 3D (5 focal planes) fname = public_file('OME/bioformats-artificial/z-series.ome.tif') with TiffFile(fname) as tif: assert tif.is_ome assert tif.byteorder == '>' assert len(...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_ome_z_series():
"""Test read OME volume.""" # 3D (5 focal planes) fname = public_file('OME/bioformats-artificial/z-series.ome.tif') with TiffFile(fname) as tif: assert tif.is_ome assert tif.byteorder == '>' assert len(tif.pages) == 5 assert len(tif.series) == 1 # assert page prop...
) assert data.shape == (3, 167, 439) assert data.dtype == numpy.int8 assert data[2, 158, 428] == 91 assert_aszarr_method(tif, data) # don't squeeze data = tif.asarray(squeeze=False) assert_aszarr_method(tif, data, squeeze=False) assert__str__(tif) @pytest....
108
108
362
21
87
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_ome_z_series
test_read_ome_z_series
7,132
7,166
7,132
7,133
4fff860aa15fe050bb625c5bb52987114c05b064
bigcode/the-stack
train
2dd93bc33b75b7db302ca4e7
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_read_rgba_wo_extra_samples(): """Test read 1065x785 RGBA uint8.""" fname = private_file('rgba_wo_extra_samples.tif') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_read_rgba_wo_extra_samples():
"""Test read 1065x785 RGBA uint8.""" fname = private_file('rgba_wo_extra_samples.tif') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.series) == 1 # assert page properties page = tif.pages[0] assert page.phot...
_CONTIGUOUS'] assert data.shape == (128, 128, 4) assert data.dtype == numpy.uint8 assert tuple(data[22, 112, :]) == (100, 99, 98, 132) assert_aszarr_method(tif, data) assert__str__(tif) @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_read_rgba_wo_extra_sa...
100
100
335
28
72
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_rgba_wo_extra_samples
test_read_rgba_wo_extra_samples
4,485
4,517
4,485
4,486
0a2559c97d92581ac71f9290eb12797080dba5cd
bigcode/the-stack
train
aa8acf053c0615f6f0599927
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_ome_modulo_flim_tcspc(): """Test read OME modulo FLIM TSCPC.""" # Two channels each recorded at two timepoints and eight histogram bins fname = public_file('OME/modulo/FLIM-ModuloAlongT-TSCPC.ome.tiff') with TiffFile(fname) as tif: as...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_ome_modulo_flim_tcspc():
"""Test read OME modulo FLIM TSCPC.""" # Two channels each recorded at two timepoints and eight histogram bins fname = public_file('OME/modulo/FLIM-ModuloAlongT-TSCPC.ome.tiff') with TiffFile(fname) as tif: assert tif.is_ome assert tif.byteorder == '<' assert len(tif.pages) == 32...
, 150, 180) assert data.dtype == numpy.int8 assert data[1, 7, 143, 172] == 92 assert_aszarr_method(tif, data) # don't squeeze data = tif.asarray(squeeze=False) assert_aszarr_method(tif, data, squeeze=False) assert__str__(tif) @pytest.mark.skipif(SKIP_PUBLIC, reaso...
108
108
362
26
82
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_ome_modulo_flim_tcspc
test_read_ome_modulo_flim_tcspc
7,403
7,435
7,403
7,404
c0a34122ffec986da901b274b30792d0f5945440
bigcode/the-stack
train
f0a1c9d37ea7aa7fa37baed4
train
function
def test_write_minisblack_planar(): """Test write planar minisblack.""" data = random_data(numpy.uint8, (3, 219, 301)) with TempFileName('minisblack_planar') as fname: imwrite(fname, data, photometric=MINISBLACK) assert_valid_tiff(fname) with TiffFile(fname) as tif: asser...
def test_write_minisblack_planar():
"""Test write planar minisblack.""" data = random_data(numpy.uint8, (3, 219, 301)) with TempFileName('minisblack_planar') as fname: imwrite(fname, data, photometric=MINISBLACK) assert_valid_tiff(fname) with TiffFile(fname) as tif: assert len(tif.pages) == 3 pa...
.samplesperpixel == 219 assert len(page.extrasamples) == 219 - 3 image = tif.asarray() assert_array_equal(data, image) assert_aszarr_method(tif, image) assert__str__(tif) def test_write_minisblack_planar():
64
64
188
9
55
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_minisblack_planar
test_write_minisblack_planar
11,622
11,640
11,622
11,622
818ff193e0646bbb516b250e84b32dfc9c49b187
bigcode/the-stack
train
a930e6d5804b29eb89ec6508
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_issue_missing_eoi_in_strips(): """Test read LZW strips without EOI.""" # 256x256 uint16, lzw, imagej # Strips do not contain an EOI code as required by the TIFF spec. # File generated by `tiffcp -c lzw Z*.tif stack.tif` from # ...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_issue_missing_eoi_in_strips():
"""Test read LZW strips without EOI.""" # 256x256 uint16, lzw, imagej # Strips do not contain an EOI code as required by the TIFF spec. # File generated by `tiffcp -c lzw Z*.tif stack.tif` from # Bars-G10-P15.zip # Failed with "series 0 failed: string size must be a multiple of # element siz...
abytecounts[0] == 0 # assert data image = tif.asarray() assert image.shape == (800, 1200) # fails: assert_aszarr_method(tif, image) assert 'invalid value offset 0' in caplog.text assert 'invalid data type 31073' in caplog.text assert 'invalid page offset 808333686' in caplog....
119
119
398
28
90
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_missing_eoi_in_strips
test_issue_missing_eoi_in_strips
703
739
703
704
74ccbabf1d0ebc3b76fa73aaa2b3b5bd5d1100fa
bigcode/the-stack
train
d563ed453fad2b81b5bda04e
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_bad_ascii(caplog): """Test coercing invalid ASCII to bytes.""" # ImageID is not ASCII but bytes # https://github.com/blink1073/tifffile/pull/38 fname = private_file('issues/tifffile_013_tagfail.tif') with TiffFile(fname) as tif: ...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_bad_ascii(caplog):
"""Test coercing invalid ASCII to bytes.""" # ImageID is not ASCII but bytes # https://github.com/blink1073/tifffile/pull/38 fname = private_file('issues/tifffile_013_tagfail.tif') with TiffFile(fname) as tif: tags = tif.pages[0].tags assert tags['ImageID'].value[-8:] == b'rev 2893' ...
(fname) as tif: page = tif.pages[0] assert page.description == '' assert__str__(tif) assert 'coercing invalid ASCII to bytes' in caplog.text @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_bad_ascii(caplog):
64
64
141
21
42
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_bad_ascii
test_issue_bad_ascii
572
582
572
573
3a05421f27420682daab16a250ea9616c216c98d
bigcode/the-stack
train
d00c3b1b9fa99ebfa01cc2df
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_issue_filesequence_file_parameter(): """Test FileSequence.asarray with deprecated 'file' parameter.""" # https://github.com/bluesky/tiled/pull/97 files = public_file('tifffile/temp_C001T00*.tif') with TiffSequence(files) as tiffs: assert ...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_issue_filesequence_file_parameter():
"""Test FileSequence.asarray with deprecated 'file' parameter.""" # https://github.com/bluesky/tiled/pull/97 files = public_file('tifffile/temp_C001T00*.tif') with TiffSequence(files) as tiffs: assert tiffs.shape == (2,) with pytest.warns(DeprecationWarning): assert_array_eq...
assert data.shape == (2, 1, 2, 200, 200) assert data[1, 0, 1, 100, 100] == 353 @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_issue_filesequence_file_parameter():
64
64
148
22
41
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_filesequence_file_parameter
test_issue_filesequence_file_parameter
1,552
1,563
1,552
1,553
e45ba1ff05ba8745beecb9f985129cb564f556b7
bigcode/the-stack
train
7dbe0558a0ef682c05cca441
train
function
def test_write_extrasamples_gray(): """Test write grayscale with extrasamples contig.""" data = random_data(numpy.uint8, (301, 219, 2)) with TempFileName('extrasamples_gray') as fname: imwrite(fname, data, extrasamples=UNASSALPHA) assert_valid_tiff(fname) with TiffFile(fname) as tif:...
def test_write_extrasamples_gray():
"""Test write grayscale with extrasamples contig.""" data = random_data(numpy.uint8, (301, 219, 2)) with TempFileName('extrasamples_gray') as fname: imwrite(fname, data, extrasamples=UNASSALPHA) assert_valid_tiff(fname) with TiffFile(fname) as tif: assert len(tif.pages) =...
301 assert page.imagelength == 219 assert page.samplesperpixel == 2 image = tif.asarray() assert_array_equal(data, image) assert_aszarr_method(tif, image) assert__str__(tif) def test_write_extrasamples_gray():
64
64
204
8
56
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_extrasamples_gray
test_write_extrasamples_gray
11,362
11,381
11,362
11,362
58f2fc80dd6b4100f3168cbb3de0268f0ff363b1
bigcode/the-stack
train
5728c63aac0d672835f5b65d
train
function
def test_func_imagej_description(): """Test imagej_description function.""" expected = ( 'ImageJ=1.11a\nimages=510\nchannels=2\nslices=5\n' 'frames=51\nhyperstack=true\nmode=grayscale\nloop=false\n' ) assert imagej_description((51, 5, 2, 196, 171)) == expected assert imagej_descripti...
def test_func_imagej_description():
"""Test imagej_description function.""" expected = ( 'ImageJ=1.11a\nimages=510\nchannels=2\nslices=5\n' 'frames=51\nhyperstack=true\nmode=grayscale\nloop=false\n' ) assert imagej_description((51, 5, 2, 196, 171)) == expected assert imagej_description((51, 5, 2, 196, 171), axes='TZCYX...
3, 4, 5, 3, 1)), ((1, 2, 3, 4, 5, 4, None), (1, 2, 3, 4, 5, 4)), ((6, 5, 4, 3, 2, 1, None), (6, 5, 4, 3, 2, 1)), ): assert imagej_shape(k[:-1], k[-1]) == v def test_func_imagej_description():
117
117
393
7
109
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_imagej_description
test_func_imagej_description
2,694
2,719
2,694
2,694
6f66928c959259650b6a2d1f4ef792fc3c2833eb
bigcode/the-stack
train
a4a2729aca977c70988faf80
train
function
def test_func_json_description(): """Test json_description function.""" descr = json_description((256, 256, 3), axes='YXS') assert json.loads(descr) == {'shape': [256, 256, 3], 'axes': 'YXS'}
def test_func_json_description():
"""Test json_description function.""" descr = json_description((256, 256, 3), axes='YXS') assert json.loads(descr) == {'shape': [256, 256, 3], 'axes': 'YXS'}
4, 8, 255, 255, 255] ) assert_array_equal( unpack_rgb(data, '<B', (5, 5, 5)), [16, 8, 8, 255, 255, 255] ) def test_func_json_description():
64
64
59
6
58
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_json_description
test_func_json_description
2,650
2,653
2,650
2,650
d622bdb81e07075d22986fdb584e5bcb4188df66
bigcode/the-stack
train
9e1fa9e253330e443dda95b7
train
function
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_read_cramps(): """Test 800x607 uint8, PackBits.""" fname = public_file('juicypixels/cramps.tif') with TiffFile(fname) as tif: assert tif.byteorder == '>' assert len(tif.pages) == 1 assert len(tif.series) == 1 ...
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_read_cramps():
"""Test 800x607 uint8, PackBits.""" fname = public_file('juicypixels/cramps.tif') with TiffFile(fname) as tif: assert tif.byteorder == '>' assert len(tif.pages) == 1 assert len(tif.series) == 1 # assert page properties page = tif.pages[0] assert page.compressi...
IGUOUS'] assert data.shape == (3, 81, 601) assert data.dtype == numpy.uint8 assert data[1, 24, 49] == 191 assert_aszarr_method(tif, data) assert__str__(tif) @pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_read_cramps():
86
86
288
24
62
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_cramps
test_read_cramps
4,108
4,137
4,108
4,109
a85c9df68883fd7b29b5532a461b6efb7caf96cc
bigcode/the-stack
train
62b4e28b039b26899d926d1b
train
function
def test_write_lists(): """Test write lists.""" array = numpy.arange(1000).reshape(10, 10, 10).astype(numpy.uint16) data = array.tolist() with TempFileName('write_lists') as fname: with TiffWriter(fname) as tif: tif.write(data, dtype=numpy.uint16) tif.write(data, compress...
def test_write_lists():
"""Test write lists.""" array = numpy.arange(1000).reshape(10, 10, 10).astype(numpy.uint16) data = array.tolist() with TempFileName('write_lists') as fname: with TiffWriter(fname) as tif: tif.write(data, dtype=numpy.uint16) tif.write(data, compression=ADOBE_DEFLATE) ...
'OME' if ome else 'Shaped' assert_array_equal(tif.series[s].asarray(), data[0]) for i in range(subifds): assert_array_equal( tif.series[s].levels[i + 1].asarray(), data[i + 1] ) def test_write_lists():
67
67
226
5
62
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_lists
test_write_lists
9,994
10,012
9,994
9,994
87bd3d438df3076985aee8df6f61f7010da2892c
bigcode/the-stack
train
e6241d06287287be3f918e3d
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_imagej_grascalemode(): """Test read ImageJ grayscale mode RGB image.""" # https://github.com/cgohlke/tifffile/issues/6 fname = private_file('issues/hela-cells.tif') with TiffFile(fname) as tif: assert tif.is_imagej assert ti...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_imagej_grascalemode():
"""Test read ImageJ grayscale mode RGB image.""" # https://github.com/cgohlke/tifffile/issues/6 fname = private_file('issues/hela-cells.tif') with TiffFile(fname) as tif: assert tif.is_imagej assert tif.byteorder == '>' assert len(tif.pages) == 1 assert len(tif.series) ==...
1.41e' # assert data data = tif.asarray() assert data.shape == (128, 256, 256) assert data.dtype == numpy.uint16 assert data[64, 128, 128] == 19226 assert_aszarr_method(tif, data) del data assert__str__(tif) @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)...
102
102
340
23
79
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_imagej_grascalemode
test_issue_imagej_grascalemode
742
775
742
743
3e3ecffe1c9db2cb4f4807ebca00929f0c4bf6c4
bigcode/the-stack
train
143436a500677e56d6ec29e5
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_sequence_imread(): """Test TiffSequence with imagecodecs.imread.""" fname = private_file('PNG/*.png') pngs = TiffSequence(fname, imread=imagecodecs.imread) assert len(pngs) == 4 assert pngs.shape == (4,) assert pngs.axes ==...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_sequence_imread():
"""Test TiffSequence with imagecodecs.imread.""" fname = private_file('PNG/*.png') pngs = TiffSequence(fname, imread=imagecodecs.imread) assert len(pngs) == 4 assert pngs.shape == (4,) assert pngs.axes == 'I' data = pngs.asarray(codec=imagecodecs.png_decode) assert data.flags['C_CONTIGUO...
data[1, 2, 1, 3:5], zarr.open(store, mode='r')[1, 2, 1, 3:5], ) @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_sequence_imread():
64
64
182
24
40
bioturing/tifffile
tests/test_tifffile.py
Python
test_sequence_imread
test_sequence_imread
14,198
14,213
14,198
14,199
d639e300754e6146686e294c0303b8b1b37f546c
bigcode/the-stack
train
68441b9f401ed7ebbfac4166
train
function
def test_func_pilatus_header_metadata(): """Test pilatus_description_metadata function.""" header = """ # Detector: PILATUS 300K, 3-0101 # 2011-07-22T17:33:22.529 # Pixel_size 172e-6 m x 172e-6 m # Silicon sensor, thickness 0.000320 m # Exposure_time 0.0970000 s #...
def test_func_pilatus_header_metadata():
"""Test pilatus_description_metadata function.""" header = """ # Detector: PILATUS 300K, 3-0101 # 2011-07-22T17:33:22.529 # Pixel_size 172e-6 m x 172e-6 m # Silicon sensor, thickness 0.000320 m # Exposure_time 0.0970000 s # Exposure_period 0.1000000 s # Ta...
'frames=51\nhyperstack=true\nmode=grayscale\nloop=false\n' ) imagej_dict = { 'ImageJ': '1.11a', 'images': 510, 'channels': 2, 'slices': 5, 'frames': 51, 'hyperstack': True, 'mode': 'grayscale', 'loop': False, } assert imagej_descrip...
114
114
380
9
104
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_pilatus_header_metadata
test_func_pilatus_header_metadata
2,741
2,770
2,741
2,741
bcd4a28984c11af9bcba560eef1486843a2c3d32
bigcode/the-stack
train
c541c746b5a49368b05d193f
train
function
def test_func_pformat_printable_bytes(): """Test pformat function with printable bytes.""" value = ( b'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRST' b'UVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c' ) assert pformat(value, height=1, width=60) == ( '012345678...
def test_func_pformat_printable_bytes():
"""Test pformat function with printable bytes.""" value = ( b'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRST' b'UVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c' ) assert pformat(value, height=1, width=60) == ( '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN...
abcdefghijklmnop', 8, snipat=0, ellipsis='....') == '....mnop' ) assert ( snipstr('abcdefghijklmnop', 8, snipat=0, ellipsis='......') == '......op' ) def test_func_pformat_printable_bytes():
64
64
139
9
55
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_pformat_printable_bytes
test_func_pformat_printable_bytes
2,993
3,009
2,993
2,993
d4512c605178868a40b14ed44ffcac9eeadb54f2
bigcode/the-stack
train
a9c7268d6cd9b720c6efee82
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_issue_description_bytes(caplog): """Test reading file with imagedescription bytes.""" # https://github.com/cgohlke/tifffile/issues/112 with TempFileName('issue_description_bytes') as fname: imwrite( fname, [[0]], ...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_issue_description_bytes(caplog):
"""Test reading file with imagedescription bytes.""" # https://github.com/cgohlke/tifffile/issues/112 with TempFileName('issue_description_bytes') as fname: imwrite( fname, [[0]], description='1st description', extratags=[ (270, 1, None...
as tif: assert tif.is_imagej page = tif.pages[0] assert isinstance(page.tags['IJMetadataByteCounts'].value, tuple) assert isinstance(page.tags['IJMetadata'].value, dict) @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_issue_description_bytes(caplog):
67
67
226
21
46
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_description_bytes
test_issue_description_bytes
1,633
1,654
1,633
1,634
b2dbe445fdec29736a673f04aefb8496387d4f4a
bigcode/the-stack
train
3dfecdf60f04b864048c7960
train
function
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_read_lsm_lzw_no_eoi(): """Test read LSM with LZW compressed strip without EOI.""" # The first LZW compressed strip in page 834 has no EOI # such that too much data is returned from the decoder and # the data of the 2nd channel was g...
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_read_lsm_lzw_no_eoi():
"""Test read LSM with LZW compressed strip without EOI.""" # The first LZW compressed strip in page 834 has no EOI # such that too much data is returned from the decoder and # the data of the 2nd channel was getting corrupted fname = public_file('tifffile/MB231paxgfp_060214.lzw.lsm') with TiffFi...
60 assert tags['DimensionChannels'] == 2 # assert some lsm_scan_info tags tags = tif.lsm_metadata['ScanInformation'] assert tags['ScanMode'] == 'Stack' assert tags['User'] == 'lfdguest1' assert__str__(tif, 0) @pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON)...
99
99
333
29
70
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_lsm_lzw_no_eoi
test_read_lsm_lzw_no_eoi
6,174
6,202
6,174
6,175
d56ad1a861a78a7d8c7fcaa9d4c17d6b4add35dd
bigcode/the-stack
train
4748abb4446a8aa455f4a600
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) @pytest.mark.parametrize('fp', ['fp16', 'fp24', 'fp32']) def test_read_dng_floatpredx2(fp): """Test read FLOATINGPOINTX2 predictor in DNG.""" # <https://raw.pixls.us/data/Canon/EOS%205D%20Mark%20III/> fname = private_file(f'DNG/fpx2/hdrmerge-ba...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) @pytest.mark.parametrize('fp', ['fp16', 'fp24', 'fp32']) def test_read_dng_floatpredx2(fp):
"""Test read FLOATINGPOINTX2 predictor in DNG.""" # <https://raw.pixls.us/data/Canon/EOS%205D%20Mark%20III/> fname = private_file(f'DNG/fpx2/hdrmerge-bayer-{fp}-w-pred-deflate.dng') with TiffFile(fname) as tif: assert len(tif.pages) == 1 assert len(tif.series) == 3 page = tif.pag...
(tif.series) == 6 for series in tif.series: image = series.asarray() assert_aszarr_method(series, image) assert__str__(tif) @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) @pytest.mark.parametrize('fp', ['fp16', 'fp24', 'fp32']) def test_read_dng_floatpredx2(fp):
86
86
288
47
39
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_dng_floatpredx2
test_read_dng_floatpredx2
3,925
3,949
3,925
3,927
15cf0addd05b506670f7df9a3737e9654e9949f3
bigcode/the-stack
train
31772e335819f4ed49c8bc41
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_scanimage_no_framedata(): """Test read ScanImage no FrameData.""" fname = private_file('ScanImage/PSF001_ScanImage36.tif') with TiffFile(fname) as tif: assert tif.is_scanimage assert len(tif.pages) == 100 assert len(tif.s...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_scanimage_no_framedata():
"""Test read ScanImage no FrameData.""" fname = private_file('ScanImage/PSF001_ScanImage36.tif') with TiffFile(fname) as tif: assert tif.is_scanimage assert len(tif.pages) == 100 assert len(tif.series) == 1 # no non-tiff scanimage_metadata assert not tif.scanimage_met...
) assert metadata['epoch'] == [2021, 3, 1, 17, 31, 28.047] assert_aszarr_method(tif) assert__str__(tif) @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_scanimage_no_framedata():
69
69
231
23
46
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_scanimage_no_framedata
test_read_scanimage_no_framedata
6,944
6,967
6,944
6,945
9818a45217c415f6c2ca50c303d412d11969da95
bigcode/the-stack
train
84943bc3156ac4ebece38752
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def create_filehandle_file(): """Write test_FileHandle.bin file.""" # array start 999 # array end 1254 # recarray start 2253 # recarray end 6078 # tiff start 7077 # tiff end 12821 # mm offset = 13820 # mm size = 7936382 with open(FI...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def create_filehandle_file():
"""Write test_FileHandle.bin file.""" # array start 999 # array end 1254 # recarray start 2253 # recarray end 6078 # tiff start 7077 # tiff end 12821 # mm offset = 13820 # mm size = 7936382 with open(FILEHANDLE_NAME, 'wb') as fh: # buffer numpy.ones(999, dtype=num...
elif out == 'name': # memmap in specified file with TempFileName( f'out_{key}_{out}', ext='.memmap' ) as fileout: image = obj.asarray(out=fileout) assert isinstance(image, numpy.core.memmap) ...
142
142
475
19
122
bioturing/tifffile
tests/test_tifffile.py
Python
create_filehandle_file
create_filehandle_file
3,320
3,365
3,320
3,321
01c3dc4b67cd416e7ed5698254653636f063c2e2
bigcode/the-stack
train
e79c7f076fbdf1f0136e0d88
train
function
def test_write_extrasamples_unspecified(): """Test write RGB with unspecified extrasamples by default.""" data = random_data(numpy.uint8, (301, 219, 5)) with TempFileName('extrasamples_unspecified') as fname: imwrite(fname, data, photometric=RGB) assert_valid_tiff(fname) with TiffFil...
def test_write_extrasamples_unspecified():
"""Test write RGB with unspecified extrasamples by default.""" data = random_data(numpy.uint8, (301, 219, 5)) with TempFileName('extrasamples_unspecified') as fname: imwrite(fname, data, photometric=RGB) assert_valid_tiff(fname) with TiffFile(fname) as tif: assert len(tif...
perpixel == 4 assert page.extrasamples == (1, 2, 0) image = tif.asarray() assert_array_equal(data, image) assert_aszarr_method(tif, image) assert__str__(tif) def test_write_extrasamples_unspecified():
64
64
192
9
55
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_extrasamples_unspecified
test_write_extrasamples_unspecified
11,432
11,450
11,432
11,432
1014a5ce813fba42463880f583d5deba932d3821
bigcode/the-stack
train
e552e09dd9645cc61160ece1
train
function
def test_func_pformat_list(): """Test pformat function with list.""" value = ( 60.0, 0.0, 0.0, 600000.0, 0.0, -60.0, 0.0, 5900040.0, 60.0, 0.0, 0.0, 600000.0, 0.0, -60.0, 0.0, 5900040....
def test_func_pformat_list():
"""Test pformat function with list.""" value = ( 60.0, 0.0, 0.0, 600000.0, 0.0, -60.0, 0.0, 5900040.0, 60.0, 0.0, 0.0, 600000.0, 0.0, -60.0, 0.0, 5900040.0, ) assert pformat(v...
, 'KeyDirectoryVersion': 1, ... [ 0., 0., 0., 0.], [ 0., 0., 0., 1.]]), 'PCSCitationGeoKey': 'WGS 84 / UTM zone 29N', 'ProjectedCSTypeGeoKey': 32629}""" ) def test_func_pformat_list():
90
90
301
7
83
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_pformat_list
test_func_pformat_list
3,095
3,123
3,095
3,095
82744d9f0598c7c213e66d2b62f51528a4639126
bigcode/the-stack
train
a10af58ae33740e5d2549b46
train
function
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.PNG, reason=REASON ) def test_issue_filesequence_categories(): """Test FileSequence with categories.""" # https://github.com/cgohlke/tifffile/issues/76 with tifffile.FileSequence( imagecodecs.imread, private_file('datas...
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.PNG, reason=REASON ) def test_issue_filesequence_categories():
"""Test FileSequence with categories.""" # https://github.com/cgohlke/tifffile/issues/76 with tifffile.FileSequence( imagecodecs.imread, private_file('dataset-A1-20200531/*.png'), pattern=( r'(?P<sampleid>.{2})-' r'(?P<experiment>.+)-\d{8}T\d{6}-PSII0-' ...
tag value assert isclosed == page.parent.filehandle.closed with pytest.warns(UserWarning): frame.asarray() # read data assert isclosed == page.parent.filehandle.closed assert count > 0 @pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs....
84
84
283
35
48
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_filesequence_categories
test_issue_filesequence_categories
1,526
1,549
1,526
1,529
aea6922cc84975e024139444257c961288980941
bigcode/the-stack
train
f2ea2c3ab84cc6ed65287f0d
train
function
@pytest.mark.skipif(SKIP_BE, reason=REASON) def test_func_unpack_rgb(): """Test unpack_rgb function.""" data = struct.pack('BBBB', 0x21, 0x08, 0xFF, 0xFF) assert_array_equal( unpack_rgb(data, '<B', (5, 6, 5), False), [1, 1, 1, 31, 63, 31] ) assert_array_equal( unpack_rgb(data, '<B', ...
@pytest.mark.skipif(SKIP_BE, reason=REASON) def test_func_unpack_rgb():
"""Test unpack_rgb function.""" data = struct.pack('BBBB', 0x21, 0x08, 0xFF, 0xFF) assert_array_equal( unpack_rgb(data, '<B', (5, 6, 5), False), [1, 1, 1, 31, 63, 31] ) assert_array_equal( unpack_rgb(data, '<B', (5, 6, 5)), [8, 4, 8, 255, 255, 255] ) assert_array_equal( ...
4) assert subresolution(a, b) is None b.shape = (3, 32, 64, 128, 4) assert subresolution(a, b) == 3 @pytest.mark.skipif(SKIP_BE, reason=REASON) def test_func_unpack_rgb():
64
64
182
19
44
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_unpack_rgb
test_func_unpack_rgb
2,635
2,647
2,635
2,636
8a8480b66a2e322f59f792e3c482a5ec7c1c6330
bigcode/the-stack
train
231c4a61c1514689a165cc7d
train
function
def assert_embed_micromanager(tif): """Assert embedded MicroManager TIFF file.""" assert tif.is_ome assert tif.is_imagej assert tif.is_micromanager assert tif.byteorder == '<' assert len(tif.pages) == 15 assert len(tif.series) == 1 # assert non-tiff micromanager_metadata tags = tif.m...
def assert_embed_micromanager(tif):
"""Assert embedded MicroManager TIFF file.""" assert tif.is_ome assert tif.is_imagej assert tif.is_micromanager assert tif.byteorder == '<' assert len(tif.pages) == 15 assert len(tif.series) == 1 # assert non-tiff micromanager_metadata tags = tif.micromanager_metadata['Summary'] ...
== numpy.float32 assert series.axes == 'YX' page = series.pages[0] assert page.compression == LZW assert page.imagewidth == 10 assert page.imagelength == 10 assert page.bitspersample == 32 assert page.samplesperpixel == 1 data = tif.asarray(series=3) assert isinstance(data, numpy.nd...
152
152
507
10
142
bioturing/tifffile
tests/test_tifffile.py
Python
assert_embed_micromanager
assert_embed_micromanager
13,885
13,933
13,885
13,885
fa434b05c19c9e83d409a7c0e280fda385695dd9
bigcode/the-stack
train
62f62da628482bd32eda8f09
train
function
@pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_read_ndpi_4gb(): """Test read > 4GB Hamamatsu NDPI slide, JPEG 103680x188160.""" fname = private_file('HamamatsuNDPI/103680x188160.ndpi') with TiffFile(fname) as tif: assert tif.is_ndpi asse...
@pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_read_ndpi_4gb():
"""Test read > 4GB Hamamatsu NDPI slide, JPEG 103680x188160.""" fname = private_file('HamamatsuNDPI/103680x188160.ndpi') with TiffFile(fname) as tif: assert tif.is_ndpi assert len(tif.pages) == 8 assert len(tif.series) == 3 for page in tif.pages: assert page.ndpi_...
assert page.is_ndpi assert page.photometric == YCBCR assert page.compression == JPEG assert page.shape == (33792, 79872, 3) assert page.ndpi_tags['Magnification'] == 20.0 # with pytest.raises(RuntimeError): if not SKIP_PYPY: data = page.asarray() ...
244
244
814
37
207
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_ndpi_4gb
test_read_ndpi_4gb
6,606
6,670
6,606
6,609
efe7c11677ba7c3a6a3aa3a1bc5e4b3b710b3885
bigcode/the-stack
train
a19d55b6cc8f0f31f2a274fa
train
function
@pytest.mark.parametrize( 'axes, shape, storedshape, sizetzc, dimorder', [ ('ZAYX', (3, 4, 32, 32), (12, 1, 1, 32, 32, 1), (1, 12, 1), 'XYCZT'), ('AYX', (3, 32, 32), (3, 1, 1, 32, 32, 1), (3, 1, 1), 'XYCZT'), ('APYX', (3, 4, 32, 32), (12, 1, 1, 32, 32, 1), (3, 4, 1), 'XYCZT'), ('...
@pytest.mark.parametrize( 'axes, shape, storedshape, sizetzc, dimorder', [ ('ZAYX', (3, 4, 32, 32), (12, 1, 1, 32, 32, 1), (1, 12, 1), 'XYCZT'), ('AYX', (3, 32, 32), (3, 1, 1, 32, 32, 1), (3, 1, 1), 'XYCZT'), ('APYX', (3, 4, 32, 32), (12, 1, 1, 32, 32, 1), (3, 4, 1), 'XYCZT'), ('...
"""Test OmeXml class with modulo dimensions.""" dtype = numpy.uint8 omexml = OmeXml() omexml.addimage(dtype, shape, storedshape, axes=axes) assert '\n ' in str(omexml) omexml = omexml.tostring() assert dimorder in omexml for ax, size in zip('TZC', sizetzc): assert f'Size{ax}="{s...
@pytest.mark.parametrize( 'axes, shape, storedshape, sizetzc, dimorder', [ ('ZAYX', (3, 4, 32, 32), (12, 1, 1, 32, 32, 1), (1, 12, 1), 'XYCZT'), ('AYX', (3, 32, 32), (3, 1, 1, 32, 32, 1), (3, 1, 1), 'XYCZT'), ('APYX', (3, 4, 32, 32), (12, 1, 1, 32, 32, 1), (3, 4, 1), 'XYCZT'), ('...
740
256
859
740
0
bioturing/tifffile
tests/test_tifffile.py
Python
test_class_omexml_modulo
test_class_omexml_modulo
2,150
2,225
2,150
2,215
3eea45e5dac5b35b9bab28ddc0daf12e3aef9f54
bigcode/the-stack
train
5fb7303e51c4bf91b8e0fcef
train
function
def test_write_extrasamples_planar_rgb2(): """Test write planar RGB with large number of extrasamples.""" data = random_data(numpy.uint8, (219, 301, 3)) with TempFileName('extrasamples_planar_rgb2') as fname: imwrite(fname, data, photometric=RGB, planarconfig=SEPARATE) assert_valid_tiff(fnam...
def test_write_extrasamples_planar_rgb2():
"""Test write planar RGB with large number of extrasamples.""" data = random_data(numpy.uint8, (219, 301, 3)) with TempFileName('extrasamples_planar_rgb2') as fname: imwrite(fname, data, photometric=RGB, planarconfig=SEPARATE) assert_valid_tiff(fname) with TiffFile(fname) as tif: ...
perpixel == 219 assert len(page.extrasamples) == 219 - 1 image = tif.asarray() assert_array_equal(data, image) assert_aszarr_method(tif, image) assert__str__(tif) def test_write_extrasamples_planar_rgb2():
65
65
217
11
54
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_extrasamples_planar_rgb2
test_write_extrasamples_planar_rgb2
11,600
11,619
11,600
11,600
efe5ee186857a425281b0aa0919c1a524e7290b1
bigcode/the-stack
train
26c17e91cd8d52b13a41e8c9
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_embed_mm_openfile_seek(): """Test embedded MicroManager TIFF from seeked file handle.""" with open(EMBED_NAME, 'rb') as fh: fh.seek(EMBED_OFFSET1) with TiffFile(fh, size=EMBED_SIZE1) as tif: assert_embed_micromanager(tif)
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_embed_mm_openfile_seek():
"""Test embedded MicroManager TIFF from seeked file handle.""" with open(EMBED_NAME, 'rb') as fh: fh.seek(EMBED_OFFSET1) with TiffFile(fh, size=EMBED_SIZE1) as tif: assert_embed_micromanager(tif)
_NAME, 'rb') as fh: with TiffFile(fh, offset=EMBED_OFFSET1, size=EMBED_SIZE1) as tif: assert_embed_micromanager(tif) @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_embed_mm_openfile_seek():
64
64
85
21
43
bioturing/tifffile
tests/test_tifffile.py
Python
test_embed_mm_openfile_seek
test_embed_mm_openfile_seek
13,992
13,998
13,992
13,993
fe64f7798b1b426007cd2e335d78b01c5bd66d5d
bigcode/the-stack
train
f5881977df2dbbec74cc81e1
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_ome_float_modulo_attributes(): """Test read OME with floating point modulo attributes.""" # reported by Start Berg. File by Lorenz Maier. fname = private_file('OME/float_modulo_attributes.ome.tiff') with TiffFile(fname) as tif: asser...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_ome_float_modulo_attributes():
"""Test read OME with floating point modulo attributes.""" # reported by Start Berg. File by Lorenz Maier. fname = private_file('OME/float_modulo_attributes.ome.tiff') with TiffFile(fname) as tif: assert tif.is_ome assert tif.byteorder == '>' assert len(tif.pages) == 2 as...
6, 3, 1024, 1024) assert data.dtype == numpy.uint8 assert tuple(data[5, :, 191, 449]) == (253, 0, 28) assert_aszarr_method(tif, data) assert_aszarr_method(tif, data, chunkmode='page') assert__str__(tif) @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_ome_float_modu...
104
104
347
23
81
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_ome_float_modulo_attributes
test_read_ome_float_modulo_attributes
7,789
7,822
7,789
7,790
59227899559937de06de4fad4affb33485b7efcd
bigcode/the-stack
train
29a46d6cae55cfd5bb647408
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_filehandle_bytesio(): """Test FileHandle from BytesIO.""" with open(FILEHANDLE_NAME, 'rb') as fh: stream = BytesIO(fh.read()) with FileHandle(stream) as fh: assert fh.name == 'Unnamed binary stream' assert not fh.is_file ...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_filehandle_bytesio():
"""Test FileHandle from BytesIO.""" with open(FILEHANDLE_NAME, 'rb') as fh: stream = BytesIO(fh.read()) with FileHandle(stream) as fh: assert fh.name == 'Unnamed binary stream' assert not fh.is_file assert_filehandle(fh)
=FILEHANDLE_OFFSET, size=FILEHANDLE_LENGTH ) as fh: assert fh.name == 'test_FileHandle.bin' assert fh.is_file assert_filehandle(fh, FILEHANDLE_OFFSET) @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_filehandle_bytesio():
64
64
84
20
44
bioturing/tifffile
tests/test_tifffile.py
Python
test_filehandle_bytesio
test_filehandle_bytesio
3,469
3,477
3,469
3,470
a17ee1b3d726f48cde8c520edb53c08d23f1a980
bigcode/the-stack
train