Provide guidance on parameters and variables with the same name
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 文档
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- python
调研方向
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PolicyEngine/policyengine.dev 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 38/100
PolicyEngine/policyengine.dev#19 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 20/100
-
难度 5/5 一周以上 新手友好度 25/100
-
难度 4/5 3-5 天 新手友好度 20/100
查看 PolicyEngine/policyengine.dev 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 95/100
Git-it-App/git-it-electron#1047 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
neondatabase/website#5944 ·
-
📕documentation
难度 2/5 1-3 小时 新手友好度 75/100
db-ux-design-system/core-web#8239 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
libsdl-org/sdlwiki#1008 ·
-
难度 2/5 1-3 小时 新手友好度 70/100