Skip to content

Commit

Permalink
Refactor2024/unstable decorator (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
baggiponte authored Jun 8, 2024
1 parent 0b2851f commit c7def0d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 0 additions & 4 deletions functime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@

__version__ = "0.9.5"

import logging

from functime.feature_extractors import FeatureExtractor # noqa: F401

logging.basicConfig(level=logging.INFO)
14 changes: 11 additions & 3 deletions functime/_utils.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
from __future__ import annotations

import logging
from typing import Any, Callable
from functools import wraps
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Callable, ParamSpec, TypeVar

P = ParamSpec("P")
R = TypeVar("R")

logger = logging.getLogger(__name__)


def UseAtOwnRisk(func: Callable) -> Any:
def wrapped_func(*args, **kwargs):
def warn_is_unstable(func: Callable[P, R]) -> Callable[P, R]:
@wraps(func)
def wrapped_func(*args: P.args, **kwargs: P.kwargs) -> R:
logger.warning(
f"The function {func.__name__} is unstable and untested. Use at your own risk."
)
Expand Down
4 changes: 2 additions & 2 deletions functime/feature_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from scipy.spatial import KDTree

from functime._functime_rust import rs_faer_lstsq1
from functime._utils import UseAtOwnRisk
from functime._utils import warn_is_unstable
from functime.type_aliases import DetrendMethod

# from functime.feature_extractor import FeatureExtractor # noqa: F401
Expand Down Expand Up @@ -164,7 +164,7 @@ def approximate_entropy(
ApEn = approximate_entropy


@UseAtOwnRisk
@warn_is_unstable
def augmented_dickey_fuller(x: TIME_SERIES_T, n_lags: int) -> float:
"""
Calculates the Augmented Dickey-Fuller (ADF) test statistic. This only works for Series input right now.
Expand Down

0 comments on commit c7def0d

Please sign in to comment.