Skip to content

Commit

Permalink
Removing Python 3.x issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
cfournie committed Jul 4, 2013
1 parent e733ea6 commit 655566f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion segeval/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@


object_origins = {}
for module, items in all_by_module.iteritems():
for module, items in all_by_module.items():
for item in items:
object_origins[item] = module

Expand Down
7 changes: 6 additions & 1 deletion segeval/agreement/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ def __actual_agreement_linear__(dataset, **kwargs):
all_pbs = list()
coders_boundaries = dict()
coders = dataset.values()[0].keys()
# FOr each permutation of coders
# Obtain the list of coders
coders = set()
for value in dataset.values():
coders = coders.union(value.keys())
coders = list(coders)
# For each permutation of coders
for m in range(0, len(coders) - 1):
for n in range(m + 1, len(coders)):
for item in dataset.keys():
Expand Down
4 changes: 1 addition & 3 deletions segeval/agreement/kappa.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ def __fleiss_kappa_linear__(dataset, **kwargs):
if len(coder_segs.keys()) < 2]) > 0:
raise Exception('Less than 2 coders specified.')
# Check that there are an identical number of items
num_items = len(dataset.values()[0].keys())
if len([True for coder_segs in dataset.values()
if len(coder_segs.values()) is not num_items]) > 0:
if len(set([len(coder_segs.values()) for coder_segs in dataset.values()])) != 1:
raise Exception('Unequal number of items contained.')
# Initialize totals
all_numerators, all_denominators, _, coders_boundaries = \
Expand Down
8 changes: 3 additions & 5 deletions segeval/agreement/pi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from . import __fnc_metric__, __actual_agreement_linear__


def __fleiss_pi_linear__(items_masses, **kwargs):
def __fleiss_pi_linear__(dataset, **kwargs):
'''
Calculates Fleiss' :math:`\pi` (or multi-:math:`\pi`), originally proposed in
[Fleiss1971]_, and is equivalent to Siegel and Castellan's :math:`K`
Expand All @@ -20,13 +20,11 @@ def __fleiss_pi_linear__(items_masses, **kwargs):
# Arguments
return_parts = kwargs['return_parts']
# Check that there are an equal number of items for each coder
num_items = len(items_masses.values()[0].keys())
if len([True for coder_segs in items_masses.values()
if len(coder_segs.values()) is not num_items]) > 0:
if len(set([len(coder_segs.values()) for coder_segs in dataset.values()])) != 1:
raise Exception('Unequal number of items contained.')
# Initialize totals
all_numerators, all_denominators, _, coders_boundaries = \
__actual_agreement_linear__(items_masses, **metric_kwargs)
__actual_agreement_linear__(dataset, **metric_kwargs)
# Calculate Aa
A_a = Decimal(sum(all_numerators)) / sum(all_denominators)
# Calculate Ae
Expand Down

0 comments on commit 655566f

Please sign in to comment.