(vector: List[float], target_dim: int)
| 382 | |
| 383 | |
| 384 | def _resize_vector(vector: List[float], target_dim: int) -> List[float]: |
| 385 | if target_dim <= 0: |
| 386 | return [] |
| 387 | |
| 388 | values = [float(value) for value in (vector or [])] |
| 389 | if len(values) == target_dim: |
| 390 | return values |
| 391 | if len(values) > target_dim: |
| 392 | return values[:target_dim] |
| 393 | return values + [0.0] * (target_dim - len(values)) |
| 394 | |
| 395 | |
| 396 | def _normalize_vector(vector: List[float]) -> List[float]: |
no outgoing calls
no test coverage detected