I noticed that gummy.create() mutates its input covariance matrix.
This leads to unexpected behavior:
from metrolopy import gummy
import numpy as np
val = [1., 2.]
cov = np.array([[0.3, 0.1], [0.1, 0.2]])
print("cov before gummy creation:\n", cov)
print()
a, b = gummy.create(val, covariance_matrix=cov)
print("cov after gummy creation:\n", cov)
print()
print("a + b after first gummy creation ", a + b)
a, b = gummy.create(val, covariance_matrix=cov)
print("a + b after second gummy creation ", a + b)
cov before gummy creation:
[[0.3 0.1]
[0.1 0.2]]
cov after gummy creation:
[[1. 0.40824829]
[0.40824829 1. ]]
a + b after first gummy creation 3.00(84)
a + b after second gummy creation 3.0(17)
Hi,
I noticed that
gummy.create()
mutates its input covariance matrix. This leads to unexpected behavior:I think this line is the problem:
https://github.com/nrc-cnrc/MetroloPy/blob/2230edc95b88bd61b2f66935555cc4669a37af9d/metrolopy/ummy.py#L381
Is the mutation necessary? A workaround is to pass a deepcopy of the covariance matrix.