code: def test_lpca_dtype():
      # If out_dtype is not specified, we retain the original precision:
      S0 = 200 * np.ones((20, 20, 20, 3), dtype=np.float64)
      S0ns = localpca(S0, sigma=1)
      assert_equal(S0.dtype, S0ns.dtype)
  
      S0 = 200 * np.ones((20, 20, 20, 20), dtype=np.uint16)
      S0ns = localpca(S0, sigma=np.ones((20, 20, 20)))
      assert_equal(S0.dtype, S0ns.dtype)
  
      # If we set out_dtype, we get what we asked for:
      S0 = 200 * np.ones((20, 20, 20, 20), dtype=np.uint16)
      S0ns = localpca(
          S0, sigma=np.ones((20, 20, 20)), out_dtype=np.float32
      )
      assert_equal(np.float32, S0ns.dtype)
  
      # If we set a few entries to zero, this induces negative entries in the
      # Resulting denoised array:
      S0[5:8, 5:8, 5:8] = 0
      # But if we should always get all non-negative results:
      S0ns = localpca(
          S0, sigma=np.ones((20, 20, 20)), out_dtype=np.uint16
      )
      assert_(np.all(S0ns >= 0))
      # And no wrap-around to crazy high values:
      assert_(np.all(S0ns <= 200))
  
imports: import warnings
  import numpy
  import scipy.special
  from numpy.testing import assert_, assert_equal, assert_raises, assert_array_almost_equal, assert_warns
  from dipy.denoise.localpca import dimensionality_problem_message, create_patch_radius_arr, compute_patch_size, compute_num_samples, compute_suggested_patch_radius, localpca, mppca, genpca, _pca_classifier
  from dipy.sims.voxel import multi_tensor
  from dipy.core.gradients import gradient_table, generate_bvecs
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 8 for calling a global function with example usage: test_lpca_dtype() without return types