pyccl.pyutils module

Utility functions to analyze status and error messages passed from CCL, as well as wrappers to automatically vectorize functions.

class pyccl.pyutils.ExtrapolationMethods(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

NONE = 'none'
CONSTANT = 'constant'
LINX_LINY = 'linx_liny'
LINX_LOGY = 'linx_logy'
LOGX_LINY = 'logx_liny'
LOGX_LOGY = 'logx_logy'
class pyccl.pyutils.IntegrationMethods(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

QAG_QUAD = 'qag_quad'
SPLINE = 'spline'
pyccl.pyutils.debug_mode(debug)[source]

Toggle debug mode on or off. If debug mode is on, the C backend is forced to print error messages as soon as they are raised, even if the flow of the program continues. This makes it easier to track down errors.

If debug mode is off, the C code will not print errors, and the Python wrapper will raise the last error that was detected. If multiple errors were raised, all but the last will be overwritten within the C code, so the user will not necessarily be informed of the root cause of the error.

Parameters:

debug (bool) – Switch debug mode on (True) or off (False).

pyccl.pyutils.resample_array(x_in, y_in, x_out, extrap_lo='none', extrap_hi='none', fill_value_lo=0, fill_value_hi=0)[source]

Interpolates an input y array onto a set of x values.

Parameters:
  • x_in (array) – input x-values.

  • y_in (array) – input y-values.

  • x_out (array) – x-values for output array.

  • extrap_lo (str) – type of extrapolation for x-values below the range of x_in. ‘none’ (for no interpolation), ‘constant’, ‘linx_liny’ (linear in x and y), ‘linx_logy’, ‘logx_liny’ and ‘logx_logy’.

  • extrap_hi (str) – type of extrapolation for x-values above the range of x_in.

  • fill_value_lo (float) – constant value if extrap_lo is ‘constant’.

  • fill_value_hi (float) – constant value if extrap_hi is ‘constant’.

Returns:

output array.

Return type:

array