Skip to content

Support matrix multiplication (@) #705

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

Closed
spkersten opened this issue Jun 2, 2015 · 2 comments
Closed

Support matrix multiplication (@) #705

spkersten opened this issue Jun 2, 2015 · 2 comments

Comments

@spkersten
Copy link
Contributor

The matrix multiplication operators @ and @= and their corresponding methods, __matmul__, __rmatmul__, and __imatmul__, that are introduced with Python 3.5 should be supported. See PEP 465.

@gilesc
Copy link

gilesc commented Oct 14, 2016

Was this fixed? I am using mypy v0.4.5 installed via pip3 (just getting started) and I get errors when using this feature. I haven't even started annotating anything yet.

I run mypy --python-version=3.5 -p mypackage, and get lots of errors like the following:

mypackage/distance.py: note: In function "nearest_neighbors":
mypackage/distance.py:57: error: Parse error before @

And the line referred to is:

r = Xa[:,j] @ Xa / (Xa.shape[0] - 1)

Since I use this feature heavily I get tons of such errors.

@gvanrossum
Copy link
Member

Yeah, the default parser doesn't support that. We're moving to a new parser, which you can invoke with --fast-parser. Unfortunately that leads to raise RuntimeError('mypy does not support the MatMult operator') which becomes a crash, so it's just as bad. We'll have to fix this. Thanks for noticing!

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

4 participants