def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel', 'urbansim'], test_data={ 'development_template': { 'template_id': array([1,2,3,4]), 'building_type_id': array([1, 1, 2, 3]), "density_type": array(['units_per_acre', 'units_per_acre', 'far', 'units_per_acre']), 'density':array([0.6, 2.0, 10, 5]), 'percent_land_overhead':array([0, 10, 0, 20]), 'land_sqft_min': array([0, 10, 4, 30],dtype=int32) * self.ACRE, 'land_sqft_max': array([2, 20, 8, 100],dtype=int32) * self.ACRE }, 'parcel': { "parcel_id": array([1, 2, 3]), "vacant_land_area": array([1, 50, 200],dtype=int32)* self.ACRE, }, 'development_project_proposal': { "proposal_id":array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]), "parcel_id": array([1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3 ]), "template_id":array([1, 2, 3, 4, 2, 3, 4, 1, 2, 3, 4]) } }) should_be = array([1, 0, 0, 0, 36, 80*self.ACRE, 200, 1, 36, 80*self.ACRE, 400]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): """Number of homes without children for a given gridcell """ gridcell_grid_id = array([1, 2, 3]) #specify an array of 4 households, 1st hh's grid_id = 2 (it's in gridcell 2), etc. household_grid_id = array([2, 1, 3, 1] ) #corresponds to above hh array, specifies which hh's in which locations "qualify" is_without_children = array([0, 1, 1, 1] ) tester = VariableTester( __file__, package_order=['urbansim'], test_data={ "gridcell":{ "grid_id":gridcell_grid_id }, "household":{ "household_id":array([1,2,3,4]), "grid_id":household_grid_id, "is_without_children":is_without_children } } ) should_be = array([2, 0, 1]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim'], test_data={ 'gridcell': { 'grid_id': array([1, 2, 3, 4]), 'relative_x': array([1, 2, 1, 2]), 'relative_y': array([1, 1, 2, 2]), 'acres_open_space_within_walking_distance': array([20, 10, 5, 0]), }, 'urbansim_constant': { "walking_distance_circle_radius": array([150]), 'cell_size': array([150]), } }) acres_within_walking_distance = 5 * 5.5597500000000002 should_be = 100 * array([ 20 / acres_within_walking_distance, 10 / acres_within_walking_distance, 5 / acres_within_walking_distance, 0 ]) tester.test_is_close_for_variable_defined_by_this_module( self, should_be)
def test_my_inputs(self): tester = VariableTester(__file__, package_order=['urbansim'], test_data={ 'gridcell': { 'grid_id': array([1, 2, 3, 4]), 'relative_x': array([1, 2, 1, 2]), 'relative_y': array([1, 1, 2, 2]), 'total_residential_value': array([100, 500, 1000, 1500]), 'residential_units': array([1, 1, 1, 1]), }, 'urbansim_constant': { "walking_distance_circle_radius": array([1]), 'cell_size': array([1]), } }) should_be = array( [log(1800 / 5), log(3100 / 5), log(4600 / 5), log(6000 / 5)]) tester.test_is_close_for_variable_defined_by_this_module( self, should_be)
def test(self): tester = VariableTester( __file__, package_order=['urbansim_parcel', 'urbansim'], test_data={ "building": { "building_id": array([1, 2, 3]), "zone_id": array([1, 2, 3]), "building_type_id": array([1, 3, 1]), "building_sqft": array([10, 900, 30]) }, "building_sqft_per_job": { "zone_id": array([1, 1, 1, 2, 2, 2, 3, 3]), "building_type_id": array([1, 2, 3, 1, 2, 3, 1, 3]), "building_sqft_per_job": array([100, 50, 200, 80, 60, 500, 20, 10]), }, "job": { "job_id": array([1, 2, 3, 4, 5, 6, 7]), "sqft": array([0, 1, 4, 0, 2, 5, 0]), "building_id": array([2, 1, 3, 2, 1, 2, 3]) }, }) should_be = array([10, 900, 30]) #was should_be = array([1+2,900,4+20]) tester.test_is_close_for_variable_defined_by_this_module( self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel', 'urbansim', 'opus_core'], test_data={ "household":{ 'household_id':array([1, 2, 3, 4, 5]), 'zone_id': array([3, 1,-1, 1, 2]), 'income': array([8, 5, 2, 0, 3]) * 10000 ##income_break: array([4, 3, 1, 1, 2]) }, "zone":{ 'zone_id': array([1, 2, 3]), }, "travel_data":{ 'from_zone_id': array([ 3, 3, 1, 1, 1, 2, 2, 3, 2]), 'to_zone_id': array([ 1, 3, 1, 3, 2, 1, 3, 2, 2]), 'logsum_hbw_am_income_1':array([ 1.1, 2.2, 3.3, 4.4, 0.5, 0.7, 8.7, 7.8, 1.0]), 'logsum_hbw_am_income_2':array([ 0.9, 2.0, 3.1, 4.2, 0.3, 0.5, 8.5, 7.6, 0.8]), 'logsum_hbw_am_income_3':array([ 0.7, 1.8, 2.9, 4.0, 0.1, 0.3, 8.3, 7.4, 0.6]), 'logsum_hbw_am_income_4':array([ 0.5, 1.6, 2.7, 3.8,-0.1, 0.1, 8.1, 7.2, 0.4]), 'am_pk_period_drive_alone_vehicle_trips':\ array([11.0, 2.0,30.0, 4.0, 0.0, 1.0, 5.0, 2.0, 7.0]), } }) should_be = array([(0.5*11.0 + 7.2*2.0 + 1.6*2.0) / (11.0 + 2.0 + 2.0), (2.9*30.0 + 0.1*0.0 + 4.0*4.0) / (30.0 + 0.0 + 4.0), trip_weighted_average_logsum_hbw_am_from_residence.default_value, (3.3*30.0 + 0.5*0.0 + 4.4*4.0) / (30.0 + 0.0 + 4.0), (0.5* 1.0 + 0.8*7.0 + 8.5*5.0) / (1.0 + 7.0 + 5.0)]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel','urbansim'], test_data={ "building":{"building_id": array([1,2,3,4,5,6,7,8,9,10]), "is_residential": array([0,1,1,1,0,1,0,0,1,1,]), "building_sqft": array([1,0,0,0,1,3,3,1,2,2])*1000, "residential_units": array([0,3,1,2,0,1,0,1,2,4]) #occupied sqft 1400,0,0,0,0,0,1200,0,0,0 #occupied units 0,3,3,0,0,1,1, 0,1,1 }, "job":{"job_id": array([1,2,3,4,5,6,7,8,9,10]), "building_id": array([1,1,1,4,5,7,7,7,9,10]), "home_based_status": array([0,0,0,1,1,0,0,0,1,1]), "sqft_imputed": array([3,3,1,2,2,1,2,3,2,4]) * 200 }, "household":{"household_id": array([1,2,3,4,5,6,7,8,9,10]), "building_id": array([2,2,2,3,3,3,6,7,9,10]), }, } ) should_be = array([3, 3, 3, 0, 0, 1, 3, 0, 1, 1]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel', 'urbansim', 'opus_core'], test_data={ "household":{ 'household_id':array([1, 2, 3, 4, 5]), 'zone_id': array([3, 1,-1, 1, 2]), 'income': array([8, 5, 2, 0, 3]) * 10000 ##income_break: array([4, 3, 1, 1, 2]) }, "zone":{ 'zone_id': array([1, 2, 3]), }, "travel_data":{ 'from_zone_id': array([ 3, 3, 1, 1, 1, 2, 2, 3, 2]), 'to_zone_id': array([ 1, 3, 1, 3, 2, 1, 3, 2, 2]), 'logsum_hbw_am_income_1':array([ 1.1, 2.2, 3.3, 4.4, 0.5, 0.7, 8.7, 7.8, 1.0]), 'logsum_hbw_am_income_2':array([ 0.9, 2.0, 3.1, 4.2, 0.3, 0.5, 8.5, 7.6, 0.8]), 'logsum_hbw_am_income_3':array([ 0.7, 1.8, 2.9, 4.0, 0.1, 0.3, 8.3, 7.4, 0.6]), 'logsum_hbw_am_income_4':array([ 0.5, 1.6, 2.7, 3.8,-0.1, 0.1, 8.1, 7.2, 0.4]), 'am_pk_period_drive_alone_vehicle_trips':\ array([11.0, 2.0,30.0, 4.0, 0.0, 1.0, 5.0, 2.0, 7.0]), } }) should_be = array([(0.5*11.0 + 7.2*2.0 + 1.6*2.0) / (11.0 + 2.0 + 2.0), (2.9*30.0 + 0.1*0.0 + 4.0*4.0) / (30.0 + 0.0 + 4.0), trip_weighted_average_logsum_hbw_am_from_residence.default_value, (3.3*30.0 + 0.5*0.0 + 4.4*4.0) / (30.0 + 0.0 + 4.0), (0.5* 1.0 + 0.8*7.0 + 8.5*5.0) / (1.0 + 7.0 + 5.0)]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel', 'urbansim', 'opus_core'], test_data={ "person":{ 'person_id': array([1, 2, 3, 4, 5, 6]), 'household_id':array([1, 1, 2, 3, 3, 5]), #hhzone_id :array([3, 3, 1, 1, 1, 2]), 'job_id': array([1, 2, -1, -1, 2, 3]), #jobzone_id: array([1, 2, -1, -1, 2, 3]) }, "job":{ 'job_id': array([1, 2, 3]), 'zone_id':array([1, 2, 3]), }, "household":{ 'household_id':array([1, 2, 3, 4, 5]), 'zone_id': array([3, 1, 1, 1, 2]), }, 'travel_data':{ 'from_zone_id': array([3, 3, 1, 1, 1, 2, 2, 3, 2]), 'to_zone_id': array([1, 3, 1, 3, 2, 1, 3, 2, 2]), 'am_single_vehicle_to_work_travel_time':array([1.1, 2.2, 3.3, 4.4, 0.5, 0.7, 8.7, 7.8, 1.0]) }, }) should_be = array([1.1, 7.8, 0, 0, 0.5, 8.7]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test(self): tester = VariableTester( __file__, package_order=["urbansim_parcel", "urbansim"], test_data={ "building": { "building_id": array([1, 2, 3]), "zone_id": array([1, 2, 3]), "building_type_id": array([1, 3, 1]), "building_sqft": array([10, 900, 30]), }, "building_sqft_per_job": { "zone_id": array([1, 1, 1, 2, 2, 2, 3, 3]), "building_type_id": array([1, 2, 3, 1, 2, 3, 1, 3]), "building_sqft_per_job": array([100, 50, 200, 80, 60, 500, 20, 10]), }, "job": { "job_id": array([1, 2, 3, 4, 5, 6, 7]), "sqft": array([0, 1, 4, 0, 2, 5, 0]), "building_id": array([2, 1, 3, 2, 1, 2, 3]), }, }, ) should_be = array([10, 900, 30]) # was should_be = array([1+2,900,4+20]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_zone', 'urbansim'], test_data={ 'building': { 'building_id': array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 'zone_id': array([1, 2, 3, 4, 1, 2, 3, 2, 3, 4]), # 'faz_id': array([1, 2, 3, 1, 1, 2, 3, 2, 3, 1]) 'building_type_id': array([1, 1, 1, 1, 1, 2, 2, 2, 2, 2]), 'average_value_per_unit': array([ 19.0, 2000.0, 310.0, 400.0, 0.0, 5000.0, 300.0, 45.0, 79.0, 200.0 ]), }, 'zone': { 'zone_id': array([1, 2, 3, 4]), 'faz_id': array([1, 2, 3, 1]) }, }) should_be = array([ 139.666667, 2000, 310, 139.6666667, 139.6666667, 2522.5, 189.5, 2522.5, 189.5, 200 ]) tester.test_is_close_for_variable_defined_by_this_module( self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['sanfrancisco', 'urbansim'], test_data={ 'building_type': { "building_type_id": array([1, 2, 3, 4]), "class_id": array([1, 2, 1, 2]), }, 'building_type_classification': { "class_id": array([1, 2]), "name": array(["nonresidential", "residential"]), "unit_name": array(["building_sqft", "residential_units"]) }, "building": { 'building_id': array([1, 2, 3, 4, 5]), 'building_type_id': array([1, 2, 3, 4, 3]), 'building_sqft': array([1000, 200, 0, 400, 1500]), 'residential_units': array([0, 2, 0, 40, 5]), }, }) should_be = array([1000, 2, 0, 40, 1500]) tester.test_is_close_for_variable_defined_by_this_module( self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel', 'urbansim', 'opus_core'], test_data={ "job":{ 'job_id': array([1, 2, 3, 4, 5, 6]), 'building_id':array([1, 1, 5, 3, 3, 3]), 'sector_id': array([1, 1, 2, 1, 3, 3]), }, "building":{ 'building_id': array([1, 2, 3, 4, 5,]), 'parcel_id': array([1, 2, 2, 3, 4,]), }, 'parcel':{ 'parcel_id': array([1,2,3,4]), }, }) ## mind the mirror of gridcells in waling_distance calculus should_be = array([[2, 1, 1, 0, 0], [2, 1, 1, 0, 0], [0, 0, 0, 0, 1], [2, 1, 1, 0, 0], [0, 2, 2, 0, 0], [0, 2, 2, 0, 0]]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_finding_ids(self): # similar test, but we don't put the zone id in the household dataset -- instead # it has to be computed by finding the building with the household in it, then the # zone with that building tester = VariableTester(__file__, package_order=['urbansim_parcel', 'urbansim'], test_data={ "zone": { "zone_id": arange(1, 4) }, "building": { "building_id": arange(1, 6), "zone_id": array([1, 3, 1, 2, 2]) }, "household": { "building_id": array([1, 1, 4, 4, 1, 5, 3]), "household_id": arange(1, 8), "income": array([10, 0, 7, 2, 3, 5, 20]), } }) should_be = array([33.0 / 4.0, 14.0 / 3.0, 0]) tester.test_is_close_for_variable_defined_by_this_module( self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim'], test_data={ 'gridcell': { 'grid_id': array([1, 2, 3, 4]), 'relative_x': array([1, 2, 1, 2]), 'relative_y': array([1, 1, 2, 2]), 'residential_units_within_walking_distance': array([3, 5, 1, 0]), }, 'urbansim_constant': { 'acres': array([11]), 'walking_distance_circle_radius': array([150]), 'cell_size': array([150]), } }) should_be = array( [3 / (5.0 * 11), 5 / (5.0 * 11), 1 / (5.0 * 11), 0 / (5.0 * 11)]) tester.test_is_close_for_variable_defined_by_this_module( self, should_be)
def test_visitacion(self): tester = VariableTester( __file__, package_order=['urbansim_parcel','urbansim'], test_data={ 'proposal_component': { "proposal_component_id": array([1, 2, 3, 4]), "proposal_id": array([1, 1, 1, 1]), "building_type_id": array([2, 3, 5, 9]), #mf, mf-affordable, retail, cultural "sqft": array([0, 0, 105, 15]) * 1000, "price_per_unit": array([400,0, 0, 0]) * 1000, "rent_per_unit": array([0, 15, 0, 0]) * 1000, "lease_per_sqft": array([0, 0, 21, 0]), "parking_ratio": array([4/3.0,4/3.0,500,500]), "common_area": array([.2, .2, .15, .15]), }, 'proposal':{ 'proposal_id': array([1]), 'total_units': array([1250]), 'affordable_ratio': array([.25]), }, } ) should_be = array([381369250.00]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be, rtol=1e-2)
def test_my_inputs(self): """Number of homes without children for a given gridcell """ gridcell_grid_id = array([1, 2, 3]) #specify an array of 4 households, 1st hh's grid_id = 2 (it's in gridcell 2), etc. household_grid_id = array([2, 1, 3, 1] ) #corresponds to above hh array, specifies which hh's in which locations "qualify" is_without_children = array([0, 1, 1, 1] ) tester = VariableTester( __file__, package_order=['urbansim'], test_data={ "gridcell":{ "grid_id":gridcell_grid_id }, "household":{ "household_id":array([1,2,3,4]), "grid_id":household_grid_id, "is_without_children":is_without_children } } ) should_be = array([2, 0, 1]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=["urbansim_parcel", "urbansim", "opus_core"], test_data={ "faz": {"faz_id": arange(1, 3)}, "land_use_type": {"land_use_type_id": arange(1, 6)}, "parcel": { "parcel_id": arange(1, 21), "unit_price": array([10, 5, 3, 100, 2, 1, 4, 2, 68, 400, 3, 12, 14, 59, 24, 0, 0, 24, 5, 2.5]), "total_value_per_sqft": array( [10, 5, 3, 100, 2, 1, 4, 2, 68, 400, 3, 12, 14, 59, 24, 20, 0, 24, 5, 2.5] ), "land_use_type_id": array([1, 3, 1, 5, 4, 5, 4, 3, 1, 1, 4, 3, 1, 5, 5, 3, 4, 1, 1, 1]), "faz_id": array([1, 2, 2, 1, 2, 1, 1, 1, 1, 2, 2, 1, 2, 1, 2, 2, 1, 1, 1, 2]), }, }, ) should_be = array( [ [array([10, 68, 24, 5]).mean(), 0, array([2, 12]).mean(), 4, array([100, 1, 59]).mean()], [array([3, 400, 14, 2.5]).mean(), 0, array([5, 20]).mean(), array([2, 3]).mean(), 24], ] ) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim'], test_data={ 'gridcell':{ 'grid_id': array([1,2,3,4]), 'relative_x': array([1,2,1,2]), 'relative_y': array([1,1,2,2]), 'commercial_sqft': array([30,1000,50,2000]), 'number_of_commercial_jobs': array([100,0,10,500]), }, 'urbansim_constant':{ "walking_distance_circle_radius": array([150]), 'cell_size': array([150]), "acres": array([105.0]), } } ) should_be = array([3080.0/610.0, 5030.0/600.0, 3080.0/610.0, 7050.0/1510.0]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel', 'urbansim', 'opus_core'], test_data={ 'person': { 'person_id':array([1, 2, 3, 4, 5, 6, 7, 8]), 'household_id': array([1, 1, 2, 3, 3, 3, 4, 5]), 'worker1': array([1, 0, 1, 0, 0, 1, 0, 0]), 'worker2': array([0, 0, 0, 0, 1, 0, 0, 0]), 'workplace_zone_id': array([1, 3, 3, 2, 2, 3, -1, -1]), }, 'household': { 'household_id':array([1, 2, 3, 4, 5]), 'zone_id': array([3, 1, 1, 1, 2]), }, 'travel_data': { 'from_zone_id':array([3,3,1,1,1,2,2,3,2]), 'to_zone_id': array([1,3,1,3,2,1,3,2,2]), 'am_single_vehicle_to_work_travel_time':array([1.1, 2.2, 3.3, 4.4, 6.5, 0.7, 8.7, 7.8, 1.0]) } }) default_value = workerDDD_drive_alone_from_home_to_work.default_value should_be = array([1.1, 4.4, 6.5, default_value, default_value]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel', 'urbansim'], test_data={ "building": { "building_id": array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), "unit_name": array([ "building_sqft", "residential_units", "residential_units", "residential_units", 'building_sqft', "residential_units", "building_sqft", "parcel_sqft", "residential_units", "residential_units", ]), "building_sqft": array([1, 0, 0, 0, 1, 3, 3, 1, 2, 2]) * 1000, "residential_units": array([0, 3, 1, 2, 0, 1, 0, 1, 2, 4]) #occupied sqft 1400,0,0,0,0,0,1200,0,0,0 #occupied units 0,3,3,0,0,1,1, 0,1,1 }, }) should_be = array([1000, 3, 1, 2, 1000, 1, 3000, 0, 2, 4]) tester.test_is_close_for_variable_defined_by_this_module( self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel','urbansim'], test_data={ "building":{"building_id": array([1,2,3,4,5,6,7,8,9,10]), "unit_name": array(["building_sqft","residential_units","residential_units","residential_units", 'building_sqft',"residential_units","building_sqft", "parcel_sqft", "residential_units","residential_units",]), "building_sqft": array([1,0,0,0,1,3,3,1,2,2])*1000, "residential_units": array([0,3,1,2,0,1,0,1,2,4]) #occupied sqft 1400,0,0,0,0,0,1200,0,0,0 #occupied units 0,3,3,0,0,1,1, 0,1,1 }, "job":{"job_id": array([1,2,3,4,5,6,7,8,9,10]), "building_id": array([1,1,1,4,5,7,7,7,9,10]), "home_based_status": array([0,0,0,1,1,0,0,0,1,1]), "sqft_imputed": array([3,3,1,2,2,1,2,3,2,4]) * 200 }, "household":{"household_id": array([1,2,3,4,5,6,7,8,9,10]), "building_id": array([2,2,2,3,3,3,6,7,9,10]), }, } ) should_be = array([1000, 3, 1, 0, 0, 1, 1200, 0, 1, 1]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel'], test_data={ 'development_template': { 'template_id': array([1,2,3,4]), 'land_sqft_min': array([0, 10, 1000, 0]), 'land_sqft_max': array([0, 1999, 2000, 10]), }, 'parcel': { "parcel_id": array([1, 2, 3]), "vacant_land_area":array([10, 1000, 2000]), }, 'development_project_proposal': { "proposal_id":array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]), "parcel_id": array([1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3 ]), "template_id":array([1, 2, 3, 4, 2, 3, 4, 1, 2, 3, 4]) } } ) should_be = array([0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel','urbansim'], test_data={ 'parcel': { "parcel_id": array([1, 2, 3]), "parcel_sqft": array([20000, 45360, 90000]), "unit_price": array([50, 500, 100000]), "existing_units": array([20000, 1000, 1]), "improvement_value":array([0, 150000, 60000]), }, 'development_project_proposal': { "proposal_id":array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]), "parcel_id": array([1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3 ]), "template_id":array([1, 2, 3, 4, 2, 3, 4, 1, 2, 3, 4]), "is_redevelopment":array([0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1]), "land_area_taken": array([10000, 20000, 10000, 20000, 22680, 45360, 15120, 45000, 45000, 90000, 9000, ]), }, } ) should_be = array([500000, 1000000, 500000, 1000000, 175000, 500000, 266666.666, 20000, 80000, 100000, 64000]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be, rtol=1e-2)
def test_my_inputs(self): tester = VariableTester(__file__, package_order=['urbansim_parcel', 'urbansim'], test_data={ "job": { "job_id": array([1, 2, 3, 4, 5, 6, 7, 8]), "building_id": array([1, 2, 2, 2, 3, 3, 4, 5]), }, "building": { "building_id": array([1, 2, 3, 4, 5]), "parcel_id": array([1, 1, 2, 3, 4]) }, "parcel": { "parcel_id": array([1, 2, 3, 4]), "zone_id": array([1, 3, 2, 2]), "parcel_sqft": array([0.1, 0.2, 0.4, 0.3]) * 43560.0, }, "zone": { "zone_id": array([1, 2, 3]), } }) should_be = array([1, 1, 1, 1, 2, 2, 3, 4]) tester.test_is_close_for_variable_defined_by_this_module( self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel','urbansim'], test_data={ 'development_template': { 'template_id': array([1,2,3,4]), 'density_type': array(['units_per_acre', 'far', 'units_per_acre', 'far']), 'density':array([0.2, 10, 1.5, 7.2], dtype='float32') }, # 'development_template_component': # { # 'template_id': array([1,2,3,4,4]), # "component_id":array([1,2,3,4,1]), # "percent_of_building_sqft":array([100, 100, 100, 20, 80]) # }, # 'building_component': # { # "component_id":array([1, 2, 3, 4]), # "sqft_per_unit": array([1600, 1, 2000, 1]), # "construction_cost_per_unit":array([100000, 200, 300000, 100]) # } } ) should_be = array([0, 10, 0, 7.2]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel', 'urbansim', 'opus_core'], test_data={ "job":{ 'job_id': array([1, 2, 3, 4, 5, 6]), 'building_id':array([1, 1, 5, 3, 3, 3]), 'sector_id': array([1, 1, 2, 1, 3, 3]), }, "building":{ 'building_id': array([1, 2, 3, 4, 5,]), 'grid_id': array([1, 2, 2, 3, 4,]), }, 'gridcell':{ 'grid_id': array([1,2,3,4]), 'relative_x': array([1,2,1,2]), 'relative_y': array([1,1,2,2]), }, 'urbansim_constant':{ "walking_distance_circle_radius": array([150]), 'cell_size': array([150]), "acres": array([105.0]), } }) ## mind the mirror of gridcells in waling_distance calculus should_be = array([[7, 5, 5, 2, 1], [7, 5, 5, 2, 1], [0, 1, 1, 1, 3], [7, 5, 5, 2, 1], [2, 6, 6, 0, 2], [2, 6, 6, 0, 2]]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['psrc_parcel', 'urbansim_parcel','urbansim'], test_data={ "building":{"building_id": array([1,2,3,4,5,6,7,8,9,10]), "zone_id": array([1,1,2,2,1,3,3,3,2,2]), "building_type_id": array([1,3,1,2,2,1,2,3,2,4]), "job_capacity": array([0,1,2,0,0,1,2,2,0,5])*10, "year_built": array([-1,0,1,1,1,2,2,2,0,0])+2000, "non_residential_sqft": array([1,2,2,1,7,0,3,5,4,6])*1000, }, "building_sqft_per_job":{ "zone_id": array([1, 1, 1, 2, 2, 2, 3, 3]), "building_type_id": array([1, 2, 3, 1, 2, 3, 1, 3]), "building_sqft_per_job":array([100,50,200,80,60,500,20,10]), }, } ) SimulationState().set_start_time(2000) # mean over "building_sqft_per_job" is 127.5 should_be = array([0, 10, 2000/80., 1000/60., 7000/50., 0/200, 3000/127.5 , 5000/10., 0, 50]).astype("int32") tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel', 'urbansim', 'opus_core'], test_data={ 'person': { 'person_id': array([1, 2, 3, 4, 5, 6, 7, 8]), 'household_id': array([1, 1, 2, 3, 3, 3, 4, 5]), 'worker1': array([1, 0, 1, 0, 0, 1, 0, 0]), 'worker2': array([0, 0, 0, 0, 1, 0, 0, 0]), 'workplace_zone_id': array([1, 3, 3, 2, 2, 3, -1, -1]), }, 'household': { 'household_id': array([1, 2, 3, 4, 5]), 'zone_id': array([3, 1, 1, 1, 2]), }, 'travel_data': { 'from_zone_id': array([3, 3, 1, 1, 1, 2, 2, 3, 2]), 'to_zone_id': array([1, 3, 1, 3, 2, 1, 3, 2, 2]), 'am_single_vehicle_to_work_travel_time': array([1.1, 2.2, 3.3, 4.4, 6.5, 0.7, 8.7, 7.8, 1.0]) } }) default_value = workerDDD_drive_alone_from_home_to_work.default_value should_be = array([1.1, 4.4, 6.5, default_value, default_value]) tester.test_is_close_for_variable_defined_by_this_module( self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=["urbansim_parcel", "urbansim"], test_data={ "building": { "building_id": array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), "unit_name": array( [ "building_sqft", "residential_units", "residential_units", "residential_units", "building_sqft", "residential_units", "building_sqft", "parcel_sqft", "residential_units", "residential_units", ] ), "building_sqft": array([1, 0, 0, 0, 1, 3, 3, 1, 2, 2]) * 1000, "residential_units": array([0, 3, 1, 2, 0, 1, 0, 1, 2, 4]) # occupied sqft 1400,0,0,0,0,0,1200,0,0,0 # occupied units 0,3,3,0,0,1,1, 0,1,1 } }, ) should_be = array([1000, 3, 1, 2, 1000, 1, 3000, 0, 2, 4]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel', 'urbansim'], test_data={ 'parcel': { "parcel_id": array([1, 2, 3, 4]), "land_use_type_id": array([1, 2, 3, 5]), "sqft_per_job": array([1, 50, 200, 0],dtype=int32), }, 'job': { "job_id":array([1, 2, 3, 4]), "parcel_id": array([1, 1, 2, 3]), }, 'household': { "household_id":array([1, 2, 3, 4]), "parcel_id": array([4, 4, 2, 3]), }, }) should_be = array([2, 51, 201, 2]) #nonsense tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): gridcell_grid_id = array([1, 2, 3]) #specify an array of 4 jobs, 1st job's grid_id = 2 (it's in gridcell 2), etc. job_grid_id = array([2, 1, 3, 1] ) #corresponds to above job array, specifies which jobs in which location "qualify" is_commercial = array([0, 1, 1, 1]) tester = VariableTester( __file__, package_order=['urbansim'], test_data={ "gridcell":{ "grid_id":array([1,2,3]), "gridcell_grid_id":gridcell_grid_id }, "job":{ "job_id":array([1,2,3,4]), "grid_id":job_grid_id, "is_commercial":is_commercial } } ) should_be = array([2, 0, 1]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester(__file__, package_order=['urbansim'], test_data={ 'gridcell': { 'grid_id': array([1, 2, 3, 4]), 'relative_x': array([1, 2, 1, 2]), 'relative_y': array([1, 1, 2, 2]), 'acres_of_open_space': array([100.0, 500.0, 1000.0, 1500.0]), }, 'urbansim_constant': { "walking_distance_circle_radius": array([150]), 'cell_size': array([150]), "acres": array([105.0]), } }) should_be = array([1800.0, 3100.0, 4600.0, 6000.0]) tester.test_is_close_for_variable_defined_by_this_module( self, should_be)
def test_my_inputs(self): ratio = 10.3 tester = VariableTester( __file__, package_order=['urbansim'], test_data={ 'gridcell': { 'grid_id': array([1, 2, 3, 4, 5, 6]), 'total_residential_value': array([50, 75, 0, 5, 20.5, 10000000000000000]), 'residential_units': array([1, 1, 0, 0, 2, 100]), }, 'urbansim_constant': { "property_value_to_annual_cost_ratio": array([ratio]), } }) should_be = array([ 50. / 1 / ratio, 75. / 1 / ratio, 0, 0, 20.5 / 2 / ratio, 10000000000000000. / 100 / ratio ]) tester.test_is_close_for_variable_defined_by_this_module( self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel', 'urbansim', 'opus_core'], test_data={ "person":{ 'person_id': array([1, 2, 3, 4, 5, 6]), 'household_id':array([1, 1, 2, 3, 3, 5]), #hhzone_id :array([3, 3, 1, 1, 1, 2]), 'job_id': array([1, 2, -1, -1, 2, 3]), #jobzone_id: array([1, 2, -1, -1, 2, 3]) }, "job":{ 'job_id': array([1, 2, 3]), 'zone_id':array([1, 2, 3]), }, "household":{ 'household_id':array([1, 2, 3, 4, 5]), 'zone_id': array([3, 1, 1, 1, 2]), }, 'travel_data':{ 'from_zone_id': array([3, 3, 1, 1, 1, 2, 2, 3, 2]), 'to_zone_id': array([1, 3, 1, 3, 2, 1, 3, 2, 2]), 'am_single_vehicle_to_work_travel_time':array([1.1, 2.2, 3.3, 4.4, 0.5, 0.7, 8.7, 7.8, 1.0]) }, }) should_be = array([1.1, 7.8, 0, 0, 0.5, 8.7]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel', 'urbansim'], test_data={ 'development_project_proposal': { "proposal_id": array([1, 2, 3, 4, 5]), "units_proposed": array([34, 250, 130, 0, 52]) }, 'development_project_proposal_component': { "proposal_component_id": arange(8)+1, "proposal_id": array([3, 3, 5, 2, 5, 1, 3, 1]), "percent_building_sqft": array([30, 25, 1, 100, 99, 100, 45, 0]), "template_id": array([4, 2, 1, 3, 2, 2, 4, 1]), "is_residential": array([True,False, True, True,False,True,False, True]), "building_sqft_per_unit": array([3.5, 1, 20, 0, 1, 0.1, 10, 50]) }, 'development_template': { 'template_id': array([1,2,3,4]), 'density_type': array(['units_per_acre', 'far', 'units_per_acre', 'far']), }, }) should_be = array([130/100.0*30/3.5, 130/100.0*25, 52/100.0, 250, 52/100.0 * 99, 34/0.1, 130/100.0*45, 0]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): seed(1) beta = [10, 15] n = 20 z = uniform(0.1, 2, n) r = normal(scale=0.01, size=n) y = beta[0] + beta[1] * z + r resources = Resources({'outcome': y, 'coefficient_names': array(['bz']), "constant_position": array([0])}) est = estimate_linear_regression().run(z[:, newaxis], resources=resources)['estimators'] should_be = y - (est[0] + est[1]*z) tester = VariableTester( __file__, package_order=['urbansim_parcel', 'urbansim'], test_data={ 'building': { "building_id": arange(n)+1, "price_per_unit": y, "avg_price_per_unit_in_zone": z, }, }) #should_be = r tester.test_is_close_for_variable_defined_by_this_module(self, should_be, rtol=0.01)
def test_my_inputs(self): tester = VariableTester(__file__, package_order=['urbansim'], test_data={ 'gridcell': { 'grid_id': array([1, 2, 3, 4]), 'relative_x': array([1, 2, 1, 2]), 'relative_y': array([1, 1, 2, 2]), 'industrial_sqft': array([30, 1000, 50, 2000]), 'number_of_industrial_jobs': array([100, 0, 10, 500]), }, 'urbansim_constant': { "walking_distance_circle_radius": array([150]), 'cell_size': array([150]), "acres": array([105.0]), } }) should_be = array( [3080.0 / 610.0, 5030.0 / 600.0, 3080.0 / 610.0, 7050.0 / 1510.0]) tester.test_is_close_for_variable_defined_by_this_module( self, should_be)
def test_my_inputs(self): gridcell_grid_id = array([1, 2, 3]) #specify an array of 4 jobs, 1st job's grid_id = 2 (it's in gridcell 2), etc. job_grid_id = array([2, 1, 3, 1]) #corresponds to above job array, specifies which jobs in which locations are in the group of interest home_based = array([0, 1, 1, 1]) #thorough explanation in number_of_high_income_households tester = VariableTester( __file__, package_order=['urbansim'], test_data={ "gridcell":{ "grid_id":array([1,2,3]), "gridcell_grid_id":gridcell_grid_id }, "job":{ "job_id":array([1,2,3,4]), "grid_id":job_grid_id, "is_home_based_job":home_based } } ) should_be = array([2, 0, 1]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['sanfrancisco','urbansim'], test_data={ 'building_type': { "building_type_id":array([1,2,3,4]), "class_id":array([1,2,1,2]), }, 'building_type_classification': { "class_id":array([1,2]), "name": array(["nonresidential","residential"]), "unit_name":array(["building_sqft","residential_units"]) }, "building":{ 'building_id': array([1, 2, 3, 4, 5]), 'building_type_id': array([1, 2, 3, 4, 3]), 'building_sqft': array([1000, 200, 0, 400, 1500]), 'residential_units': array([0, 2, 0, 40, 5]), }, } ) should_be = array([1000, 2, 0, 40, 1500]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): sum_income = array([1000, 10000, 100000]) #specify the total income for each of three locations number_of_households = array([300, 20, 500]) #specify the total number of households for each of three locations tester = VariableTester( __file__, package_order=['urbansim'], test_data={ 'gridcell':{ 'grid_id': array([1,2,3]), 'sum_income':sum_income, 'number_of_households':number_of_households } } ) #if the dependent variables span different "directories", i.e. gridcell and household, then a "household" key #would also be added to this dictionary. the names of keys within MUST MATCH an already existing variable... #as a general rule, look at the dependencies for the actual variable code above, and each one should appear #somewhere in the compute_variable dictionary arguments, i.e. in this case, "sum_income" and "number_of_households" #the corresponding value name to the keys doesn't matter, in this case i chose them to be the same. #"dataset" is the name of the "directory" that this variable is located should_be = array([3.33333, 500.0, 200.0]) #would be a 2-D array if it spanned more than one "directory" tester.test_is_close_for_variable_defined_by_this_module(self, should_be, rtol=1e-5)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel', 'urbansim'], test_data={ 'parcel': { "parcel_id": array([1, 2, 3]), "land_use_type_id": array([1, 2, 3 ]), "parcel_sqft": array([1, 50, 200],dtype=int32), }, 'building': { "building_id":array([1, 2, 3, 4]), "parcel_id": array([1, 1, 2, 3]), "building_sqft": array([1000, 0, 2000, 3000]), "residential_units": array([0, 7, 4, 2]), }, 'land_use_type': { "land_use_type_id":array([1, 2, 3]), "unit_name": array(["residential_units", "parcel_sqft", "building_sqft"]) } }) should_be = array([7, 50, 3000]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=["urbansim_parcel"], test_data={ "development_template": { "template_id": array([1, 2, 3, 4]), "building_type_id": array([1, 1, 2, 3]), "density": array([0.6, 2, 10, 5]), "land_sqft_min": array([0, 10, 4, 30]), "land_sqft_max": array([2, 20, 8, 100]), }, "parcel": { "parcel_id": array([1, 2, 3]), "parcel_sqft": array([2, 35, 110]), "vacant_land_area": array([1, 22, 110]), }, "development_project_proposal": { "proposal_id": array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]), "parcel_id": array([1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3]), "template_id": array([1, 2, 3, 4, 2, 3, 4, 1, 2, 3, 4]), "is_redevelopment": array([0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0]), }, }, ) should_be = array([1, 0, 0, 0, 20, 8, 35, 2, 20, 8, 110]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel','urbansim'], test_data={ "household":{ "household_id":array([1, 2, 3, 4, 5, 6, 7, 8]), "building_id": array([1, 2, 2, 2, 3, 3, 4, 5]), "persons": array([1, 2, 2, 2, 3, 3, 1, 5]) }, "building":{ "building_id":array([1,2,3,4,5]), "parcel_id": array([1,1,2,3,4]) }, "parcel":{ "parcel_id":array([1,2,3,4]), "zone_id": array([1,3,2,2]), "parcel_sqft":array([0.1, 0.2, 0.4, 0.3]) * 43560.0, }, "zone":{ "zone_id":array([1,2,3]), } } ) should_be = array([7/0.1, 6/(0.3+0.4), 6/0.2]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel','urbansim'], test_data={ 'development_template': { 'template_id': array([1,2,3,4]), 'density_type': array(['units_per_acre', 'far', 'units_per_acre', 'far']), 'density':array([0.2, 10, 1.5, 7.2], dtype='float32') }, # 'development_template_component': # { # 'template_id': array([1,2,3,4,4]), # "component_id":array([1,2,3,4,1]), # "percent_of_building_sqft":array([100, 100, 100, 20, 80]) # }, # 'building_component': # { # "component_id":array([1, 2, 3, 4]), # "sqft_per_unit": array([1600, 1, 2000, 1]), # "construction_cost_per_unit":array([100000, 200, 300000, 100]) # } } ) should_be = array([0.2, 0, 1.5, 0]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel'], test_data={ 'development_template': { 'template_id': array([1, 2, 3, 4]), 'building_type_id': array([1, 1, 2, 3]), 'density': array([0.6, 2, 10, 5]), 'land_sqft_min': array([0, 10, 4, 30]), 'land_sqft_max': array([2, 20, 8, 100]) }, 'parcel': { "parcel_id": array([1, 2, 3]), "parcel_sqft": array([2, 35, 110]), "vacant_land_area": array([1, 22, 110]), }, 'development_project_proposal': { "proposal_id": array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]), "parcel_id": array([1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3]), "template_id": array([1, 2, 3, 4, 2, 3, 4, 1, 2, 3, 4]), 'is_redevelopment': array([0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0]) }, }) should_be = array([1, 0, 0, 0, 20, 8, 35, 2, 20, 8, 110]) tester.test_is_close_for_variable_defined_by_this_module( self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=["urbansim"], test_data={"gridcell": {"grid_id": array([1, 2, 3])}, "urbansim_constant": {"acres": array([105.0])}}, ) should_be = array([105.0, 105.0, 105.0]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): """Log of the amount of commercial space on cell.[ln_bounded(c.commercial_sqft )] """ tester = VariableTester( __file__, package_order=["urbansim"], test_data={"gridcell": {"grid_id": array([1, 2, 3]), "commercial_sqft": array([1, 1000, 20])}}, ) should_be = array([0.0, 6.907755, 2.995732]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_visitacion(self): tester = VariableTester( __file__, package_order=['urbansim_parcel','urbansim'], test_data={ 'proposal_component': { "proposal_component_id": array([1, 2, 3, 4, 5, 6, 7, 8]), "proposal_id": array([1, 1, 1, 1, 1, 1, 1, 1]), "building_type_id": array([2, 3, 5, 9, 0, 0, 0, 0]), #MXD Townhome #Townhome #MXD Midrise 55 #Midrise 55 #MXD Midrise 65 #Midrise 65 #MXD Highrise 85 #Highrise 85 "special": array([0, 1, 0, 0, 0, 0, 0, 1]), #why these are special? "cost_per_unit": array([140, 140, 140, 140, 140, 168, 0, 168]) * 1.26, "footprint_sqft": array([0,6000,308750,6000,85000,42875,0,102500]), "commercial_floors": array([0, 0, 1, 0, 1, 0,1, 0]), "residential_floors": array([0, 1, 3, 4, 4, 5,6, 7]), #"sqft": array([0, 0, 105, 15]) * 1000, #"price_per_unit": array([400,0, 0, 0]) * 1000, #"rent_per_unit": array([0, 15, 0, 0]) * 1000, #"lease_per_sqft": array([0, 0, 21, 0]), #"parking_ratio": array([4/3.0,4/3.0,500,500]), #"common_area": array([.2, .2, .15, .15]), }, 'proposal':{ 'proposal_id': array([1]), 'residential_sqft_permitted': array([1875000]), 'total_units': array([1250]), 'retail_sqft': array([105000]), 'cultural_sqft': array([15000]), 'residential_parking_ratio': array([.75]), 'non_residential_parking_ratio': array([2.0/1000]), 'surface_parking': array([0]), 'deck_parking': array([60000 * 3]), 'road_cost': array([2500 * 2000]), 'infrastructure_cost':array([0.075]), }, } ) should_be = array([ 467087722 ]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be, rtol=1e-2)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim'], test_data={ "gridcell":{ "grid_id":array([1, 2, 3, 4, 5, 6]), "total_improvement_value":array([50, 75, 0, 50, -20, 10000000000000000]) } } ) should_be = array([3.912023, 4.317488, 0.0, 3.912023, 0.0, 36.8413614]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester(__file__, package_order=['urbansim_parcel', 'urbansim'], test_data={ 'household': { 'household_id': array([1, 2, 3, 4]), 'persons': array([2, 1, 1, 7]) }, }) should_be = array([2, 1, 1, 2]) tester.test_is_close_for_variable_defined_by_this_module( self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel','urbansim'], test_data={ 'development_template': { 'template_id': array([1,2,3,4]), "land_use_type_id":array([1, 1, 2, 2]), 'density_type': array(['units_per_acre', 'units_per_acre', 'far', 'far']), # 'constraint_name':array(['units_per_acre', 'units_per_acre', 'far', 'far']), 'units_per_acre': array([0.2, 2, 0, 0]), 'far':array([0, 0, 25, 7]) }, 'land_use_type': { "land_use_type_id":array([1, 2]), "generic_land_use_type_id":array([1, 2]), # 'density_type': array(['units_per_acre','far']), }, 'development_constraint': { 'constraint_id': array([1,2,3,4]), 'is_constrained': array([0, 1, 1, 0]), 'generic_land_use_type_id': array([1, 1, 2, 2]), 'constraint_type':array(['units_per_acre','units_per_acre', 'far', 'far']), 'minimum': array([0, 0, 0, 0]), 'maximum': array([3, 0.2, 10, 100]), }, 'parcel': { "parcel_id": array([1, 2, 3]), "is_constrained": array([1, 0, 1]), }, 'development_project_proposal': { "proposal_id":array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]), "parcel_id": array([1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3 ]), "template_id":array([1, 2, 3, 4, 2, 3, 4, 1, 2, 3, 4]) } } ) should_be = array([1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test_my_inputs(self): tester = VariableTester( __file__, package_order=['urbansim_parcel', 'urbansim', 'opus_core'], test_data={ #"person":{ #'person_id': array([1, 2, 3, 4, 5, 6]), #'household_id':array([1, 1, 5, 3, 3, 3]), #'member_id': array([1, 2, 1, 1, 2, 3]), #}, "household": { 'household_id': array([1, 2, 3, 4, 5, 6]), 'worker1_workplace_zone_id': array([1, 3, 3, 2, 3, -1]), 'available_travel_time': array([6, 4.4, 4.3, 2, 17, 0]) }, "building": { 'building_id': array([1, 2, 3, 4]), 'parcel_id': array([1, 1, 3, 4]), #'zone_id': array([1, 1, 3, 2]) }, "parcel": { 'parcel_id': array([1, 2, 3, 4]), 'zone_id': array([1, 1, 3, 2]), }, "zone": { 'zone_id': array([1, 2, 3]), 'number_of_jobs_of_sector_group_retail': array([7, 0, 103]), }, "travel_data": { 'from_zone_id': array([3, 3, 1, 1, 1, 2, 2, 3, 2]), 'to_zone_id': array([1, 3, 1, 3, 2, 1, 3, 2, 2]), 'am_single_vehicle_to_work_travel_time': array([1.1, 2.2, 3.3, 4.4, 0.5, 0.7, 8.7, 7.8, 1.0]) }, }) should_be = array([ [103, 103, 0, 7], [110, 110, 103, 7], [103, 103, 0, 7], [0, 0, 0, 7], [110, 110, 110, 110], [0, 0, 0, 0], ]) tester.test_is_close_for_variable_defined_by_this_module( self, should_be)
def test(self): tester = VariableTester( __file__, package_order=['opus_core'], test_data={ 'test':{ 'id': array([1, 2]), 'attr1': array([1, 2])}, 'test2': { 'id': array([1,2]), 'attr1': array([20, 15])} }, ) should_be = array([(1*2)/(20*4.0), (2*2)/(15*4.0)]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
def test(self): tester = VariableTester(__file__, package_order=['opus_core'], test_data={ 'test': { 'id': array([1, 2]), 'attr2': array([1., 2.]), }, }) should_be = array([1 * 2, 2 * 2]) tester.test_is_close_for_variable_defined_by_this_module(self, should_be, rtol=1e-20)