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

Better mechanism to control SetterFlags

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

还没有人认领这个 Issue。

评估

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

调研方向

首先跟踪 issue 测试示例中使用的 Python properties、_set_PMult setter、SetterFlags 和 end_edit(),然后比较所提议的 context-manager 和 default-property 方法将如何通过 C API 传递 flags。完成后应建立一个有文档说明的机制,支持单个操作和批量操作,包括 ImplicitSizes 和 AvoidFullRecalc,并使所示的基于 property 的用法能够正常工作。

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

描述

enhancement

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 Edit context 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

贡献指南

这个仓库没有索引到贡献指南

从这里开始

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

dss-extensions/AltDSS-Python 的其他 Issue

查看 dss-extensions/AltDSS-Python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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