Skip to content

Commit

Permalink
Fix some developer docstrings and add to sphinx docs.
Browse files Browse the repository at this point in the history
[ci-skip]
  • Loading branch information
jiffyclub committed Jul 24, 2014
1 parent 21b83a1 commit 17c91ce
Show file tree
Hide file tree
Showing 6 changed files with 201 additions and 153 deletions.
9 changes: 9 additions & 0 deletions docs/developer/developer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Developer
=========

API
---

.. automodule:: urbansim.developer.developer
:members:
:undoc-members:
8 changes: 8 additions & 0 deletions docs/developer/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Developer Models
================

.. toctree::
:maxdepth: 2

developer
sqftproforma
9 changes: 9 additions & 0 deletions docs/developer/sqftproforma.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Square-Foot Proforma
====================

API
---

.. automodule:: urbansim.developer.sqftproforma
:members:
:undoc-members:
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Contents
:maxdepth: 2

models/index
developer/index
utils/index
urbanchoice/index

Expand Down
57 changes: 33 additions & 24 deletions urbansim/developer/developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
import numpy as np


class Developer:
class Developer(object):
"""
Pass the dataframe that is returned by feasibility here
def __init__(self, feasibility):
"""
Pass the dataframe that is returned by feasibility here
Can also be a dictionary where keys are building forms and values are
the individual data frames returned by the proforma lookup routine.
Can also be a dictionary where keys are building forms and values are
the individual data frames returned by the proforma lookup routine.
"""
"""

def __init__(self, feasibility):
if isinstance(feasibility, dict):
feasibility = pd.concat(feasibility.values(), keys=feasibility.keys(), axis=1)
self.feasibility = feasibility
Expand All @@ -19,21 +20,23 @@ def __init__(self, feasibility):
def max_form(f, colname):
"""
Assumes dataframe with hierarchical columns with first index equal to the
use and second index equal to the attribute
e.g. f.columns equal to:
mixedoffice building_cost
building_revenue
building_size
max_profit
max_profit_far
total_cost
industrial building_cost
building_revenue
building_size
max_profit
max_profit_far
total_cost
use and second index equal to the attribute.
e.g. f.columns equal to::
mixedoffice building_cost
building_revenue
building_size
max_profit
max_profit_far
total_cost
industrial building_cost
building_revenue
building_size
max_profit
max_profit_far
total_cost
"""
df = f.stack(level=0)[[colname]].stack().unstack(level=1).reset_index(level=1, drop=True)
return df.idxmax(axis=1)
Expand All @@ -48,6 +51,7 @@ def keep_form_with_max_profit(self, forms=None):
----------
forms: list of strings
List of forms which compete which other. Can leave some out.
"""
f = self.feasibility

Expand All @@ -66,15 +70,18 @@ def compute_units_to_build(num_agents, num_units, target_vacancy):
"""
Compute number of units to build to match target vacancy.
Parameters:
Parameters
----------
num_agents : int
number of agents that need units in the region
num_units : int
number of units in buildings
target_vacancy : float (0-1.0)
target vacancy rate
Returns : int
Returns
-------
int
the number of units that need to be built
"""
print "Number of agents: %d" % num_agents
Expand Down Expand Up @@ -129,6 +136,7 @@ def pick(self, form, target_units, parcel_size, ave_unit_size,
residential: bool
If creating non-residential buildings set this to false and developer
will fill in non_residential_units rather than residential_units
"""

if isinstance(form, list):
Expand Down Expand Up @@ -183,6 +191,7 @@ def merge(old_df, new_df):
Merge two dataframes of buildings. The old dataframe is
usually the buildings dataset and the new dataframe is a modified
(by the user) version of what is returned by the pick method.
"""
maxind = np.max(old_df.index.values)
new_df = new_df.reset_index(drop=True)
Expand Down
Loading

0 comments on commit 17c91ce

Please sign in to comment.