Skip to content

[BUG] apply_categorical_cmap does not work with boolean data #1122

Description

@sgvandijk

Context

I have a dataset with a column with boolean data. I want to show that on a map, colored by whether the boolean field is true or false, using apply_categorical_cmap. A stripped down example:

import numpy as np
from lonboard.colormap import apply_categorical_cmap

values = np.array([True, False])
get_color = apply_categorical_cmap(values, {False: [255, 0, 0], True: [0, 255, 0]})

Resulting error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/snipped/.venv/lib/python3.12/site-packages/lonboard/colormap.py", line 207, in apply_categorical_cmap
    values = ChunkedArray(dictionary_encode(values))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Exception: C Data interface error: C Data interface error: Compute error: Boolean not supported in rank

Environment

  • OS: Arch Linux
  • Lonboard Version: 0.14.0

It is not a big problem to cast the data to integer 0/1 first, but just thought I'd report it as it would be nice if it works out of the box :).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions