diff --git a/pina/_src/domain/base_domain.py b/pina/_src/domain/base_domain.py index 3316fabfd..d3cea3848 100644 --- a/pina/_src/domain/base_domain.py +++ b/pina/_src/domain/base_domain.py @@ -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) diff --git a/tests/test_domain/test_cartesian_domain.py b/tests/test_domain/test_cartesian_domain.py index db9297ced..e5b80a5ad 100644 --- a/tests/test_domain/test_cartesian_domain.py +++ b/tests/test_domain/test_cartesian_domain.py @@ -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) diff --git a/tests/test_domain/test_ellipsoid_domain.py b/tests/test_domain/test_ellipsoid_domain.py index ced0f9dd0..a39d3eca2 100644 --- a/tests/test_domain/test_ellipsoid_domain.py +++ b/tests/test_domain/test_ellipsoid_domain.py @@ -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