Skip to content

Commit

Permalink
avoid unnecessary contiguous
Browse files Browse the repository at this point in the history
  • Loading branch information
j042 committed Jan 10, 2024
1 parent 4550396 commit 9eaef8f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions gustaf/utils/arr.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,7 @@ def rotate(arr, rotation, rotation_axis=None, degree=True):
"""
arr = make_c_contiguous(arr, settings.FLOAT_DTYPE)
if rotation_axis is not None:
rotation_axis = make_c_contiguous(
rotation_axis, settings.FLOAT_DTYPE
).ravel()
rotation_axis = np.asanyarray(rotation_axis)

if rotation_axis is None:
return np.matmul(arr, rotation_matrix(rotation, degree))
Expand Down
6 changes: 3 additions & 3 deletions gustaf/utils/connec.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def tet_to_tri(volumes):
--------
faces: (n * 4, 3) np.ndarray
"""
volumes = arr.make_c_contiguous(volumes, settings.INT_DTYPE)
volumes = np.asanyarray(volumes, settings.INT_DTYPE)

if volumes.ndim != 2 or volumes.shape[1] != 4:
raise ValueError("Given volumes are not `tet` volumes")
Expand Down Expand Up @@ -113,7 +113,7 @@ def hexa_to_quad(volumes):
--------
faces: (n * 8, 4) np.ndarray
"""
volumes = arr.make_c_contiguous(volumes, settings.INT_DTYPE)
volumes = np.asanyarray(volumes, settings.INT_DTYPE)

if volumes.ndim != 2 or volumes.shape[1] != 8:
raise ValueError("Given volumes are not `hexa` volumes")
Expand Down Expand Up @@ -142,7 +142,7 @@ def volumes_to_faces(volumes):
--------
faces: (n*4, 3) or (m*6, 4) np.ndarray
"""
volumes = arr.make_c_contiguous(volumes, settings.INT_DTYPE)
volumes = np.asanyarray(volumes, settings.INT_DTYPE)
if volumes.shape[1] == 4:
return tet_to_tri(volumes)

Expand Down

0 comments on commit 9eaef8f

Please sign in to comment.