[SciPy-dev] PyArray_CanCastSafely(exact,inexact) on 64-bit

Arnd Baecker arnd.baecker at web.de
Tue Nov 1 04:06:20 CST 2005


On Mon, 31 Oct 2005, Travis Oliphant wrote:

> Arnd Baecker wrote:
>
> >That is great news! I also get this on my 64 Bit machine!
> >
> Wonderful...
>
> >Just in case it has fallen through the cracks:
> >Concerning the check_integer problem:
> >
> >    def check_integer(self):
> >        from scipy import stats
> >        a = stats.randint.rvs(1,20,size=(3,4))
> >        fname = tempfile.mktemp('.dat')
> >        io.write_array(fname,a)
> >        b = io.read_array(fname,atype=N.Int)
> >        assert_array_equal(a,b)
> >        os.remove(fname)
> >
> >Executing this line by line shows the error for
> >  b = io.read_array(fname,atype=N.Int)
> >
> >Doing
> >  b = io.read_array(fname)
> >reads in the array, but it gives floats.
> >
> >However,
> >  b = io.read_array(fname,atype=N.Int32)
> >works.
> >
> >If this is the intended behaviour (also on 32Bit),
> >the unit test should be changed accordingly...
> >
> >
> What is the type of 'a' (i.e. stats.randint.rvs(1,20,size=(3,4))  )
> on your platform?
>
> This does look like a problem of type mismatch on 64-bit that we can
> handle much better now.
>
> It looks like randint is returning 32-bit numbers, but N.Int is 'l'
> which on your 64-bit platform is a 64-bit integer.  This would
> definitely be the problem.

In [1]: import scipy
In [2]: print scipy.__core_version__, scipy.__scipy_version__
0.4.3.1408 0.4.2_1409
In [3]: a=scipy.stats.randint.rvs(1,20,size=(3,4))
In [4]: a.dtypechar
Out[4]: 'l'
In [5]: a.dtypestr
Out[5]: '<i8'
In [6]: scipy.Int
Out[6]: 'p'
In [7]: scipy.typecodes
Out[7]:
{'All': '?bhilqBHILQfdgFDGSUVO',
 'AllFloat': 'fdgFDG',
 'AllInteger': 'bBhHiIlLqQ',
 'Character': 'S1',
 'Complex': 'FDG',
 'Float': 'fdg',
 'Integer': 'bhilq',
 'UnsignedInteger': 'BHILQ'}
In [8]: scipy.Int,scipy.Int0,scipy.Int8,scipy.Int16,scipy.Int32
Out[8]: ('p', 'p', 'b', 'h', 'i')

So `scipy.Int` is not 'l'?? And what is 'p'? (is it intp
as described in your newcore manual? - should this arise here?)

> I've changed the test...

Hmm - can't see any difference to previous versions?

Best, Arnd




More information about the Scipy-dev mailing list