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_buildings["height"] = np.linspace(10.0, 30.0, 144)
self.df_buildings["volume"] = mm.Volume(self.df_buildings, "height").series
self.df_streets["nID"] = mm.unique_id(self.df_streets)
self.df_buildings["nID"] = mm.get_network_id(
self.df_buildings, self.df_streets, "nID"
)
).series
check = self.df_buildings.geometry[0].area * self.df_buildings.height[0]
assert self.df_buildings["volume"][0] == check
area = self.df_buildings.geometry.area
height = np.linspace(10.0, 30.0, 144)
self.df_buildings["volume"] = mm.Volume(self.df_buildings, height, area).series
check = self.df_buildings.geometry[0].area * self.df_buildings.height[0]
assert self.df_buildings["volume"][0] == check
self.df_buildings["volume"] = mm.Volume(self.df_buildings, "height").series
check = self.df_buildings.geometry[0].area * self.df_buildings.height[0]
assert self.df_buildings["volume"][0] == check
with pytest.raises(KeyError):
self.df_buildings["volume"] = mm.Volume(
self.df_buildings, "height", "nonexistent"
)
def test_Volume(self):
self.df_buildings["area"] = self.df_buildings.geometry.area
self.df_buildings["volume"] = mm.Volume(
self.df_buildings, "height", "area"
).series
check = self.df_buildings.geometry[0].area * self.df_buildings.height[0]
assert self.df_buildings["volume"][0] == check
area = self.df_buildings.geometry.area
height = np.linspace(10.0, 30.0, 144)
self.df_buildings["volume"] = mm.Volume(self.df_buildings, height, area).series
check = self.df_buildings.geometry[0].area * self.df_buildings.height[0]
assert self.df_buildings["volume"][0] == check
self.df_buildings["volume"] = mm.Volume(self.df_buildings, "height").series
check = self.df_buildings.geometry[0].area * self.df_buildings.height[0]
assert self.df_buildings["volume"][0] == check
with pytest.raises(KeyError):
def test_FormFactor(self):
self.df_buildings["ff"] = mm.FormFactor(self.df_buildings, "volume").series
check = (self.df_buildings.geometry[0].area) / (
self.df_buildings.volume[0] ** (2 / 3)
)
assert self.df_buildings["ff"][0] == check
self.df_buildings["ff"] = mm.FormFactor(
self.df_buildings,
mm.Volume(self.df_buildings, "height").series,
areas=self.df_buildings.geometry.area,
).series
check = (self.df_buildings.geometry[0].area) / (
self.df_buildings.volume[0] ** (2 / 3)
)
assert self.df_buildings["ff"][0] == check
def test_Volume(self):
self.df_buildings["area"] = self.df_buildings.geometry.area
self.df_buildings["volume"] = mm.Volume(
self.df_buildings, "height", "area"
).series
check = self.df_buildings.geometry[0].area * self.df_buildings.height[0]
assert self.df_buildings["volume"][0] == check
area = self.df_buildings.geometry.area
height = np.linspace(10.0, 30.0, 144)
self.df_buildings["volume"] = mm.Volume(self.df_buildings, height, area).series
check = self.df_buildings.geometry[0].area * self.df_buildings.height[0]
assert self.df_buildings["volume"][0] == check
self.df_buildings["volume"] = mm.Volume(self.df_buildings, "height").series
check = self.df_buildings.geometry[0].area * self.df_buildings.height[0]
assert self.df_buildings["volume"][0] == check
with pytest.raises(KeyError):
self.df_buildings["volume"] = mm.Volume(
self.df_buildings, "height", "nonexistent"
)
def test_VolumeFacadeRatio(self):
self.df_buildings["peri"] = self.df_buildings.geometry.length
self.df_buildings["vfr"] = mm.VolumeFacadeRatio(
self.df_buildings, "height", "volume", "peri"
).series
check = self.df_buildings.volume[0] / (
self.df_buildings.peri[0] * self.df_buildings.height[0]
)
assert self.df_buildings["vfr"][0] == check
peri = self.df_buildings.geometry.length
volume = mm.Volume(self.df_buildings, "height").series
self.df_buildings["vfr2"] = mm.VolumeFacadeRatio(
self.df_buildings, "height", volume, peri
).series
assert self.df_buildings["vfr2"][0] == check
self.df_buildings["peri"] = self.df_buildings.geometry.length
self.df_buildings["vfr3"] = mm.VolumeFacadeRatio(
self.df_buildings, "height"
).series
assert self.df_buildings["vfr3"][0] == check
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_buildings["height"] = np.linspace(10.0, 30.0, 144)
self.df_buildings["volume"] = mm.Volume(self.df_buildings, "height").series
def setup(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_buildings["height"] = np.linspace(10.0, 30.0, 144)
self.df_buildings["volume"] = mm.Volume(self.df_buildings, "height").series
self.df_streets["nID"] = mm.unique_id(self.df_streets)
self.df_buildings["nID"] = mm.get_network_id(
self.df_buildings, self.df_streets, "nID"
)
self.df_buildings["orient"] = mm.Orientation(self.df_buildings).series
self.df_tessellation["orient"] = mm.Orientation(self.df_tessellation).series
self.sw = Queen.from_dataframe(self.df_tessellation, ids="uID")
self.swh = mm.sw_high(k=3, gdf=self.df_tessellation, ids="uID")
self.swb = Queen.from_dataframe(self.df_buildings, ids="uID")