code: def test_rank_filter(self, filter, outdt):
      @run_in_parallel(warnings_matching=["Possible precision loss"])
      def check():
          expected = self.refs[filter]
          if outdt is not None:
              out = np.zeros_like(expected, dtype=outdt)
          else:
              out = None
          result = getattr(rank, filter)(
              self.image, self.footprint, out=out
          )
          if filter == "entropy":
              # There may be some arch dependent rounding errors
              # See the discussions in
              # https://github.com/scikit-image/scikit-image/issues/3091
              # https://github.com/scikit-image/scikit-image/issues/2528
              if outdt is not None:
                  # Adjust expected precision
                  expected = expected.astype(outdt)
              assert_allclose(expected, result, atol=0, rtol=1e-15)
          elif filter == "otsu":
              # OTSU May also have some optimization dependent failures
              # See the discussions in
              # https://github.com/scikit-image/scikit-image/issues/3091
              # Pixel 3, 5 was found to be problematic. It can take either
              # a value of 41 or 81 depending on the specific optimizations
              # used.
              assert result[3, 5] in [41, 81]
              result[3, 5] = 81
              # Pixel [19, 18] is also found to be problematic for the same
              # reason.
              assert result[19, 18] in [141, 172]
              result[19, 18] = 172
              assert_array_almost_equal(expected, result)
          else:
              if outdt is not None:
                  # Avoid rounding issues comparing to expected result.
                  # Take modulus first to avoid undefined behavior for
                  # float->uint8 conversions.
                  result = np.mod(result, 256.0).astype(expected.dtype)
              assert_array_almost_equal(expected, result)
  
      check()
  
imports: import numpy
  import pytest
  from skimage import data, morphology, util
  from skimage._shared._warnings import expected_warnings
  from skimage._shared.testing import assert_allclose, assert_array_almost_equal, assert_equal, fetch, run_in_parallel
  from skimage.filters import rank
  from skimage.filters.rank import __all__
  from skimage.filters.rank import subtract_mean
  from skimage.morphology import ball, disk, gray
  from skimage.util import img_as_float, img_as_ubyte
label_desc: Use image node_id 2 for calling the TestRank obj's underlying member method code with example usage: obj.test_rank_filter(filter, outdt) without return types