Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Register weighted-microdata rules: weights aren't values

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

Maintainer thường phản hồi trong vòng 2 ngày

@anth-volk đang làm issue này rồi.

Từ ngày 14/10/2026.

  • #3938 của @anth-volk — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
18/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
api, data

Hướng nghiên cứu

The work is registering four rules in rules/registry.toml plus AST guards for the shapes they describe. Read the issue's list of rule IDs and the cited Simulation API line first, then check whether linked pull request #3938 already covers them, since it is still open. Done means the three guarded rules are enforced with no findings on the current code, and the doc-only rule is registered.

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

Mô tả

Problem

A weighted MicroSeries or MicroDataFrame weights every .sum(), .mean() and .count(). Aggregating a weight column through one weights it by itself, and returns the sum of squared weights.

That happened in the Simulation API (PolicyEngine/policyengine-sim-api#766, fixed by PolicyEngine/policyengine-sim-api#767). budget.households was about 10^4 times too high on every run, and its test missed it because it used plain pd.DataFrames.

Once the unused economy comparison module is removed, nothing in the Public API handles microdata. Nothing stops new code from making the same mistake, though.

Proposal

Phase 1 step 1.9. Register the rule that weights aren't values, plus AST guards for the shapes a source check can recognise, in rules/registry.toml:

  • api.microdata.weights-not-values (doc-only): weights, values, labels and counts each allow different operations.
  • api.microdata.weights-not-aggregated-as-values: a weight is never the value of a weighted MicroSeries, the variable of a weighted aggregator, or frame[<weight>] followed by a weighted reduction.
  • api.microdata.weight-stripping-confined: raw values (np.array, .values, .to_numpy() and so on) are read from weighted microdata only in a designated module. None is designated yet.
  • api.microdata.unweighted-series-are-labels: a MicroSeries built without weights= is only a grouping or filter key.

The aggregation rule's proof is the real pre-#767 Simulation API line. With no current code in scope, all three guarded rules start enforced, with no findings.

Ngôn ngữ chính
Python
Star
18
Fork
33
Merge trung bình
1 ngày 20 giờ
Pull request đã merge (30 ngày)
27

Chuẩn bị môi trường

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.

Issue khác của PolicyEngine/policyengine-api

Tất cả issue của PolicyEngine/policyengine-api

Issue tương tự

Thêm issue về Python

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.