From 38f263587fb365b7ed051337810ff0a6ab351361 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 11 Apr 2017 20:09:35 +0000 Subject: [PATCH] fixed boundary case in supply and demand We protect against the boundary case of having no choosers in the predict method, but this gets circumvented and is still a problem with the supply and demand code. I was hoping to protect against this outside of urbansim, but we dont't know how many choosers there are until the predict_filters gets run, and that happens in urbansim. --- urbansim/models/dcm.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/urbansim/models/dcm.py b/urbansim/models/dcm.py index 96935089..b649ad1d 100644 --- a/urbansim/models/dcm.py +++ b/urbansim/models/dcm.py @@ -1135,6 +1135,9 @@ def summed_probabilities(self, choosers, alternatives): Summed probabilities from each segment added together. """ + if len(alternatives) == 0 or len(choosers) == 0: + return pd.Series() + logger.debug( 'start: calculate summed probabilities in LCM group {}'.format( self.name))