code: def test_ufunc(pandas_input, ufunc):
      dafunc = getattr(da, ufunc)
      npfunc = getattr(np, ufunc)
  
      dask_input = dd.from_pandas(pandas_input, 3)
      pandas_type = pandas_input.__class__
      dask_type = dask_input.__class__
  
      # applying Dask ufunc doesn't trigger computation
      with warnings.catch_warnings():
          warnings.simplefilter("ignore", RuntimeWarning)
          # Some cause warnings (arcsine)
          assert isinstance(dafunc(dask_input), dask_type)
          assert_eq(dafunc(dask_input), npfunc(pandas_input))
  
          # applying NumPy ufunc is lazy
          if isinstance(npfunc, np.ufunc):
              assert isinstance(npfunc(dask_input), dask_type)
          else:
              assert isinstance(npfunc(dask_input), pandas_type)
          assert_eq(npfunc(dask_input), npfunc(pandas_input))
  
          # applying Dask ufunc to normal Series triggers computation
          assert isinstance(dafunc(pandas_input), pandas_type)
          assert_eq(dafunc(dask_input), npfunc(pandas_input))
  
      # Index
      if pandas_input.index.dtype in [object, str]:
          return
      if ufunc in (
          "logical_not",
          "signbit",
          "isnan",
          "isinf",
          "isfinite",
      ):
          return
  
      with warnings.catch_warnings():
          warnings.simplefilter("ignore", RuntimeWarning)
          assert isinstance(dafunc(dask_input.index), dd.Index)
          assert_eq(
              dafunc(dask_input.index),
              npfunc(pandas_input.index),
              check_divisions=ufunc != "spacing",
          )
  
          # applying NumPy ufunc is lazy
          if isinstance(npfunc, np.ufunc):
              assert isinstance(npfunc(dask_input.index), dd.Index)
          else:
              assert isinstance(npfunc(dask_input.index), pd.Index)
  
          assert_eq(
              npfunc(dask_input.index),
              npfunc(dask_input.index),
              check_divisions=ufunc != "spacing",
          )
  
      # applying Dask ufunc to normal Series triggers computation
      with warnings.catch_warnings():
          warnings.simplefilter("ignore", RuntimeWarning)
          # some (da.log) cause warnings
          assert isinstance(dafunc(pandas_input.index), pd.Index)
          assert_eq(dafunc(pandas_input), npfunc(pandas_input))
  
file_path: dask/dask/dataframe/tests/test_ufunc.py
imports: from __future__ import annotations
  import warnings
  import pytest
  import numpy
  import dask.array
  import dask.dataframe
  from dask.dataframe.utils import assert_eq
label_desc: Use image node_id 1 for calling a global function with example usage: test_ufunc(pandas_input, ufunc) without return types