Best Python code snippet using hypothesis
test_write.py
Source:test_write.py
...22 data = handle[:]23 assert np.all(img == data[:, :, :3])24# scanline integer tests25@settings(buffer_size=11000000)26@given(data=hnp.arrays(dtype=st.one_of(hnp.integer_dtypes(endianness="="), hnp.unsigned_integer_dtypes(endianness="=")),27 shape=hnp.array_shapes(min_dims=2, max_dims=2, min_side=10, max_side=50)))28def test_write_int_scanline(data, tmpdir_factory):29 filename = str(tmpdir_factory.mktemp("write").join("int_img.tif"))30 with Tiff(filename, "w") as handle:31 handle.write(data, method="scanline")32 with tifffile.TiffFile(filename) as handle:33 img = handle.asarray()34 np.testing.assert_array_equal(data, img)35@settings(buffer_size=11000000)36@given(data=hnp.arrays(dtype=st.one_of(hnp.integer_dtypes(endianness="="), hnp.unsigned_integer_dtypes(endianness="=")),37 shape=hnp.array_shapes(min_dims=2, max_dims=2, min_side=10, max_side=50)))38def test_write_int_scanline_set_rows_per_strip(data, tmpdir_factory):39 filename = str(tmpdir_factory.mktemp("write").join("int_img.tif"))40 rows_per_strip = 141 with Tiff(filename, "w") as handle:42 handle.write(data, method="scanline", rows_per_strip=rows_per_strip)43 with tifffile.TiffFile(filename) as handle:44 img = handle.asarray()45 np.testing.assert_array_equal(data, img)46 assert rows_per_strip == handle[0].tags["rows_per_strip"].value47@settings(buffer_size=11000000)48@given(data=hnp.arrays(dtype=st.one_of(hnp.integer_dtypes(endianness="="), hnp.unsigned_integer_dtypes(endianness="=")),49 shape=hnp.array_shapes(min_dims=2, max_dims=2, min_side=20, max_side=20)))50def test_write_int_slices_scanline(data, tmpdir_factory):51 filename = str(tmpdir_factory.mktemp("write").join("int_img_scanline.tif"))52 with Tiff(filename, "w") as handle:53 handle.write(data[:, :], method="scanline")54 with tifffile.TiffFile(filename) as handle:55 img = handle.asarray()56 np.testing.assert_array_equal(data[:,:], img)57# tile integer tests58@settings(buffer_size=11000000)59@given(data=hnp.arrays(dtype=st.one_of(hnp.integer_dtypes(endianness="="), hnp.unsigned_integer_dtypes(endianness="=")),60 shape=hnp.array_shapes(min_dims=2, max_dims=2, min_side=10, max_side=50)))61def test_write_int_tile(data, tmpdir_factory):62 filename = str(tmpdir_factory.mktemp("write").join("int_tile_img.tif"))63 with Tiff(filename, "w") as handle:64 handle.write(data, method="tile", tile_width=16, tile_length=16)65 with tifffile.TiffFile(filename) as handle:66 img = handle.asarray()67 np.testing.assert_array_equal(data, img)68@settings(buffer_size=11000000)69@given(data=hnp.arrays(dtype=hnp.floating_dtypes(endianness="="),70 shape=hnp.array_shapes(min_dims=2, max_dims=2, min_side=10, max_side=50), elements=st.floats(0, 1)))71def test_write_float_scanline(data, tmpdir_factory):72 filename = str(tmpdir_factory.mktemp("write").join("float_img.tif"))73 with Tiff(filename, "w") as handle:74 handle.write(data, method="scanline")75 with tifffile.TiffFile(filename) as handle:76 img = handle.asarray()77 np.testing.assert_array_equal(data, img)78@settings(buffer_size=11000000)79@given(data=hnp.arrays(dtype=hnp.floating_dtypes(endianness="="),80 shape=hnp.array_shapes(min_dims=2, max_dims=2, min_side=10, max_side=50), elements=st.floats(0, 1)))81def test_write_float_tile(data, tmpdir_factory):82 filename = str(tmpdir_factory.mktemp("write").join("float_tile_img.tif"))83 with Tiff(filename, "w") as handle:84 handle.write(data, method="tile", tile_length=16, tile_width=16)85 with tifffile.TiffFile(filename) as handle:86 img = handle.asarray()87 np.testing.assert_array_equal(data, img)88@settings(buffer_size=11000000)89@given(data=hnp.arrays(dtype=st.one_of(hnp.integer_dtypes(endianness="="), hnp.unsigned_integer_dtypes(endianness="=")),90 shape=hnp.array_shapes(min_dims=2, max_dims=2, min_side=10, max_side=50)))91def test_append_int_tile(data, tmpdir_factory):92 filename = str(tmpdir_factory.mktemp("write").join("append_img.tif"))93 with Tiff(filename, "w") as handle:94 handle.write(data, method="tile", tile_width=16, tile_length=16)95 with Tiff(filename, "a") as handle:96 handle.write(data, method="tile", tile_width=16, tile_length=16)97 with Tiff(filename, "r") as handle:98 assert handle.number_of_pages == 299 with tifffile.TiffFile(filename) as handle:100 img = handle.asarray()101 np.testing.assert_array_equal(data, img[0])102 np.testing.assert_array_equal(data, img[1])103def test_write_chunk(tmpdir_factory):...
test_pretty.py
Source:test_pretty.py
...33 ("scalar_dtypes", scalar_dtypes(xp)),34 ("boolean_dtypes", boolean_dtypes(xp)),35 ("numeric_dtypes", numeric_dtypes(xp)),36 ("integer_dtypes", integer_dtypes(xp)),37 ("unsigned_integer_dtypes", unsigned_integer_dtypes(xp)),38 ("floating_dtypes", floating_dtypes(xp)),39 # Namespaced strategies40 ("from_dtype", xps.from_dtype(xp.int8)),41 ("arrays", xps.arrays(xp.int8, 5)),42 ("scalar_dtypes", xps.scalar_dtypes()),43 ("boolean_dtypes", xps.boolean_dtypes()),44 ("numeric_dtypes", xps.numeric_dtypes()),45 ("integer_dtypes", xps.integer_dtypes()),46 ("unsigned_integer_dtypes", xps.unsigned_integer_dtypes()),47 ("floating_dtypes", xps.floating_dtypes()),48 ]49)50def test_xp_strategies_pretty_repr(name, strat):51 """Strategies that take xp use its __name__ for their own repr."""52 assert repr(strat).startswith(name), f"{name} not in strat repr"53 assert len(repr(strat)) < 100, "strat repr looks too long"...
strategies.py
Source:strategies.py
...3 unsigned_integer_dtypes)4from rasterio import check_dtype5st_rasterio_dtypes = st.one_of(6 integer_dtypes(),7 unsigned_integer_dtypes(),8 floating_dtypes(),...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!