def test_polar2cart_n_cart2polar(): r = 5 t = linspace(0, pi, 20) x, y = polar2cart(t, r) assert_array_almost_equal( x, np.array( [5., 4.93180652, 4.72908621, 4.39736876, 3.94570255, 3.38640786, 2.73474079, 2.00847712, 1.22742744, 0.41289673, -0.41289673, -1.22742744, -2.00847712, -2.73474079, -3.38640786, -3.94570255, -4.39736876, -4.72908621, -4.93180652, -5.])) assert_array_almost_equal( y, np.array( [0.00000000e+00, 8.22972951e-01, 1.62349735e+00, 2.37973697e+00, 3.07106356e+00, 3.67861955e+00, 4.18583239e+00, 4.57886663e+00, 4.84700133e+00, 4.98292247e+00, 4.98292247e+00, 4.84700133e+00, 4.57886663e+00, 4.18583239e+00, 3.67861955e+00, 3.07106356e+00, 2.37973697e+00, 1.62349735e+00, 8.22972951e-01, 6.12323400e-16])) ti, ri = cart2polar(x, y) assert_array_almost_equal( ti, np.array( [0., 0.16534698, 0.33069396, 0.49604095, 0.66138793, 0.82673491, 0.99208189, 1.15742887, 1.32277585, 1.48812284, 1.65346982, 1.8188168, 1.98416378, 2.14951076, 2.31485774, 2.48020473, 2.64555171, 2.81089869, 2.97624567, 3.14159265])) assert_array_almost_equal( ri, np.array( [5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5.]))