as_cell fails on tuples

Issue #110 new
Grant Bruer created an issue

Calling as_cell on a tuple leads to an infinite recursion, instead of creating the desired TensorProductCell.

I believe the bug is caused by line 327 of ufl/cell.py, where it does return TensorProductCell(cell) when it actually should be doing return TensorProductCell(*cell).

MWE:

>>> from ufl import as_cell
>>> as_cell(('interval', 'interval'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/gbruer/anaconda3/envs/latest/lib/python3.7/site-packages/ufl/cell.py", line 327, in as_cell
    return TensorProductCell(cell)
  File "/home/gbruer/anaconda3/envs/latest/lib/python3.7/site-packages/ufl/cell.py", line 223, in __init__
    self._cells = tuple(as_cell(cell) for cell in cells)
  File "/home/gbruer/anaconda3/envs/latest/lib/python3.7/site-packages/ufl/cell.py", line 223, in <genexpr>
    self._cells = tuple(as_cell(cell) for cell in cells)
  File "/home/gbruer/anaconda3/envs/latest/lib/python3.7/site-packages/ufl/cell.py", line 327, in as_cell
    return TensorProductCell(cell)
...
  File "/home/gbruer/anaconda3/envs/latest/lib/python3.7/site-packages/ufl/cell.py", line 223, in __init__
    self._cells = tuple(as_cell(cell) for cell in cells)
RecursionError: maximum recursion depth exceeded

Comments (0)

  1. Log in to comment