Commit 9d73b683 authored by Stephan Rave's avatar Stephan Rave Committed by GitHub

Merge pull request #970 from TiKeil/fix_parse_parameter

[parameters] Fix a serious bug in Parameters.parse()
parents 781dfe63 d686efa9
Pipeline #61471 failed with stages
in 21 minutes and 56 seconds
......@@ -140,7 +140,7 @@ class Parameters(FrozenDict):
all(isinstance(v, Number) for v in mu) or fail('not every element a number')
len(mu) == sum(v for v in self.values()) or fail('wrong size')
parsed_mu = {}
for k, v in self.items():
for k, v in sorted(self.items()):
p, mu = mu[:v], mu[v:]
parsed_mu[k] = p
return Mu(parsed_mu)
......
......@@ -29,6 +29,11 @@ def test_randomly(space):
for value in values:
assert space.contains(value)
def test_parse_parameter():
parameters = Parameters(b=2, a=1)
mu_as_list = [1,2,3]
mu_as_parameter_and_back = list(parameters.parse(mu_as_list).to_numpy())
assert mu_as_list == mu_as_parameter_and_back
if __name__ == "__main__":
runmodule(filename=__file__)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment