Skip to content

Commit

Permalink
exclude pyvista untyped import
Browse files Browse the repository at this point in the history
  • Loading branch information
skim0119 committed Jun 19, 2024
1 parent 45c6cce commit 13fd737
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
21 changes: 11 additions & 10 deletions elastica/mesh/mesh_initializer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
__doc__ = """ Mesh Initializer using Pyvista """

import pyvista as pv
import pyvista as pv # type: ignore
import numpy as np
from numpy.typing import NDArray


class Mesh:
Expand Down Expand Up @@ -100,8 +101,8 @@ def mesh_update(self) -> None:
)

def face_calculation(
self, pvfaces: np.ndarray, meshpoints: np.ndarray, n_faces: int
) -> np.ndarray:
self, pvfaces: NDArray, meshpoints: NDArray, n_faces: int
) -> NDArray:
"""
This function converts the faces from pyvista to pyelastica geometry
Expand Down Expand Up @@ -142,7 +143,7 @@ def face_calculation(

return faces

def face_normal_calculation(self, pyvista_face_normals: np.ndarray) -> np.ndarray:
def face_normal_calculation(self, pyvista_face_normals: NDArray) -> NDArray:
"""
This function converts the face normals from pyvista to pyelastica geometry,
in pyelastica the face are stored in the format of (n_faces, 3 spatial coordinates),
Expand All @@ -152,7 +153,7 @@ def face_normal_calculation(self, pyvista_face_normals: np.ndarray) -> np.ndarra

return face_normals

def face_center_calculation(self, faces: np.ndarray, n_faces: int) -> np.ndarray:
def face_center_calculation(self, faces: NDArray, n_faces: int) -> NDArray:
"""
This function calculates the position vector of each face of the mesh
simply by averaging all the vertices of every face/cell.
Expand All @@ -167,7 +168,7 @@ def face_center_calculation(self, faces: np.ndarray, n_faces: int) -> np.ndarray

return face_centers

def mesh_scale_calculation(self, bounds: np.ndarray) -> np.ndarray:
def mesh_scale_calculation(self, bounds: NDArray) -> NDArray:
"""
This function calculates scale of the mesh,
for that it calculates the maximum distance between mesh's farthest verticies in each axis.
Expand All @@ -180,7 +181,7 @@ def mesh_scale_calculation(self, bounds: np.ndarray) -> np.ndarray:

return scale

def orientation_calculation(self, cube_face_normals: np.ndarray) -> np.ndarray:
def orientation_calculation(self, cube_face_normals: NDArray) -> NDArray:
"""
This function calculates the orientation of the mesh
by using a dummy cube utility from pyvista.
Expand Down Expand Up @@ -209,7 +210,7 @@ def visualize(self) -> None:
pyvista_plotter.add_mesh(self.mesh)
pyvista_plotter.show()

def translate(self, target_center: np.ndarray) -> None:
def translate(self, target_center: NDArray) -> None:
"""
Parameters: {numpy.ndarray-(3 spatial coordinates)}
ex : mesh.translate(np.array([1,1,1]))
Expand All @@ -220,7 +221,7 @@ def translate(self, target_center: np.ndarray) -> None:
self.mesh = self.mesh.translate(target_center)
self.mesh_update()

def scale(self, factor: np.ndarray) -> None:
def scale(self, factor: NDArray) -> None:
"""
Parameters: {numpy.ndarray-(3 spatial constants)}
ex : mesh.scale(np.array([1,1,1]))
Expand All @@ -230,7 +231,7 @@ def scale(self, factor: np.ndarray) -> None:
self.mesh = self.mesh.scale(factor)
self.mesh_update()

def rotate(self, axis: np.ndarray, angle: float) -> None:
def rotate(self, axis: NDArray, angle: float) -> None:
"""
Parameters: {rotation_axis: unit vector[numpy.ndarray-(3 spatial coordinates)], angle: in degrees[float]}
ex : mesh.rotate(np.array([1,0,0]), 90)
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ warn_unused_ignores = false
exclude = [
"elastica/systems/analytical.py",
"elastica/experimental/*",
"elastica/mesh/mesh_initializer.py",
]

untyped_calls_exclude = [
"pyvista",
]

[tool.coverage.report]
Expand Down

0 comments on commit 13fd737

Please sign in to comment.