Exemplo n.º 1
0
 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', '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_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):
        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=['urbansim_parcel','urbansim'],
         test_data={
         '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([1,  0,   0,  0]),
             'maximum': array([3, 0.2, 10, 100]),                
         },
         'parcel':
         {
             "parcel_id":        array([1,   2,    3]),
             "is_constrained":   array([1,   0,    1]),
         },
         'generic_land_use_type':
         {
             "generic_land_use_type_id":        array([1,   2]),
             "generic_land_use_type_name":      array(['',  '']),
         },
         }
     )
     
     should_be = array([0, 1, 0])
     
     instance_name = 'urbansim_parcel.parcel.min_units_per_acre_capacity_for_generic_land_use_type_1'
     tester.test_is_equal_for_family_variable(self, should_be, instance_name)
    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 "qualify"
        is_in_employment_sector = array([0, 1, 1, 1])
        home_based = array([1, 0, 1, 0])

        tester = VariableTester(
            __file__,
            package_order=["urbansim"],
            test_data={
                "gridcell": {"grid_id": gridcell_grid_id},
                "job": {
                    "job_id": array([1, 2, 3, 4]),
                    "grid_id": job_grid_id,
                    "is_in_employment_sector_2": is_in_employment_sector,
                    "is_home_based_job": home_based,
                },
            },
        )

        should_be = array([2, 0, 0])
        instance_name = "urbansim.gridcell.number_of_non_home_based_jobs_of_sector_2"
        tester.test_is_close_for_family_variable(self, should_be, instance_name)
Exemplo n.º 7
0
 def test_my_inputs(self):
     tester = VariableTester(
         __file__,
         package_order=['psrc_parcel', 'psrc', '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]),
             'income':      array([10000, 45000, 40000, 5000, 0])
              },
         'travel_data_link':{
             'travel_data_link_id':  array([1]),
             'data_link':  array([self.temp_dir]),
         },
      })
     should_be = array([66.4, 121, 0, 0, 36.6, 108])
     tester.test_is_close_for_family_variable(self, should_be, self.variable_name)
Exemplo n.º 8
0
    def test_my_inputs(self):
        tester = VariableTester(
            __file__,
            package_order=['sanfrancisco','urbansim'],
            test_data={
            'building':
            {"building_id": array([1,2,3,4,5,6]),
             "parcel_id": array([1,1,2,2,3,3]),
             "employment_of_sector_4":array([0,1,4,0,2,5]),
            },
            'parcel':
            {
             "parcel_id":array([1,2,3]),
             "zone_id":  array([1,1,2]),
             },
            'zone':
            {
             "zone_id":  array([1,2]),
             },
             
           }
        )
        
        should_be = array([5, 7])

        instance_name = 'sanfrancisco.zone.aggregate_employment_of_sector_4_from_building'
        tester.test_is_equal_for_family_variable(self, should_be, instance_name)
    def test_my_inputs(self):
        tester = VariableTester(
            __file__,
            package_order=['zurich_parcel', 'urbansim_parcel', 'urbansim'],
            test_data={
            'parcel':
            {
                "parcel_id":        array([1,   2,    3]),
                "x_coord_sp": array([1,   2,    4 ]),
                "y_coord_sp": array([1,   1,    1 ]),
            },
            'job':
            {
                "job_id":array([1,2,3,4,5,6,7]),
                "building_id":array([1,2,3,4,5,6,7]),
             },
            'building':
            {
                "building_id":array([1,2,3,4,5,6,7]),
                "parcel_id":array([1,2,2,2,2,1,3]),
             },
        })
        should_be = array([3.47151776, 4.87109417, 1.54134113])

        instance_name = 'zurich_parcel.parcel.jobs_within_2_of_parcel_weighted'
        tester.test_is_close_for_family_variable(self, should_be, instance_name)
Exemplo n.º 10
0
    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', '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)
Exemplo n.º 12
0
 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]),
                 'governmental_improvement_value': array([100, 500, 1000, 1500]),
                 # The four items below are 'throw-away' items to allow this Variable to test -
                 # they can be anything and not affect the outcome of this variable.
                 'commercial_improvement_value': array([0, 0, 0, 0]),
                 'industrial_improvement_value': array([0, 0, 0, 0]),
                 'residential_improvement_value': array([0, 0, 0, 0]),
                 'residential_units': array([0, 0, 0, 0]),
                 },
             'urbansim_constant':{
                 "walking_distance_circle_radius": array([150]),
                 'cell_size': array([150]),
             }
         }
     )
     
     should_be = array([1800, 3100, 4600, 6000])
     tester.test_is_equal_for_variable_defined_by_this_module(self, should_be)
Exemplo n.º 13
0
 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]),
                "x_coord_sp": array([1,   2,    3 ]),
                "y_coord_sp": array([1,   1,    1 ]),
            },
            'household':
            {
                "household_id":array([1,2,3,4,5,6,7]),
                "building_id":array([1,2,3,4,5,6,7]),
             },
            'building':
            {
                "building_id":array([1,2,3,4,5,6,7]),
                "parcel_id":array([1,2,2,2,2,1,3]),
             },
        })
        should_be = array([6, 7, 5])

        instance_name = 'urbansim_parcel.parcel.households_within_1_of_parcel'
        tester.test_is_equal_for_family_variable(self, should_be, instance_name)
Exemplo n.º 15
0
 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)
Exemplo n.º 16
0
    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)
Exemplo n.º 17
0
    def test_my_inputs( self ):
        tester = VariableTester(
            __file__,
            package_order=['urbansim', 'opus_core'],
            test_data={
                'gridcell':{
                    'grid_id': array([1,2,3,4]),
                    'plan_type_id': array([1, 3, 2, 3]),
                    },
                'plan_type_group':{
                    'name': array(["mixed_use", "high_density_residential"]),
                    'group_id': array([1,2]),
                }
            }
        )
        tester.dataset_pool._add_dataset('plan_type', mock_plantype(3))

        # Test variable 1
        should_be = array( [True, False, False, False] )
        instance_name1 = "urbansim.gridcell.is_in_plan_type_group_mixed_use"
        tester.test_is_equal_for_family_variable(self, should_be, instance_name1)

        # Test variable 2
        should_be = array( [True, False, True, False] )
        instance_name2 = "urbansim.gridcell.is_in_plan_type_group_high_density_residential"
        tester.test_is_equal_for_family_variable(self, should_be, instance_name2)
Exemplo n.º 18
0
    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)
Exemplo n.º 19
0
    def test_my_inputs(self):
        grid_id = array([1,  1,  2, 3, 1,  2])
        units = array([100, 40, 33, 0, 30,  10])
        SimulationState().set_current_time(2000)
        
        tester = VariableTester(
            __file__,
            package_order=['urbansim'],
            test_data={
                "gridcell": { 
                    "grid_id": array([1,2,3])
                    },
                "building": {
                    "building_id": array([1,2,3,4,5,6]),
                    "grid_id": grid_id,
                    "year_built": array([1980, 1945, 2000, 1997, 1000, 1970]),
                    "residential_units": units
                    },
                "urbansim_constant": {
                    "recent_years": array([3]),
                    "absolute_min_year": array([1800])
                }
            }
        )

        should_be = array([0, 33, 0]) 
        instance_name = 'urbansim.gridcell.n_recent_residential_units'
        tester.test_is_equal_for_family_variable(self, should_be, instance_name)
Exemplo n.º 20
0
    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_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)
Exemplo n.º 22
0
 def test_my_inputs(self):
     tester = VariableTester(
         __file__,
         package_order=['psrc_parcel','urbansim_parcel', 'urbansim'],
         test_data={
             'travel_data':
                 { 'from_zone_id': array([1, 3, 1, 368, 416]),
                   'to_zone_id' :array( [ 2, 2, 3, 416, 368]),
                   'travel_time': array([ 150, 73, 230, 15.5, 17.2])
                  },
             'node_travel_data':
                 {
                  'from_node_id': array([2873, 1348, 1421, 4835, 6628, 6523, 10, 2189]),
                  'to_node_id':   array([1348, 1421, 1348, 6628, 6523, 6628, 15, 2190]),
                  'travel_time': array([ 1.1,   0.4,  0.9,  2.5,  3.6,   0.1, 8.7, 0.8])
                  },
             'commute_travel_data':
                 {
                  'from_node_id': array([2873, 4835, 10]),
                  'to_node_id':   array([4835, 2873, 20])
                  }
                 }
     )
     
     should_be = array([15.5-1.1-0.4-2.5-3.6, 17.2-1.1-0.4-2.5-3.6, 0])
     instance_name = 'psrc_parcel.commute_travel_data.subtract_from_travel_data_travel_time'
     tester.test_is_close_for_family_variable(self, should_be, instance_name)
    def test_my_inputs2(self):
        tester = VariableTester(
            __file__,
            package_order=['urbansim_parcel', 'urbansim'],
            test_data={
            'development_project_proposal':
            {
                "proposal_id":    array([1,  2,    3,  4, 5]),
                "start_year": array([2005, 2007, 2005, 2006, 2006])
            },
            'development_project_proposal_component':
            {
                "proposal_component_id": arange(8)+1,
                 "proposal_id":           array([3, 3, 5, 2, 5, 1, 3, 1]),
                 "component_id":          array([3, 1, 4, 2, 4, 1, 3, 4]),
                 "annual_construction_schedule": array(["[0, 50, 100]", "[100]", "[25, 50, 75, 100]", "[0, 50, 100]", "[0, 50, 100]", "[25, 50, 75, 100]", "[25, 50, 75, 100]", "[100]"])
             },
            'development_template_component':
            {
                "component_id":          array([1, 2, 3, 4]),
                "velocity_function_id":  array([2, 1, 1, 3])
             },            
        })
        SimulationState().set_current_time(2007)
        should_be = array([50, 0,  25,  0, 50, 25, 25, 0])

        tester.test_is_equal_for_variable_defined_by_this_module(self, should_be)
Exemplo n.º 24
0
    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)
Exemplo n.º 25
0
    def test_my_inputs(self):
        """Total number of commercial sqft of buildings.
        """
        tester = VariableTester(
            __file__,
            package_order=['urbansim'],
            test_data={
                'gridcell':{
                    'grid_id':array([1,2,3]),
                    },
                'building': {
                    'building_id':array([1,2,3,4,5,6]),
                    'building_type_id':array([1,2,1,2,1,1]),
                    'grid_id':array([2,3,1,1,2,1]),
                    'sqft':array([100, 350, 1000, 0, 430, 95])
                    },
                'building_type': {
                    'building_type_id':array([1,2]),
                    'name': array(['foo', 'commercial'])
                }
            }
        )

        should_be = array([0, 0, 350])
        instance_name = "urbansim.gridcell.buildings_commercial_sqft"
        tester.test_is_equal_for_family_variable(self, should_be, instance_name)
Exemplo n.º 26
0
    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)
Exemplo n.º 27
0
    def test_full_tree(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_improvement_value': array([100, 500, 1000, 1500]),
                    },
                'household':{
                    'household_id': array([1, 2, 3, 4, 5, 6]),
                    'grid_id': array([1, 2, 3, 4, 2, 2]),
                    'income': array([1000, 5000, 3000, 10000, 1000, 8000]),
                    },
                'urbansim_constant':{
                    "walking_distance_circle_radius": array([150]),
                    'cell_size': array([150]),
                    "low_income_fraction": array([.25]),
                    'mid_income_fraction': array([.3]),
                }
            }
        )

        should_be = array([1,1,0,0])
        tester.test_is_equal_for_variable_defined_by_this_module(self, should_be)
Exemplo n.º 28
0
    def test_my_inputs(self):
        """Sum the number of jobs for a given gridcell that are in the employment sector specified by DDD """
        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 "qualify"
        is_in_employment_sector_group = array([0, 1, 1, 0] )

        tester = VariableTester(
            __file__,
            package_order=['urbansim'],
            test_data={
                "gridcell":{
                    "grid_id":gridcell_grid_id 
                    }, 
                "job":{ 
                    "job_id":array([1,2,3,4]),
                    "grid_id":job_grid_id, 
                    "is_in_employment_sector_group_retail":is_in_employment_sector_group
                }
            }
        )
        should_be = array([1, 0, 1])
        instance_name = "urbansim.gridcell.number_of_jobs_of_group_retail"    
        tester.test_is_equal_for_family_variable(self, should_be, instance_name)
Exemplo n.º 29
0
    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)
Exemplo n.º 30
0
    def test_my_inputs(self):
        zone_id = array([2, 1, 3])
        faz_id = array([3,4, 5])

        tester = VariableTester(
            __file__,
            package_order=['urbansim'],
            test_data={
                "gridcell":{ 
                    "grid_id":array([1,2,3]),
                    "zone_id":zone_id
                    }, 
                "zone":{ 
                    "zone_id":array([1,2,3]),
                    "faz_id":faz_id
                    }, 
                "faz":{
                    "faz_id":array([1,2,3,4,5,6]),
                    "fazdistrict_id":array([1,1,1,2,2,2])
                }
            }
        )
        
        should_be = array([2,1,2])
        tester.test_is_equal_for_variable_defined_by_this_module(self, should_be)
    def test_my_inputs(self):
        nonresidential_improvement_value = array([100, 200, 300])
        residential_improvement_value = array([1000, 400, 0])

        tester = VariableTester(__file__,
                                package_order=['urbansim'],
                                test_data={
                                    "gridcell": {
                                        "grid_id":
                                        array([1, 2, 3]),
                                        "nonresidential_improvement_value":
                                        nonresidential_improvement_value,
                                        "residential_improvement_value":
                                        residential_improvement_value
                                    }
                                })

        should_be = array([1100, 600, 300])
        tester.test_is_equal_for_variable_defined_by_this_module(
            self, should_be)
Exemplo n.º 32
0
 def test_my_inputs(self):
     tester = VariableTester(
         __file__,
         package_order=['urbansim'],
         test_data={
             'gridcell':{
                 'grid_id': array([33, 5, 20]),
                 'percent_open_space': array([33, 5, 20]),
             },
             'urbansim_constant':{
                 "acres": array([105.0]),
             }
         }
     )
     
     should_be = array([(1.0 - (33/100.0))*105.0, 
                        (1.0 - (5/100.0))*105.0, 
                        (1.0 - (20/100.0))*105.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]),
                    'is_developed': array([1, 0, 1, 1], dtype="bool8"),
                    },
                'urbansim_constant':{
                    "walking_distance_circle_radius": array([150]),
                    'cell_size': array([150]),
                }
            }
        )

        should_be = array([4.0, 2.0, 5.0, 4.0])
        tester.test_is_equal_for_variable_defined_by_this_module(self, should_be)
Exemplo n.º 34
0
    def test_my_inputs(self):
        tester = VariableTester(__file__,
                                package_order=['sanfrancisco', 'urbansim'],
                                test_data={
                                    'business': {
                                        "business_id": array([1, 2, 3, 4, 5]),
                                        "sector_id": array([4, 2, 4, 3, 4]),
                                        "building_id": array([1, 1, 2, 2, 2]),
                                        "employment":
                                        array([100, 20, 40, 30, 41])
                                    },
                                    'building': {
                                        "building_id": array([1, 2]),
                                    },
                                })

        should_be = array([100, 81])
        instance_name = 'sanfrancisco.building.employment_of_sector_4'
        tester.test_is_equal_for_family_variable(self, should_be,
                                                 instance_name)
Exemplo n.º 35
0
 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]),
                 'vacant_land_sqft': array([100, 500, 1000, 1500])
                 },
             'urbansim_constant':{
                 "walking_distance_circle_radius": array([150]),
                 'cell_size': array([150]),
             }
         }
     )
     
     should_be = array([1800.0, 3100.0, 4600.0, 6000.0])
     tester.test_is_equal_for_variable_defined_by_this_module(self, should_be)
    def test_my_inputs(self):
        nonresidential_improvement_value = array([200.5, 5, 200])
        nonresidential_land_value = array([199, 205, 6])

        tester = VariableTester(__file__,
                                package_order=['urbansim'],
                                test_data={
                                    "gridcell": {
                                        "grid_id":
                                        array([1, 2, 3]),
                                        "nonresidential_improvement_value":
                                        nonresidential_improvement_value,
                                        "nonresidential_land_value":
                                        nonresidential_land_value
                                    }
                                })

        should_be = array([399.5, 210, 206])
        tester.test_is_equal_for_variable_defined_by_this_module(
            self, should_be)
Exemplo n.º 37
0
    def test_my_inputs(self):
        utility_for_SOV = array([0.0, 0.250, 1])
        locations_in_zoneid = array([1, 1, 3, 2, 2])

        tester = VariableTester(__file__,
                                package_order=['urbansim'],
                                test_data={
                                    "zone": {
                                        "zone_id": array([1, 2, 3]),
                                        "utility_for_sov": utility_for_SOV
                                    },
                                    "gridcell": {
                                        "grid_id": array([1, 2, 3, 4, 5]),
                                        "zone_id": locations_in_zoneid
                                    }
                                })

        should_be = array([0.0, 0.0, 1, .250, .250])
        tester.test_is_equal_for_variable_defined_by_this_module(
            self, should_be)
    def test_my_inputs(self):
        number_of_jobs = array([500, 1000, 5000, 10000])
        number_of_home_based_jobs = array([500, 500, 1250, 10000])

        tester = VariableTester(__file__,
                                package_order=['urbansim'],
                                test_data={
                                    "gridcell": {
                                        "grid_id":
                                        array([1, 2, 3, 4]),
                                        "number_of_jobs":
                                        number_of_jobs,
                                        "number_of_home_based_jobs":
                                        number_of_home_based_jobs
                                    }
                                })

        should_be = array([0.0, 500.0, 3750.0, 0.0])
        tester.test_is_equal_for_variable_defined_by_this_module(
            self, should_be)
    def test_my_inputs(self):
        number_of_industrial_jobs = array([0, 4, 10])
        industrial_sqft_per_job = array([1995, 2005, 2006])

        tester = VariableTester(__file__,
                                package_order=['urbansim'],
                                test_data={
                                    "gridcell": {
                                        "grid_id":
                                        array([1, 2, 3]),
                                        "number_of_industrial_jobs":
                                        number_of_industrial_jobs,
                                        "industrial_sqft_per_job":
                                        industrial_sqft_per_job
                                    }
                                })

        should_be = array([0, 8020, 20060])
        tester.test_is_equal_for_variable_defined_by_this_module(
            self, should_be)
Exemplo n.º 40
0
 def test_my_inputs1(self):
     commercial_sqft = array([100, 200, 300])
     governmental_sqft = array([1000, 400, 0])
     industrial_sqft = array([0, 100, 500])
     
     tester = VariableTester(
         __file__,
         package_order=['urbansim'],
         test_data={
             "gridcell":{ 
                 "grid_id":array([1,2,3]),
                 "commercial_sqft":commercial_sqft, 
                 "governmental_sqft":governmental_sqft, 
                 "industrial_sqft":industrial_sqft
             }
         }
     )
     
     should_be = array([100, 300, 800])
     tester.test_is_equal_for_variable_defined_by_this_module(self, should_be)
Exemplo n.º 41
0
    def test_my_inputs(self):
        zone_id = array([2, 1, 3])
        faz_id = array([4, 5, 6])

        tester = VariableTester(__file__,
                                package_order=['urbansim'],
                                test_data={
                                    "gridcell": {
                                        "grid_id": array([1, 2, 3]),
                                        "zone_id": zone_id
                                    },
                                    "zone": {
                                        "zone_id": array([1, 2, 3]),
                                        "faz_id": faz_id
                                    }
                                })

        should_be = array([5, 4, 6])
        tester.test_is_equal_for_variable_defined_by_this_module(
            self, should_be)
    def test_my_inputs(self):
        number_of_commercial_jobs = array([12, 3, 39, 10])
        commercial_sqft = array([1200, 100, 3900, 16])
        commercial_sqft_per_job = array([20, 30, 30, 0])

        tester = VariableTester(
            __file__,
            package_order=['urbansim'],
            test_data={
                "gridcell":{
                    "grid_id":array([1,2,3,4]),
                    "number_of_commercial_jobs":number_of_commercial_jobs, 
                    "commercial_sqft":commercial_sqft, 
                    "commercial_sqft_per_job":commercial_sqft_per_job
                }
            }
        )
        
        should_be = array([48.0, 0.0, 91.0, 0])
        tester.test_is_equal_for_variable_defined_by_this_module(self, should_be)
Exemplo n.º 43
0
    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):
        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]),
                    #homezone_id:           3, 3, 2, 1, 1, 1
                    #income_brk:            4, 4, 2, 1, 1, 1
                },
                "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]),
                    'income': array([8, 5, 2, 0, 3]) * 10000
                },
                "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])
                }
            })
        should_be = array([[0.5, 7.2, 1.6], [0.5, 7.2, 1.6], [0.5, 0.8, 8.5],
                           [3.3, 0.5, 4.4], [3.3, 0.5, 4.4], [3.3, 0.5, 4.4]])

        tester.test_is_close_for_variable_defined_by_this_module(
            self, should_be)
Exemplo n.º 45
0
    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"]),
                    "unit_capacity_name":
                    array([
                        "building_sqft_capacity", "residential_units_capacity"
                    ])
                },
                "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]),
                    #                           sqft, ru, sqft, ru, sqft
                },
                "parcel": {
                    'parcel_id': array([1, 2, 3, 4, 5]),
                    'building_sqft_capacity': array([2000, 400, 0, 800, 3000]),
                    'residential_units_capacity': array([0, 4, 0, 42, 6]),
                },
            })

        should_be = array([[2000, 400, 0, 800, 3000], [0, 4, 0, 42, 6],
                           [2000, 400, 0, 800, 3000], [0, 4, 0, 42, 6],
                           [2000, 400, 0, 800, 3000]])

        tester.test_is_close_for_variable_defined_by_this_module(
            self, should_be)
    def test_my_inputs(self):
        zone_id = array([1, 1, 3, 2])
        tffjth = array([4.1, 5.3, 6.2])

        tester = VariableTester(
            __file__,
            package_order=['urbansim'],
            test_data={
                "gridcell": {
                    "grid_id": array([1, 2, 3, 4]),
                    "zone_id": zone_id
                },
                "zone": {
                    "zone_id": array([1, 2, 3]),
                    "ln_access_to_workplace_from_residences": tffjth
                }
            })

        should_be = array([4.1, 4.1, 6.2, 5.3])
        tester.test_is_close_for_variable_defined_by_this_module(
            self, should_be)
Exemplo n.º 47
0
    def test_my_inputs(self):
        gridcell_grid_id = array([1, 2, 3])
        job_grid_id = array(
            [2, 1, 3, 1]
        )  #specify an array of 4 jobs, 1st job's grid_id = 2 (it's in gridcell 2), etc.

        tester = VariableTester(__file__,
                                package_order=['urbansim'],
                                test_data={
                                    "gridcell": {
                                        "grid_id": gridcell_grid_id
                                    },
                                    "job": {
                                        "job_id": array([1, 2, 3, 4]),
                                        "grid_id": job_grid_id
                                    }
                                })

        should_be = array([2, 1, 1])
        tester.test_is_close_for_variable_defined_by_this_module(
            self, should_be)
 def test_my_inputs(self):
     mode = 'hwy'
     tester = VariableTester(__file__,
                             package_order=['urbansim_parcel', 'urbansim'],
                             test_data={
                                 "zone": {
                                     "zone_id": array([1, 3]),
                                     "population": array([10, 1])
                                 },
                                 "travel_data": {
                                     "from_zone_id": array([3, 3, 1, 1]),
                                     "to_zone_id": array([1, 3, 1, 3]),
                                     mode: array([1, 2, 3, 4])
                                 }
                             })
     should_be = array([2.11111, 0.875])
     instance_name = "sanfrancisco.zone.%s_travel_time_weighted_access_by_population" % mode
     tester.test_is_close_for_family_variable(self,
                                              should_be,
                                              instance_name,
                                              rtol=1e-5)
