<s> import os <EOL> import pandas as pd <EOL> import numpy as np <EOL> import pytest <EOL> from . . import sqftproforma as sqpf <EOL> @ pytest . fixture <EOL> def simple_dev_inputs ( ) : <EOL> return pd . DataFrame ( <EOL> { '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> '<STR_LIT>' : [ <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT:15> ] , <EOL> '<STR_LIT>' : [ <NUM_LIT:12> , <NUM_LIT:10> , <NUM_LIT:10> ] , <EOL> '<STR_LIT>' : [ <NUM_LIT:12> , <NUM_LIT:12> , <NUM_LIT:12> ] , <EOL> '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] } , <EOL> index = [ '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ] ) <EOL> @ pytest . fixture <EOL> def max_dua_dev_inputs ( ) : <EOL> sdi = simple_dev_inputs ( ) <EOL> sdi [ '<STR_LIT>' ] = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> sdi [ '<STR_LIT>' ] = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> return sdi <EOL> @ pytest . fixture <EOL> def simple_dev_inputs_high_cost ( ) : <EOL> sdi = simple_dev_inputs ( ) <EOL> sdi . land_cost *= <NUM_LIT:20> <EOL> return sdi <EOL> @ pytest . fixture <EOL> def simple_dev_inputs_low_cost ( ) : <EOL> sdi = simple_dev_inputs ( ) <EOL> sdi . land_cost /= <NUM_LIT:20> <EOL> return sdi <EOL> def test_sqftproforma_config_defaults ( ) : <EOL> sqpf . SqFtProFormaConfig ( ) <EOL> def test_sqftproforma_defaults ( simple_dev_inputs ) : <EOL> pf = sqpf . SqFtProForma ( ) <EOL> for form in pf . config . forms : <EOL> out = pf . lookup ( form , simple_dev_inputs ) <EOL> if form == "<STR_LIT>" : <EOL> assert len ( out ) == <NUM_LIT:0> <EOL> if form == "<STR_LIT>" : <EOL> assert len ( out ) == <NUM_LIT:3> <EOL> if form == "<STR_LIT>" : <EOL> assert len ( out ) == <NUM_LIT:0> <EOL> def test_sqftproforma_max_dua ( simple_dev_inputs_low_cost , max_dua_dev_inputs ) : <EOL> pf = sqpf . SqFtProForma ( ) <EOL> out = pf . lookup ( "<STR_LIT>" , simple_dev_inputs_low_cost ) <EOL> assert len ( out ) == <NUM_LIT:3> <EOL> out = pf . lookup ( "<STR_LIT>" , max_dua_dev_inputs ) <EOL> assert len ( out ) == <NUM_LIT:0> <EOL> def test_sqftproforma_low_cost ( simple_dev_inputs_low_cost ) : <EOL> pf = sqpf . SqFtProForma ( ) <EOL> for form in pf . config . forms : <EOL> out = pf . lookup ( form , simple_dev_inputs_low_cost ) <EOL> if form == "<STR_LIT>" : <EOL> assert len ( out ) == <NUM_LIT:3> <EOL> if form == "<STR_LIT>" : <EOL> assert len ( out ) == <NUM_LIT:3> <EOL> if form == "<STR_LIT>" : <EOL> assert len ( out ) == <NUM_LIT:3> <EOL> def test_reasonable_feasibility_results ( ) : <EOL> pf = sqpf . SqFtProForma ( ) <EOL> df = pd . DataFrame ( <EOL> { '<STR_LIT>' : [ <NUM_LIT:30> , <NUM_LIT:20> , <NUM_LIT:10> ] , <EOL> '<STR_LIT>' : [ <NUM_LIT:15> , <NUM_LIT:15> , <NUM_LIT:15> ] , <EOL> '<STR_LIT>' : [ <NUM_LIT:12> , <NUM_LIT:12> , <NUM_LIT:12> ] , <EOL> '<STR_LIT>' : [ <NUM_LIT:12> , <NUM_LIT:12> , <NUM_LIT:12> ] , <EOL> '<STR_LIT>' : [ <NUM_LIT:1000> * <NUM_LIT:100> , <NUM_LIT:1000> * <NUM_LIT:100> , <NUM_LIT:1000> * <NUM_LIT:100> ] , <EOL> '<STR_LIT>' : [ <NUM_LIT:1000> , <NUM_LIT:1000> , <NUM_LIT:1000> ] , <EOL> '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] } , index = [ '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ] ) <EOL> out = pf . lookup ( "<STR_LIT>" , df ) <EOL> first = out . iloc [ <NUM_LIT:0> ] <EOL> assert first . max_profit_far == <NUM_LIT> <EOL> assert first . building_sqft == <NUM_LIT> <EOL> assert <NUM_LIT:100> < first . building_cost / first . building_sqft < <NUM_LIT> <EOL> assert first . total_cost == first . building_cost + df . iloc [ <NUM_LIT:0> ] . land_cost <EOL> assert <NUM_LIT:200> < first . building_revenue / first . building_sqft < <NUM_LIT> <EOL> assert first . residential_sqft == first . building_sqft * pf . config . building_efficiency <EOL> assert first . max_profit_far < first . stories < first . max_profit_far * <NUM_LIT> <EOL> assert first . non_residential_sqft == <NUM_LIT:0> <EOL> assert first . max_profit > <NUM_LIT:0> <EOL> assert len ( out ) == <NUM_LIT:1> <EOL> c = sqpf . SqFtProFormaConfig ( ) <EOL> c . parking_rates [ "<STR_LIT>" ] = <NUM_LIT:0> <EOL> pf = sqpf . SqFtProForma ( c ) <EOL> out = pf . lookup ( "<STR_LIT>" , df ) <EOL> second = out . iloc [ <NUM_LIT:1> ] <EOL> assert second . max_profit_far == <NUM_LIT> <EOL> def test_sqftproforma_high_cost ( simple_dev_inputs_high_cost ) : <EOL> pf = sqpf . SqFtProForma ( ) <EOL> for form in pf . config . forms : <EOL> out = pf . lookup ( form , simple_dev_inputs_high_cost ) <EOL> if form == "<STR_LIT>" : <EOL> assert len ( out ) == <NUM_LIT:0> <EOL> if form == "<STR_LIT>" : <EOL> assert len ( out ) == <NUM_LIT:0> <EOL> if form == "<STR_LIT>" : <EOL> assert len ( out ) == <NUM_LIT:0> <EOL> def test_debug_info ( ) : <EOL> pf = sqpf . SqFtProForma ( ) <EOL> for form in pf . config . forms : <EOL> for parking_config in pf . config . parking_configs : <EOL> pf . get_debug_info ( form , parking_config ) <EOL> def test_appropriate_range ( ) : <EOL> pf = sqpf . SqFtProForma ( ) <EOL> for form in pf . config . forms : <EOL> for park_config in pf . config . parking_configs : <EOL> s = pf . get_ave_cost_sqft ( form , park_config ) <EOL> assert len ( s [ s > <NUM_LIT> ] ) == <NUM_LIT:0> <EOL> assert len ( s [ s < <NUM_LIT> ] ) == <NUM_LIT:0> <EOL> def test_roughly_monotonic ( ) : <EOL> pf = sqpf . SqFtProForma ( ) <EOL> for form in pf . config . forms : <EOL> for park_config in pf . config . parking_configs : <EOL> s = pf . get_ave_cost_sqft ( form , park_config ) . values <EOL> for i in range ( <NUM_LIT:0> , s . size - <NUM_LIT:1> ) : <EOL> left , right = s [ i ] , s [ i + <NUM_LIT:1> ] <EOL> if np . isnan ( left ) or np . isnan ( right ) : <EOL> continue <EOL> assert left < right * <NUM_LIT> <EOL> def test_config_params ( ) : <EOL> c = sqpf . SqFtProFormaConfig ( ) <EOL> c . check_is_reasonable ( ) <EOL> class TestSqFtProFormaDebug ( object ) : <EOL> def teardown_method ( self , method ) : <EOL> if os . path . exists ( '<STR_LIT>' ) : <EOL> os . remove ( '<STR_LIT>' ) <EOL> def test_sqftproforma_debug ( self ) : <EOL> pf = sqpf . SqFtProForma ( ) <EOL> pf . _debug_output ( ) </s>
