Skip to content

Commit eb7d0e6

Browse files
committed
tests: include decimal data in test suite
1 parent b860ef2 commit eb7d0e6

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

tests/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from decimal import Decimal
12
from json import load
23
from os.path import dirname
34

@@ -88,4 +89,8 @@ def pytest_configure():
8889

8990
df = pd.read_csv(resources.data(CSV_FILE))
9091
df["date"] = pd.to_datetime(df["date"])
92+
93+
# Decimal type
94+
df["amount"] = df["balance"].str.replace("$", "", regex=False).str.replace(",", "", regex=False).apply(Decimal)
95+
9196
pytest.test_df = df

tests/test_pandas_histogrammar.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414

1515
def test_get_histograms():
16-
1716
pandas_filler = PandasHistogrammar(
1817
features=[
1918
"date",
@@ -47,7 +46,6 @@ def test_get_histograms():
4746

4847

4948
def test_make_histograms():
50-
5149
features = [
5250
"date",
5351
"isActive",
@@ -85,15 +83,14 @@ def test_make_histograms():
8583

8684

8785
def test_make_histograms_no_time_axis():
88-
8986
hists, features, bin_specs, time_axis, var_dtype = make_histograms(
9087
pytest.test_df, time_axis="", ret_specs=True,
9188
)
9289

93-
assert len(hists) == 21
94-
assert len(features) == 21
95-
assert len(bin_specs) == 6
96-
assert len(var_dtype) == 21
90+
assert len(hists) == 22
91+
assert len(features) == 22
92+
assert len(bin_specs) == 7
93+
assert len(var_dtype) == 22
9794
assert time_axis == ""
9895
assert "date" in hists
9996
h = hists["date"]
@@ -110,15 +107,14 @@ def test_make_histograms_no_time_axis():
110107

111108

112109
def test_make_histograms_with_time_axis():
113-
114110
hists, features, bin_specs, time_axis, var_dtype = make_histograms(
115111
pytest.test_df, time_axis=True, ret_specs=True, time_width=None, time_offset=None
116112
)
117113

118-
assert len(hists) == 20
119-
assert len(features) == 20
120-
assert len(bin_specs) == 20
121-
assert len(var_dtype) == 21
114+
assert len(hists) == 21
115+
assert len(features) == 21
116+
assert len(bin_specs) == 21
117+
assert len(var_dtype) == 22
122118
assert time_axis == "date"
123119
assert "date:age" in hists
124120
h = hists["date:age"]
@@ -167,10 +163,10 @@ def test_make_histograms_unit_binning():
167163
pytest.test_df, binning="unit", time_axis="", ret_specs=True
168164
)
169165

170-
assert len(hists) == 21
171-
assert len(features) == 21
166+
assert len(hists) == 22
167+
assert len(features) == 22
172168
assert len(bin_specs) == 0
173-
assert len(var_dtype) == 21
169+
assert len(var_dtype) == 22
174170
assert time_axis == ""
175171
assert "date" in hists
176172
h = hists["date"]

tests/test_spark_histogrammar.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def test_get_histograms(spark_co):
8181
["isActive", "age"],
8282
["latitude", "longitude"],
8383
"transaction",
84+
"amount",
8485
],
8586
bin_specs={
8687
"transaction": {"num": 100, "low": -2000, "high": 2000},
@@ -140,6 +141,7 @@ def test_get_histograms_module(spark_co):
140141
"longitude",
141142
["isActive", "age"],
142143
["latitude", "longitude"],
144+
"amount",
143145
],
144146
bin_specs={
145147
"longitude": {"bin_width": 5.0, "bin_offset": 0.0},

0 commit comments

Comments
 (0)