Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Register weighted-microdata rules: weights aren't values

未关闭
#3,937 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@anth-volk 已经在做这个了。

开始于 2026年10月14日。

  • #3938 来自 @anth-volk —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
18/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
python
领域
api, data

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Python
星标
18
派生
33
平均合并
1 天 19 小时
30 天内合并 PR
26

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

PolicyEngine/policyengine-api 的其他 Issue

查看 PolicyEngine/policyengine-api 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。