Skip to content

Commit

Permalink
Organize repo, create tests, add CI support
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacobaldrich11 committed Apr 12, 2024
1 parent 5908cff commit 9373fd9
Show file tree
Hide file tree
Showing 20 changed files with 85 additions and 25 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# PYTHON VERSION: 3.10.10

numpy==1.24.2
pytest==7.4.2
pandas==2.0.0
Expand Down
Empty file added site_slotting_new/__init__.py
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 0 additions & 15 deletions site_slotting_new/data-cleaning.py

This file was deleted.

36 changes: 36 additions & 0 deletions site_slotting_new/data_cleaning.py
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added tests/__init__.py
Empty file.
Binary file added tests/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file not shown.
10 changes: 0 additions & 10 deletions tests/algorithm-test.py

This file was deleted.

18 changes: 18 additions & 0 deletions tests/algorithm_test.py
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.

0 comments on commit 9373fd9

Please sign in to comment.