(vector: Dict[str, float])
| 215 | |
| 216 | |
| 217 | def normalize_vector(vector: Dict[str, float]) -> Dict[str, float]: |
| 218 | norm = math.sqrt(sum(value * value for value in vector.values())) |
| 219 | if norm <= 0: |
| 220 | return {} |
| 221 | return {key: value / norm for key, value in vector.items() if value} |
| 222 | |
| 223 | |
| 224 | def add_weighted_vector(target: Dict[str, float], vector: Dict[str, float], weight: float) -> None: |
no outgoing calls
no test coverage detected