Skip to content

Support matrix multiplication (@) #705

Closed

Description

@spkersten

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.

Activity

  1. gilesc commented on Oct 14, 2016

    @gilesc

    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.

  2. gvanrossum commented on Oct 14, 2016

    @gvanrossum
    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!

  3. added this to the milestone on Oct 14, 2016
  4. added a commit that references this issue on Oct 20, 2016
    48fa2ef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions