assert_raster_almost_equal_magnitude#
- assert_raster_almost_equal_magnitude(path_1: str | CloudPath | Path, path_2: str | CloudPath | Path, decimal=2) None [source]#
Assert that two rasters are almost equal, with the decimal taken on the scientif representation of the array. (everything is equal except the transform and the arrays that are almost equal)
Accepts an offset of
1E{decimal}
on the array divided by the order of magnitude of the array and a precision of 10^-{decimal} on the transformi.e. decimal=2, mean(array) = 15.2, true = 13.2687, false = 13.977, comparison: 1.32687, false <-> 1.3977 => false (2 != 9)
Useful for pytests.
- Parameters:
path_1 (AnyPathStrType) – Raster 1
path_2 (AnyPathStrType) – Raster 2
decimal (int) – Number of decimal
Example
>>> path = r"CI/DATA/rasters/raster.tif" >>> path2 = r"CI/DATA/rasters/raster_almost.tif" >>> assert_raster_almost_equal_magnitude(path, path2) >>> # Raises AssertionError if sth goes wrong