Kaydet (Commit) 919a45d5 authored tarafından Zack M. Davis's avatar Zack M. Davis

adds support for Python 3.5 infix matrix multiplication

üst 0d5faf3a
...@@ -10,6 +10,7 @@ Copyright 2013 (c) Berker Peksag ...@@ -10,6 +10,7 @@ Copyright 2013 (c) Berker Peksag
""" """
import ast import ast
import sys
class NonExistent(object): class NonExistent(object):
...@@ -118,13 +119,18 @@ get_boolop = _getsymbol(""" ...@@ -118,13 +119,18 @@ get_boolop = _getsymbol("""
And and Or or And and Or or
""", all_symbols) """, all_symbols)
get_binop = _getsymbol(""" binops = """
Add + Mult * LShift << BitAnd & Add + Mult * LShift << BitAnd &
Sub - Div / RShift >> BitOr | Sub - Div / RShift >> BitOr |
Mod % BitXor ^ Mod % BitXor ^
FloorDiv // FloorDiv //
Pow ** Pow **
""", all_symbols) """
if sys.version_info >= (3, 5):
binops += "MatMult @"
get_binop = _getsymbol(binops, all_symbols)
get_cmpop = _getsymbol(""" get_cmpop = _getsymbol("""
Eq == Gt > GtE >= In in Is is Eq == Gt > GtE >= In in Is is
......
...@@ -30,6 +30,7 @@ setup( ...@@ -30,6 +30,7 @@ setup(
'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: Implementation', 'Programming Language :: Python :: Implementation',
'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy', 'Programming Language :: Python :: Implementation :: PyPy',
......
import ast
import unittest
import sys
import astor
class GetSymbolTestCase(unittest.TestCase):
def test_get_mat_mult(self):
if sys.version_info < (2, 7):
# We can't use `@unittest.skipIf` or `raise skipTest` in
# Python 2.6
pass
elif sys.version_info < (3, 5):
raise unittest.SkipTest("ast.MatMult introduced in Python 3.5")
else:
self.assertEqual('@', astor.misc.get_binop(ast.MatMult()))
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment