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
36fa90db6501bbdcae75a319
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_no_bytecounts(caplog): """Test read no bytecounts.""" with TiffFile(private_file('bad/img2_corrupt.tif')) as tif: assert not tif.is_bigtiff assert len(tif.pages) == 1 page = tif.pages[0] assert page.is_contiguous ...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_no_bytecounts(caplog):
"""Test read no bytecounts.""" with TiffFile(private_file('bad/img2_corrupt.tif')) as tif: assert not tif.is_bigtiff assert len(tif.pages) == 1 page = tif.pages[0] assert page.is_contiguous assert page.planarconfig == CONTIG assert page.dataoffsets[0] == 512 ...
4, 3) assert_aszarr_method(page, image) assert 'incorrect StripOffsets count' in caplog.text assert 'incorrect StripByteCounts count' in caplog.text @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_no_bytecounts(caplog):
64
64
202
22
41
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_no_bytecounts
test_issue_no_bytecounts
683
700
683
684
4f19060d20c0737c0784eefd6c975ebc1067e7eb
bigcode/the-stack
train
45a16d5e8849bfb23032b11a
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_ome_cropped(caplog): """Test read bad OME by ImageJ cropping.""" # ImageJ produces invalid ome-xml when cropping # http://lists.openmicroscopy.org.uk/pipermail/ome-devel/2013-December # /002631.html # Reported by Hadrien Mary on Dec 11,...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_ome_cropped(caplog):
"""Test read bad OME by ImageJ cropping.""" # ImageJ produces invalid ome-xml when cropping # http://lists.openmicroscopy.org.uk/pipermail/ome-devel/2013-December # /002631.html # Reported by Hadrien Mary on Dec 11, 2013 fname = private_file('ome/cropped.ome.tif') with TiffFile(fname) as ti...
ile # assert data data = tif.asarray() assert isinstance(data, numpy.ndarray) assert data.shape == (2, 512, 512) assert data.dtype == numpy.uint16 assert data[1, 158, 428] == 51 assert_aszarr_method(tif, data) assert_aszarr_method(tif, data, chunkmode='pag...
118
118
396
23
95
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_ome_cropped
test_read_ome_cropped
7,825
7,859
7,825
7,826
229c18aa3ea29c366b10fd84057f3b8ad43c1f8a
bigcode/the-stack
train
5d9c8fb43a6896d43cac42a8
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_issue_predictor_byteorder(): """Test read big-endian uint32 RGB with horizontal predictor.""" fname = private_file('issues/flower-rgb-contig-32_msb_zip_predictor.tiff') with TiffFile(fname) as tif: assert tif.tiff.byteorder =...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_issue_predictor_byteorder():
"""Test read big-endian uint32 RGB with horizontal predictor.""" fname = private_file('issues/flower-rgb-contig-32_msb_zip_predictor.tiff') with TiffFile(fname) as tif: assert tif.tiff.byteorder == '>' assert len(tif.pages) == 1 page = tif.pages[0] assert page.compression =...
data.dtype == numpy.int16 assert data[184, 72] == 24 assert_aszarr_method(page, data) data = tif.asarray() assert_aszarr_method(tif, data) @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_issue_predictor_byteorder():
73
73
244
26
47
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_predictor_byteorder
test_issue_predictor_byteorder
1,446
1,468
1,446
1,447
d5a729e7e5b0dc7a4b1a94bd4f5c60880a8716bd
bigcode/the-stack
train
8198c51632ba77c4967a9f23
train
function
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.JPEG2K, reason=REASON ) def test_read_ome_jpeg2000_be(): """Test read JPEG2000 compressed big-endian OME-TIFF.""" fname = private_file('OME/mitosis.jpeg2000.ome.tif') with TiffFile(fname) as tif: assert tif.is_ome assert...
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.JPEG2K, reason=REASON ) def test_read_ome_jpeg2000_be():
"""Test read JPEG2000 compressed big-endian OME-TIFF.""" fname = private_file('OME/mitosis.jpeg2000.ome.tif') with TiffFile(fname) as tif: assert tif.is_ome assert tif.byteorder == '>' assert len(tif.pages) == 510 assert len(tif.series) == 1 # assert page properties ...
perpixel == 1 # assert series properties series = tif.series[0] assert series.shape == (20000, 500) assert series.dtype == numpy.uint16 assert series.axes == 'YX' assert series.offset == 8 assert series.kind == 'Generic' @pytest.mark.skipif( SKIP_PRIVATE or SK...
106
106
356
41
65
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_ome_jpeg2000_be
test_read_ome_jpeg2000_be
7,983
8,016
7,983
7,986
5c3291af9d903f6b82822697d98506478ef878ce
bigcode/the-stack
train
44ca431d2752aa09b46b78c2
train
function
def test_write_compression_deflate(): """Test write ZLIB compression.""" data = WRITE_DATA with TempFileName('compression_deflate') as fname: imwrite(fname, data, compression=(DEFLATE, 6), photometric=RGB) assert_valid_tiff(fname) with TiffFile(fname) as tif: assert len(t...
def test_write_compression_deflate():
"""Test write ZLIB compression.""" data = WRITE_DATA with TempFileName('compression_deflate') as fname: imwrite(fname, data, compression=(DEFLATE, 6), photometric=RGB) assert_valid_tiff(fname) with TiffFile(fname) as tif: assert len(tif.pages) == 1 page = tif....
elength == data.shape[0] assert page.samplesperpixel == 3 image = tif.asarray() assert_allclose(data, image, atol=atol) assert_aszarr_method(tif, image) assert__str__(tif) def test_write_compression_deflate():
64
64
213
8
56
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_compression_deflate
test_write_compression_deflate
10,780
10,801
10,780
10,780
0b7f1a9e41c815a8e673900618cefa34dec7c6a2
bigcode/the-stack
train
217e5bfbfcd5cc4fb2ccaace
train
function
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_transpose_axes():
"""Test transpose_axes function.""" assert transpose_axes( numpy.zeros((2, 3, 4, 5)), 'TYXC', asaxes='CTZYX' ).shape == (5, 2, 1, 3, 4)
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_transpose_axes():
64
64
64
7
57
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_transpose_axes
test_func_transpose_axes
2,597
2,601
2,597
2,597
487995c55bbf193b25e887fc8ddf4a196386f43b
bigcode/the-stack
train
89d3a9b67423a896170e3a4a
train
function
def test_func_repeat_nd(): """Test repeat_nd function.""" a = repeat_nd([[0, 1, 2], [3, 4, 5], [6, 7, 8]], (2, 3)) assert_array_equal( a, [ [0, 0, 0, 1, 1, 1, 2, 2, 2], [0, 0, 0, 1, 1, 1, 2, 2, 2], [3, 3, 3, 4, 4, 4, 5, 5, 5], [3, 3, 3, 4, 4, 4...
def test_func_repeat_nd():
"""Test repeat_nd function.""" a = repeat_nd([[0, 1, 2], [3, 4, 5], [6, 7, 8]], (2, 3)) assert_array_equal( a, [ [0, 0, 0, 1, 1, 1, 2, 2, 2], [0, 0, 0, 1, 1, 1, 2, 2, 2], [3, 3, 3, 4, 4, 4, 5, 5, 5], [3, 3, 3, 4, 4, 4, 5, 5, 5], [6,...
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' else '<', ) def test_func_repea...
69
69
233
6
63
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_repeat_nd
test_func_repeat_nd
2,371
2,384
2,371
2,371
97e3cee8448a5a974fd7294d463b7164a65c62be
bigcode/the-stack
train
46f26b9f2931bc5e61e2ba2f
train
function
def test_write_compression_none(): """Test write compression=0.""" data = WRITE_DATA with TempFileName('compression_none') as fname: imwrite(fname, data, compression=0, photometric=RGB) assert_valid_tiff(fname) with TiffFile(fname) as tif: assert len(tif.pages) == 1 ...
def test_write_compression_none():
"""Test write compression=0.""" data = WRITE_DATA with TempFileName('compression_none') as fname: imwrite(fname, data, compression=0, photometric=RGB) assert_valid_tiff(fname) with TiffFile(fname) as tif: assert len(tif.pages) == 1 page = tif.pages[0] ...
page.imagelength == 219 assert page.samplesperpixel == 3 assert len(page.dataoffsets) == (9 if compressed else 3) image = tif.asarray() assert_array_equal(data, image) assert__str__(tif) def test_write_compression_none():
64
64
193
7
57
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_compression_none
test_write_compression_none
10,711
10,731
10,711
10,711
2f7520489aa91b5971515ec47fa9efb08922d0c7
bigcode/the-stack
train
6fd92d488d21b43280b0ad50
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_sem_metadata(): """Test read Zeiss SEM metadata.""" # file from hyperspy tests fname = private_file('hyperspy/test_tiff_Zeiss_SEM_1k.tif') with TiffFile(fname) as tif: assert tif.is_sem assert tif.byteorder == '<' ass...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_sem_metadata():
"""Test read Zeiss SEM metadata.""" # file from hyperspy tests fname = private_file('hyperspy/test_tiff_Zeiss_SEM_1k.tif') with TiffFile(fname) as tif: assert tif.is_sem assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.series) == 1 # assert pa...
assert page.imagewidth == 2560 assert page.imagelength == 1920 assert page.bitspersample == 8 assert page.samplesperpixel == 3 # assert metadata sis = tif.sis_metadata assert 'axes' not in sis assert sis['magnification'] == 20.0 assert__str__(tif) ...
103
103
345
19
84
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_sem_metadata
test_read_sem_metadata
9,334
9,366
9,334
9,335
e1499b1e13e948afae4ecd13775a900bfbbe3a7b
bigcode/the-stack
train
923c111029dea4d3f8b56977
train
function
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.LZW, reason=REASON ) def test_issue_read_from_closed_file(): """Test read from closed file handles.""" fname = private_file('OME/tubhiswt-4D-lzw/tubhiswt_C0_T0.ome.tif') with tifffile.TiffFile(fname) as tif: count = 0 fo...
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.LZW, reason=REASON ) def test_issue_read_from_closed_file():
"""Test read from closed file handles.""" fname = private_file('OME/tubhiswt-4D-lzw/tubhiswt_C0_T0.ome.tif') with tifffile.TiffFile(fname) as tif: count = 0 for frame in tif.series[0].pages[:10]: # most file handles are closed if frame is None: continu...
imread(fname, aszarr=True, chunkmode=chunkmode) as store: daskarray = dask.array.from_zarr(store).compute() assert_array_equal(data, daskarray) @pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.LZW, reason=REASON ) def test_issue_read_from_closed_file():
79
79
264
36
43
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_read_from_closed_file
test_issue_read_from_closed_file
1,492
1,523
1,492
1,495
177ee78e7b7aaa36f74a384e2708aac26f4f48a3
bigcode/the-stack
train
3a000138d59a52c0d1c57e0f
train
function
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) @pytest.mark.parametrize( 'fname', ['tiff_tiled_cmyk_jpeg.tif', 'tiff_strip_cmyk_jpeg.tif'] ) def test_read_jpeg_cmyk(fname): """Test read JPEG compressed CMYK image.""" with TiffFile(private_file(f'pillow/{fname}'...
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) @pytest.mark.parametrize( 'fname', ['tiff_tiled_cmyk_jpeg.tif', 'tiff_strip_cmyk_jpeg.tif'] ) def test_read_jpeg_cmyk(fname):
"""Test read JPEG compressed CMYK image.""" with TiffFile(private_file(f'pillow/{fname}')) as tif: assert len(tif.pages) == 1 page = tif.pages[0] assert page.compression == JPEG assert page.photometric == SEPARATED assert page.shape == (100, 100, 4) assert page.dt...
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) @pytest.mark.parametrize( 'fname', ['tiff_tiled_cmyk_jpeg.tif', 'tiff_strip_cmyk_jpeg.tif'] ) def test_read_jpeg_cmyk(fname):
72
71
237
72
0
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_jpeg_cmyk
test_read_jpeg_cmyk
4,854
4,875
4,854
4,860
31e6988197c2931008a1ecbbbfbf210f96b22bea
bigcode/the-stack
train
916ca43939313e77f54ff2ec
train
function
def assert_embed_tif(tif): """Assert embedded TIFF file.""" # 4 series in 6 pages assert tif.byteorder == '<' assert len(tif.pages) == 6 assert len(tif.series) == 4 # assert series 0 properties series = tif.series[0] assert series.shape == (3, 20, 20) assert series.dtype == numpy.uin...
def assert_embed_tif(tif):
"""Assert embedded TIFF file.""" # 4 series in 6 pages assert tif.byteorder == '<' assert len(tif.pages) == 6 assert len(tif.series) == 4 # assert series 0 properties series = tif.series[0] assert series.shape == (3, 20, 20) assert series.dtype == numpy.uint8 assert series.axes =...
assert tif.is_geotiff assert len(tif.pages) == 1 assert tif.nodata == -32767 assert tif.pages[0].tags['ModelPixelScaleTag'].value == ( 30.0, 30.0, 0.0, ) assert tif...
225
225
750
8
216
bioturing/tifffile
tests/test_tifffile.py
Python
assert_embed_tif
assert_embed_tif
13,810
13,882
13,810
13,810
08881a690ac96037f74991ec8d46a9d6a2d4f03c
bigcode/the-stack
train
683ad5beb6d4ee7756bcd2ba
train
function
@pytest.mark.skipif(SKIP_CODECS, reason=REASON) def test_write_volumetric_tiled_png(): """Test write tiled volume using an image compressor.""" data = random_data(numpy.uint8, (16, 64, 96, 3)) with TempFileName('volumetric_tiled_png') as fname: imwrite( fname, data, tile=(1, 64, 64), pho...
@pytest.mark.skipif(SKIP_CODECS, reason=REASON) def test_write_volumetric_tiled_png():
"""Test write tiled volume using an image compressor.""" data = random_data(numpy.uint8, (16, 64, 96, 3)) with TempFileName('volumetric_tiled_png') as fname: imwrite( fname, data, tile=(1, 64, 64), photometric=RGB, compression=PNG ) assert_valid_tiff(fname) with T...
assert page.tilelength == 64 assert page.tiledepth == 64 assert page.samplesperpixel == 1 image = tif.asarray() assert_array_equal(data, image) assert_aszarr_method(tif, image) assert__str__(tif) @pytest.mark.skipif(SKIP_CODECS, reason...
86
86
288
24
62
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_volumetric_tiled_png
test_write_volumetric_tiled_png
12,285
12,313
12,285
12,286
06b3891c501226304372872e5d83c0649c0af926
bigcode/the-stack
train
f83c51549057e96ff74cdd5d
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_issue_circular_ifd(): """Test circular IFD raises error.""" fname = public_file('Tiff-Library-4J/IFD struct/Circular E.tif') with pytest.raises(TiffFileError): imread(fname)
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_issue_circular_ifd():
"""Test circular IFD raises error.""" fname = public_file('Tiff-Library-4J/IFD struct/Circular E.tif') with pytest.raises(TiffFileError): imread(fname)
) to (3, 21, 31) image = imread(fname, key=1) assert image.shape == (21, 31) assert_array_equal(image, data[1]) @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_issue_circular_ifd():
64
64
67
21
43
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_circular_ifd
test_issue_circular_ifd
552
557
552
553
08465ddb03b1bac7afff5175bfc797fbfd2d0a75
bigcode/the-stack
train
faae2000e1fe6e8880938959
train
function
def test_func_imagej_shape(): """Test imagej_shape function.""" for k, v in ( ((1, None), (1, 1, 1, 1, 1, 1)), ((3, None), (1, 1, 1, 1, 3, 1)), ((4, 3, None), (1, 1, 1, 4, 3, 1)), ((4, 3, True), (1, 1, 1, 1, 4, 3)), ((4, 4, None), (1, 1, 1, 4, 4, 1)), ((4, 4, True...
def test_func_imagej_shape():
"""Test imagej_shape function.""" for k, v in ( ((1, None), (1, 1, 1, 1, 1, 1)), ((3, None), (1, 1, 1, 1, 3, 1)), ((4, 3, None), (1, 1, 1, 4, 3, 1)), ((4, 3, True), (1, 1, 1, 1, 4, 3)), ((4, 4, None), (1, 1, 1, 4, 4, 1)), ((4, 4, True), (1, 1, 1, 1, 4, 4)), ...
) assert_array_equal( unpack_rgb(data, '<B', (5, 5, 5)), [16, 8, 8, 255, 255, 255] ) 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 tes...
209
210
700
7
202
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_imagej_shape
test_func_imagej_shape
2,666
2,691
2,666
2,666
a7147eb3a07586cfcbafb87c631683eb7dff1a50
bigcode/the-stack
train
74734890febcebf0f57305af
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_read_lsm_mosaic(): """Test read LSM: PTZCYX (Mosaic mode), two areas, 32 samples, >4 GB.""" # LSM files are little endian with two series, one of which is reduced RGB # Tags may be unordered or contain bogus values fname = private_f...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_read_lsm_mosaic():
"""Test read LSM: PTZCYX (Mosaic mode), two areas, 32 samples, >4 GB.""" # LSM files are little endian with two series, one of which is reduced RGB # Tags may be unordered or contain bogus values fname = private_file( 'lsm/Twoareas_Zstacks54slices_3umintervals_5cycles.lsm' ) with TiffFil...
fh = tif.filehandle for page in tif.pages: segments = page.segments() jpegtables = page.tags.get('JPEGTables', None) if jpegtables is not None: jpegtables = jpegtables.value for index, (offset, bytecount) in enum...
156
156
522
26
130
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_lsm_mosaic
test_read_lsm_mosaic
5,783
5,830
5,783
5,784
fb7750db76c5e9c1ce12236b3b5d4492203694ff
bigcode/the-stack
train
a776ea9fb67ce1b5cb099562
train
function
def test_func_memmap(): """Test memmap function.""" with TempFileName('memmap_new') as fname: # create new file im = memmap( fname, shape=(32, 16), dtype=numpy.float32, bigtiff=True, compression=False, ) im[31, 15] = 1.0...
def test_func_memmap():
"""Test memmap function.""" with TempFileName('memmap_new') as fname: # create new file im = memmap( fname, shape=(32, 16), dtype=numpy.float32, bigtiff=True, compression=False, ) im[31, 15] = 1.0 im.flush() ...
?> <root attr="attribute"> <int>1</int> <float>3.14</float> <bool>True</bool> <string>Lorem Ipsum</string> </root> """ ) assert d['root']['attr'] == 'attribute' assert d['root']['int'] == 1 assert d['root']['float'] == 3.14 assert d['root']['bool'] is Tru...
118
118
394
6
112
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_memmap
test_func_memmap
2,307
2,356
2,307
2,307
fe6e7836fc27421fe8b9b4fb6b0b0fbb0e8a3e25
bigcode/the-stack
train
0b95ad4ba6996d1b8114a411
train
function
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_LARGE or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON, ) def test_read_scn_collection(): """Test read Leica SCN slide, JPEG.""" # collection of 43 CZYX images # https://forum.image.sc/t/43585 fname = private_file( 'LeicaSCN/19-3-12_b5992c2e...
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_LARGE or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON, ) def test_read_scn_collection():
"""Test read Leica SCN slide, JPEG.""" # collection of 43 CZYX images # https://forum.image.sc/t/43585 fname = private_file( 'LeicaSCN/19-3-12_b5992c2e-5b6e-46f2-bf9b-d5872bdebdc1.SCN' ) with TiffFile(fname) as tif: assert tif.is_scn assert tif.is_bigtiff assert l...
page.is_tiled assert page.photometric == YCBCR assert page.compression == JPEG assert page.shape == (2600, 4000, 3) assert page.description == 'level=5 mag=1.25 quality=90' assert_aszarr_method(page) assert__str__(tif) @pytest.mark.skipif( SKIP_PRIVATE or SKIP_LARGE...
114
114
381
41
73
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_scn_collection
test_read_scn_collection
6,853
6,888
6,853
6,857
c2072c43e77d591d14ad9f78f02a060ce463ea1f
bigcode/the-stack
train
b9b584bc4590b655efe7e6da
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_volumetric(): """Test read 128x128x128, float32, tiled SGI.""" fname = public_file('tifffile/sgi_depth.tif') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.series) == 1 ...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_volumetric():
"""Test read 128x128x128, float32, tiled SGI.""" fname = public_file('tifffile/sgi_depth.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 p...
data = tif.asarray(series=0) assert isinstance(data, numpy.ndarray) assert data.flags['C_CONTIGUOUS'] assert data.shape == (347, 641, 3) assert data.dtype == numpy.uint8 assert tuple(data[132, 361]) == (114, 233, 58) assert_aszarr_method(tif, data, series=0, level=0) ...
117
117
392
20
97
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_volumetric
test_read_volumetric
4,032
4,072
4,032
4,033
a430a38beeb29a0c79b3dcd99b9e65aa242bc552
bigcode/the-stack
train
e10e4313aecb3fac876647c3
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_depend_cmapfile(): """Test cmapfile.lsm2cmap.""" from cmapfile import CmapFile, lsm2cmap # noqa filename = private_file('LSM/3d_zfish_onephoton_zoom.lsm') data = imread(filename) with TempFileName('cmapfile', ext='.cmap') as cmapfile: ...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_depend_cmapfile():
"""Test cmapfile.lsm2cmap.""" from cmapfile import CmapFile, lsm2cmap # noqa filename = private_file('LSM/3d_zfish_onephoton_zoom.lsm') data = imread(filename) with TempFileName('cmapfile', ext='.cmap') as cmapfile: lsm2cmap(filename, cmapfile, step=(1.0, 1.0, 20.0)) fname = os.pat...
== 1 assert tif.series[0].shape == (256, 256, 256) assert tif.series[0].dtype == numpy.float32 assert_array_equal(data, tif.asarray()) @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_depend_cmapfile():
64
64
193
20
44
bioturing/tifffile
tests/test_tifffile.py
Python
test_depend_cmapfile
test_depend_cmapfile
14,250
14,265
14,250
14,251
463d85a0fdd5b6c873c7564c10dc6a3496518e53
bigcode/the-stack
train
8a2d293672cb4c17e1682058
train
function
@pytest.mark.skipif(SKIP_EXTENDED, reason=REASON) @pytest.mark.parametrize('repeat', [1, 4]) @pytest.mark.parametrize('shape', [(1, 0), (0, 1), (3, 0, 2, 1)]) @pytest.mark.parametrize('data', ['random', 'empty']) @pytest.mark.parametrize('shaped', [True, False]) def test_write_zeroshape(shaped, data, repeat, shape): ...
@pytest.mark.skipif(SKIP_EXTENDED, reason=REASON) @pytest.mark.parametrize('repeat', [1, 4]) @pytest.mark.parametrize('shape', [(1, 0), (0, 1), (3, 0, 2, 1)]) @pytest.mark.parametrize('data', ['random', 'empty']) @pytest.mark.parametrize('shaped', [True, False]) def test_write_zeroshape(shaped, data, repeat, shape):
"""Test write arrays with zero shape.""" dtype = numpy.uint8 fname = 'shape_{}x{}{}{}'.format( repeat, str(shape).replace(' ', ''), '_shaped' if shaped else '', '_empty' if data == 'empty' else '', ) metadata = {} if shaped else None with TempFileName(fname) as f...
== count assert page.tags[tag].dtype == dtype assert page.is_contiguous != bool(compression) assert page.planarconfig == CONTIG assert page.photometric == MINISBLACK assert page.imagewidth == shape[1] assert page.imagelength == shape[0] ...
198
198
660
96
102
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_zeroshape
test_write_zeroshape
9,829
9,904
9,829
9,834
3fb59cd4b62732b7ea5f84311466dd239a2c41b5
bigcode/the-stack
train
7a99150328b7f5e1e16d10bb
train
function
@pytest.mark.parametrize('kind', ['enum', 'int', 'lower', 'upper']) def test_write_enum_parameters(kind): """Test imwrite using different kind of enum""" data = random_data(numpy.uint8, (2, 6, 219, 301)) with TempFileName(f'enum_parameters_{kind}') as fname: if kind == 'enum': imwrite( ...
@pytest.mark.parametrize('kind', ['enum', 'int', 'lower', 'upper']) def test_write_enum_parameters(kind):
"""Test imwrite using different kind of enum""" data = random_data(numpy.uint8, (2, 6, 219, 301)) with TempFileName(f'enum_parameters_{kind}') as fname: if kind == 'enum': imwrite( fname, data, photometric=RGB, planarconfig=...
spersample=bps, photometric=RGB, ) for bps in (1, 8, 17, 32): with pytest.raises(ValueError): tif.write( data.astype(numpy.uint16), bitspersample=bps, photo...
143
143
478
25
118
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_enum_parameters
test_write_enum_parameters
10,578
10,637
10,578
10,579
9c403649546d5d413145cae624b09ffb23cfd8af
bigcode/the-stack
train
fd8a2eaebb88b7fdca312d07
train
function
@pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) @pytest.mark.parametrize('subsampling', ['444', '422', '420', '411']) @pytest.mark.parametrize('dtype', [numpy.uint8, numpy.uint16]) def test_write_compression_jpeg(dtype, subsampling): """Test write JPEG compression with s...
@pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) @pytest.mark.parametrize('subsampling', ['444', '422', '420', '411']) @pytest.mark.parametrize('dtype', [numpy.uint8, numpy.uint16]) def test_write_compression_jpeg(dtype, subsampling):
"""Test write JPEG compression with subsampling.""" dtype = numpy.dtype(dtype) filename = f'compression_jpeg_{dtype}_{subsampling}' subsampling, atol = { '444': [(1, 1), 5], '422': [(2, 1), 10], '420': [(2, 2), 20], '411': [(4, 1), 40], }[subsampling] data = numpy...
image) assert_aszarr_method(tif, image) assert__str__(tif) # @pytest.mark.parametrize('optimize', [None, False, True]) # @pytest.mark.parametrize('smoothing', [None, 10]) @pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) @pytest.mark.parametrize('sub...
126
126
422
74
52
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_compression_jpeg
test_write_compression_jpeg
10,736
10,777
10,736
10,741
a09d9d94b90d44194e2c0e64eab681c7232a8864
bigcode/the-stack
train
2de843c83084b6585d6656cc
train
function
def test_write_small(): """Test write small image.""" data = random_data(numpy.uint8, (1, 1)) with TempFileName('small') as fname: imwrite(fname, data) assert_valid_tiff(fname) with TiffFile(fname) as tif: assert len(tif.pages) == 1 page = tif.pages[0] ...
def test_write_small():
"""Test write small image.""" data = random_data(numpy.uint8, (1, 1)) with TempFileName('small') as fname: imwrite(fname, data) assert_valid_tiff(fname) with TiffFile(fname) as tif: assert len(tif.pages) == 1 page = tif.pages[0] assert page.is_cont...
assert page.samplesperpixel == 1 image = tif.asarray() assert_array_equal(data, image) assert_aszarr_method(tif, image) assert_aszarr_method(tif, image, chunkmode='page') assert__str__(tif) def test_write_small():
64
64
169
5
59
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_small
test_write_small
11,229
11,247
11,229
11,229
a694f16f782a2a1e28c1dd7b2fc2c20919f1097e
bigcode/the-stack
train
1ac1d4704fd0092f88f91884
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_write_multiple_series(): """Test write multiple data into one file using various options.""" data1 = imread(private_file('ome/multi-channel-4D-series.ome.tif')) image1 = imread(private_file('django.tiff')) image2 = imread(private_file('horse-16bi...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_write_multiple_series():
"""Test write multiple data into one file using various options.""" data1 = imread(private_file('ome/multi-channel-4D-series.ome.tif')) image1 = imread(private_file('django.tiff')) image2 = imread(private_file('horse-16bit-col-littleendian.tif')) with TempFileName('multiple_series') as fname: ...
with TiffFile(fname) as tif: page = tif.pages[0] assert page.photometric == PALETTE assert page.imagewidth == 320 assert page.imagelength == 480 data = page.asarray() # .squeeze() # UserWarning ... cmap = page.colormap assert__str__(tif) with TempFileName('...
256
256
1,083
19
237
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_multiple_series
test_write_multiple_series
12,740
12,856
12,740
12,741
59c1756658f3ea5590d7c5082da258368aaf9baa
bigcode/the-stack
train
680948d8a0a1ca94f2a2e2d8
train
function
@pytest.mark.skipif(SKIP_WIN, reason='not reliable on Linux') def test_func_pformat_xml(): """Test pformat function with XML.""" value = """<?xml version="1.0" encoding="ISO-8859-1" ?> <Dimap_Document name="band2.dim"> <Metadata_Id> <METADATA_FORMAT version="2.12.1">DIMAP</METADATA_FORMAT> <METADATA_P...
@pytest.mark.skipif(SKIP_WIN, reason='not reliable on Linux') def test_func_pformat_xml():
"""Test pformat function with XML.""" value = """<?xml version="1.0" encoding="ISO-8859-1" ?> <Dimap_Document name="band2.dim"> <Metadata_Id> <METADATA_FORMAT version="2.12.1">DIMAP</METADATA_FORMAT> <METADATA_PROFILE>BEAM-DATAMODEL-V1</METADATA_PROFILE> </Metadata_Id> <Image_Interpretation> <...
60., 0., 0., 600000., 0., -60., 0., 5900040., 60., 0., 0., 600000., 0., -60., 0., 5900040.])""" ) @pytest.mark.skipif(SKIP_WIN, reason='not reliable on Linux') def test_func_pformat_xml():
93
93
313
22
71
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_pformat_xml
test_func_pformat_xml
3,161
3,191
3,161
3,162
50e715d566f003005afb906267dff3c3d572b3db
bigcode/the-stack
train
9e99a2b319e2f3ebcb0a3d99
train
function
def test_issue_sampleformat(): """Test write correct number of SampleFormat values.""" # https://github.com/ngageoint/geopackage-tiff-java/issues/5 data = random_data(numpy.int16, (256, 256, 4)) with TempFileName('sampleformat') as fname: imwrite(fname, data, photometric=RGB) with TiffFi...
def test_issue_sampleformat():
"""Test write correct number of SampleFormat values.""" # https://github.com/ngageoint/geopackage-tiff-java/issues/5 data = random_data(numpy.int16, (256, 256, 4)) with TempFileName('sampleformat') as fname: imwrite(fname, data, photometric=RGB) with TiffFile(fname) as tif: t...
(fname) as tif: tags = tif.pages[0].tags assert tags['ImageID'].value[-8:] == b'rev 2893' assert__str__(tif) assert 'coercing invalid ASCII to bytes' in caplog.text def test_issue_sampleformat():
64
64
140
6
57
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_sampleformat
test_issue_sampleformat
585
595
585
585
ddfaeca30407f7f8fd5da2ab6635eca7e7f15a3b
bigcode/the-stack
train
a59dec4d9073d6476ade1a51
train
function
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or SKIP_LARGE or not imagecodecs.JPEG, reason=REASON, ) def test_read_ndpi_cmu2(): """Test read Hamamatsu NDPI slide, JPEG.""" # JPEG stream too large to be opened with unpatched libjpeg fname = private_file('HamamatsuNDPI/CMU-2.ndpi') with TiffFi...
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or SKIP_LARGE or not imagecodecs.JPEG, reason=REASON, ) def test_read_ndpi_cmu2():
"""Test read Hamamatsu NDPI slide, JPEG.""" # JPEG stream too large to be opened with unpatched libjpeg fname = private_file('HamamatsuNDPI/CMU-2.ndpi') with TiffFile(fname) as tif: assert tif.is_ndpi assert len(tif.pages) == 6 assert len(tif.series) == 2 for page in tif....
pression == JPEG assert page.shape == (408, 1191, 3) assert page.ndpi_tags['Magnification'] == -1.0 assert page.asarray()[226, 629, 0] == 167 assert_aszarr_method(page) assert__str__(tif) @pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or SKIP_LARGE or not imagecodecs.JPEG, ...
111
111
372
43
68
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_ndpi_cmu2
test_read_ndpi_cmu2
6,568
6,603
6,568
6,572
7422774ad0e5ace7a0c542bc5fc5c2e52d597010
bigcode/the-stack
train
dd8c140d0814ab1293576411
train
function
def test_func_pformat_dict(): """Test pformat function with dict.""" value = { 'GTCitationGeoKey': 'WGS 84 / UTM zone 29N', 'GTModelTypeGeoKey': 1, 'GTRasterTypeGeoKey': 1, 'KeyDirectoryVersion': 1, 'KeyRevision': 1, 'KeyRevisionMinor': 2, 'ModelTransforma...
def test_func_pformat_dict():
"""Test pformat function with dict.""" value = { 'GTCitationGeoKey': 'WGS 84 / UTM zone 29N', 'GTModelTypeGeoKey': 1, 'GTRasterTypeGeoKey': 1, 'KeyDirectoryVersion': 1, 'KeyRevision': 1, 'KeyRevisionMinor': 2, 'ModelTransformation': numpy.array( ...
fe 00 04 00 01 00 II*............. 10: 00 00 00 00 00 00 00 01 04 00 01 00 00 00 00 01 ................ 20: 00 00 01 01 04 00 01 00 00 00 00 01 00 00 02 01 ................ 30: 03 00 01 00 00 00 20 00 00 00 03 01 03 00 01 00 ...... ......... """.strip() ) def test_func_pformat_dict():
137
137
458
7
130
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_pformat_dict
test_func_pformat_dict
3,057
3,092
3,057
3,057
ce314531e07f5c7dee105a011f9449c7787d4751
bigcode/the-stack
train
c854cd1b8a051ee8519f9a30
train
function
def test_func_asbool(): """Test asbool function.""" for true in ('TRUE', ' True ', 'true '): assert asbool(true) assert asbool(true.encode()) for false in ('FALSE', ' False ', 'false '): assert not asbool(false) assert not asbool(false.encode()) assert asbool('ON', ['on']...
def test_func_asbool():
"""Test asbool function.""" for true in ('TRUE', ' True ', 'true '): assert asbool(true) assert asbool(true.encode()) for false in ('FALSE', ' False ', 'false '): assert not asbool(false) assert not asbool(false.encode()) assert asbool('ON', ['on'], ['off']) assert as...
00 00 00 01 ' '................\n' '20: 00 00 01 01 04 00 01 00 00 00 00 01 00 00 02 01 ' '................' ) def test_func_asbool():
64
64
129
6
58
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_asbool
test_func_asbool
2,902
2,915
2,902
2,902
f5f84bcba98a680387c6f55bc6fde0917fa7b1d7
bigcode/the-stack
train
93607121d2eea4650fdd45a5
train
function
@pytest.mark.skipif(SKIP_LARGE, reason=REASON) def test_write_3gb(): """Test write 3 GB no-BigTiff file.""" # https://github.com/blink1073/tifffile/issues/47 data = numpy.empty((4096 - 32, 1024, 1024), dtype=numpy.uint8) with TempFileName('3gb', remove=False) as fname: imwrite(fname, data) ...
@pytest.mark.skipif(SKIP_LARGE, reason=REASON) def test_write_3gb():
"""Test write 3 GB no-BigTiff file.""" # https://github.com/blink1073/tifffile/issues/47 data = numpy.empty((4096 - 32, 1024, 1024), dtype=numpy.uint8) with TempFileName('3gb', remove=False) as fname: imwrite(fname, data) del data assert_valid_tiff(fname) # assert file ...
assert page.samplesperpixel == 3 image = tif.asarray() assert_array_equal(data, image) assert_aszarr_method(tif, image) assert__str__(tif) @pytest.mark.skipif(SKIP_LARGE, reason=REASON) def test_write_3gb():
64
64
136
21
43
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_3gb
test_write_3gb
12,635
12,646
12,635
12,636
e155aa44df153afe8f38e3081aeea857b2a827cf
bigcode/the-stack
train
8fce5dbc4affa03241b8a058
train
function
@pytest.mark.skipif(SKIP_CODECS, reason=REASON) @pytest.mark.parametrize('dtype', [numpy.int8, numpy.uint8, numpy.bool8]) @pytest.mark.parametrize('tile', [None, (16, 16)]) def test_write_compression_packbits(dtype, tile): """Test write PackBits compression.""" dtype = numpy.dtype(dtype) uncompressed = nump...
@pytest.mark.skipif(SKIP_CODECS, reason=REASON) @pytest.mark.parametrize('dtype', [numpy.int8, numpy.uint8, numpy.bool8]) @pytest.mark.parametrize('tile', [None, (16, 16)]) def test_write_compression_packbits(dtype, tile):
"""Test write PackBits compression.""" dtype = numpy.dtype(dtype) uncompressed = numpy.frombuffer( b'\xaa\xaa\xaa\x80\x00\x2a\xaa\xaa\xaa\xaa\x80\x00' b'\x2a\x22\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa', dtype=dtype, ) shape = 2, 7, uncompressed.size data = numpy.empty(sh...
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.int8, numpy.uint8, numpy.bool8]) @pytest.mark.para...
100
100
336
59
41
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_compression_packbits
test_write_compression_packbits
10,944
10,973
10,944
10,947
10dbc09e6d2d5f0626165ad5192ca691573dacdb
bigcode/the-stack
train
8fd2b51c76f39168a6ecc6c7
train
function
def test_write_tiled_pages(): """Test write multiple tiled pages.""" data = random_data(numpy.uint8, (5, 219, 301, 3)) with TempFileName('tiled_pages') as fname: imwrite(fname, data, tile=(96, 64), photometric=RGB) assert_valid_tiff(fname) with TiffFile(fname) as tif: ass...
def test_write_tiled_pages():
"""Test write multiple tiled pages.""" data = random_data(numpy.uint8, (5, 219, 301, 3)) with TempFileName('tiled_pages') as fname: imwrite(fname, data, tile=(96, 64), photometric=RGB) assert_valid_tiff(fname) with TiffFile(fname) as tif: assert len(tif.pages) == 5 ...
assert page.tilewidth == 64 assert page.tilelength == 96 assert page.samplesperpixel == 3 image = tif.asarray() assert_array_equal(data, image) assert_aszarr_method(tif, image) assert__str__(tif) def test_write_tiled_pages():
68
68
227
7
61
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_tiled_pages
test_write_tiled_pages
12,049
12,071
12,049
12,049
1faf4ab0c9c4b0aa737df81d303795f161b50711
bigcode/the-stack
train
e866d74002865b40acc81526
train
function
def test_write_double_tags(): """Test write single and sequences of doubles.""" # older versions of tifffile do not use offset to write doubles # reported by Eric Prestat on Feb 21, 2016 data = random_data(numpy.uint8, (8, 8)) value = math.pi extratags = [ (34563, 'd', 1, value, False), ...
def test_write_double_tags():
"""Test write single and sequences of doubles.""" # older versions of tifffile do not use offset to write doubles # reported by Eric Prestat on Feb 21, 2016 data = random_data(numpy.uint8, (8, 8)) value = math.pi extratags = [ (34563, 'd', 1, value, False), (34564, 'd', 1, (value...
'].value == pagename assert '50001' not in tif.pages[1].tags tags = tif.pages[0].tags assert tags['50001'].value == 49 assert tags['50002'].value == (49, 50) assert tags['50004'].value == (49, 50, 51, 52) assert_array_equal(tags['50008'].value, b'1...
138
138
460
6
132
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_double_tags
test_write_double_tags
10,311
10,348
10,311
10,311
e7333e59b0b5643e971322aa529a5c8a74516dd5
bigcode/the-stack
train
bce99fdfe23d6ffbc319a32f
train
function
def test_filehandle_write_bytesio(): """Test write to FileHandle from BytesIO.""" value = b'123456789' buf = BytesIO() with FileHandle(buf) as fh: fh.write(value) buf.seek(0) assert buf.read() == value
def test_filehandle_write_bytesio():
"""Test write to FileHandle from BytesIO.""" value = b'123456789' buf = BytesIO() with FileHandle(buf) as fh: fh.write(value) buf.seek(0) assert buf.read() == value
', 'test_tifffile.py')] try: fh = opener.open(URL + 'data/test_http.tif') except OSError: pytest.skip(URL + 'data/test_http.tif') with pytest.raises(ValueError): FileHandle(fh) def test_filehandle_write_bytesio():
64
64
62
8
56
bioturing/tifffile
tests/test_tifffile.py
Python
test_filehandle_write_bytesio
test_filehandle_write_bytesio
3,422
3,429
3,422
3,422
17d811514d13d0b9b6cfaed8e40cd599dcd8d964
bigcode/the-stack
train
b0a07270f19ee6410f166d51
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_read_qpi(): """Test read PerkinElmer-QPI, non Pyramid.""" fname = private_file( 'PerkinElmer-QPI/LuCa-7color_[13860,52919]_1x1component_data.tiff' ) with TiffFile(fname) as tif: assert len(tif.series) == 2 a...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_read_qpi():
"""Test read PerkinElmer-QPI, non Pyramid.""" fname = private_file( 'PerkinElmer-QPI/LuCa-7color_[13860,52919]_1x1component_data.tiff' ) with TiffFile(fname) as tif: assert len(tif.series) == 2 assert len(tif.pages) == 9 assert tif.is_qpi page = tif.pages[0] ...
) assert page.imagewidth == 20 assert page.imagelength == 20 assert not page.is_contiguous data = page.asarray() data[9, 11] == 107 + 0j # assert GeoTIFF tags tags = tif.geotiff_metadata assert tags['GTCitationGeoKey'] == 'NAD27 / UTM zone 11N' ass...
132
132
443
24
108
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_qpi
test_read_qpi
9,162
9,200
9,162
9,163
e761b93a1e069d98736d03aac191f0b26be58ae5
bigcode/the-stack
train
42104793a4214e4845f5dd31
train
function
@pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG or not imagecodecs.JPEG2K, reason=REASON, ) def test_read_aperio_j2k(): """Test read SVS slide with J2K compression.""" fname = private_file('slides/CMU-1-JP2K-33005.tif') with TiffFile(fname) as tif: assert ...
@pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG or not imagecodecs.JPEG2K, reason=REASON, ) def test_read_aperio_j2k():
"""Test read SVS slide with J2K compression.""" fname = private_file('slides/CMU-1-JP2K-33005.tif') with TiffFile(fname) as tif: assert tif.is_svs assert len(tif.pages) == 6 page = tif.pages[0] assert page.compression == APERIO_JP2000_RGB assert page.photometric == RG...
assert page.imagelength == 59683 assert page.bitspersample == 8 assert page.samplesperpixel == 3 # assert data image = tif.asarray() assert image.flags['C_CONTIGUOUS'] assert image.shape == (59683, 49128, 3) assert image.dtype == numpy.uint8 assert tuple(...
187
187
626
54
133
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_aperio_j2k
test_read_aperio_j2k
4,935
4,996
4,935
4,942
15d08c152976a61808f131e091df643b05eb5506
bigcode/the-stack
train
afdf126cbba51ba34fd039f1
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_write_imagej_roundtrip(): """Test ImageJ metadata survive read/write roundtrip.""" fname = private_file('imagej/IJMetadata.tif') with TiffFile(fname) as tif: assert tif.is_imagej assert tif.byteorder == '>' assert len(tif.page...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_write_imagej_roundtrip():
"""Test ImageJ metadata survive read/write roundtrip.""" fname = private_file('imagej/IJMetadata.tif') with TiffFile(fname) as tif: assert tif.is_imagej assert tif.byteorder == '>' assert len(tif.pages) == 3 assert len(tif.series) == 1 data = tif.asarray() ijm...
assert_array_equal(data, data2) assert imagej_metadata['mode'] == 'composite' assert imagej_metadata['Info'] == ijmetadata['Info'] assert ijmetadata2['Info'] == ijmetadata['Info'] assert ijmetadata2['ROI'] == ijmetadata['ROI'] assert ijmetadata2['Overlays'] == ijmetadata['Overlays'] assert i...
160
160
534
21
139
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_imagej_roundtrip
test_write_imagej_roundtrip
13,200
13,245
13,200
13,201
1629bbbd1862a1ee79f23ca81ddacb085affb6f5
bigcode/the-stack
train
542a70bcf9b2ac9db7d7a640
train
function
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_LARGE, reason=REASON) def test_read_ome_multifile(): """Test read OME CTZYX series in 86 files.""" # (2, 43, 10, 512, 512) CTZYX uint8 in 86 files, 10 pages each fname = public_file('OME/tubhiswt-4D/tubhiswt_C0_TP10.ome.tif') with TiffFile(fname) as tif: a...
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_LARGE, reason=REASON) def test_read_ome_multifile():
"""Test read OME CTZYX series in 86 files.""" # (2, 43, 10, 512, 512) CTZYX uint8 in 86 files, 10 pages each fname = public_file('OME/tubhiswt-4D/tubhiswt_C0_TP10.ome.tif') with TiffFile(fname) as tif: assert tif.is_ome assert tif.byteorder == '<' assert len(tif.pages) == 10 ...
assert series.shape == (2, 19, 21, 300, 400) assert series.dtype == numpy.uint8 assert series.axes == 'CTZYX' assert not series.is_multifile # assert data data = tif.asarray() assert isinstance(data, numpy.ndarray) assert data.shape == (2, 19, 21, 300, 400) ...
166
166
554
27
139
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_ome_multifile
test_read_ome_multifile
7,620
7,665
7,620
7,621
7949bae8de7b38d76e8065fd09c756e9694e83eb
bigcode/the-stack
train
28aa8856e82992bae4f9c1cd
train
function
def test_issue_star_import(): """Test from tifffile import *.""" assert STAR_IMPORTED is not None assert lsm2bin not in STAR_IMPORTED
def test_issue_star_import():
"""Test from tifffile import *.""" assert STAR_IMPORTED is not None assert lsm2bin not in STAR_IMPORTED
.name def __exit__(self, exc_type, exc_value, traceback): if self.remove: try: os.remove(self.name) except Exception: pass numpy.set_printoptions(suppress=True, precision=5) #########################################################################...
64
64
35
6
57
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_star_import
test_issue_star_import
406
409
406
406
1e531c334e90bcd55523abceea8a316d8bd42906
bigcode/the-stack
train
4aea9c8d3e0dd729e8bb288d
train
function
def test_write_bytes_str(): """Test write bytes in place of 7-bit ascii string.""" micron = 'micron \xB5'.encode('latin-1') # can't be encoded as 7-bit ascii data = numpy.arange(4, dtype=numpy.uint32).reshape((2, 2)) with TempFileName('write_bytes_str') as fname: imwrite( fname, ...
def test_write_bytes_str():
"""Test write bytes in place of 7-bit ascii string.""" micron = 'micron \xB5'.encode('latin-1') # can't be encoded as 7-bit ascii data = numpy.arange(4, dtype=numpy.uint32).reshape((2, 2)) with TempFileName('write_bytes_str') as fname: imwrite( fname, data, d...
if.pages) == 1 page = tif.pages[0] assert page.is_shaped assert page.description == descr assert_aszarr_method(page) assert_aszarr_method(page, chunkmode='page') assert__str__(tif) def test_write_bytes_str():
64
64
188
6
58
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_bytes_str
test_write_bytes_str
10,260
10,276
10,260
10,260
a1c4c926d6ec59fe6b989257c68346d3d1c04e3a
bigcode/the-stack
train
70377a99edb35bcf627026aa
train
function
def test_write_invalid_contig_rgb(): """Test write planar RGB with 2 samplesperpixel.""" data = random_data(numpy.uint8, (219, 301, 2)) with pytest.raises(ValueError): with TempFileName('invalid_contig_rgb') as fname: imwrite(fname, data, photometric=RGB) # default to pages with ...
def test_write_invalid_contig_rgb():
"""Test write planar RGB with 2 samplesperpixel.""" data = random_data(numpy.uint8, (219, 301, 2)) with pytest.raises(ValueError): with TempFileName('invalid_contig_rgb') as fname: imwrite(fname, data, photometric=RGB) # default to pages with TempFileName('invalid_contig_rgb_page...
== 'XS' page = tif.pages[0] assert page.is_contiguous assert page.planarconfig == CONTIG assert page.photometric == RGB assert page.imagewidth == 256 assert page.imagelength == 1 assert page.samplesperpixel == 3 image = tif...
123
123
410
8
115
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_invalid_contig_rgb
test_write_invalid_contig_rgb
11,274
11,315
11,274
11,274
ead6d1ab1b0ddb3f387e5c3311bacc1ac0fa9824
bigcode/the-stack
train
0fd6262481d578a78470677d
train
function
def test_write_extrasamples_planar(): """Test write planar large number of extrasamples.""" data = random_data(numpy.uint8, (219, 301, 3)) with TempFileName('extrasamples_planar') as fname: imwrite(fname, data, planarconfig=SEPARATE) assert_valid_tiff(fname) with TiffFile(fname) as t...
def test_write_extrasamples_planar():
"""Test write planar large number of extrasamples.""" data = random_data(numpy.uint8, (219, 301, 3)) with TempFileName('extrasamples_planar') as fname: imwrite(fname, data, planarconfig=SEPARATE) assert_valid_tiff(fname) with TiffFile(fname) as tif: assert len(tif.pages) ...
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_extrasamples_planar():
64
64
206
9
55
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_extrasamples_planar
test_write_extrasamples_planar
11,578
11,597
11,578
11,578
927434dede156d433dcf193274d7c2ec7679a076
bigcode/the-stack
train
2fe40017b01abf53479bef8d
train
function
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_LARGE, reason=REASON) def test_read_imagej_100000_pages(): """Test read ImageJ with 100000 pages.""" # 100000x64x64 # file is big endian, memory mapped fname = public_file('tifffile/100000_pages.tif') with TiffFile(fname) as tif: assert tif.is_imagej ...
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_LARGE, reason=REASON) def test_read_imagej_100000_pages():
"""Test read ImageJ with 100000 pages.""" # 100000x64x64 # file is big endian, memory mapped fname = public_file('tifffile/100000_pages.tif') with TiffFile(fname) as tif: assert tif.is_imagej assert tif.byteorder == '>' assert len(tif.pages) == 100000 assert len(tif.s...
tags['images'] == 3 assert ijtags['channels'] == 3 # assert data data = tif.asarray() assert isinstance(data, numpy.ndarray) assert data.shape == (3, 512, 512) assert data.dtype == numpy.uint8 assert tuple(data[:, 256, 256]) == (57, 120, 13) assert_aszarr_...
128
128
428
28
100
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_imagej_100000_pages
test_read_imagej_100000_pages
8,583
8,620
8,583
8,584
ea3a44f36e7c57880cf45c8075450c67ec54095d
bigcode/the-stack
train
5911d04771382f4744e12140
train
function
def test_write_volumetric_striped_planar_rgb(): """Test write 5D array as grayscale volumes.""" shape = (2, 3, 15, 63, 96) data = numpy.empty(shape, dtype=numpy.uint8) data[:] = numpy.arange(15, dtype=numpy.uint8).reshape(1, 1, -1, 1, 1) with TempFileName('volumetric_striped_planar_rgb') as fname: ...
def test_write_volumetric_striped_planar_rgb():
"""Test write 5D array as grayscale volumes.""" shape = (2, 3, 15, 63, 96) data = numpy.empty(shape, dtype=numpy.uint8) data[:] = numpy.arange(15, dtype=numpy.uint8).reshape(1, 1, -1, 1, 1) with TempFileName('volumetric_striped_planar_rgb') as fname: imwrite(fname, data, volumetric=True, pho...
.imagedepth == 15 assert page.samplesperpixel == 3 assert len(page.dataoffsets) == 30 assert len(page.databytecounts) == 30 image = tif.asarray() assert_array_equal(data, image) assert_aszarr_method(tif, image) assert_aszarr_method(tif,...
103
103
345
12
91
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_volumetric_striped_planar_rgb
test_write_volumetric_striped_planar_rgb
12,500
12,530
12,500
12,500
4a1fa5aa23daa5a13d430a5145ff128488e5443a
bigcode/the-stack
train
7dab62b6ee44ce0945877cce
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_stk_zser24(): """Test read MetaMorph STK RGB z-series.""" fname = private_file('stk/zser24.stk') with TiffFile(fname) as tif: assert tif.is_stk assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_stk_zser24():
"""Test read MetaMorph STK RGB z-series.""" fname = private_file('stk/zser24.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] ...
:06:02.000783000' ) # assert series properties series = tif.series[0] assert series.shape == (11, 256, 320) assert series.dtype == numpy.uint16 assert series.axes == 'ZYX' # assert data data = tif.asarray() assert isinstance(data, numpy.ndarray) ...
163
163
545
22
141
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_stk_zser24
test_read_stk_zser24
6,257
6,305
6,257
6,258
1a3d9a1c69028aee3b7aa47b1cb3caa582dbfcc4
bigcode/the-stack
train
2fad8ce2bdc40f0c9b0da7dd
train
function
def test_write_volumetric_tiled_contig_rgb(): """Test write 6D array as contig RGB volumes.""" shape = (2, 3, 256, 64, 96, 3) data = numpy.empty(shape, dtype=numpy.uint8) data[:] = numpy.arange(256, dtype=numpy.uint8).reshape(1, 1, -1, 1, 1, 1) with TempFileName('volumetric_tiled_contig_rgb') as fna...
def test_write_volumetric_tiled_contig_rgb():
"""Test write 6D array as contig RGB volumes.""" shape = (2, 3, 256, 64, 96, 3) data = numpy.empty(shape, dtype=numpy.uint8) data[:] = numpy.arange(256, dtype=numpy.uint8).reshape(1, 1, -1, 1, 1, 1) with TempFileName('volumetric_tiled_contig_rgb') as fname: imwrite(fname, data, tile=(256, 64...
th == 256 assert page.tilewidth == 96 assert page.tilelength == 64 assert page.tiledepth == 256 assert page.samplesperpixel == 3 series = tif.series[0] assert len(series._pages) == 1 assert len(series.pages) == 2 assert seri...
131
131
439
12
119
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_volumetric_tiled_contig_rgb
test_write_volumetric_tiled_contig_rgb
12,356
12,394
12,356
12,356
f8147be3afdd0ab9927bbec65bc2ab1fa33cad81
bigcode/the-stack
train
1a382dd4c496ebb93600fa36
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_mdgel_rat(): """Test read Molecular Dynamics GEL.""" # Second page does not contain data, only private tags fname = private_file('mdgel/rat.gel') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) ...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_mdgel_rat():
"""Test read Molecular Dynamics GEL.""" # Second page does not contain data, only private tags fname = private_file('mdgel/rat.gel') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 2 assert len(tif.series) == 1 # assert page properties ...
, 13453) assert series.dtype == numpy.uint16 assert series.axes == 'YX' # assert data data = tif.asarray(out='memmap') assert isinstance(data, numpy.core.memmap) assert data.shape == (12113, 13453) assert data.dtype == numpy.dtype('<u2') assert round(abs(d...
156
156
523
20
136
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_mdgel_rat
test_read_mdgel_rat
8,848
8,899
8,848
8,849
aae6f8bb6bbe9fa0fe92001eb4c2cb8e116e389c
bigcode/the-stack
train
1f88a05f2f52da02428d4052
train
function
def test_write_planar_extrasample(): """Test write grayscale with planar extrasamples.""" data = random_data(numpy.uint8, (2, 219, 301)) with TempFileName('planar_extrasample') as fname: imwrite(fname, data, planarconfig=SEPARATE) assert_valid_tiff(fname) with TiffFile(fname) as tif:...
def test_write_planar_extrasample():
"""Test write grayscale with planar extrasamples.""" data = random_data(numpy.uint8, (2, 219, 301)) with TempFileName('planar_extrasample') as fname: imwrite(fname, data, planarconfig=SEPARATE) 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_planar_extrasample():
64
64
191
9
55
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_planar_extrasample
test_write_planar_extrasample
11,749
11,767
11,749
11,749
51bb19e76135a6859ff7d257fc86ef1cba233e45
bigcode/the-stack
train
6d58080e3f1ffd8b9f1e8456
train
function
@pytest.mark.skipif(SKIP_CODECS, reason=REASON) @pytest.mark.parametrize('bps', [1, 2, 7, 8]) @pytest.mark.parametrize('dtype', [numpy.uint8, numpy.uint16, numpy.uint32]) def test_write_bitspersample(bps, dtype): """Test write with packints.""" dtype = numpy.dtype(dtype) bps += (dtype.itemsize // 2) * 8 ...
@pytest.mark.skipif(SKIP_CODECS, reason=REASON) @pytest.mark.parametrize('bps', [1, 2, 7, 8]) @pytest.mark.parametrize('dtype', [numpy.uint8, numpy.uint16, numpy.uint32]) def test_write_bitspersample(bps, dtype):
"""Test write with packints.""" dtype = numpy.dtype(dtype) bps += (dtype.itemsize // 2) * 8 data = numpy.arange(256 * 256 * 3, dtype=dtype).reshape((256, 256, 3)) with TempFileName(f'write_bitspersample_{dtype.char}{bps}') as fname: # TODO: enable all cases once imagecodecs.packints_encode w...
assert__str__(tif) @pytest.mark.skipif(SKIP_CODECS, reason=REASON) @pytest.mark.parametrize('bps', [1, 2, 7, 8]) @pytest.mark.parametrize('dtype', [numpy.uint8, numpy.uint16, numpy.uint32]) def test_write_bitspersample(bps, dtype):
70
70
236
62
8
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_bitspersample
test_write_bitspersample
10,511
10,527
10,511
10,514
09aff8c419e5d6291d6d03f4600d9daa6647043a
bigcode/the-stack
train
39a7d1041ea6521e4adcd93b
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_read_ome_multifile_missing(caplog): """Test read OME referencing missing files.""" # (2, 43, 10, 512, 512) CTZYX uint8, 85 files missing fname = private_file('OME/tubhiswt_C0_TP34.ome.tif') with TiffFile(fname) as tif: asser...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_read_ome_multifile_missing(caplog):
"""Test read OME referencing missing files.""" # (2, 43, 10, 512, 512) CTZYX uint8, 85 files missing fname = private_file('OME/tubhiswt_C0_TP34.ome.tif') with TiffFile(fname) as tif: assert tif.is_ome assert tif.byteorder == '<' assert len(tif.pages) == 10 assert len(tif....
for page in tif.series[0].pages: assert bool(page.parent.filehandle._fh) == (page.parent == tif) # assert all files stay open # with TiffFile(fname) as tif: # for page in tif.series[0].pages: # self.assertTrue(page.parent.filehandle._fh) # data = tif.asarray(out...
142
142
475
30
112
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_ome_multifile_missing
test_read_ome_multifile_missing
7,676
7,716
7,676
7,677
fe6f95c5a5b019364d0603d0322df2fff56443d2
bigcode/the-stack
train
33e42cee05f7be10102b36d4
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_missing_dataoffset(caplog): """Test reading file with missing data offset.""" fname = private_file('gdal/bigtiff_header_extract.tif') with tifffile.TiffFile(fname) as tif: page = tif.pages[0] assert page.imagewidth == 100000 ...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_missing_dataoffset(caplog):
"""Test reading file with missing data offset.""" fname = private_file('gdal/bigtiff_header_extract.tif') with tifffile.TiffFile(fname) as tif: page = tif.pages[0] assert page.imagewidth == 100000 assert page.imagelength == 100000 assert page.rowsperstrip == 1 assert ...
1' assert tif.pages[0].photometric == PALETTE colormap = tif.pages[0].colormap image = tif.asarray() assert_array_equal(image, data) @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_missing_dataoffset(caplog):
64
64
174
22
42
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_missing_dataoffset
test_issue_missing_dataoffset
1,603
1,618
1,603
1,604
a33e7ea442ecf6e5a84da37bb44ef0a8e4d745d9
bigcode/the-stack
train
4f36762897080aaf7f663dc2
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_sis_noini(): """Test read Olympus SIS without INI tag.""" fname = private_file('sis/110.tif') with TiffFile(fname) as tif: assert tif.is_sis assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.se...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_sis_noini():
"""Test read Olympus SIS without INI tag.""" fname = private_file('sis/110.tif') with TiffFile(fname) as tif: assert tif.is_sis assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.series) == 1 # assert page properties page = tif.pages[0] ...
ification'] == 60.0 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_sis_noini():
64
64
189
21
43
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_sis_noini
test_read_sis_noini
9,312
9,331
9,312
9,313
b44ade297d7b9fa03d44af5de6a007e164be8e2d
bigcode/the-stack
train
b827b22ed621dbb6e02aba01
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_read_stk_noname(): """Test read MetaMorph STK with no name in metadata.""" # https://forum.image.sc/t/metamorph-stack-issue-with-ome-metadata- # bioformats-and-omero/48416 fname = private_file('stk/60x_2well_diffexpos1_w1sdcGFP_s1_t...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_read_stk_noname():
"""Test read MetaMorph STK with no name in metadata.""" # https://forum.image.sc/t/metamorph-stack-issue-with-ome-metadata- # bioformats-and-omero/48416 fname = private_file('stk/60x_2well_diffexpos1_w1sdcGFP_s1_t1.stk') with TiffFile(fname) as tif: assert tif.is_stk assert tif.byteo...
assert series.shape == (2048, 128, 512) assert series.dtype == numpy.uint16 assert series.axes == 'TYX' # assert data data = tif.asarray() assert isinstance(data, numpy.ndarray) assert data.shape == (2048, 128, 512) assert data.dtype == numpy.uint16 ...
139
139
466
26
113
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_stk_noname
test_read_stk_noname
6,494
6,534
6,494
6,495
31a5d820be3c9acb741ef281b2acf310559fb72a
bigcode/the-stack
train
2ac89ed0811426b3d770a0a6
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_filehandle_filehandle(): """Test FileHandle from other FileHandle.""" with FileHandle(FILEHANDLE_NAME, 'rb') as fhandle: with FileHandle(fhandle) as fh: assert fh.name == 'test_FileHandle.bin' assert fh.is_file ...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_filehandle_filehandle():
"""Test FileHandle from other FileHandle.""" with FileHandle(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
_LENGTH ) as fh: assert fh.name == 'test_FileHandle.bin' assert fh.is_file assert_filehandle(fh, offset=FILEHANDLE_OFFSET) assert not fhandle.closed @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_filehandle_filehandle():
64
64
86
20
43
bioturing/tifffile
tests/test_tifffile.py
Python
test_filehandle_filehandle
test_filehandle_filehandle
3,517
3,525
3,517
3,518
eb13c66b8a914755ce32bdb72140b07cac795985
bigcode/the-stack
train
bdef7a3872c3a047974c6d32
train
function
def test_sequence_stream_list(): """Test TiffSequence with list of ByteIO streams raises TypeError.""" data = numpy.random.rand(7, 9) files = [BytesIO(), BytesIO()] for buffer in files: imwrite(buffer, data) with pytest.raises(TypeError): imread(files)
def test_sequence_stream_list():
"""Test TiffSequence with list of ByteIO streams raises TypeError.""" data = numpy.random.rand(7, 9) files = [BytesIO(), BytesIO()] for buffer in files: imwrite(buffer, data) with pytest.raises(TypeError): imread(files)
as fh: fh2 = BytesIO(fh.read()) with TiffFile(fh2, offset=EMBED_OFFSET1, size=EMBED_SIZE1) as tif: assert_embed_micromanager(tif) ############################################################################### # Test sequence of image files def test_sequence_stream_list():
64
64
69
6
57
bioturing/tifffile
tests/test_tifffile.py
Python
test_sequence_stream_list
test_sequence_stream_list
14,023
14,030
14,023
14,023
b7d8f7c3ddf74742e8df26354ef4040791f1a5fd
bigcode/the-stack
train
d025396b20c510cd4eea11b5
train
function
def test_func_byteorder_isnative(): """Test byteorder_isnative function.""" assert byteorder_isnative(sys.byteorder) assert byteorder_isnative('=') if sys.byteorder == 'little': assert byteorder_isnative('<') assert not byteorder_isnative('>') else: assert byteorder_isnative(...
def test_func_byteorder_isnative():
"""Test byteorder_isnative function.""" assert byteorder_isnative(sys.byteorder) assert byteorder_isnative('=') if sys.byteorder == 'little': assert byteorder_isnative('<') assert not byteorder_isnative('>') else: assert byteorder_isnative('>') assert not byteorder_is...
6, 6, 7, 7, 7, 8, 8, 8], [6, 6, 6, 7, 7, 7, 8, 8, 8], ], ) def test_func_byteorder_isnative():
64
64
81
8
56
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_byteorder_isnative
test_func_byteorder_isnative
2,387
2,396
2,387
2,387
c918aa05392ec1ff463005ec9503f966df194932
bigcode/the-stack
train
19df8e4a4770c0a0888229b2
train
class
class TempFileName: """Temporary file name context manager.""" def __init__(self, name=None, ext='.tif', remove=False): self.remove = remove or TEMP_DIR == tempfile.gettempdir() if not name: fh = tempfile.NamedTemporaryFile(prefix='test_') self.name = fh.named ...
class TempFileName:
"""Temporary file name context manager.""" def __init__(self, name=None, ext='.tif', remove=False): self.remove = remove or TEMP_DIR == tempfile.gettempdir() if not name: fh = tempfile.NamedTemporaryFile(prefix='test_') self.name = fh.named fh.close() ...
) with obj.aszarr(chunkmode=chunkmode, **kwargs) as store: data = zarr.open(store, mode='r') if isinstance(data, zarr.Group): data = data[0] assert_array_equal(data, image) del data class TempFileName:
64
64
143
5
58
bioturing/tifffile
tests/test_tifffile.py
Python
TempFileName
TempFileName
375
395
375
375
a9e7ea249de490c8c74f494a24eaefce18851576
bigcode/the-stack
train
507cf016e87e695bacfcbdf8
train
function
def test_func_natural_sorted(): """Test natural_sorted function.""" assert natural_sorted(['f1', 'f2', 'f10']) == ['f1', 'f2', 'f10']
def test_func_natural_sorted():
"""Test natural_sorted function.""" assert natural_sorted(['f1', 'f2', 'f10']) == ['f1', 'f2', 'f10']
) 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_natural_sorted():
64
64
43
7
57
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_natural_sorted
test_func_natural_sorted
2,552
2,554
2,552
2,552
df6454d4e6549437b3ac684b07693fed23ca91b3
bigcode/the-stack
train
8c108b524a2d0b148f394934
train
function
def test_func_xml2dict(): """Test xml2dict function.""" d = xml2dict( """<?xml version="1.0" ?> <root attr="attribute"> <int>1</int> <float>3.14</float> <bool>True</bool> <string>Lorem Ipsum</string> </root> """ ) assert d['root']['attr'] == 'attribute...
def test_func_xml2dict():
"""Test xml2dict function.""" d = xml2dict( """<?xml version="1.0" ?> <root attr="attribute"> <int>1</int> <float>3.14</float> <bool>True</bool> <string>Lorem Ipsum</string> </root> """ ) assert d['root']['attr'] == 'attribute' assert d['root']['in...
exml assert 'TiffData IFD="1" PlaneCount="4"' in omexml assert 'TiffData IFD="5" PlaneCount="1"' in omexml assert_valid_omexml(omexml) def test_func_xml2dict():
64
64
144
7
57
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_xml2dict
test_func_xml2dict
2,288
2,304
2,288
2,288
ee13c7f3e1e5f61b454dbc857a767d865c503d80
bigcode/the-stack
train
5a26ec879f5f0ee53e508493
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_imagej_hela_cells(): """Test read ImageJ 512x672 RGB uint16.""" fname = private_file('imagej/hela-cells.tif') with TiffFile(fname) as tif: assert tif.is_imagej assert tif.byteorder == '>' assert len(tif.pages) == 1 ...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_imagej_hela_cells():
"""Test read ImageJ 512x672 RGB uint16.""" fname = private_file('imagej/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 # assert page properties page = tif.pa...
' assert ijtags['images'] == 205 # assert data data = tif.asarray() assert isinstance(data, numpy.ndarray) assert data.shape == (205, 434, 425) assert data.dtype == numpy.uint8 assert data[102, 216, 212] == 120 assert_aszarr_method(series, data) as...
128
128
428
22
106
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_imagej_hela_cells
test_read_imagej_hela_cells
8,292
8,331
8,292
8,293
bbef27ead0d5ed73f200dde62ba003d7ac74fdf9
bigcode/the-stack
train
83765d873e14b9debcf45290
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_imagej_prop(): """Test reading and writing ImageJ prop metadata type.""" # https://github.com/cgohlke/tifffile/issues/103 # also test writing indexed ImageJ file fname = private_file('issues/triple-sphere-big-distance=035.tif') with ti...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_imagej_prop():
"""Test reading and writing ImageJ prop metadata type.""" # https://github.com/cgohlke/tifffile/issues/103 # also test writing indexed ImageJ file fname = private_file('issues/triple-sphere-big-distance=035.tif') with tifffile.TiffFile(fname) as tif: assert tif.is_imagej meta = tif....
_C001T00*.tif') with TiffSequence(files) as tiffs: assert tiffs.shape == (2,) with pytest.warns(DeprecationWarning): assert_array_equal(tiffs.asarray(file=files[0]), imread(files[0])) with pytest.warns(DeprecationWarning): assert_array_equal(tiffs.asarray(file=1), imr...
106
107
357
20
86
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_imagej_prop
test_issue_imagej_prop
1,566
1,600
1,566
1,567
6d37a5743e13219f45ab2226a76e4af52389d89a
bigcode/the-stack
train
d98ce6de0c385027b7eb9457
train
function
def test_write_tiled_compressed(): """Test write compressed tiles.""" data = random_data(numpy.uint8, (3, 219, 301)) with TempFileName('tiled_compressed') as fname: imwrite( fname, data, photometric=RGB, planarconfig=SEPARATE, compression=(...
def test_write_tiled_compressed():
"""Test write compressed tiles.""" data = random_data(numpy.uint8, (3, 219, 301)) with TempFileName('tiled_compressed') as fname: imwrite( fname, data, photometric=RGB, planarconfig=SEPARATE, compression=(ADOBE_DEFLATE, 5), tile...
ample == 16 assert page.tags['CFARepeatPatternDim'].value == (2, 2) assert page.tags['CFAPattern'].value == b'\x00\x01\x01\x02' assert_array_equal(page.asarray(), data) assert_aszarr_method(page, data) def test_write_tiled_compressed():
73
73
245
8
65
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_tiled_compressed
test_write_tiled_compressed
11,943
11,971
11,943
11,943
19833da1a3ede11ac7b47986465bd7c262577ed3
bigcode/the-stack
train
dc13fa249c57f8f7e2ccb051
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_rgb565(): """Test read 64x64 RGB uint8 5,6,5 bitspersample.""" fname = private_file('rgb565.tif') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.series) == 1 # a...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_rgb565():
"""Test read 64x64 RGB uint8 5,6,5 bitspersample.""" fname = private_file('rgb565.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.pho...
assert data.shape == (785, 1065, 4) assert data.dtype == numpy.uint8 assert tuple(data[560, 412, :]) == (60, 92, 74, 255) assert_aszarr_method(tif, data) assert_decode_method(page) assert__str__(tif) @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_rgb565():...
93
93
312
19
74
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_rgb565
test_read_rgb565
4,520
4,550
4,520
4,521
16200041e536e82f4856c32e0f081ab034288146
bigcode/the-stack
train
401b73e820cc649fcd85c09b
train
function
def test_write_rowsperstrip(): """Test write rowsperstrip without compression.""" data = WRITE_DATA with TempFileName('rowsperstrip') as fname: imwrite( fname, data, rowsperstrip=32, contiguous=False, photometric=RGB, metadata=N...
def test_write_rowsperstrip():
"""Test write rowsperstrip without compression.""" data = WRITE_DATA with TempFileName('rowsperstrip') as fname: imwrite( fname, data, rowsperstrip=32, contiguous=False, photometric=RGB, metadata=None, ) assert_v...
.imagelength == 219 assert page.samplesperpixel == 3 assert page.predictor == 3 if dtype.kind == 'f' else 2 image = tif.asarray() assert_array_equal(data, image) assert_aszarr_method(tif, image) assert__str__(tif) def test_write_rowsperstrip():
76
76
255
7
69
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_rowsperstrip
test_write_rowsperstrip
11,100
11,130
11,100
11,100
4b23ae4e9a34d6bf54d218d3d4fe0e86a3cf1855
bigcode/the-stack
train
5e4e7a49937f7a4e88074193
train
function
def test_issue_pickle(): """Test that TIFF constants are picklable.""" # https://github.com/cgohlke/tifffile/issues/64 from pickle import dumps, loads assert loads(dumps(TIFF)).CHUNKMODE.PLANE == TIFF.CHUNKMODE.PLANE assert loads(dumps(TIFF.CHUNKMODE)).PLANE == TIFF.CHUNKMODE.PLANE assert loads...
def test_issue_pickle():
"""Test that TIFF constants are picklable.""" # https://github.com/cgohlke/tifffile/issues/64 from pickle import dumps, loads assert loads(dumps(TIFF)).CHUNKMODE.PLANE == TIFF.CHUNKMODE.PLANE assert loads(dumps(TIFF.CHUNKMODE)).PLANE == TIFF.CHUNKMODE.PLANE assert loads(dumps(TIFF.CHUNKMODE.PLA...
j assert 'DisplaySettings' not in tif.micromanager_metadata assert 'failed to read display settings' in caplog.text series = tif.series[0] assert series.shape == (50, 5, 3, 256, 256) def test_issue_pickle():
64
64
110
5
59
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_pickle
test_issue_pickle
1,138
1,145
1,138
1,138
9a79fa01d50aa4e4e01f44374fc1d9a5a08b4347
bigcode/the-stack
train
393a445082f458cb1914a430
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_scanimage_2021(): """Test read ScanImage metadata.""" # https://github.com/cgohlke/tifffile/issues/46 fname = private_file('ScanImage/ScanImage2021_3frames.tif') with open(fname, 'rb') as fh: frame_data, roi_data, version = read_scan...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_scanimage_2021():
"""Test read ScanImage metadata.""" # https://github.com/cgohlke/tifffile/issues/46 fname = private_file('ScanImage/ScanImage2021_3frames.tif') with open(fname, 'rb') as fh: frame_data, roi_data, version = read_scanimage_metadata(fh) assert frame_data['SI.hChannels.channelType'] == [ ...
read ScanImage metadata.""" fname = private_file('ScanImage/TS_UnitTestImage_BigTIFF.tif') with open(fname, 'rb') as fh: frame_data, roi_data, version = read_scanimage_metadata(fh) assert version == 3 assert frame_data['SI.hChannels.channelType'] == ['stripe', 'stripe'] assert roi_data['Roi...
121
121
406
22
98
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_scanimage_2021
test_read_scanimage_2021
6,902
6,941
6,902
6,903
930ed6bf2a93ee1d6013fa5709fe05afee3bee68
bigcode/the-stack
train
41a2caca8b26a57ab0a66900
train
function
@pytest.mark.parametrize('compression', [0, 6]) @pytest.mark.parametrize('dtype', [numpy.uint8, numpy.uint16]) def test_write_palette(dtype, compression): """Test write palette images.""" dtype = numpy.dtype(dtype) data = random_data(dtype, (3, 219, 301)) cmap = random_data(numpy.uint16, (3, 2 ** (data....
@pytest.mark.parametrize('compression', [0, 6]) @pytest.mark.parametrize('dtype', [numpy.uint8, numpy.uint16]) def test_write_palette(dtype, compression):
"""Test write palette images.""" dtype = numpy.dtype(dtype) data = random_data(dtype, (3, 219, 301)) cmap = random_data(numpy.uint16, (3, 2 ** (data.itemsize * 8))) with TempFileName(f'palette_{compression}{dtype}') as fname: imwrite( fname, data, colormap...
1024 assert page.samplesperpixel == 1 image = tif.asarray(out='memmap') assert_array_equal(data, image) del image del data assert__str__(tif) @pytest.mark.parametrize('compression', [0, 6]) @pytest.mark.parametrize('dtype', [numpy.uint8, numpy.uint...
82
82
275
35
47
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_palette
test_write_palette
12,680
12,708
12,680
12,682
77a49cbe79e4152f76af0625e7fc24dcf07dc2ff
bigcode/the-stack
train
30acf1ea2d06ec50499bc956
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_subifd4(): """Test read BigTIFFSubIFD4.""" fname = public_file('twelvemonkeys/bigtiff/BigTIFFSubIFD4.tif') with TiffFile(fname) as tif: assert len(tif.series) == 1 assert len(tif.pages) == 2 page = tif.pages[0] ass...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_subifd4():
"""Test read BigTIFFSubIFD4.""" fname = public_file('twelvemonkeys/bigtiff/BigTIFFSubIFD4.tif') with TiffFile(fname) as tif: assert len(tif.series) == 1 assert len(tif.pages) == 2 page = tif.pages[0] assert page.photometric == RGB assert page.imagewidth == 64 ...
# assert data image = page.asarray() assert image.flags['C_CONTIGUOUS'] assert image.shape == (300, 400, 3) assert image.dtype == numpy.uint8 assert tuple(image[124, 292]) == (236, 109, 95) assert__str__(tif) @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def tes...
94
94
315
21
73
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_subifd4
test_read_subifd4
5,687
5,716
5,687
5,688
b01e8ae8878a8d88d3b7159db59782d4a0abde7a
bigcode/the-stack
train
3f6e469adbecd0cd240cbea4
train
function
def test_issue_imread_kwargs_legacy(): """Test legacy arguments still work in some cases. Specifying 'fastij', 'movie', 'multifile', 'multifile_close', or 'pages' raises DeprecationWarning. Specifying 'key' and 'pages' raises TypeError. Specifying 'pages' in TiffFile constructor raises TypeError. ...
def test_issue_imread_kwargs_legacy():
"""Test legacy arguments still work in some cases. Specifying 'fastij', 'movie', 'multifile', 'multifile_close', or 'pages' raises DeprecationWarning. Specifying 'key' and 'pages' raises TypeError. Specifying 'pages' in TiffFile constructor raises TypeError. """ data = random_data(numpy.ui...
image in data: tif.write(image) # create 5 series assert_valid_tiff(fname) image = imread(fname, pattern=None) # reads first series assert_array_equal(image, data[0]) image = imread(fname, is_shaped=False) # reads all pages assert_array_equal(image, data) def ...
84
84
281
9
75
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_imread_kwargs_legacy
test_issue_imread_kwargs_legacy
450
480
450
450
90b096d480b16b3b975c28a8a4a82788b33f0bd6
bigcode/the-stack
train
36c57c0cff2c6b6f62af8daf
train
function
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_read_strike(): """Test read 256x200 RGBA uint8 LZW.""" fname = public_file('juicypixels/strike.tif') with TiffFile(fname) as tif: assert__str__(tif) assert tif.byteorder == '>' assert len(tif.pages) == 1 ...
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_read_strike():
"""Test read 256x200 RGBA uint8 LZW.""" fname = public_file('juicypixels/strike.tif') with TiffFile(fname) as tif: assert__str__(tif) assert tif.byteorder == '>' assert len(tif.pages) == 1 assert len(tif.series) == 1 # assert page properties page = tif.pages[0...
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, data) @pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, r...
100
100
336
24
76
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_strike
test_read_strike
4,314
4,346
4,314
4,315
fb8ee7352a0ad351c138fa09df3f022e5f5ba2b1
bigcode/the-stack
train
133b9f154743333ef661c496
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_fei_metadata(): """Test read Helios FEI metadata.""" # file from hyperspy tests fname = private_file('hyperspy/test_tiff_FEI_SEM.tif') with TiffFile(fname) as tif: assert tif.is_fei assert tif.byteorder == '<' assert ...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_fei_metadata():
"""Test read Helios FEI metadata.""" # file from hyperspy tests fname = private_file('hyperspy/test_tiff_FEI_SEM.tif') with TiffFile(fname) as tif: assert tif.is_fei assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.series) == 1 # assert page p...
17476, 17476) sem = tif.sem_metadata assert sem['sv_version'][1] == 'V05.07.00.00 : 08-Jul-14' assert_aszarr_method(tif) assert__str__(tif) @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_fei_metadata():
77
77
258
20
57
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_fei_metadata
test_read_fei_metadata
9,396
9,421
9,396
9,397
663f682e9e18f6cf9062d8fdc8904d10fb7ff1d4
bigcode/the-stack
train
652597c6080033ddfef75144
train
function
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS or SKIP_LARGE, reason=REASON) def test_read_lsm_mb231paxgfp_060214(): """Test read LSM with many LZW compressed pages.""" # TZCYX (Stack mode), (60, 31, 2, 512, 512), 3720 fname = public_file('tifffile/MB231paxgfp_060214.lzw.lsm') with TiffFile(fname) as ti...
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS or SKIP_LARGE, reason=REASON) def test_read_lsm_mb231paxgfp_060214():
"""Test read LSM with many LZW compressed pages.""" # TZCYX (Stack mode), (60, 31, 2, 512, 512), 3720 fname = public_file('tifffile/MB231paxgfp_060214.lzw.lsm') with TiffFile(fname) as tif: assert tif.is_lsm assert tif.byteorder == '<' assert len(tif.pages) == 3720 assert...
.dtype == numpy.uint8 assert tuple(data[18, :, 64, 64]) == (25, 5, 33) assert_aszarr_method(tif, series=1) # assert lsm_info tags tags = tif.lsm_metadata assert tags['DimensionX'] == 512 assert tags['DimensionY'] == 512 assert tags['DimensionZ'] == 19 ...
202
202
675
38
164
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_lsm_mb231paxgfp_060214
test_read_lsm_mb231paxgfp_060214
6,112
6,171
6,112
6,113
3680bc88a9aa7b84515413a5c7c4361207758e71
bigcode/the-stack
train
7e34d9f3d33742abc57318f1
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_ndtiffstorage(): """Test read NDTiffStorage/MagellanStack.""" # https://github.com/cgohlke/tifffile/issues/23 fname = private_file( 'NDTiffStorage/MagellanStack/Full resolution/democam_MagellanStack.tif' ) with TiffFile(fname) as...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_ndtiffstorage():
"""Test read NDTiffStorage/MagellanStack.""" # https://github.com/cgohlke/tifffile/issues/23 fname = private_file( 'NDTiffStorage/MagellanStack/Full resolution/democam_MagellanStack.tif' ) with TiffFile(fname) as tif: assert tif.is_micromanager assert len(tif.pages) == 12 ...
['User']['User'] == 'supervisor' assert fei['System']['DisplayHeight'] == 0.324 assert_aszarr_method(tif) assert__str__(tif) @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_ndtiffstorage():
64
64
178
21
43
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_ndtiffstorage
test_read_ndtiffstorage
9,424
9,438
9,424
9,425
b69bfb08fa0c3191da233442d6b98fed268ec447
bigcode/the-stack
train
f17ba107e8cfb45a3dbc56ec
train
function
def test_write_description_tag_nojson(): """Test no JSON description is written with metatata=None.""" data = random_data(numpy.uint8, (2, 219, 301)) description = 'Created by TestTiffWriter\nLorem ipsum dolor...' with TempFileName('description_tag_nojson') as fname: imwrite(fname, data, descrip...
def test_write_description_tag_nojson():
"""Test no JSON description is written with metatata=None.""" data = random_data(numpy.uint8, (2, 219, 301)) description = 'Created by TestTiffWriter\nLorem ipsum dolor...' with TempFileName('description_tag_nojson') as fname: imwrite(fname, data, description=description, metadata=None) ...
assert tif.pages[0].description == description assert tif.pages[0].description1 == '{"shape": [2, 219, 301]}' assert 'ImageDescription' not in tif.pages[1].tags assert__str__(tif) def test_write_description_tag_nojson():
64
64
163
8
56
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_description_tag_nojson
test_write_description_tag_nojson
10,438
10,450
10,438
10,438
1d5b05f54a9474bffb69eb4565132d26436047cb
bigcode/the-stack
train
892454900f584d3937456a18
train
function
def test_func_snipstr(): """Test snipstr function.""" # cut middle assert snipstr('abc', 3, ellipsis='...') == 'abc' assert snipstr('abc', 3, ellipsis='....') == 'abc' assert snipstr('abcdefg', 4, ellipsis='') == 'abcd' assert snipstr('abcdefg', 4, ellipsis=None) == 'abc…' assert snipstr(b'a...
def test_func_snipstr():
"""Test snipstr function.""" # cut middle assert snipstr('abc', 3, ellipsis='...') == 'abc' assert snipstr('abc', 3, ellipsis='....') == 'abc' assert snipstr('abcdefg', 4, ellipsis='') == 'abcd' assert snipstr('abcdefg', 4, ellipsis=None) == 'abc…' assert snipstr(b'abcdefg', 4, ellipsis=None...
08 00 00 00 0e 00 fe 00 04 00 01 00 ' 'II*.............\n' '10: 00 00 00 00 00 00 00 01 04 00 01 00 00 00 00 01 ' '................\n' '20: 00 00 01 01 04 00 01 00 00 00 00 01 00 00 02 01 ' '................' ) def test_func_asbool(): """Test asbool function.""" for...
255
256
997
7
248
bioturing/tifffile
tests/test_tifffile.py
Python
test_func_snipstr
test_func_snipstr
2,918
2,990
2,918
2,918
f224aa1e6f70ffc57f522f1a5ce3eec10ecba74a
bigcode/the-stack
train
a8ebece0fdb2ac29d1357f6b
train
function
def public_file(pathname, base=PUBLIC_DIR, expand=True): """Return path to public test file(s).""" return data_file(pathname, base, expand=expand)
def public_file(pathname, base=PUBLIC_DIR, expand=True):
"""Return path to public test file(s).""" return data_file(pathname, base, expand=expand)
?'): return glob.glob(path) return path def private_file(pathname, base=PRIVATE_DIR, expand=True): """Return path to private test file(s).""" return data_file(pathname, base, expand=expand) def public_file(pathname, base=PUBLIC_DIR, expand=True):
64
64
38
14
50
bioturing/tifffile
tests/test_tifffile.py
Python
public_file
public_file
298
300
298
298
0a98ff0b6006cc8a956561f33fe9a242867b9982
bigcode/the-stack
train
b725dbf2c624f046c0b9f4b4
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_read_metaseries(): """Test read MetaSeries 1040x1392 uint16, LZW.""" # Strips do not contain an EOI code as required by the TIFF spec. fname = private_file('metaseries/metaseries.tif') with TiffFile(fname) as tif: assert ti...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_read_metaseries():
"""Test read MetaSeries 1040x1392 uint16, LZW.""" # Strips do not contain an EOI code as required by the TIFF spec. fname = private_file('metaseries/metaseries.tif') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.series) == 1 ...
1024) assert data.dtype == numpy.uint16 assert round(abs(data[1, 2, 128, 128] - 8317), 7) == 0 # too slow: assert_aszarr_method(series, data) assert__str__(tif) @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_read_metaseries():
89
89
299
25
64
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_metaseries
test_read_metaseries
8,776
8,804
8,776
8,777
2a6ab2a16d7adc7f5d9290e0f54b5d285295bfb4
bigcode/the-stack
train
e5cda648ec510c6992ac066b
train
function
def test_write_compression_predictor(): """Test write horizontal differencing.""" data = WRITE_DATA with TempFileName('compression_predictor') as fname: imwrite( fname, data, compression=ADOBE_DEFLATE, predictor=HORIZONTAL, photometric=RGB,...
def test_write_compression_predictor():
"""Test write horizontal differencing.""" data = WRITE_DATA with TempFileName('compression_predictor') as fname: imwrite( fname, data, compression=ADOBE_DEFLATE, predictor=HORIZONTAL, photometric=RGB, ) assert_valid_tiff(fna...
assert page.samplesperpixel == 3 assert len(page.dataoffsets) == 210 image = tif.asarray() assert_array_equal(data, image) assert_aszarr_method(tif, image) assert__str__(tif) def test_write_compression_predictor():
64
64
216
8
56
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_compression_predictor
test_write_compression_predictor
11,036
11,062
11,036
11,036
85fd0cfee951813d377ad4c6e17d6c8ae9d7bae4
bigcode/the-stack
train
87d5fc5686c0f0d0a67a96cb
train
function
@pytest.mark.skipif(SKIP_EXTENDED, reason=REASON) @pytest.mark.parametrize( 'shape', [ (219, 301, 1), (219, 301, 2), (219, 301, 3), (219, 301, 4), (219, 301, 5), (1, 219, 301), (2, 219, 301), (3, 219, 301), (4, 219, 301), (5, 219, 3...
@pytest.mark.skipif(SKIP_EXTENDED, reason=REASON) @pytest.mark.parametrize( 'shape', [ (219, 301, 1), (219, 301, 2), (219, 301, 3), (219, 301, 4), (219, 301, 5), (1, 219, 301), (2, 219, 301), (3, 219, 301), (4, 219, 301), (5, 219, 3...
"""Test write ImageJ format.""" # TODO: test compression and bigtiff ? dtype = numpy.dtype(dtype) if dtype != numpy.uint8 and shape[-1] in (3, 4): pytest.xfail('ImageJ only supports uint8 RGB') data = random_data(dtype, shape) fname = 'imagej_{}_{}_{}'.format( {'<': 'le', '>': 'b...
@pytest.mark.skipif(SKIP_EXTENDED, reason=REASON) @pytest.mark.parametrize( 'shape', [ (219, 301, 1), (219, 301, 2), (219, 301, 3), (219, 301, 4), (219, 301, 5), (1, 219, 301), (2, 219, 301), (3, 219, 301), (4, 219, 301), (5, 219, 3...
349
154
516
349
0
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_imagej
test_write_imagej
13,051
13,097
13,051
13,082
2839cafea36354571b97a58b03f78d4fb528b8d4
bigcode/the-stack
train
383a6d2617d0141d8b307649
train
function
@pytest.mark.skipif(SKIP_CODECS or not imagecodecs.JPEG, reason=REASON) def test_read_tiles(): """Test iteration over tiles, manually and via page.segments.""" data = numpy.arange(600 * 500 * 3, dtype=numpy.uint8).reshape( (600, 500, 3) ) with TempFileName('read_tiles') as fname: with Ti...
@pytest.mark.skipif(SKIP_CODECS or not imagecodecs.JPEG, reason=REASON) def test_read_tiles():
"""Test iteration over tiles, manually and via page.segments.""" data = numpy.arange(600 * 500 * 3, dtype=numpy.uint8).reshape( (600, 500, 3) ) with TempFileName('read_tiles') as fname: with TiffWriter(fname) as tif: options = dict( tile=(256, 256), ...
32, 3) assert image.dtype == numpy.uint8 assert image[15, 15, 0] == 255 assert image[16, 16, 2] == 0 assert_aszarr_method(page) assert__str__(tif) @pytest.mark.skipif(SKIP_CODECS or not imagecodecs.JPEG, reason=REASON) def test_read_tiles():
88
88
294
26
62
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_tiles
test_read_tiles
5,751
5,780
5,751
5,752
5a7d322f0a95d16a7fbd4e8a5544afd83de19258
bigcode/the-stack
train
106af8b8ea643f900c3055cb
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_imagej_metadatabytecounts(): """Test reading ImageJ file with many IJMetadataByteCounts.""" # https://github.com/cgohlke/tifffile/issues/111 fname = private_file('imagej/issue111.tif') with tifffile.TiffFile(fname) as tif: assert ti...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_imagej_metadatabytecounts():
"""Test reading ImageJ file with many IJMetadataByteCounts.""" # https://github.com/cgohlke/tifffile/issues/111 fname = private_file('imagej/issue111.tif') with tifffile.TiffFile(fname) as tif: assert tif.is_imagej page = tif.pages[0] assert isinstance(page.tags['IJMetadataByteCo...
assert 'incorrect StripByteCounts count' in caplog.text assert 'missing data offset tag' in caplog.text with pytest.raises(TiffFileError): tif.asarray() @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_issue_imagej_metadatabytecounts():
64
64
125
23
41
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_imagej_metadatabytecounts
test_issue_imagej_metadatabytecounts
1,621
1,630
1,621
1,622
4a29d449eee58a0f6b9eeceb7ce0f7b7480f17d3
bigcode/the-stack
train
4b83c4b7e87d214d1e6f72fa
train
function
@pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_read_jpeg_ycbcr(): """Test read YCBCR JPEG is returned as RGB.""" fname = private_file('jpeg/jpeg_ycbcr.tiff') with TiffFile(fname) as tif: assert len(tif.pages) == 1 page = tif.pages[0] ...
@pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_read_jpeg_ycbcr():
"""Test read YCBCR JPEG is returned as RGB.""" fname = private_file('jpeg/jpeg_ycbcr.tiff') with TiffFile(fname) as tif: assert len(tif.pages) == 1 page = tif.pages[0] assert page.compression == JPEG assert page.photometric == YCBCR assert page.planarconfig == CONTIG ...
Error, NotImplementedError)): image = tif.asarray() assert image.flags['C_CONTIGUOUS'] assert_aszarr_method(tif, image) assert__str__(tif) @pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_read_jpeg_ycbcr():
79
79
266
37
42
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_jpeg_ycbcr
test_read_jpeg_ycbcr
4,826
4,851
4,826
4,829
d0b0a4d07a7e8eb5e4b9ff60b0dc5db8b919e696
bigcode/the-stack
train
d971c0c37a9a073e8d2250f0
train
function
@pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.LJPEG, reason=REASON ) def test_read_dng(): """Test read JPEG compressed CFA image in SubIFD.""" fname = private_file('DNG/IMG_0793.DNG') with TiffFile(fname) as tif: assert len(tif.pages) == 1 assert len(tif.series) == 2...
@pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.LJPEG, reason=REASON ) def test_read_dng():
"""Test read JPEG compressed CFA image in SubIFD.""" fname = private_file('DNG/IMG_0793.DNG') with TiffFile(fname) as tif: assert len(tif.pages) == 1 assert len(tif.series) == 2 page = tif.pages[0] assert page.index == 0 assert page.shape == (640, 852, 3) asse...
'] assert image.shape == (20, 20) assert image.dtype == numpy.uint8 assert image[18, 1] == 247 assert_aszarr_method(tif, image) assert__str__(tif) @pytest.mark.skipif( SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.LJPEG, reason=REASON ) def test_read_dng():
87
87
290
34
53
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_dng
test_read_dng
5,115
5,141
5,115
5,118
08943f0c88c9caf0bbf686e5db0b9538c7476553
bigcode/the-stack
train
1e3bde599bbcc3c912158c7d
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_ome_rgb(): """Test read OME RGB image.""" # https://github.com/openmicroscopy/bioformats/pull/1986 fname = private_file('OME/test_rgb.ome.tif') with TiffFile(fname) as tif: assert tif.is_ome assert tif.byteorder == '<' ...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_ome_rgb():
"""Test read OME RGB image.""" # https://github.com/openmicroscopy/bioformats/pull/1986 fname = private_file('OME/test_rgb.ome.tif') with TiffFile(fname) as tif: assert tif.is_ome assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.series) == 1 #...
assert data[0, 34, 4, 303, 206] == 82 assert data[1, 25, 2, 425, 272] == 196 assert_aszarr_method(tif, data) assert_aszarr_method(tif, data, chunkmode='page') del data assert__str__(tif) @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_ome_rgb():
103
103
346
20
83
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_ome_rgb
test_read_ome_rgb
7,719
7,752
7,719
7,720
f0dff40abfe43317979958a69ddee457fe39fea7
bigcode/the-stack
train
a2c96d9fe0cda8d329636664
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_filehandle_openfile_offset(): """Test FileHandle from open file with offset.""" with open(FILEHANDLE_NAME, 'rb') as fhandle: with FileHandle( fhandle, offset=FILEHANDLE_OFFSET, size=FILEHANDLE_LENGTH ) as fh: assert...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_filehandle_openfile_offset():
"""Test FileHandle from open file with offset.""" with open(FILEHANDLE_NAME, 'rb') as fhandle: with FileHandle( fhandle, offset=FILEHANDLE_OFFSET, size=FILEHANDLE_LENGTH ) as fh: assert fh.name == 'test_FileHandle.bin' assert fh.is_file assert_file...
handle: 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_openfile_offset():
64
64
109
21
42
bioturing/tifffile
tests/test_tifffile.py
Python
test_filehandle_openfile_offset
test_filehandle_openfile_offset
3,504
3,514
3,504
3,505
9d99d10060e0c184cac7f408be9173879abb172f
bigcode/the-stack
train
0bcd7f131c78f37a6a68c59b
train
function
def test_write_volumetric_striped_contig_rgb(): """Test write 6D array as contig RGB volumes.""" shape = (2, 3, 15, 63, 95, 3) data = numpy.empty(shape, dtype=numpy.uint8) data[:] = numpy.arange(15, dtype=numpy.uint8).reshape(1, 1, -1, 1, 1, 1) with TempFileName('volumetric_striped_contig_rgb') as f...
def test_write_volumetric_striped_contig_rgb():
"""Test write 6D array as contig RGB volumes.""" shape = (2, 3, 15, 63, 95, 3) data = numpy.empty(shape, dtype=numpy.uint8) data[:] = numpy.arange(15, dtype=numpy.uint8).reshape(1, 1, -1, 1, 1, 1) with TempFileName('volumetric_striped_contig_rgb') as fname: imwrite(fname, data, volumetric=Tr...
assert len(page.dataoffsets) == 15 * 3 assert len(page.databytecounts) == 15 * 3 series = tif.series[0] assert len(series._pages) == 1 assert len(series.pages) == 2 assert series.offset is not None assert series.shape == shape ...
119
119
399
12
107
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_volumetric_striped_contig_rgb
test_write_volumetric_striped_contig_rgb
12,533
12,568
12,533
12,533
b0aa47394de10a8e715cb35e3ab7c25d6f401876
bigcode/the-stack
train
bce7bf2fd9544aa385ccf880
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_sequence_zip_container(): """Test TiffSequence with glob pattern without axes pattern.""" fname = private_file('TiffSequence.zip') with TiffSequence('*.tif', container=fname, pattern=None) as tifs: assert len(tifs) == 10 ...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_sequence_zip_container():
"""Test TiffSequence with glob pattern without axes pattern.""" fname = private_file('TiffSequence.zip') with TiffSequence('*.tif', container=fname, pattern=None) as tifs: assert len(tifs) == 10 assert tifs.shape == (10,) assert tifs.axes == 'I' data = tifs.asarray() ...
56) if not SKIP_ZARR: with tifs.aszarr() as store: assert_array_equal(data, zarr.open(store, mode='r')) del data @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON) def test_sequence_zip_container():
64
64
174
24
39
bioturing/tifffile
tests/test_tifffile.py
Python
test_sequence_zip_container
test_sequence_zip_container
14,118
14,132
14,118
14,119
9db3e3a4110365c8a28f152171ebf227d67ee2d0
bigcode/the-stack
train
6f0d529435687d149acd4f4d
train
function
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_issue_arw(caplog): """Test read Sony ARW RAW image.""" # https://github.com/cgohlke/tifffile/issues/95 fname = private_file('RAW/A1_full_lossless_compressed.ARW') with TiffFile(fname) as tif: ...
@pytest.mark.skipif( SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON ) def test_issue_arw(caplog):
"""Test read Sony ARW RAW image.""" # https://github.com/cgohlke/tifffile/issues/95 fname = private_file('RAW/A1_full_lossless_compressed.ARW') with TiffFile(fname) as tif: assert len(tif.pages) == 3 assert len(tif.series) == 4 page = tif.pages[0] assert page.compressi...
(4032, 6048, 3) assert page.dtype == numpy.uint8 assert page.photometric == OJPEG data = page.asarray() assert tuple(data[60, 80]) == (67, 13, 11) assert_aszarr_method(page, data) page = tif.pages[0].pages[1] assert page.shape == (4044, 6080) assert page...
172
172
574
36
136
bioturing/tifffile
tests/test_tifffile.py
Python
test_issue_arw
test_issue_arw
1,265
1,320
1,265
1,268
9a3d23108ed880adb5062bb1f18b17227508a6ca
bigcode/the-stack
train
0c5064e14cd03c0ad8071c89
train
function
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON) def test_embed_tif_openfile(): """Test embedded TIFF from file handle.""" with open(EMBED_NAME, 'rb') as fh: with TiffFile(fh, 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_openfile():
"""Test embedded TIFF from file handle.""" with open(EMBED_NAME, 'rb') as fh: with TiffFile(fh, offset=EMBED_OFFSET, size=EMBED_SIZE) as tif: assert_embed_tif(tif)
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_openfile():
64
64
80
26
38
bioturing/tifffile
tests/test_tifffile.py
Python
test_embed_tif_openfile
test_embed_tif_openfile
13,943
13,948
13,943
13,944
df4024938bcc00a7ef3a63885d1889b164488afa
bigcode/the-stack
train
f4b4f303427f9e6c0c5152b8
train
function
def test_write_volumetric_striped(): """Test write striped volume.""" data = random_data(numpy.uint8, (15, 63, 95)) with TempFileName('volumetric_striped') as fname: imwrite(fname, data, volumetric=True) assert_valid_tiff(fname) with TiffFile(fname) as tif: assert len(tif...
def test_write_volumetric_striped():
"""Test write striped volume.""" data = random_data(numpy.uint8, (15, 63, 95)) with TempFileName('volumetric_striped') as fname: imwrite(fname, data, volumetric=True) assert_valid_tiff(fname) with TiffFile(fname) as tif: assert len(tif.pages) == 1 page = tif.p...
1 assert len(series.pages) == 6 assert series.offset is not None assert series.shape == shape image = tif.asarray() assert_array_equal(image.shape, shape) assert_aszarr_method(tif, image) assert__str__(tif) def test_write_volumetric_str...
70
70
235
9
61
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_volumetric_striped
test_write_volumetric_striped
12,438
12,461
12,438
12,438
a9c264430f427072144ccfec5b90a06ef3d08ed3
bigcode/the-stack
train
24b12e77ebab06dcb7216be4
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_ome_shape_mismatch(caplog): """Test read OME with page shape mismatch.""" # TCX (20000, 2, 500) is stored in 2 pages of (20000, 500) # probably exported by ZEN Software fname = private_file('OME/Image 7.ome_h00.tiff') with TiffFile(fname...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_ome_shape_mismatch(caplog):
"""Test read OME with page shape mismatch.""" # TCX (20000, 2, 500) is stored in 2 pages of (20000, 500) # probably exported by ZEN Software fname = private_file('OME/Image 7.ome_h00.tiff') with TiffFile(fname) as tif: assert tif.is_ome assert tif.byteorder == '<' assert len(...
# assert series properties series = tif.series[0] assert len(series.pages) == 1000 assert series.offset is None # not contiguous assert series.shape == (1000, 1726, 1982) assert series.dtype == numpy.uint16 assert series.axes == 'IYX' assert__str__(tif) @...
103
103
346
24
79
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_ome_shape_mismatch
test_read_ome_shape_mismatch
7,947
7,980
7,947
7,948
dfe783edf0f77d5581082d02d4f7423f6ab5dd3b
bigcode/the-stack
train
3173c421e172a46461a63362
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS or SKIP_LARGE, reason=REASON) def test_read_lzw_large_buffer(): """Test read LZW compression which requires large buffer.""" # https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET-MVC-App # /issues/35 fname = private_file('lzw/lzw_large_buffer.tif...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS or SKIP_LARGE, reason=REASON) def test_read_lzw_large_buffer():
"""Test read LZW compression which requires large buffer.""" # https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET-MVC-App # /issues/35 fname = private_file('lzw/lzw_large_buffer.tiff') with TiffFile(fname) as tif: assert len(tif.pages) == 1 page = tif.pages[0] asse...
assert image.flags['C_CONTIGUOUS'] assert image[434, 588] == 88 assert image[400, 600] == 255 assert_aszarr_method(page, image) assert__str__(tif) @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS or SKIP_LARGE, reason=REASON) def test_read_lzw_large_buffer():
86
86
288
31
55
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_lzw_large_buffer
test_read_lzw_large_buffer
4,727
4,751
4,727
4,728
657f0e215bf43c3bfea6768314846bec929e9c73
bigcode/the-stack
train
43cfe989e4b297a304663d9f
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_ome_modulo_lambda(): """Test read OME modulo LAMBDA.""" # Excitation of 5 wavelength [big-lambda] each recorded at 10 emission # wavelength ranges [lambda]. fname = public_file('OME/modulo/LAMBDA-ModuloAlongZ-ModuloAlongT.ome.tiff') with ...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_ome_modulo_lambda():
"""Test read OME modulo LAMBDA.""" # Excitation of 5 wavelength [big-lambda] each recorded at 10 emission # wavelength ranges [lambda]. fname = public_file('OME/modulo/LAMBDA-ModuloAlongZ-ModuloAlongT.ome.tiff') with TiffFile(fname) as tif: assert tif.is_ome assert tif.byteorder == '...
(data, numpy.ndarray) assert data.shape == (3, 4, 2, 4, 2, 220, 160) assert data.dtype == numpy.uint8 assert data[2, 3, 1, 3, 1, 210, 151] == 92 assert_aszarr_method(tif, data) assert__str__(tif) @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_ome_modulo_lambda():
109
109
364
22
87
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_ome_modulo_lambda
test_read_ome_modulo_lambda
7,473
7,506
7,473
7,474
f0c8d9cbaccf32d0b18ecc54b9b87f2441fdd296
bigcode/the-stack
train
1b6a70d02079ca65f0740c1d
train
function
def test_write_nopages(): """Test write TIFF with no pages.""" with TempFileName('nopages') as fname: with TiffWriter(fname) as tif: pass with TiffFile(fname) as tif: assert len(tif.pages) == 0 tif.asarray() if not SKIP_VALIDATE: with pytes...
def test_write_nopages():
"""Test write TIFF with no pages.""" with TempFileName('nopages') as fname: with TiffWriter(fname) as tif: pass with TiffFile(fname) as tif: assert len(tif.pages) == 0 tif.asarray() if not SKIP_VALIDATE: with pytest.raises(ValueError): ...
zarr_method(tif.series[0], array) assert_aszarr_method(tif.series[1], array) assert_aszarr_method(tif.series[2], [100.0]) # assert_aszarr_method(tif.series[3], []) def test_write_nopages():
63
64
87
7
56
bioturing/tifffile
tests/test_tifffile.py
Python
test_write_nopages
test_write_nopages
10,016
10,026
10,016
10,016
b0b4db9580ce17a666d223b14671ad62295a9e13
bigcode/the-stack
train
259fbfed418be50b5b3af287
train
function
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_depend_czi2tif_airy(): """Test czifile.czi2tif with AiryScan.""" from czifile.czifile import czi2tif fname = private_file('CZI/AiryscanSRChannel.czi') with TempFileName('czi2tif_airy') as tif: czi2tif(fname, tif, verbose=Tr...
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_depend_czi2tif_airy():
"""Test czifile.czi2tif with AiryScan.""" from czifile.czifile import czi2tif fname = private_file('CZI/AiryscanSRChannel.czi') with TempFileName('czi2tif_airy') as tif: czi2tif(fname, tif, verbose=True, truncate=True, bigtiff=False) im = memmap(tif) assert im.shape == (32, 6, 1...
assert t.pages[0].description == metadata assert_array_equal(im, data) del im del data assert_valid_tiff(tif) @pytest.mark.skipif(SKIP_PRIVATE or SKIP_LARGE, reason=REASON) def test_depend_czi2tif_airy():
64
64
190
29
35
bioturing/tifffile
tests/test_tifffile.py
Python
test_depend_czi2tif_airy
test_depend_czi2tif_airy
14,307
14,319
14,307
14,308
296bdbab7ee45e979302050300eaa54a4a96572c
bigcode/the-stack
train
49eb3a0be7176873d4b2784f
train
function
@pytest.mark.parametrize('bigtiff', [False, True]) @pytest.mark.parametrize('byteorder', ['<', '>']) def test_class_tifftag_overwrite(bigtiff, byteorder): """Test TiffTag.overwrite method.""" data = numpy.ones((16, 16, 3), dtype=byteorder + 'i2') bt = '_bigtiff' if bigtiff else '' bo = 'be' if byteorder...
@pytest.mark.parametrize('bigtiff', [False, True]) @pytest.mark.parametrize('byteorder', ['<', '>']) def test_class_tifftag_overwrite(bigtiff, byteorder):
"""Test TiffTag.overwrite method.""" data = numpy.ones((16, 16, 3), dtype=byteorder + 'i2') bt = '_bigtiff' if bigtiff else '' bo = 'be' if byteorder == '>' else 'le' with TempFileName(f'class_tifftag_overwrite_{bo}{bt}') as fname: imwrite(fname, data, bigtiff=bigtiff, photometric=RGB, soft...
open and close all files twice for fh in handles: cache.open(fh) cache.open(fh) assert len(cache) == 6 for i, fh in enumerate(handles): assert not fh.closed assert cache.files[fh] == 2 if i else 3 # close files once for fh in handl...
256
256
949
40
216
bioturing/tifffile
tests/test_tifffile.py
Python
test_class_tifftag_overwrite
test_class_tifftag_overwrite
1,783
1,878
1,783
1,785
20f087f4d000b756eac1cb37856c69dea4e2836e
bigcode/the-stack
train
56989bc6473caaf94b169552
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_fluoview_lsp1_v_laser(): """Test read FluoView CTYX.""" # raises 'UnicodeWarning: Unicode equal comparison failed' on Python 2 fname = private_file('fluoview/lsp1-V-laser0.3-1.tif') with TiffFile(fname) as tif: assert tif.byteorder =...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_fluoview_lsp1_v_laser():
"""Test read FluoView CTYX.""" # raises 'UnicodeWarning: Unicode equal comparison failed' on Python 2 fname = private_file('fluoview/lsp1-V-laser0.3-1.tif') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 100 assert len(tif.series) == 1 a...
# assert series properties series = tif.series[0] assert series.offset is None # not contiguous assert series.shape == (2, 4, 6, 1040, 1392) assert series.dtype == numpy.uint16 assert series.axes == 'TZCYX' # assert ImageJ tags ijtags = tif.imagej_metadata ...
135
135
452
27
108
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_fluoview_lsp1_v_laser
test_read_fluoview_lsp1_v_laser
8,696
8,735
8,696
8,697
7833299327271bfdb85675b9a571f3623da59d32
bigcode/the-stack
train
3851774922fb4deea36769f6
train
function
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_mediacy_imagepro(): """Test read Media Cybernetics SEQ.""" # TZYX, uint16, OME multifile TIFF fname = private_file('mediacy/imagepro.tif') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 1 ...
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON) def test_read_mediacy_imagepro():
"""Test read Media Cybernetics SEQ.""" # TZYX, uint16, OME multifile TIFF fname = private_file('mediacy/imagepro.tif') with TiffFile(fname) as tif: assert tif.byteorder == '<' assert len(tif.pages) == 1 assert len(tif.series) == 1 # assert page properties page = t...
assert data.shape == (413, 1528) assert data.dtype == numpy.float32 assert round(abs(data[260, 740] - 399.1728515625), 7) == 0 assert_aszarr_method(series, data) assert_aszarr_method(series, data, chunkmode='page') assert__str__(tif) @pytest.mark.skipif(SKIP_PRIVATE, reason=REAS...
102
102
341
22
80
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_mediacy_imagepro
test_read_mediacy_imagepro
8,902
8,934
8,902
8,903
0a66ac1c068aa0fd2c41bc35170ca3b676909d45
bigcode/the-stack
train
2f01341e7ffef3eb8737906b
train
function
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_ome_multi_channel_time_series(): """Test read OME time-series of multi-channel images.""" # 3D (7 time points, 3 channels) fname = public_file( 'OME/bioformats-artificial/multi-channel-time-series.ome.tiff' ) with TiffFile(fname) ...
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON) def test_read_ome_multi_channel_time_series():
"""Test read OME time-series of multi-channel images.""" # 3D (7 time points, 3 channels) fname = public_file( 'OME/bioformats-artificial/multi-channel-time-series.ome.tiff' ) with TiffFile(fname) as tif: assert tif.is_ome assert tif.byteorder == '>' assert len(tif.pa...
1) assert series.get_axes(False) == 'TCZYXS' assert not series.is_multifile # assert data data = tif.asarray() assert isinstance(data, numpy.ndarray) assert data.shape == (7, 167, 439) assert data.dtype == numpy.int8 assert data[6, 158, 428] == 91 ...
125
125
417
23
102
bioturing/tifffile
tests/test_tifffile.py
Python
test_read_ome_multi_channel_time_series
test_read_ome_multi_channel_time_series
7,245
7,284
7,245
7,246
37b44ce012fc70d7fe9131fe9773a67faca82242
bigcode/the-stack
train