Skip to content

Commit

Permalink
fix: adding more informative errors to p2 tetra
Browse files Browse the repository at this point in the history
  • Loading branch information
Lachlan Grose committed Jun 8, 2022
1 parent 57ed443 commit c63cae7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions LoopStructural/interpolators/supports/_3d_p2_tetra.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ def __init__(
):
UnStructuredTetMesh.__init__(self, nodes, elements, neighbours, aabb_nsteps)
if self.elements.shape[1] != 10:
raise ValueError("P2 tetrahedron must have 8 nodes")
raise ValueError(
f"P2 tetrahedron must have 8 nodes, has {self.elements.shape[1]}"
)
self.hessian = np.array(
[
[
Expand Down Expand Up @@ -309,8 +311,10 @@ def evaluate_value(self, pos: np.ndarray, property_array: np.ndarray) -> np.ndar
-------
"""
if len(pos) != 2 or pos.shape[1] != 3:
raise ValueError("pos must be a numpy array of shape (n,3)")
if len(pos.shape) != 2 or pos.shape[1] != 3:
raise ValueError(
f"pos must be a numpy array of shape (n,3), shape is {pos.shape}"
)
if property_array.shape[0] != self.n_nodes:
raise ValueError("property array must have same length as nodes")
values = np.zeros(pos.shape[0])
Expand All @@ -324,8 +328,10 @@ def evaluate_value(self, pos: np.ndarray, property_array: np.ndarray) -> np.ndar
def evaluate_gradient(
self, pos: np.ndarray, property_array: np.ndarray
) -> np.ndarray:
if len(pos) != 2 or pos.shape[1] != 3:
raise ValueError("pos must be a numpy array of shape (n,3)")
if len(pos.shape) != 2 or pos.shape[1] != 3:
raise ValueError(
f"pos must be a numpy array of shape (n,3), shape is {pos.shape}"
)
if property_array.shape[0] != self.n_nodes:
raise ValueError("property array must have same length as nodes")
values = np.zeros(pos.shape)
Expand Down

0 comments on commit c63cae7

Please sign in to comment.