Inspector `nanmean` divides by the wrong count
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 86/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- data-visualization
Hướng nghiên cứu
Cả hai trường hợp đều nằm trong plotting/_inspector.py: kiểm tra giá trị trung bình của hình chữ nhật quanh dòng 90–91 và giá trị trung bình của đa giác quanh dòng 128. So sánh mẫu số với các bin được tính vào từng tử số, đồng thời tính đến các bin bị mask và chiều được lập hồ sơ. Tái hiện các ví dụ hình chữ nhật và đa giác đã cung cấp; hoàn thành khi nanmean trả về 1 cho cả hai, còn sum, nansum và cách hoạt động hiện có của mean vẫn chính xác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Both cases are in plotting/_inspector.py, in the mean computed by hand
(the workaround for scipp#3841):
- Rectangle (lines 90–91): the numerator
out.nansum(dims)skips
masked bins, but the denominator(~sc.isnan(out.data)).sum(dims)
counts them. A region that includes a mask comes out too low. - Polygon (line 128):
(inside & non_nan).sum()sums over all
dimensions, including the profiled one, so the result is too small by a
factor of that dimension's length, even with no masks or NaNs. It also
counts masked bins.
import numpy as np, scipp as sc
from plopp.plotting._inspector import _mask_outside_polygon, _slice_rectangular_region
da = sc.DataArray(sc.ones(dims=['x', 'y', 'z'], shape=[4, 3, 5]),
coords={d: sc.arange(d, float(n)) for d, n in zip('xyz', (4, 3, 5))})
plain = da.copy()
da.masks['m'] = sc.array(dims=['x'], values=[True, False, False, False])
box = {d: {'dim': d, 'value': sc.array(dims=['p'], values=[-1.0, 9.0])} for d in 'xy'}
print(_slice_rectangular_region(da, box, 'nanmean').values) # 0.75, expected 1
sizes = {'x': 4, 'y': 3}
pts = np.column_stack([sc.broadcast(plain.coords[d], sizes=sizes).values.ravel() for d in 'xy'])
poly = {'x': {'value': sc.array(dims=['v'], values=[-1.0, 9.0, 9.0, -1.0])},
'y': {'value': sc.array(dims=['v'], values=[-1.0, -1.0, 9.0, 9.0])}}
print(_mask_outside_polygon(plain, poly, points=pts, sizes=sizes, op='nanmean',
non_nan=~sc.isnan(plain.data)).values) # 0.2, expected 1
(These are the arguments inspector passes.) sum and nansum are
correct. With mean, the polygon is right when nothing is masked, but
both shapes count masked bins.
Suggestion: count only the bins the numerator sums, i.e. leave out masked
bins and, for the polygon, sum the count over the two drawn dimensions
only.
Reproduced on plopp 26.11.0, scipp 26.9.0, matplotlib 3.11.2.
- Ngôn ngữ chính
- Python
- Star
- 12
- Fork
- 7
- Merge trung bình
- 16 giờ 5 phút
- Pull request đã merge (30 ngày)
- 6
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của scipp/plopp
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Values clipped by `vmin` and masked values look alike, and the colourbar doesn't show clippingĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
`pp.plot` docstring: say that style kwargs can be per-line dictsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
LIF-Initiative/lif-core#1534 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
fix(frontend): on a phone a new page opens scrolled down, at the last page's scroll positionĐang mởbug frontend good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 89/100
nikhilb2/simple_invoicing#1231 ·
-
review-panel severity:low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
kristovatlas/coin-accounting#498 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement github_actions
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
QWED-AI/qwed-verification#703 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Calc 1.1: inconsistent duplicate facts with equal `decimals` don't stop the calculation checkĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày