Skip to content

Commit

Permalink
fix ir line
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Apr 5, 2018
1 parent 1d85fe4 commit d14e794
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions numba/annotations/type_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,24 @@ def html_annotate(self, outfile):
self.annotate_raw()
# make a deep copy ahead of the pending mutations
func_data = copy.deepcopy(self.func_data)
def add_in_nbsp(key):
for this_func in func_data.values():
if key in this_func:
idents = {}
for line, amount in this_func[key].items():
idents[line] = ' ' * amount
this_func[key] = idents
add_in_nbsp('python_indent')
add_in_nbsp('ir_indent')
#def add_in_nbsp(key):
key = 'python_indent'
for this_func in func_data.values():
if key in this_func:
idents = {}
for line, amount in this_func[key].items():
idents[line] = ' ' * amount
this_func[key] = idents

key = 'ir_indent'
for this_func in func_data.values():
if key in this_func:
idents = {}
for line, ir_id in this_func[key].items():
idents[line] = [' ' * amount for amount in ir_id]
this_func[key] = idents



try:
from jinja2 import Template
Expand Down Expand Up @@ -194,7 +203,7 @@ def add_ir_line(func_data, line):
line_type = 'pyobject'
func_data['ir_lines'][num].append((line_str, line_type))
indent_len = len(_getindent(line))
func_data['ir_indent'][num] += indent_len
func_data['ir_indent'][num].append(indent_len)

func_key = (self.func_id.filename + ':' + str(self.func_id.firstlineno + 1),
self.signature)
Expand All @@ -207,7 +216,7 @@ def add_ir_line(func_data, line):
if num not in ir_lines.keys():
continue
func_data['ir_lines'][num] = []
func_data['ir_indent'][num] = 0
func_data['ir_indent'][num] = []
for line in ir_lines[num]:
add_ir_line(func_data, line)
if line.strip().endswith('pyobject'):
Expand Down Expand Up @@ -248,7 +257,7 @@ def add_ir_line(func_data, line):
func_data['python_indent'][num] = indent_len
func_data['python_tags'][num] = ''
func_data['ir_lines'][num] = []
func_data['ir_indent'][num] = 0
func_data['ir_indent'][num] = []

for line in ir_lines[num]:
add_ir_line(func_data, line)
Expand Down

0 comments on commit d14e794

Please sign in to comment.