Thanks to visit codestin.com
Credit goes to github.com

Skip to content

rr.TimeColumn doesn't support numpy array with epoch second timestamps #10167

@MichaelGrupp

Description

@MichaelGrupp

I tried to log a batch of data with timestamps that are stored as plain seconds since Unix epoch in a numpy array.
According to the TimeColumn documentation, I expected that this should be supported:

        timestamp:
            Used for absolute time indices, like `capture_time`.
            Must either be in seconds since Unix epoch, [`datetime.datetime`][], or [`numpy.datetime64`][].

Logging succeeded but the timeline in the viewer was completely wrong.

Looking at the code, it turns out that TimeColumn.__init__() implicitly assumes any np.ndarray passed as timestamp to have a datetime dtype. This effectively means your seconds array will be interpreted as nanoseconds.

Note: the duration kwarg works with numeric arrays as advertised, there is a conversion.

Workaround: convert numpy array to list

rr.TimeColumn("time", timestamp=list(timestamps)))

Proposed fix: convert the array, similar to what is done for duration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    sdk-pythonPython logging API🪳 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions