Skip to content

Commit

Permalink
_bearings_distribution: bin_centers terminology
Browse files Browse the repository at this point in the history
  • Loading branch information
dhimmel committed Mar 17, 2024
1 parent 016d3ca commit f39d6a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions osmnx/bearing.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,9 @@ def _bearings_distribution(
Returns
-------
bin_counts, bin_edges
Counts of bearings per bin and the bins edges.
bin_counts, bin_centers
Counts of bearings per bin and the bins' centers in degrees.
Both arrays are of length `num_bins`.
"""
n = num_bins * 2
bins = np.arange(n + 1) * 360 / n
Expand All @@ -282,6 +283,6 @@ def _bearings_distribution(
count = np.roll(count, 1)
bin_counts = count[::2] + count[1::2]

# because we merged the bins, their edges are now only every other one
bin_edges = bin_edges[range(0, len(bin_edges), 2)]
return bin_counts, bin_edges
# because we merged the bins, their centers are now only every other one
bin_centers = bin_edges[range(0, len(bin_edges) - 1, 2)]
return bin_counts, bin_centers
4 changes: 2 additions & 2 deletions osmnx/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ def plot_orientation( # noqa: PLR0913
}

# get the bearings' distribution's bin counts and edges
bin_counts, bin_edges = bearing._bearings_distribution(
bin_counts, bin_centers = bearing._bearings_distribution(
G,
num_bins,
min_length=min_length,
Expand All @@ -758,7 +758,7 @@ def plot_orientation( # noqa: PLR0913

# positions: where to center each bar. ignore the last bin edge, because
# it's the same as the first (i.e., 0 degrees = 360 degrees)
positions = np.radians(bin_edges[:-1])
positions = np.radians(bin_centers)

# width: make bars fill the circumference without gaps or overlaps
width = 2 * np.pi / num_bins
Expand Down

0 comments on commit f39d6a0

Please sign in to comment.