Skip to content

Commit

Permalink
Merge pull request #264 from arup-group/fix_issue_263
Browse files Browse the repository at this point in the history
fix bug
  • Loading branch information
Theodore-Chatziioannou authored Oct 30, 2023
2 parents 8dcdd0f + f8d10df commit 76eddc3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- **internal** conda upload CI script.
- **public** fix person attributes type conversion bug ([#263](https://github.com/arup-group/pam/issues/263))

### Added

Expand Down
2 changes: 1 addition & 1 deletion pam/read/matsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def get_attributes_from_person(elem):
elif attribute_type == "java.lang.Integer":
attributes[attribute_name] = int(attr.text)
elif attribute_type == "java.lang.Double":
attributes[attribute_name] = float(attr)
attributes[attribute_name] = float(attr.text)
elif attribute_type == "org.matsim.vehicles.PersonVehicles":
attributes[attribute_name] = parse_veh_attribute(attr.text)
# last try:
Expand Down
11 changes: 11 additions & 0 deletions tests/test_03_read_matsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,14 @@ def test_get_attributes_from_person():
assert pid == "chris"
assert attributes["hid"] == "A"
assert attributes["vehicles"] == {"car": "chris"}


def test_get_float_attribute_from_person():
text = """<person id="chris">
<attributes>
<attribute name="age" class="java.lang.Double">10.0</attribute>
</attributes>
</person>"""
elem = et.fromstring(text)
pid, attributes = get_attributes_from_person(elem)
assert isinstance(attributes["age"], float)

0 comments on commit 76eddc3

Please sign in to comment.