From 9373fd9fc72bb260c5a1652526c18be0bd118be3 Mon Sep 17 00:00:00 2001 From: Jacob Aldrich Date: Fri, 12 Apr 2024 15:27:22 -0700 Subject: [PATCH] Organize repo, create tests, add CI support --- .github/workflows/pytest.yml | 29 ++++++++++++++ requirements.txt | 2 + site_slotting_new/__init__.py | 0 .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 188 bytes .../__pycache__/algorithm.cpython-310.pyc | Bin 0 -> 426 bytes .../__pycache__/algorithm.cpython-311.pyc | Bin 0 -> 491 bytes .../__pycache__/data_cleaning.cpython-310.pyc | Bin 0 -> 1000 bytes .../__pycache__/data_cleaning.cpython-311.pyc | Bin 0 -> 1389 bytes site_slotting_new/data-cleaning.py | 15 -------- site_slotting_new/data_cleaning.py | 36 ++++++++++++++++++ .../__pycache__/algorithm.cpython-310.pyc | Bin .../algorithm.py | 0 .../cleaning.ipynb | 0 .../usage.ipynb | 0 tests/__init__.py | 0 tests/__pycache__/__init__.cpython-311.pyc | Bin 0 -> 176 bytes ...lgorithm_test.cpython-311-pytest-7.4.2.pyc | Bin 0 -> 2257 bytes tests/algorithm-test.py | 10 ----- tests/algorithm_test.py | 18 +++++++++ ...{algorithm-test2.py => algorithm_test2.py} | 0 20 files changed, 85 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/pytest.yml create mode 100644 site_slotting_new/__init__.py create mode 100644 site_slotting_new/__pycache__/__init__.cpython-311.pyc create mode 100644 site_slotting_new/__pycache__/algorithm.cpython-310.pyc create mode 100644 site_slotting_new/__pycache__/algorithm.cpython-311.pyc create mode 100644 site_slotting_new/__pycache__/data_cleaning.cpython-310.pyc create mode 100644 site_slotting_new/__pycache__/data_cleaning.cpython-311.pyc delete mode 100644 site_slotting_new/data-cleaning.py create mode 100644 site_slotting_new/data_cleaning.py rename {site_slotting => site_slotting_old}/__pycache__/algorithm.cpython-310.pyc (100%) rename {site_slotting => site_slotting_old}/algorithm.py (100%) rename {site_slotting => site_slotting_old}/cleaning.ipynb (100%) rename {site_slotting => site_slotting_old}/usage.ipynb (100%) create mode 100644 tests/__init__.py create mode 100644 tests/__pycache__/__init__.cpython-311.pyc create mode 100644 tests/__pycache__/algorithm_test.cpython-311-pytest-7.4.2.pyc delete mode 100644 tests/algorithm-test.py create mode 100644 tests/algorithm_test.py rename tests/{algorithm-test2.py => algorithm_test2.py} (100%) 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 0000000000000000000000000000000000000000..a1b4550d0abeb3c321c4ada080cc8b6294352578 GIT binary patch literal 188 zcmZ3^%ge<81ZOu$rh(|kAOZ#$p^VRLK*n^26oz01O-8?!3`I;p{%4TnFMs{e;?$yI z{j9{~{G`O3l%mY!41JgU;u zY+k&glU15NCn_zqpcS^fk)q!tyBd(ktdt+k|7nQqL zBDB#Qht9>=+U2C`Z&h3KAXK+>zKu$!QNdE#tmG`gd7R zCZ7`gUi3>+&L$7qd9zEN9fA^JUdUp=xhlwH0GZpdA67E4!!&NP{0*G4%G2J#*qJl> Ntw2d7D|wk7WS`B?RH^^~ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..0f6694a1a604093135186fdc3e1db87b6dbe9435 GIT binary patch literal 491 zcmah_Jx;?g6n@ShDODvzZ@|`tTmT^kQwQ$A5m0ZyF*-(B znYu;lRu-O3Qv?gv^Y=bK`+NTEx6$Yra17r+Imi5=7yYpIWP66>6&Ns*K}1ZpBAZz+ z5IM|7bQzh!#Mx*;81H2!5kwp3)8hVI0>dA zu5(^gD!2;80}WJK@wv)GRi(w^_iA47$AD%FA=4_!&&#KFENQ_+o<4In&uJAWsF6P2 zWiCBJvV_L*ms6=-{pVLYc*ywu2Cb30N$aXuNG^xS2fAoLZ%@3|E71d0tyQwtE$SR? zSw(4F7{Q-jJO3gVtj_qQJi!L~+tf8eXA?pi7_a+i;B?(b=MggK-~j%C{nRuw&-?-a C&un=B literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..189292055ebbc39fd8a955b1631fbb32fa31b00b GIT binary patch literal 1000 zcmah{&2G~`5Z+z8iIWnw{HQ87bEy;|8bq&EMU)h(s?C7_2TRD>ddG>2y>@qI5C^1g`QYxMl+h3Z+5cPj!tacbpT_z3+2}k+ z(Jm@M1dWMD1p_85podmy3tKFl*`6(Em()wYFpG4GN*Kl9XFTs0B?b9F$$*;3{25Sd zF8Uc7Ir%~-}4>%#8v1iWgC>pX@emAO~mM-7U5r8evWm!8#bH9hCmKxn~Z%-u_6FN8QwkG;k2 z(SYlITSY?{S9jCCbaz0i(fH0@6oT6fxPW9duC!Y2J|qXAJbU{Dg7H!}<1*5Hx0?Zf z4+=B5bgy8_J6yXhuDsGqkOE_i-6#il4-iY;;>7S%Lb;Ek*HHDyguGk2KyGGSATMXm zIW=5qrXW*kfLruMxV{;u0gv?- z8j;R}G|AAsuB_uXxg6E0GJIW9@2-LvhFs?Ud=RZ1j40EhsQ!hRwKNQ^k@2JdHmq9( z%S7QQ+?5~bVNphI28q;lTN#joiO^fVX*~~m%LwexM*)Gu%;;3Ln-A4)bv6uW^RX&* z=mXoaY^KZ!)E9~po|WKQEumXjI#)%djeNdPc;vI3D`c~+D{D5dvzeq~5W|)^s2RZy HS+)KEXhaFJ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..13dcc46d2a0a32c01bb78d329d25fe357e7cb572 GIT binary patch literal 1389 zcmah}&2Jk;6rb5$f5lB&8Upz!WC4kiR>VjgkWdsi*oCU3KGYP63S>=p-r5fP#mw4i zEC=}zsY#UsNL1;uLZ}G!z=40nm2#*?suYP!xh+Z$QBJ(Ioev`+M!UaxZ{M4F@Aux! z{yI83LU26zW6J(WC*;pqIU2@5*nba&9l{Bx4!KRa1{&9auAqN^*akN?jN1mMWipre zEB;tg8N2R4C17DqB?W{H;aPOxA5Zb(_}%vq?io8IJY`)umfPep%1@5we8MuYo7lT4$E)HkeBm zscTG{1twJTGw?XtvgLXR<}%=3VyKo$Bsh-m{xZS?dXMgqDru8%X7AI}Ro$dmF|v`~ z(*9ki;Tr$`#uoii+cvRMbSO^TuMgumW-rd?gyONlIO%oTrdwK*d`WgFCEFQJ;6Y)vcpKB~9Db3zB|*sC3bXt>%;BPL)pAAOYPjHqGPhLnn=B`h zb45CS7}mY&uvYP4HOE=VDwc!&LHm5Lc9>bHf(Lg4vDmsC2nd94VSg*!o?mc$i#c); zg}Mwa-wjYaa()w&k{1yUUXT~0L%L&md>&ogTz&Y?=J$Q=H14A-a#T9=*5-5(mtRaE zs8<9y&}3d%8IYEJ!dE)tHMAd&oJ4QE^}h+u;1XFvI5_B#h!~T}6WBX*_IY;fbW+{- z7g2pWmfuCp=6AFCD1}R&rL&Pfv{X#umT_|euF?WeRK=1_mBQ{cTu;s=MBF2#aa)}` zrZX_AbC`5xP*&hrSTP+ZnLsdcT8)o6@NPIsp-?Y@2)wY}_2*O=)O zOsFK@FV3X6fMJy`L!mN7JTadNyzRZD#Cf#zy!-7*FStH$IIt+*MMM1Gk$Hqjr<6V; b 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 0000000000000000000000000000000000000000..423c1af602d7d1b023877bedad5089640d08933d GIT binary patch literal 176 zcmZ3^%ge<81WPtcrh(|kAOZ#$p^VRLK*n^26oz01O-8?!3`I;p{%4TnFK7MG;?$yI z{j9{~{G`O3l%mY!41JgU&ryk0@&FAkgB{FKt1RJ$TppqU_Bi}``X2WCb_#t#fIqKFwN1_1eBE13WQ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..14396e0a8488b74d20850e025cc53bef66892b86 GIT binary patch literal 2257 zcmdT_&2QsG6rZu3?`{<+z#6KFsF zx-q(>g#3*{+O#X?@=IWTAU3h7M}}1Ony*_LCB88%(Zo_7mX)P4tU|AOHNQTrE1M2{ zW7q)R_>K(M>=MwXO}`-B@;Oei-=(s~yayq7;{zXrrp;nzTAsrKH+W!OrJ=eCP#wNY z53+@v=!C?;rR^}|$K)~aPcnHz<5KEH$e12t6xE7;6m3Rov$c(sB@@loC;C_$>tCy= z6Ju-$FK%QGb)=+1#}b`g@^uk7&Wz24acgeenxzz&?EO8*|FOy;@jO$e%weUN zd1k@$8W{V`@Fd7H&Ux_?N+he1Vh>K^|3eBufE4=x$yOqOvR@%Uc83YcA;-TVKz>Aq zO3xv{YOnu_08Lzxq{aD28UF$Zz!Bg$M&Nj`@OJMOZuf3>yE*<>I3~ec=vq~GnZJSx zL