diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 49d69131..0dc7aeee 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -26,7 +26,7 @@ jobs: - name: Test formatting uses: psf/black@stable with: - version: "21.7b0" + version: "22.3.0" - name: PEP8 rules uses: tonybajan/flake8-check-action@v1.0.0 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5c289686..f832e238 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: 'https://github.com/psf/black' - rev: 21.7b0 + rev: 22.3.0 hooks: - id: black stages: [commit] diff --git a/sepal_ui/mapping/mapping.py b/sepal_ui/mapping/mapping.py index 1dae10f3..6c0f1639 100644 --- a/sepal_ui/mapping/mapping.py +++ b/sepal_ui/mapping/mapping.py @@ -29,6 +29,7 @@ WidgetControl, ZoomControl, ) +from rasterio.crs import CRS from traitlets import Bool, link, observe import ipyvuetify as v import ipyleaflet @@ -405,6 +406,11 @@ def add_raster( # That will also improve performances as the generation of a tile can be done in parallel using Dask. da = da.chunk((1000, 1000)) + # unproject if necessary + epsg_4326 = "EPSG:4326" + if da.rio.crs != CRS.from_string(epsg_4326): + da = da.rio.reproject(epsg_4326) + # Create a named tuple with raster bounds and resolution local_raster = collections.namedtuple( "LocalRaster", @@ -625,7 +631,7 @@ def addLayer( inverted = vis_params.pop("inverted", None) if inverted is not None: - # get the index of the bands taht need to be inverted + # get the index of the bands that need to be inverted index_list = [i for i, v in enumerate(inverted) if v is True] # multiply everything by -1 diff --git a/sepal_ui/scripts/utils.py b/sepal_ui/scripts/utils.py index 2cd55df9..d3f0fe85 100644 --- a/sepal_ui/scripts/utils.py +++ b/sepal_ui/scripts/utils.py @@ -139,7 +139,7 @@ def get_file_size(filename): size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB") i = int(math.floor(math.log(file_size, 1024))) - s = file_size / (1024 ** i) + s = file_size / (1024**i) return "{:.1f} {}".format(s, size_name[i]) diff --git a/tests/test_utils.py b/tests/test_utils.py index 05136ab4..4a0ce8b8 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -102,7 +102,7 @@ def test_get_file_size(self): # mock every pow of 1024 to YB for i in range(9): with patch("pathlib.Path.stat") as stat: - stat.return_value.st_size = test_value * (1024 ** i) + stat.return_value.st_size = test_value * (1024**i) txt = su.get_file_size("random") assert txt == f"7.5 {size_name[i]}"