Skip to content

Commit

Permalink
Replace warning with error
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-hse-repository committed Feb 27, 2023
1 parent 354ce9f commit e9a58cd
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 14 deletions.
5 changes: 2 additions & 3 deletions etna/transforms/encoders/categorical.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import warnings
from enum import Enum
from typing import List
from typing import Optional
Expand Down Expand Up @@ -78,7 +77,7 @@ def __init__(self, in_column: str, out_column: Optional[str] = None, strategy: s
def get_regressors_info(self) -> List[str]:
"""Return the list with regressors created by the transform."""
if self.in_column_regressor is None:
warnings.warn("Regressors info might be incorrect. Fit the transform to get the correct regressors info.")
raise ValueError("Fit the transform to get the correct regressors info!")
return [self._get_column_name()] if self.in_column_regressor else []

def _fit(self, df: pd.DataFrame) -> "LabelEncoderTransform":
Expand Down Expand Up @@ -159,7 +158,7 @@ def __init__(self, in_column: str, out_column: Optional[str] = None):
def get_regressors_info(self) -> List[str]:
"""Return the list with regressors created by the transform."""
if self.in_column_regressor is None:
warnings.warn("Regressors info might be incorrect. Fit the transform to get the correct regressors info.")
raise ValueError("Fit the transform to get the correct regressors info!")
return self._get_out_column_names() if self.in_column_regressor else []

def _fit(self, df: pd.DataFrame) -> "OneHotEncoderTransform":
Expand Down
2 changes: 1 addition & 1 deletion etna/transforms/math/add_constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def _inverse_transform(self, df: pd.DataFrame) -> pd.DataFrame:
def get_regressors_info(self) -> List[str]:
"""Return the list with regressors created by the transform."""
if self.in_column_regressor is None:
warnings.warn("Regressors info might be incorrect. Fit the transform to get the correct regressors info.")
raise ValueError("Fit the transform to get the correct regressors info!")
return [self._get_column_name()] if self.in_column_regressor and not self.inplace else []


Expand Down
2 changes: 1 addition & 1 deletion etna/transforms/math/apply_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,5 @@ def _inverse_transform(self, df: pd.DataFrame) -> pd.DataFrame:
def get_regressors_info(self) -> List[str]:
"""Return the list with regressors created by the transform."""
if self.in_column_regressor is None:
warnings.warn("Regressors info might be incorrect. Fit the transform to get the correct regressors info.")
raise ValueError("Fit the transform to get the correct regressors info!")
return [self.change_column] if self.in_column_regressor and not self.inplace else []
5 changes: 2 additions & 3 deletions etna/transforms/math/differencing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import warnings
from typing import Dict
from typing import List
from typing import Optional
Expand Down Expand Up @@ -84,7 +83,7 @@ def get_regressors_info(self) -> List[str]:
if self.inplace:
return []
if self.in_column_regressor is None:
warnings.warn("Regressors info might be incorrect. Fit the transform to get the correct regressors info.")
raise ValueError("Fit the transform to get the correct regressors info!")
return [self._get_column_name()] if self.in_column_regressor else []

def fit(self, ts: TSDataset) -> "_SingleDifferencingTransform":
Expand Down Expand Up @@ -362,7 +361,7 @@ def get_regressors_info(self) -> List[str]:
if self.inplace:
return []
if self.in_column_regressor is None:
warnings.warn("Regressors info might be incorrect. Fit the transform to get the correct regressors info.")
raise ValueError("Fit the transform to get the correct regressors info!")
return [self._get_column_name()] if self.in_column_regressor else []

def fit(self, ts: TSDataset) -> "DifferencingTransform":
Expand Down
2 changes: 1 addition & 1 deletion etna/transforms/math/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def _inverse_transform(self, df: pd.DataFrame) -> pd.DataFrame:
def get_regressors_info(self) -> List[str]:
"""Return the list with regressors created by the transform."""
if self.in_column_regressor is None:
warnings.warn("Regressors info might be incorrect. Fit the transform to get the correct regressors info.")
raise ValueError("Fit the transform to get the correct regressors info!")
return [self._get_column_name()] if self.in_column_regressor and not self.inplace else []


Expand Down
3 changes: 1 addition & 2 deletions etna/transforms/math/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,5 @@ def get_regressors_info(self) -> List[str]:
if self.inplace:
return []
if self.out_column_regressors is None:
warnings.warn("Regressors info might be incorrect. Fit the transform to get the correct regressors info.")
return []
raise ValueError("Fit the transform to get the correct regressors info!")
return self.out_column_regressors
3 changes: 1 addition & 2 deletions etna/transforms/math/statistics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import warnings
from abc import ABC
from abc import abstractmethod
from typing import List
Expand Down Expand Up @@ -110,7 +109,7 @@ def _transform(self, df: pd.DataFrame) -> pd.DataFrame:
def get_regressors_info(self) -> List[str]:
"""Return the list with regressors created by the transform."""
if self.in_column_regressor is None:
warnings.warn("Regressors info might be incorrect. Fit the transform to get the correct regressors info.")
raise ValueError("Fit the transform to get the correct regressors info!")
return [self.out_column_name] if self.in_column_regressor else []


Expand Down
2 changes: 1 addition & 1 deletion etna/transforms/missing_values/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def get_regressors_info(self) -> List[str]:
if self.inplace:
return []
if self.in_column_regressor is None:
warnings.warn("Regressors info might be incorrect. Fit the transform to get the correct regressors info.")
raise ValueError("Fit the transform to get the correct regressors info!")
return [self.out_column] if self.in_column_regressor else []

def fit(self, ts: TSDataset) -> "ResampleWithDistributionTransform":
Expand Down

0 comments on commit e9a58cd

Please sign in to comment.