Skip to content

Commit

Permalink
MAINT: handle scenarios leading to dimensions.StreetProfile() warnings (
Browse files Browse the repository at this point in the history
#389)

* address #388

* address #388 [2]

* 1 np.isnan call
  • Loading branch information
jGaboardi committed Sep 11, 2022
1 parent 67d9509 commit b2d8884
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions momepy/dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,21 @@ def __init__(
np.nanmean(rights) if ~np.isnan(rights).all() else tick_length / 2
)
widths.append(np.mean([left_mean, right_mean]) * 2)
openness.append(np.isnan(s).sum() / (f).sum())
deviations.append(np.nanstd(s))

f_sum = (f).sum()
s_nan = np.isnan(s)

if not f_sum:
openness_score = np.nan
else:
openness_score = s_nan.sum() / f_sum
openness.append(openness_score)

if s_nan.all():
deviation_score = np.nan
else:
deviation_score = np.nanstd(s)
deviations.append(deviation_score)

if do_heights:
b = blgs[f]
Expand Down

0 comments on commit b2d8884

Please sign in to comment.