<h2 dir="auto">Proposal</h2>
<p dir="auto">Add a new argument - <code class="notranslate">combinatorial</code> - in order for all combinations of the input ndarray to be compared to one another:</p>
<p dir="auto"><code class="notranslate">stats.ttest_ind(ndarray, combinatorial=True,...)</code></p>
<p dir="auto">If the ndarray contains 5 vectors (<code class="notranslate">np.array([array1, array2...array5)]</code>) then the function would calculate 1vs2, 1vs3, 1vs4...2vs3, 2vs4,...4vs5.</p>
<h2 dir="auto">Current Limitations</h2>
<p dir="auto">Currently the ttest_ind function requires that you pass in two array like variables, a &amp; b, and compares one vector to the next:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; from scipy import stats
&gt;&gt;&gt; array1 = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9])
&gt;&gt;&gt; array2 = np.array([1, 1, 1, 1, 1, 1, 1, 1, 1])
&gt;&gt;&gt; stats.ttest_ind(array1, array2)
Ttest_indResult(statistic=4.3817804600413295, pvalue=0.00046449025177634345)"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">from</span> <span class="pl-s1">scipy</span> <span class="pl-k">import</span> <span class="pl-s1">stats</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">array1</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>, <span class="pl-c1">4</span>, <span class="pl-c1">5</span>, <span class="pl-c1">6</span>, <span class="pl-c1">7</span>, <span class="pl-c1">8</span>, <span class="pl-c1">9</span>])
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">array2</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-c1">1</span>])
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">stats</span>.<span class="pl-en">ttest_ind</span>(<span class="pl-s1">array1</span>, <span class="pl-s1">array2</span>)
<span class="pl-v">Ttest_indResult</span>(<span class="pl-s1">statistic</span><span class="pl-c1">=</span><span class="pl-c1">4.3817804600413295</span>, <span class="pl-s1">pvalue</span><span class="pl-c1">=</span><span class="pl-c1">0.00046449025177634345</span>)</pre></div>
<p dir="auto">or as an ndarray</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; stats.ttest_ind(np.array([array1, array2]).T, np.array([array2, array1]).T)
Ttest_indResult(statistic=array([ 4.38178046, -4.38178046]), pvalue=array([0.00046449, 0.00046449]))"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">stats</span>.<span class="pl-en">ttest_ind</span>(<span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-s1">array1</span>, <span class="pl-s1">array2</span>]).<span class="pl-v">T</span>, <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-s1">array2</span>, <span class="pl-s1">array1</span>]).<span class="pl-v">T</span>)
<span class="pl-v">Ttest_indResult</span>(<span class="pl-s1">statistic</span><span class="pl-c1">=</span><span class="pl-en">array</span>([ <span class="pl-c1">4.38178046</span>, <span class="pl-c1">-</span><span class="pl-c1">4.38178046</span>]), <span class="pl-s1">pvalue</span><span class="pl-c1">=</span><span class="pl-en">array</span>([<span class="pl-c1">0.00046449</span>, <span class="pl-c1">0.00046449</span>]))</pre></div>
<p dir="auto">Due to the structure of the arguments it means that only 1 comparison can be made: Thus requiring some combination, potentially using the itertools library to compare multiple groups (i.e. 1 vs 2, 2 vs 3 &amp; 1 vs 3):</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; import itertools as it
&gt;&gt;&gt; array3 = np.array([7, 7, 7, 7, 7, 7, 7, 7, 7])
&gt;&gt;&gt; ndarray = np.array([array1, array2, array3])
&gt;&gt;&gt; [ stats.ttest_ind(ndarray[x[0], :], ndarray[x[1], :]) for x in it.combinations(range(0, ndarray.shape[0]), 2)]
[Ttest_indResult(statistic=4.3817804600413295, pvalue=0.00046449025177634345),
Ttest_indResult(statistic=-2.1908902300206647, pvalue=0.04360954625650814),
Ttest_indResult(statistic=-inf, pvalue=0.0)]"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">import</span> <span class="pl-s1">itertools</span> <span class="pl-k">as</span> <span class="pl-s1">it</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">array3</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">7</span>, <span class="pl-c1">7</span>, <span class="pl-c1">7</span>, <span class="pl-c1">7</span>, <span class="pl-c1">7</span>, <span class="pl-c1">7</span>, <span class="pl-c1">7</span>, <span class="pl-c1">7</span>, <span class="pl-c1">7</span>])
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">ndarray</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-s1">array1</span>, <span class="pl-s1">array2</span>, <span class="pl-s1">array3</span>])
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> [ <span class="pl-s1">stats</span>.<span class="pl-en">ttest_ind</span>(<span class="pl-s1">ndarray</span>[<span class="pl-s1">x</span>[<span class="pl-c1">0</span>], :], <span class="pl-s1">ndarray</span>[<span class="pl-s1">x</span>[<span class="pl-c1">1</span>], :]) <span class="pl-k">for</span> <span class="pl-s1">x</span> <span class="pl-c1">in</span> <span class="pl-s1">it</span>.<span class="pl-en">combinations</span>(<span class="pl-en">range</span>(<span class="pl-c1">0</span>, <span class="pl-s1">ndarray</span>.<span class="pl-s1">shape</span>[<span class="pl-c1">0</span>]), <span class="pl-c1">2</span>)]
[<span class="pl-v">Ttest_indResult</span>(<span class="pl-s1">statistic</span><span class="pl-c1">=</span><span class="pl-c1">4.3817804600413295</span>, <span class="pl-s1">pvalue</span><span class="pl-c1">=</span><span class="pl-c1">0.00046449025177634345</span>),
<span class="pl-v">Ttest_indResult</span>(<span class="pl-s1">statistic</span><span class="pl-c1">=</span><span class="pl-c1">-</span><span class="pl-c1">2.1908902300206647</span>, <span class="pl-s1">pvalue</span><span class="pl-c1">=</span><span class="pl-c1">0.04360954625650814</span>),
<span class="pl-v">Ttest_indResult</span>(<span class="pl-s1">statistic</span><span class="pl-c1">=</span><span class="pl-c1">-</span><span class="pl-s1">inf</span>, <span class="pl-s1">pvalue</span><span class="pl-c1">=</span><span class="pl-c1">0.0</span>)]</pre></div>
<p dir="auto">or this way:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; stats.ttest_ind(np.array([array1, array2, array1]).T, np.array([array2, array3, array3]).T)
Ttest_indResult(statistic=array([ 4.38178046,        -inf, -2.19089023]), pvalue=array([0.00046449, 0.        , 0.04360955]))"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">stats</span>.<span class="pl-en">ttest_ind</span>(<span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-s1">array1</span>, <span class="pl-s1">array2</span>, <span class="pl-s1">array1</span>]).<span class="pl-v">T</span>, <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-s1">array2</span>, <span class="pl-s1">array3</span>, <span class="pl-s1">array3</span>]).<span class="pl-v">T</span>)
<span class="pl-v">Ttest_indResult</span>(<span class="pl-s1">statistic</span><span class="pl-c1">=</span><span class="pl-en">array</span>([ <span class="pl-c1">4.38178046</span>,        <span class="pl-c1">-</span><span class="pl-s1">inf</span>, <span class="pl-c1">-</span><span class="pl-c1">2.19089023</span>]), <span class="pl-s1">pvalue</span><span class="pl-c1">=</span><span class="pl-en">array</span>([<span class="pl-c1">0.00046449</span>, <span class="pl-c1">0.</span>        , <span class="pl-c1">0.04360955</span>]))</pre></div>
<p dir="auto">However, it's not immediately obvious how to construct the input variables when doing combinations and suppose the dimensions become very large: It would require very large input ndarrays to be constucted, with large amounts of duplicated data. It therefore seems sensible that the arguments would support a general combinatorial case.</p>
<p dir="auto">Internally I wrote a series of functions for the different t-tests that do support this input using matrix broadcasting and thus removing the need for python looping external to the function or constucting large input ndarrays:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; p_values, score = t_test_(ndarray, None, {'paired': False, 'equal_variance': True})
&gt;&gt;&gt; p_values
array([[1.00000000e+00, 4.64490252e-04, 4.36095463e-02],
       [4.64490252e-04,            nan, 0.00000000e+00],
       [4.36095463e-02, 0.00000000e+00,            nan]])
