From 5dad4305b967b301d8ed04e6b67846dd5c6a740b Mon Sep 17 00:00:00 2001 From: Hana Sevcikova Date: Tue, 12 Feb 2019 11:55:10 -0800 Subject: [PATCH 1/2] fixed an issue when proposals_to_keep is larger than the maximum number of proposals --- developer/sqftproforma.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/developer/sqftproforma.py b/developer/sqftproforma.py index c3323ac..9f6262f 100644 --- a/developer/sqftproforma.py +++ b/developer/sqftproforma.py @@ -779,6 +779,7 @@ def _lookup_parking_cfg(self, form, parking_config, df, else: maxprofitind = np.argmax(profit, axis=0) + proposals_to_keep_in_form = min(self.proposals_to_keep, maxprofitind.shape[0]) def twod_get(indexes, arr): if indexes.ndim == 1: return arr[indexes, np.arange(indexes.size)].astype('float') @@ -786,10 +787,10 @@ def twod_get(indexes, arr): arr = arr[indexes, np.arange(indexes.shape[1])] return arr.astype('float').flatten() - if self.proposals_to_keep == 1: + if proposals_to_keep_in_form == 1: outdf_index = df.index else: - outdf_index = np.tile(df.index, self.proposals_to_keep) + outdf_index = np.tile(df.index, proposals_to_keep_in_form) outdf = pd.DataFrame({ 'building_sqft': twod_get(maxprofitind, building_bulks), From 862ac6058bd6e6feea124b739a2a067df838d41a Mon Sep 17 00:00:00 2001 From: Hana Sevcikova Date: Tue, 12 Feb 2019 17:42:30 -0800 Subject: [PATCH 2/2] finished change --- developer/sqftproforma.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/developer/sqftproforma.py b/developer/sqftproforma.py index 9f6262f..fe58585 100644 --- a/developer/sqftproforma.py +++ b/developer/sqftproforma.py @@ -773,13 +773,13 @@ def _lookup_parking_cfg(self, form, parking_config, df, profit = profit.astype('float') profit[np.isnan(profit)] = -np.inf - if self.proposals_to_keep > 1: + proposals_to_keep_in_form = min(self.proposals_to_keep, fars.shape[0]) + if proposals_to_keep_in_form > 1: maxprofit_sorted_indexes = np.argsort(-profit, axis=0) - maxprofitind = maxprofit_sorted_indexes[:self.proposals_to_keep] + maxprofitind = maxprofit_sorted_indexes[:proposals_to_keep_in_form] else: maxprofitind = np.argmax(profit, axis=0) - proposals_to_keep_in_form = min(self.proposals_to_keep, maxprofitind.shape[0]) def twod_get(indexes, arr): if indexes.ndim == 1: return arr[indexes, np.arange(indexes.size)].astype('float')