How to use the syft.equal function in syft

To help you get started, we’ve selected a few syft 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 OpenMined / PySyft / tests / test_math.py View on Github external
def test_sin(self):
        # int
        t1 = TensorBase(np.array([[3, 1, 2], [0, -1, 2]]))
        t2 = syft.math.sin(t1)
        self.assertTrue(syft.equal(t1.data, np.array([[3, 1, 2], [0, -1, 2]])))
        self.assertTrue(syft.equal(t2.data, np.sin(np.array([[3, 1, 2], [0, -1, 2]]))))
        # float
        t1 = TensorBase(np.array([[3.3, 1.3, 2.2], [0.0, -1.3, 2.4]]))
        t2 = syft.math.sin(t1)
        self.assertTrue(syft.equal(t1.data, np.array([[3.3, 1.3, 2.2], [0.0, -1.3, 2.4]])))
        self.assertTrue(syft.equal(t2.data, np.sin(np.array([[3.3, 1.3, 2.2], [0.0, -1.3, 2.4]]))))
github OpenMined / PySyft / tests / test_tensor.py View on Github external
def test_ceil(self):
        t = TensorBase(np.array([1.4, 2.7, 6.2]))
        tdash = t.ceil()
        self.assertTrue(syft.equal(tdash.data, TensorBase([2, 3, 7])))
        self.assertTrue(syft.equal(t.data, TensorBase([1.4, 2.7, 6.2])))
github OpenMined / PySyft / tests / test_math.py View on Github external
def test_cos(self):
        # int
        t1 = TensorBase(np.array([[3, 1, 2], [0, -1, 2]]))
        t2 = syft.math.cos(t1)
        self.assertTrue(syft.equal(t1.data, np.array([[3, 1, 2], [0, -1, 2]])))
        self.assertTrue(syft.equal(t2.data, np.cos(np.array([[3, 1, 2], [0, -1, 2]]))))
        # float
        t1 = TensorBase(np.array([[3.3, 1.3, 2.2], [0.0, -1.3, 2.4]]))
        t2 = syft.math.cos(t1)
        self.assertTrue(syft.equal(t1.data, np.array([[3.3, 1.3, 2.2], [0.0, -1.3, 2.4]])))
        self.assertTrue(syft.equal(t2.data, np.cos(np.array([[3.3, 1.3, 2.2], [0.0, -1.3, 2.4]]))))
github OpenMined / PySyft / tests / test_tensor.py View on Github external
def test_scalar(self):
        t = TensorBase(np.array([1, 2, 3]))
        self.assertTrue(syft.equal(t * 2, [2, 4, 6]))
github OpenMined / PySyft / tests / test_math.py View on Github external
def test_cumprod(self):
        t1 = TensorBase(np.array([1, 2, 3]))
        self.assertTrue(syft.equal(syft.cumprod(t1), TensorBase([1, 2, 6])))
github OpenMined / PySyft / tests / test_tensor.py View on Github external
def test_two_dim_tensor_main_diag(self):
        t = TensorBase(np.array([[0, 1], [2, 3]]))
        tdiag = t.diag()
        self.assertTrue(syft.equal(tdiag.data, TensorBase(np.array([0, 3]))))
github OpenMined / PySyft / tests / test_math.py View on Github external
def test_cosh(self):
        # int
        t1 = TensorBase(np.array([[3, 1, 2], [0, -1, 2]]))
        t2 = syft.math.cosh(t1)
        self.assertTrue(syft.equal(t1.data, np.array([[3, 1, 2], [0, -1, 2]])))
        self.assertTrue(syft.equal(t2.data, np.cosh(np.array([[3, 1, 2], [0, -1, 2]]))))
        # float
        t1 = TensorBase(np.array([[3.3, 1.3, 2.2], [0.0, -1.3, 2.4]]))
        t2 = syft.math.cosh(t1)
        self.assertTrue(syft.equal(t1.data, np.array([[3.3, 1.3, 2.2], [0.0, -1.3, 2.4]])))
        self.assertTrue(syft.equal(t2.data, np.cosh(np.array([[3.3, 1.3, 2.2], [0.0, -1.3, 2.4]]))))
github OpenMined / PySyft / tests / test_math.py View on Github external
def test_tan(self):
        # int
        t1 = TensorBase(np.array([[3, 1, 2], [0, -1, 2]]))
        t2 = syft.math.tan(t1)
        self.assertTrue(syft.equal(t1.data, np.array([[3, 1, 2], [0, -1, 2]])))
        self.assertTrue(syft.equal(t2.data, np.tan(np.array([[3, 1, 2], [0, -1, 2]]))))
        # float
        t1 = TensorBase(np.array([[3.3, 1.3, 2.2], [0.0, -1.3, 2.4]]))
        t2 = syft.math.tan(t1)
        self.assertTrue(syft.equal(t1.data, np.array([[3.3, 1.3, 2.2], [0.0, -1.3, 2.4]])))
        self.assertTrue(syft.equal(t2.data, np.tan(np.array([[3.3, 1.3, 2.2], [0.0, -1.3, 2.4]]))))
github OpenMined / PySyft / tests / test_tensor.py View on Github external
def test_shape(self):
        t = TensorBase(np.array([[0, 1], [0, 5]]))
        self.assertTrue(syft.equal(t.shape(), (2, 2)))
github OpenMined / PySyft / tests / test_tensor.py View on Github external
def test_two_dim_tensor_below_diag(self):
        t = TensorBase(np.array([[0, 1], [2, 3]]))
        tdiag = t.diag(-1)
        self.assertTrue(syft.equal(tdiag.data, TensorBase(np.array([2]))))