Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 176914

Summary: dev-python/numeric is not compatible with python-2.5 on 64bit arches
Product: Gentoo Linux Reporter: Darren Dale <dsdale24>
Component: Current packagesAssignee: Python Gentoo Team <python>
Status: RESOLVED FIXED    
Severity: major CC: anarchy, coldwind, delimy, denilsonsa, dsd, rmay31
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 148333    
Attachments: numarray fix
python 2.5 fix for numeric-24.2

Description Darren Dale 2007-05-03 13:07:17 UTC
Numeric is not compatible with python-2.5 on 64bit arches. For example:

In [1]: import Numeric

In [2]: Numeric.arange(0,10)
Out[2]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

In [3]: Numeric.arange(0,10)[:10]
Out[3]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

In [4]: Numeric.arange(0,10)[:]
Out[4]: zeros((0,), 'l')

That last line should yield the same result as the previous command. Some discussion can be found in this thread: http://projects.scipy.org/pipermail/numpy-discussion/2007-May/027616.html

The problem has been reported upstream, but is unlikely to be addressed. Numeric is not supported anymore, in favor of numpy.

Reproducible: Always
Comment 1 Sébastien Fabbro (RETIRED) gentoo-dev 2007-05-03 14:51:37 UTC
which version of numeric are you using? I can't reproduce it with numeric-24.2-r4 (which includes a fair amount of patches to the stable one) on my amd64 box.
Comment 2 Darren Dale 2007-05-03 17:29:50 UTC
I am also using numeric-24.2-r4. It was fine with python-2.4, I only see the error with python-2.5 (specifically python-2.5-r2). Which python are you using? 
Comment 3 Sébastien Fabbro (RETIRED) gentoo-dev 2007-05-04 17:53:01 UTC
I am using python-2.4, you're right. I have not got the time to dig in python-2.5.
Do all tests run fine?
Comment 4 Darren Dale 2007-05-04 18:43:14 UTC
$ python test.py
......E.E...........E.........E..............
======================================================================
ERROR: test concatenate
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 433, in testConcatenate
    assert_eq(Numeric.concatenate((self.a[:3], self.a[3:])), [0,1,2,3,4,5])
  File "test.py", line 28, in assert_eq
    assert eq(a,b)
  File "test.py", line 24, in eq
    (aa.shape, a, ab.shape, b))
ValueError: sequences have different shapes:
a(3,)=array([0, 1, 2])
b(6,)=[0, 1, 2, 3, 4, 5]

======================================================================
ERROR: Test the diagonal function.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 584, in testDiagonal
    assert_eq(Numeric.diagonal(c,1), [[2,7,4], [2,7,4]])
  File "test.py", line 28, in assert_eq
    assert eq(a,b)
  File "test.py", line 24, in eq
    (aa.shape, a, ab.shape, b))
ValueError: sequences have different shapes:
a(4, 2)=array([[5, 1],
       [6, 2],
       [7, 3],
       [8, 4]])
b(2, 3)=[[2, 7, 4], [2, 7, 4]]

======================================================================
ERROR: Test of average function.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 297, in testAverage
    c.shape=(3,2)
ValueError: total size of new array must be unchanged

======================================================================
ERROR: Test slicing, like x[1:3]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 141, in testSlice
    assert_eq(a[0:], a)
  File "test.py", line 28, in assert_eq
    assert eq(a,b)
  File "test.py", line 24, in eq
    (aa.shape, a, ab.shape, b))
ValueError: sequences have different shapes:
a(0,)=zeros((0,), 'l')
b(4,)=array([1, 2, 3, 4])

----------------------------------------------------------------------
Ran 45 tests in 0.264s

FAILED (errors=4)
Comment 5 delimy 2007-05-24 06:42:23 UTC
dev-lang/python-2.5.1-r2
dev-python/numeric-24.2-r4

even 32bit x86 couldn't pass all test:

delimy@COIN Test $ python test.py
........E....................................
======================================================================
ERROR: Test the diagonal function.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 584, in testDiagonal
    assert_eq(Numeric.diagonal(c,1), [[2,7,4], [2,7,4]])
  File "test.py", line 28, in assert_eq
    assert eq(a,b)
  File "test.py", line 24, in eq
    (aa.shape, a, ab.shape, b))
ValueError: sequences have different shapes:
a(4, 2)=array([[5, 1],
       [6, 2],
       [7, 3],
       [8, 4]])
b(2, 3)=[[2, 7, 4], [2, 7, 4]]

----------------------------------------------------------------------
Ran 45 tests in 0.137s

FAILED (errors=1)


but the example above runs correctly.
Comment 6 Sébastien Fabbro (RETIRED) gentoo-dev 2007-05-25 18:32:03 UTC
Hi,

It gave me more work than I had thougth initially. Anyway, I produced some new patches for 2.5, which I tested on x86. I could not test them with python 2.5 on my amd64 box (they worked for 2.4). I put those patches on the gentooscience overlay (layman -a science). 
Please let me know if they also work on amd64 and any other arches you may test.

Thanks

