Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Krishnan Sanjay
/
cmsc13600-public
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8cadfb5b
authored
Apr 29, 2021
by
Krishnan Sanjay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete auto_grader.py
parent
db5be436
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
112 deletions
hw4/auto_grader.py
hw4/auto_grader.py
deleted
100644 → 0
View file @
db5be436
import
random
import
string
from
bloom
import
*
def
generate_random_string
(
seed
=
True
):
chars
=
string
.
ascii_uppercase
+
string
.
digits
size
=
10
return
''
.
join
(
random
.
choice
(
chars
)
for
x
in
range
(
size
))
def
test_hash_generation
():
b
=
Bloom
(
5
,
10
)
try
:
assert
(
len
(
b
.
hashes
)
==
10
)
except
:
print
(
'[#1] Failure the number of generated hashes is wrong'
)
try
:
for
h
in
b
.
hashes
:
h
(
generate_random_string
())
except
:
print
(
'[#2] The hashes are not properly represented as a lambda'
)
s
=
generate_random_string
()
try
:
for
h
in
b
.
hashes
:
assert
(
h
(
s
)
==
h
(
s
))
except
:
print
(
'[#3] Hashes are not deterministic'
)
try
:
b
=
Bloom
(
100
,
10
)
b1h
=
b
.
hashes
[
0
](
s
)
b
=
Bloom
(
100
,
10
)
b2h
=
b
.
hashes
[
0
](
s
)
assert
(
b1h
==
b2h
)
except
:
print
(
'[#4] Seeds are not properly set'
)
try
:
b
=
Bloom
(
100
,
10
)
for
h
in
b
.
hashes
:
for
i
in
range
(
10
):
assert
(
h
(
generate_random_string
())
<
100
)
except
:
print
(
'[#5] Hash exceeds range'
)
try
:
b
=
Bloom
(
1000
,
2
)
s
=
generate_random_string
()
bh1
=
b
.
hashes
[
0
](
s
)
bh2
=
b
.
hashes
[
1
](
s
)
assert
(
bh1
!=
bh2
)
except
:
print
(
'[#6] Hashes generated are not independent'
)
def
test_put
():
b
=
Bloom
(
100
,
10
,
seed
=
0
)
b
.
put
(
'the'
)
b
.
put
(
'university'
)
b
.
put
(
'of'
)
b
.
put
(
'chicago'
)
try
:
assert
(
sum
(
b
.
array
)
==
30
)
except
:
print
(
'[#7] Unexpected Put() Result'
)
def
test_put_get
():
b
=
Bloom
(
100
,
5
,
seed
=
0
)
b
.
put
(
'the'
)
b
.
put
(
'quick'
)
b
.
put
(
'brown'
)
b
.
put
(
'fox'
)
b
.
put
(
'jumped'
)
b
.
put
(
'over'
)
b
.
put
(
'the'
)
b
.
put
(
'lazy'
)
b
.
put
(
'dog'
)
results
=
[
b
.
contains
(
'the'
),
\
b
.
contains
(
'cow'
),
\
b
.
contains
(
'jumped'
),
\
b
.
contains
(
'over'
),
\
b
.
contains
(
'the'
),
\
b
.
contains
(
'moon'
)]
try
:
assert
(
results
==
[
True
,
False
,
True
,
True
,
True
,
False
])
except
:
print
(
'[#8] Unexpected contains result'
)
test_hash_generation
()
test_put
()
test_put_get
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment