def test_my_inputs(self):
        tester = VariableTester(
            __file__,
            package_order=['urbansim'],
            test_data={
                'gridcell': {
                    'grid_id':
                    array([1, 2, 3, 4]),
                    'developable_maximum_commercial_sqft':
                    array([1200, 16, 3900, 15]),
                },
                'building_type': {
                    'building_type_id': array([1, 2]),
                    'name': array(['residential', 'commercial']),
                    'units': array(['residential_units', 'commercial_sqft'])
                }
            })

        should_be = array([1200, 16, 3900, 15])
        instance_name = "urbansim.gridcell.developable_commercial_capacity"
        tester.test_is_equal_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]),
                                        'average_income': array([150, 50,
                                                                 250]),
                                    },
                                    'household': {
                                        'household_id': array([1, 2, 3, 4]),
                                        'income': array([50, 100, 200, 300]),
                                    },
                                    'urbansim_constant': {
                                        'low_income_fraction': array([.25]),
                                        'mid_income_fraction': array([.25]),
                                    }
                                })

        should_be = array([0, 0, 1])
        tester.test_is_equal_for_variable_defined_by_this_module(
            self, should_be)
    def test_my_inputs2(self):
        tester = VariableTester(__file__,
                                package_order=['urbansim_parcel', 'urbansim'],
                                test_data={
                                    'development_project_proposal_component': {
                                        "proposal_component_id":
                                        arange(8) + 1,
                                        "building_type_id":
                                        array([1, 1, 1, 1, 2, 2, 2, 2]),
                                        "units_proposed":
                                        array([0, 1, 2, 3, 5, 15, 51, 999])
                                    },
                                    'velocity_function': {
                                        "velocity_function_id":
                                        arange(6) + 1,
                                        "annual_construction_schedule":
                                        array([
                                            "[100]", "[50, 100]",
                                            "[50, 75, 100]", "[25, 50, 100]",
                                            "[25, 50, 75, 100]",
                                            "[20, 40, 60, 80, 100]"
                                        ]),
                                        "building_type_id":
                                        array([1, 1, 1, 2, 2, 2]),
                                        "minimum_units":
                                        array([0, 3, 6, 0, 11, 51]),
                                        "maximum_units":
                                        array([2, 5, 10, 10, 50, 1000])
                                    }
                                })

        should_be = array([
            '[100]', '[100]', '[100]', '[50, 100]', '[25, 50, 100]',
            '[25, 50, 75, 100]', '[20, 40, 60, 80, 100]',
            '[20, 40, 60, 80, 100]'
        ])
        tester.test_is_equal_for_variable_defined_by_this_module(
            self, should_be)
    def test_my_inputs(self):
        """Number of homes with workers 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])
        w = array([0, 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,
                                        "workers": w
                                    }
                                })

        should_be = array([2, 0, 1])
        tester.test_is_close_for_variable_defined_by_this_module(
            self, should_be)
Esempio n. 5
0
    def test_my_inputs(self):
        high_income = array(
            [1, 0, 1,
             0])  #specify the total income for each of three locations
        units = array([5, 4, 8, 3])

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

        should_be = array(
            [1, 0, 0,
             0])  #would be a 2-D array if it spanned more than one "directory"
        instance_name = "urbansim.gridcell.is_average_income_high_income_and_has_1_to_5_units"
        tester.test_is_equal_for_family_variable(self, should_be,
                                                 instance_name)
 def test(self):
     zone_id = array([1, 2, 3, 4, 5])
     job_zone_id = array([1, 2, 3, 4, 2, 2])
     
     tester = VariableTester(
         __file__,
         package_order=['urbansim'],
         test_data={
             "gridcell":{ 
                 "grid_id":zone_id
                 }, 
             "job":{
                 "job_id":array([1,2,3,4,5,6]),
                 "grid_id":job_zone_id,
                 "potential_movers": array([1,1,0,0,0,1]),
                 "is_building_type_commercial": array([1,0,1,1,0,0])
             }
         }
     )
     
     should_be = array([1,0,0,0,0])
     instance_name = "urbansim.gridcell.number_of_potential_commercial_job_movers"
     tester.test_is_equal_for_family_variable(self, should_be, instance_name)
Esempio n. 7
0
 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)
Esempio n. 8
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])
                                    }
                                })

        should_be = array([0, 65, 12, 0])
        instance_name = "urbansim.gridcell.buildings_residential_space"
        tester.test_is_equal_for_family_variable(self, should_be,
                                                 instance_name)
Esempio n. 9
0
    def test_my_inputs(self):
        number_of_industrial_jobs = array([12, 0, 39, 0])
        industrial_sqft = array([1200, 16, 3900, 15])
        industrial_sqft_per_job = array([20, 3, 30, 0])

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

        should_be = array([48.0, 5.0, 91.0, 0.0])
        tester.test_is_equal_for_variable_defined_by_this_module(
            self, should_be)
Esempio n. 10
0
    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]),
                    'residential_units':
                    array([0, 2, 3, 0, 2, 3, 4, 1, 0, 5]),
                    'sqft_per_unit':
                    array([0, 2, 2, 0, 10, 5, 2, 20, 0, 20]),
                    'non_residential_sqft':
                    array([19, 0, 310, 400, 0, 223, 58, 0, 0, 0]),
                    'is_residential':
                    array([0, 1, 0, 0, 1, 0, 0, 1, 1, 1], dtype="bool8")
                },
            })

        should_be = array([19, 2, 316, 400, 2, 223 + 15, 8 + 58, 1, 0, 5])

        tester.test_is_close_for_variable_defined_by_this_module(
            self, should_be)
Esempio n. 11
0
    def test(self):
        zone_id = array([1, 2, 3, 4, 5])
        hh_zone_id = array([1, 2, 3, 4, 2, 2])

        tester = VariableTester(__file__,
                                package_order=['urbansim'],
                                test_data={
                                    "gridcell": {
                                        "grid_id": zone_id
                                    },
                                    "household": {
                                        "household_id":
                                        array([1, 2, 3, 4, 5, 6]),
                                        "grid_id":
                                        hh_zone_id,
                                        "potential_movers":
                                        array([1, 1, 0, 0, 0, 1])
                                    }
                                })

        should_be = array([1, 2, 0, 0, 0])
        tester.test_is_equal_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]),
                    'number_of_development_type_group_residential_within_walking_distance':
                    array([3, 5, 1, 0]),
                },
                'urbansim_constant': {
                    "walking_distance_circle_radius": array([150]),
                    'cell_size': array([150]),
                }
            })

        should_be = array([
            3 / 5.0 * 100.0, 5 / 5.0 * 100.0, 1 / 5.0 * 100.0, 0 / 5.0 * 100.0
        ])
        instance_name = "urbansim.gridcell.percent_residential_within_walking_distance"
        tester.test_is_close_for_family_variable(self, should_be,
                                                 instance_name)
Esempio n. 13
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]),
                                        "x_coord_sp": array([1, 2, 3, 3, 1]),
                                        "y_coord_sp": array([1, 1, 1, 2, 4]),
                                    },
                                    'busstop': {
                                        "busstop_id":
                                        array([1, 2, 3, 4, 5, 6, 7]),
                                        "point_x": array([1, 2, 3, 2, 2, 1,
                                                          3]),
                                        "point_y": array([1, 1, 1, 2, 2, 1,
                                                          3]),
                                    },
                                })
        should_be = array([0, 0, 0, 1, 2])

        instance_name = 'urbansim_parcel.parcel.distance_to_busstop_dataset'
        tester.test_is_equal_for_family_variable(self, should_be,
                                                 instance_name)
Esempio n. 14
0
    def test_my_inputs(self):
        """If cell.distance_to_highway < NearHighwayThreshold then 1 else 0."""
        #we assume that the distance is measured from the gridcell border to the arterial
        tester = VariableTester(
            __file__,
            package_order=['urbansim'],
            test_data={
                'gridcell': {
                    'grid_id':
                    array([1, 2, 3, 4, 5, 6]),
                    'distance_to_highway':
                    array([0.0, 50.0, 99.0, 100.0, 101.0, 200.0]),
                },
                'urbansim_constant': {
                    'cell_size': array([150]),
                    'near_highway_threshold': array([100]),
                    'units': array(['meters']),
                }
            })

        should_be = array([True, True, True, False, False, False])
        tester.test_is_equal_for_variable_defined_by_this_module(
            self, should_be)
Esempio n. 15
0
    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, 1, 1, 1]),
                    "job_capacity_computed_if_necessary":
                    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, 1, 2, 4])

        tester.test_is_close_for_variable_defined_by_this_module(
            self, should_be)
Esempio n. 16
0
    def test_my_inputs(self):
        number_of_home_owners_within_walking_distance = array(
            [0, 333, 500, 100])
        number_of_households_within_walking_distance = array(
            [500, 501, 500, 0])

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

        should_be = array([0.0, 333 / 501.0 * 100.0, 100.0, 0.0])
        tester.test_is_close_for_variable_defined_by_this_module(
            self, should_be)
Esempio n. 17
0
    def test_my_inputs(self):
        governmental_improvement_value = array([100, 200, 300])
        commercial_improvement_value = array([1000, 400, 0])
        industrial_improvement_value = array([10000000000, 800, 700])

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

        should_be = array([10000001100, 1400, 1000])
        tester.test_is_equal_for_variable_defined_by_this_module(
            self, should_be)
Esempio n. 18
0
    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_industrial = array([0, 1, 1, 1])

        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_industrial": is_industrial
                                    }
                                })

        should_be = array([2, 0, 1])
        tester.test_is_close_for_variable_defined_by_this_module(
            self, should_be)
Esempio n. 19
0
    def test_my_inputs(self):
        avg_income = array([1000, 10000, 100000]) #specify the total income for each of three locations
        units = 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]),
                    "average_income":avg_income,
                    "residential_units":units
                }
            }
        )
        #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)
Esempio n. 20
0
 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]),
                    "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]),
                    "non_residential_sqft": array([1,2,2,1,7,0,3,5,4,6])*1000,
          "occupied_building_sqft_by_jobs": array([500, 2100, 0, 0, 6000, 100, 3000, 1000, 0, 5999])
                                    #vacant sqft:  500, 0,  2000, 1000, 1000, 0, 0, 4000, 4000, 1  
             },
         "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]),
             },                          
     }
     )
     
     should_be = array([5, 0, 2000/80, 1000/60, 1000/50, 0, 0, 4000/10, 4000/60, 0])
     
     tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
Esempio n. 21
0
    def test_my_inputs(self):
        tester = VariableTester(
            __file__,
            package_order=['urbansim_parcel','urbansim'],
            test_data={
            "development_project_proposal_component":{"proposal_component_id":array([1,2,3,4,5,6,7,8,9,10]),
                                                      "building_type_id":     array([1,2,2,2,1,2,1,3,2,2]),
                                                      "job_capacity_computed":        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]),
#                        "unit_name":           array(["building_sqft","residential_units","residential_units","residential_units",
#                          'building_sqft',"residential_units","building_sqft", "parcel_sqft", 
#                          "residential_units","residential_units",]),                                                      
                },
           "building_type":{
                        "building_type_id":    array([1, 2, 3]),
                        "is_residential":      array([0, 1, 0]),
                        }                
        }
        )
        
        should_be = array([1000, 3, 1, 2, 1000,  1, 3000, 1000, 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=['psrc', 'urbansim_parcel', 'urbansim', 'opus_core'],
         test_data={
         "building":{ 
              "building_id": array([1,2,3,4]),
              "area_type":   array([1,3,1,2])
                        }, 
         "household":{ 
              "household_id":array([1,2,3,4,5,6]),
              "building_id": array([1,1,3,2,4,2])
                           },
         "person":{
              "person_id":    array([1,2,3,4,5,6,7,8]),
              "household_id": array([1,2,2,2,3,4,5,6]),
             #"area_type":    array([1,1,1,1,1,3,2,3])
              },
         "job":{
              "job_id":      array([1,2,3,4,5]),
              "building_id": array([1,3,4,1,4]),
             #"area_type":   array([1,1,2,1,2])
                    }
          })
     should_be = array([[0,0,1,0,1],
                        [0,0,1,0,1],
                        [0,0,1,0,1],
                        [0,0,1,0,1],
                        
                        [0,0,1,0,1],
                        [0,0,0,0,0],
                        [0,0,0,0,0],
                        [0,0,0,0,0],
                    ])
                         
     instance_name = 'psrc_parcel.person_x_job.home_area_type_1_workplace_area_type_2'
     tester.test_is_equal_for_family_variable(self, should_be, instance_name)
Esempio n. 23
0
    def test_my_inputs(self):
        tester = VariableTester(
            __file__,
            package_order=['psrc', 'urbansim_parcel', 'urbansim', 'opus_core'],
            test_data={
                "building": {
                    "building_id": array([1, 2, 3, 4]),
                    "area_type": array([1, 3, 1, 2])
                },
                "household": {
                    "household_id": array([1, 2, 3, 4, 5, 6]),
                    "building_id": array([1, 1, 3, 2, 4, 2])
                },
                "person": {
                    "person_id": array([1, 2, 3, 4, 5, 6, 7, 8]),
                    "household_id": array([1, 2, 2, 2, 3, 4, 5, 6]),
                    #"area_type":    array([1,1,1,1,1,3,2,3])
                },
                "job": {
                    "job_id": array([1, 2, 3, 4, 5]),
                    "building_id": array([1, 3, 4, 1, 4]),
                    #"area_type":   array([1,1,2,1,2])
                }
            })
        should_be = array([
            [1, 1, 0, 1, 0],
            [1, 1, 0, 1, 0],
            [1, 1, 0, 1, 0],
            [1, 1, 0, 1, 0],
            [1, 1, 0, 1, 0],
            [0, 0, 0, 0, 0],
            [0, 0, 1, 0, 1],
            [0, 0, 0, 0, 0],
        ])

        tester.test_is_close_for_variable_defined_by_this_module(
            self, should_be)
    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)
    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,
                    ]),
                    'faz_id': array([
                        1,
                        2,
                        2,
                        3,
                        4,
                    ]),
                },
                'faz': {
                    'faz_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=['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]),
                },
            })
        # 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)
Esempio n. 27
0
    def test_my_inputs(self):
        zone_id = array([1, 1, 3, 2])
        twauht_work_ai_3 = 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]),
                    "trip_weighted_average_utility_hbw_to_work_am_income_3":
                    twauht_work_ai_3
                }
            })

        should_be = array([4.1, 4.1, 6.2, 5.3])
        instance_name = "urbansim.gridcell.trip_weighted_average_utility_hbw_to_work_am_income_3"
        tester.test_is_close_for_family_variable(self, should_be,
                                                 instance_name)
    def test_my_inputs(self):
        number_of_commercial_jobs = array([12, 39, 0, 10])
        commercial_sqft = array([1205, 16, 3900, 15])
        commercial_sqft_per_job = array([20, 3, 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,
                                        "buildings_commercial_sqft":
                                        commercial_sqft,
                                        "commercial_sqft_per_job":
                                        commercial_sqft_per_job
                                    }
                                })

        should_be = array([60 - 12, 0, 3900 / 30, 0])
        instance_name = "urbansim.gridcell.vacant_commercial_job_space_from_buildings"
        tester.test_is_equal_for_family_variable(self, should_be,
                                                 instance_name)
Esempio n. 29
0
    def test_my_inputs(self):
        home_access_to_employment = array([0.0, 5000.0, 12000.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]),
                    "home_access_to_employment_2":home_access_to_employment
                    },
                "gridcell":{ 
                    "grid_id":array([1,2,3,4,5]),
                    "zone_id":locations_in_zoneid
                }
            }
        )

        # since we're using bounded log, we get 0.0 for the 0 value of home_access_to_employment
        should_be = array([0.0, 0.0, log(12000.0), log(5000.0), log(5000.0)])
        # The number of cars is 2 in this test
        instance_name = "urbansim.gridcell.ln_home_access_to_employment_2"
        tester.test_is_close_for_family_variable(self, should_be, instance_name)
Esempio n. 30
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, 6]),
                                        'building_type_id':
                                        array([1, 2, 1, 2, 1, 1]),
                                        'grid_id':
                                        array([2, 3, 1, 1, 2, 1])
                                    },
                                    'building_type': {
                                        'building_type_id': array([1, 2]),
                                        'name': array(['foo', 'commercial'])
                                    }
                                })

        should_be = array([0, 0, 0, 1])
        tester.test_is_equal_for_variable_defined_by_this_module(
            self, should_be)