(vector: Dict[str, float])
| 253 | |
| 254 | |
| 255 | def normalize_vector(vector: Dict[str, float]) -> Dict[str, float]: |
| 256 | norm = math.sqrt(sum(value * value for value in vector.values())) |
| 257 | if norm <= 0: |
| 258 | return {} |
| 259 | return {key: value / norm for key, value in vector.items() if value} |
| 260 | |
| 261 | |
| 262 | def add_weighted_vector(target: Dict[str, float], vector: Dict[str, float], weight: float) -> None: |
no outgoing calls
no test coverage detected