VAS rating failing on account of transform.frozen() in matplotlib/path.py

54 views
Skip to first unread message

Horea Christian

unread,
Jan 15, 2013, 5:35:28 PM1/15/13
to psychop...@googlegroups.com
Hi, I am trying to run the following code http://paste2.org/p/2753550 - the rating function is defined on lines 41ff  (I am trying to get a visual analogue scale out of it)

I have tried running a similar script via the builder, as well, and in principle: if singleClick=False the script fails after I click (wherever on the screen) with the following error: http://paste2.org/p/2753557

If singleClick=True it fails with the same error even before I can click.

Additionally the script I linked above (as opposed to the builder alternative) fails to display my cursor.

Do you have any idea what's amiss here? I tried reading the path.py matplotlib file, but I don't really understand what transform.frozen() is all about.

Many thanks for your help,

Jeremy Gray

unread,
Jan 15, 2013, 7:19:31 PM1/15/13
to psychop...@googlegroups.com
I haven't seen this one before. It has something to do with how matplotlib.nxutils is working on your system. this is used to detect whether a point is inside a polygon (which is used by the RatingScale code). if nxutils cannot be found, it will fall through to pure python (slower but should work for you). I could add a try - except so that things will fall through to the slow way of doing it.

what version of matplotlib do you have? I have 1.1.0


--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To post to this group, send email to psychop...@googlegroups.com.
To unsubscribe from this group, send email to psychopy-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/psychopy-users/-/zJCBvH5Du9YJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Horea Christian

unread,
Jan 16, 2013, 8:26:16 AM1/16/13
to psychop...@googlegroups.com
I have 1.2.0-r1 A piece of example code would be very much appreciated.

Jeremy Gray

unread,
Jan 16, 2013, 8:35:04 AM1/16/13
to psychop...@googlegroups.com
in visual.py around line 7344, look for 

    # faster if have matplotlib.nxutils:
    if haveNxutils:
        return bool(nxutils.pnpoly(x, y, poly))

and change to
    if haveNxutils:
        try: return bool(nxutils.pnpoly(x, y, poly))
        except: pass

and a similar change near line 7380.

    if haveNxutils:
        try:
            if any(nxutils.points_inside_poly(poly1, poly2)):
                return True
            return any(nxutils.points_inside_poly(poly2, poly1))
        except: pass

If you can confirm that this works, I'll submit it as a patch to psychopy.


To view this discussion on the web visit https://groups.google.com/d/msg/psychopy-users/-/aJwxMYdATzQJ.

Jeremy Gray

unread,
Jan 16, 2013, 8:42:16 AM1/16/13
to psychop...@googlegroups.com
looks like it will be a different line number for you. you'll want:
File "/usr/lib64/python2.7/site-packages/psychopy/visual.py", line 7185, in pointInPolygon

Horea Christian

unread,
Jan 16, 2013, 10:25:00 AM1/16/13
to psychop...@googlegroups.com
Worked like a charm (well, initially it complained a bit about indenting, so I had to rewrite the paragraph - whitespaces I think)
you can see the working code here http://bpaste.net/show/70666/

Will I be able to pull your modified code from git tonight?

Also, what about the cursor not being shown - any advice on that?

Cheers,

Jeremy Gray

unread,
Jan 16, 2013, 10:44:02 AM1/16/13
to psychop...@googlegroups.com

Worked like a charm (well, initially it complained a bit about indenting, so I had to rewrite the paragraph - whitespaces I think)
you can see the working code here http://bpaste.net/show/70666/

Will I be able to pull your modified code from git tonight?


I'm not sure when Jon will pull this into upstream. A better solution would be for someone to figure out why, in your version of nxutils, its getting a numpy.float64 when it did not expect one. Maybe there's a way to get the speed benefits of nxutils for you as well. And this might be needed in the future anyway as matplot lib 1.2 gets used in psychopy.

Also, what about the cursor not being shown - any advice on that?

try setting allowGUI=True in 
    win = visual.Window(.... allowGUI=True, ...)

--Jeremy
 

To view this discussion on the web visit https://groups.google.com/d/msg/psychopy-users/-/F1tzt3EOysoJ.

Horea Christian

unread,
Jan 16, 2013, 10:59:29 AM1/16/13
to psychop...@googlegroups.com
Thanks for the cursor tip :) I think I'll wait for upstream. Is he usually quick?

I shared your/our nxutils inquiry with scipy (since I couldn't get to the matplotlib people directly - maybe you want to try that?)

Cheers,

Jeremy Gray

unread,
Jan 16, 2013, 11:03:44 AM1/16/13
to psychop...@googlegroups.com
its in upstream already (!)

I am personally willing to check out the nxutils thing, and talk with scipy or matplotlib people, but I feel I should have a crack at it myself first and be more informed about the issues.


To view this discussion on the web visit https://groups.google.com/d/msg/psychopy-users/-/Qo05uGESIsMJ.
Reply all
Reply to author
Forward
0 new messages