RWTH-EBC/FiLiP

ContextAttribute: wrong type conversion for value

Closed this issue · 2 comments

Describe the bug
When creating an instance of the ContextAttribute-class with a string value which can also be interpreted as a number, the ContextAttribute -constructor takes the first suitable data type (here a float) listed in the Union for value instead of a string.

To Reproduce
Steps to reproduce the behavior:

building_entity = ContextEntity(id="MyBuilding01",
type='Building',
number=ContextAttribute(value="0970"))
print(building_entity)

Output:

id='MyBuilding01' type='Building' number=ContextAttribute(type='Text', value='970.0', metadata={})

Expected behavior
Output should be
id='MyBuilding01' type='Building' number=ContextAttribute(type='Text', value='0970', metadata={})

@lidiawestphal is there any use case to create such an attribute without specifying the type? Now, if the type is specified, the value will be correct. However, if type is not specified, Text will be used by default.