Skip to content

Commit 25d7162

Browse files
authored
ENH allow all kinds of covariances (#104)
* ENH allow all kinds of covariances * TST remove outdated tests
1 parent 264aa3d commit 25d7162

4 files changed

Lines changed: 2 additions & 38 deletions

File tree

firecrown/ccl/likelihoods/gaussian.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import numpy as np
22
import scipy.linalg
3-
import sacc
43

54
from ..core import LogLike
65

@@ -42,10 +41,6 @@ def read(self, sacc_data, sources, statistics):
4241
A dictionary mapping statistics to their objects. These statistics do
4342
not have to have been rendered.
4443
"""
45-
if not isinstance(sacc_data.covariance, sacc.covariance.FullCovariance):
46-
raise RuntimeError(
47-
"Currently, the SACC covariance must be a 'FullCovariance'. "
48-
"This may change in a future firecrown release.")
4944
_sd = sacc_data.copy()
5045
inds = []
5146
for stat in self.data_vector:
@@ -58,7 +53,7 @@ def read(self, sacc_data, sources, statistics):
5853
cov = np.zeros((len(inds), len(inds)))
5954
for new_i, old_i in enumerate(inds):
6055
for new_j, old_j in enumerate(inds):
61-
cov[new_i, new_j] = _sd.covariance.covmat[old_i, old_j]
56+
cov[new_i, new_j] = _sd.covariance.dense[old_i, old_j]
6257
self.cov = cov
6358
self.cholesky = scipy.linalg.cholesky(self.cov, lower=True)
6459

firecrown/ccl/likelihoods/tdist.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import numpy as np
22
import scipy.linalg
3-
import sacc
43

54
from ..core import LogLike
65

@@ -50,10 +49,6 @@ def read(self, sacc_data, sources, statistics):
5049
A dictionary mapping statistics to their objects. These statistics do
5150
not have to have been rendered.
5251
"""
53-
if not isinstance(sacc_data.covariance, sacc.covariance.FullCovariance):
54-
raise RuntimeError(
55-
"Currently, the SACC covariance must be a 'FullCovariance'. "
56-
"This may change in a future firecrown release.")
5752
_sd = sacc_data.copy()
5853
inds = []
5954
for stat in self.data_vector:
@@ -66,7 +61,7 @@ def read(self, sacc_data, sources, statistics):
6661
cov = np.zeros((len(inds), len(inds)))
6762
for new_i, old_i in enumerate(inds):
6863
for new_j, old_j in enumerate(inds):
69-
cov[new_i, new_j] = _sd.covariance.covmat[old_i, old_j]
64+
cov[new_i, new_j] = _sd.covariance.dense[old_i, old_j]
7065
self.cov = cov
7166
self.cholesky = scipy.linalg.cholesky(self.cov, lower=True)
7267

firecrown/ccl/likelihoods/tests/test_gaussian.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import numpy as np
2-
import pytest
32

43
from ..gaussian import ConstGaussianLogLike
54

@@ -34,15 +33,3 @@ def test_likelihood_gaussian_subset(likelihood_test_data):
3433
cov = likelihood_test_data['cov'][0:4, 0:4]
3534
loglike = -0.5 * np.dot(delta, np.dot(np.linalg.inv(cov), delta))
3635
assert np.allclose(loglike, ll.compute(data, theory))
37-
38-
39-
def test_likelihood_gaussian_raises(likelihood_test_data):
40-
ll = ConstGaussianLogLike(data_vector=["stat_src0_src0", "stat_src0_src1"])
41-
sd = likelihood_test_data['sacc_data'].copy()
42-
sd.covariance = 10
43-
with pytest.raises(RuntimeError) as e:
44-
ll.read(
45-
sd,
46-
likelihood_test_data['sources'],
47-
likelihood_test_data['statistics'])
48-
assert 'FullCovariance' in str(e)

firecrown/ccl/likelihoods/tests/test_tdist.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import numpy as np
2-
import pytest
32

43
from ..tdist import TdistLogLike
54

@@ -42,15 +41,3 @@ def test_likelihood_tdist_subset(likelihood_test_data):
4241
chi2 = np.dot(delta, np.dot(np.linalg.inv(cov), delta))
4342
loglike = -0.5 * nu * np.log(1.0 + chi2 / (nu - 1.0))
4443
assert np.allclose(loglike, ll.compute(data, theory))
45-
46-
47-
def test_likelihood_tdist_raises(likelihood_test_data):
48-
ll = TdistLogLike(data_vector=["stat_src0_src0", "stat_src0_src1"], nu=10)
49-
sd = likelihood_test_data['sacc_data'].copy()
50-
sd.covariance = 10
51-
with pytest.raises(RuntimeError) as e:
52-
ll.read(
53-
sd,
54-
likelihood_test_data['sources'],
55-
likelihood_test_data['statistics'])
56-
assert 'FullCovariance' in str(e)

0 commit comments

Comments
 (0)