Better mechanism to control SetterFlags
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 28/100
Research direction
Start by tracing the Python properties, the _set_PMult setter, SetterFlags, and end_edit() used in the issue's test examples, then compare how the proposed context-manager and default-property approaches would pass flags through the C API. Done should establish one documented mechanism that supports individual and batch operations, including ImplicitSizes and AvoidFullRecalc, with the shown property-based usage working.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 19
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dss-extensions/AltDSS-Python
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 35/100
dss-extensions/AltDSS-Python#13 · 1 comment ·
-
documentation
Difficulty 3/5 1-2 days Newbie friendliness 35/100
dss-extensions/AltDSS-Python#8 · 3 comments ·
-
documentation
Difficulty 4/5 3-5 days Newbie friendliness 20/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 20/100
dss-extensions/AltDSS-Python#6 · 1 reaction ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in dss-extensions/AltDSS-Python
Similar issues
-
bug confirmed issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-webui/open-webui#30750 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 90/100