kinemotion 0.25.0__py3-none-any.whl → 0.26.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of kinemotion might be problematic. Click here for more details.

@@ -19,6 +19,38 @@ if TYPE_CHECKING:
19
19
  from ..core.quality import QualityAssessment
20
20
 
21
21
 
22
+ def _format_float_metric(
23
+ value: float | None, multiplier: float = 1, decimals: int = 2
24
+ ) -> float | None:
25
+ """Format a float metric value with optional scaling and rounding.
26
+
27
+ Args:
28
+ value: The value to format, or None
29
+ multiplier: Factor to multiply value by (default: 1)
30
+ decimals: Number of decimal places to round to (default: 2)
31
+
32
+ Returns:
33
+ Formatted value rounded to specified decimals, or None if input is None
34
+ """
35
+ if value is None:
36
+ return None
37
+ return round(value * multiplier, decimals)
38
+
39
+
40
+ def _format_int_metric(value: float | int | None) -> int | None:
41
+ """Format a value as an integer.
42
+
43
+ Args:
44
+ value: The value to format, or None
45
+
46
+ Returns:
47
+ Value converted to int, or None if input is None
48
+ """
49
+ if value is None:
50
+ return None
51
+ return int(value)
52
+
53
+
22
54
  class DropJumpDataDict(TypedDict, total=False):
23
55
  """Type-safe dictionary for drop jump measurement data."""
24
56
 
@@ -69,94 +101,65 @@ class DropJumpMetrics:
69
101
  # Complete metadata
70
102
  self.result_metadata: ResultMetadata | None = None
71
103
 
72
- def to_dict(self) -> DropJumpResultDict:
73
- """Convert metrics to JSON-serializable dictionary with data/metadata structure.
104
+ def _build_data_dict(self) -> DropJumpDataDict:
105
+ """Build the data portion of the result dictionary.
74
106
 
75
107
  Returns:
