<p dir="auto">The issue is about several reducing functions such as <code class="notranslate">np.mean</code> or <code class="notranslate">np.std</code>. These functions seem to return a different result when passed a 2D array together with <code class="notranslate">axis</code> argument instead of 1D array which is manually subscripted. Formally these two methods describe the exact same operation and so they should return the same result. For example:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="a = np.random.uniform(size=(100, 2))
assert np.mean(a, axis=0)[0] == np.mean(a[:, 0])"><pre class="notranslate"><span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">uniform</span>(<span class="pl-s1">size</span><span class="pl-c1">=</span>(<span class="pl-c1">100</span>, <span class="pl-c1">2</span>))
<span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">mean</span>(<span class="pl-s1">a</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">0</span>)[<span class="pl-c1">0</span>] <span class="pl-c1">==</span> <span class="pl-s1">np</span>.<span class="pl-en">mean</span>(<span class="pl-s1">a</span>[:, <span class="pl-c1">0</span>])</pre></div>
<p dir="auto">However the above assertion fails for various sizes of the 0th-axis.</p>
<h3 dir="auto">Reproducing code example:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np


def check(f, a):
    axis = f(a, axis=0)
    manual = f(a[:, 0]), f(a[:, 1])
    print(axis[0] == manual[0])
    print(axis[1] == manual[1])
    print('0: {:e}'.format(axis[0] - manual[0]))
    print('1: {:e}'.format(axis[1] - manual[1]))
    print()

a1 = np.empty(shape=(5, 2), dtype=float)
a1[:, 0] = 0.69646919
a1[:, 1] = 0.28613933

a2 = np.empty(shape=(100, 2), dtype=float)
a2[:, 0] = 0.69646919
a2[:, 1] = 0.28613933

print('=== Checking a1 ===', end='\n\n')
check(np.mean, a1)  # Pass.
check(np.std, a1)  # Pass.
check(np.var, a1)  # Pass.
check(np.sum, a1)  # Pass.

print('=== Checking a2 ===', end='\n\n')
check(np.mean, a2)  # Fail.
check(np.std, a2)  # Fail.
check(np.var, a2)  # Fail.
check(np.sum, a2)  # Fail."><pre class="notranslate"><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-k">def</span> <span class="pl-en">check</span>(<span class="pl-s1">f</span>, <span class="pl-s1">a</span>):
    <span class="pl-s1">axis</span> <span class="pl-c1">=</span> <span class="pl-en">f</span>(<span class="pl-s1">a</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">0</span>)
    <span class="pl-s1">manual</span> <span class="pl-c1">=</span> <span class="pl-en">f</span>(<span class="pl-s1">a</span>[:, <span class="pl-c1">0</span>]), <span class="pl-en">f</span>(<span class="pl-s1">a</span>[:, <span class="pl-c1">1</span>])
    <span class="pl-en">print</span>(<span class="pl-s1">axis</span>[<span class="pl-c1">0</span>] <span class="pl-c1">==</span> <span class="pl-s1">manual</span>[<span class="pl-c1">0</span>])
    <span class="pl-en">print</span>(<span class="pl-s1">axis</span>[<span class="pl-c1">1</span>] <span class="pl-c1">==</span> <span class="pl-s1">manual</span>[<span class="pl-c1">1</span>])
    <span class="pl-en">print</span>(<span class="pl-s">'0: {:e}'</span>.<span class="pl-en">format</span>(<span class="pl-s1">axis</span>[<span class="pl-c1">0</span>] <span class="pl-c1">-</span> <span class="pl-s1">manual</span>[<span class="pl-c1">0</span>]))
    <span class="pl-en">print</span>(<span class="pl-s">'1: {:e}'</span>.<span class="pl-en">format</span>(<span class="pl-s1">axis</span>[<span class="pl-c1">1</span>] <span class="pl-c1">-</span> <span class="pl-s1">manual</span>[<span class="pl-c1">1</span>]))
    <span class="pl-en">print</span>()

<span class="pl-s1">a1</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">empty</span>(<span class="pl-s1">shape</span><span class="pl-c1">=</span>(<span class="pl-c1">5</span>, <span class="pl-c1">2</span>), <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">float</span>)
<span class="pl-s1">a1</span>[:, <span class="pl-c1">0</span>] <span class="pl-c1">=</span> <span class="pl-c1">0.69646919</span>
<span class="pl-s1">a1</span>[:, <span class="pl-c1">1</span>] <span class="pl-c1">=</span> <span class="pl-c1">0.28613933</span>

