From bcc6bc35d3973ccfdaa80c7859cdddfd63a4a085 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Wed, 6 Jul 2016 19:48:20 +0200 Subject: [PATCH] Fix None*unit_factor error Also make the code more explicit about what happens when getting cost == None. --- .../cartodb_services/cartodb_services/mapzen/isolines.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/mapzen/isolines.py b/server/lib/python/cartodb_services/cartodb_services/mapzen/isolines.py index cd521c0..d686407 100644 --- a/server/lib/python/cartodb_services/cartodb_services/mapzen/isolines.py +++ b/server/lib/python/cartodb_services/cartodb_services/mapzen/isolines.py @@ -107,7 +107,12 @@ class MapzenIsolines: # Just assume isorange and stop the calculations there response = self._matrix_client.one_to_many([origin] + location_estimates, costing_model) - costs = [(c[cost_variable]*unit_factor or isorange) for c in response['one_to_many'][0][1:]] + costs = [None] * self.NUMBER_OF_ANGLES + for idx, c in enumerate(response['one_to_many'][0][1:]): + if c[cost_variable]: + costs[idx] = c[cost_variable]*unit_factor + else: + costs[idx] = isorange logging.debug('i = %d, costs = %s' % (i, costs))