Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Ethan Mertz
/
CS-123-Final
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
ec6fb55e
authored
Jun 03, 2018
by
Ethan Mertz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed top variables?
parent
6bfedaf8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
Python/topvariables.py
Python/topvariables.py
View file @
ec6fb55e
...
...
@@ -6,6 +6,8 @@ import math
CAPACITY
=
500
VARIABLE_REGEX
=
(
"[
\
s]*([
\
w, ]+)[
\
s]*="
)
class
TopVariables
(
MRJob
):
def
mapper
(
self
,
_
,
line
):
...
...
@@ -43,15 +45,15 @@ class TopVariables(MRJob):
yield
variable
,
(
1
,
simscore
)
yield
comp
,
(
1
,
simscore
)
#Track the total by yielding with None.
yield
None
,
(
len
(
f1vars
)
+
len
(
f2vars
)
)
yield
None
,
len
(
f1vars
)
+
len
(
f2vars
)
else
:
#When the subset is odd, only yield once.
yield
None
,
len
(
f1vars
)
def
combiner
(
self
,
name
,
scores
):
if
not
name
:
total
=
sum
(
scores
)
if
type
(
name
)
!=
str
:
total
=
sum
(
list
(
scores
)
)
yield
None
,
total
else
:
count
=
0
...
...
@@ -69,7 +71,7 @@ class TopVariables(MRJob):
heapq
.
heapify
(
self
.
h
)
def
reducer
(
self
,
name
,
scores
):
if
not
name
:
if
type
(
name
)
!=
str
:
self
.
total
=
sum
(
scores
)
else
:
count
=
0
...
...
@@ -89,7 +91,7 @@ class TopVariables(MRJob):
for
i
in
range
(
len
(
self
.
h
)):
item
=
heapq
.
heappop
(
self
.
h
)
#Yield the mean scores.
yield
item
[
1
],
-
item
[
0
]
/
(
self
.
total
-
1
)
yield
item
[
1
],
-
item
[
0
]
/
self
.
total
if
__name__
==
'__main__'
:
TopVariables
.
run
()
\ No newline at end of file
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