class_docstr: Test pairwise.py.
class_docstr_tok: ["Test","pairwise.py","."]
docstr: Test function ptests.
docstr_tok: ["Test","function","ptests","."]
code: def test_ptests(self):
      """Test function ptests."""
      from itertools import combinations
      from scipy.stats import ttest_ind, ttest_rel
  
      # Load BFI dataset
      df = read_dataset("pairwise_corr").iloc[:30, 1:]
      df.columns = ["N", "E", "O", "A", "C"]
      # Add some missing values
      df.iloc[[2, 5, 20], 2] = np.nan
      df.iloc[[1, 4, 10], 3] = np.nan
  
      combs = list(combinations(df.columns, 2))
  
      # Independent T-test
      pt = df.ptests(decimals=7, stars=False)
      for a, b in combs:
          t, p = ttest_ind(df[a], df[b], nan_policy="omit")
          assert round(t, 7) == float(pt.at[b, a])
          assert round(p, 7) == float(pt.at[a, b])
  
      # Using custom parameter
      pt_welch = df.ptests(decimals=5, stars=False, equal_var=False)
      assert not pt.equals(pt_welch)
  
      # Using stars
      pt_stars = df.ptests(decimals=7)
      assert not pt.equals(pt_stars)
  
      # Paired T-test
      pt = df.ptests(decimals=7, paired=True, stars=False)
      for a, b in combs:
          t, p = ttest_rel(df[a], df[b], nan_policy="omit")
          assert round(t, 7) == float(pt.at[b, a])
          assert round(p, 7) == float(pt.at[a, b])
  
      # With Bonferroni correction
      pt = df.ptests(
          decimals=7, paired=True, stars=False, padjust="bonf"
      )
      for a, b in combs:
          _, p = ttest_rel(df[a], df[b], nan_policy="omit")
          p = min(p * len(combs), 1)
          assert round(p, 7) == float(pt.at[a, b])
  
file_path: pingouin/pingouin/tests/test_pairwise.py
imports: import pytest
  import numpy
  import pandas
  from unittest import TestCase
  from pingouin import read_dataset
  from pingouin.pairwise import pairwise_ttests, pairwise_tests, pairwise_corr, pairwise_tukey, pairwise_gameshowell
label_desc: Use image node_id 2 for calling the TestPairwise obj's underlying member method code with example usage: obj.test_ptests() without return types