&gt;&gt;&gt; score
array([[ 0.        ,  4.38178046, -2.19089023],
       [-4.38178046,         nan,        -inf],
       [ 2.19089023,         inf,         nan]])"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">p_values</span>, <span class="pl-s1">score</span> <span class="pl-c1">=</span> <span class="pl-en">t_test_</span>(<span class="pl-s1">ndarray</span>, <span class="pl-c1">None</span>, {<span class="pl-s">'paired'</span>: <span class="pl-c1">False</span>, <span class="pl-s">'equal_variance'</span>: <span class="pl-c1">True</span>})
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">p_values</span>
<span class="pl-en">array</span>([[<span class="pl-c1">1.00000000e+00</span>, <span class="pl-c1">4.64490252e-04</span>, <span class="pl-c1">4.36095463e-02</span>],
       [<span class="pl-c1">4.64490252e-04</span>,            <span class="pl-s1">nan</span>, <span class="pl-c1">0.00000000e+00</span>],
       [<span class="pl-c1">4.36095463e-02</span>, <span class="pl-c1">0.00000000e+00</span>,            <span class="pl-s1">nan</span>]])
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">score</span>
<span class="pl-en">array</span>([[ <span class="pl-c1">0.</span>        ,  <span class="pl-c1">4.38178046</span>, <span class="pl-c1">-</span><span class="pl-c1">2.19089023</span>],
       [<span class="pl-c1">-</span><span class="pl-c1">4.38178046</span>,         <span class="pl-s1">nan</span>,        <span class="pl-c1">-</span><span class="pl-s1">inf</span>],
       [ <span class="pl-c1">2.19089023</span>,         <span class="pl-s1">inf</span>,         <span class="pl-s1">nan</span>]])</pre></div>
