Skip to content

Commit

Permalink
Fix asking for truth value of np array
Browse files Browse the repository at this point in the history
  • Loading branch information
bryant1410 committed Oct 8, 2017
1 parent 648b58f commit d63805c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions krippendorff/krippendorff.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,15 @@ def alpha(reliability_data=None, value_counts=None, value_domain=None, level_of_
if (reliability_data is None) == (value_counts is None):
raise ValueError("Either reliability_data or value_counts must be provided, but not both.")

if reliability_data:
# Don't know if it's a list or numpy array. If it's the latter, the truth value is ambiguous. So, ask for None.
if value_counts is None:
if type(reliability_data) is not np.ndarray:
reliability_data = np.array(reliability_data)

value_domain = value_domain or np.unique(reliability_data[~np.isnan(reliability_data)])

value_counts = _reliability_data_to_value_counts(reliability_data, value_domain)
else: # elif value_counts
else: # elif reliability_data is None
if value_domain:
assert value_counts.shape[1] == len(value_domain), \
"The value domain should be equal to the number of columns of value_counts."
Expand Down

0 comments on commit d63805c

Please sign in to comment.