Corr array initialization generalized (#203)

* feat: corr array initialization generalized.

* feat: additional checks for three-dimensional arrays added.

* docs: Corr docstring improved.

* docs: typos corrected.

* docs: details about None padding added to Corr docstring.
This commit is contained in:
Fabian Joswig 2023-07-18 12:07:46 +01:00 committed by GitHub
parent 491c7bcb04
commit 66d5f8be24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 81 additions and 38 deletions

View file

@ -572,6 +572,27 @@ def test_corr_symmetric():
assert scorr[0] == corr[0]
def test_corr_array_ndim1_init():
y = [pe.pseudo_Obs(2 + np.random.normal(0.0, 0.1), .1, 't') for i in np.arange(5)]
cc1 = pe.Corr(y)
cc2 = pe.Corr(np.array(y))
assert np.all([o1 == o2 for o1, o2 in zip(cc1, cc2)])
def test_corr_array_ndim3_init():
y = np.array([pe.pseudo_Obs(np.random.normal(2.0, 0.1), .1, 't') for i in np.arange(12)]).reshape(3, 2, 2)
tt1 = pe.Corr(list(y))
tt2 = pe.Corr(y)
tt3 = pe.Corr(np.array([pe.Corr(o) for o in y.reshape(3, 4).T]).reshape(2, 2))
assert np.all([o1 == o2 for o1, o2 in zip(tt1, tt2)])
assert np.all([o1 == o2 for o1, o2 in zip(tt1, tt3)])
assert tt1.T == y.shape[0]
assert tt1.N == y.shape[1] == y.shape[2]
with pytest.raises(ValueError):
pe.Corr(y.reshape(6, 2, 1))
def test_two_matrix_corr_inits():
T = 4
rn = lambda : np.random.normal(0.5, 0.1)