UDST / developer

Redesigned UrbanSim developer/pro forma models
https://udst.github.io/developer/
BSD 3-Clause "New" or "Revised" License
3 stars 5 forks source link

use self.target_units for custom functions #73

Closed cvanoli closed 4 years ago

cvanoli commented 4 years ago

The _select_buildings is a function inside the Developer object. The function selects buildings using the self.target_units, a developer property, which can be passed as a Float or as a pd.DataFrame with the column target_units. With self.target_units, a float variable called target_units is created being the self.target_units itself, it this is a Float, or a sum of the target_units column if self.target_units is a DataFrame. Then, the selection of buildings can be done through three methods: a custom selection passed by the user called custom_selection_func, the weighted_random_choice_multiparcel method from proposal_select.py or the weighted_random_choice method also from proposal_select.py. The three functions uses the target_units as inputs. The two latter, defined in proposal_select.py needs a Float type as the target_units input, so the variable target_units that was created is passed into these. But, as the custom_selection_func is a function that is defined and passed by the user, we assume that it will designed to take as input the original target_units that is passed to create the developer object. Therefore, the parameter to pass into the custom_selection_func should be self.target_units instead of target_units, since in the case self.target_units is a pd.DataFrame, the custom_selection_func will be expecting that type, instead of a Float which is the local variable target_units.

coveralls commented 4 years ago

Pull Request Test Coverage Report for Build 54


Changes Missing Coverage Covered Lines Changed/Added Lines %
developer/develop.py 0 1 0.0%
<!-- Total: 0 1 0.0% -->
Totals Coverage Status
Change from base Build 52: 0.0%
Covered Lines: 789
Relevant Lines: 829

💛 - Coveralls
smmaurer commented 4 years ago

Linking things up, this fixes the bug identified in https://github.com/UDST/developer/pull/71#issuecomment-574852680.