SIENTIAPDE-1579?: removed duplicated method
This commit is contained in:
@@ -15,21 +15,16 @@ from sientia_do.operations.df_preprocessor import load_data
|
||||
from sientia_do.operations.normalization import MinMaxScaler, Z_Scaler
|
||||
|
||||
from model_manager.sientia.metrics import mae, mse, r2
|
||||
from model_manager.sientia.models import DataPreprocessor, LinearRegressionModel
|
||||
from model_manager.sientia.models import (
|
||||
DataPreprocessor,
|
||||
LinearRegressionModel,
|
||||
_frontend_date_format_to_strftime as _frontend_format_to_strftime,
|
||||
)
|
||||
from model_manager.sientia.utils import split_train_test
|
||||
from model_manager.utils.models.train_model_params import TrainModelParams
|
||||
from model_manager.utils.models.train_model_result import TrainModelResult
|
||||
|
||||
|
||||
def _frontend_format_to_strftime(fmt: str) -> str:
|
||||
"""Convert front-end date format (dd/MM/yyyy HH:mm:ss) to Python strftime (%d/%m/%Y %H:%M:%S)."""
|
||||
if not fmt:
|
||||
return fmt
|
||||
out = fmt.replace('yyyy', '%Y').replace('MM', '%m').replace('dd', '%d')
|
||||
out = out.replace('HH', '%H').replace('mm', '%M').replace('ss', '%S')
|
||||
return out
|
||||
|
||||
|
||||
def _ensure_date_column_parsed(data: pd.DataFrame, params: TrainModelParams) -> pd.DataFrame:
|
||||
"""If date_column and date_format are set, parse the column as datetime to avoid comparison errors downstream."""
|
||||
if not params.date_column or not params.date_format or params.date_column not in data.columns:
|
||||
|
||||
@@ -1127,9 +1127,10 @@ class TestExtractModelEquationPolynomial:
|
||||
class TestFrontendFormatToStrftime:
|
||||
"""Tests for _frontend_format_to_strftime."""
|
||||
|
||||
def test_empty_returns_unchanged(self):
|
||||
"""Empty string is returned as-is."""
|
||||
assert _frontend_format_to_strftime('') == ''
|
||||
def test_empty_or_none_returns_none(self):
|
||||
"""Empty string or None returns None (same behavior as models module)."""
|
||||
assert _frontend_format_to_strftime('') is None
|
||||
assert _frontend_format_to_strftime(None) is None
|
||||
|
||||
def test_dd_mm_yyyy_hh_mm_ss(self):
|
||||
"""Converts dd/MM/yyyy HH:mm:ss to strftime."""
|
||||
|
||||
Reference in New Issue
Block a user