Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5522378c1cf2
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: eeb2790243e9
Choose a head ref
  • 3 commits
  • 5 files changed
  • 1 contributor

Commits on Dec 19, 2014

  1. Copy the full SHA
    a9b28df View commit details
  2. Copy the full SHA
    5d40c24 View commit details
  3. Copy the full SHA
    eeb2790 View commit details
Showing with 17 additions and 13 deletions.
  1. +1 −1 artiq/py2llvm/ast_body.py
  2. +8 −1 artiq/py2llvm/lists.py
  3. +5 −4 artiq/transforms/lower_units.py
  4. +1 −2 examples/photon_histogram.py
  5. +2 −5 examples/transport.py
2 changes: 1 addition & 1 deletion artiq/py2llvm/ast_body.py
Original file line number Diff line number Diff line change
@@ -200,7 +200,7 @@ def _visit_expr_List(self, node):
for elt in elts[1:]:
el_type.merge(elt)
else:
el_type = VNone()
el_type = base_types.VNone()
count = len(elts)
r = lists.VList(el_type, count)
r.elts = elts
9 changes: 8 additions & 1 deletion artiq/py2llvm/lists.py
Original file line number Diff line number Diff line change
@@ -30,7 +30,14 @@ def same_type(self, other):

def merge(self, other):
if isinstance(other, VList):
self.el_type.merge(other.el_type)
if self.alloc_count:
if other.alloc_count:
self.el_type.merge(other.el_type)
if self.alloc_count < other.alloc_count:
self.alloc_count = other.alloc_count
else:
self.el_type = other.el_type.new()
self.alloc_count = other.alloc_count
else:
raise TypeError("Incompatible types: {} and {}"
.format(repr(self), repr(other)))
9 changes: 5 additions & 4 deletions artiq/transforms/lower_units.py
Original file line number Diff line number Diff line change
@@ -89,10 +89,11 @@ def visit_Attribute(self, node):

def visit_List(self, node):
self.generic_visit(node)
us = [getattr(elt, "unit", None) for elt in node.elts]
if not all(u == us[0] for u in us[1:]):
raise units.DimensionError
node.unit = us[0]
if node.elts:
us = [getattr(elt, "unit", None) for elt in node.elts]
if not all(u == us[0] for u in us[1:]):
raise units.DimensionError
node.unit = us[0]
return node

def visit_ListComp(self, node):
3 changes: 1 addition & 2 deletions examples/photon_histogram.py
Original file line number Diff line number Diff line change
@@ -31,5 +31,4 @@ def run(self):
n = self.nbins-1
hist[n] += 1

for i in range(self.nbins):
print(i, hist[i])
print(hist)
7 changes: 2 additions & 5 deletions examples/transport.py
Original file line number Diff line number Diff line change
@@ -94,16 +94,13 @@ def one(self):

@kernel
def repeat(self):
hist = [0 for _ in range(self.nbins)]
self.histogram = [0 for _ in range(self.nbins)]

for i in range(self.repeats):
n = self.one()
if n >= self.nbins:
n = self.nbins-1
hist[n] += 1

for i in range(self.nbins):
self.histogram.append(hist[i])
self.histogram[n] += 1

def scan(self, stops):
for s in stops: