Skip to content

Commit

Permalink
Add additional unit tests for _check_operations_valid (#93)
Browse files Browse the repository at this point in the history
* fix badge

* cleanup files:

* cleanup files:

* add more tests

* finish up ops tests

* finish up ops tests

* update changelog
  • Loading branch information
gsheni authored Jul 8, 2023
1 parent 96ee9c2 commit 9a86f64
Show file tree
Hide file tree
Showing 18 changed files with 154 additions and 172 deletions.
41 changes: 0 additions & 41 deletions Examples/youtube/meta_youtube.json

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<img src="https://github.com/HDI-Project/Trane/actions/workflows/tests.yaml/badge.svg" alt="Tests" />
</a>
<a href="https://codecov.io/gh/trane-dev/Trane" >
<img src="https://codecov.io/gh/trane-dev/Trane/branch/master/graph/badge.svg?token=HafAlYGH8F"/>
<img src="https://codecov.io/gh/trane-dev/Trane/branch/main/graph/badge.svg?token=HafAlYGH8F"/>
</a>
<a href="https://badge.fury.io/py/Trane" target="_blank">
<img src="https://badge.fury.io/py/Trane.svg?maxAge=2592000" alt="PyPI Version" />
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ What’s new in 0.4.0 (X, 2023)
* Add detailed walkthroughts in Examples directory [#60][#60]
* Add code coverage analysis from Codecov [#77][#77]
* Clean up input and output for operations [#87][#87]
* Add additional unit tests for _check_operations_valid [#93][#93]
* Fixes
* Remove TableMeta class and replace with ColumnSchema [#83][#83] [#85][#85]

Expand All @@ -16,6 +17,7 @@ What’s new in 0.4.0 (X, 2023)
[#83]: <https://github.com/HDI-Project/Trane/pull/83>
[#85]: <https://github.com/HDI-Project/Trane/pull/85>
[#87]: <https://github.com/HDI-Project/Trane/pull/87>
[#93]: <https://github.com/HDI-Project/Trane/pull/93>

What’s new in 0.3.0 (February 24, 2023)
=======================================
Expand Down
55 changes: 0 additions & 55 deletions tests/integration_tests/meta_chicago.json

This file was deleted.

13 changes: 0 additions & 13 deletions tests/integration_tests/meta_covid.json

This file was deleted.

41 changes: 0 additions & 41 deletions tests/integration_tests/meta_youtube.json

This file was deleted.

File renamed without changes.
28 changes: 20 additions & 8 deletions tests/test_prediction_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def make_fake_df():
datetime(2023, 1, 5),
],
"state": ["MA", "NY", "NY", "NJ", "NJ", "CT"],
"amount": [10, 20, 30, 40, 50, 60],
"amount": [10.0, 20.0, 30.0, 40.0, 50.0, 60.0],
}
df = pd.DataFrame(data)
df["date"] = pd.to_datetime(df["date"])
Expand All @@ -31,7 +31,7 @@ def make_fake_df():
@pytest.fixture()
def make_fake_meta():
meta = {
"id": ("Integer", {"index"}),
"id": ("Integer", {"numeric", "index"}),
"date": ("Datetime", {}),
"state": ("Categorical", {"category"}),
"amount": ("Double", {"numeric"}),
Expand Down Expand Up @@ -87,13 +87,9 @@ def min_column(data_slice, column, **kwargs):
return data_slice[column].min()


def test_prediction_problem(make_fake_df, make_fake_meta):
df = make_fake_df
meta = make_fake_meta
for column in df.columns:
assert column in meta
@pytest.fixture()
def make_cutoff_strategy():
entity_col = "id"
time_col = "date"
window_size = "2d"
minimum_data = "2023-01-01"
maximum_data = "2023-01-05"
Expand All @@ -103,6 +99,18 @@ def test_prediction_problem(make_fake_df, make_fake_meta):
minimum_data=minimum_data,
maximum_data=maximum_data,
)
return cutoff_strategy


def test_prediction_problem(make_fake_df, make_fake_meta, make_cutoff_strategy):
entity_col = "id"
time_col = "date"
df = make_fake_df
meta = make_fake_meta
for column in df.columns:
assert column in meta
cutoff_strategy = make_cutoff_strategy

problem_generator = trane.PredictionProblemGenerator(
df=df,
table_meta=meta,
Expand All @@ -112,6 +120,10 @@ def test_prediction_problem(make_fake_df, make_fake_meta):
)

problems = problem_generator.generate(df, generate_thresholds=True)
verify_problems(problems, df, cutoff_strategy)


def verify_problems(problems, df, cutoff_strategy):
problems_verified = 0
# bad integration testing
# not ideal but okay to test for now
Expand Down
Loading

0 comments on commit 9a86f64

Please sign in to comment.