OptionsManager does not delete options inherited through default_options_set
Đánh giá
Issue này chưa được đánh giá.
Mô tả
OptionsManager does not delete the options that it inherits through default_options_set. When inserted_options() exits, these options stay in the global PETSc options database under the prefix of the manager. The next manager that has the same prefix then reads them back as options that the user set.
Minimal example
from petsc4py import PETSc
from petsctools import DefaultOptionSet, OptionsManager
options = PETSc.Options()
options["base_ksp_type"] = "cg"
child = OptionsManager({}, options_prefix="base_0",
default_options_set=DefaultOptionSet("base", [0]))
print(child.parameters) # {'ksp_type': 'cg'}
with child.inserted_options():
pass
del options["base_ksp_type"]
print(options.getAll()) # expected {}, actual {'base_0_ksp_type': 'cg'}
This reproduces on main (d4caedc).
Cause
OptionsManager.__init__ builds to_delete before it merges the default options into parameters:
https://github.com/firedrakeproject/petsctools/blob/d4caedc/petsctools/options.py#L505-L509
inserted_options() inserts every key of parameters, but deletes only the keys in to_delete. The inherited keys are therefore inserted and never deleted.
Possible fix
to_delete = set(default_options | parameters)
parameters = default_options | parameters
The loop that follows already discards every key that the database held before, so options from the command line are kept.
This issue was written by Claude (Claude Code) on behalf of @pbrubeck.
- Ngôn ngữ chính
- Python
- Star
- 4
- Fork
- 1
- Merge trung bình
- 2 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của firedrakeproject/petsctools
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
firedrakeproject/petsctools#54 · 1 bình luận ·
-
Lazy PETSc init?Đang mởenhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
firedrakeproject/petsctools#51 · 1 bình luận · 1 reaction ·
-
enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
-
bug question
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Tất cả issue của firedrakeproject/petsctools
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
datamodel-code-generator/datamodel-code-generator#6906 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
UKGovernmentBEIS/optstop#12 ·
-
bug good first issue severity: low
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
TMHSDigital/Awesome-Ads#37 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
smokin-salmon/smoked-salmon#1095 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Sienna-Platform/SiennaSchemas#130 ·
Maintainer thường phản hồi trong vòng 3 ngày