From 54be7dc33fc0eb7049f5fff8f426e09888389401 Mon Sep 17 00:00:00 2001 From: Bane Sullivan Date: Thu, 12 Sep 2024 22:58:15 -0700 Subject: [PATCH] Linting --- localtileserver/client.py | 7 +++---- localtileserver/tiler/handler.py | 7 ++++--- localtileserver/widgets.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/localtileserver/client.py b/localtileserver/client.py index 7a8fe88..084feba 100644 --- a/localtileserver/client.py +++ b/localtileserver/client.py @@ -1,9 +1,10 @@ from collections.abc import Iterable +import json import logging import pathlib from typing import List, Optional, Union -from matplotlib.colors import Colormap +from matplotlib.colors import Colormap import rasterio import requests from rio_tiler.io import Reader @@ -442,16 +443,14 @@ def get_tile_url( The value from the band to use to interpret as not valid data. """ - import json # First handle query parameters to check for errors params = {} if indexes is not None: params["indexes"] = indexes if colormap is not None: - if isinstance(colormap, Colormap): colormap = json.dumps( - {k:tuple(v.tolist()) for k,v in enumerate(colormap(range(256),1,1))} + {k: tuple(v.tolist()) for k, v in enumerate(colormap(range(256), 1, 1))} ) elif isinstance(colormap, list): colormap = json.dumps(colormap) diff --git a/localtileserver/tiler/handler.py b/localtileserver/tiler/handler.py index f8f7d94..94f3912 100644 --- a/localtileserver/tiler/handler.py +++ b/localtileserver/tiler/handler.py @@ -151,6 +151,7 @@ def _render_image( img_format: str = "PNG", ): import json + from matplotlib.colors import LinearSegmentedColormap if colormap in cmap.list(): @@ -158,11 +159,11 @@ def _render_image( elif colormap: c = json.loads(colormap) if isinstance(c, list): - c = LinearSegmentedColormap.from_list('', c, N=256) - colormap = {k:tuple(v) for k,v in enumerate(c(range(256),1,1))} + c = LinearSegmentedColormap.from_list("", c, N=256) + colormap = {k: tuple(v) for k, v in enumerate(c(range(256), 1, 1))} else: colormap = {} - for key,value in c.items(): + for key, value in c.items(): colormap[int(key)] = tuple(value) if ( diff --git a/localtileserver/widgets.py b/localtileserver/widgets.py index 23d7e77..b33a1b3 100644 --- a/localtileserver/widgets.py +++ b/localtileserver/widgets.py @@ -1,9 +1,9 @@ import logging import pathlib from typing import List, Optional, Union -from matplotlib.colors import Colormap import warnings +from matplotlib.colors import Colormap import rasterio from localtileserver.client import TileClient, get_or_create_tile_client