From c6780dd9e4a380957ca9ae4d0b33729daa17820f Mon Sep 17 00:00:00 2001 From: Roni Kobrosly Date: Mon, 18 May 2020 13:13:11 -0400 Subject: [PATCH] test cleanup --- docs/changelog.rst | 5 +++++ docs/conf.py | 2 +- setup.py | 2 +- tests/conftest.py | 14 ++++++++------ tests/integration/test_gps.py | 1 - tests/integration/test_tmle.py | 1 - tests/test_helpers.py | 2 -- tests/unit/test_gps.py | 5 +---- tests/unit/test_tmle.py | 6 +----- 9 files changed, 17 insertions(+), 21 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index e7f1a08..894879c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,11 @@ Change Log ========== +Version 0.1.3 +------------- +- Simplifying unit and integration tests. + + Version 0.1.2 ------------- diff --git a/docs/conf.py b/docs/conf.py index 3f624bb..ac44085 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,7 +22,7 @@ author = 'Roni Kobrosly' # The full version, including alpha/beta/rc tags -release = '0.1.2' +release = '0.1.3' # -- General configuration --------------------------------------------------- diff --git a/setup.py b/setup.py index c982ce9..cedab46 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="causal-curve", - version="0.1.2", + version="0.1.3", author="Roni Kobrosly", author_email="roni.kobrosly@gmail.com", description="A python library with tools to perform causal inference using \ diff --git a/tests/conftest.py b/tests/conftest.py index 5cca7c3..db53368 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,22 +7,24 @@ @pytest.fixture(scope="module") def dataset_fixture(): + """Returns full_example_dataset""" return full_example_dataset() def full_example_dataset(): + """Example dataset with a treatment, two covariates, and outcome variable""" np.random.seed(500) - n = 500 + n_obs = 500 - treatment = np.random.normal(loc=50.0, scale=10.0, size=n) - x1 = np.random.normal(loc=50.0, scale=10.0, size=n) - x2 = np.random.normal(loc=0, scale=10.0, size=n) - outcome = treatment + x1 + x2 + np.random.normal(loc=50.0, scale=3.0, size=n) + treatment = np.random.normal(loc=50.0, scale=10.0, size=n_obs) + x_1 = np.random.normal(loc=50.0, scale=10.0, size=n_obs) + x_2 = np.random.normal(loc=0, scale=10.0, size=n_obs) + outcome = treatment + x_1 + x_2 + np.random.normal(loc=50.0, scale=3.0, size=n_obs) fixture = pd.DataFrame( - {"treatment": treatment, "x1": x1, "x2": x2, "outcome": outcome} + {"treatment": treatment, "x1": x_1, "x2": x_2, "outcome": outcome} ) fixture.reset_index(drop=True, inplace=True) diff --git a/tests/integration/test_gps.py b/tests/integration/test_gps.py index dd8f4ba..22f266c 100644 --- a/tests/integration/test_gps.py +++ b/tests/integration/test_gps.py @@ -3,7 +3,6 @@ import pandas as pd from causal_curve import GPS -from tests.test_helpers import assert_df_equal def test_full_gps_flow(dataset_fixture): diff --git a/tests/integration/test_tmle.py b/tests/integration/test_tmle.py index b432f24..e461e0a 100644 --- a/tests/integration/test_tmle.py +++ b/tests/integration/test_tmle.py @@ -3,7 +3,6 @@ import pandas as pd from causal_curve import TMLE -from tests.test_helpers import assert_df_equal def test_full_tmle_flow(dataset_fixture): diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 732e7c3..84b7129 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -1,7 +1,5 @@ """Misc helper functions for tests""" - -import pandas as pd from pandas.testing import assert_frame_equal diff --git a/tests/unit/test_gps.py b/tests/unit/test_gps.py index 223b1cd..bf5e67f 100644 --- a/tests/unit/test_gps.py +++ b/tests/unit/test_gps.py @@ -1,14 +1,11 @@ """ Unit tests of the gps.py module """ - -import pandas as pd from pygam import LinearGAM from causal_curve import GPS -from tests.test_helpers import assert_df_equal -def test_GPS_fit(dataset_fixture): +def test_gps_fit(dataset_fixture): """ Tests the fit method GPS tool """ diff --git a/tests/unit/test_tmle.py b/tests/unit/test_tmle.py index ca42de0..31518fc 100644 --- a/tests/unit/test_tmle.py +++ b/tests/unit/test_tmle.py @@ -1,13 +1,9 @@ """ Unit tests of the tmle.py module """ - -import pandas as pd - from causal_curve import TMLE -from tests.test_helpers import assert_df_equal -def test_TMLE_fit(dataset_fixture): +def test_tmle_fit(dataset_fixture): """ Tests the fit method GPS tool """