From 898e6801c2151f9a90bd0a09c949bdc50f1bd091 Mon Sep 17 00:00:00 2001 From: AmitMY Date: Fri, 3 Jul 2026 11:44:03 +0200 Subject: [PATCH] chore(deps): make scipy an optional dependency scipy was a required install for just two call sites: a z-axis rotation matrix in normalization_3d.py (now pure numpy, numerically identical) and cubic spline interpolation in NumPyPoseBody.interpolate, which already imports scipy lazily with an install hint. Dropping it from required dependencies shrinks the install footprint; scipy stays in the dev extra so tests still cover interpolation. Co-Authored-By: Claude Fable 5 --- src/python/pose_format/utils/normalization_3d.py | 12 +++++++++--- src/python/pyproject.toml | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/python/pose_format/utils/normalization_3d.py b/src/python/pose_format/utils/normalization_3d.py index e7e9d80..0ea6632 100644 --- a/src/python/pose_format/utils/normalization_3d.py +++ b/src/python/pose_format/utils/normalization_3d.py @@ -2,7 +2,6 @@ import numpy as np import numpy.ma as ma -from scipy.spatial.transform import Rotation from pose_format.pose_header import PoseNormalizationInfo @@ -136,8 +135,15 @@ def rotate(self, pose: ma.masked_array, angle: np.ndarray) -> ma.masked_array: ma.masked_array rotated pose """ - r = Rotation.from_euler('z', -angle[..., np.newaxis], degrees=True) # Clockwise rotation - rotated = np.einsum('...ij,...kj->...ik', pose, r.as_matrix()).reshape(pose.shape) + theta = np.radians(-angle) # Clockwise rotation + cos, sin = np.cos(theta), np.sin(theta) + rotation_matrix = np.zeros((*theta.shape, 3, 3)) + rotation_matrix[..., 0, 0] = cos + rotation_matrix[..., 0, 1] = -sin + rotation_matrix[..., 1, 0] = sin + rotation_matrix[..., 1, 1] = cos + rotation_matrix[..., 2, 2] = 1 + rotated = np.einsum('...ij,...kj->...ik', pose, rotation_matrix).reshape(pose.shape) return ma.masked_array(rotated, pose.mask) def scale(self, pose: ma.masked_array) -> ma.masked_array: diff --git a/src/python/pyproject.toml b/src/python/pyproject.toml index 5bcd451..1ed2684 100644 --- a/src/python/pyproject.toml +++ b/src/python/pyproject.toml @@ -11,7 +11,6 @@ authors = [ ] dependencies = [ "numpy", - "scipy", "tqdm", "simple-video-utils", ] @@ -21,6 +20,7 @@ requires-python = ">= 3.8" dev = [ "pylint", "pytest", + "scipy", "opencv-python", "vidgear", "mediapipe<0.10.30",