Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup_method(self):
test_file_path = mm.datasets.get_path("bubenec")
self.df_buildings = gpd.read_file(test_file_path, layer="buildings")
self.df_streets = gpd.read_file(test_file_path, layer="streets")
self.df_tessellation = gpd.read_file(test_file_path, layer="tessellation")
self.df_streets["nID"] = mm.unique_id(self.df_streets)
self.df_buildings["height"] = np.linspace(10.0, 30.0, 144)
self.df_tessellation["area"] = self.df_tessellation.geometry.area
self.df_buildings["area"] = self.df_buildings.geometry.area
self.df_buildings["fl_area"] = mm.FloorArea(self.df_buildings, "height").series
self.df_buildings["nID"] = mm.get_network_id(
self.df_buildings, self.df_streets, "nID"
)
blocks = mm.Blocks(
self.df_tessellation, self.df_streets, self.df_buildings, "bID", "uID"
)
self.blocks = blocks.blocks
self.df_buildings["bID"] = blocks.buildings_id
def test_network_false_nodes(self):
test_file_path2 = mm.datasets.get_path("tests")
self.false_network = gpd.read_file(test_file_path2, layer="network")
self.false_network["vals"] = range(len(self.false_network))
fixed = mm.network_false_nodes(self.false_network)
assert len(fixed) == 56
assert isinstance(fixed, gpd.GeoDataFrame)
assert self.false_network.crs.equals(fixed.crs)
assert sorted(self.false_network.columns) == sorted(fixed.columns)
fixed_series = mm.network_false_nodes(self.false_network.geometry)
assert len(fixed_series) == 56
assert isinstance(fixed_series, gpd.GeoSeries)
assert self.false_network.crs.equals(fixed_series.crs)
with pytest.raises(TypeError):
mm.network_false_nodes(list())
multiindex = self.false_network.explode()
fixed_multiindex = mm.network_false_nodes(multiindex)
assert len(fixed_multiindex) == 56
def test_preprocess(self):
test_file_path2 = mm.datasets.get_path("tests")
self.os_buildings = gpd.read_file(test_file_path2, layer="os")
processed = mm.preprocess(self.os_buildings)
assert len(processed) == 5