code: def test_corr1d(data1, data2, method):
      if method == "spearman":
          # Pandas uses scipy.stats.spearmanr code-path
          pytest.importorskip("scipy")
  
      gs1 = cudf.Series(data1)
      gs2 = cudf.Series(data2)
  
      ps1 = gs1.to_pandas()
      ps2 = gs2.to_pandas()
  
      got = gs1.corr(gs2, method)
  
      ps1_align, ps2_align = ps1.align(ps2, join="inner")
  
      is_singular = (
          len(ps1_align.dropna()) == 1 and len(ps2_align.dropna()) > 0
      ) or (
          len(ps2_align.dropna()) == 1 and len(ps1_align.dropna()) > 0
      )
      is_identical = (
          len(ps1_align.dropna().unique()) == 1
          and len(ps2_align.dropna()) > 0
      ) or (
          len(ps2_align.dropna().unique()) == 1
          and len(ps1_align.dropna()) > 0
      )
  
      # Pearson correlation leads to division by 0 when either sample size is 1.
      # Spearman allows for size 1 samples, but will error if all data in a
      # sample is identical since the covariance is zero and so the correlation
      # coefficient is not defined.
      cond = (is_singular and method == "pearson") or (
          is_identical and not is_singular and method == "spearman"
      )
      if method == "spearman":
          # SciPy has shuffled around the warning it throws a couple of times.
          # It's not worth the effort of conditionally importing the appropriate
          # warning based on the scipy version, just catching a base Warning is
          # good enough validation.
          expected_warning = Warning
      elif method == "pearson":
          expected_warning = RuntimeWarning
  
      with expect_warning_if(cond, expected_warning):
          expected = ps1.corr(ps2, method)
      np.testing.assert_approx_equal(got, expected, significant=8)
  
imports: from concurrent.futures import ThreadPoolExecutor
  import cupy
  import numpy
  import pandas
  import pytest
  import cudf
  from cudf.datasets import randomdata
  from cudf.testing._utils import _create_cudf_series_float64_default, _create_pandas_series_float64_default, assert_eq, assert_exceptions_equal, expect_warning_if
label_desc: Use image node_id 18 for calling a global function with example usage: test_corr1d(data1, data2, method) without return types