plotly / plotly/plotly.py

create_trisurf raises an IndexError exception when one triangle's average height is very close to max height

Đang mở
#3,323 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

bug P3
Ngôn ngữ chính
Python
Star
18.8k
Fork
2.8k
Merge trung bình
16 giờ 26 phút
Pull request đã merge (30 ngày)
21

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu trong plotly/figure_factory/_trisurf.py, đặc biệt là tại map_face2color, nơi traceback báo cáo việc truy cập colormap vượt quá phạm vi. Chạy bản tái hiện được cung cấp bằng Python và NumPy, sau đó xác minh rằng create_trisurf hoàn tất và tạo ra một biểu đồ thay vì phát sinh IndexError.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
numpy, python
Lĩnh vực
data-visualization
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
52/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.