From b99a842275a083962d51436a77f10bb1bce1b587 Mon Sep 17 00:00:00 2001 From: conorhenley Date: Tue, 27 Jun 2017 12:01:21 -0700 Subject: [PATCH] fix for cases in which large number of accounting_column records should be removed in transition model --- urbansim/models/transition.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/urbansim/models/transition.py b/urbansim/models/transition.py index f834de21..c0fad61d 100644 --- a/urbansim/models/transition.py +++ b/urbansim/models/transition.py @@ -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