Source code for solrat.engine.functions.looping
import numpy as np
[docs]
def fromto(a, b):
"""Inclusive Range"""
return (float(x) for x in np.arange(a, b + 1))
[docs]
def FROMTO(a, b):
"""Inclusive Range"""
return f"fromto({a}, {b})"
[docs]
def triangular(a, b):
r"""Triangular Range: from :math:`|a-b|` to :math:`a+b`"""
return fromto(abs(a - b), a + b)
[docs]
def TRIANGULAR(a, b):
r"""Triangular Range: from :math:`|a-b|` to :math:`a+b`"""
return f"triangular({a}, {b})"
[docs]
def intersection(*args):
"""Intersect ranges"""
sets = [set(arg) for arg in args]
return tuple(set.intersection(*sets))
[docs]
def INTERSECTION(*args):
"""Intersect ranges"""
return f"intersection({', '.join(args)})"
[docs]
def projection(a):
"""Range from -a to a (inclusive)"""
return fromto(-a, a)
[docs]
def PROJECTION(a):
"""Range from -a to a (inclusive)"""
return f"projection({a})"
[docs]
def VALUE(a):
"""Just single value"""
return f"({a},)"