Skip to content

Commit 3ae5bee

Browse files
authored
Convert integer to string in operator variable represenation (#1013)
* Convert integer to string in operator variable represenation * Allow Py2.7 and Py3k index representation in test
1 parent 3e38ff2 commit 3ae5bee

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fipy/variables/operatorVariable.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def _py3kInstructions(self, op, style, argDict, id, freshen):
208208
# Removed in Python 3
209209
stack.append("`" + stack.pop() + "`")
210210
elif ins.opname == 'BINARY_SUBSCR':
211-
stack.append(stack.pop(-2) + "[" + stack.pop() + "]")
211+
stack.append(stack.pop(-2) + "[" + str(stack.pop()) + "]")
212212
elif ins.opname == 'RETURN_VALUE':
213213
s = stack.pop()
214214
if style == 'C':
@@ -371,6 +371,11 @@ def _testBinOp(self):
371371
>>> ttns((v1 / v2 - v3 * v4 + v1 * v4)._getRepresentation(style='C', id=""))
372372
'(((var000[i] / var001[i]) - (var010[i] * var011[i])) + (var10[i] * var11[i]))'
373373
374+
Test that the representation of indexing works correctly
375+
376+
>>> ttns(v1[1]._getRepresentation()) # doctest: +ELLIPSIS
377+
'Variable(value=array([1, 2, 3, 4]))[...]'
378+
374379
Check that unit works for a `binOp`
375380
376381
>>> (Variable(value="1 m") * Variable(value="1 s")).unit == Variable(value="1 s*m").unit

0 commit comments

Comments
 (0)