Skip to content

Commit

Permalink
adding max_dua to sqftproforma (finally)
Browse files Browse the repository at this point in the history
should be documented and tested and full coverage
  • Loading branch information
fscottfoti committed Jul 17, 2014
1 parent e0689c7 commit 93695e9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
22 changes: 21 additions & 1 deletion urbansim/developer/sqftproforma.py
Expand Up @@ -482,6 +482,14 @@ def lookup(self, form, df, only_built=True):
will not be built above these heights. Will pick between the min of
the far and height, will ignore on of them if one is nan, but will not
build if both are nan.
max_dua : series, optional
A series representing the maximum dwelling units per acre allowed by
zoning. If max_dua is passed, the average unit size should be passed
below to translate from dua to floor space.
ave_unit_size : series, optional
This is required if max_dua is passed above, otherwise it is optional.
This is the same as the parameter to Developer.pick() (it should be the
same series).
Returns
-------
Expand Down Expand Up @@ -523,7 +531,19 @@ 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).fillna(0)
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
# everything just works (floor space will get covered back to units in developer.pick()
# but we need to test the profitability of the floorspace allowed by max_dua here.
if 'max_dua' in df.columns:
# 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.min_max_fars.fillna(0)
if only_built:
df = df.query('min_max_fars > 0 and parcel_size > 0')

Expand Down
20 changes: 20 additions & 0 deletions urbansim/developer/tests/test_sqftproforma.py
Expand Up @@ -19,6 +19,14 @@ def simple_dev_inputs():
index=['a', 'b', 'c'])


@pytest.fixture
def max_dua_dev_inputs():
sdi = simple_dev_inputs()
sdi['max_dua'] = [0, 0, 0]
sdi['ave_unit_size'] = [650, 650, 650]
return sdi


@pytest.fixture
def simple_dev_inputs_high_cost():
sdi = simple_dev_inputs()
Expand Down Expand Up @@ -50,6 +58,18 @@ def test_sqftproforma_defaults(simple_dev_inputs):
assert len(out) == 2


def test_sqftproforma_max_dua(simple_dev_inputs_low_cost, max_dua_dev_inputs):
pf = sqpf.SqFtProForma()

out = pf.lookup("residential", simple_dev_inputs_low_cost)
# normal run return 3
assert len(out) == 3

out = pf.lookup("residential", max_dua_dev_inputs)
# max_dua is set to 0
assert len(out) == 0


def test_sqftproforma_low_cost(simple_dev_inputs_low_cost):
pf = sqpf.SqFtProForma()

Expand Down

0 comments on commit 93695e9

Please sign in to comment.