Skip to content

Commit a660079

Browse files
RoboX2020taughz
authored andcommitted
Defer scipy imports in spline.py
1 parent 824a459 commit a660079

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎spatialmath/spline.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
from typing import TYPE_CHECKING, List, Optional, Tuple
1212

1313
import numpy as np
14-
from scipy.interpolate import BSpline, CubicSpline
15-
from scipy.spatial.transform import Rotation, RotationSpline
1614

1715
from spatialmath import SE3, SO3, Twist3
1816
from spatialmath.base.transforms3d import tranimate
@@ -122,6 +120,9 @@ def __init__(
122120
self.timepoints = self.timepoints - self.timepoints[0]
123121
self.timepoints = self.timepoints / self.timepoints[-1]
124122

123+
from scipy.interpolate import CubicSpline # deferred, scipy is slow to import
124+
from scipy.spatial.transform import Rotation, RotationSpline
125+
125126
self.spline_xyz = CubicSpline(
126127
self.timepoints,
127128
np.array([pose.t for pose in self.control_poses]),
@@ -292,6 +293,8 @@ def __init__(
292293
) # ensures the curve ends on the last control pose
293294
self.knots = knots
294295

296+
from scipy.interpolate import BSpline # deferred, scipy is slow to import
297+
295298
self.splines = [
296299
BSpline(knots, self.control_pose_matrix[:, i], degree)
297300
for i in range(0, 6) # twists are length 6

0 commit comments

Comments
 (0)