diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..b28022a --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,29 @@ +name: Run Pytest on Push + +on: + push: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 # Checks out your repository code + - name: Set up Python + uses: actions/setup-python@v2 + + # Specify your Python version here + with: + python-version: "3.10.10" + + # Install all modules used in code + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + # Run your pytest tests + - name: Run Pytest + run: | + pytest diff --git a/requirements.txt b/requirements.txt index 8eae1be..9d13288 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ +# PYTHON VERSION: 3.10.10 + numpy==1.24.2 pytest==7.4.2 pandas==2.0.0 diff --git a/site_slotting_new/__init__.py b/site_slotting_new/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/site_slotting_new/__pycache__/__init__.cpython-311.pyc b/site_slotting_new/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..a1b4550 Binary files /dev/null and b/site_slotting_new/__pycache__/__init__.cpython-311.pyc differ diff --git a/site_slotting_new/__pycache__/algorithm.cpython-310.pyc b/site_slotting_new/__pycache__/algorithm.cpython-310.pyc new file mode 100644 index 0000000..4cdb63a Binary files /dev/null and b/site_slotting_new/__pycache__/algorithm.cpython-310.pyc differ diff --git a/site_slotting_new/__pycache__/algorithm.cpython-311.pyc b/site_slotting_new/__pycache__/algorithm.cpython-311.pyc new file mode 100644 index 0000000..0f6694a Binary files /dev/null and b/site_slotting_new/__pycache__/algorithm.cpython-311.pyc differ diff --git a/site_slotting_new/__pycache__/data_cleaning.cpython-310.pyc b/site_slotting_new/__pycache__/data_cleaning.cpython-310.pyc new file mode 100644 index 0000000..1892920 Binary files /dev/null and b/site_slotting_new/__pycache__/data_cleaning.cpython-310.pyc differ diff --git a/site_slotting_new/__pycache__/data_cleaning.cpython-311.pyc b/site_slotting_new/__pycache__/data_cleaning.cpython-311.pyc new file mode 100644 index 0000000..13dcc46 Binary files /dev/null and b/site_slotting_new/__pycache__/data_cleaning.cpython-311.pyc differ diff --git a/site_slotting_new/data-cleaning.py b/site_slotting_new/data-cleaning.py deleted file mode 100644 index 98358cd..0000000 --- a/site_slotting_new/data-cleaning.py +++ /dev/null @@ -1,15 +0,0 @@ -import pandas as pd - - -def preprocess_df(file_path: str) -> pd.DataFrame: - df = pd.read_csv(file_path) - relevant_features = ['Email Address','Name','Castlemont', 'Montera', 'DeJean', 'DCA', 'Rudsdale', - 'Longfellow', 'SquashDrive', 'John Henry', 'Life Academy', 'CC Member', 'Exec', - 'Spanish Speaker', 'Can Drive', 'Has Car','Gender', 'Site Leader'] - # Select columns that contain a feature - relevant_columns = [col for col in df.columns if any(feature in col for feature in relevant_features)] - - # Create a new DataFrame with only the relevant columns - pre_processed_df = df[relevant_columns] - - return pre_processed_df diff --git a/site_slotting_new/data_cleaning.py b/site_slotting_new/data_cleaning.py new file mode 100644 index 0000000..ca309d2 --- /dev/null +++ b/site_slotting_new/data_cleaning.py @@ -0,0 +1,36 @@ +import pandas as pd + + +def preprocess_df(file_path: str) -> pd.DataFrame: + df = pd.read_csv(file_path) + relevant_features = [ + "Email Address", + "Name", + "Castlemont", + "Montera", + "DeJean", + "DCA", + "Rudsdale", + "Longfellow", + "SquashDrive", + "John Henry", + "Life Academy", + "CC Member", + "Exec", + "Spanish Speaker", + "Can Drive", + "Has Car", + "Gender", + "Site Leader", + ] + # Select columns that contain a feature + relevant_columns = [ + col + for col in df.columns + if any(feature in col for feature in relevant_features) + ] + + # Create a new DataFrame with only the relevant columns + pre_processed_df = df[relevant_columns] + + return pre_processed_df diff --git a/site_slotting/__pycache__/algorithm.cpython-310.pyc b/site_slotting_old/__pycache__/algorithm.cpython-310.pyc similarity index 100% rename from site_slotting/__pycache__/algorithm.cpython-310.pyc rename to site_slotting_old/__pycache__/algorithm.cpython-310.pyc diff --git a/site_slotting/algorithm.py b/site_slotting_old/algorithm.py similarity index 100% rename from site_slotting/algorithm.py rename to site_slotting_old/algorithm.py diff --git a/site_slotting/cleaning.ipynb b/site_slotting_old/cleaning.ipynb similarity index 100% rename from site_slotting/cleaning.ipynb rename to site_slotting_old/cleaning.ipynb diff --git a/site_slotting/usage.ipynb b/site_slotting_old/usage.ipynb similarity index 100% rename from site_slotting/usage.ipynb rename to site_slotting_old/usage.ipynb diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/__pycache__/__init__.cpython-311.pyc b/tests/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..423c1af Binary files /dev/null and b/tests/__pycache__/__init__.cpython-311.pyc differ diff --git a/tests/__pycache__/algorithm_test.cpython-311-pytest-7.4.2.pyc b/tests/__pycache__/algorithm_test.cpython-311-pytest-7.4.2.pyc new file mode 100644 index 0000000..14396e0 Binary files /dev/null and b/tests/__pycache__/algorithm_test.cpython-311-pytest-7.4.2.pyc differ diff --git a/tests/algorithm-test.py b/tests/algorithm-test.py deleted file mode 100644 index b5f546e..0000000 --- a/tests/algorithm-test.py +++ /dev/null @@ -1,10 +0,0 @@ -import pytest -from site_slotting_new.algorithm import randomized_matching - - -def test1(): - pass - - -def test2(): - pass diff --git a/tests/algorithm_test.py b/tests/algorithm_test.py new file mode 100644 index 0000000..2a0c463 --- /dev/null +++ b/tests/algorithm_test.py @@ -0,0 +1,18 @@ +import pytest +import pandas as pd + +from site_slotting_new import algorithm +from site_slotting_new import data_cleaning + + +def test_preprocess_df1(): + file = "data/anonymized_spring24_sites_data.csv" + cleaned_data = data_cleaning.preprocess_df(file) + print(cleaned_data.columns) + assert cleaned_data.shape[1] <= 18 + + +def test_preprocess_df2(): + file = "data/anonymized_spring24_sites_data.csv" + cleaned_data = data_cleaning.preprocess_df(file) + assert cleaned_data.shape[1] == 18 diff --git a/tests/algorithm-test2.py b/tests/algorithm_test2.py similarity index 100% rename from tests/algorithm-test2.py rename to tests/algorithm_test2.py