Exemple #1
0
    def test_Queen_higher(self):
        first_order = libpysal.weights.Queen.from_dataframe(
            self.df_tessellation)
        from_sw = mm.Queen_higher(2, geodataframe=None, weights=first_order)
        from_df = mm.Queen_higher(2, geodataframe=self.df_tessellation)
        check = [133, 134, 111, 112, 113, 114, 115, 121, 125]
        assert from_sw.neighbors[0] == check
        assert from_df.neighbors[0] == check

        with pytest.raises(Warning):
            mm.Queen_higher(2, geodataframe=None, weights=None)

        with pytest.raises(ValueError):
            gdf = self.df_tessellation
            gdf.index = gdf.index + 20
            mm.Queen_higher(2, geodataframe=gdf, weights=None)
Exemple #2
0
 def test_mean_interbuilding_distance(self):
     self.df_buildings['m_dist'] = mm.mean_interbuilding_distance(
         self.df_buildings, self.df_tessellation, 'uID')
     sw = Queen.from_dataframe(self.df_tessellation)
     swh = mm.Queen_higher(k=3, geodataframe=self.df_tessellation)
     self.df_buildings['m_dist_sw'] = mm.mean_interbuilding_distance(
         self.df_buildings, self.df_tessellation, 'uID', sw, swh)
     check = 29.305457092042744
     assert self.df_buildings['m_dist'][0] == check
     assert self.df_buildings['m_dist_sw'][0] == check
Exemple #3
0
 def test_reached(self):
     count = mm.reached(self.df_streets, self.df_buildings, 'nID')
     area = mm.reached(self.df_streets,
                       self.df_buildings,
                       'nID',
                       mode='area')
     sw = mm.Queen_higher(k=2, geodataframe=self.df_streets)
     count_sw = mm.reached(self.df_streets, self.df_buildings, 'nID', sw)
     assert max(count) == 18
     assert max(area) == 18085.45897711331
     assert max(count_sw) == 138
Exemple #4
0
 def test_blocks_count(self):
     count = mm.blocks_count(self.df_tessellation,
                             'bID',
                             spatial_weights=None,
                             order=5)
     sw = mm.Queen_higher(k=5, geodataframe=self.df_tessellation)
     count2 = mm.blocks_count(self.df_tessellation,
                              'bID',
                              spatial_weights=sw)
     check = 3.142437439120778e-05
     assert count.mean() == check
     assert count2.mean() == check
Exemple #5
0
 def test_gross_density(self):
     dens = mm.gross_density(self.df_tessellation, self.df_buildings,
                             'area', 'fl_area')
     sw = mm.Queen_higher(k=3, geodataframe=self.df_tessellation)
     dens2 = mm.gross_density(self.df_tessellation,
                              self.df_buildings,
                              'area',
                              'fl_area',
                              spatial_weights=sw)
     check = 1.6615871155383324
     assert dens.mean() == check
     assert dens2.mean() == check
Exemple #6
0
 def test_building_adjacency(self):
     self.df_buildings['adj'] = mm.building_adjacency(
         self.df_buildings, self.df_tessellation)
     sw = Queen.from_dataframe(self.df_buildings)
     swh = mm.Queen_higher(k=3, geodataframe=self.df_tessellation)
     self.df_buildings['adj_sw'] = mm.building_adjacency(
         self.df_buildings,
         self.df_tessellation,
         spatial_weights=sw,
         spatial_weights_higher=swh)
     check = 0.2613824113909074
     assert self.df_buildings['adj'].mean() == check
     assert self.df_buildings['adj_sw'].mean() == check