<p dir="auto">Internal function:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="def t_test_(v, weights, opts):
    base = np.nansum(~np.isnan(v)*1, axis=1)
    mean = np.nanmean(v, axis=1)
    t_nom = mean[:, np.newaxis] - mean
    s = np.nanvar(v, axis=1, ddof=1)
    if opts['equal_variance']:
        sp = ((base - 1) * s + (base[:, np.newaxis] - 1) * s[:, np.newaxis]) / (base + base[:, np.newaxis] - 2)
        score = t_nom / (np.sqrt(sp) * np.sqrt(1 / base + 1 / base[:, np.newaxis]))
        dof = base + base[:, np.newaxis] - 2
    else:
        s_n = s / base
        score = t_nom / np.sqrt(s_n + s_n[:, np.newaxis])
        dof_denom = (s_n**2 / (base - 1)) + (s_n[:, np.newaxis]**2 / (base[:, np.newaxis] - 1))
        dof = (s_n + s_n[:, np.newaxis])**2 / dof_denom
    return stats.t.sf(np.abs(score), dof) * 2, score"><pre class="notranslate"><span class="pl-k">def</span> <span class="pl-en">t_test_</span>(<span class="pl-s1">v</span>, <span class="pl-s1">weights</span>, <span class="pl-s1">opts</span>):
    <span class="pl-s1">base</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">nansum</span>(<span class="pl-c1">~</span><span class="pl-s1">np</span>.<span class="pl-en">isnan</span>(<span class="pl-s1">v</span>)<span class="pl-c1">*</span><span class="pl-c1">1</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">1</span>)
    <span class="pl-s1">mean</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">nanmean</span>(<span class="pl-s1">v</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">1</span>)
    <span class="pl-s1">t_nom</span> <span class="pl-c1">=</span> <span class="pl-s1">mean</span>[:, <span class="pl-s1">np</span>.<span class="pl-s1">newaxis</span>] <span class="pl-c1">-</span> <span class="pl-s1">mean</span>
    <span class="pl-s1">s</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">nanvar</span>(<span class="pl-s1">v</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">1</span>, <span class="pl-s1">ddof</span><span class="pl-c1">=</span><span class="pl-c1">1</span>)
    <span class="pl-k">if</span> <span class="pl-s1">opts</span>[<span class="pl-s">'equal_variance'</span>]:
        <span class="pl-s1">sp</span> <span class="pl-c1">=</span> ((<span class="pl-s1">base</span> <span class="pl-c1">-</span> <span class="pl-c1">1</span>) <span class="pl-c1">*</span> <span class="pl-s1">s</span> <span class="pl-c1">+</span> (<span class="pl-s1">base</span>[:, <span class="pl-s1">np</span>.<span class="pl-s1">newaxis</span>] <span class="pl-c1">-</span> <span class="pl-c1">1</span>) <span class="pl-c1">*</span> <span class="pl-s1">s</span>[:, <span class="pl-s1">np</span>.<span class="pl-s1">newaxis</span>]) <span class="pl-c1">/</span> (<span class="pl-s1">base</span> <span class="pl-c1">+</span> <span class="pl-s1">base</span>[:, <span class="pl-s1">np</span>.<span class="pl-s1">newaxis</span>] <span class="pl-c1">-</span> <span class="pl-c1">2</span>)
        <span class="pl-s1">score</span> <span class="pl-c1">=</span> <span class="pl-s1">t_nom</span> <span class="pl-c1">/</span> (<span class="pl-s1">np</span>.<span class="pl-en">sqrt</span>(<span class="pl-s1">sp</span>) <span class="pl-c1">*</span> <span class="pl-s1">np</span>.<span class="pl-en">sqrt</span>(<span class="pl-c1">1</span> <span class="pl-c1">/</span> <span class="pl-s1">base</span> <span class="pl-c1">+</span> <span class="pl-c1">1</span> <span class="pl-c1">/</span> <span class="pl-s1">base</span>[:, <span class="pl-s1">np</span>.<span class="pl-s1">newaxis</span>]))
        <span class="pl-s1">dof</span> <span class="pl-c1">=</span> <span class="pl-s1">base</span> <span class="pl-c1">+</span> <span class="pl-s1">base</span>[:, <span class="pl-s1">np</span>.<span class="pl-s1">newaxis</span>] <span class="pl-c1">-</span> <span class="pl-c1">2</span>
    <span class="pl-k">else</span>:
        <span class="pl-s1">s_n</span> <span class="pl-c1">=</span> <span class="pl-s1">s</span> <span class="pl-c1">/</span> <span class="pl-s1">base</span>
        <span class="pl-s1">score</span> <span class="pl-c1">=</span> <span class="pl-s1">t_nom</span> <span class="pl-c1">/</span> <span class="pl-s1">np</span>.<span class="pl-en">sqrt</span>(<span class="pl-s1">s_n</span> <span class="pl-c1">+</span> <span class="pl-s1">s_n</span>[:, <span class="pl-s1">np</span>.<span class="pl-s1">newaxis</span>])
        <span class="pl-s1">dof_denom</span> <span class="pl-c1">=</span> (<span class="pl-s1">s_n</span><span class="pl-c1">**</span><span class="pl-c1">2</span> <span class="pl-c1">/</span> (<span class="pl-s1">base</span> <span class="pl-c1">-</span> <span class="pl-c1">1</span>)) <span class="pl-c1">+</span> (<span class="pl-s1">s_n</span>[:, <span class="pl-s1">np</span>.<span class="pl-s1">newaxis</span>]<span class="pl-c1">**</span><span class="pl-c1">2</span> <span class="pl-c1">/</span> (<span class="pl-s1">base</span>[:, <span class="pl-s1">np</span>.<span class="pl-s1">newaxis</span>] <span class="pl-c1">-</span> <span class="pl-c1">1</span>))
        <span class="pl-s1">dof</span> <span class="pl-c1">=</span> (<span class="pl-s1">s_n</span> <span class="pl-c1">+</span> <span class="pl-s1">s_n</span>[:, <span class="pl-s1">np</span>.<span class="pl-s1">newaxis</span>])<span class="pl-c1">**</span><span class="pl-c1">2</span> <span class="pl-c1">/</span> <span class="pl-s1">dof_denom</span>
    <span class="pl-k">return</span> <span class="pl-s1">stats</span>.<span class="pl-s1">t</span>.<span class="pl-en">sf</span>(<span class="pl-s1">np</span>.<span class="pl-en">abs</span>(<span class="pl-s1">score</span>), <span class="pl-s1">dof</span>) <span class="pl-c1">*</span> <span class="pl-c1">2</span>, <span class="pl-s1">score</span></pre></div>
