Skip to content

Commit

Permalink
Merge pull request #46 from UBC-MDS/scale-tests-add
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
chuangw6 authored Mar 14, 2021
2 parents 7e45172 + 9ab91f8 commit 76926b9
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tests/test_eda_utils_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ def test_cor_map():


def test_scaler():
data = pd.DataFrame(
{
"SepalLengthCm": [5.1, 4.9, 4.7],
"SepalWidthCm": [1.4, 1.4, 1.3],
"PetalWidthCm": [0.2, 0.1, 0.2],
"Species": ["Iris-setosa", "Iris-virginica", "Iris-germanica"],
}
)
mock_df_1 = pd.DataFrame(
{"col1": [1, 0, 0, 3, 4], "col2": [4, 1, 1, 0, 1], "col3": [2, 0, 0, 2, 1]}
)
Expand Down Expand Up @@ -227,19 +235,22 @@ def test_scaler():

# Test if the imput is not dataFrame
with raises(TypeError):
eda_utils_py.scale("A string")
eda_utils_py.scale("A string", ['one', 'two'])

# Tests if contents of columns is not of type str
with raises(TypeError):
eda_utils_py.scale(mock_df_1, (1, 2, 3, 4))
eda_utils_py.scale(mock_df_1, [1, 2, 3, 4])

with raises(TypeError):
eda_utils_py.scale(mock_df_1, [None])

# Tests if columns do not exist in the dataframe
with raises(Exception):
eda_utils_py.scale(mock_df_1, ['one', 'two'])

# Tests if if not all columns in columns are numeric
with raises(Exception):
eda_utils_py.scale(mock_df_1, {'col1': "1", 'col2': "3"})
eda_utils_py.scale(data, ['Species'])

# Tests whether data is not of type pd.Dataframe raises TypeError
with raises(TypeError):
Expand Down

0 comments on commit 76926b9

Please sign in to comment.