Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matmul operator on Python version <= 3.4 (rel: #18) #41

Closed
max0410 opened this issue Mar 31, 2018 · 2 comments
Closed

matmul operator on Python version <= 3.4 (rel: #18) #41

max0410 opened this issue Mar 31, 2018 · 2 comments

Comments

@max0410
Copy link

max0410 commented Mar 31, 2018

Test script:

from p5 import *

def setup():
    size(640, 360)
    no_stroke()
    background(204)

def draw():
    if mouse_is_pressed:
        fill(random_uniform(255), random_uniform(127), random_uniform(51), 127)
    else:
        fill(255, 15)

    circle_size = random_uniform(low=10, high=80)

    circle((mouse_x, mouse_y), circle_size)

def key_pressed(event):
    background(204)

run()

Expected behavior:
The video in the README

Actual behavior
An error is thrown.

Errors produced (if any):

Traceback (most recent call last):
  File "C:/Users/User/Dropbox/Programs/p5play.py", line 1, in <module>
    from p5 import *
  File "C:\Python34\lib\site-packages\p5\__init__.py", line 19, in <module>
    from .sketch import *
  File "C:\Python34\lib\site-packages\p5\sketch\__init__.py", line 19, in <module>
    from .base import *
  File "C:\Python34\lib\site-packages\p5\sketch\base.py", line 29, in <module>
    from ..opengl import renderer
  File "C:\Python34\lib\site-packages\p5\opengl\__init__.py", line 19, in <module>
    from .renderer import *
  File "C:\Python34\lib\site-packages\p5\opengl\renderer.py", line 33, in <module>
    from ..pmath import matrix
  File "C:\Python34\lib\site-packages\p5\pmath\__init__.py", line 20, in <module>
    from .vector import *
  File "C:\Python34\lib\site-packages\p5\pmath\vector.py", line 321
    return np.arccos( (self @ other) / (self.magnitude * other.magnitude))
                            ^
SyntaxError: invalid syntax

p5 version:
Newest version

Python version:
Python 3.4.0

Operating System:
Windows 10

@abhikpal
Copy link
Member

abhikpal commented Apr 1, 2018

Hey, this seems to be related to #18. Can you try running your code on a newer version of Python (say, 3.6)?

@AliabbasMerchant
Copy link

AliabbasMerchant commented Apr 1, 2018

The syntax of using '@' for matrix multiplication was introduced in Python 3.5.
Also, this problem also includes issues due to tuple unpacking, which was introduced after Python 3.4.

As @abhikpal pointed out, the script will run properly in newer versions of Python.

Maybe we will have to include Python 3.5 in the dependencies of p5py.

@abhikpal abhikpal changed the title Example throws an error matmul operator on Python version <= 3.4 May 1, 2018
@abhikpal abhikpal changed the title matmul operator on Python version <= 3.4 matmul operator on Python version <= 3.4 (rel: #18) May 1, 2018
@abhikpal abhikpal added this to the Pre-VisPy release milestone Jun 5, 2018
@abhikpal abhikpal self-assigned this Jun 5, 2018
@abhikpal abhikpal modified the milestones: Pre-VisPy release, Port backend to VisPy Jun 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants