class_docstr: Test power.py.
docstr: Test function power_corr.
  Values are compared to the pwr R package.
code: def test_power_corr(self):
      """Test function power_corr.
      Values are compared to the pwr R package.
      """
      # Two-sided
      assert np.isclose(power_corr(r=0.5, n=20), 0.6378746)
      assert np.isclose(power_corr(r=0.5, power=0.80), 28.24841)
      assert np.isclose(power_corr(n=20, power=0.80), 0.5821478)
      assert np.isclose(
          power_corr(r=0.5, n=20, power=0.80, alpha=None),
          0.1377332,
          rtol=1e-03,
      )
  
      # Greater
      assert np.isclose(
          power_corr(r=0.5, n=20, alternative="greater"), 0.7509873
      )
      assert np.isclose(
          power_corr(r=-0.1, n=20, alternative="greater"), 0.01941224
      )
      assert np.isclose(
          power_corr(r=0.5, power=0.80, alternative="greater"), 22.60907
      )
      assert np.isclose(
          power_corr(n=20, power=0.80, alternative="greater"), 0.5286949
      )
  
      # Less
      assert np.isclose(
          power_corr(r=-0.5, n=20, alternative="less"), 0.7509873
      )
      assert np.isclose(
          power_corr(r=-0.1, n=20, alternative="less"), 0.1118106
      )
      assert np.isclose(
          power_corr(r=0.1, n=20, alternative="less"), 0.01941224
      )
      assert np.isclose(
          power_corr(r=-0.5, power=0.80, alternative="less"), 22.60907
      )
      assert np.isclose(
          power_corr(n=20, power=0.80, alternative="less"), -0.5286949
      )
  
      # Error & Warning
      with pytest.raises(ValueError):
          power_corr(r=0.5)
      with pytest.warns(UserWarning):
          power_corr(r=0.5, n=4)
          power_corr(power=0.80, n=4)
  
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 5 for calling the TestPower obj's underlying member method code with example usage: obj.test_power_corr() without return types