getdist.types

class getdist.types.BestFit(fileName=None, setParamNameFile=None, want_fixed=False)[source]

Class holding the result of a likelihood minimization, inheriting from ParamResults

Parameters:
  • fileName – text file to load from, assumed to be in CosmoMC’s .minimum format
  • setParamNameFile – optional name of .paramnames file listing preferred parameter labels for the parameters
  • want_fixed – whether to include values of parameters that are not allowed to vary
class getdist.types.LikeStats(fileName=None, setParamNameFile=None, default=0, names=None)[source]

Stores likelihood-related statistics, including best-fit sample and extremal values of the N-D confidence region, inheriting from ParamResults. TODO: currently only saves to text, does not load full data from file

Parameters:
  • fileName – name of .paramnames file to load from
  • setParamNameFile – override specific parameter names’ labels using another file
  • default – set to int>0 to automatically generate that number of default names and labels (param1, p_{1}, etc.)
  • names – a list of name strings to use
class getdist.types.MargeStats(fileName=None, setParamNameFile=None, default=0, names=None)[source]

Stores marginalized 1D parameter statistics, including mean, variance and confidence limits, inheriting from ParamResults.

Values are stored as attributes of the ParamInfo objects stored in self.names. Use par= margeStats.parWithName(‘xxx’) to get the ParamInfo for parameter xxx; Values stored are:

  • par.mean: parameter mean
  • par.err: standard deviation
  • limits: list of ParamLimit objects for the stored number of marginalized limits

For example to get the first and second lower limits (default 68% and 95%) for parameter xxx:

print(margeStats.names.parWithName('xxx').limits[0].lower)
print(margeStats.names.parWithName('xxx').limits[1].lower)

See ParamLimit for details of limits.

Parameters:
  • fileName – name of .paramnames file to load from
  • setParamNameFile – override specific parameter names’ labels using another file
  • default – set to int>0 to automatically generate that number of default names and labels (param1, p_{1}, etc.)
  • names – a list of name strings to use
loadFromFile(filename)[source]

Load from a plain text file

Parameters:filename – file to load from
class getdist.types.ParamLimit(minmax, tag='two')[source]

Class containing information about a marginalized parameter limit.

Variables:
  • lower – lower limit
  • upper – upper limit
  • twotail – True if a two-tail limit, False if one-tail
  • onetail_upper – True if one-tail upper limit
  • ontail_lower – True if one-tail lower limit
Parameters:
  • minmax – a [min,max] tuple with lower and upper limits. Entries be None if no limit.
  • tag – a text tag descibing the limit, one of [‘two’ | ‘>’ | ‘<’ | ‘none’]
limitTag()[source]
Returns:Short text tag describing the type of limit (one-tail or two tail):
  • two: two-tail limit
  • >: a one-tail upper limit
  • <: a one-tail lower limit
  • none: no limits (both boundaries have high probability)
limitType()[source]
Returns:a text description of the type of limit. One of:
  • two tail
  • one tail upper limit
  • one tail lower limit
  • none
class getdist.types.ParamResults(fileName=None, setParamNameFile=None, default=0, names=None)[source]

Base class for a set of parameter results, inheriting from ParamList, so that self.names is a list of ParamInfo instances for each parameter, which have attribute holding results for the different parameters.

Parameters:
  • fileName – name of .paramnames file to load from
  • setParamNameFile – override specific parameter names’ labels using another file
  • default – set to int>0 to automatically generate that number of default names and labels (param1, p_{1}, etc.)
  • names – a list of name strings to use
class getdist.types.ResultTable(ncol, results, limit=2, tableParamNames=None, titles=None, formatter=None, numFormatter=None, blockEndParams=None, paramList=None, refResults=None, shiftSigma_indep=False, shiftSigma_subset=False)[source]

Class for holding a latex table of parameter statistics

Parameters:
  • ncol – number of columns
  • results – a MargeStats or BestFit instance, or a list of them for comparing different results
  • limit – which limit to include (1 is first limit calculated, usually 68%, 2 the second, usually 95%)
  • tableParamNames – optional ParamNames instance listing particular parameters to include
  • titles – optional titles describing different results
  • formatter – a table formatting class
  • numFormatter – a number formatting class
  • blockEndParams – mark parameters in blocks, ending on this list of parameter names
  • paramList – a list of parameter names (strings) to include
  • refResults – for showing parameter shifts, a reference MargeStats instance to show differences to
  • shiftSigma_indep – show parameter shifts in sigma assuming data are independent
  • shiftSigma_subset – show parameter shifts in sigma assuming data are a subset of each other
tablePNG(dpi=None, latex_preamble=None, filename=None, bytesIO=False)[source]

Get a .png file image of the table. You must have latex installed to use this.

Parameters:
  • dpi – dpi settings for the png
  • latex_preamble – any latex preamble
  • filename – filename to save to (defaults to file in the temp directory)
  • bytesIO – if True, return a BytesIO instance holding the .png data
Returns:

if bytesIO, the BytesIO instance, otherwise name of the output file

tableTex(document=False, latex_preamble=None, packages=['amsmath', 'amssymb', 'bm'])[source]

Get the latex string for the table

Parameters:
  • document – if True, make a full latex file, if False just the snippet for including in another file
  • latex_preamble – any preamble to include in the latex file
  • packages – list of packages to load
write(fname, **kwargs)[source]

Write the latex for the table to a file

Parameters:
  • fname – filename to write
  • kwargs – arguments for tableTex()
getdist.types.float_to_decimal(f)[source]

Convert a floating point number to a Decimal with no loss of information