Skip to content

Commit 77b7bfd

Browse files
fix update method in base domain
1 parent 54a4d90 commit 77b7bfd

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

pina/_src/domain/base_domain.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,17 @@ def update(self, domain):
103103
f"with domain of type {type(domain)}."
104104
)
105105

106-
# Update fixed and ranged variables
106+
# Create a deepcopy of the current domain
107107
updated = deepcopy(self)
108+
109+
# Remove keys that change category
110+
for key in domain.fixed:
111+
updated.range.pop(key, None)
112+
113+
for key in domain.range:
114+
updated.fixed.pop(key, None)
115+
116+
# Update fixed and ranged variables
108117
updated.fixed.update(domain.fixed)
109118
updated.range.update(domain.range)
110119

tests/test_domain/test_cartesian_domain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def test_update(dict):
7676

7777
# Define the domains
7878
domain_1 = CartesianDomain(dict)
79-
domain_2 = CartesianDomain({"new_var": [0, 1]})
80-
domain_3 = CartesianDomain(dict | {"new_var": [0, 1]})
79+
domain_2 = CartesianDomain({"new_var": [0, 1], "x": 1})
80+
domain_3 = CartesianDomain(dict | {"new_var": [0, 1], "x": 1})
8181

8282
# Update domain_1 with domain_2
8383
updated_domain = domain_1.update(domain_2)

tests/test_domain/test_ellipsoid_domain.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,12 @@ def test_update(dict, sample_surface):
9191
ellipsoid_dict=dict, sample_surface=sample_surface
9292
)
9393
domain_2 = EllipsoidDomain(
94-
ellipsoid_dict={"new_var": [0, 1]}, sample_surface=sample_surface
94+
ellipsoid_dict={"new_var": [0, 1], "x": 1},
95+
sample_surface=sample_surface
9596
)
9697
domain_3 = EllipsoidDomain(
97-
ellipsoid_dict=dict | {"new_var": [0, 1]}, sample_surface=sample_surface
98+
ellipsoid_dict=dict | {"new_var": [0, 1], "x": 1},
99+
sample_surface=sample_surface
98100
)
99101

100102
# Update domain_1 with domain_2

0 commit comments

Comments
 (0)