How to use the lab.B.divide function in lab

To help you get started, we’ve selected a few lab 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 wesselb / stheno / tests / test_matrix.py View on Github external
right=np.random.randn(3, 2),
                 middle=np.random.randn(2, 2))
    zero = Zero.from_(a)
    one = One.from_(a)
    constant = Constant.from_(2.0, a)
    wb = d + lr

    # Aggregate all matrices.
    candidates = [a, d, lr, wb, constant, one, zero, 2, 1, 0, 2.0, 1.0, 0.0]

    # Check division.
    allclose(a.__div__(5.0), to_np(a) / 5.0)
    allclose(a.__rdiv__(5.0), 5.0 / to_np(a))
    allclose(a.__truediv__(5.0), to_np(a) / 5.0)
    allclose(a.__rtruediv__(5.0), 5.0 / to_np(a))
    allclose(B.divide(a, 5.0), to_np(a) / 5.0)
    allclose(B.divide(a, a), B.ones(to_np(a)))

    # Check shapes.
    for m in candidates:
        assert B.shape(a) == (4, 3)

    # Check interactions.
    for m1, m2 in product(candidates, candidates):
        allclose(m1 * m2, to_np(m1) * to_np(m2))
        allclose(m1 + m2, to_np(m1) + to_np(m2))
        allclose(m1 - m2, to_np(m1) - to_np(m2))
github wesselb / stheno / stheno / matrix.py View on Github external
@B.divide.extend(Dense, Dense)
def divide(a, b): return B.multiply(a, 1 / b)
github wesselb / stheno / stheno / kernel.py View on Github external
def _compute(self, x, y):
        stretches1, stretches2 = expand(self.stretches)
        return B.divide(x, stretches1), B.divide(y, stretches2)
github wesselb / stheno / stheno / matrix.py View on Github external
def __div__(self, other):
        return B.divide(self, other)
github wesselb / stheno / stheno / kernel.py View on Github external
def feat_map(z):
            z = B.divide(B.multiply(B.multiply(z, 2), B.pi), self.period)
            return B.concat(B.sin(z), B.cos(z), axis=1)
github wesselb / stheno / stheno / kernel.py View on Github external
def __call__(self, x, y):
        dists = B.maximum(B.pw_dists(x, y), 1e-10)
        return Dense(B.divide(B.log(dists + 1), dists))
github wesselb / stheno / stheno / matrix.py View on Github external
def __truediv__(self, other):
        return B.divide(self, other)
github wesselb / stheno / stheno / mean.py View on Github external
def __call__(self, x):
        return self[0](B.divide(x, self.stretches[0]))