def test_polar_to_cartesian():
 r = 1
 theta = np.pi
 x = (r * np.cos(theta))
 y = (r * np.sin(theta))
 coord = _pol_to_cart(np.array([[r, theta]]))[0]
 assert_allclose(coord, (x, y), atol=1e-07)
 assert_allclose(coord, ((-1), 0), atol=1e-07)
 assert_allclose(coord, _polar_to_cartesian(theta, r), atol=1e-07)
 rng = np.random.RandomState(0)
 r = rng.randn(10)
 theta = (rng.rand(10) * (2 * np.pi))
 polar = np.array((r, theta)).T
 assert_allclose([_polar_to_cartesian(p[1], p[0]) for p in polar], _pol_to_cart(polar), atol=1e-07)

def test_polar_to_cartesian ( ) : r = 1 theta = np . pi x = ( r * np . cos ( theta ) ) y = ( r * np . sin ( theta ) ) coord = _pol_to_cart ( np . array ( [ [ r , theta ] ] ) ) [ 0 ] assert_allclose ( coord , ( x , y ) , atol = 1e-07 ) assert_allclose ( coord , ( ( - 1 ) , 0 ) , atol = 1e-07 ) assert_allclose ( coord , _polar_to_cartesian ( theta , r ) , atol = 1e-07 ) rng = np . random . RandomState ( 0 ) r = rng . randn ( 10 ) theta = ( rng . rand ( 10 ) * ( 2 * np . pi ) ) polar = np . array ( ( r , theta ) ) . T assert_allclose ( [ _polar_to_cartesian ( p [ 1 ] , p [ 0 ] ) for p in polar ] , _pol_to_cart ( polar ) , atol = 1e-07 )
test helper transform function from polar to cartesian .