code: def test_check_cast_bin8():
      # Function to return np.uint8 array with check whether array is binary.
      for in_dtype in np.sctypes["int"] + np.sctypes["uint"]:
          assert_equal_bin8(
              np.array([0, 1, 1, 1], in_dtype), [0, 1, 1, 1]
          )
          assert_equal_bin8(
              np.array([[0, 1], [1, 1]], in_dtype), [[0, 1], [1, 1]]
          )
          pytest.raises(
              ValueError,
              check_cast_bin8,
              np.array([0, 1, 2], dtype=in_dtype),
          )
      for in_dtype in np.sctypes["float"]:
          assert_equal_bin8(
              np.array([0, 1, 1, -0], np.float64), [0, 1, 1, 0]
          )
          assert_equal_bin8(
              np.array([[0, 1], [1, -0]], np.float64), [[0, 1], [1, 0]]
          )
          pytest.raises(
              ValueError,
              check_cast_bin8,
              np.array([0, 0.1, 1], dtype=in_dtype),
          )
          pytest.raises(
              ValueError,
              check_cast_bin8,
              np.array([0, -1, 1], dtype=in_dtype),
          )
  
file_path: nipy/nipy/algorithms/statistics/tests/test_utils.py
imports: import numpy
  import pytest
  import scipy.linalg
  from numpy.testing import assert_almost_equal, assert_array_almost_equal, assert_array_equal
  from scipy.stats import norm
  from ..utils import check_cast_bin8, multiple_fast_inv, multiple_mahalanobis, z_score
label_desc: Use image node_id 6 for calling a global function with example usage: test_check_cast_bin8() without return types