Skip to content

Commit

Permalink
Merge branch 'master' into remove-dataset-mdlrunner
Browse files Browse the repository at this point in the history
  • Loading branch information
fscottfoti committed Aug 6, 2014
2 parents 10f279c + cea8f08 commit 7c1ddaa
Show file tree
Hide file tree
Showing 10 changed files with 469 additions and 95 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
@@ -1,4 +1,4 @@
[run]
omit =
urbansim/utils/texttable.py
urbansim/urbanchoice/pmat.py
urbansim/**/tests/*
19 changes: 11 additions & 8 deletions urbansim/developer/developer.py
Expand Up @@ -94,7 +94,7 @@ def compute_units_to_build(num_agents, num_units, target_vacancy):

def pick(self, form, target_units, parcel_size, ave_unit_size,
current_units, max_parcel_size=200000, min_unit_size=400,
drop_after_build=True, residential=True):
drop_after_build=True, residential=True, bldg_sqft_per_job=400.0):
"""
Choose the buildings from the list that are feasible to build in
order to match the specified demand.
Expand All @@ -114,9 +114,11 @@ def pick(self, form, target_units, parcel_size, ave_unit_size,
The size of the parcels. This was passed to feasibility as well,
but should be passed here as well. Index should be parcel_ids.
ave_unit_size : series
The average unit size around each parcel - this is indexed
by parcel, but is usually a disaggregated version of a zonal or
accessibility aggregation.
The average residential unit size around each parcel - this is
indexed by parcel, but is usually a disaggregated version of a
zonal or accessibility aggregation.
bldg_sqft_per_job : float (default 400.0)
The average square feet per job for this building form.
min_unit_size : float
Values less than this number in ave_unit_size will be set to this
number. Deals with cases where units are currently not built.
Expand All @@ -135,7 +137,7 @@ def pick(self, form, target_units, parcel_size, ave_unit_size,
to not develop the same parcel twice.
residential: bool
If creating non-residential buildings set this to false and developer
will fill in non_residential_units rather than residential_units
will fill in job_spaces rather than residential_units
"""

Expand All @@ -152,12 +154,13 @@ def pick(self, form, target_units, parcel_size, ave_unit_size,
df['current_units'] = current_units
df = df[df.parcel_size < max_parcel_size]

df['residential_units'] = np.round(df.residential_sqft / df.ave_unit_size)
df['job_spaces'] = np.round(df.non_residential_sqft / bldg_sqft_per_job)

if residential:
df['residential_units'] = np.round(df.residential_sqft / df.ave_unit_size)
df['net_units'] = df.residential_units - df.current_units
else:
df['non_residential_units'] = np.round(df.non_residential_sqft / df.ave_unit_size)
df['net_units'] = df.non_residential_units - df.current_units
df['net_units'] = df.job_spaces - df.current_units
df = df[df.net_units > 0]

if len(df) == 0:
Expand Down
6 changes: 4 additions & 2 deletions urbansim/developer/sqftproforma.py
Expand Up @@ -542,7 +542,6 @@ def lookup(self, form, df, only_built=True):
# min between max_fars and max_heights
df['max_far_from_heights'] = df.max_height / c.height_per_story * \
c.parcel_coverage
df['min_max_fars'] = df[['max_far_from_heights', 'max_far']].min(axis=1)

# now also minimize with max_dua from zoning - since this pro forma is really geared
# toward per sqft metrics, this is a bit tricky. dua is converted to floorspace and
Expand All @@ -552,7 +551,10 @@ def lookup(self, form, df, only_built=True):
# if max_dua is in the data frame, ave_unit_size must also be present
assert 'ave_unit_size' in df.columns
df['max_far_from_dua'] = df.max_dua * df.ave_unit_size / self.config.building_efficiency
df['min_max_fars'] = df[['min_max_fars', 'max_far_from_dua']].min(axis=1)
df['min_max_fars'] = df[['max_far_from_heights', 'max_far',
'max_far_from_dua']].min(axis=1)
else:
df['min_max_fars'] = df[['max_far_from_heights', 'max_far']].min(axis=1)

if only_built:
df = df.query('min_max_fars > 0 and parcel_size > 0')
Expand Down
1 change: 1 addition & 0 deletions urbansim/models/lcm.py
Expand Up @@ -1125,6 +1125,7 @@ def columns_used(self):
self.choosers_columns_used(),
self.alts_columns_used(),
self.interaction_columns_used(),
util.columns_in_formula(self.default_model_expr),
[self.segmentation_col])))

@classmethod
Expand Down
1 change: 1 addition & 0 deletions urbansim/models/regression.py
Expand Up @@ -957,6 +957,7 @@ def columns_used(self):
return list(toolz.unique(toolz.concatv(
util.columns_in_filters(self.fit_filters),
util.columns_in_filters(self.predict_filters),
util.columns_in_formula(self.default_model_expr),
self._group.columns_used(),
[self.segmentation_col])))

Expand Down
3 changes: 3 additions & 0 deletions urbansim/models/util.py
Expand Up @@ -315,6 +315,9 @@ def columns_in_formula(formula):
columns : list of str
"""
if formula is None:
return []

formula = str_model_expression(formula, add_constant=False)
columns = []

Expand Down

0 comments on commit 7c1ddaa

Please sign in to comment.