create_trisurf raises an IndexError exception when one triangle's average height is very close to max height
オープン
まだ誰も着手していません。
bug
P3
- 主要言語
- Python
- スター
- 18.8k
- フォーク
- 2.8k
- 平均マージ
- 16時間 26分
- マージ済み PR(30日)
- 21
説明
When giving plotly.figure_factory.create_trisurf values where on triangle on the surface is very close to the maximum the function raises an IndexError. I'd expect a pretty plot instead.
Reproduction:
Python 3.6.9 (default, Jan 26 2021, 15:33:00)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import plotly
>>> import plotly.figure_factory as ff
>>> import numpy as np
>>> plotly.__version__
'5.1.0'
>>> vmin, vmax = -0.8, 0.2
>>> face = np.nextafter(vmax, -vmax) # the last value less than vmax
>>> # define a simple shape which includes 3 triangles of constant value vmin, vmax and face
...
>>> x = [0.0, 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0]
>>> y = [1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0]
>>> z = [vmin, vmin, vmin, face, face, face, vmax, vmax, vmax]
>>> simplices = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8]]
>>> ff.create_trisurf(x, y, z, simplices)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/.local/lib/python3.6/site-packages/plotly/figure_factory/_trisurf.py", line 488, in create_trisurf
plot_edges=plot_edges,
File "/home/user/.local/lib/python3.6/site-packages/plotly/figure_factory/_trisurf.py", line 153, in trisurf
mean_dists[index], colormap, scale, min_mean_dists, max_mean_dists
File "/home/user/.local/lib/python3.6/site-packages/plotly/figure_factory/_trisurf.py", line 48, in map_face2color
colormap[low_color_index + 1],
IndexError: list index out of range
Also attached a file does the same thing, as a .txt file instead of .py because that's what github supports in this context.
plotly_trisurf_indexerror.txt
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
plotly/figure_factory/_trisurf.py から始め、特に map_face2color を確認してください。そこでは traceback が colormap への範囲外アクセスを報告しています。提供された Python と NumPy の再現コードを実行し、その後、create_trisurf が IndexError を発生させるのではなく正常に完了してプロットを生成することを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- numpy, python
- 領域
- data-visualization
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 52/100