Skip to content

Commit

Permalink
mesh: remove deprecation of copy
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl authored and inducer committed May 8, 2024
1 parent 08a0e20 commit 279d40b
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions meshmode/mesh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,7 @@ class Mesh:
.. autoattribute:: _nodal_adjacency
.. autoattribute:: _facial_adjacency_groups
.. automethod:: copy
.. automethod:: __eq__
"""

Expand Down Expand Up @@ -1242,20 +1243,30 @@ def __init__(
node_vertex_consistency_tolerance=node_vertex_consistency_tolerance,
skip_element_orientation_test=skip_element_orientation_test)

def copy(self, **kwargs: Any) -> "Mesh":
warn(f"'{type(self).__name__}.copy' is deprecated and will be removed in "
f"2025. '{type(self).__name__}' is a dataclass and can use the "
"standard 'replace' function.",
DeprecationWarning, stacklevel=2)

def copy(self, *,
skip_tests: bool = False,
node_vertex_consistency_tolerance:
Optional[Union[Literal[False], bool]] = None,
skip_element_orientation_test: bool = False,
# NOTE: this is set to *True* to avoid the meaningless warning in
# `__init__` when calling `Mesh.copy`
factory_constructed: bool = True,
**kwargs: Any) -> "Mesh":
if "nodal_adjacency" in kwargs:
kwargs["_nodal_adjacency"] = kwargs.pop("nodal_adjacency")

if "facial_adjacency_groups" in kwargs:
kwargs["_facial_adjacency_groups"] = (
kwargs.pop("facial_adjacency_groups"))

return replace(self, **kwargs)
mesh = replace(self, factory_constructed=factory_constructed, **kwargs)
if __debug__ and not skip_tests:
check_mesh_consistency(
mesh,
node_vertex_consistency_tolerance=node_vertex_consistency_tolerance,
skip_element_orientation_test=skip_element_orientation_test)

return mesh

@property
def ambient_dim(self) -> int:
Expand Down

0 comments on commit 279d40b

Please sign in to comment.