| Anonymous | Login | Signup for a new account | 2013-05-22 18:47 EDT |
| Main | My View | View Issues | Change Log | Roadmap | Docs |
| Viewing Issue Simple Details [ Jump to Notes ] | [ View Advanced ] [ Issue History ] [ Print ] | ||||||||
| ID | Category | Severity | Reproducibility | Date Submitted | Last Update | ||||
| 0002193 | [Slicer4] Core: Scripting (Wrapping, Python) | crash | always | 2012-06-13 16:12 | 2012-07-27 19:40 | ||||
| Reporter | m2j | View Status | public | ||||||
| Assigned To | jcfr | ||||||||
| Priority | normal | Resolution | fixed | ||||||
| Status | resolved | Product Version | Slicer 4.1.0 | ||||||
| Summary | 0002193: Python NumPy crash | ||||||||
| Description |
Numpy crashes when I try to find the inverse of a square matrix. On the other hand, when I try to solve a linear least-squares problem, it does not obtain the correct answer. 1) Go to the Python interactor. 2) Enter the following commands: import numpy B = numpy.array([[1,2],[3,4]]) numpy.linalg.inv(B) Traceback (most recent call last): File "<console>", line 1, in <module> File "/home/user/Documents/Mis_Programas/Slicer-4.1.0-linux-amd64/lib/Python/lib/python2.6/site-packages/numpy/linalg/linalg.py", line 423, in inv return wrap(solve(a, identity(a.shape[0], dtype=a.dtype))) File "/home/user/Documents/Mis_Programas/Slicer-4.1.0-linux-amd64/lib/Python/lib/python2.6/site-packages/numpy/linalg/linalg.py", line 310, in solve return wrap(b.transpose().astype(result_t)) ValueError: On entry to DGESV parameter number 4 had an illegal value ------------------------------------------------------------------------------ I tried the same in the system installed python, and the answer is this one: array([[-2. , 1. ], [ 1.5, -0.5]]) ------------------------------------------------------------------------------- Solving a linear least-squares problem: Once again, in the Python Interactor: 1) Import the numpy package (in case you haven't imported it yet) import numpy 2) Enter the following commands: x = numpy.array([0, 1, 2, 3]) y = numpy.array([-1, 0.2, 0.9, 2.1]) A = numpy.vstack([x, numpy.ones(len(x))]).T numpy.linalg.lstsq(A, y) (array([-1. , 0.2]), array([], dtype=float64), 0, array([ 0., 0.])) This is not the correct answer!! I tried the same in the system installed python, and the correct answer is obtained: (array([ 1. , -0.95]), array([ 0.05]), 2, array([ 4.10003045, 1.09075677])) ------------------------------------------------------------------------------- |
||||||||
| Additional Information |
I am using Slicer 4.1.0 , 64 bits linux version. I have tried both pre-compiled versions: stable release and nightly build, with the same result. |
||||||||
| Tags | No tags attached. | ||||||||
| Attached Files | |||||||||
|
|
|||||||||
Relationships |
||||||
|
||||||
Notes |
|
|
(0005020) jcfr (administrator) 2012-07-01 03:37 edited on: 2012-07-01 03:38 |
The topic referenced in this note should resolve the problem: http://www.na-mic.org/Bug/view.php?id=2249#c5017 [^] m2j> Could you try on your side and let me know if it also solves the issue you reported ? Using the topic reported above, the test now passes (Ubuntu 10.04 / Gcc 4.4.3) Python 2.6.6 (r266:84292, May 15 2012, 11:26:17) [GCC 4.4.3] on linux2 >>> >>> import numpy >>> B = numpy.array([[1,2],[3,4]]) >>> numpy.linalg.inv(B) array([[-2. , 1. ], [ 1.5, -0.5]]) >>> x = numpy.array([0, 1, 2, 3]) >>> y = numpy.array([-1, 0.2, 0.9, 2.1]) >>> A = numpy.vstack([x, numpy.ones(len(x))]).T >>> numpy.linalg.lstsq(A, y) (array([ 1. , -0.95]), array([ 0.05]), 2, array([ 4.10003045, 1.09075677])) >>> |
|
(0005023) fedorov (developer) 2012-07-01 18:05 |
Tested with gcc 4.2.1 on Mac Snow leopard, the issue appears to be resolved. >>> B=np.array([[1,2],[3,4]]) >>> np.linalg.inv(B) array([[-2. , 1. ], [ 1.5, -0.5]]) >>> x = numpy.array([0, 1, 2, 3]) >>> y = numpy.array([-1, 0.2, 0.9, 2.1]) >>> A = numpy.vstack([x, numpy.ones(len(x))]).T >>> numpy.linalg.lstsq(A, y) (array([ 1. , -0.95]), array([ 0.05]), 2, array([ 4.10003045, 1.09075677])) >>> |
|
(0005026) jcfr (administrator) 2012-07-01 18:35 |
Excellent ! |
|
(0005030) jcfr (administrator) 2012-07-01 22:29 |
Fixed in r20539 See http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=20539 [^] |
|
(0005397) jcfr (administrator) 2012-07-27 19:40 |
Dear issue reporter, Good news :) Slicer developers SOLVED the problem you reported - YOU now need to VERIFY and CLOSE this issue. |
| Mantis 1.1.4[^] Copyright © 2000 - 2008 Mantis Group |