code: def test_sphere_cart():
      # test arrays of points
      rs, thetas, phis = cart2sphere(*sphere_points.T)
      xyz = sphere2cart(rs, thetas, phis)
      assert_array_almost_equal(xyz, sphere_points.T)
      # test radius estimation
      big_sph_pts = sphere_points * 10.4
      rs, thetas, phis = cart2sphere(*big_sph_pts.T)
      assert_array_almost_equal(rs, 10.4)
      xyz = sphere2cart(rs, thetas, phis)
      assert_array_almost_equal(xyz, big_sph_pts.T, decimal=6)
      # test that result shapes match
      x, y, z = big_sph_pts.T
      r, theta, phi = cart2sphere(x[:1], y[:1], z)
      assert_equal(r.shape, theta.shape)
      assert_equal(r.shape, phi.shape)
      x, y, z = sphere2cart(r[:1], theta[:1], phi)
      assert_equal(x.shape, y.shape)
      assert_equal(x.shape, z.shape)
      # test a scalar point
      pt = sphere_points[3]
      r, theta, phi = cart2sphere(*pt)
      xyz = sphere2cart(r, theta, phi)
      assert_array_almost_equal(xyz, pt)
  
      # Test full circle on x=1, y=1, z=1
      x, y, z = sphere2cart(*cart2sphere(1.0, 1.0, 1.0))
      assert_array_almost_equal((x, y, z), (1.0, 1.0, 1.0))
  
imports: import numpy
  import random
  from dipy.core.geometry import sphere2cart, cart2sphere, nearest_pos_semi_def, sphere_distance, cart_distance, vector_cosine, lambert_equal_area_projection_polar, circumradius, vec2vec_rotmat, vector_norm, compose_transformations, compose_matrix, decompose_matrix, perpendicular_directions, dist_to_corner, is_hemispherical
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_equal, assert_raises, assert_almost_equal
  from dipy.testing.spherepoints import sphere_points
  from dipy.testing.decorators import set_random_number_generator
  from dipy.core.sphere_stats import random_uniform_on_sphere
  from itertools import permutations
label_desc: Use image node_id 2 for calling a global function with example usage: test_sphere_cart() without return types