Utilities module (analphipy.utils)#

Functions:

combine_segmets(a, b)

Combine two lists of segments.

is_float(val)

Type guard for float.

quad_segments(func, segments[, args, ...])

Perform quadrature with discontinuities.

minimize_phi(phi, r0[, bounds])

Find value of r which minimized phi.

segments_to_segments_cut(segments, rcut)

Update segments for 'cut' potential.

analphipy.utils.combine_segmets(a, b)[source]#

Combine two lists of segments.

Parameters:

a, b (array-like) – list of segments.

Returns:

combined (list of float) – sorted unique values for a and b.

analphipy.utils.is_float(val)[source]#

Type guard for float.

Use to type narrow output for quad_segments

analphipy.utils.quad_segments(func, segments, args=(), full_output=False, sum_integrals=True, sum_errors=False, err=True, **kws)[source]#

Perform quadrature with discontinuities.

Parameters:
  • func (callable()) – function to be integrated

  • segments (sequence of int) – Integration limits. For n = len(segments) integration will be performed over ranges (segments[0], segments[1]), (segments[1], segments[2]), ..., (segments[n-2], segments[n-]])

  • args (tuple, optional) – Extra positional arguments to func.

  • full_output (bool, default False) – If True, return extra information.

  • sum_integrals (bool, default True) – If True, sum the segments in the output.

  • sum_errors (bool, default True) – If True and returning error sum errors.

  • err (bool, default True) – If True, return error.

  • **kws – Extra arguments to scipy.integrate.quad()

Returns:

  • integral (float or list of float) – If sum_integrals, this is the sum of integrals over each segment. Otherwise return list of values corresponding to integral in each segment.

  • errors (float or list of float, optional) – If err or full_output are True, then return error. If sum_errors, then sum of errors Across segments.

  • outputs (object) – Output from scipy.integrate.quad(). If multiple segments, return a list of output.

analphipy.utils.minimize_phi(phi, r0, bounds=None, **kws)[source]#

Find value of r which minimized phi.

Parameters:
Returns:

analphipy.utils.segments_to_segments_cut(segments, rcut)[source]#

Update segments for ‘cut’ potential.