Skip to content

_utils

Full documentation pages are generated for docstring reference only and may contain symbols imported from other modules. Imported symbols are not distinguished from locally defined symbols and will appear in any module that they are imported into. For better information on where symbols should be imported from, review the sourcecode on the github.

FoSpy.ui.sliders._utils

DEF_DIGITS module-attribute

DEF_DIGITS = 2

_ceil_to

_ceil_to(x, digits)
Source code in FoSpy/_utils.py
def _ceil_to(x, digits):
    return math.ceil(x * 10**digits) / 10**digits

_floor_to

_floor_to(x, digits)
Source code in FoSpy/_utils.py
def _floor_to(x, digits):
    return math.floor(x * 10**digits) / 10**digits

_get_digits

_get_digits(spec)
Source code in FoSpy/ui/sliders/_utils.py
def _get_digits(spec):
    from ...config import values as cfg
    default = cfg.get("slider_digits.default", DEF_DIGITS)
    return spec.get("digits", default)

_round_spec

_round_spec(x, digits, key=None, include=True)
Source code in FoSpy/ui/sliders/_utils.py
def _round_spec(x, digits, key=None, include=True):
    if isinstance(x, list or tuple):
        return [_round_spec(xi, digits) for xi in x]
    elif key == "min":
        val = _floor_to(x, digits)
        if not include:
            val += 10**-digits
        return val
    elif key == "max":
        val = _ceil_to(x, digits)
        if not include:
            val -= 10**-digits
        return val
    elif key == "None":
        return round(x, digits)
    else:
        return round(x, digits) if x is not None else None