Beispiel #1
0
 def test_fmod_tensor(self):
     t1 = TensorBase(np.array([-3, -2, -1, 1, 2, 3]))
     divisor = np.array([2] * 6)
     self.assertTrue(np.array_equal(t1.fmod(divisor).data, np.array([-1, 0, -1, 1, 0, 1])))
     t2 = TensorBase(np.array([-3.5, -2.5, -1.5, 1.5, 2.5, 3.5]))
     divisor = np.array([2.] * 6)
     self.assertTrue(np.array_equal(t2.fmod(divisor).data, np.array([-1.5, -0.5, -1.5, 1.5, 0.5, 1.5])))
Beispiel #2
0
 def test_fmod_broadcasting(self):
     t = TensorBase([[-2, -3], [4, 1]])
     result = t.fmod([2, -3])
     self.assertTrue(np.array_equal(result.data, np.array([[0, 0], [0,
                                                                    1]])))
Beispiel #3
0
 def test_fmod_number(self):
     t1 = TensorBase(np.array([-3, -2, -1, 1, 2, 3]))
     self.assertTrue(np.array_equal(t1.fmod(2).data, np.array([-1, 0, -1, 1, 0, 1])))
     t2 = TensorBase(np.array([-3.5, -2.5, -1.5, 1.5, 2.5, 3.5]))
     self.assertTrue(np.array_equal(t2.fmod(2.).data, np.array([-1.5, -0.5, -1.5, 1.5, 0.5, 1.5])))
Beispiel #4
0
 def test_fmod(self):
     t = TensorBase([[-2, -3], [4, 1]])
     result = t.fmod(1.5)
     self.assertTrue(
         np.array_equal(result.data, np.array([[-0.5, -0], [1, 1]])))