(self, q, unquantize=False)
| 513 | self._n = len(X) |
| 514 | |
| 515 | def transform(self, q, unquantize=False): |
| 516 | if self.reduction == Reductions.DOT_PRODUCT: |
| 517 | func = self._encoder_.dot_prods |
| 518 | elif self.reduction == Reductions.SQUARED_EUCLIDEAN: |
| 519 | func = self._encoder_.dists_sq |
| 520 | else: |
| 521 | self._bad_reduction() |
| 522 | |
| 523 | ret = func(self._preproc(q))[:self._n] |
| 524 | return (ret - self._total_offset_) / self.scale if unquantize else ret |
| 525 | |
| 526 | def knn(self, q, k): |
| 527 | if self.reduction == Reductions.DOT_PRODUCT: |