trollimage.tests package
Submodules
trollimage.tests.test_colormap module
Test colormap.py.
- class trollimage.tests.test_colormap.TestColormap
Bases:
object
Pytest tests for colormap objects.
- test_add()
Test adding colormaps.
- test_bad_color_dims()
Test passing colors that aren’t RGB or RGBA.
- test_colorbar(category)
Test colorbar.
- test_colorize_dask_with_interpolation()
Test colorize dask arrays.
- test_colorize_no_interpolation(input_cmap_func, expected_result)
Test colorize.
- test_colorize_with_interpolation(input_cmap_func, expected_result)
Test colorize where data values require interpolation between colors.
- test_colorize_with_large_hue_jumps(reverse)
Test colorize with a colormap that has large hue transitions.
- test_diff_colors_values()
Test failure when colors and values have different number of elements.
- test_invert_set_range()
Test inverted set_range.
- test_merge_equal_values()
Test that merged colormaps can have equal values at the merge point.
- test_merge_monotonic_decreasing()
Test that merged colormaps can be monotonically decreasing.
- test_merge_nonmonotonic()
Test that merged colormaps must have monotonic values.
- test_merge_rgb_rgba(colors1, colors2)
Test that two colormaps with RGB or RGBA colors can be merged.
- test_nonfloat_colors()
Pass integer colors to colormap.
- test_only_colors_only_values()
Test passing only colors or only values keyword arguments.
- test_palettebar()
Test colorbar.
- test_palettize_edge_of_dtype_range()
Test palettize when bins span the entire dtype range.
- test_palettize_in_range(input_cmap_func, expected_result)
Test palettize with values inside the set range.
- test_palettize_mono_inc_in_range_dask()
Test palettize on a dask array.
- test_palettize_mono_inc_nan()
Test palettize with monotonic increasing values with a NaN.
- test_palettize_mono_inc_out_range()
Test palettize with a value outside the colormap values.
- test_reverse(inplace)
Test colormap reverse.
- test_set_alpha_range(new_range, inplace, colors_already_with_alpha)
Test ‘set_alpha_range’ method.
- test_set_range(new_range, inplace)
Test ‘set_range’ method.
- test_to_rgb(colors)
Test ‘to_rgb’ method.
- test_to_rgba(colors)
Test ‘to_rgba’ method.
- test_to_rio()
Test conversion to rasterio colormap.
- class trollimage.tests.test_colormap.TestFromFileCreation
Bases:
object
Tests for loading Colormaps from files.
- test_cmap_bad_mode(real_mode, forced_mode, filename_suffix)
Test that reading colormaps with the wrong mode fails.
- test_cmap_from_csv(tmp_path, color_scale)
Test creating a colormap from a CSV file.
- test_cmap_from_file(color_scale, colormap_mode, filename_suffix)
Test that colormaps can be loaded from a binary or CSV file.
- test_cmap_from_file_bad_shape()
Test that unknown array shape causes an error.
- test_cmap_from_np(tmp_path, color_scale)
Test creating a colormap from a numpy file.
- test_cmap_vrgb_as_rgba()
Test that data created as VRGB still reads as RGBA.
- test_csv_roundtrip(tmp_path, csv_filename, new_range, color_scale)
Test saving and loading a Colormap from a CSV file.
- trollimage.tests.test_colormap.closed_named_temp_file(**kwargs)
Named temporary file context manager that closes the file after creation.
This helps with Windows systems which can get upset with opening or deleting a file that is already open.
- trollimage.tests.test_colormap.test_build_colormap_with_float_data()
Test colormap building for float data.
- trollimage.tests.test_colormap.test_build_colormap_with_int_data_and_with_meanings()
Test colormap building.
- trollimage.tests.test_colormap.test_build_colormap_with_int_data_and_without_meanings()
Test colormap building from uint8 array with metadata.
- trollimage.tests.test_colormap.test_cmap_from_name()
Test creating a colormap from a string representing a name.
- trollimage.tests.test_colormap.test_cmap_from_ndarray(color_scale)
Test creating a colormap from a numpy array.
- trollimage.tests.test_colormap.test_cmap_from_sequence_of_colors()
Test creating a colormap from a sequence of colors.
- trollimage.tests.test_colormap.test_cmap_from_string()
Test creating a colormap from a string.
trollimage.tests.test_image module
Module for testing the image and xrimage modules.
- class trollimage.tests.test_image.TestEmptyImage(methodName='runTest')
Bases:
TestCase
Class for testing the mpop.imageo.image module.
- setUp()
Set up the test case.
- test_clip()
Clip an empty image.
- test_convert()
Convert an empty image.
- test_gamma()
Gamma correction on an empty image.
- test_invert()
Invert an empty image.
- test_is_empty()
Test if an image is empty.
- test_merge()
Merging of an empty image with another.
- test_pil_image()
Return an empty PIL image.
- test_putalpha()
Add an alpha channel to en empty image.
- test_replace_luminance()
Replace luminance in an empty image.
- test_resize()
Resize an empty image.
- test_save()
Save an empty image.
- test_shape()
Shape of an empty image.
- test_stretch()
Stretch an empty image.
- class trollimage.tests.test_image.TestFlatImage(methodName='runTest')
Bases:
TestCase
Test a flat image, ie an image where min == max.
- setUp()
Set up the test case.
- test_stretch()
Stretch a flat image.
- class trollimage.tests.test_image.TestImageColorize
Bases:
object
Test the colorize method of the Image class.
- test_colorize_la_rgb()
Test colorizing an LA image with an RGB colormap.
- class trollimage.tests.test_image.TestImageCreation(methodName='runTest')
Bases:
TestCase
Class for testing the mpop.imageo.image module.
- setUp()
Set up the test case.
- test_creation()
Test creation of an image.
- class trollimage.tests.test_image.TestNoDataImage(methodName='runTest')
Bases:
TestCase
Test an image filled with no data.
- setUp()
Set up the test case.
- test_stretch()
Stretch a no data image.
- class trollimage.tests.test_image.TestRegularImage(methodName='runTest')
Bases:
TestCase
Class for testing the image module.
- setUp()
Set up the test case.
- tearDown()
Clean up the mess.
- test_clip()
Clip an image.
- test_convert()
Convert an image.
- test_gamma()
Gamma correction on an image.
- test_invert()
Invert an image.
- test_is_empty()
Test if an image is empty.
- test_merge()
Merging of an image with another.
- test_pil_image()
Return an PIL image.
- test_putalpha()
Add an alpha channel.
- test_replace_luminance()
Replace luminance in an image.
- test_resize()
Resize an image.
- test_save()
Save an image.
- test_save_jpeg()
Save a jpeg image.
- test_shape()
Shape of an image.
- test_stretch()
Stretch an image.
- class trollimage.tests.test_image.TestXRImage
Bases:
object
Test XRImage objects.
- test_LA_save()
Test LA saving.
- test_L_save()
Test L saving.
- test_PA_save()
Test PA saving.
- test_P_save()
Test P saving.
- test_apply_pil()
Test the apply_pil method.
- test_blend(dtype)
Test blend.
- test_convert_modes()
Test modes convertions.
- test_crude_stretch(dtype)
Check crude stretching.
- test_crude_stretch_integer_data(dtype, max_stretch)
Test crude stretch with different input integer dtypes.
- test_crude_stretch_with_limits(dtype)
Test crude stretch with different input dtypes.
- test_delayed_save_geotiff_float_dask_array(tmp_path)
Test saving geotiffs when input data is float.
- test_final_mode()
Test final_mode.
- test_gamma_noop(gamma_val, dtype)
Test variety of unity gamma corrections.
- test_gamma_per_channel(dtype)
Test gamma correction with a value for each channel.
- test_gamma_single_value(dtype)
Test gamma correction for one value for all channels.
- test_gtiff_save()
Test saving to geotiff.
- test_histogram_stretch(dtype)
Test histogram stretching.
- test_init()
Test object initialization.
- test_init_writability()
Test data is writable after init.
Xarray >0.15 makes data read-only after expand_dims.
- test_invert_parameter_for_each_channel(dtype)
Check inversion of the image for single inversion parameter.
- test_invert_single_parameter(dtype)
Check inversion of the image for single inversion parameter.
- test_jpeg_save()
Test saving to jpeg.
- test_linear_stretch(dtype)
Test linear stretching with cutoffs.
- test_linear_stretch_does_affect_alpha_with_explicit_cutoffs(dtype)
Test linear stretching with full explicit cutoffs.
- test_linear_stretch_does_not_affect_alpha(dtype)
Test linear stretching with cutoffs.
- test_linear_stretch_does_not_affect_alpha_with_partial_cutoffs(dtype)
Test linear stretching with cutoffs.
- test_linear_stretch_integers(dtype, max_val, exp_min, exp_max)
Test linear stretch with low-bit unsigned integer data.
- test_logarithmic_stretch(min_stretch, max_stretch, base, dtype)
Test logarithmic strecthing.
- test_merge()
Test merge.
- test_putalpha()
Test putalpha.
- test_regression_double_format_save()
Test that double format information isn’t passed to save.
- test_replace_luminance()
Test luminance replacement.
- test_rgb_save()
Test saving RGB/A data to simple image formats.
- test_save_cloud_optimized_geotiff()
Test saving cloud optimized geotiffs.
- test_save_geotiff_closed_file()
Test saving geotiffs when the geotiff file has been closed.
This is to mimic a situation where garbage collection would cause the file handler to close the underlying geotiff file that will be written to.
- test_save_geotiff_datetime()
Test saving geotiffs when start_time is in the attributes.
- test_save_geotiff_delayed()
Test saving a geotiff but not computing the result immediately.
- test_save_geotiff_float_dask_array(tmp_path)
Test saving geotiffs when input data is float.
- test_save_geotiff_float_dask_array_to_float(tmp_path)
Test saving geotiffs when input data is float.
- test_save_geotiff_float_dask_array_to_float_with_nans_fill_value(tmp_path)
Test saving geotiffs when input data is float.
- test_save_geotiff_float_dask_array_to_float_with_numeric_fill_value(tmp_path)
Test saving geotiffs when input data is float.
- test_save_geotiff_float_dask_array_to_signed_int(tmp_path)
Test saving geotiffs when input data is float.
- test_save_geotiff_float_dask_array_with_alpha(tmp_path)
Test saving geotiffs when input data is float.
- test_save_geotiff_float_dask_array_with_nans(tmp_path)
Test saving geotiffs when input data is float.
- test_save_geotiff_float_dask_array_with_nans_and_fill_value(tmp_path)
Test saving geotiffs when input data is float.
- test_save_geotiff_float_numpy_array(tmp_path)
Test saving geotiffs when input data is float.
- test_save_geotiff_int(output_ext, use_dask)
Test saving geotiffs when input data is int.
- test_save_geotiff_int_gcps()
Test saving geotiffs when input data is int and has GCPs.
- test_save_geotiff_int_no_gcp_swath()
Test saving geotiffs when input data whose SwathDefinition has no GCPs.
If shouldn’t fail, but it also shouldn’t have a non-default transform.
- test_save_geotiff_int_rio_colormap()
Test saving geotiffs when input data is int and a rasterio colormap is provided.
- test_save_geotiff_int_with_area_def()
Test saving a integer image with an AreaDefinition.
- test_save_geotiff_int_with_bad_cmap()
Test saving integer data to geotiff with a bad colormap.
- test_save_geotiff_int_with_cmap(cmap)
Test saving integer data to geotiff with a colormap.
Rasterio specifically can’t handle colormaps that are not round integers. Unfortunately it only warns when it finds a value in the color table that it doesn’t expect. For example if an unsigned 8-bit color table is being filled with a trollimage Colormap where due to floating point one of the values is 15.0000001 instead of 15.0, rasterio will issue a warning and then not add a color for that value. This test makes sure the colormap written is the colormap read back.
- test_save_geotiff_int_with_fill()
Test saving geotiffs when input data is int and a fill value is specified.
- test_save_geotiff_int_with_fill_and_alpha()
Test saving int geotiffs with a fill value and input alpha band.
- test_save_geotiff_with_cmap_and_fill_value(tmp_path)
Test saving GeoTIFF with colormap and fill value.
- test_save_jp2_int()
Test saving jp2000 when input data is int.
- test_save_masked()
Test saving masked data.
- test_save_overviews()
Test saving geotiffs with overviews.
- test_save_palettes()
Test saving paletted images to simple image formats.
- test_save_single_band_jpeg()
Test saving single band to jpeg formats.
- test_save_single_band_png()
Test saving single band images to simple image formats.
- test_save_tags()
Test saving geotiffs with tags.
- test_show()
Test that the show commands calls PIL.show.
- test_stack()
Test stack.
- test_weber_fechner_stretch(dtype)
Test applying S=2.3klog10I+C to the data.
- class trollimage.tests.test_image.TestXRImageColorize
Bases:
object
Test the colorize method of the XRImage class.
- test_colorize_geotiff_tag(tmp_path, colormap_tag)
Test that a colorized colormap can be saved to a geotiff tag.
- test_colorize_int_l_rgb_with_fills()
Test integer data with _FillValue is masked (NaN) when colorized.
- test_colorize_l_rgb(new_range, input_scale, input_offset, expected_scale, expected_offset, dtype)
Test colorize with a RGB colormap.
- test_colorize_la_rgb()
Test colorizing an LA image with an RGB colormap.
- test_colorize_rgba()
Test colorize with an RGBA colormap.
- class trollimage.tests.test_image.TestXRImagePalettize
Bases:
object
Test the XRImage palettize method.
- test_palettize(new_range, input_scale, input_offset, expected_scale, expected_offset)
Test palettize with an RGB colormap.
- test_palettize_bad_fill_value()
Test that palettize warns with a strange fill value.
- test_palettize_fill_value()
Test that fill values are adapted.
- test_palettize_geotiff_tag(tmp_path, colormap_tag, keep_palette)
Test that a palettized image can be saved to a geotiff tag.
- test_palettize_rgba()
Test palettize with an RGBA colormap.
- class trollimage.tests.test_image.TestXRImageSaveScaleOffset
Bases:
object
Test case for saving an image with scale and offset tags.
- test_gamma_geotiff_scale_offset(tmp_path)
Test that saving gamma-enhanced data to a geotiff with scale/offset tags doesn’t fail.
- test_rgb_geotiff_scale_offset(tmp_path)
Test that saving RGB data to a geotiff with scale/offset tags doesn’t fail.
- test_save_scale_offset()
Test saving geotiffs with tags.
- test_save_scale_offset_custom_labels()
Test saving GeoTIFF with different scale/offset tag labels.
- test_save_scale_offset_custom_values()
Test saving GeoTIFF overriding the scale/offset values.
- test_save_scale_offset_from_lists()
Test saving geotiffs with tags that come from lists.
- trollimage.tests.test_image.random_string(length, choices='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
Generate a random string with elements from set of the specified length.
trollimage.tests.utils module
Helper classes and functions for running and writing tests.
- class trollimage.tests.utils.CustomScheduler(max_computes=1)
Bases:
object
Scheduler raising an exception if data are computed too many times.
- trollimage.tests.utils.assert_maximum_dask_computes(max_computes=1)
Context manager to make sure dask computations are not executed more than
max_computes
times.
Module contents
The tests package.