<span class="pl-s1">a2</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">empty</span>(<span class="pl-s1">shape</span><span class="pl-c1">=</span>(<span class="pl-c1">100</span>, <span class="pl-c1">2</span>), <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">float</span>)
<span class="pl-s1">a2</span>[:, <span class="pl-c1">0</span>] <span class="pl-c1">=</span> <span class="pl-c1">0.69646919</span>
<span class="pl-s1">a2</span>[:, <span class="pl-c1">1</span>] <span class="pl-c1">=</span> <span class="pl-c1">0.28613933</span>

<span class="pl-en">print</span>(<span class="pl-s">'=== Checking a1 ==='</span>, <span class="pl-s1">end</span><span class="pl-c1">=</span><span class="pl-s">'<span class="pl-cce">\n</span><span class="pl-cce">\n</span>'</span>)
<span class="pl-en">check</span>(<span class="pl-s1">np</span>.<span class="pl-s1">mean</span>, <span class="pl-s1">a1</span>)  <span class="pl-c"># Pass.</span>
<span class="pl-en">check</span>(<span class="pl-s1">np</span>.<span class="pl-s1">std</span>, <span class="pl-s1">a1</span>)  <span class="pl-c"># Pass.</span>
<span class="pl-en">check</span>(<span class="pl-s1">np</span>.<span class="pl-s1">var</span>, <span class="pl-s1">a1</span>)  <span class="pl-c"># Pass.</span>
<span class="pl-en">check</span>(<span class="pl-s1">np</span>.<span class="pl-s1">sum</span>, <span class="pl-s1">a1</span>)  <span class="pl-c"># Pass.</span>

<span class="pl-en">print</span>(<span class="pl-s">'=== Checking a2 ==='</span>, <span class="pl-s1">end</span><span class="pl-c1">=</span><span class="pl-s">'<span class="pl-cce">\n</span><span class="pl-cce">\n</span>'</span>)
<span class="pl-en">check</span>(<span class="pl-s1">np</span>.<span class="pl-s1">mean</span>, <span class="pl-s1">a2</span>)  <span class="pl-c"># Fail.</span>
<span class="pl-en">check</span>(<span class="pl-s1">np</span>.<span class="pl-s1">std</span>, <span class="pl-s1">a2</span>)  <span class="pl-c"># Fail.</span>
<span class="pl-en">check</span>(<span class="pl-s1">np</span>.<span class="pl-s1">var</span>, <span class="pl-s1">a2</span>)  <span class="pl-c"># Fail.</span>
<span class="pl-en">check</span>(<span class="pl-s1">np</span>.<span class="pl-s1">sum</span>, <span class="pl-s1">a2</span>)  <span class="pl-c"># Fail.</span></pre></div>
<h3 dir="auto">Numpy/Python version information:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; import sys, numpy; print(numpy.__version__, sys.version)
1.15.0 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609]"><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">sys</span>, <span class="pl-s1">numpy</span>; <span class="pl-en">print</span>(<span class="pl-s1">numpy</span>.<span class="pl-s1">__version__</span>, <span class="pl-s1">sys</span>.<span class="pl-s1">version</span>)
<span class="pl-c1">1.15</span>.<span class="pl-c1">0</span> <span class="pl-c1">3.5</span>.<span class="pl-c1">2</span> (<span class="pl-s1">default</span>, <span class="pl-v">Nov</span> <span class="pl-c1">23</span> <span class="pl-c1">2017</span>, <span class="pl-c1">16</span>:<span class="pl-c1">37</span>:<span class="pl-c1">01</span>) 
[<span class="pl-v">GCC</span> <span class="pl-c1">5.4</span><span class="pl-c1">.0</span> <span class="pl-c1">20160609</span>]</pre></div>
<h3 dir="auto">Further investigation</h3>
<p dir="auto">Checking various sizes for the 0th-axis for various methods:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
import pandas as pd


def generate(n):
    a = np.empty(shape=(n, 2), dtype=float)
    a[:, 0] = 0.69646919
    a[:, 1] = 0.28613933
    return a


def check(f, a):
    axis = f(a, axis=0)
    manual = f(a[:, 0]), f(a[:, 1])
    return axis[0] == manual[0] and axis[1] == manual[1]


funcs = ['mean', 'std', 'var', 'sum', 'prod']
results = []
for f in map(lambda x: getattr(np, x), funcs):
    results.append([check(f, generate(i)) for i in range(2, 101)])

with pd.option_context('display.max_rows', None):
    print(pd.DataFrame(
        columns=funcs,
        index=range(2, 101),
        data=np.asarray(results).T
    ))"><pre class="notranslate"><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-k">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>


<span class="pl-k">def</span> <span class="pl-en">generate</span>(<span class="pl-s1">n</span>):
    <span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">empty</span>(<span class="pl-s1">shape</span><span class="pl-c1">=</span>(<span class="pl-s1">n</span>, <span class="pl-c1">2</span>), <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">float</span>)
    <span class="pl-s1">a</span>[:, <span class="pl-c1">0</span>] <span class="pl-c1">=</span> <span class="pl-c1">0.69646919</span>
    <span class="pl-s1">a</span>[:, <span class="pl-c1">1</span>] <span class="pl-c1">=</span> <span class="pl-c1">0.28613933</span>
    <span class="pl-k">return</span> <span class="pl-s1">a</span>