<h2 dir="auto">Benchmark</h2>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; array4 = np.array([11, 3, 2, 1, 5, 2, 1, 3, 6])
&gt;&gt;&gt; array5 = np.array([11, 3, 2, 1, 5, 2, 1, 6, 6])
&gt;&gt;&gt; ndarray = np.array([array1, array2, array3, array4, array5])
&gt;&gt;&gt; def test_current():
...     return [ stats.ttest_ind(ndarray[x[0], :], ndarray[x[1], :], nan_policy='omit') for x in it.combinations(range(0, ndarray.shape[0]), 2)]
&gt;&gt;&gt; def test_new():
...     return standard_t_test_(ndarray, None, {'paired': False, 'equal_variance': True})
&gt;&gt;&gt; print(timeit.timeit(&quot;test_current()&quot;, &quot;from __main__ import test_current&quot;, number=100000))
202.31119344299987
&gt;&gt;&gt; print(timeit.timeit(&quot;test_new()&quot;, &quot;from __main__ import test_new&quot;, number=100000))
20.02507360100026"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">array4</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">11</span>, <span class="pl-c1">3</span>, <span class="pl-c1">2</span>, <span class="pl-c1">1</span>, <span class="pl-c1">5</span>, <span class="pl-c1">2</span>, <span class="pl-c1">1</span>, <span class="pl-c1">3</span>, <span class="pl-c1">6</span>])
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">array5</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">11</span>, <span class="pl-c1">3</span>, <span class="pl-c1">2</span>, <span class="pl-c1">1</span>, <span class="pl-c1">5</span>, <span class="pl-c1">2</span>, <span class="pl-c1">1</span>, <span class="pl-c1">6</span>, <span class="pl-c1">6</span>])
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">ndarray</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-s1">array1</span>, <span class="pl-s1">array2</span>, <span class="pl-s1">array3</span>, <span class="pl-s1">array4</span>, <span class="pl-s1">array5</span>])
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">def</span> <span class="pl-en">test_current</span>():
...     <span class="pl-k">return</span> [ <span class="pl-s1">stats</span>.<span class="pl-en">ttest_ind</span>(<span class="pl-s1">ndarray</span>[<span class="pl-s1">x</span>[<span class="pl-c1">0</span>], :], <span class="pl-s1">ndarray</span>[<span class="pl-s1">x</span>[<span class="pl-c1">1</span>], :], <span class="pl-s1">nan_policy</span><span class="pl-c1">=</span><span class="pl-s">'omit'</span>) <span class="pl-k">for</span> <span class="pl-s1">x</span> <span class="pl-c1">in</span> <span class="pl-s1">it</span>.<span class="pl-en">combinations</span>(<span class="pl-en">range</span>(<span class="pl-c1">0</span>, <span class="pl-s1">ndarray</span>.<span class="pl-s1">shape</span>[<span class="pl-c1">0</span>]), <span class="pl-c1">2</span>)]
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">def</span> <span class="pl-en">test_new</span>():
...     <span class="pl-k">return</span> <span class="pl-en">standard_t_test_</span>(<span class="pl-s1">ndarray</span>, <span class="pl-c1">None</span>, {<span class="pl-s">'paired'</span>: <span class="pl-c1">False</span>, <span class="pl-s">'equal_variance'</span>: <span class="pl-c1">True</span>})
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-en">print</span>(<span class="pl-s1">timeit</span>.<span class="pl-en">timeit</span>(<span class="pl-s">"test_current()"</span>, <span class="pl-s">"from __main__ import test_current"</span>, <span class="pl-s1">number</span><span class="pl-c1">=</span><span class="pl-c1">100000</span>))
<span class="pl-c1">202.31119344299987</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-en">print</span>(<span class="pl-s1">timeit</span>.<span class="pl-en">timeit</span>(<span class="pl-s">"test_new()"</span>, <span class="pl-s">"from __main__ import test_new"</span>, <span class="pl-s1">number</span><span class="pl-c1">=</span><span class="pl-c1">100000</span>))
<span class="pl-c1">20.02507360100026</span></pre></div>
<p dir="auto">This demonstrates that the new function is around 10 times faster when comparing 5 groups with one another when comparing to the python looping way.</p>
<h2 dir="auto">Summary</h2>
<p dir="auto">What are the implications for adding a feature such as this? Statistically running multiple tests would affect the p-value performance as it would permit p-hacking/mining - however I'd argue that that decision rests with the statistician, not the statistical library.</p>
<p dir="auto">I'd like to know people's thoughts on a feature such as - or similar to - this.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; from scipy.sparse import test
&gt;&gt;&gt; test() "><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; from scipy.sparse import test
&gt;&gt;&gt; test() 
</code></pre></div>
<p dir="auto">gives a bunch of errors of this sort:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="======================================================================
ERROR: test_base.TestLIL.test_sum(&lt;type 'numpy.complex128'&gt;, 4)
----------------------------------------------------------------------
Traceback (most recent call last):
  File &quot;/home/br/virtualenvs/scipy-dev/local/lib/python2.7/site-packages/nose/case.py&quot;, line 197, in runTest
    self.test(*self.arg)
  File &quot;/home/br/virtualenvs/scipy-dev/local/lib/python2.7/site-packages/scipy/sparse/tests/test_base.py&quot;, line 654, in check
    assert_array_almost_equal(dat.sum(axis=-2), datsp.sum(axis=-2))
  File &quot;/home/br/virtualenvs/scipy-dev/local/lib/python2.7/site-packages/numpy/matrixlib/defmatrix.py&quot;, line 435, in sum
    return N.ndarray.sum(self, axis, dtype, out)._align(axis)
  File &quot;/home/br/virtualenvs/scipy-dev/`local/lib/python2.7/site-packages/numpy/matrixlib/defmatrix.py&quot;, line 376, in _align
    raise ValueError, &quot;unsupported axis&quot;
ValueError: unsupported axis

----------------------------------------------------------------------
Ran 8645 tests in 80.713s

FAILED (KNOWNFAIL=251, SKIP=997, errors=246)
&lt;nose.result.TextTestResult run=8645 errors=246 failures=0&gt;
&gt;&gt;&gt; import scipy
&gt;&gt;&gt; scipy.__version__
'0.14.0.dev-9812e4c'
&gt;&gt;&gt; import numpy
&gt;&gt;&gt; numpy.__version__
'1.6.2'"><pre class="notranslate"><code class="notranslate">======================================================================
ERROR: test_base.TestLIL.test_sum(&lt;type 'numpy.complex128'&gt;, 4)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/br/virtualenvs/scipy-dev/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/br/virtualenvs/scipy-dev/local/lib/python2.7/site-packages/scipy/sparse/tests/test_base.py", line 654, in check
    assert_array_almost_equal(dat.sum(axis=-2), datsp.sum(axis=-2))
  File "/home/br/virtualenvs/scipy-dev/local/lib/python2.7/site-packages/numpy/matrixlib/defmatrix.py", line 435, in sum
    return N.ndarray.sum(self, axis, dtype, out)._align(axis)
  File "/home/br/virtualenvs/scipy-dev/`local/lib/python2.7/site-packages/numpy/matrixlib/defmatrix.py", line 376, in _align
    raise ValueError, "unsupported axis"
ValueError: unsupported axis

----------------------------------------------------------------------
Ran 8645 tests in 80.713s

FAILED (KNOWNFAIL=251, SKIP=997, errors=246)
&lt;nose.result.TextTestResult run=8645 errors=246 failures=0&gt;
&gt;&gt;&gt; import scipy
&gt;&gt;&gt; scipy.__version__
'0.14.0.dev-9812e4c'
&gt;&gt;&gt; import numpy
&gt;&gt;&gt; numpy.__version__
'1.6.2'
</code></pre></div>
<p dir="auto">This all is with python 2.7.3 on 64 bit Ubuntu Precise with stock atlas.</p>