Skip to content

log_{line_segments,point} fails when color is a numpy array #2486

@roym899

Description

@roym899

Describe the bug

import rerun as rr
import numpy as np
rr.log_line_segments("points", [0.0, 0.0], color=np.array([0.5, 0.5, 0.5]))

fails with the following warning

WARNING:root:Ignoring rerun log call: Traceback (most recent call last):
  File "/home/leo/.pyenv/versions/widebaseline/lib/python3.10/site-packages/rerun_sdk/rerun/log/log_decorator.py", line 47, in wrapper
    return func(*args, **kwargs)
  File "/home/leo/.pyenv/versions/widebaseline/lib/python3.10/site-packages/rerun_sdk/rerun/log/lines.py", line 208, in log_line_segments
    if color:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

The boolean value of a numpy array with more than one value is not defined and is also False for scalar arrays with 0 value. This can most likely be fixed by changing if color: to if color is not None:. Maybe worth checking if similar code is anywhere else in the codebase.

A workaround is to convert the color to a list first.

Desktop (please complete the following information):

  • OS: Ubuntu 20.04

Rerun version

rerun_py 0.7.0 [rustc 1.69.0 (84c898d65 2023-04-16), LLVM 15.0.7] x86_64-unknown-linux-gnu prepare-0.7 9cf3033, built 2023-06-16T15:47:32Z

Metadata

Metadata

Assignees

Labels

sdk-pythonPython logging API🏎️ Quick IssueCan be fixed in a few hours or less🪳 bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions