Skip to content

Commit

Permalink
log messages in supply and demand functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jiffyclub committed Oct 1, 2014
1 parent fa3e7f8 commit 308420f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions urbansim/models/supplydemand.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
Tools for modeling how supply and demand affect real estate prices.
"""
import logging

import numpy as np
import pandas as pd

logger = logging.getLogger(__name__)


def _calculate_adjustment_ratio(
lcm, choosers, alternatives, alt_segmenter,
Expand Down Expand Up @@ -35,6 +39,7 @@ def _calculate_adjustment_ratio(
and `clip_change_high`.
"""
logger.debug('start: calculate supply and demand price adjustment ratio')
# probabilities of agents choosing * number of agents = demand
demand = pd.Series(lcm.summed_probabilities(choosers, alternatives))
# group by submarket
Expand All @@ -49,6 +54,9 @@ def _calculate_adjustment_ratio(
ratio = ratio.loc[alt_segmenter]
ratio.index = alt_segmenter.index

logger.debug(
('finish: calculate supply and demand price adjustment ratio '
'with mean ratio {}').format(ratio.mean()))
return ratio


Expand Down Expand Up @@ -86,6 +94,7 @@ def supply_and_demand(
Equivalent of the `price_col` in `alternatives`.
"""
logger.debug('start: calculating supply and demand price adjustment')
# copy alternatives so we don't modify the user's original
alternatives = alternatives.copy()

Expand All @@ -101,4 +110,5 @@ def supply_and_demand(
clip_change_low, clip_change_high)
alternatives[price_col] = alternatives[price_col] * ratio

logger.debug('finish: calculating supply and demand price adjustment')
return alternatives[price_col]

0 comments on commit 308420f

Please sign in to comment.