From 1ab45539b7f5ce235798ca4739b292adf6dd749e Mon Sep 17 00:00:00 2001 From: "e.kerkhof" <e.kerkhof@nki.nl> Date: Mon, 8 Jul 2024 16:52:51 +0200 Subject: [PATCH 1/2] Issue #88: fixed np.NaN deprecation --- sksurgerycore/algorithms/tracking_smoothing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sksurgerycore/algorithms/tracking_smoothing.py b/sksurgerycore/algorithms/tracking_smoothing.py index 3be700a..243996b 100644 --- a/sksurgerycore/algorithms/tracking_smoothing.py +++ b/sksurgerycore/algorithms/tracking_smoothing.py @@ -80,7 +80,7 @@ def __init__(self, vector_size=3, buffer_size=1, datatype = float): self._buffer = np.empty((buffer_size, vector_size), dtype=datatype) if datatype in [float, np.float32, np.float64]: - self._buffer[:] = np.NaN + self._buffer[:] = np.nan else: self._buffer[:] = -1 @@ -146,4 +146,4 @@ def getmean(self): if no_nan_buffer.shape[0] > 0: return average_quaternions(np.reshape(no_nan_buffer, (samples, 4))) - return [np.NaN, np.NaN, np.NaN, np.NaN] + return [np.nan, np.nan, np.nan, np.nan] From 180afca29c3d56b821fbc344f437b795250a8577 Mon Sep 17 00:00:00 2001 From: "e.kerkhof" <e.kerkhof@nki.nl> Date: Tue, 9 Jul 2024 13:08:22 +0200 Subject: [PATCH 2/2] Issue #88: missed 2 instances --- sksurgerycore/algorithms/tracking_smoothing.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sksurgerycore/algorithms/tracking_smoothing.py b/sksurgerycore/algorithms/tracking_smoothing.py index 243996b..046a353 100644 --- a/sksurgerycore/algorithms/tracking_smoothing.py +++ b/sksurgerycore/algorithms/tracking_smoothing.py @@ -21,7 +21,7 @@ def _rvec_to_quaternion(rvec): rvec_rs = np.reshape(rvec, (1, 3)) if np.isnan(rvec_rs).any(): - return np.full(4, np.NaN) + return np.full(4, np.nan) angle = np.linalg.norm(rvec_rs) assert angle >= 0.0 @@ -31,7 +31,7 @@ def _rvec_to_quaternion(rvec): rvec_norm = rvec_rs / angle - quaternion = np.full(4, np.NaN) + quaternion = np.full(4, np.nan) quaternion[0] = math.cos(angle/2) quaternion[1] = rvec_norm[0][0] * math.sin(angle/2) quaternion[2] = rvec_norm[0][1] * math.sin(angle/2) @@ -97,7 +97,7 @@ def pop(self, vector): def getmean(self): """ - Returns the mean vector across the buffer, ignoring NaNs + Returns the mean vector across the buffer, ignoring nans """ with warnings.catch_warnings(): #nanmean raises a warning if all values are nan, @@ -135,7 +135,7 @@ def pop(self, vector, is_quaternion = False): def getmean(self): """ - Returns the mean quaternion across the buffer, ignoring NaNs + Returns the mean quaternion across the buffer, ignoring nans """ no_nan_buffer = self._buffer[~np.isnan(self._buffer)] samples = int(no_nan_buffer.shape[0]/4)