class_docstr: Test power.py.
docstr: Test function power_ttest2n.
  Values are compared to the pwr R package.
code: def test_power_ttest2n(self):
      """Test function power_ttest2n.
      Values are compared to the pwr R package.
      """
      # TWO-SAMPLES
      # alternative = 'greater'
      assert np.isclose(
          power_ttest2n(nx=20, ny=18, d=0.5, alternative="greater"),
          0.4463552,
      )
      assert np.isclose(
          power_ttest2n(
              nx=20, ny=18, power=0.80, alternative="greater"
          ),
          0.8234684,
      )
      assert np.isclose(
          power_ttest2n(
              nx=20,
              ny=18,
              d=0.5,
              power=0.80,
              alpha=None,
              alternative="greater",
          ),
          0.2444025,
          rtol=1e-01,
      )
      # alternative = 'less'
      assert np.isclose(
          power_ttest2n(nx=20, ny=18, d=0.5, alternative="less"),
          0.0008011104,
      )
      assert np.isclose(
          power_ttest2n(nx=20, ny=18, d=-0.5, alternative="less"),
          0.4463552,
      )
      assert np.isclose(
          power_ttest2n(nx=20, ny=18, power=0.80, alternative="less"),
          -0.8234684,
      )
      assert np.isclose(
          power_ttest2n(
              nx=20,
              ny=18,
              d=0.5,
              power=0.80,
              alpha=None,
              alternative="less",
          ),
          0.989896,
          rtol=1e-01,
      )
      # Two-sided
      assert np.isclose(
          power_ttest2n(nx=20, ny=18, d=0.5), 0.3223224, rtol=1e-03
      )
      assert np.isclose(
          power_ttest2n(nx=20, ny=18, power=0.80), 0.9354168
      )
      assert np.isclose(
          power_ttest2n(nx=20, ny=18, d=0.5, power=0.80, alpha=None),
          0.46372,
          rtol=1e-01,
      )
      # Error
      with pytest.raises(ValueError):
          power_ttest2n(nx=20, ny=20)
  
file_path: pingouin/pingouin/tests/test_power.py
imports: import pytest
  import numpy
  from unittest import TestCase
  from pingouin.power import power_ttest, power_ttest2n, power_anova, power_rm_anova, power_corr, power_chi2
label_desc: Use image node_id 2 for calling the TestPower obj's underlying member method code with example usage: obj.test_power_ttest2n() without return types