Repository: martinfleis/momepy
Pull request #86 (2019-09-27 11:42:35)

API: remove uID from get_network_id
`uID` is not used anyway in the script

codecov[bot]: # [Codecov](https://codecov.io/gh/martinfleis/momepy/pull/86?src=pr&el=h1) Report
> Merging [#86](https://codecov.io/gh/martinfleis/momepy/pull/86?src=pr&el=desc) into [master](https://codecov.io/gh/martinfleis/momepy/commit/0bb1eabf158bdf12a010a00ba27df7a717aa9490?src=pr&el=desc) will **increase** coverage by `0.07%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/martinfleis/momepy/pull/86/graphs/tree.svg?width=650&token=i04999UxkK&height=150&src=pr)](https://codecov.io/gh/martinfleis/momepy/pull/86?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##           master     #86      +/-   ##
=========================================
+ Coverage   93.22%   93.3%   +0.07%     
=========================================
  Files           9       9              
  Lines        2421    2418       -3     
=========================================
- Hits         2257    2256       -1     
+ Misses        164     162       -2
```


| [Impacted Files](https://codecov.io/gh/martinfleis/momepy/pull/86?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [momepy/elements.py](https://codecov.io/gh/martinfleis/momepy/pull/86/diff?src=pr&el=tree#diff-bW9tZXB5L2VsZW1lbnRzLnB5) | `92.04% <100%> (+0.46%)` | :arrow_up: |
| [momepy/dimension.py](https://codecov.io/gh/martinfleis/momepy/pull/86/diff?src=pr&el=tree#diff-bW9tZXB5L2RpbWVuc2lvbi5weQ==) | `97.19% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/martinfleis/momepy/pull/86?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/martinfleis/momepy/pull/86?src=pr&el=footer). Last update [0bb1eab...6518dd5](https://codecov.io/gh/martinfleis/momepy/pull/86?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/momepy/dimension.py b/momepy/dimension.py
index edde993..2f97925 100644
--- a/momepy/dimension.py
+++ b/momepy/dimension.py
@@ -411,7 +411,7 @@ class AverageCharacter:
             if rng:
                 from momepy import limit_range
 
-                values_list = limit_range(values_list.tolist(), rng=rng)
+                values_list = limit_range(values_list, rng=rng)
             if mode == "mean":
                 results_list.append(np.mean(values_list))
             elif mode == "median":
diff --git a/momepy/elements.py b/momepy/elements.py
index 38e3d83..f317986 100644
--- a/momepy/elements.py
+++ b/momepy/elements.py
@@ -630,7 +630,7 @@ class Blocks:
         self.tessellation_id = cells_m[id_name]
 
 
-def get_network_id(left, right, unique_id, network_id, min_size=100):
+def get_network_id(left, right, network_id, min_size=100):
     """
     Snap each element (preferably building) to the closest street network segment, saves its id.
 
@@ -643,8 +643,6 @@ def get_network_id(left, right, unique_id, network_id, min_size=100):
     right : GeoDataFrame
         GeoDataFrame containing street network with unique network ID.
         If there is none, it could be generated by :py:func:`momepy.elements.unique_id`.
-    unique_id : str, list, np.array, pd.Series (default None)
-        the name of the left dataframe column, np.array, or pd.Series with unique id
     network_id : str, list, np.array, pd.Series (default None)
         the name of the streets dataframe column, np.array, or pd.Series with network unique id.
     min_size : int (default 100)
@@ -659,7 +657,7 @@ def get_network_id(left, right, unique_id, network_id, min_size=100):
 
     Examples
     --------
-    >>> buildings_df['nID'] = momepy.get_network_id(buildings_df, streets_df, 'uID', 'nID')
+    >>> buildings_df['nID'] = momepy.get_network_id(buildings_df, streets_df, 'nID')
     Generating centroids...
     Generating rtree...
     Snapping: 100%|██████████| 144/144 [00:00<00:00, 2718.98it/s]
@@ -675,9 +673,6 @@ def get_network_id(left, right, unique_id, network_id, min_size=100):
     left = left.copy()
     right = right.copy()
 
-    if not isinstance(unique_id, str):
-        left["mm_uid"] = unique_id
-        unique_id = "mm_uid"
     if not isinstance(network_id, str):
         right["mm_nid"] = network_id
         network_id = "mm_nid"


Test patch:
diff --git a/tests/test_distribution.py b/tests/test_distribution.py
index b65ef37..45bcc98 100644
--- a/tests/test_distribution.py
+++ b/tests/test_distribution.py
@@ -16,7 +16,7 @@ class TestDistribution:
         self.df_buildings["volume"] = mm.Volume(self.df_buildings, "height").volume
         self.df_streets["nID"] = mm.unique_id(self.df_streets)
         self.df_buildings["nID"] = mm.get_network_id(
-            self.df_buildings, self.df_streets, "uID", "nID"
+            self.df_buildings, self.df_streets, "nID"
         )
 
     def test_Orientation(self):
diff --git a/tests/test_elements.py b/tests/test_elements.py
index 2ae516a..520042d 100644
--- a/tests/test_elements.py
+++ b/tests/test_elements.py
@@ -35,14 +35,14 @@ class TestElements:
 
     def test_get_network_id(self):
         buildings_id = mm.get_network_id(
-            self.df_buildings, self.df_streets, "uID", "nID"
+            self.df_buildings, self.df_streets, "nID"
         )
         assert not buildings_id.isna().any()
 
     def test_get_network_id_duplicate(self):
         self.df_buildings["nID"] = range(len(self.df_buildings))
         buildings_id = mm.get_network_id(
-            self.df_buildings, self.df_streets, "uID", "nID"
+            self.df_buildings, self.df_streets, "nID"
         )
         assert not buildings_id.isna().any()
 
@@ -50,7 +50,7 @@ class TestElements:
         nx = mm.gdf_to_nx(self.df_streets)
         nodes, edges = mm.nx_to_gdf(nx)
         self.df_buildings["nID"] = mm.get_network_id(
-            self.df_buildings, self.df_streets, "uID", "nID"
+            self.df_buildings, self.df_streets, "nID"
         )
         ids = mm.get_node_id(self.df_buildings, nodes, edges, "nodeID", "nID")
         assert not ids.isna().any()
diff --git a/tests/test_intensity.py b/tests/test_intensity.py
index f5532e2..210fab6 100644
--- a/tests/test_intensity.py
+++ b/tests/test_intensity.py
@@ -19,7 +19,7 @@ class TestIntensity:
         self.df_buildings["area"] = self.df_buildings.geometry.area
         self.df_buildings["fl_area"] = mm.FloorArea(self.df_buildings, "height").fa
         self.df_buildings["nID"] = mm.get_network_id(
-            self.df_buildings, self.df_streets, "uID", "nID"
+            self.df_buildings, self.df_streets, "nID"
         )
         blocks = mm.Blocks(
             self.df_tessellation, self.df_streets, self.df_buildings, "bID", "uID"