class_docstr: Test bayesian.py.
class_docstr_tok: ["Test","bayesian.py","."]
docstr: Test function bayesfactor_ttest.
docstr_tok: ["Test","function","bayesfactor_ttest","."]
code: def test_bayesfactor_ttest(self):
      """Test function bayesfactor_ttest."""
      # check for approximate equality with 1e-3 tolerance
      # (as this is how we store the values here)
      assert bayesfactor_ttest(3.5, 20, 20) == appr(26.743)
      assert bayesfactor_ttest(3.5, 20) == appr(17.185)
      assert bayesfactor_ttest(3.5, 20, 1) == appr(17.185)
      # Compare against BayesFactor::testBF
      # >>> ttestBF(df$x, df$y, paired = FALSE, rscale = "medium")
      assert ttest(x, y).at["T-test", "BF10"] == "0.183"
      assert ttest(x, y, paired=True).at["T-test", "BF10"] == "0.135"
      assert int(float(ttest(x, z).at["T-test", "BF10"])) == 1290
      assert (
          int(float(ttest(x, z, paired=True).at["T-test", "BF10"]))
          == 420
      )
      # Now check the alternative tails
      assert bayesfactor_ttest(3.5, 20, 20, alternative="greater") > 1
      assert bayesfactor_ttest(3.5, 20, 20, alternative="less") < 1
      assert bayesfactor_ttest(-3.5, 20, 20, alternative="greater") < 1
      assert bayesfactor_ttest(-3.5, 20, 20, alternative="less") > 1
      # Check with wrong T-value
      assert np.isnan(bayesfactor_ttest(np.nan, 20, paired=True))
  
file_path: pingouin/pingouin/tests/test_bayesian.py
imports: import numpy
  from unittest import TestCase
  from scipy.stats import pearsonr
  from pingouin.parametric import ttest
  from pingouin.bayesian import bayesfactor_ttest, bayesfactor_binom
  from pingouin.bayesian import bayesfactor_pearson
  from pytest import approx
label_desc: Use image node_id 1 for calling the TestBayesian obj's underlying member method code with example usage: obj.test_bayesfactor_ttest() without return types