code: def test_pmf_from_array():
      sphere = HemiSphere.from_sphere(unit_octahedron)
      pmfgen = SimplePmfGen(
          np.ones([2, 2, 2, len(sphere.vertices)]), sphere
      )
  
      # Test that the pmf is greater than 0 for a valid point
      pmf = pmfgen.get_pmf(np.array([0, 0, 0], dtype="float"))
      npt.assert_equal(np.sum(pmf) > 0, True)
  
      # Test that the pmf is 0 for invalid Points
      npt.assert_array_equal(
          pmfgen.get_pmf(np.array([-1, 0, 0], dtype="float")),
          np.zeros(len(sphere.vertices)),
      )
      npt.assert_array_equal(
          pmfgen.get_pmf(np.array([0, 0, 10], dtype="float")),
          np.zeros(len(sphere.vertices)),
      )
  
      # Test ValueError for negative pmf
      npt.assert_raises(
          ValueError,
          lambda: SimplePmfGen(
              np.ones([2, 2, 2, len(sphere.vertices)]) * -1, sphere
          ),
      )
      # Test ValueError for non matching pmf and sphere
      npt.assert_raises(
          ValueError,
          lambda: SimplePmfGen(
              np.ones([2, 2, 2, len(sphere.vertices)]), default_sphere
          ),
      )
  
file_path: dipy/dipy/direction/tests/test_pmf.py
imports: import warnings
  import numpy
  import numpy.testing
  from dipy.core.gradients import gradient_table
  from dipy.core.sphere import HemiSphere, unit_octahedron
  from dipy.data import default_sphere, get_sphere
  from dipy.reconst import shm
  from dipy.direction.pmf import SimplePmfGen, SHCoeffPmfGen
  from dipy.reconst.csdeconv import ConstrainedSphericalDeconvModel
  from dipy.reconst.dti import TensorModel
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 3 for calling a global function with example usage: test_pmf_from_array() without return types