@@ -313,7 +313,7 @@ def test_flat_cost_constr(self, basis):
313313 np .testing .assert_array_almost_equal (uf , u_const [:, - 1 ])
314314
315315 # Make sure that the solution respects the bounds (with some slop)
316- for i in range (x_const .shape [0 ]):
316+ for i in range (x_const .shape [0 ]):
317317 assert all (lb [i ] - x_const [i ] < rtol * abs (lb [i ]) + atol )
318318 assert all (x_const [i ] - ub [i ] < rtol * abs (ub [i ]) + atol )
319319
@@ -673,3 +673,43 @@ def test_response(self, xf, uf, Tf):
673673 np .testing .assert_equal (T , response .time )
674674 np .testing .assert_equal (u , response .inputs )
675675 np .testing .assert_equal (x , response .states )
676+
677+ @pytest .mark .parametrize (
678+ "basis" ,
679+ [fs .PolyFamily (4 ),
680+ fs .BezierFamily (4 ),
681+ fs .BSplineFamily ([0 , 1 ], 4 ),
682+ fs .BSplineFamily ([0 , 1 ], 4 , vars = 2 ),
683+ fs .BSplineFamily ([0 , 1 ], [4 , 3 ], [2 , 1 ], vars = 2 ),
684+ ])
685+ def test_basis_class (self , basis ):
686+ timepts = np .linspace (0 , 1 , 10 )
687+
688+ if basis .nvars is None :
689+ # Evaluate function on basis vectors
690+ for j in range (basis .N ):
691+ coefs = np .zeros (basis .N )
692+ coefs [j ] = 1
693+ np .testing .assert_equal (
694+ basis .eval (coefs , timepts ),
695+ basis .eval_deriv (j , 0 , timepts ))
696+ else :
697+ # Evaluate each variable on basis vectors
698+ for i in range (basis .nvars ):
699+ for j in range (basis .var_ncoefs (i )):
700+ coefs = np .zeros (basis .var_ncoefs (i ))
701+ coefs [j ] = 1
702+ np .testing .assert_equal (
703+ basis .eval (coefs , timepts , var = i ),
704+ basis .eval_deriv (j , 0 , timepts , var = i ))
705+
706+ # Evaluate multi-variable output
707+ offset = 0
708+ for i in range (basis .nvars ):
709+ for j in range (basis .var_ncoefs (i )):
710+ coefs = np .zeros (basis .N )
711+ coefs [offset ] = 1
712+ np .testing .assert_equal (
713+ basis .eval (coefs , timepts )[i ],
714+ basis .eval_deriv (j , 0 , timepts , var = i ))
715+ offset += 1
0 commit comments