def test_polynomial_bases(self):
     data = helper.load_test_npz('test_points_10_2.npz')
     X = data['X']
     data = helper.load_test_npz('test_poly_bases_3.npz')
     B, I = rs.polynomial_bases(X, 3)
     np.testing.assert_equal(B, data['B'])
     np.testing.assert_equal(I, data['I'])
Example #2
0
 def test_polynomial_bases(self):
     data = helper.load_test_npz('test_points_10_2.npz')
     X = data['X']
     data = helper.load_test_npz('test_poly_bases_3.npz')
     B, I = rs.polynomial_bases(X, 3)
     np.testing.assert_equal(B, data['B'])
     np.testing.assert_equal(I, data['I'])
    def test_grad_polynomial_bases_fd(self):
        np.random.seed(42)
        X0 = np.random.normal(size=(10, 2))

        dB = rs.grad_polynomial_bases(X0, 3)
        e = 1e-6
        B0 = rs.polynomial_bases(X0, 3)[0]

        X1 = X0.copy()
        X1[:, 0] += e
        B1 = rs.polynomial_bases(X1, 3)[0]
        dB1 = (B1 - B0) / e
        np.testing.assert_array_almost_equal(dB[:, :, 0], dB1, decimal=5)

        X2 = X0.copy()
        X2[:, 1] += e
        B2 = rs.polynomial_bases(X2, 3)[0]
        dB2 = (B2 - B0) / e
        np.testing.assert_array_almost_equal(dB[:, :, 1], dB2, decimal=5)
    def test_grad_polynomial_bases_fd(self):
        np.random.seed(42)
        X0 = np.random.normal(size=(10, 2))

        dB = rs.grad_polynomial_bases(X0, 3)
        e = 1e-6
        B0 = rs.polynomial_bases(X0, 3)[0]

        X1 = X0.copy()
        X1[:, 0] += e
        B1 = rs.polynomial_bases(X1, 3)[0]
        dB1 = (B1 - B0) / e
        np.testing.assert_array_almost_equal(dB[:, :, 0], dB1, decimal=5)

        X2 = X0.copy()
        X2[:, 1] += e
        B2 = rs.polynomial_bases(X2, 3)[0]
        dB2 = (B2 - B0) / e
        np.testing.assert_array_almost_equal(dB[:, :, 1], dB2, decimal=5)
    def test_polynomial_bases(self):
        data = helper.load_test_npz('test_points_10_2.npz')
        X = data['X']

        B, I = rs.polynomial_bases(X, 3)
        if self.writeData:
            np.savez('data/test_poly_bases_3.npz', B=B, I=I)
        data = helper.load_test_npz('test_poly_bases_3.npz')
        np.testing.assert_almost_equal(B, data['B'])
        np.testing.assert_almost_equal(I, data['I'])
 def test_grad_polynomial_bases_fd(self):
     data = helper.load_test_npz('test_points_10_2.npz')
     X0 = data['X']
     data = helper.load_test_npz('test_grad_poly_bases_3.npz')
     
     dB = rs.grad_polynomial_bases(X0, 3)
     e = 1e-6
     B0 = rs.polynomial_bases(X0, 3)[0]
     
     X1 = X0.copy()
     X1[:,0] += e
     B1 = rs.polynomial_bases(X1, 3)[0]
     dB1 = (B1 - B0)/e
     np.testing.assert_array_almost_equal(dB[:,:,0], dB1, decimal=5)
     
     X2 = X0.copy()
     X2[:,1] += e
     B2 = rs.polynomial_bases(X2, 3)[0]
     dB2 = (B2 - B0)/e
     np.testing.assert_array_almost_equal(dB[:,:,1], dB2, decimal=5)
Example #7
0
    def test_grad_polynomial_bases_fd(self):
        data = helper.load_test_npz('test_points_10_2.npz')
        X0 = data['X']
        data = helper.load_test_npz('test_grad_poly_bases_3.npz')

        dB = rs.grad_polynomial_bases(X0, 3)
        e = 1e-6
        B0 = rs.polynomial_bases(X0, 3)[0]

        X1 = X0.copy()
        X1[:, 0] += e
        B1 = rs.polynomial_bases(X1, 3)[0]
        dB1 = (B1 - B0) / e
        np.testing.assert_array_almost_equal(dB[:, :, 0], dB1, decimal=5)

        X2 = X0.copy()
        X2[:, 1] += e
        B2 = rs.polynomial_bases(X2, 3)[0]
        dB2 = (B2 - B0) / e
        np.testing.assert_array_almost_equal(dB[:, :, 1], dB2, decimal=5)
 def test_polynomial_bases(self):
     np.random.seed(42)
     X = np.random.normal(size=(10, 2))
     B, I = rs.polynomial_bases(X, 3)
 def test_polynomial_bases(self):
     np.random.seed(42)
     X = np.random.normal(size=(10, 2))
     B, I = rs.polynomial_bases(X, 3)