Better mechanism to control SetterFlags
还没有人认领这个 Issue。
评估
调研方向
首先跟踪 issue 测试示例中使用的 Python properties、_set_PMult setter、SetterFlags 和 end_edit(),然后比较所提议的 context-manager 和 default-property 方法将如何通过 C API 传递 flags。完成后应建立一个有文档说明的机制,支持单个操作和批量操作,包括 ImplicitSizes 和 AvoidFullRecalc,并使所示的基于 property 的用法能够正常工作。
由索引模型根据 Issue 内容生成。
描述
Currently this is an advanced feature, and users need to leave the comfort of the Python properties, using instead the setter methods in order to pass both a value and the flags.
Some context, from the tests:
alt.Clear()
ls = alt.LoadShape.new('test_shape')
with pt.raises(DSSException):
ls.PMult = [1.0, 2.0, 3.0]
ls._set_PMult([1.0, 2.0, 3.0], SetterFlags.ImplicitSizes)
assert tuple(ls.PMult) == (1.0, 2.0, 3.0)
ls.end_edit()
Some possible alternatives:
- Use a context manager in Python to keep the flags used in a block, use these flags on each Python function (when passing to the C API) and reset them later. This could be combined with the
Editcontext manager later.
with alt.with_setter_flags(SetterFlags.ImplicitSizes):
ls = alt.LoadShape.new('test_shape')
ls.PMult = [1.0, 2.0, 3.0]
assert tuple(ls.PMult) == (1.0, 2.0, 3.0)
ls.end_edit()
- Introduce a pair of API functions to control some default flags, expose it as a property. For this, we wouldn't need to change much of the Python code, but would require consuming the default flags on the engine:
alt.DefaultSetterFlags = SetterFlags.ImplicitSizes
#...
ls = alt.LoadShape.new('test_shape')
ls.PMult = [1.0, 2.0, 3.0]
assert tuple(ls.PMult) == (1.0, 2.0, 3.0)
ls.end_edit()
Other examples include using SetterFlags.AvoidFullRecalc to minimize Yprim and SystemY changes for loads and generators. This is valid for both individual and batch operations.
- 主要语言
- Python
- 星标
- 19
- 派生
- 2
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dss-extensions/AltDSS-Python 的其他 Issue
-
enhancement
难度 3/5 1-2 天 新手友好度 35/100
dss-extensions/AltDSS-Python#13 · 1 条评论 ·
-
documentation
难度 3/5 1-2 天 新手友好度 35/100
dss-extensions/AltDSS-Python#8 · 3 条评论 ·
-
documentation
难度 4/5 3-5 天 新手友好度 20/100
-
enhancement
难度 5/5 一周以上 新手友好度 20/100
dss-extensions/AltDSS-Python#6 · 1 个 reaction ·
-
enhancement
难度 5/5 一周以上 新手友好度 25/100
查看 dss-extensions/AltDSS-Python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
anthropics/skills#1811 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
speaches-ai/speaches#678 ·
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
datalayer/mcp-compose#42 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
conda-forge/spacy-feedstock#177 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
UKGovernmentBEIS/inspect_evals#2523 ·