Skip to content

Unexpected behavior in BaseDomain.update method #779

Description

@GiovanniCanali

Describe the bug
The BaseDomain.update method does not behave correctly when a variable changes type. Specifically, if a key is defined as a range variable in the original domain and as a fixed variable in the updating domain, the update does not properly override the original definition.

To Reproduce

domain1 = CartesianDomain({"x": [0, 1], "y": [0, 1], "t": 0})
domain2 = CartesianDomain({"x": 0, "z": 0})
new_domain = domain1.update(domain2)

print(new_domain.domain_dict)

Expected behavior
new_domain should reflect the values in domain2 when keys overlap. In particular, since "x" is defined as a fixed variable in domain2, it should override the ranged definition in domain1. Therefore, the expected domain is:

{"t": 0, "x": 0, "z": 0,  "y": [0, 1]}

Instead, "x" keeps its original ranged definition from domain1, and the output is:

{'t': 0, 'x': (0, 1), 'z': 0, 'y': (0, 1)}

Metadata

Metadata

Labels

0.3Related to 0.3 releasebugSomething isn't workinghigh priorityHigher priority

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions