<p dir="auto">For some small example data, on my system (and one other), <code class="notranslate">operator.lshift</code> and <code class="notranslate">operator.rshift</code> randomly return incorrect results.</p>
<p dir="auto">PC 1:</p>
<ul dir="auto">
<li>macOS 10.13.2</li>
<li>Anaconda (latest)</li>
<li>Python 3.6.4</li>
<li>Numpy 1.13.3</li>
</ul>
<p dir="auto">PC 2:</p>
<ul dir="auto">
<li>Same as PC 1, except Numpy 1.14.0</li>
<li>New Conda env</li>
</ul>
<p dir="auto">Third config:</p>
<ul dir="auto">
<li>PC 1, but with system Python 2.7 and a clean VENV</li>
<li>Numpy 1.14.0</li>
</ul>
<p dir="auto">Simple test (only fails on some data) and doesn't fail on third configuration. But it can be reproduced reliably.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import numpy as np

if __name__ == '__main__':
    x = np.load('x.npy')
    y = np.load('y.npy')

    print(x.shape)  # (2, 3, 4)
    print(y.shape)  # (2, 3, 4)

    print(x.shape == y.shape)  # True

    print(x[0, 2, 0] &lt;&lt; y[0, 2, 0])  # 1476395008
    print((x &lt;&lt; y)[0, 2, 0])  # 0

    print(x[0, 2, 0] &lt;&lt; y[0, 2, 0] == (x &lt;&lt; y)[0, 2, 0])  # False"><pre class="notranslate"><code class="notranslate">import numpy as np

if __name__ == '__main__':
    x = np.load('x.npy')
    y = np.load('y.npy')

    print(x.shape)  # (2, 3, 4)
    print(y.shape)  # (2, 3, 4)

    print(x.shape == y.shape)  # True

    print(x[0, 2, 0] &lt;&lt; y[0, 2, 0])  # 1476395008
    print((x &lt;&lt; y)[0, 2, 0])  # 0

    print(x[0, 2, 0] &lt;&lt; y[0, 2, 0] == (x &lt;&lt; y)[0, 2, 0])  # False
</code></pre></div>
<p dir="auto">Attaching example data/project on which this happens (produced with <code class="notranslate">np.save</code>):<br>
<a href="https://github.com/numpy/numpy/files/1626656/numpy_test.zip">numpy_test.zip</a></p>
<p dir="auto">I strongly suspect this isn't really a Numpy bug, but maybe Python 3 related or possibly related to the compiler Anaconda uses.</p>
<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/1856" rel="nofollow">http://projects.scipy.org/numpy/ticket/1856</a> on 2011-06-02 by trac user klasj, assigned to unknown.</em></p>
<p dir="auto">The bitshift operations, both right and left cycles when they are shifted more bits than<br>
the length of the datatype. This happens for both int32 and int64 but not for int16,<br>
unsigned integers works as expected. In the example below version 1.6.1 is used but<br>
this is also present in at least 1.5.0.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [1]: import numpy as np

In [2]: np.right_shift(np.int32(8),32)

Out[2]: 8

In [3]: np.right_shift(np.int64(8),64)

Out[3]: 8

In [4]: np.right_shift(np.int16(8),16)

Out[4]: 0

In [5]: np.left_shift(np.int32(8),32)

Out[5]: 8

In [6]: np.left_shift(np.int64(8),64)

Out[6]: 8

In [7]: np.left_shift(np.int16(8),16)

Out[7]: 524288

In [8]: np.version.full_version

Out[8]: '1.6.1.dev-08953ea'"><pre class="notranslate"><code class="notranslate">In [1]: import numpy as np

In [2]: np.right_shift(np.int32(8),32)

Out[2]: 8

In [3]: np.right_shift(np.int64(8),64)

Out[3]: 8

In [4]: np.right_shift(np.int16(8),16)

Out[4]: 0

In [5]: np.left_shift(np.int32(8),32)

Out[5]: 8

In [6]: np.left_shift(np.int64(8),64)

Out[6]: 8

In [7]: np.left_shift(np.int16(8),16)

Out[7]: 524288

In [8]: np.version.full_version

Out[8]: '1.6.1.dev-08953ea'
</code></pre></div>