|
From: Dominique O. <dom...@gm...> - 2007-02-01 23:13:35
|
Daniel,
I just installed the latest NumPy 1.0.1 and downloaded PySparse from
cvs. I don't have the old Numeric installed, and testing PySparse
caused a number of problems. Here are a few dirty changes to make
things work. I suspect it would be best to have a config file (a la
Matplotlib) while users are still transitioning from Numeric to NumPy,
in order to know which they are currently using. In the meantime, here
are the difficulties I came across:
On line 19 of Src/ll_mat.c, there is an #include
Numeric/array_object.h which breaks things
when using NumPy and the old Numeric is not installed. I commented it
out and could compile the everything.
In test_superlu.py, replace
import Numeric
with
import numpy as Numeric
Of course, it would be better to import the appropriate "numerix" according to
local settings.
In test_sparray.py, there is an error at the top, replace
from pysparse import sparray
with
from pysparse.sparray import sparray
After that I still get the error:
testgetitem (__main__.test_sparray) ... ERROR
testinit (__main__.test_sparray) ... ok
testsetitem (__main__.test_sparray) ... ok
======================================================================
ERROR: testgetitem (__main__.test_sparray)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_sparray.py", line 30, in testgetitem
self.assertEqual(a[:,3], map(float, (1,2,3,4,5)))
File "/usr/lib/python2.3/unittest.py", line 301, in failUnlessEqual
if not first == second:
ValueError: The truth value of an array with more than one element is
ambiguous. Use a.any() or a.all()
----------------------------------------------------------------------
Ran 3 tests in 0.027s
FAILED (errors=1)
I am not familiar with the unittest module, but I guess the test class should
have a custom assertEqual method.
In test_spmatrix.py, an error occurs from spmatrix_utils.py, saying that
pysparse_version doesn't exist. Indeed it doesn't. So in spmatrix_utils.py, I
commented out line 3 (which imports the fictitious module) and replace line 66
with
comment = 'generated using pysparse-%s\n' % (pysparse__version__, )
Next, I changed line 6 of test_spmatrix.py to read
import numpy as Numeric, numpy.oldnumeric.random_array as RandomArray
and line 119 to read
import numpy as Numeric
After that, test_spmatrix.py ran just fine. Sorry if the changes above
look dirty. This is just to let you know where the current tests
break.
Dominique
On 1/4/07, Daniel Wheeler <dan...@ni...> wrote:
>
> On Jan 3, 2007, at 4:37 AM, Roman Geus wrote:
>
> > Hello Daniel
> >
> > Thanks a lot for your contribution. Judging from the description your
> > changes make much sense. I have not been using pysparse myself for a
> > long time so cannot be the person to test new versions.
>
> Hi Roman,
>
> Hope all is well. No problem about testing. We still use it a lot
> with FiPy.
> I will release a new version of pysparse ASAP and give it a version
> number
> of 1.0 since we have changed the namespace and it has now become
> dependent
> on a new array package.
>
> Cheers
>
> >
> > Happy new year!
> > -- Roman
> >
> > 2007/1/2, Daniel Wheeler <dan...@ni...>:
> >>
> >> The changes for compatibility with numpy have now been merged back
> >> onto
> >> HEAD. I will do a new release in the near future.
> >>
> >> Cheers
> >>
> >>
> >> On Dec 21, 2006, at 12:36 PM, Daniel Wheeler wrote:
> >>
> >> Numeric is dying slowly and being replaced by numpy.
> >> With this in mind, I have updated pysparse to use the new numpy,
> >> this is all
> >> on a branch at the moment.
> >> It was straightforward matter of changing the imported header
> >> files from
> >> Numeric's to numpy's. I am sending this email
> >> to check to see if everybody is happy with the changes that have
> >> been made.
> >> If there are no objections, I can merge back
> >> onto the trunk and maybe make a new release. Changes and issues
> >> are as
> >> follows:
> >>
> >> - Created a C macro defined from setup.py that either imports
> >> numpy's or
> >> Numeric's headers depending
> >> on the flag "use_numpy". The C macro was confusing me for
> >> awhile, but I
> >> think it works
> >> now.
> >>
> >> - I have changed the name space of itsolvers, spmatrix, jdsym
> >> etc to all
> >> lie under pysparse. So, instead of
> >>
> >> >>> import spmatrix
> >>
> >> you do
> >>
> >> >>> from pysparse import spmatrix
> >>
> >> This change stops site-packages from being polluted. At the
> >> moment
> >> the branch version is using pysparse_numpy
> >> or pysparse_Numeric as the pysparse name space for testing
> >> purposes.
> >>
> >> - The branch can be checked out via:
> >>
> >> $ cvs -d:ext:ui...@py...:/cvsroot/pysparse
> >> co -r
> >> branch-numpy pysparse
> >>
> >> - I have updated the Examples and Test directories to import from
> >> pysparse. They all seem to work apart from stuff that was broken
> >> already.
> >>
> >> - I got rid of pysparse_version.py and replaced it with an
> >> __init__.py
> >> in Lib, which does the imports and holds a __version__ variable.
> >> So you can now do:
> >>
> >> >>> import pysparse_numpy
> >> >>> print pysparse_numpy.__version__
> >> 0.34.032-numpy
> >>
> >> - I think the default flag should be use_numpy=True since most
> >> users
> >> will now be getting numpy rather than Numeric. This could
> >> be automated with a try and except, which tests for the
> >> availability
> >> of numpy or Numeric. What do you think?
> >>
> >> - You can diff from your working copy of pysparse with "cvs
> >> diff -c -r
> >> branch-numpy" to check the changes.
> >>
> >> - Is it worth bumping the version number of pysparse to 1.0,
> >> since we
> >> will be breaking the name space (interface change)?
> >>
> >> - If you are compiling against numpy, the numpy header files
> >> don't seem
> >> to be going into the right place at least on my two computers.
> >> I haven't resolved this problem yet. For now, I was just
> >> copying the
> >> .h files from .../site-packages/python/numpy/core/include/
> >> to Include/Lib/numpy
> >> in my working copy of pysparse.
> >>
> >> Merry Christmas!
> >>
> >>
> >> --
> >> Daniel Wheeler
> >>
> >> ---------------------------------------------------------------------
> >> ----
> >> Take Surveys. Earn Cash. Influence the Future of IT
> >> Join SourceForge.net's Techsay panel and you'll get the chance to
> >> share your
> >> opinions on IT & business topics through brief surveys - and earn
> >> cash
> >> http://www.techsay.com/default.php?
> >> page=join.php&p=sourceforge&CID=DEVDEV_______________________________
> >> ________________
> >> Pysparse-users mailing list
> >> Pys...@li...
> >> https://lists.sourceforge.net/lists/listinfo/pysparse-users
> >>
> >>
> >> --
> >>
> >> Daniel Wheeler
> >>
> >>
> >> ---------------------------------------------------------------------
> >> ----
> >> Take Surveys. Earn Cash. Influence the Future of IT
> >> Join SourceForge.net's Techsay panel and you'll get the chance to
> >> share your
> >> opinions on IT & business topics through brief surveys - and earn
> >> cash
> >> http://www.techsay.com/default.php?
> >> page=join.php&p=sourceforge&CID=DEVDEV
> >>
> >> _______________________________________________
> >> Pysparse-users mailing list
> >> Pys...@li...
> >> https://lists.sourceforge.net/lists/listinfo/pysparse-users
>
> --
> Daniel Wheeler
>
>
>
>
|