plotly / plotly/plotly.py

go.Scatter3d doesn't display a given tensor

Offen
#4,507 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug P3 sev-2
Vorherrschende Sprache
Python
Sterne
18.8k
Forks
2.8k
Ø Merge
16 Std. 26 Min.
Gemergte PRs (30 T.)
21

Beschreibung

Issue

While plotting an np.ndarray of type fp64, it is not displayed.
It is so funny that we could reproduce it only for one specific array.

Thigs that make the script work:

  • If we add epsilon (as in the commented line), then the pointcloud is displayed properly.
  • If we cast to fp32 it works.
  • If we add a small value (0.000000000001 for example), it works.

Things that doesn't work:

  • If we add or substract big values, like 0.4, 1 or 2, it doesn't work
  • If we substract epsilon, it doesn't work
  • if we add numbers larger than 0.000000000001, it doesnt' work even if tehy are small (0.000001 for example)

Environment

We tried this (and reproduced in at least 2 computers) with numpy 1.26.3 and plotly 5.18.0 on ubuntu 22

import numpy as np
import plotly.graph_objects as go

init = np.array(
    [
        [
            -0.063,
            -0.063,
            0.0,
        ],
        [
            -0.063,
            -0.021,
            0.0,
        ],
        [
            -0.063,
            0.021,
            0.0,
        ],
        [
            -0.063,
            0.063,
            0.0,
        ],
        [
            -0.021,
            -0.021,
            0.0,
        ],
        [
            -0.021,
            -0.063,
            0.0,
        ],
        [
            -0.021,
            0.021,
            0.0,
        ],
        [
            -0.021,
            0.063,
            0.0,
        ],
        [
            0.021,
            -0.063,
            0.0,
        ],
        [
            0.021,
            -0.021,
            0.0,
        ],
        [
            0.021,
            0.021,
            0.0,
        ],
        [
            0.021,
            0.063,
            0.0,
        ],
        [
            0.063,
            -0.063,
            0.0,
        ],
        [
            0.063,
            -0.021,
            0.0,
        ],
        [
            0.063,
            0.021,
            0.0,
        ],
        [
            0.063,
            0.063,
            0.0,
        ],
    ]
)

rot_mat = [
    [4.93038066e-32, -1.00000000e00, 2.22044605e-16],
    [2.22044605e-16, 2.22044605e-16, 1.00000000e00],
    [-1.00000000e00, 0.00000000e00, 2.22044605e-16],
]

transformed = (rot_mat @ init.T).T + np.array([0.5, 0.5, 0.5])


x, y, z = 0, 1, 2
idx = list(transformed.shape).index(3)
if idx < 0:
    raise ValueError("Array must be [X,Y,Z] x N")
elif idx == 1:
    array = transformed.transpose()

default_kwargs = dict(
    mode="markers",
    marker=dict(size=3, color="black"),
)

print(array.dtype)

# array[y]+=np.finfo(np.float64).eps
print(array.dtype)
print(array)
plot = go.Scatter3d(x=array[x], y=array[y], z=array[z], **default_kwargs)

default_kwargs = dict(
    scene=dict(
        xaxis=dict(title="X", range=[0, 2]),
        yaxis=dict(title="Y", range=[0, 2]),
        zaxis=dict(title="Z", range=[0, 2]),
    ),
)
layout = go.Layout(**default_kwargs)

fig = go.Figure(data=plot, layout=layout)

fig.show()

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Verwende das bereitgestellte Reproduktionsskript als Einstiegspunkt und führe es mit numpy 1.26.3 und plotly 5.18.0 auf Ubuntu 22 aus. Vergleiche das fehlschlagende fp64-Array mit den funktionierenden epsilon- und fp32-Varianten und verfolge anschließend den go.Scatter3d-Renderingpfad. Als erledigt gilt die Aufgabe, wenn die Ursache identifiziert und eine Regression-Prüfung hinzugefügt wurde, die zeigt, dass der angegebene Tensor angezeigt wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
numpy, plotly, python
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.