Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jitingxu1 committed Sep 17, 2024
1 parent b8b39f2 commit ac7e48d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_standardize.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import numpy as np
import pandas as pd
import pandas.testing as tm
import pytest

import ibis_ml as ml

Expand All @@ -28,3 +29,14 @@ def test_scaleminmax():
result = step.transform_table(table)
expected = pd.DataFrame({"col": (cols - min_val) / (max_val - min_val)})
tm.assert_frame_equal(result.execute(), expected, check_exact=False)


@pytest.mark.parametrize("scaler", ["ScaleStandard", "ScaleMinMax"])
def test_constant_columns(scaler):
table = ibis.memtable({"int_col": [100], "float_col": [100.0]})
scaler_class = getattr(ml, scaler)
scale_step = scaler_class(ml.numeric())
scale_step.fit_table(table, ml.core.Metadata())
result = scale_step.transform_table(table)
expected = pd.DataFrame({"int_col": [0.0], "float_col": [0.0]})
tm.assert_frame_equal(result.execute(), expected)

0 comments on commit ac7e48d

Please # to comment.