Exemplo n.º 49
0
 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]),
                 'buildings_commercial_space': array([100, 500, 1000, 1500])
                 },
             'urbansim_constant':{
                 "walking_distance_circle_radius": array([150]),
                 'cell_size': array([150]),
             }
         }
     )
     
     should_be = array([1800.0, 3100.0, 4600.0, 6000.0])
     instance_name = "urbansim.gridcell.buildings_commercial_sqft_within_walking_distance"        
     tester.test_is_equal_for_family_variable(self, should_be, instance_name)
Exemplo n.º 50
0
    def test_my_inputs(self):
        tester = VariableTester(
            __file__,
            package_order=['urbansim_parcel', 'urbansim'],
            test_data={
                'parcel': {
                    'parcel_id':
                    array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),
                    'large_area_id':
                    array([11, 11, 21, 21, 31, 31, 11, 11, 21, 21, 31, 31]),
                    'land_use_type_id':
                    array([7, 99, 7, 99, 7, 99, 0, 99, 0, 7, 99, 7]),
                },
            })
        should_be = array([
            1107, 1199, 2107, 2199, 3107, 3199, 1100, 1199, 2100, 2107, 3199,
            3107
        ])

        tester.test_is_close_for_variable_defined_by_this_module(
            self, should_be)
Exemplo n.º 51
0
    def test_my_inputs(self):
        total_land_value_within_walking_distance = array(
            [1000, 5000, 10000, 15000])
        acres_within_walking_distance = array([0.0, 100.0, 300.0, 56.0])

        tester = VariableTester(
            __file__,
            package_order=['urbansim'],
            test_data={
                "gridcell": {
                    "grid_id": array([1, 2, 3, 4]),
                    "total_land_value_within_walking_distance":
                    total_land_value_within_walking_distance,
                    "acres_within_walking_distance":
                    acres_within_walking_distance
                }
            })

        should_be = array([-1.0, 50.0, 33.3333333, 267.8571429])
        tester.test_is_close_for_variable_defined_by_this_module(
            self, should_be)
    def test_my_inputs(self):
        wtt_tw = array([0.0, 0.250, 1])
        locations_in_zoneid = array([1, 1, 3, 2, 2])

        tester = VariableTester(
            __file__,
            package_order=['urbansim'],
            test_data={
                "zone": {
                    "zone_id": array([1, 2, 3]),
                    "trip_weighted_travel_time_for_transit_walk": wtt_tw
                },
                "gridcell": {
                    "grid_id": array([1, 2, 3, 4, 5]),
                    "zone_id": locations_in_zoneid
                }
            })

        should_be = array([0.0, 0.0, 1, .250, .250])
        tester.test_is_equal_for_variable_defined_by_this_module(
            self, should_be)
Exemplo n.º 53
0
    def test_my_inputs(self):
        tester = VariableTester(
            __file__,
            package_order=['urbansim'],
            test_data={
                "gridcell":{
                    "grid_id":array([1,2,3,4]), 
                    },
                "building":{ 
                    "building_id": array([1,2,3,4,5]),
                    "grid_id":array([4,2,3,2,2]), 
                    "is_building_type_residential": array([0,1,1,1,0]),
                    "building_size": array([24, 60, 12, 5, 30]),
                    "total_residential_value": array([10, 0, 1, 3, 0])
                } 
            }
        )

        should_be = array([0, 5, 12, 0])              
        instance_name = "urbansim.gridcell.buildings_residential_space_where_total_value"  
        tester.test_is_equal_for_family_variable(self, should_be, instance_name)
