Skip to content

Commit

Permalink
Merge branch 'v2' into typing
Browse files Browse the repository at this point in the history
  • Loading branch information
gboeing authored Jan 16, 2024
2 parents 2af97ef + 3cf440e commit 1a5974d
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
push:
branches: [main]
branches: [main, typing]
pull_request:
branches: [main]
branches: [main, v2]
schedule:
- cron: "0 6 * * 1" # Every Monday at 06:00 UTC

Expand All @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest]

defaults:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
## 1.x.x (Unreleased)

- fix a bug in the features module's polygon handling (#1104)
- update obsolete numpy random number generation (#1108)
- deprecate return_coords argument in graph.graph_from_address function (#1105)
- deprecate return_hex argument in plot.get_colors function (#1109)

## 1.8.1 (2023-12-31)

Expand Down
2 changes: 1 addition & 1 deletion osmnx/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""OSMnx package version information."""

__version__ = "1.8.1"
__version__ = "2.0.0-dev"
4 changes: 2 additions & 2 deletions osmnx/utils_geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def sample_points(G: nx.MultiGraph, n: int) -> gpd.GeoSeries:
warn("graph should be undirected to avoid oversampling bidirectional edges", stacklevel=2)
gdf_edges = utils_graph.graph_to_gdfs(G, nodes=False)[["geometry", "length"]]
weights = gdf_edges["length"] / gdf_edges["length"].sum()
idx = np.random.choice(gdf_edges.index, size=n, p=weights)
idx = np.random.default_rng().choice(gdf_edges.index, size=n, p=weights)
lines = gdf_edges.loc[idx, "geometry"]
return lines.interpolate(np.random.rand(n), normalized=True)
return lines.interpolate(np.random.default_rng().random(n), normalized=True)


def interpolate_points(geom: LineString, dist: float) -> Generator[tuple[float, float], None, None]:
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,13 @@ extend-select = [
"EM", # check raw literals inside exception raising
"ERA", # check commented-out code from python files a la eradicate
"F", # check python source code for errors a la pyflakes
"FA", # check from __future__ import annotations
"FIX", # check temporary developer notes a la flake8-fixme
#"FURB", # check code improvements a la refurb (preview)
"G", # check logging string formatting a la flake8-logging-format
"I", # check isort imports
#"LOG", # check logging module usage a la flake8-logging (preview)
"NPY", # check numpy usage
"PD", # check pandas linting a la pandas-vet
"PERF", # check performance anti-patterns a la perflint
"PGH", # check pygrep hooks
Expand Down
2 changes: 1 addition & 1 deletion tests/environments/env-test-minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- networkx=2.5
- numpy=1.20
- pandas=1.1
- python=3.8 # pin to minimum version from /pyproject.toml
- python=3.9 # pin to minimum version from /pyproject.toml
- requests=2.27
- shapely=2.0

Expand Down
12 changes: 6 additions & 6 deletions tests/test_osmnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ def test_routing() -> None:
# test multiple origins-destinations
n = 5
nodes = np.array(G.nodes)
origs = [int(x) for x in np.random.choice(nodes, size=n, replace=True)]
dests = [int(x) for x in np.random.choice(nodes, size=n, replace=True)]
origs = [int(x) for x in np.random.default_rng().choice(nodes, size=n, replace=True)]
dests = [int(x) for x in np.random.default_rng().choice(nodes, size=n, replace=True)]
paths1 = ox.shortest_path(G, origs, dests, weight="length", cpus=1)
paths2 = ox.shortest_path(G, origs, dests, weight="length", cpus=2)
paths3 = ox.shortest_path(G, origs, dests, weight="length", cpus=None)
Expand Down Expand Up @@ -506,16 +506,16 @@ def test_graph_save_load() -> None:
# create random boolean graph/node/edge attributes
attr_name = "test_bool"
G.graph[attr_name] = False
bools = np.random.randint(0, 2, len(G.nodes))
bools = np.random.default_rng().integers(low=0, high=2, size=len(G.nodes))
node_attrs = {n: bool(b) for n, b in zip(G.nodes, bools)}
nx.set_node_attributes(G, node_attrs, attr_name)
bools = np.random.randint(0, 2, len(G.edges))
bools = np.random.default_rng().integers(low=0, high=2, size=len(G.edges))
edge_attrs = {n: bool(b) for n, b in zip(G.edges, bools)}
nx.set_edge_attributes(G, edge_attrs, attr_name)

# create list, set, and dict attributes for nodes and edges
rand_ints_nodes = np.random.randint(0, 10, len(G.nodes))
rand_ints_edges = np.random.randint(0, 10, len(G.edges))
rand_ints_nodes = np.random.default_rng().integers(low=0, high=10, size=len(G.nodes))
rand_ints_edges = np.random.default_rng().integers(low=0, high=10, size=len(G.edges))
list_node_attrs = {n: [n, r] for n, r in zip(G.nodes, rand_ints_nodes)}
nx.set_node_attributes(G, list_node_attrs, "test_list")
list_edge_attrs = {e: [e, r] for e, r in zip(G.edges, rand_ints_edges)}
Expand Down

0 comments on commit 1a5974d

Please sign in to comment.