Skip to content

Commit 7c0ab70

Browse files
fix: geomdl dependency in conda-forge (#1900)
Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
1 parent 2ae51ef commit 7c0ab70

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

doc/changelog.d/1900.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
geomdl dependency in conda-forge

src/ansys/geometry/core/shapes/curves/nurbs.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222
"""Provides for creating and managing a NURBS curve."""
2323

2424
from functools import cached_property
25-
from typing import Optional
25+
from typing import TYPE_CHECKING, Optional
2626

2727
from beartype import beartype as check_input_types
28-
import geomdl.NURBS as geomdl_nurbs # noqa: N811
2928

3029
from ansys.geometry.core.math import Matrix44, Point3D
3130
from ansys.geometry.core.math.vector import Vector3D
@@ -39,6 +38,9 @@
3938
)
4039
from ansys.geometry.core.typing import Real
4140

41+
if TYPE_CHECKING: # pragma: no cover
42+
import geomdl.NURBS as geomdl_nurbs # noqa: N811
43+
4244

4345
class NURBSCurve(Curve):
4446
"""Represents a NURBS curve.
@@ -53,14 +55,20 @@ class NURBSCurve(Curve):
5355
5456
"""
5557

56-
def __init__(
57-
self,
58-
):
58+
def __init__(self):
5959
"""Initialize ``NURBSCurve`` class."""
60+
try:
61+
import geomdl.NURBS as geomdl_nurbs # noqa: N811
62+
except ImportError as e: # pragma: no cover
63+
raise ImportError(
64+
"The `geomdl` library is required to use the NURBSCurve class. "
65+
"Please install it using `pip install geomdl`."
66+
) from e
67+
6068
self._nurbs_curve = geomdl_nurbs.Curve()
6169

6270
@property
63-
def geomdl_nurbs_curve(self) -> geomdl_nurbs.Curve:
71+
def geomdl_nurbs_curve(self) -> "geomdl_nurbs.Curve":
6472
"""Get the underlying NURBS curve.
6573
6674
Notes
@@ -237,7 +245,7 @@ def project_point(
237245

238246
# Function to minimize (distance squared)
239247
def distance_squared(
240-
u: float, geomdl_nurbs_curbe: geomdl_nurbs.Curve, point: np.ndarray
248+
u: float, geomdl_nurbs_curbe: "geomdl_nurbs.Curve", point: np.ndarray
241249
) -> np.ndarray:
242250
point_on_curve = np.array(geomdl_nurbs_curbe.evaluate_single(u))
243251
return np.sum((point_on_curve - point) ** 2)

0 commit comments

Comments
 (0)