How to use the slider.element_wise.ElementWise function in slider

To help you get started, we’ve selected a few slider examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github llllllllll / slider / slider / element_wise.py View on Github external
----------
    lhs, rhs : ElementWise or scalar
        The objects to broadcast together.

    Returns
    -------
    lhs, rhs : ElementWise
        The broadcasted operands.

    Raises
    -------
    ValueError
        Raised when the operands cannot be broadcasted together.
    """
    if not isinstance(lhs, ElementWise):
        lhs = ElementWise([lhs])
    if not isinstance(rhs, ElementWise):
        rhs = ElementWise([rhs])

    if len(lhs) == len(rhs):
        return lhs, rhs

    if len(lhs) == 1:
        return ElementWise([lhs._elements[0]] * len(rhs)), rhs

    if len(rhs) == 1:
        return lhs, ElementWise([rhs._elements[0]] * len(lhs))

    raise bad_broadcast(lhs, rhs)
github llllllllll / slider / slider / element_wise.py View on Github external
The objects to broadcast together.

    Returns
    -------
    lhs, rhs : ElementWise
        The broadcasted operands.

    Raises
    -------
    ValueError
        Raised when the operands cannot be broadcasted together.
    """
    if not isinstance(lhs, ElementWise):
        lhs = ElementWise([lhs])
    if not isinstance(rhs, ElementWise):
        rhs = ElementWise([rhs])

    if len(lhs) == len(rhs):
        return lhs, rhs

    if len(lhs) == 1:
        return ElementWise([lhs._elements[0]] * len(rhs)), rhs

    if len(rhs) == 1:
        return lhs, ElementWise([rhs._elements[0]] * len(lhs))

    raise bad_broadcast(lhs, rhs)
github llllllllll / slider / slider / element_wise.py View on Github external
def op(self, other):
        if (not isinstance(self, ElementWise) and
                not isinstance(other, ElementWise)):
                return operator(self, other)

        return ElementWise(list(map(operator, *broadcast(self, other))))
    op.__doc__ = doc
github llllllllll / slider / slider / element_wise.py View on Github external
def op(self):
        if not isinstance(self, ElementWise):
            return operator(self)

        return ElementWise(list(map(operator, self)))
github llllllllll / slider / slider / element_wise.py View on Github external
ValueError
        Raised when the operands cannot be broadcasted together.
    """
    if not isinstance(lhs, ElementWise):
        lhs = ElementWise([lhs])
    if not isinstance(rhs, ElementWise):
        rhs = ElementWise([rhs])

    if len(lhs) == len(rhs):
        return lhs, rhs

    if len(lhs) == 1:
        return ElementWise([lhs._elements[0]] * len(rhs)), rhs

    if len(rhs) == 1:
        return lhs, ElementWise([rhs._elements[0]] * len(lhs))

    raise bad_broadcast(lhs, rhs)
github llllllllll / slider / slider / element_wise.py View on Github external
def op(self, other):
        return ElementWise(list(map(operator, *broadcast(other, self))))
github llllllllll / slider / slider / element_wise.py View on Github external
def __getitem__(self, ix):
        elements = self._elements
        try:
            return elements[ix]
        except TypeError:
            pass

        if isinstance(ix[0], bool):
            if len(self) != len(ix):
                raise bad_broadcast(self, ix)
            return ElementWise(list(compress(elements, ix)))

        return ElementWise([elements[i] for i in ix])