<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/859" rel="nofollow">http://projects.scipy.org/numpy/ticket/859</a> on 2008-07-24 by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/cournape/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/cournape">@cournape</a>, assigned to <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/cournape/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/cournape">@cournape</a>.</em></p>
<p dir="auto">Detected under valgrind, and looking at the code, it looks like there is a problem, but I don't know enough about that code to solve it quickly:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Tests compress2d==5148==
==5148== Conditional jump or move depends on uninitialised value(s)
==5148==    at 0x4636A27: PyArray_MapIterReset (arrayobject.c:10242)
==5148==    by 0x466B511: array_subscript (arrayobject.c:2549)
==5148==    by 0x466C07B: array_subscript_nice (arrayobject.c:3173)
==5148==    by 0x80C7235: PyEval_EvalFrameEx (ceval.c:1193)
==5148==    by 0x80CB0D6: PyEval_EvalCodeEx (ceval.c:2836)
==5148==    by 0x80C92DD: PyEval_EvalFrameEx (ceval.c:3669)
==5148==    by 0x80C95C4: PyEval_EvalFrameEx (ceval.c:3659)
==5148==    by 0x80CB0D6: PyEval_EvalCodeEx (ceval.c:2836)
==5148==    by 0x81133BA: function_call (funcobject.c:517)
==5148==    by 0x805CB36: PyObject_Call (abstract.c:1861)
==5148==    by 0x80C7CE3: PyEval_EvalFrameEx (ceval.c:3853)
==5148==    by 0x80CB0D6: PyEval_EvalCodeEx (ceval.c:2836)"><pre class="notranslate"><code class="notranslate">Tests compress2d==5148==
==5148== Conditional jump or move depends on uninitialised value(s)
==5148==    at 0x4636A27: PyArray_MapIterReset (arrayobject.c:10242)
==5148==    by 0x466B511: array_subscript (arrayobject.c:2549)
==5148==    by 0x466C07B: array_subscript_nice (arrayobject.c:3173)
==5148==    by 0x80C7235: PyEval_EvalFrameEx (ceval.c:1193)
==5148==    by 0x80CB0D6: PyEval_EvalCodeEx (ceval.c:2836)
==5148==    by 0x80C92DD: PyEval_EvalFrameEx (ceval.c:3669)
==5148==    by 0x80C95C4: PyEval_EvalFrameEx (ceval.c:3659)
==5148==    by 0x80CB0D6: PyEval_EvalCodeEx (ceval.c:2836)
==5148==    by 0x81133BA: function_call (funcobject.c:517)
==5148==    by 0x805CB36: PyObject_Call (abstract.c:1861)
==5148==    by 0x80C7CE3: PyEval_EvalFrameEx (ceval.c:3853)
==5148==    by 0x80CB0D6: PyEval_EvalCodeEx (ceval.c:2836)
</code></pre></div>
<p dir="auto">The problem is inside the macro PyArrayIter_GOTO: some items of the argument destination are accessed without having been set previously (when they are swapped with the copyswap function).</p>
<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/333" rel="nofollow">http://projects.scipy.org/numpy/ticket/333</a> on 2006-10-11 by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/FrancescAlted/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/FrancescAlted">@FrancescAlted</a>, assigned to unknown.</em></p>
<p dir="auto">The next exposes the problem:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [142]:dt1=numpy.dtype('i4')
In [143]:numpy.array(0, dtype=dt1.type)
Out[143]:array(0)
# good, but
In [144]:dt2=numpy.dtype(('i4',(2,)))
In [145]:numpy.array(0, dtype=dt2.type)
---------------------------------------------------------------------------
exceptions.MemoryError                               Traceback (most recent call last)

/home/faltet/python.nobackup/numpy/&lt;ipython console&gt;

MemoryError:"><pre class="notranslate"><code class="notranslate">In [142]:dt1=numpy.dtype('i4')
In [143]:numpy.array(0, dtype=dt1.type)
Out[143]:array(0)
# good, but
In [144]:dt2=numpy.dtype(('i4',(2,)))
In [145]:numpy.array(0, dtype=dt2.type)
---------------------------------------------------------------------------
exceptions.MemoryError                               Traceback (most recent call last)

/home/faltet/python.nobackup/numpy/&lt;ipython console&gt;

MemoryError:
</code></pre></div>
<p dir="auto">Moreover:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [147]:numpy.array([0], dtype=dt1.type)
Out[147]:array([0])
# good, but
In [148]:numpy.array([0], dtype=dt2.type)
---------------------------------------------------------------------------
exceptions.TypeError                                 Traceback (most recent call last)

/home/faltet/python.nobackup/numpy/&lt;ipython console&gt;

TypeError: expected a readable buffer object"><pre class="notranslate"><code class="notranslate">In [147]:numpy.array([0], dtype=dt1.type)
Out[147]:array([0])
# good, but
In [148]:numpy.array([0], dtype=dt2.type)
---------------------------------------------------------------------------
exceptions.TypeError                                 Traceback (most recent call last)

/home/faltet/python.nobackup/numpy/&lt;ipython console&gt;

TypeError: expected a readable buffer object
</code></pre></div>
<p dir="auto">I'd say that the .type is an scalar type that should be independent of the shape of the base dtype.</p>