Closed tomasdsousa closed 1 year ago
This has been addressed in #10
We now check for all infs in the DL file and do not sort these functions. We still generate an output file, but it is empty. As a minimum working example, the following code would not previously run as all DL values are inf by construction, but now does.
import numpy as np
import esr.fitting.test_all
import esr.fitting.test_all_Fisher
import esr.fitting.match
import esr.fitting.combine_DL
import esr.fitting.plot
from esr.fitting.likelihood import Likelihood
class InfLikelihood(Likelihood):
def __init__(self,):
super().__init__('data_file', 'cov_file', 'inf_test',)
self.ylabel = r'$y$'
nx = 10
self.xvar = np.ones(nx)
self.yvar = np.ones(nx)
self.yerr = np.ones(nx)
def negloglike(self, a, eq_numpy, **kwargs):
return np.inf
class SometimesInfLikelihood(Likelihood):
def __init__(self,):
super().__init__('data_file', 'cov_file', 'inf_test',)
self.ylabel = r'$y$'
nx = 10
self.xvar = np.ones(nx)
self.yvar = np.ones(nx)
self.yerr = np.ones(nx)
def negloglike(self, a, eq_numpy, **kwargs):
if len(a) == 1:
return np.inf
return 0
comp = 1
for likelihood in [InfLikelihood(), SometimesInfLikelihood()]:
print('\n')
esr.fitting.test_all.main(comp, likelihood)
esr.fitting.test_all_Fisher.main(comp, likelihood)
esr.fitting.match.main(comp, likelihood)
esr.fitting.combine_DL.main(comp, likelihood)
esr.fitting.plot.main(comp, likelihood)
File ~/Desktop/ESR/esr/fitting/combine_DL.py:135 in main DL_sort = arr_sort[0,:]
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed
When all functions have nll=inf.