Skip to content

Commit 87db37a

Browse files
change size 0 check
1 parent e1192d9 commit 87db37a

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/smsfusion/_smoothing.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ def position(self) -> NDArray:
148148
Position estimates for each of the N time steps where the smoother has
149149
been updated with measurements.
150150
"""
151-
if len(self.x) == 0:
151+
x = self.x
152+
if x.size == 0:
152153
return np.array([])
153154
return self.x[:, :3]
154155

@@ -162,7 +163,8 @@ def velocity(self) -> NDArray:
162163
Velocity estimates for each of the N time steps where the smoother has
163164
been updated with measurements.
164165
"""
165-
if len(self._x_buf) == 0:
166+
x = self.x
167+
if x.size == 0:
166168
return np.array([])
167169
return self.x[:, 3:6]
168170

@@ -176,7 +178,8 @@ def quaternion(self) -> NDArray:
176178
Unit quaternion estimates for each of the N time steps where the smoother has
177179
been updated with measurements.
178180
"""
179-
if len(self._x_buf) == 0:
181+
x = self.x
182+
if x.size == 0:
180183
return np.array([])
181184
return self.x[:, 6:10]
182185

@@ -190,7 +193,8 @@ def bias_acc(self) -> NDArray:
190193
Accelerometer bias estimates for each of the N time steps where the smoother has
191194
been updated with measurements.
192195
"""
193-
if len(self._x_buf) == 0:
196+
x = self.x
197+
if x.size == 0:
194198
return np.array([])
195199
return self.x[:, 10:13]
196200

@@ -204,7 +208,8 @@ def bias_gyro(self, degrees: bool = False) -> NDArray:
204208
Gyroscope bias estimates for each of the N time steps where the smoother has
205209
been updated with measurements.
206210
"""
207-
if len(self._x_buf) == 0:
211+
x = self.x
212+
if x.size == 0:
208213
return np.array([])
209214
bg = self.x[:, 13:16]
210215
if degrees:
@@ -221,7 +226,8 @@ def euler(self, degrees: bool = False) -> NDArray:
221226
Euler angles estimates for each of the N time steps where the smoother has
222227
been updated with measurements.
223228
"""
224-
if len(self._x_buf) == 0:
229+
x = self.x
230+
if x.size == 0:
225231
return np.array([])
226232
q = self.quaternion()
227233
theta = np.empty((q.shape[0], 3))

0 commit comments

Comments
 (0)