[SciPy-user] scipy debian packages

Arnd Baecker arnd.baecker at web.de
Thu Oct 21 02:46:08 CDT 2004


Hi,

I looked a bit further into this
by installing a fresh python, Numeric 23.5 (tar.gz from sourceforge)
and scipy.


On Wed, 20 Oct 2004, Robert Kern wrote:

> Arnd Baecker wrote:
> > On Wed, 20 Oct 2004, Robert Kern wrote:
> >
> >
> >>Arnd Baecker wrote:
> >>
> >>
> >>>  File "/usr/lib/python2.3/site-packages/scipy/xplt/slice3.py", line 1575,
> >>>in _construct3
> >>>    mask = find_mask (below, _node_edges3 [itype])
> >>>TypeError: Array can not be safely cast to required type
> >>
> >>This is a problem with Numeric. Bug the maintainer of python-numeric to
> >>update from the latest 23.5 tarball. The fix somehow didn't make it into
> >>the first release of the 23.5 tarball but should be in the copy there now.
> >
> >
> > Many thanks! Do you have a simple example demonstrating the problem
> > in pure Numeric code?
> > (this would make it simpler to illustrate/test the problem without
> > referring to scipy and thus more convincing, IMHO).
>
> It's an issue with the function arrayfns.find_mask(x, y) when
> x.typecode() == UInt8 and y.typecode() == Int. With the function not
> having any docstrings, I can't construct an example right now.

I cannot confirm this: From the failing example in slice3.py
I cooked up this example here

import Numeric
print Numeric.__version__
import arrayfns
x=Numeric.array([[0, 0, 0, 1], [1, 1, 1, 0]])
y=Numeric.array([[0,  1], [0,  1], [1,  0], [1,  0]])
print x.typecode()
print y.typecode()
arrayfns.find_mask(x, y)

Using the Numeric version from debian testing gives
Python 2.3.4 (#2, Sep 24 2004, 08:39:09)
[...]
In [1]: import Numeric
In [2]: print Numeric.__version__
23.5
In [3]: import arrayfns
In [4]: x=Numeric.array([[0, 0, 0, 1], [1, 1, 1, 0]])
In [5]: y=Numeric.array([[0,  1], [0,  1], [1,  0], [1,  0]])
In [6]: print x.typecode()
l
In [7]: print y.typecode()
l
In [8]: arrayfns.find_mask(x, y)
---------------------------------------------------------------------------
TypeError      Traceback (most recent call last)
TypeError: Array can not be safely cast to required type
In [9]: arrayfns.find_mask(x.astype("b"), y.astype("b"))
Out[9]: array([1, 0, 1, 0],'i')


Using the freshly compiled one gives
Python 2.3.3 (#1, Oct 20 2004, 19:22:14)
[...]
In [1]: import Numeric
In [2]: print Numeric.__version__
23.5
In [3]: import arrayfns
In [4]: x=Numeric.array([[0, 0, 0, 1], [1, 1, 1, 0]])
In [5]: y=Numeric.array([[0,  1], [0,  1], [1,  0], [1,  0]])
In [6]: print x.typecode()
l
In [7]: print y.typecode()
l
In [8]: arrayfns.find_mask(x, y)
Out[8]: array([1, 0, 1, 0])
In [9]: arrayfns.find_mask(x.astype("b"), y.astype("b"))
Out[9]: array([1, 0, 1, 0])

((I just realize that it is different python versions
(2.3.3 vs. 2.3.4), but I hope this does not matter here))

> > Until that happens: is there a file which I could hand-edit
> > in my installation (of course this would only work if it is on the .py
> > level) to remove the problem for the moment?
>
> This is untested, but it should work: just before the error I isolated
> above, put the line
>
>      below = below.astype(_node_edges3[itype].typecode())


So from the above it seems that in 23.5 (the one I get with debian)
only the astype("b") works.

Therefore a quick fix (which works for me) is:

   mask = find_mask (below.astype("b"), _node_edges3 [itype].astype("b"))

I think that this should be enough of an example to ask the debian
maintainer of python-numeric for an update.
((Somehow I am wondering, for how long the first release of
the 23.5 tarball was there ... very unfortunate ...))
Unless there are any further comments, I will mail
the maintainer tomorrow.

Best,

Arnd



More information about the SciPy-user mailing list