Exemplo n.º 54
0
    def test_my_inputs(self):
        sqft_of_industrial_jobs = array([1225, 5000, 7500])
        industrial_sqft = array([1995, 10000, 7500])

        tester = VariableTester(__file__,
                                package_order=['urbansim'],
                                test_data={
                                    "gridcell": {
                                        "grid_id":
                                        array([1, 2, 3]),
                                        "sqft_of_industrial_jobs":
                                        sqft_of_industrial_jobs,
                                        "buildings_industrial_sqft":
                                        industrial_sqft,
                                    }
                                })

        should_be = array([770 / 1995.0, 5000 / 10000.0, 0])
        instance_name = "urbansim.gridcell.vacancy_rate_for_industrial_sqft"
        tester.test_is_close_for_family_variable(self, should_be,
                                                 instance_name)
    def test_my_inputs(self):
        tester = VariableTester(
            __file__,
            package_order=['urbansim'],
            test_data={
                "gridcell": {
                    "grid_id": array([1, 2, 3]),
                    "zone_id": array([1, 1, 3])
                },
                "zone": {
                    "zone_id":
                    array([1, 2, 3]),
                    "ln_access_from_residence_to_workplaces_2":
                    array([4.1, 5.3, 6.2])
                }
            })

        should_be = array([4.1, 4.1, 6.2])
        instance_name = "urbansim.gridcell.ln_access_from_residence_to_workplaces_2"
        tester.test_is_close_for_family_variable(self, should_be,
                                                 instance_name)
Exemplo n.º 56
0
    def test_my_inputs(self):
        number_of_households = array([1225, 5000, 7500])
        residential_units = array([1995, 10000, 7500])

        tester = VariableTester(__file__,
                                package_order=['urbansim'],
                                test_data={
                                    "gridcell": {
                                        "grid_id":
                                        array([1, 2, 3]),
                                        "number_of_households":
                                        number_of_households,
                                        "buildings_residential_space":
                                        residential_units
                                    }
                                })

        should_be = array([770, 5000, 0])
        instance_name = "urbansim.gridcell.vacant_residential_units_from_buildings"
        tester.test_is_equal_for_family_variable(self, should_be,
                                                 instance_name)
Exemplo n.º 57
0
    def test_my_inputs(self):
        gridcell_grid_id = array([1, 2, 3])
        hh_income = array([1000, 5000, 10000, 2000])
        household_grid_id = array([2, 3, 1, 2])

        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,
                                        "income": hh_income
                                    }
                                })

        should_be = array([10000, 3000, 5000])
        tester.test_is_equal_for_variable_defined_by_this_module(
            self, should_be)
Exemplo n.º 58
0
    def test_my_inputs(self):
        tester = VariableTester(
            __file__,
            package_order=['sanfrancisco', 'urbansim'],
            test_data={
                'business': {
                    "business_id": array([1, 2, 3, 4, 5]),
                    "sector_id": array([4, 2, 4, 3, 4])
                },
                'sector': {
                    "sector_id":
                    array([1, 2, 3, 4]),
                    "sector_name":
                    array(["others", "agr", "manufactural", "retail"])
                },
            })

        should_be = array([1, 0, 1, 0, 1])
        instance_name = 'sanfrancisco.business.is_of_sector_retail'
        tester.test_is_equal_for_family_variable(self, should_be,
                                                 instance_name)
Exemplo n.º 59
0
    def test_my_inputs(self):
        travel_time_to_cbd = array([0.0, 30.0, 60.0])
        locations_in_zoneid = array([1, 1, 3, 2, 2])

        tester = VariableTester(__file__,
                                package_order=['urbansim'],
                                test_data={
                                    "zone": {
                                        "zone_id": array([1, 2, 3]),
                                        "travel_time_to_cbd":
                                        travel_time_to_cbd
                                    },
                                    "gridcell": {
                                        "grid_id": array([1, 2, 3, 4, 5]),
                                        "zone_id": locations_in_zoneid
                                    }
                                })

        should_be = array([0.0, 0.0, 60.0, 30.0, 30.0])
        tester.test_is_equal_for_variable_defined_by_this_module(
            self, should_be)
Exemplo n.º 60
0
    def test_my_inputs(self):
        tester = VariableTester(__file__,
                                package_order=['urbansim'],
                                test_data={
                                    'gridcell': {
                                        'grid_id':
                                        array([1, 2, 3]),
                                        'residential_units':
                                        array([25, 50, 75]),
                                        'total_residential_value':
                                        array([10000, 10002, 300]),
                                    },
                                    'urbansim_constant': {
                                        'property_value_to_annual_cost_ratio':
                                        array([50]),
                                    }
                                })

        should_be = array([8.0, 4.0007996559, 0.0799999982])
        tester.test_is_close_for_variable_defined_by_this_module(
            self, should_be)