Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for dependency (scipy and pandas) updates #234

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pingouin/correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ def corr(x, y, alternative='two-sided', method='pearson', **kwargs):
stats['BF10'] = bayesfactor_pearson(r, n_clean, alternative=alternative)

# Convert to DataFrame
stats = pd.DataFrame.from_records(stats, index=[method])
stats = pd.DataFrame(stats, index=[method])

# Define order
col_keep = ['n', 'outliers', 'r', 'CI95%', 'p-val', 'BF10', 'power']
Expand Down Expand Up @@ -863,7 +863,7 @@ def partial_corr(data=None, x=None, y=None, covar=None, x_covar=None,
}

# Convert to DataFrame
stats = pd.DataFrame.from_records(stats, index=[method])
stats = pd.DataFrame(stats, index=[method])

# Define order
col_keep = ['n', 'r', 'CI95%', 'p-val']
Expand Down
4 changes: 2 additions & 2 deletions pingouin/pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,8 @@ def pairwise_ttests(data=None, dv=None, between=None, within=None, subject=None,

# Append empty rows
idxiter = np.arange(nrows, nrows + ncombs)
stats = stats.append(
pd.DataFrame(columns=stats.columns, index=idxiter), ignore_index=True)
stats = stats.reindex(stats.index.union(idxiter))

# Update other columns
stats.loc[idxiter, 'Contrast'] = factors[0] + ' * ' + factors[1]
stats.loc[idxiter, 'Time'] = combs[:, 0]
Expand Down
10 changes: 7 additions & 3 deletions pingouin/parametric.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,12 @@ def ttest(x, y, paired=False, alternative='two-sided', correction='auto', r=.707
array([1.971859, 0.057056])
"""
from scipy.stats import t, ttest_rel, ttest_ind, ttest_1samp
from scipy.stats.stats import (_unequal_var_ttest_denom,
_equal_var_ttest_denom)
try:
from scipy.stats._stats_py import (_unequal_var_ttest_denom,
_equal_var_ttest_denom)
except ImportError: # Fallback for scipy<1.8.0
from scipy.stats.stats import (_unequal_var_ttest_denom,
_equal_var_ttest_denom)
from pingouin import (power_ttest, power_ttest2n, compute_effsize)

# Check arguments
Expand Down Expand Up @@ -306,7 +310,7 @@ def ttest(x, y, paired=False, alternative='two-sided', correction='auto', r=.707

# Convert to dataframe
col_order = ['T', 'dof', 'alternative', 'p-val', ci_name, 'cohen-d', 'BF10', 'power']
stats = pd.DataFrame.from_records(stats, columns=col_order, index=['T-test'])
stats = pd.DataFrame(stats, columns=col_order, index=['T-test'])
return _postprocess_dataframe(stats)


Expand Down
13 changes: 9 additions & 4 deletions pingouin/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ def qqplot(x, dist='norm', sparams=(), confidence=.95, figsize=(5, 4),
>>> sns.set_style('darkgrid')
>>> ax = pg.qqplot(x, dist='norm', sparams=(mean, std))
"""
try:
from scipy.stats._morestats import _add_axis_labels_title
except ImportError: # Fallback for scipy<1.8.0
from scipy.stats.morestats import _add_axis_labels_title

if isinstance(dist, str):
dist = getattr(stats, dist)

Expand Down Expand Up @@ -371,10 +376,10 @@ def qqplot(x, dist='norm', sparams=(), confidence=.95, figsize=(5, 4),

ax.plot(theor, observed, 'bo')

stats.morestats._add_axis_labels_title(ax,
xlabel='Theoretical quantiles',
ylabel='Ordered quantiles',
title='Q-Q Plot')
_add_axis_labels_title(ax,
xlabel='Theoretical quantiles',
ylabel='Ordered quantiles',
title='Q-Q Plot')

# Add diagonal line
end_pts = [ax.get_xlim(), ax.get_ylim()]
Expand Down