Skip to content

Commit

Permalink
modifying values on 1d arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
rhayes777 committed Jul 1, 2024
1 parent 00ba187 commit df708b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion autofit/mapper/prior_model/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _make_key(index: Tuple[int, ...]) -> str:
The attribute name for the prior.
"""
if isinstance(index, int):
suffix = f"_{index}"
suffix = str(index)
else:
suffix = "_".join(map(str, index))
return f"prior_{suffix}"
Expand Down
6 changes: 6 additions & 0 deletions test_autofit/mapper/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,9 @@ def array_1d():
def test_1d_array(array_1d):
assert array_1d.prior_count == 2
assert (array_1d.instance_from_prior_medians() == [0.0, 0.0]).all()


def test_1d_array_modify_prior(array_1d):
array_1d[0] = 1.0
assert array_1d.prior_count == 1
assert (array_1d.instance_from_prior_medians() == [1.0, 0.0]).all()

0 comments on commit df708b7

Please sign in to comment.