plotly / plotly/plotly.py

go.Scatter3d doesn't display a given tensor

オープン
#4,507 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P3 sev-2
主要言語
Python
スター
18.8k
フォーク
2.8k
平均マージ
16時間 26分
マージ済み PR(30日)
21

説明

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()

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

提供された再現スクリプトを入口として使用し、Ubuntu 22 上で numpy 1.26.3 と plotly 5.18.0 を使って実行してください。失敗する fp64 配列と、動作する epsilon および fp32 のバリアントを比較し、その後 go.Scatter3d のレンダリングパスを追跡してください。原因を特定し、指定されたテンソルが表示されることを示す回帰チェックを追加できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
numpy, plotly, python
領域
data-visualization
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。