Skip to content

Commit

Permalink
refactor if check to pass ordereddict first
Browse files Browse the repository at this point in the history
  • Loading branch information
alistairewj committed Nov 19, 2019
1 parent fadfa3a commit 16ec69d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pyroc.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ def _parse_inputs(self, preds, target):
integers.
"""
if type(preds) is list:
if type(preds) is OrderedDict:
# is already a ordered dict
pass
elif type(preds) is list:
if len(preds) == len(target):
preds = OrderedDict([(0, np.asarray(preds))])
elif hasattr(preds[0], '__len__'):
Expand All @@ -127,13 +130,10 @@ def _parse_inputs(self, preds, target):
# preds is a dict - convert to ordered
names = sorted(preds.keys())
preds = OrderedDict([[c, np.asarray(preds[c])] for c in names])
elif type(preds) is not OrderedDict:
else:
raise ValueError(
'Unrecognized type "%s" for predictions.', str(type(preds))
)
else:
# is already a ordered dict
pass

if type(target) is pd.Series:
target = target.values
Expand Down

0 comments on commit 16ec69d

Please sign in to comment.