GetDist&COBAYA: Negative index

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Ali Rida Khalife
Posts: 18
Joined: October 31 2022
Affiliation: Institut d'Astrophysique de Paris

GetDist&COBAYA: Negative index

Post by Ali Rida Khalife »

Hello,
I'm trying to produce the MargeStats for a run I made with COBAYA, with 4 chains:

Code: Select all

sample = loadMCSamples('path/to/chains/CLASS', no_cache=True)
MargeStats = sample.getMargeStats()
However, I'm getting the following error:

Code: Select all

/path/to/cobaya/getdist/mcsamples.py:1416: RuntimeWarning: invalid value encountered in cast
  ix = ((paramVec - binmin) / fine_width + 0.5).astype(int)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[3], line 1
----> 1 MargeStats = sample_SPT.getMargeStats()

File /path/to/cobaya/getdist/mcsamples.py:2190, in MCSamples.getMargeStats(self, include_bestfit)
   2183 def getMargeStats(self, include_bestfit=False):
   2184     """
   2185     Returns a :class:`~.types.MargeStats` object with marginalized 1D parameter constraints
   2186 
   2187     :param include_bestfit: if True, set best fit values by loading from root_name.minimum file (assuming it exists)
   2188     :return: A :class:`~.types.MargeStats` instance
   2189     """
-> 2190     self._setDensitiesandMarge1D()
   2191     m = types.MargeStats()
   2192     m.hasBestFit = False

File /path/to/cobaya/getdist/mcsamples.py:2284, in MCSamples._setDensitiesandMarge1D(self, max_frac_twotail, meanlikes)
   2282 for j in range(self.n):
   2283     paramConfid = self.initParamConfidenceData(self.samples[:, j])
-> 2284     self.get1DDensityGridData(j, paramConfid=paramConfid, meanlikes=meanlikes)
   2285     self._setMargeLimits(self.paramNames.names[j], paramConfid, max_frac_twotail)
   2287 self.done_1Dbins = True

File /path/to/cobaya/getdist/mcsamples.py:1473, in MCSamples.get1DDensityGridData(self, j, paramConfid, meanlikes, **kwargs)
   1470 width = paramrange / (num_bins - 1)
   1472 bin_indices, fine_width, binmin, binmax = self._binSamples(self.samples[:, j], par, fine_bins)
-> 1473 bins = np.bincount(bin_indices, weights=self.weights, minlength=fine_bins)
   1475 if meanlikes:
   1476     if self.shade_likes_is_mean_loglikes:

ValueError: 'list' argument must have no negative elements
After putting print(ix), indeed I found the very last line to be negative, and the same value repeated:

Code: Select all

 ix = ((paramVec - binmin) / fine_width + 0.5).astype(int)
[-9223372036854775808 -9223372036854775808 -9223372036854775808 ...
 -9223372036854775808 -9223372036854775808 -9223372036854775808]
I tried removing the last line of the chain files(CLASS.txt) from each chain file, but I still get that error.
I've never had this error before, even tho I did run this model before, and I ran similar chains(with different data sets) but didn't get such an error.
Did anyone face this problem?
I would appreciate the help!
Cheers,
Ali
Jesus Torrado
Posts: 37
Joined: April 15 2013
Affiliation: RWTH Aachen
Contact:

Re: GetDist&COBAYA: Negative index

Post by Jesus Torrado »

Hi Ali,

Hard to say what's failing. Could you do some histograms and scatter plots of the sample itself, when loaded with `numpy.loadtxt`? The "last line" in your test probably refers to the last parameter in the chain files, so could you post a histogram of the last column in particular?
Post Reply