<span class="pl-k">def</span> <span class="pl-en">check</span>(<span class="pl-s1">f</span>, <span class="pl-s1">a</span>):
    <span class="pl-s1">axis</span> <span class="pl-c1">=</span> <span class="pl-en">f</span>(<span class="pl-s1">a</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">0</span>)
    <span class="pl-s1">manual</span> <span class="pl-c1">=</span> <span class="pl-en">f</span>(<span class="pl-s1">a</span>[:, <span class="pl-c1">0</span>]), <span class="pl-en">f</span>(<span class="pl-s1">a</span>[:, <span class="pl-c1">1</span>])
    <span class="pl-k">return</span> <span class="pl-s1">axis</span>[<span class="pl-c1">0</span>] <span class="pl-c1">==</span> <span class="pl-s1">manual</span>[<span class="pl-c1">0</span>] <span class="pl-c1">and</span> <span class="pl-s1">axis</span>[<span class="pl-c1">1</span>] <span class="pl-c1">==</span> <span class="pl-s1">manual</span>[<span class="pl-c1">1</span>]


<span class="pl-s1">funcs</span> <span class="pl-c1">=</span> [<span class="pl-s">'mean'</span>, <span class="pl-s">'std'</span>, <span class="pl-s">'var'</span>, <span class="pl-s">'sum'</span>, <span class="pl-s">'prod'</span>]
<span class="pl-s1">results</span> <span class="pl-c1">=</span> []
<span class="pl-k">for</span> <span class="pl-s1">f</span> <span class="pl-c1">in</span> <span class="pl-en">map</span>(<span class="pl-k">lambda</span> <span class="pl-s1">x</span>: <span class="pl-en">getattr</span>(<span class="pl-s1">np</span>, <span class="pl-s1">x</span>), <span class="pl-s1">funcs</span>):
    <span class="pl-s1">results</span>.<span class="pl-en">append</span>([<span class="pl-en">check</span>(<span class="pl-s1">f</span>, <span class="pl-en">generate</span>(<span class="pl-s1">i</span>)) <span class="pl-k">for</span> <span class="pl-s1">i</span> <span class="pl-c1">in</span> <span class="pl-en">range</span>(<span class="pl-c1">2</span>, <span class="pl-c1">101</span>)])

<span class="pl-k">with</span> <span class="pl-s1">pd</span>.<span class="pl-en">option_context</span>(<span class="pl-s">'display.max_rows'</span>, <span class="pl-c1">None</span>):
    <span class="pl-en">print</span>(<span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(
        <span class="pl-s1">columns</span><span class="pl-c1">=</span><span class="pl-s1">funcs</span>,
        <span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-en">range</span>(<span class="pl-c1">2</span>, <span class="pl-c1">101</span>),
        <span class="pl-s1">data</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-en">asarray</span>(<span class="pl-s1">results</span>).<span class="pl-v">T</span>
    ))</pre></div>
<p dir="auto">This yields the following results:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="      mean    std    var    sum  prod
2     True   True   True   True  True
3     True   True   True   True  True
4     True   True   True   True  True
5     True   True   True   True  True
6     True   True   True   True  True
7     True   True   True   True  True
8    False  False  False  False  True
9    False  False  False  False  True
10   False  False  False  False  True
11    True   True   True  False  True
12    True   True   True  False  True
13    True   True   True  False  True
14    True   True   True   True  True
15    True   True   True   True  True
16   False  False  False  False  True
17   False  False  False  False  True
18   False  False  False  False  True
19   False  False  False  False  True
20   False  False  False  False  True
21   False  False  False  False  True
22    True   True   True  False  True
23   False  False  False  False  True
24   False  False  False  False  True
25   False  False  False  False  True
26   False  False  False  False  True
27   False  False  False  False  True
28   False  False  False  False  True
29   False  False  False  False  True
30   False  False  False  False  True
31   False  False  False  False  True
32   False  False  False  False  True
33   False  False  False  False  True
34   False  False  False  False  True
35   False  False  False  False  True
36   False  False  False  False  True
37   False  False  False  False  True
38   False  False  False  False  True
39   False  False  False  False  True
40   False  False  False  False  True
41   False  False  False  False  True
42   False  False  False  False  True
43   False  False  False  False  True
44   False  False  False  False  True
45   False  False  False  False  True
46   False  False  False  False  True
47   False  False  False  False  True
48   False  False  False  False  True
49   False  False  False  False  True
50   False  False  False  False  True
51   False  False  False  False  True
52   False  False  False  False  True
53   False  False  False  False  True
54   False  False  False  False  True
55   False  False  False  False  True
56   False  False  False  False  True
57   False  False  False  False  True
58   False  False  False  False  True
59   False  False  False  False  True
60   False  False  False  False  True
61   False  False  False  False  True
62   False  False  False  False  True
63   False  False  False  False  True
64   False  False  False  False  True
65   False  False  False  False  True
66   False   True   True  False  True
67   False   True   True  False  True
68   False   True   True  False  True
69   False  False  False  False  True
70   False  False  False  False  True
71   False  False  False  False  True
72   False  False  False  False  True
73   False  False  False  False  True
74   False  False  False  False  True
75   False  False  False  False  True
76   False  False  False  False  True
77   False  False  False  False  True
78   False  False  False  False  True
79   False  False  False  False  True
80   False  False  False  False  True
81   False  False  False  False  True
82   False  False  False  False  True
83   False  False  False  False  True
84   False  False  False  False  True
85   False  False  False  False  True
86   False  False  False  False  True
87   False  False  False  False  True
88   False  False  False  False  True
89   False  False  False  False  True
90   False  False  False  False  True
91   False  False  False  False  True
92   False  False  False  False  True
93   False  False  False  False  True
94   False  False  False  False  True
95   False  False  False  False  True
96   False  False  False  False  True
97   False  False  False  False  True
98   False  False  False  False  True
99   False  False  False  False  True
100  False  False  False  False  True"><pre class="notranslate">      <span class="pl-s1">mean</span>    <span class="pl-s1">std</span>    <span class="pl-s1">var</span>    <span class="pl-s1">sum</span>  <span class="pl-s1">prod</span>
<span class="pl-c1">2</span>     <span class="pl-v">True</span>   <span class="pl-c1">True</span>   <span class="pl-v">True</span>   <span class="pl-c1">True</span>  <span class="pl-v">True</span>
<span class="pl-c1">3</span>     <span class="pl-v">True</span>   <span class="pl-c1">True</span>   <span class="pl-v">True</span>   <span class="pl-c1">True</span>  <span class="pl-v">True</span>
<span class="pl-c1">4</span>     <span class="pl-v">True</span>   <span class="pl-c1">True</span>   <span class="pl-v">True</span>   <span class="pl-c1">True</span>  <span class="pl-v">True</span>
<span class="pl-c1">5</span>     <span class="pl-v">True</span>   <span class="pl-c1">True</span>   <span class="pl-v">True</span>   <span class="pl-c1">True</span>  <span class="pl-v">True</span>
<span class="pl-c1">6</span>     <span class="pl-v">True</span>   <span class="pl-c1">True</span>   <span class="pl-v">True</span>   <span class="pl-c1">True</span>  <span class="pl-v">True</span>
<span class="pl-c1">7</span>     <span class="pl-v">True</span>   <span class="pl-c1">True</span>   <span class="pl-v">True</span>   <span class="pl-c1">True</span>  <span class="pl-v">True</span>
<span class="pl-c1">8</span>    <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">9</span>    <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">10</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">11</span>    <span class="pl-v">True</span>   <span class="pl-c1">True</span>   <span class="pl-v">True</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">12</span>    <span class="pl-v">True</span>   <span class="pl-c1">True</span>   <span class="pl-v">True</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">13</span>    <span class="pl-v">True</span>   <span class="pl-c1">True</span>   <span class="pl-v">True</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">14</span>    <span class="pl-v">True</span>   <span class="pl-c1">True</span>   <span class="pl-v">True</span>   <span class="pl-c1">True</span>  <span class="pl-v">True</span>
<span class="pl-c1">15</span>    <span class="pl-v">True</span>   <span class="pl-c1">True</span>   <span class="pl-v">True</span>   <span class="pl-c1">True</span>  <span class="pl-v">True</span>
<span class="pl-c1">16</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">17</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">18</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">19</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">20</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">21</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">22</span>    <span class="pl-v">True</span>   <span class="pl-c1">True</span>   <span class="pl-v">True</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">23</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">24</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">25</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">26</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">27</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">28</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">29</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">30</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">31</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">32</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">33</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">34</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">35</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">36</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">37</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">38</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">39</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">40</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">41</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">42</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">43</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">44</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">45</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">46</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">47</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">48</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">49</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">50</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">51</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">52</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">53</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">54</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">55</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">56</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">57</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">58</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">59</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">60</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">61</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">62</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">63</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">64</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">65</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">66</span>   <span class="pl-v">False</span>   <span class="pl-c1">True</span>   <span class="pl-v">True</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">67</span>   <span class="pl-v">False</span>   <span class="pl-c1">True</span>   <span class="pl-v">True</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">68</span>   <span class="pl-v">False</span>   <span class="pl-c1">True</span>   <span class="pl-v">True</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">69</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">70</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">71</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">72</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">73</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">74</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">75</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">76</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">77</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">78</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">79</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">80</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">81</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">82</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">83</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">84</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">85</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">86</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">87</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">88</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">89</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">90</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">91</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">92</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">93</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">94</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">95</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">96</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">97</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">98</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">99</span>   <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span>
<span class="pl-c1">100</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">False</span>  <span class="pl-c1">False</span>  <span class="pl-v">True</span></pre></div>
<p dir="auto">On Numpy 1.14.2 I get the following:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="A = np.random.rand(1024,256,256,3)*255 # similar to a 1024 256x256 images tensor
print(np.mean(A,axis=(0,1,2))) # 64 bit works fine
print(np.mean(A.astype(np.float32),axis=(0,1,2))) # 32 bit works fails
print(np.mean(A.astype(np.float32))) # 32 bit works fine if without axis selection"><pre class="notranslate"><code class="notranslate">A = np.random.rand(1024,256,256,3)*255 # similar to a 1024 256x256 images tensor
print(np.mean(A,axis=(0,1,2))) # 64 bit works fine
print(np.mean(A.astype(np.float32),axis=(0,1,2))) # 32 bit works fails
print(np.mean(A.astype(np.float32))) # 32 bit works fine if without axis selection
</code></pre></div>
<p dir="auto">results in:<br>
[127.50656009 127.49165182 127.51390158]<br>
[64. 64. 64.]<br>
127.50413</p>
<p dir="auto">Even considering float32 precision, this type of failure seems odd, especially given that the entire array's mean can be calculated succesfully</p>