PyQtGraph Isosurface and numpy 1.9.3 vs numpy 1.10.1

399 views
Skip to first unread message

Ryan Martin

unread,
Nov 25, 2015, 1:56:03 PM11/25/15
to pyqtgraph
Hi all, 
I am not sure if this is a problem with my system or just that I shouldn't use numpy 1.10.1, but figured I'd report my findings. I was just testing different examples accessed with the python -m pyqtgraph.examples command. The isosurface example under 3D Graphics fails to run on my system when numpy 1.10.1 is installed with the following error:

Traceback (most recent call last):
  File "<stdin>", line 49, in <module>
  File "C:\Users\rmartin\Anaconda3\lib\site-packages\pyqtgraph\functions.py", line 2030, in isosurface
    index += fields[i,j,k] * 2**vertIndex
TypeError: Cannot cast ufunc add output from dtype('int32') to dtype('uint8') with casting rule 'same_kind'

If I then revert the numpy package to 1.9.3 using: 

conda install numpy=1.9 -f

and rerun the same example of 3D Graphics > Isosurface, no error is generated, and the example displays as intended.

All other 3D Graphics examples seem to run without issue for both versions of numpy. The following other examples run with numpy 1.9.3 but fail with similar cast errors under numpy 1.10.1:

GraphicsItems > IsocurveItem, ImageItem-Video, ImageItem-Draw 

I am using a downloaded .zip from https://github.com/pyqtgraph/pyqtgraph version 0.9.10, installed to my anaconda distribution with python setup.py installLet me know if there is other information to provide. 

Should numpy 1.10.1 work for all examples? is it recommended to not use the updated numpy? Maybe there is something else wrong with my system..?

Thanks, 
Ryan

Big Stone

unread,
Nov 25, 2015, 4:13:16 PM11/25/15
to pyqtgraph
there are some bugs on numpy 1.10.1. you may wait 1.10.2

Dane Austin

unread,
Dec 3, 2015, 11:12:48 AM12/3/15
to pyqtgraph
Hi all,
Just confirming I have reproduced this on python version 2.7.10 on Ubuntu. I get the same TypeError with numpy 1.10.1 and 1.10.0, but not with 1.9.3.
Cheers,
Dane

Dane Austin

unread,
Dec 5, 2015, 6:08:17 PM12/5/15
to pyqtgraph
I got it working with numpy 1.10.1 with the following small changes:

around line 2030 of functions py:
added astype(np.uint16) to give

index += (fields[i,j,k] * 2**vertIndex).astype(np.ubyte)


around line 2100:
added astype(np.uint16) to give

verts[...,:3] += cells[:,np.newaxis,np.newaxis,:].astype(np.uint16) ## we now have indexes into cutEdges



On Wednesday, November 25, 2015 at 6:56:03 PM UTC, Ryan Martin wrote:

alexfrigo

unread,
Sep 30, 2016, 9:00:10 AM9/30/16
to pyqtgraph
Thanks, Dane.

I am trying to plot some level curves with the pyqtgraph library-->isocurve, but i get the same error.

Does your solution work also with numpy 11.1.1?
Which file do I have do edit, exactly? I can't find any "functions.py" on my PC.

Thank you.

Luke Campagnola

unread,
Sep 30, 2016, 7:02:17 PM9/30/16
to pyqt...@googlegroups.com
This is fixed in the develop branch on github. 
Release coming soon! 

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/1f5e4cc2-908b-4006-911c-b67ea9313071%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Dane Austin

unread,
Oct 1, 2016, 4:04:25 AM10/1/16
to pyqtgraph
As Luke mentioned, this is fixed on the develop branch. For what it's worth: functions.py is at the top level of my pyqtgraph installation.

At some point between May and now, I started using the develop branch on github (discarding my changes). So I cannot tell you if my solution works with numpy 11.1.1. I can confirm that the pyqtgraph develop branch does work.

Paul Manis

unread,
Oct 7, 2016, 8:02:17 AM10/7/16
to pyqtgraph
I think the need for the cast results from a change in numpy in 1.10, where the default casting rule changed (see the numpy release notes, and search for 'Default casting rule change'). The upshot is the using 'a += b' may fail when a and b are different types. I have encountered this already in several pyqtgraph routines (including the version packaged with acq4). Unfortunately I just fixed these as needed and haven't kept track of them. However, they are obvious once you know...
Reply all
Reply to author
Forward
0 new messages