Skip to content

Commit 0a61cf8

Browse files
authored
Merge pull request #42 from wangjc640/main
update test for better coverage
2 parents 9470238 + f4be2f6 commit 0a61cf8

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

eda_utils_py/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.1.3'
1+
__version__ = '0.1.5'

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "eda_utils_py"
3-
version = "0.1.3"
3+
version = "0.1.5"
44
description = "Python package that contains util functions for eda process"
55
authors = ["Chuang Wang <chuangw.sde@gmail.com>"]
66
license = "MIT"

tests/test_eda_utils_py.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,18 @@ def test_outlier_identifier():
357357
}
358358
)
359359

360+
numeric_only_df = pd.DataFrame({
361+
'SepalLengthCm' : [5.1, 4.9, 4.7, 5.5, 5.1, 50, 5.4, 5.0, 5.2, 5.3, 5.1],
362+
'SepalWidthCm' : [1.4, 1.4, 20, 2.0, 0.7, 1.6, 1.2, 1.4, 1.8, 1.5, 2.1],
363+
'PetalWidthCm' : [0.2, 0.2, 0.2, 0.3, 0.4, 0.5, 0.5, 0.6, 0.4, 0.2, 5]
364+
})
365+
366+
numeric_only_out = pd.DataFrame({
367+
'SepalLengthCm': [5.1, 4.9, 5.5, 5.1, 5.4, 5.0, 5.2, 5.3],
368+
'SepalWidthCm': [1.4, 1.4, 2.0, 0.7, 1.2, 1.4, 1.8, 1.5],
369+
'PetalWidthCm' :[0.2, 0.2, 0.3, 0.4, 0.5, 0.6, 0.4, 0.2],
370+
})
371+
360372
# Test if the imput is not dataFrame
361373
with raises(TypeError):
362374
eda_utils_py.outlier_identifier("not dataframe")
@@ -369,6 +381,10 @@ def test_outlier_identifier():
369381
with raises(Exception):
370382
eda_utils_py.outlier_identifier(test_df, columns=["not in"])
371383

384+
# Test if dataframe contains non-numeric column, but the user want to do it for all columns.
385+
with raises(Exception):
386+
eda_utils_py.outlier_identifier(test_df, method = "trim")
387+
372388
# Test if method input is not one of three methods provided
373389
with raises(Exception):
374390
eda_utils_py.outlier_identifier(test_df, columns=["SepalLengthCm"], method="no")
@@ -394,3 +410,6 @@ def test_outlier_identifier():
394410
),
395411
column_output,
396412
), "The selected column method is not correct"
413+
assert pd.DataFrame.equals(
414+
eda_utils_py.outlier_identifier(numeric_only_df, method = "trim"), numeric_only_out
415+
), "The numeric only method is not correct"

0 commit comments

Comments
 (0)