code: def test_ulp():
      assert ulp() == np.finfo(np.float64).eps
      assert ulp(1.0) == np.finfo(np.float64).eps
      assert ulp(np.float32(1.0)) == np.finfo(np.float32).eps
      assert ulp(np.float32(1.999)) == np.finfo(np.float32).eps
      # Integers always return 1
      assert ulp(1) == 1
      assert ulp(2**63 - 1) == 1
      # negative / positive same
      assert ulp(-1) == 1
      assert ulp(7.999) == ulp(4.0)
      assert ulp(-7.999) == ulp(4.0)
      assert ulp(np.float64(2**54 - 2)) == 2
      assert ulp(np.float64(2**54)) == 4
      assert ulp(np.float64(2**54)) == 4
      # Infs, NaNs return nan
      assert np.isnan(ulp(np.inf))
      assert np.isnan(ulp(-np.inf))
      assert np.isnan(ulp(np.nan))
      # 0 gives subnormal smallest
      subn64 = np.float64(2 ** (-1022 - 52))
      subn32 = np.float32(2 ** (-126 - 23))
      assert ulp(0.0) == subn64
      assert ulp(np.float64(0)) == subn64
      assert ulp(np.float32(0)) == subn32
      # as do multiples of subnormal smallest
      assert ulp(subn64 * np.float64(2**52)) == subn64
      assert ulp(subn64 * np.float64(2**53)) == subn64 * 2
      assert ulp(subn32 * np.float32(2**23)) == subn32
      assert ulp(subn32 * np.float32(2**24)) == subn32 * 2
  
file_path: nibabel/nibabel/tests/test_casting.py
imports: import os
  from platform import machine
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from ..casting import CastingError, able_int_type, best_float, float_to_int, floor_log2, int_abs, longdouble_precision_improved, sctypes, shared_range, ulp
  from ..testing import suppress_warnings
label_desc: Use image node_id 10 for calling a global function with example usage: test_ulp() without return types