Singular Matrix problem with Matplitlib in Numpy (Windows - AMD64)
Hello. I have been battling with the following error for the past week. The output from the terminal is: Traceback (most recent call last): File "C:\development\Python\2_5_2\Lib\site-packages\matplotlib\backends\backend_qt4agg.py", line 86, in paintEvent FigureCanvasAgg.draw(self) File "C:\development\Python\2_5_2\Lib\site-packages\matplotlib\backends\backend_agg.py", line 261, in draw self.figure.draw(self.renderer) File "C:\development\Python\2_5_2\Lib\site-packages\matplotlib\figure.py", line 765, in draw legend.draw(renderer) File "C:\development\Python\2_5_2\Lib\site-packages\matplotlib\legend.py", line 197, in draw self._update_positions(renderer) File "C:\development\Python\2_5_2\Lib\site-packages\matplotlib\legend.py", line 513, in _update_positions l,b,w,h = get_tbounds(self.texts[-1]) File "C:\development\Python\2_5_2\Lib\site-packages\matplotlib\legend.py", line 499, in get_tbounds bboxa = bbox.inverse_transformed(self.get_transform()) File "C:\development\Python\2_5_2\Lib\site-packages\matplotlib\transforms.py", line 478, in inverse_transformed return Bbox(transform.inverted().transform(self.get_points())) File "C:\development\Python\2_5_2\Lib\site-packages\matplotlib\transforms.py", line 1338, in inverted self._inverted = Affine2D(inv(mtx)) File "C:\development\Python\2_5_2\Lib\site-packages\numpy\linalg\linalg.py", line 350, in inv return wrap(solve(a, identity(a.shape[0], dtype=a.dtype))) File "C:\development\Python\2_5_2\Lib\site-packages\numpy\linalg\linalg.py", line 249, in solve raise LinAlgError, 'Singular matrix' numpy.linalg.linalg.LinAlgError: Singular matrix Initially MPL plots a graph but when you try to interact with the widget(for example resize) then the output is displayed and the MPL figure is not updated. Everything works with Windows 32-bit. Linux 32-bit and 64-bit are working correctly. Any ideas would be helpful. Thanks. George.
On Tue, Dec 9, 2008 at 12:50 AM, George Goussard
Hello.
I have been battling with the following error for the past week. The output from the terminal is:
What does numpy.test() says ? Did you use an external blas/lapack when you built numpy for AMD64 David
David Cournapeau
On Tue, Dec 9, 2008 at 12:50 AM, George Goussard
wrote: Hello.
I have been battling with the following error for the past week. The output from the terminal is:
What does numpy.test() says ? Did you use an external blas/lapack when you built numpy for AMD64
David
Hi David. I accidentally created a new posting previously. I have spent the last month trying to track down this bug. I am trying to compile Numpy and Matplotlib on Windows XP 64-bit. I am using the Visual Studio 2005 compiler. Everything compiles without a problem. However running matplotlib etc. gave me a lot of problems: 1. The interaction was terrible. It didn't draw anything and the console had a lot trace output with regard to singular matrices etc. Like you said, I am using an external library called Intel MKL and I decided to swap this with AMD ACML. Then the interaction was a lot better and no trace on the console of singular matrices etc. 2. Using both libraries there are problems with the plotting. In both cases the graphs are broken. It starts plotting the curve and then it stops with a section of white space and then some more of the curve etc. The same with the grid lines etc. In other words there is just something broken. I have decided to pursue this bug. I would really like to get Numpy working on AMD64. I ran the test you advised and the tests passed. However I have traced the problem to the file lines.py of matplotlib. There in a function set_xdata and set_ydata(also set_data) there is a line like x = np.asarray or y = np.asarray. My data before that line is fine, but straight after the line is executed the data is broken and garbage. I have debugged some more but I am in deep (murky) waters, but I have also ran out of ideas. If anybody has some more suggestions, please post them.
George wrote:
David Cournapeau
writes:
<SNIP> Hi George,
I have debugged some more but I am in deep (murky) waters, but I have also ran out of ideas. If anybody has some more suggestions, please post them.
Could you post a full example with additional version info that you are using? Ever since Sage upgraded to Matplotlib 0.98.3 I have been seeing issues with uninitilized values being used in certain code paths. This could be the source of potential trouble even though it doesn't seem to cause any observable trouble with gcc for example. Cheers, Michael
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Hi Micheal. I am going on vacation tomorrow. An example will have to wait until I am back, but I can give some version information now: Numpy is version 1.2.1, Matplotlib is version 0.98.5 and I am using stock-standard(not the Enthought version or other distribution) Python 2.5. My Python 2.5 I also compiled with MSVC 2005(AMD/em64t setting) because I can't have dependecies on older crt libraries/dll's. The Intel MKL version is 10.1.0.018 and the AMD ACML version is 4.2.0. I am not using both at the same time. I have first tried the Intel one and now I am using AMD's ACML as explained in previous email. Everything is compiled using the AMD64/em64t "settings". I am not compiling on IA32 and IA64 etc. All the other necessary version information(MSVC), I'll have to check when I am back at the office. I also use other libraries like PyQt(3.17.??) and SIP(version 4.7.7). Both of them are the commercial versions and I also have commercial version of Qt 4.3.3. Needless to say that my backend agg is Qt4Agg. I have tested on Linux 64 bit (SuSe 10.?? commercial version not openSuSe) and it worked. I also tested on Windows XP 32-bit and Linux 32-bit(SuSe 10.??) and everything worked. Constructing and example won't be trivial but I'll try. The reason being thatI embedded Python in an application and then I display graphs using SIP and PyQt. The application was done using Qt4. Anyway, but I'll get back to you on that as soon as I am finished with it. Another interesting aspect is that in my application where I initially construct the array using PyArray_SimpleNew, if I change this to, for example PyArray_SimpleNewFromData then I get a completely different graph which is a solid line(not the effect I described in the previous email) but it is completely the wrong graph, with very small numbers(E-16 numbers). One thing that also bothers me is that on Windows 32-bit. The default was not FORTRAN arrays, but on Windows XP 64 bit the order and everything is FORTRAN default. I ain't even using anything remotely to FORTRAN. I think the AMD ACML is compiled using the Intel FORTRAN compiler, but will that effect it?? Anyway, I'll put an effort into constructing an example, but it will have to be when I am back at the office from my vacation. Cheers. Thanks. George.
Hello. I was suppose to give more information, but after about two months(I am a Python newbie, newbie to Matplotlib and newbie to Numpy plus a vacation in-between).....I finally tracked down the problem. However ....... I see in Matplotlib 0.98.5.2 the correction was made by somebody else. (Cry, sob, sob sob). The problem was in the file MPL_isnan.h on line 26. Consider the issue closed. Thanks. George.
Hello. I am terribly sorry. I was mistaken last night. I had the latest Matplotlib version 0.98.5.2 and I thought the bug was fixed but it hasn't. Let me explain. In the file MPL_isnan.h line 26 there is a declaration: typedef long int MPL_Int64 This is fine for Linux 64-bit, but NOT for Windows XP 64-bit! For Windows the declaration should be: typedef long long MPL_Int64 This bug has caused me a LOT of late nights and last night was one of them. The declaration is correct for Linux 64-bit and I guess Matplotlib was developed on Linux because of this declaration. That is also why I thought the bug was fixed but this morning I realised that I was looking at the wrong console. So, in summary. For Matplotlib 0.98.5.2 and Numpy 1.2.1 to work without any problems. This means compiling and using Numpy and Matplotlib on Windows XP 64-bit using AMD 64-bit compile environment, change line 26 in the file MPL_isnan.h from long int to long long.\ I also previously suggested switching MKL and ACML etc. but with this change everything is fine. One can choose any math library and it works. Writing a small test application using sizeof on different platforms highlights the problem. Thanks. George.
Andrew, since you are the original author of the isnan port, could you
patch the branch and the trunk to take care of this?
JDH
On Fri, Jan 16, 2009 at 8:07 AM, George
Hello.
I am terribly sorry. I was mistaken last night. I had the latest Matplotlib version 0.98.5.2 and I thought the bug was fixed but it hasn't. Let me explain.
In the file MPL_isnan.h line 26 there is a declaration:
typedef long int MPL_Int64
This is fine for Linux 64-bit, but NOT for Windows XP 64-bit! For Windows the declaration should be:
typedef long long MPL_Int64
This bug has caused me a LOT of late nights and last night was one of them. The declaration is correct for Linux 64-bit and I guess Matplotlib was developed on Linux because of this declaration. That is also why I thought the bug was fixed but this morning I realised that I was looking at the wrong console.
So, in summary. For Matplotlib 0.98.5.2 and Numpy 1.2.1 to work without any problems. This means compiling and using Numpy and Matplotlib on Windows XP 64-bit using AMD 64-bit compile environment, change line 26 in the file MPL_isnan.h from long int to long long.\
I also previously suggested switching MKL and ACML etc. but with this change everything is fine. One can choose any math library and it works.
Writing a small test application using sizeof on different platforms highlights the problem.
Thanks.
George.
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
John Hunter wrote:
Andrew, since you are the original author of the isnan port, could you patch the branch and the trunk to take care of this?
Done in r6791 and r6792.
Sorry for the trouble.
Now I just hope we don't get a problem with "long long", although now if
_ISOC99_SOURCE is defined, we'll preferentially use "int64_t" out of
JDH
On Fri, Jan 16, 2009 at 8:07 AM, George
wrote: Hello.
I am terribly sorry. I was mistaken last night. I had the latest Matplotlib version 0.98.5.2 and I thought the bug was fixed but it hasn't. Let me explain.
In the file MPL_isnan.h line 26 there is a declaration:
typedef long int MPL_Int64
This is fine for Linux 64-bit, but NOT for Windows XP 64-bit! For Windows the declaration should be:
typedef long long MPL_Int64
This bug has caused me a LOT of late nights and last night was one of them. The declaration is correct for Linux 64-bit and I guess Matplotlib was developed on Linux because of this declaration. That is also why I thought the bug was fixed but this morning I realised that I was looking at the wrong console.
So, in summary. For Matplotlib 0.98.5.2 and Numpy 1.2.1 to work without any problems. This means compiling and using Numpy and Matplotlib on Windows XP 64-bit using AMD 64-bit compile environment, change line 26 in the file MPL_isnan.h from long int to long long.\
I also previously suggested switching MKL and ACML etc. but with this change everything is fine. One can choose any math library and it works.
Writing a small test application using sizeof on different platforms highlights the problem.
Thanks.
George.
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Hello David.
I am using the Intel MKL BLAS/LAPACK. I have replaced this with AMD's ACML
library. Now there is no exception raised due to a "Singular matrix" while
trying to move the legend(wiggling the graph). So, the graph is updated and
the interaction is fine(you can wiggle the graph and it updates, minimize,
maximeie etc.). But ... the legend is now only drawn sometimes and the graphs
are drawn with an intermittent line, as if the - - - pattern was specified.
Something is still not right. I just can't seem to put my finger on it since
there are some many parties involved(numpy,matplotlib,python, ctypes etc.)
I also ran the numpy.test() with NUmpy that I compiled with AMD's ACML. The
results are included:
Running unit tests for numpy
NumPy version 1.2.1
Results of numpy.test()
NumPy is installed in C:\Development\Python\2_5_2\lib\site-packages\numpy
Python version 2.5.2 (r252:60911, Dec 12 2008, 08:38:07) [MSC v.1400 64 bit
(AMD64)]
nose version 0.10.4
Forcing
DISTUTILS_USE_SDK=1
...............................................................................
.............................................................
...............................................................................
..........................K..K...............................
...............................................................................
.............................................................
.......................K.......................................................
..........................Ignoring "MSVCCompiler instance has
no attribute '_MSVCCompiler__root'" (I think it is msvccompiler.py bug)
...........................S...................................................
.............................................................
...............................................................................
.............................................................
...............................................................................
.............................................................
...............................................................................
.............................................................
...............................................................................
.............................................................
...............................................................................
.............................................................
...............................................................................
.............................................................
...............................................................................
........
----------------------------------------------------------------------
Ran 1592 tests in 10.704s
OK (KNOWNFAIL=3, SKIP=1)
participants (6)
-
Andrew Straw
-
David Cournapeau
-
George
-
George Goussard
-
John Hunter
-
Michael Abshoff