From 23d3216d92d569d23dab7eb58864ac12b5d24154 Mon Sep 17 00:00:00 2001 From: Fabian Date: Tue, 5 Oct 2021 17:30:22 +0200 Subject: [PATCH] base_network.py: fix scipy spatial import --- scripts/base_network.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/base_network.py b/scripts/base_network.py index 4b85bb57..514e4dc3 100644 --- a/scripts/base_network.py +++ b/scripts/base_network.py @@ -70,9 +70,9 @@ import yaml import pandas as pd import geopandas as gpd import numpy as np -import scipy as sp import networkx as nx +from scipy import spatial from scipy.sparse import csgraph from itertools import product @@ -101,7 +101,7 @@ def _find_closest_links(links, new_links, distance_upper_bound=1.5): for s in links.geometry]) querycoords = np.vstack([new_links[['x1', 'y1', 'x2', 'y2']], new_links[['x2', 'y2', 'x1', 'y1']]]) - tree = sp.spatial.KDTree(treecoords) + tree = spatial.KDTree(treecoords) dist, ind = tree.query(querycoords, distance_upper_bound=distance_upper_bound) found_b = ind < len(links) found_i = np.arange(len(new_links)*2)[found_b] % len(new_links) @@ -214,7 +214,7 @@ def _add_links_from_tyndp(buses, links): links_tyndp = links_tyndp.loc[links_tyndp["j"].isnull()] if links_tyndp.empty: return buses, links - tree = sp.spatial.KDTree(buses[['x', 'y']]) + tree = spatial.KDTree(buses[['x', 'y']]) _, ind0 = tree.query(links_tyndp[["x1", "y1"]]) ind0_b = ind0 < len(buses) links_tyndp.loc[ind0_b, "bus0"] = buses.index[ind0[ind0_b]]