Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pina/_src/domain/base_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,17 @@ def update(self, domain):
f"with domain of type {type(domain)}."
)

# Update fixed and ranged variables
# Create a deepcopy of the current domain
updated = deepcopy(self)

# Remove keys that change category
for key in domain.fixed:
updated.range.pop(key, None)

for key in domain.range:
updated.fixed.pop(key, None)

# Update fixed and ranged variables
updated.fixed.update(domain.fixed)
updated.range.update(domain.range)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_domain/test_cartesian_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def test_update(dict):

# Define the domains
domain_1 = CartesianDomain(dict)
domain_2 = CartesianDomain({"new_var": [0, 1]})
domain_3 = CartesianDomain(dict | {"new_var": [0, 1]})
domain_2 = CartesianDomain({"new_var": [0, 1], "x": 1})
domain_3 = CartesianDomain(dict | {"new_var": [0, 1], "x": 1})

# Update domain_1 with domain_2
updated_domain = domain_1.update(domain_2)
Expand Down
6 changes: 4 additions & 2 deletions tests/test_domain/test_ellipsoid_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ def test_update(dict, sample_surface):
ellipsoid_dict=dict, sample_surface=sample_surface
)
domain_2 = EllipsoidDomain(
ellipsoid_dict={"new_var": [0, 1]}, sample_surface=sample_surface
ellipsoid_dict={"new_var": [0, 1], "x": 1},
sample_surface=sample_surface
)
domain_3 = EllipsoidDomain(
ellipsoid_dict=dict | {"new_var": [0, 1]}, sample_surface=sample_surface
ellipsoid_dict=dict | {"new_var": [0, 1], "x": 1},
sample_surface=sample_surface
)

# Update domain_1 with domain_2
Expand Down
Loading