Sébastien
Comment 7 Sébastien Fabbro (RETIRED) gentoo-dev 2007-06-07 14:11:56 UTC
Well, it seems my patches don't do anything on amd64. I was thinking of masking it, but there are too many apps still depending on numeric.
I will need more time than I can give on this package, so if anyone has an idea about it, it'd help a lot. Upstream won't do anything since it is discontinued.
Comment 8 Steven Hay 2007-06-16 14:40:42 UTC
From the numeric website:

Numeric was the first arrayobject built for Python.  It has been quite successful and is used in a wide variety of settings and applications.   Maintenance has ceased for Numeric, and users should transisition to NumPy as quickly as possible.   There is a module called numpy.oldnumeric.alter_code1 in NumPy that can make the transition to NumPy easier (it will automatically perform the search-and-replace style changes that need to be made to python code that uses Numeric to make it work with NumPy).

If porting to numpy is this easy, maybe we should just patch the programs that require numeric and remove it as a dependency.

Comment 9 Daniel Drake (RETIRED) gentoo-dev 2007-06-22 22:18:40 UTC
Created attachment 122841 [details, diff]
numarray fix

numarray has an almost identical problem (due to the int/size_t thing), which is fixed by this patch. Maybe it's useful for fixing numeric.
Comment 10 Daniel Drake (RETIRED) gentoo-dev 2007-06-22 22:19:15 UTC
forgot to mention, credit for that patch goes to Todd Miller.
Comment 11 Santiago M. Mola (RETIRED) gentoo-dev 2007-07-16 15:15:48 UTC
(In reply to comment #8)
> If porting to numpy is this easy, maybe we should just patch the programs that
> require numeric and remove it as a dependency.

We should work with upstream to migrate all packages. The migration will be neccessary at some point even if numeric is fixed.

Packages using numeric are:
dev-python/f2py
dev-python/fonttools
dev-python/gnuplot-py
dev-python/matplotlib
dev-python/pycairo
dev-python/pyclimate
dev-python/pygame
dev-python/pygtk
dev-python/pyqwt
dev-python/python-biggles
dev-python/rpy
dev-python/scientificpython
dev-python/ttfquery
dev-python/visual
games-arcade/pydance
games-rpg/galaxymage
gnome-extra/music-applet
sci-biology/biopython
sci-libs/plplot
sci-libs/pymmlib
sci-physics/camfr
Comment 12 Darren Dale 2007-07-16 15:39:04 UTC
(In reply to comment #11)
> We should work with upstream to migrate all packages. The migration will be
> neccessary at some point even if numeric is fixed.

> Packages using numeric are:
[...]
> dev-python/matplotlib

The next public release of matplotlib (0.91) will not support numeric or numarray, only numpy.
Comment 13 Sébastien Fabbro (RETIRED) gentoo-dev 2007-07-16 16:03:09 UTC
(In reply to comment #11)

> We should work with upstream to migrate all packages. The migration will be
> neccessary at some point even if numeric is fixed.
> 
> Packages using numeric are:

See bug #181653 comment #8 for comments on packages.
Comment 14 Daniel Drake (RETIRED) gentoo-dev 2007-08-31 20:58:23 UTC
Created attachment 129716 [details, diff]
python 2.5 fix for numeric-24.2

I just wrote a patch to fix it for python 2.5. Patch should be applied conditionally based on python version. Will contact upstream after the long weekend. Enjoy!
Comment 15 Jory A. Pratt gentoo-dev 2007-09-02 04:29:59 UTC
(In reply to comment #14)
> Created an attachment (id=129716) [edit]
> python 2.5 fix for numeric-24.2
> 
> I just wrote a patch to fix it for python 2.5. Patch should be applied
> conditionally based on python version. Will contact upstream after the long
> weekend. Enjoy!
> 

Patch is busted with latest patchset.

>>> Unpacking source...
>>> Unpacking Numeric-24.2.tar.gz to /var/tmp/portage/dev-python/numeric-24.2-r6/work
 * Applying numeric-24.2-arrayobject.patch ...                            [ ok ]
 * Applying numeric-24.2-umath.patch ...                                  [ ok ]
 * Applying numeric-24.2-eigen.patch ...                                  [ ok ]
 * Applying numeric-24.2-test.patch ...                                   [ ok ]
 * Applying numeric-24.2-python25.patch ...

 * Failed Patch: numeric-24.2-python25.patch !
 *  ( /usr/portage/dev-python/numeric/files/numeric-24.2-python25.patch )
Comment 16 Sébastien Fabbro (RETIRED) gentoo-dev 2007-09-03 11:20:45 UTC
I included a bunch of fixes including dsd in the lastest numeric in the tree.

I don't see the problem initially reported on amd64 and all tests pass fine now.
Although numeric is probably not fully 64bits safe, I am closing this bug. Re-open if you still see a problem.

For those already having a numeric-24.2-r6 from the science overlay or a pre-03/09/2007 main tree, re-sync both the overlay and the tree before re-emerging numeric.

dsd, if you contact upstream for the fix, could you send the other patches.