Skip to content

Commit

Permalink
Ksagiyam/fix repr withmapping (#182)
Browse files Browse the repository at this point in the history
* WithMapping: fix repr

* TensorProductCell: fix reconstruct
  • Loading branch information
ksagiyam authored Jul 15, 2023
1 parent 0d03500 commit 4e32e86
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions test/test_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,9 @@ def test_cells_2d(cell):
assert cell.num_peaks() == cell.num_vertices()


def test_tensorproductcell():
orig = ufl.TensorProductCell(ufl.interval, ufl.interval)
cell = orig.reconstruct()
assert cell.sub_cells() == orig.sub_cells()
assert cell.topological_dimension() == orig.topological_dimension()
assert cell.geometric_dimension() == orig.geometric_dimension()
6 changes: 6 additions & 0 deletions test/test_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,9 @@ def test_mse():

element = FiniteElement('GLL-Edge L2', interval, degree - 1)
assert element == eval(repr(element))


def test_withmapping():
base = FiniteElement("CG", interval, 1)
element = WithMapping(base, "identity")
assert element == eval(repr(element))
2 changes: 1 addition & 1 deletion ufl/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def reconstruct(self, **kwargs: typing.Any) -> Cell:
gdim = value
else:
raise TypeError(f"reconstruct() got unexpected keyword argument '{key}'")
return TensorProductCell(self._cellname, geometric_dimension=gdim)
return TensorProductCell(*self._cells, geometric_dimension=gdim)


def simplex(topological_dimension: int, geometric_dimension: typing.Optional[int] = None):
Expand Down
2 changes: 1 addition & 1 deletion ufl/finiteelement/hdivcurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __getattr__(self, attr):
(type(self).__name__, attr))

def __repr__(self):
return f"WithMapping({repr(self.wrapee)}, {self._mapping})"
return f"WithMapping({repr(self.wrapee)}, '{self._mapping}')"

def value_shape(self):
gdim = self.cell().geometric_dimension()
Expand Down

0 comments on commit 4e32e86

Please sign in to comment.