code: def test_assert_allclose_safely():
      # Test the safe version of allclose
      assert_allclose_safely([1, 1], [1, 1])
      assert_allclose_safely(1, 1)
      assert_allclose_safely(1, [1, 1])
      assert_allclose_safely([1, 1], 1 + 1e-6)
      with pytest.raises(AssertionError):
          assert_allclose_safely([1, 1], 1 + 1e-4)
      # Broadcastable matrices
      a = np.ones((2, 3))
      b = np.ones((3, 2, 3))
      eps = np.finfo(np.float64).eps
      a[0, 0] = 1 + eps
      assert_allclose_safely(a, b)
      a[0, 0] = 1 + 1.1e-5
      with pytest.raises(AssertionError):
          assert_allclose_safely(a, b)
      # Nans in same place
      a[0, 0] = np.nan
      b[:, 0, 0] = np.nan
      assert_allclose_safely(a, b)
      # Never equal with nans present, if not matching nans
      with pytest.raises(AssertionError):
          assert_allclose_safely(a, b, match_nans=False)
      b[0, 0, 0] = 1
      with pytest.raises(AssertionError):
          assert_allclose_safely(a, b)
      # Test allcloseness of inf, especially np.float128 infs
      for dtt in sctypes["float"]:
          a = np.array([-np.inf, 1, np.inf], dtype=dtt)
          b = np.array([-np.inf, 1, np.inf], dtype=dtt)
          assert_allclose_safely(a, b)
          b[1] = 0
          with pytest.raises(AssertionError):
              assert_allclose_safely(a, b)
      # Empty compares equal to empty
      assert_allclose_safely([], [])
  
file_path: nibabel/nibabel/tests/test_testing.py
imports: import os
  import sys
  import warnings
  import numpy
  import pytest
  from ..casting import sctypes
  from ..testing import assert_allclose_safely, assert_re_in, clear_and_catch_warnings, data_path, error_warnings, get_fresh_mod, get_test_data, suppress_warnings
label_desc: Use image node_id 1 for calling a global function with example usage: test_assert_allclose_safely() without return types