Skip to content

Commit

Permalink
Start the fix up
Browse files Browse the repository at this point in the history
  • Loading branch information
znicholls committed Sep 15, 2024
1 parent a2ec368 commit a8f6440
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/openscm_calibration/model_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def x_and_parameters_to_named_with_units(
{'para_a': <Quantity(1.1, 'meter')>, 'pop_weight': <Quantity(3.2, 'thousands')>, 'factor': 4.0}
""" # noqa: E501
unit_reg = (
get_unit_registry() if get_unit_registry else pint.get_application_registry()
get_unit_registry() if get_unit_registry else pint.get_application_registry() # type: ignore
)

out: dict[str, pint.registry.UnitRegistry.Quantity] = {}
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_model_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ def test_from_parameters_run_model(mock_get_params):
),
)
def test_x_and_parameters_to_named_with_units(x_in, params_in, exp):
original_ureg = pint.get_application_registry()
pint.set_application_registry(UNIT_REG)

res = x_and_parameters_to_named_with_units(
x=x_in,
params=params_in,
Expand All @@ -124,6 +127,8 @@ def test_x_and_parameters_to_named_with_units(x_in, params_in, exp):
else:
assert exp_v == res[k]

pint.set_application_registry(original_ureg)


def test_convert_x_to_names_with_units_dependency_injection():
x = [1.1, 2.2, 0.3]
Expand Down

0 comments on commit a8f6440

Please sign in to comment.