Skip to content

Commit 034e023

Browse files
committed
Added starter files
1 parent e0a88e3 commit 034e023

10 files changed

+1224
-2
lines changed

PandasWordbank.ipynb

Lines changed: 1008 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# hw2
2-
1+
This repo has starter code for a CSE 163 assignment run in GitHub classroom.

cse163_utils.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import math
2+
3+
import pandas as pd
4+
5+
6+
def parse(file_name):
7+
"""
8+
Reads the CSV with the given file_name and returns it as a list of
9+
dictionaries. The list will have a dictionary for each row, and each
10+
dictionary will have a key for each column.
11+
"""
12+
df = pd.read_csv(file_name)
13+
return df.to_dict('records')
14+
15+
16+
def check_approx_equals(expected, received):
17+
"""
18+
Checks received against expected, and returns whether or
19+
not they match (True if they do, False otherwise).
20+
If the argument is a float, will do an approximate check.
21+
If the arugment is a data structure will do an approximate check
22+
on all of its contents.
23+
"""
24+
try:
25+
if type(expected) == dict:
26+
# first check that keys match, then check that the
27+
# values approximately match
28+
return expected.keys() == received.keys() and \
29+
all([check_approx_equals(expected[k], received[k])
30+
for k in expected.keys()])
31+
elif type(expected) == list or type(expected) == set:
32+
# Checks both lists/sets contain the same values
33+
return len(expected) == len(received) and \
34+
all([check_approx_equals(v1, v2)
35+
for v1, v2 in zip(expected, received)])
36+
elif type(expected) == float:
37+
return math.isclose(expected, received, abs_tol=0.001)
38+
else:
39+
return expected == received
40+
except Exception as e:
41+
print(f'EXCEPTION: Raised when checking check_approx_equals {e}')
42+
return False
43+
44+
45+
def assert_equals(expected, received):
46+
"""
47+
Checks received against expected, throws an AssertionError
48+
if they don't match. If the argument is a float, will do an approximate
49+
check. If the arugment is a data structure will do an approximate check
50+
on all of its contents.
51+
"""
52+
assert check_approx_equals(expected, received), \
53+
f'Failed: Expected {expected}, but received {received}'

hw2_manual.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Your code here!

hw2_pandas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Your code here!

hw2_test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import pandas as pd
2+
3+
from cse163_utils import assert_equals, parse
4+
5+
import hw2_manual
6+
import hw2_pandas
7+
8+
9+
# Your tests here!
10+
11+
12+
def main():
13+
# Call your test functions here!
14+
15+
16+
if __name__ == '__main__':
17+
main()

pets.csv

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name,age,species
2+
Fido,4,dog
3+
Meowrty,6,cat
4+
Chester,1,dog
5+
Phil,1,axolotl

pokemon_box.csv

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
id,name,level,personality,type,weakness,atk,def,hp,stage
2+
53,Persian,40,mild,normal,fighting,104,116,147,2
3+
126,Magmar,44,docile,fire,water,96,83,153,1
4+
99,Kingler,33,adamant,water,electric,110,169,29,2
5+
57,Primeape,9,lonely,fighting,flying,20,66,43,2
6+
3,Venusaur,44,sassy,grass,fire,136,195,92,3
7+
23,Ekans,81,hasty,poison,psychic,30,108,20,1
8+
11,Metapod,4,naive,grass,fire,30,114,22,2
9+
126,Magmar,96,modest,fire,water,62,114,155,1
10+
137,Porygon,96,relaxed,normal,fighting,68,50,127,1
11+
69,Bellsprout,84,lonely,grass,fire,149,32,45,1
12+
10,Caterpie,3,serious,bug,flying,7,10,15,1
13+
12,Butterfree,12,hasty,bug,flying,20,25,35,3
14+
35,Clefairy,18,impish,fairy,poison,33,25,50,1
15+
23,Ekans,15,Jolly,poison,psychic,40,15,35,1
16+
59,Arcanine,35,gentle,fire,water,45,60,80,2
17+
80,Slowbro,54,modest,psychic,dark,72,192,171,2
18+
121,Starmie,76,hardy,water,electric,34,194,131,2
19+
111,Rhyhorn,31,naughty,rock,water,40,116,175,1
20+
136,Flareon,75,bold,fire,water,67,143,103,2
21+
83,Farfetch'd,49,jolly,flying,electric,50,34,129,1
22+
94,Gengar,30,mild,ghost,dark,138,126,90,3
23+
51,Dugtrio,82,gentle,ground,water,152,161,168,2
24+
63,Abra,84,careful,psychic,dark,152,156,44,1
25+
38,Ninetales,5,brave,fire,water,59,179,173,2
26+
119,Seaking,63,jolly,water,electric,65,107,149,2
27+
54,Psyduck,89,jolly,water,electric,194,187,125,1
28+
139,Omastar,51,naive,water,electric,195,19,70,2
29+
34,Nidoking,18,timid,poison,psychic,155,143,63,3
30+
72,Tentacool,89,impish,water,electric,19,76,195,1
31+
102,Exeggcute,88,rash,grass,fire,44,124,139,1
32+
95,Onix,46,mild,rock,water,79,33,191,1
33+
134,Vaporeon,65,bashful,grass,fire,103,125,129,3
34+
21,Spearow,64,rash,flying,electric,189,23,47,1
35+
34,Nidoking,95,naughty,poison,psychic,160,102,190,3
36+
60,Poliwag,14,gentle,water,electric,34,124,25,1
37+
114,Tangela,52,quiet,grass,fire,151,166,84,1
38+
53,Persian,42,quiet,normal,fighting,169,152,27,2
39+
54,Psyduck,54,naughty,water,electric,84,19,183,1
40+
78,Rapidash,60,brave,fire,water,161,196,62,2
41+
130,Gyarados,39,adamant,water,electric,35,181,188,2
42+
28,Sandslash,12,quiet,ground,water,103,50,128,2
43+
87,Dewgong,37,impish,water,electric,187,184,190,2
44+
71,Victreebel,100,gentle,grass,fire,185,190,89,3
45+
34,Nidoking,88,serious,poison,psychic,147,192,141,3
46+
2,Ivysaur,80,docile,grass,fire,42,131,165,2
47+
30,Nidorina,10,quiet,poison,psychic,185,22,137,2
48+
42,Golbat,92,serious,poison,psychic,126,195,31,2
49+
110,Weezing,4,adamant,poison,psychic,54,52,81,2
50+
108,Lickitung,68,calm,normal,fighting,124,169,125,1
51+
134,Vaporeon,65,bold,grass,fire,34,67,60,3
52+
60,Poliwag,28,quiet,water,electric,180,156,87,1
53+
22,Fearow,79,hardy,flying,electric,166,23,181,2
54+
52,Meowth,27,naughty,normal,fighting,170,169,143,1
55+
16,Pidgey,53,serious,flying,electric,48,96,82,1
56+
118,Goldeen,10,relaxed,water,electric,20,123,44,1
57+
14,Kakuna,92,impish,grass,fire,72,150,48,2
58+
5,Charmeleon,27,rash,fire,water,72,26,51,2
59+
140,Kabuto,88,bashful,rock,grass,125,167,153,1
60+
84,Doduo,64,serious,flying,electric,168,129,155,1
61+
73,Tentacruel,36,lonely,water,electric,186,51,148,2
62+
51,Dugtrio,57,hardy,ground,water,139,155,162,2
63+
133,Eevee,97,lax,normal,fighting,127,154,184,1
64+
79,Slowpoke,38,bashful,psychic,dark,161,61,154,1
65+
132,Ditto,10,brave,normal,fighting,160,167,127,1
66+
114,Tangela,5,bold,grass,fire,172,59,175,1
67+
49,Venomoth,99,careful,bug,fire,48,188,53,2
68+
78,Rapidash,73,naughty,fire,water,137,46,93,2
69+
69,Bellsprout,73,quiet,grass,fire,97,34,129,1
70+
8,Wartortle,29,hardy,water,grass,98,190,33,2
71+
93,Haunter,45,adamant,ghost,dark,72,143,170,2
72+
129,Magikarp,41,hasty,water,electric,142,171,46,1
73+
11,Metapod,80,quiet,grass,fire,66,116,28,2
74+
95,Onix,85,docile,rock,water,88,158,174,1
75+
51,Dugtrio,43,impish,ground,water,47,72,196,2
76+
42,Golbat,34,brave,poison,psychic,166,134,152,2
77+
35,Clefairy,67,sassy,fairy,poison,92,123,137,1
78+
121,Starmie,67,sassy,water,electric,174,56,113,2
79+
113,Chansey,78,brave,normal,fighting,37,99,167,1
80+
92,Gastly,77,rash,ghost,dark,54,139,29,1
81+
75,Graveler,22,impish,rock,water,80,146,200,2
82+
73,Tentacruel,87,serious,water,electric,60,170,133,2
83+
12,Butterfree,8,impish,flying,fire,44,114,135,3
84+
6,Charizard,55,timid,fire,water,110,66,71,3
85+
125,Electabuzz,37,hardy,electric,ground,64,62,158,1
86+
61,Poliwhirl,26,hardy,water,electric,85,43,197,2
87+
57,Primeape,51,adamant,fighting,flying,200,106,123,2
88+
146,Moltres,62,naughty,fire,rock,65,155,49,1
89+
59,Arcanine,59,bashful,fire,water,75,54,93,2
90+
86,Seel,17,bashful,water,electric,27,91,126,1
91+
102,Exeggcute,98,calm,grass,fire,51,177,103,1
92+
39,Jigglypuff,95,naughty,fairy,poison,104,79,182,1
93+
102,Exeggcute,9,adamant,grass,fire,123,165,50,1
94+
58,Growlithe,28,impish,fire,water,183,172,144,1
95+
41,Zubat,38,naive,poison,psychic,174,145,125,1
96+
74,Geodude,31,impish,rock,water,117,138,100,1
97+
97,Hypno,38,naive,psychic,dark,126,53,55,2
98+
106,Hitmonlee,29,careful,fighting,flying,79,126,34,1
99+
59,Arcanine,5,hardy,fire,water,159,173,74,2
100+
131,Lapras,72,lax,water,electric,107,113,29,1
101+
139,Omastar,31,relaxed,water,electric,138,26,21,2
102+
51,Dugtrio,10,bashful,ground,water,142,176,120,2
103+
19,Rattata,25,serious,normal,fighting,47,84,183,1
104+
3,Venusaur,67,naive,grass,fire,145,85,35,3
105+
29,Nidoran(F),46,calm,poison,psychic,56,93,126,1
106+
138,Omanyte,37,careful,water,electric,141,200,96,1
107+
124,Jynx,21,modest,psychic,dark,111,93,185,1
108+
53,Persian,87,jolly,normal,fighting,74,116,172,2
109+
59,Arcanine,69,jolly,fire,water,35,28,20,2
110+
110,Weezing,30,bold,poison,psychic,168,29,151,2
111+
11,Metapod,17,mild,grass,fire,191,127,147,2
112+
76,Golem,78,hardy,rock,water,65,145,137,3
113+
116,Horsea,69,mild,water,electric,49,36,45,1
114+
6,Charizard,89,lax,fire,water,165,100,108,3
115+
65,Alakazam,33,impish,psychic,dark,67,39,169,3
116+
120,Staryu,73,hardy,water,electric,30,91,158,1

pokemon_test.csv

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
id,name,level,personality,type,weakness,atk,def,hp,stage
2+
59,Arcanine,35,impish,fire,water,50,55,90,2
3+
59,Arcanine,35,gentle,fire,water,45,60,80,2
4+
121,Starmie,67,sassy,water,electric,174,56,113,2
5+
131,Lapras,72,lax,water,electric,107,113,29,1

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[tool.poetry]
2+
name = "cse163-hw2"
3+
version = "0.1.0"
4+
description = "Test starter code for CSE 163 - HW2"
5+
authors = ["Hunter Schafer <[email protected]>"]
6+
7+
[tool.poetry.dependencies]
8+
python = "^3.8"
9+
flake8 = "3.8.4"
10+
pandas = "1.2.3"
11+
12+
[tool.poetry.dev-dependencies]
13+
pytest = "^5.2"
14+
15+
[build-system]
16+
requires = ["poetry-core>=1.0.0"]
17+
build-backend = "poetry.core.masonry.api"

0 commit comments

Comments
 (0)