Skip to content

Commit

Permalink
minor fixes: flake8, test, cyclic imports
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioLuporini committed Nov 25, 2016
1 parent 3337830 commit 6a344e8
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 12 deletions.
1 change: 0 additions & 1 deletion coffee/__init__.py
Expand Up @@ -36,7 +36,6 @@
import sys

from coffee.citations import update_citations
from coffee.vectorizer import VectStrategy
from coffee.logger import LOG_DEFAULT, set_log_level, warn
from coffee.system import set_architecture, set_compiler, set_isa

Expand Down
1 change: 1 addition & 0 deletions coffee/base.py
Expand Up @@ -1339,6 +1339,7 @@ def __init__(self, scope):
def __str__(self):
return self._scope


LOCAL = Scope("LOCAL")
EXTERNAL = Scope("EXTERNAL")
BUFFER = Scope("BUFFER")
Expand Down
1 change: 0 additions & 1 deletion coffee/rewriter.py
Expand Up @@ -562,7 +562,6 @@ def sharing_graph_rewrite(self):

# Construct the sharing graph
nodes, edges = [], []
operands = summands(self.stmt.rvalue)
for i in summands(self.stmt.rvalue):
symbols = zip(*explore_operator(i))[0] if not isinstance(i, Symbol) else [i]
lsymbols = [s for s in symbols if any(d in lda[s] for d in linear_dims)]
Expand Down
11 changes: 6 additions & 5 deletions coffee/visitors/utilities.py
Expand Up @@ -5,11 +5,9 @@
from copy import deepcopy
from collections import OrderedDict, defaultdict
import numpy as np
import networkx as nx

from coffee.visitor import Visitor
from coffee.base import Sum, Sub, Prod, Div, ArrayInit, SparseArrayInit
import coffee.utils


__all__ = ["ReplaceSymbols", "CheckUniqueness", "Uniquify", "Evaluate",
Expand Down Expand Up @@ -123,7 +121,8 @@ def __init__(self, decls, track_zeros):
import coffee.vectorizer
self.up = coffee.vectorizer.vect_roundup
self.down = coffee.vectorizer.vect_rounddown
self.make_itspace = coffee.utils.ItSpace
from coffee.utils import ItSpace
self.make_itspace = ItSpace
super(Evaluate, self).__init__()

def visit_object(self, o, *args, **kwargs):
Expand Down Expand Up @@ -284,7 +283,9 @@ def default_retval(cls):
"""

def __init__(self, symbols):
from coffee.utils import flatten
self.symbols = symbols
self.flatten = flatten
super(ProjectExpansion, self).__init__()

def visit_object(self, o, *args, **kwargs):
Expand All @@ -305,13 +306,13 @@ def visit_Prod(self, o, parent=None, *args, **kwargs):
projection = self.default_retval()
for n in o.children:
projection.extend(self.visit(n, parent=o, *args, **kwargs))
return [list(coffee.utils.flatten(projection))]
return [list(self.flatten(projection))]
else:
# Only the top level Prod, in a chain of Prods, should do the
# tensor product
projection = [self.visit(n, parent=o, *args, **kwargs) for n in o.children]
product = itertools.product(*projection)
ret = [list(coffee.utils.flatten(i)) for i in product] or projection
ret = [list(self.flatten(i)) for i in product] or projection
return ret

def visit_Symbol(self, o, *args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
@@ -1,6 +1,6 @@
[flake8]
ignore =
E501,F403,F405,E226,E265,E731,E402,E266,
E501,F403,F405,E226,E265,E731,E402,E266,F999,
FI14,FI54,
FI50,FI51,FI53
exclude = .git,,__pycache__,build,dist,doc/source/conf.py
Expand Down
5 changes: 1 addition & 4 deletions tests/test_visitors.py
Expand Up @@ -375,9 +375,8 @@ def test_find_coffee_expressions_single():

val = ret[assign]

assert len(val) == 3
assert len(val) == 2

assert val[2] == ()
assert val[1] == [(tree.children[0], tree)]
assert val[0] == tree.children[0].children[0]

Expand Down Expand Up @@ -405,13 +404,11 @@ def test_find_coffee_expressions_nested():

assert val1[0] == tree.children[0].children[0]
assert val1[1] == [(tree.children[0], tree)]
assert val1[2] == ()

assert val2[0] == tree.children[0].body[0].children[0].children[0]
assert val2[1] == [(tree.children[0], tree),
(tree.children[0].body[0].children[0],
tree.children[0].body[0])]
assert val2[2] == ("i", )


def test_symbol_modes_simple():
Expand Down

0 comments on commit 6a344e8

Please sign in to comment.