def test_ScalerList(X): g = Scaler("BoxCoxScaler") assert g.scalers() == [ "StandardScaler", "MinMaxScaler", "Normalizer", "MaxAbsScaler", "RobustScaler", "QuantileTransformer", "BoxCoxScaler", "LambertScaler", ]
def test_df_BoxCox_read(df_type): g = Scaler("BoxCoxScaler").cacheOn() g.train(df_type).predict(df_type) fp: str = "tmp/df_write" g.write(fp) g.read(fp) assert (g.trained and g.predicted and g.cache and g.persisted and (g.save_file_name == fp)) == True
def test_df_Lambert_read(df_City): g = Scaler("LambertScaler").cacheOn() g.train(df_City).predict(df_City) fp: str = "tmp/df_write" g.write(fp) g.read(fp) assert (g.trained and g.predicted and g.cache and g.persisted and (g.save_file_name == fp)) == True
def test_df_MinMax_write(df_type): g = Scaler("MinMaxScaler").cacheOn() g.train(df_type).predict(df_type) fp: str = "tmp/df" g.write(fp) assert (g.trained and g.predicted and g.cache and g.persisted and (g.save_file_name == fp)) == True
def test_df_BoxCox_type_error(ystr): g = Scaler("BoxCoxScaler") with pytest.raises(TypeError): g.train(ystr())
def test_predict_df_BoxCox_df_type(df_type): g = Scaler("BoxCoxScaler") g.train(df_type) assert g.predict(df_type).shape == df_type.shape
def test_df_BoxCox_numpy_1d_error(y): g = Scaler("BoxCoxScaler") with pytest.raises(PasoError): g.train(y)
def test_df_BoxCox_df_type(df_type): g = Scaler("BoxCoxScaler") assert g.train(df_type) == g
def test_df_BoxCox_City_NA_error(df_small): g = Scaler("BoxCoxScaler") with pytest.raises(PasoError): g.train(df_small)
def test_df_Lambert_numpy_1d_error(y): g = Scaler("LambertScaler") with pytest.raises(PasoError): g.train(y)
def test_df_Class_init_WrongScaler(): with pytest.raises(PasoError): g = Scaler("GORG")
def test_df_Class_init_NoArg(): with pytest.raises(TypeError): g = Scaler()
def test_df_BoxCox_inverse(df_type): g = Scaler("BoxCoxScaler") g.train(df_type, inplace=False) assert g.inverse_predict(g.predict(df_type) == df_type).any().any()
def test_df_Lambert_train(df_type): g = Scaler("LambertScaler") assert g.train(df_type) == g
def test_bad_scale_name(): with pytest.raises(PasoError): g = Scaler("fred")
def test_df_Lambert_predict(df_type): g = Scaler("LambertScaler") g.train(df_type) assert g.predict(df_type).shape == df_type.shape
def test_df_BoxCox_City_negative_error(df_City): g = Scaler("BoxCoxScaler") with pytest.raises(ValueError): g.train(df_City)
def test_df_Lambert_type_error(ystr): g = Scaler("LambertScaler") with pytest.raises(PasoError): g.train(ystr)
def test_df_Lambert_no_fit(yn): g = Scaler("LambertScaler") with pytest.raises(AttributeError): g.fit()