Skip to content

Commit

Permalink
Fix for input parameters without space before unit (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkundu1 authored Sep 12, 2023
1 parent 3b5b9ef commit 4229466
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ansys/fluent/parametric/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ def get_unit_label(self, name: str) -> str:
"""
value = str(self[name])
value_split = value.split(maxsplit=1)
value_split = value.split("[", maxsplit=1)
if len(value_split) == 1:
return ""
else:
return value_split[1].lstrip("[").rstrip("]")
return value_split[-1].strip().rstrip("]")

def __setitem__(self, name: str, value: V) -> None:
"""Set value of an input parameter.
Expand Down
8 changes: 8 additions & 0 deletions tests/test_input_output_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ def test_input_output_parameters():
assert inp["inlet_pressure"] == "90001 [Pa]"
assert inp.get_unit_label("inlet_pressure") == "Pa"

inp["inlet_pressure"] = "90002[Pa]"
assert inp["inlet_pressure"] == "90002[Pa]"
assert inp.get_unit_label("inlet_pressure") == "Pa"

inp["inlet_pressure"] = 90003
assert inp["inlet_pressure"] == "90003 [Pa]"
assert inp.get_unit_label("inlet_pressure") == "Pa"

outp = OutputParameters(solver_session)
assert len(outp) == 1
assert outp["mass-outlet-op"] == "0.0 [kg/s]"
Expand Down

0 comments on commit 4229466

Please sign in to comment.