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

Provide guidance on parameters and variables with the same name

未关闭
#12 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
文档
描述清晰度
需要澄清
活跃度
停滞
技术栈
python
领域
documentation

调研方向

The issue names no files, tests, or entry points to inspect. Compare the three naming and variable-design examples, then document a decided convention for parameters and variables with the same name, including when the convention is considered complete.

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

描述

For example, consider the case of identifying whether a household is in poverty, where poverty line is indexed by household size. The formula could include Python variables that both represent the poverty line parameter (which is indexed by household size) and the household's poverty line based on their specific household size. I see three ways to address this:

A: Add a qualifier to the entity's value, e.g. household_
class is_in_poverty(Variable):
    def formula(household, period, parameters):
        poverty_line = parameters(period).poverty.poverty_line
        household_size = household.nb_persons()
        household_poverty_line = poverty_line[household_size]
        return household("household_income") < household_poverty_line
B: Add a qualifier to the parameter, e.g. param_ or p_
class is_in_poverty(Variable):
    def formula(household, period, parameters):
        param_poverty_line = parameters(period).poverty.poverty_line
        household_size = household.nb_persons()
        poverty_line = poverty_line[household_size]
        return household("household_income") < poverty_line
C: Add a separate OpenFisca variable for any parameter indexed by household features
class household_poverty_line(Variable):
    def formula(household, period, parameters):
        poverty_line = parameters(period).poverty.poverty_line
        household_size = household.nb_persons()
        return poverty_line[household_size]

class is_in_poverty(Variable):
    def formula(household, period, parameters):
        return household("household_income") < household("household_poverty_line")

Option C creates a lot of variables, but it seems cleanest to me. I think it would avoid the issue of potentially overlapping variables to represent parameters and Variables, but there might be some cases I'm not thinking of.

主要语言
Makefile
星标
1
派生
3
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

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

PolicyEngine/policyengine.dev 的其他 Issue

查看 PolicyEngine/policyengine.dev 的全部 Issue

相似的 Issue

更多 Documentation Issue

把新 issue 发到你的邮箱

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