Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes deprecation warnings #572

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions aequilibrae/paths/sub_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ def __init__(
Construct a sub-area matrix from a provided sub-area GeoDataFrame using route choice.

This class aims to provide a semi-automated method for constructing the sub-area matrix. The user should provide
the Graph object, demand matrix, and a GeoDataFrame whose `unary_union` represents the desired sub-area. Perform
a route choice assignment, then call the `post_process` method to obtain a sub-area matrix.
the Graph object, demand matrix, and a GeoDataFrame whose geometry union represents the desired sub-area.
Perform a route choice assignment, then call the ``post_process`` method to obtain a sub-area matrix.

:Arguments:
**graph** (:obj:`Graph`): AequilibraE graph object to use
**subarea** (:obj:`geopandas.GeoDataFrame`): A GeoPandas GeoDataFrame whose `unary_union` represents the
**subarea** (:obj:`gpd.GeoDataFrame`): A GeoPandas GeoDataFrame whose geometry union represents the
sub-area.
**demand** (:obj:`Union[pandas.DataFrame, AequilibraeMatrix]`): The demand matrix to provide to the route
choice assignment.
Expand Down Expand Up @@ -63,7 +63,7 @@ def __init__(
self.sub_area_demand = None

links = gpd.GeoDataFrame(project.network.links.data)
self.interior_links = links[links.crosses(subarea.unary_union.boundary)].sort_index()
self.interior_links = links[links.crosses(subarea.union_all().boundary)].sort_index()

nodes = gpd.GeoDataFrame(project.network.nodes.data).set_index("node_id")
self.interior_nodes = nodes.sjoin(subarea, how="inner").sort_index()
Expand Down
1 change: 1 addition & 0 deletions aequilibrae/project/network/gmns_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def maybe_transform_srid(self, srid):

# For node table
lons, lats = transformer.transform(self.node_df.loc[:, "x_coord"], self.node_df.loc[:, "y_coord"])
self.node_df = self.node_df.astype({"x_coord": np.float64, "y_coord": np.float64})
self.node_df.loc[:, "x_coord"] = np.around(lons, decimals=10)
self.node_df.loc[:, "y_coord"] = np.around(lats, decimals=10)

Expand Down
7 changes: 4 additions & 3 deletions aequilibrae/project/network/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import shapely.wkb
import shapely.wkt
from shapely.geometry import Polygon, box
from shapely.ops import unary_union
from shapely import union_all

from aequilibrae.context import get_logger
from aequilibrae.parameters import Parameters
Expand Down Expand Up @@ -324,7 +324,8 @@ def build_graphs(self, fields: list = None, modes: list = None) -> None:

sql = f"select {','.join(all_fields)} from links"

df = pd.read_sql(sql, conn).fillna(value=np.nan)
with pd.option_context("future.no_silent_downcasting", True):
df = pd.read_sql(sql, conn).fillna(value=np.nan).infer_objects(False)
valid_fields = list(df.select_dtypes(np.number).columns) + ["modes"]
sql = "select node_id from nodes where is_centroid=1 order by node_id;"
centroids = np.array([i[0] for i in conn.execute(sql).fetchall()], np.uint32)
Expand Down Expand Up @@ -409,7 +410,7 @@ def convex_hull(self) -> Polygon:
with commit_and_close(connect_spatialite(self.project.path_to_file)) as conn:
sql = 'Select ST_asBinary("geometry") from Links where ST_Length("geometry") > 0;'
links = [shapely.wkb.loads(x[0]) for x in conn.execute(sql).fetchall()]
return unary_union(links).convex_hull
return union_all(links).convex_hull

def __count_items(self, field: str, table: str, condition: str) -> int:
with commit_and_close(connect_spatialite(self.project.path_to_file)) as conn:
Expand Down
4 changes: 2 additions & 2 deletions aequilibrae/project/zoning.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import geopandas as gpd
import shapely.wkb
from shapely.geometry import Point, Polygon, LineString, MultiLineString
from shapely.ops import unary_union
from shapely import union_all

from aequilibrae.project.basic_table import BasicTable
from aequilibrae.project.data_loader import DataLoader
Expand Down Expand Up @@ -90,7 +90,7 @@ def coverage(self) -> Polygon:
with commit_and_close(connect_spatialite(self.project.path_to_file)) as conn:
dt = conn.execute('Select ST_asBinary("geometry") from zones;').fetchall()
polygons = [shapely.wkb.loads(x[0]) for x in dt]
return unary_union(polygons)
return union_all(polygons)

def get(self, zone_id: str) -> Zone:
"""Get a zone from the model by its **zone_id**"""
Expand Down