2 GTSAM Copyright 2010-2019, Georgia Tech Research Corporation, 
    3 Atlanta, Georgia 30332-0415 
    6 See LICENSE for the license information 
    9 Author: Frank Dellaert & Gerry Chen (Python) 
   21     Tests FitBasis python binding for FourierBasis, Chebyshev1Basis, Chebyshev2Basis, and Chebyshev2. 
   23     It tests FitBasis by fitting to a ground-truth function that can be represented exactly in 
   24     the basis, then checking that the regression (fit result) matches the function.  For the 
   25     Chebyshev bases, the line y=x is used to generate the data while for Fourier, 0.7*cos(x) is 
   31         self.
x = [0., 0.5, 0.75]
 
   37         Until wrapper for Basis functors are ready, 
   38         this is how to evaluate a basis function. 
   40         return basis.WeightMatrix(self.
N, x) @ fitparams
 
   43         """Helper method to fit data to a specified fitter using a specified basis.""" 
   44         data = {x: 
f(x) 
for x 
in self.
x}
 
   45         fit = fitter(data, self.
noise, self.
N)
 
   46         coeff = fit.parameters()
 
   51         """Fit a Fourier basis.""" 
   53         f = 
lambda x: 0.7 * np.cos(x)
 
   57         np.testing.assert_almost_equal(interpy,
 
   58                                        np.array([
f(x) 
for x 
in self.
interpx]),
 
   62         """Fit a Chebyshev1 basis.""" 
   68         np.testing.assert_almost_equal(interpy,
 
   69                                        np.array([
f(x) 
for x 
in self.
interpx]),
 
   73         """Fit a Chebyshev2 basis.""" 
   79         np.testing.assert_almost_equal(interpy,
 
   80                                        np.array([
f(x) 
for x 
in self.
interpx]),
 
   84         """Fit a Chebyshev2 pseudospectral basis.""" 
   90         np.testing.assert_almost_equal(interpy,
 
   91                                        np.array([
f(x) 
for x 
in self.
interpx]),
 
   95 if __name__ == 
"__main__":