On 22 January 2014 06:14, Daniel Wheeler <[email protected]> wrote:

> On Sat, Jan 18, 2014 at 5:03 PM, Phillip Feldman
>
> > TypeError: Cannot cast array data from dtype('int64') to dtype('int32')
> > according to the rule 'safe'
>
> It seems like an inconsistency between PySparse and Numpy. You may be
> using a 64 bit Numpy with FiPy, but a version of PySparse that was
> built with a 32 bit Numpy. A gruesome hack to fix this requires
> changing the line above from
>
>     self.matrix.update_add_at(vector, id1, id2)
>
> to
>
>    self.matrix.update_add_at(vector, id1.astype('int32'),
> id2.astype('int64'))
>
> You may have to do this in more than one place, which could get ugly.
>

There will be other problems.  There were similar issues in FiPy itself,
please see

http://matforge.org/fipy/ticket/645

I had a (very) quick look at the PySparse source.  It is relatively easy to
fix the numpy array dtypes, but you're going to find that "int" occurs an
awful lot in the pysparse code, and as the ticket above indicates, "int" on
Windows x86-64 is *still* 32 bit.  This can lead to a lot of frustration.


> An alternative is to just use the Scipy solvers, so at the command
> line use "python mesh2D.py --scipy" to stipulate the Scipy solvers.
>

I could not get pysparse working, so I use the scipy solvers.  I really
don't know C too well, otherwise I would have taken a better crack at
fixing it.  (I *think* changing all the "int" types to "size_t" could fix
these issues, but I'm not sure and haven't tried it.  "size_t" correctly
reflects the change between a 32bit and 64bit binary on Windows.)
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to