Beispiel #1
0
    def testArctan2Execution(self):
        x = tensor(1)  # scalar
        y = arctan2(x, x)

        self.assertFalse(y.issparse())
        result = self.executor.execute_tensor(y, concat=True)[0]
        np.testing.assert_equal(result, np.arctan2(1, 1))

        y = arctan2(0, x)

        self.assertFalse(y.issparse())
        result = self.executor.execute_tensor(y, concat=True)[0]
        np.testing.assert_equal(result, np.arctan2(0, 1))

        raw1 = np.array([[0, 1, 2]])
        raw2 = sps.csr_matrix([[0, 1, 0]])
        y = arctan2(raw1, raw2)

        self.assertFalse(y.issparse())
        result = self.executor.execute_tensor(y, concat=True)[0]
        np.testing.assert_equal(result, np.arctan2(raw1, raw2.A))

        y = arctan2(raw2, raw2)

        self.assertTrue(y.issparse())
        result = self.executor.execute_tensor(y, concat=True)[0]
        np.testing.assert_equal(result, np.arctan2(raw2.A, raw2.A))

        y = arctan2(0, raw2)

        self.assertTrue(y.issparse())
        result = self.executor.execute_tensor(y, concat=True)[0]
        np.testing.assert_equal(result, np.arctan2(0, raw2.A))
Beispiel #2
0
def test_arctan2_execution(setup):
    x = tensor(1)  # scalar
    y = arctan2(x, x)

    assert y.issparse() is False
    result = y.execute().fetch()
    np.testing.assert_equal(result, np.arctan2(1, 1))

    y = arctan2(0, x)

    assert y.issparse() is False
    result = y.execute().fetch()
    np.testing.assert_equal(result, np.arctan2(0, 1))

    raw1 = np.array([[0, 1, 2]])
    raw2 = sps.csr_matrix([[0, 1, 0]])
    y = arctan2(raw1, raw2)

    assert y.issparse() is False
    result = y.execute().fetch()
    np.testing.assert_equal(result, np.arctan2(raw1, raw2.A))

    y = arctan2(raw2, raw2)

    assert y.issparse() is True
    result = y.execute().fetch()
    np.testing.assert_equal(result, np.arctan2(raw2.A, raw2.A))

    y = arctan2(0, raw2)

    assert y.issparse() is True
    result = y.execute().fetch()
    np.testing.assert_equal(result, np.arctan2(0, raw2.A))