Skip to content

Commit

Permalink
fix for cases in which large number of accounting_column records shou…
Browse files Browse the repository at this point in the history
…ld be removed in transition model
  • Loading branch information
conorhenley committed Jun 27, 2017
1 parent 1982464 commit b99a842
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions urbansim/models/transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ def remove_rows(data, nrows, accounting_column=None):
"""
logger.debug('start: removing {} rows in transition model'.format(nrows))
nrows = abs(nrows) # in case a negative number came in
unit_check = data[accounting_column].sum() if accounting_column else len(data)
if nrows == 0:
return data, _empty_index()
elif nrows > len(data):
raise ValueError('Number of rows to remove exceeds number of rows in table.')
elif nrows > unit_check:
raise ValueError('Number of rows to remove exceeds number of records in table.')

remove_rows = sample_rows(nrows, data, accounting_column=accounting_column, replace=False)
remove_index = remove_rows.index
Expand Down

0 comments on commit b99a842

Please sign in to comment.