haystack/haystack/utils/scipy_utils.py
ZanSara ba11d1c2a8
refactor!: extract evaluation and statistical dependencies (#4457)
* try-catch sklearn and scipy

* haystack imports

* linting

* mypy

* try to import baseretriever

* remove typing

* unused import

* remove more typing

* pylint

* isolate sql imports for postgres, which we don't use anyway

* remove stats

* replace expit

* als inmemory

* mypy

* feedback

* docker

* expit

* re-add njit
2023-04-12 15:38:56 +02:00

18 lines
421 B
Python

import logging
import numpy as np
logger = logging.getLogger(__name__)
try:
from numba import njit # pylint: disable=import-error
except (ImportError, ModuleNotFoundError):
logger.debug("Numba not found, replacing njit() with no-op implementation. Enable it with 'pip install numba'.")
def njit(f):
return f
@njit # (fastmath=True)
def expit(x: float) -> float:
return 1 / (1 + np.exp(-x))