Skip to content

Commit

Permalink
slightly changed error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHug committed Nov 22, 2017
1 parent 5d4011a commit 2d2c1f3
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions surprise/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ def split(self, n_folds=5, shuffle=True):
"""

if n_folds > len(self.raw_ratings) or n_folds < 2:
raise ValueError('Incorrect value for n_folds.')
raise ValueError('Incorrect value for n_folds. Must be >=2 and '
'less than the number or entries')

if shuffle:
random.shuffle(self.raw_ratings)
Expand Down Expand Up @@ -476,8 +477,8 @@ def parse_line(self, line):
timestamp = None

except IndexError:
raise ValueError(('Impossible to parse line.' +
' Check the line_format and sep parameters.'))
raise ValueError('Impossible to parse line. Check the line_format'
' and sep parameters.')

return uid, iid, float(r) + self.offset, timestamp

Expand Down Expand Up @@ -570,8 +571,8 @@ def to_inner_uid(self, ruid):
try:
return self._raw2inner_id_users[ruid]
except KeyError:
raise ValueError(('User ' + str(ruid) +
' is not part of the trainset.'))
raise ValueError('User ' + str(ruid) +
' is not part of the trainset.')

def to_raw_uid(self, iuid):
"""Convert a **user** inner id to a raw id.
Expand All @@ -595,8 +596,7 @@ def to_raw_uid(self, iuid):
try:
return self._inner2raw_id_users[iuid]
except KeyError:
raise ValueError((str(iuid) +
' is not a valid inner id.'))
raise ValueError(str(iuid) + ' is not a valid inner id.')

def to_inner_iid(self, riid):
"""Convert an **item** raw id to an inner id.
Expand All @@ -616,8 +616,8 @@ def to_inner_iid(self, riid):
try:
return self._raw2inner_id_items[riid]
except KeyError:
raise ValueError(('Item ' + str(riid) +
' is not part of the trainset.'))
raise ValueError('Item ' + str(riid) +
' is not part of the trainset.')

def to_raw_iid(self, iiid):
"""Convert an **item** inner id to a raw id.
Expand All @@ -641,8 +641,7 @@ def to_raw_iid(self, iiid):
try:
return self._inner2raw_id_items[iiid]
except KeyError:
raise ValueError((str(iiid) +
' is not a valid inner id.'))
raise ValueError(str(iiid) + ' is not a valid inner id.')

def all_ratings(self):
"""Generator function to iterate over all ratings.
Expand Down

0 comments on commit 2d2c1f3

Please sign in to comment.