76
- Dictionary with nested data and metadata structure.
108
+ Dictionary containing formatted metric values.
77
109
  """
78
- data: DropJumpDataDict = {
79
- "ground_contact_time_ms": (
80
- round(self.ground_contact_time * 1000, 2)
81
- if self.ground_contact_time is not None
82
- else None
83
- ),
84
- "flight_time_ms": (
85
- round(self.flight_time * 1000, 2)
86
- if self.flight_time is not None
87
- else None
110
+ return {
111
+ "ground_contact_time_ms": _format_float_metric(
112
+ self.ground_contact_time, 1000, 2
88
113
  ),
89
- "jump_height_m": (
90
- round(self.jump_height, 3) if self.jump_height is not None else None
114
+ "flight_time_ms": _format_float_metric(self.flight_time, 1000, 2),
115
+ "jump_height_m": _format_float_metric(self.jump_height, 1, 3),
116
+ "jump_height_kinematic_m": _format_float_metric(
117
+ self.jump_height_kinematic, 1, 3
91
118
  ),
92
- "jump_height_kinematic_m": (
93
- round(self.jump_height_kinematic, 3)
94
- if self.jump_height_kinematic is not None
95
- else None
119
+ "jump_height_trajectory_normalized": _format_float_metric(
120
+ self.jump_height_trajectory, 1, 4
96
121
  ),
97
- "jump_height_trajectory_normalized": (
98
- round(self.jump_height_trajectory, 4)
99
- if self.jump_height_trajectory is not None
100
- else None
122
+ "contact_start_frame": _format_int_metric(self.contact_start_frame),
123
+ "contact_end_frame": _format_int_metric(self.contact_end_frame),
124
+ "flight_start_frame": _format_int_metric(self.flight_start_frame),
125
+ "flight_end_frame": _format_int_metric(self.flight_end_frame),
126
+ "peak_height_frame": _format_int_metric(self.peak_height_frame),
127
+ "contact_start_frame_precise": _format_float_metric(
128
+ self.contact_start_frame_precise, 1, 3
101
129
  ),
102
- "contact_start_frame": (
103
- int(self.contact_start_frame)
104
- if self.contact_start_frame is not None
105
- else None
130
+ "contact_end_frame_precise": _format_float_metric(
131
+ self.contact_end_frame_precise, 1, 3
106
132
  ),
107
- "contact_end_frame": (
108
- int(self.contact_end_frame)
109
- if self.contact_end_frame is not None
110
- else None
133
+ "flight_start_frame_precise": _format_float_metric(
134
+ self.flight_start_frame_precise, 1, 3
111
135
  ),
112
- "flight_start_frame": (
113
- int(self.flight_start_frame)
114
- if self.flight_start_frame is not None
115
- else None
116
- ),
117
- "flight_end_frame": (
118
- int(self.flight_end_frame)
119
- if self.flight_end_frame is not None
120
- else None
121
- ),
122
- "peak_height_frame": (
123
- int(self.peak_height_frame)
124
- if self.peak_height_frame is not None
125
- else None
126
- ),
127
- "contact_start_frame_precise": (
128
- round(self.contact_start_frame_precise, 3)
129
- if self.contact_start_frame_precise is not None
130
- else None
131
- ),
132
- "contact_end_frame_precise": (
133
- round(self.contact_end_frame_precise, 3)
134
- if self.contact_end_frame_precise is not None
135
- else None
136
- ),
137
- "flight_start_frame_precise": (
138
- round(self.flight_start_frame_precise, 3)
139
- if self.flight_start_frame_precise is not None
140
- else None
141
- ),
142
- "flight_end_frame_precise": (
143
- round(self.flight_end_frame_precise, 3)
144
- if self.flight_end_frame_precise is not None
145
- else None
136
+ "flight_end_frame_precise": _format_float_metric(
137
+ self.flight_end_frame_precise, 1, 3
146
138
  ),
147
139
  }
148
140
 
149
- # Build metadata from ResultMetadata if available, otherwise use legacy quality
141
+ def _build_metadata_dict(self) -> dict:
142
+ """Build the metadata portion of the result dictionary.
143
+
144
+ Returns:
145
+ Metadata dictionary from available sources.
146
+ """
150
147
  if self.result_metadata is not None:
151
- metadata = self.result_metadata.to_dict()
152
- elif self.quality_assessment is not None:
153
- # Fallback for backwards compatibility during transition
154
- metadata = {"quality": self.quality_assessment.to_dict()}
155
- else:
156
- # No metadata available
157
- metadata = {}
158
-
159
- return {"data": data, "metadata": metadata}
148
+ return self.result_metadata.to_dict()
149
+ if self.quality_assessment is not None:
150
+ return {"quality": self.quality_assessment.to_dict()}
151
+ return {}
152
+
153
+ def to_dict(self) -> DropJumpResultDict:
154
+ """Convert metrics to JSON-serializable dictionary with data/metadata structure.
155
+
156
+ Returns:
157
+ Dictionary with nested data and metadata structure.
158
+ """
159
+ return {
160
+ "data": self._build_data_dict(),
161
+ "metadata": self._build_metadata_dict(),
162
+ }
160
163
 
161
164
 
162
165
  def _determine_drop_start_frame(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kinemotion
3
- Version: 0.25.0
3
+ Version: 0.26.0
4
4
  Summary: Video-based kinematic analysis for athletic performance
5
5
  Project-URL: Homepage, https://github.com/feniix/kinemotion
6
6
  Project-URL: Repository, https://github.com/feniix/kinemotion
@@ -21,10 +21,10 @@ kinemotion/dropjump/__init__.py,sha256=yc1XiZ9vfo5h_n7PKVSiX2TTgaIfGL7Y7SkQtiDZj
21
21
  kinemotion/dropjump/analysis.py,sha256=1AsIsgWg5wuwJo7poFK7aMCFr93yHVms-fEvaOGQQWs,27448
22
22
  kinemotion/dropjump/cli.py,sha256=ZyroaYPwz8TgfL39Wcaj6m68Awl6lYXC75ttaflU-c0,16236
23
23
  kinemotion/dropjump/debug_overlay.py,sha256=LkPw6ucb7beoYWS4L-Lvjs1KLCm5wAWDAfiznUeV2IQ,5668
24
- kinemotion/dropjump/kinematics.py,sha256=PaVakc8eiYR6ZErp2jO3A8Ey-rNIso0rGLft6-yOEzs,17510
24
+ kinemotion/dropjump/kinematics.py,sha256=Ig9TqXr-OEUm19gqIvUjQkqrCuw1csYt1f4ZfwG8oGc,17464
25
25
  kinemotion/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- kinemotion-0.25.0.dist-info/METADATA,sha256=lJ39uLFmaTzqvZXJNw8eWBwwvWIeM2VQDd1D2cDcBUw,23244
27
- kinemotion-0.25.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
28
- kinemotion-0.25.0.dist-info/entry_points.txt,sha256=zaqnAnjLvcdrk1Qvj5nvXZCZ2gp0prS7it1zTJygcIY,50
29
- kinemotion-0.25.0.dist-info/licenses/LICENSE,sha256=KZajvqsHw0NoOHOi2q0FZ4NBe9HdV6oey-IPYAtHXfg,1088
30
- kinemotion-0.25.0.dist-info/RECORD,,
26
+ kinemotion-0.26.0.dist-info/METADATA,sha256=8v4nga4_2u750MvPwawuPG4DdqGce2NY4jtVBZ69UK4,23244
27
+ kinemotion-0.26.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
28
+ kinemotion-0.26.0.dist-info/entry_points.txt,sha256=zaqnAnjLvcdrk1Qvj5nvXZCZ2gp0prS7it1zTJygcIY,50
29
+ kinemotion-0.26.0.dist-info/licenses/LICENSE,sha256=KZajvqsHw0NoOHOi2q0FZ4NBe9HdV6oey-IPYAtHXfg,1088
30
+ kinemotion-0.26.0.dist-info/RECORD,,