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(),...
Check out the latest blogs from LambdaTest on this topic:
Before we discuss the Joomla testing, let us understand the fundamentals of Joomla and how this content management system allows you to create and maintain web-based applications or websites without having to write and implement complex coding requirements.
In today’s world, an organization’s most valuable resource is its customers. However, acquiring new customers in an increasingly competitive marketplace can be challenging while maintaining a strong bond with existing clients. Implementing a customer relationship management (CRM) system will allow your organization to keep track of important customer information. This will enable you to market your services and products to these customers better.
How do we acquire knowledge? This is one of the seemingly basic but critical questions you and your team members must ask and consider. We are experts; therefore, we understand why we study and what we should learn. However, many of us do not give enough thought to how we learn.
Testing is a critical step in any web application development process. However, it can be an overwhelming task if you don’t have the right tools and expertise. A large percentage of websites still launch with errors that frustrate users and negatively affect the overall success of the site. When a website faces failure after launch, it costs time and money to fix.
Mobile application development is on the rise like never before, and it proportionally invites the need to perform thorough testing with the right mobile testing strategies. The strategies majorly involve the usage of various mobile automation testing tools. Mobile testing tools help businesses automate their application testing and cut down the extra cost, time, and chances of human error.
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!!