Coverage for physiodsp / sensors / imu / base.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-02-26 21:14 +0000

1from dataclasses import dataclass 

2 

3from numpy import array, sqrt, column_stack 

4 

5 

6@dataclass 

7class IMUData: 

8 timestamps: array 

9 x: array 

10 y: array 

11 z: array 

12 fs: int = 64 

13 

14 @property 

15 def magnitude(self) -> array: 

16 """Inertial Measurement Unit Magnitude""" 

17 return sqrt(self.x**2 + self.y**2 + self.z**2) 

18 

19 def to_matrix(self) -> array: 

20 """ 

21 Converte the three axes into a (N, 3) numpy ndarray. 

22 

23 Returns: 

24 array: Array of shape (N, 3) with columns [x, y, z] where N is the number of samples 

25 """ 

26 return column_stack((self.x, self.y, self.z))