Skip to content

Commit

Permalink
numpy and json error found
Browse files Browse the repository at this point in the history
  • Loading branch information
konstntokas committed Aug 7, 2024
1 parent f6a816b commit e22ccdc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions xcube/util/cmaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,11 @@ def parse_cm_code(cm_code: str) -> tuple[str, Optional[Colormap]]:
cm_base_name, _, _ = parse_cm_name(cm_name)
n = len(cm_items)
if cm_type == "categorical":
values: list[float] = []
values: list[int] = []
colors: list[Union[str, tuple[float, ...]]] = []
bad = 0, 0, 0, 0
for i, (value, color) in enumerate(cm_items):
key = float(value)
key = int(value)
values.append(key)
colors.append(color)
if i == n - 1:
Expand Down Expand Up @@ -646,8 +646,7 @@ def create_colormap_from_config(cmap_config: dict) -> Colormap:
if "Label" in color:
labels.append(color["Label"])

for i, [value, color] in enumerate(colors):
colors[i][0] = float(value)
for i, [_, color] in enumerate(colors):
if isinstance(color, list):
if any([val > 1 for val in color]):
colors[i][1] = list(np.array(color) / 255)
Expand Down
4 changes: 2 additions & 2 deletions xcube/webapi/datasets/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,8 @@ def _get_cm_styles(self) -> tuple[dict[str, Any], ColormapRegistry]:
color_mappings[var_name] = {
"ColorBar": custom_colormap.cm_name,
"ValueRange": (
np.min(custom_colormap.values),
np.max(custom_colormap.values),
min(custom_colormap.values),
max(custom_colormap.values),
),
}
else:
Expand Down

0 comments on commit e22ccdc

Please sign in to comment.