usnistgov / fipy

FiPy is a Finite Volume PDE solver written in Python
http://pages.nist.gov/fipy/en/latest
Other
504 stars 148 forks source link

Representation of index variables is broken #961

Closed guyer closed 6 months ago

guyer commented 11 months ago
>>> import fipy as fp
>>> mesh = fp.Grid2D(nx=3, ny=4)
>>> mesh.cellCenters[0]
Traceback (most recent call last):
  File ~/mambaforge-arm/envs/fipy311/lib/python3.11/site-packages/IPython/core/formatters.py:699 in __call__
    return repr(obj)
  File ~/Documents/research/FiPy/fipy/fipy/variables/operatorVariable.py:307 in __repr__
    return self._getRepresentation()
  File ~/Documents/research/FiPy/fipy/fipy/variables/operatorVariable.py:87 in _getRepresentation
    representation = self._py3kInstructions(op=self.op, style=style, argDict=argDict, id=id, freshen=freshen)
  File ~/Documents/research/FiPy/fipy/fipy/variables/operatorVariable.py:211 in _py3kInstructions
    stack.append(stack.pop(-2) + "[" + stack.pop() + "]")
TypeError: can only concatenate str (not "int") to str

The stack.pop() needs to be wrapped in str(), or the whole thing should use f-string formatting.