Repository: martinfleis/momepy (python)

Issue:
BUG: street profile will not run without set building height
`StreetProfile` should run even without building data, providing partial results. However, there is a bug at the moment causing the whole script to fail if height is None.

Pull request:
BUG: StreetProfile did not run without height
Fixes #93

Patch:
diff --git a/momepy/dimension.py b/momepy/dimension.py
index aa870c1..48c33ed 100644
--- a/momepy/dimension.py
+++ b/momepy/dimension.py
@@ -499,12 +499,13 @@ class StreetProfile:
         self.distance = distance
         self.tick_length = tick_length
 
-        if not isinstance(heights, str):
-            right = right.copy()
-            right["mm_h"] = heights
-            heights = "mm_h"
+        if heights is not None:
+            if not isinstance(heights, str):
+                right = right.copy()
+                right["mm_h"] = heights
+                heights = "mm_h"
 
-        self.heights = right[heights]
+            self.heights = right[heights]
 
         sindex = right.sindex
 


Test patch:
diff --git a/tests/test_dimension.py b/tests/test_dimension.py
index 54453ec..ad21fec 100644
--- a/tests/test_dimension.py
+++ b/tests/test_dimension.py
@@ -170,6 +170,11 @@ class TestDimensions:
         assert results2.o[0] == 0.5535714285714286
         assert results2.hd[0] == 5.526848034418866
 
+        results3 = mm.StreetProfile(self.df_streets, self.df_buildings)
+        assert results3.w[0] == 46.7290758769204
+        assert results3.wd[0] == 0.5690458650581023
+        assert results3.o[0] == 0.9107142857142857
+
     def test_WeightedCharacter(self):
         sw = sw_high(k=3, gdf=self.df_tessellation, ids="uID")
         weighted = mm.WeightedCharacter(self.df_buildings, "height", sw, "uID").wc