-
Notifications
You must be signed in to change notification settings - Fork 58
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
BUG: refactor computation of angles in COINS #632
Conversation
momepy/coins.py
Outdated
|
||
assert Counter(points.values()) == {1: 2, 2: 1} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this assertion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're accounting for the unwanted cases before that, so yes we can remove it
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #632 +/- ##
=======================================
+ Coverage 97.4% 97.8% +0.4%
=======================================
Files 26 38 +12
Lines 4328 6215 +1887
=======================================
+ Hits 4214 6079 +1865
- Misses 114 136 +22
|
Co-authored-by: Martin Fleischmann <martin@martinfleischmann.net>
Co-authored-by: Martin Fleischmann <martin@martinfleischmann.net>
momepy/coins.py
Outdated
) | ||
# assertion: we expect exactly 2 of the 4 points to be identical | ||
# (lines touch in this point) | ||
points = Counter([a, b, c, d]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one of (many!!) options to figure out which two of the four points in the vectors (a,b) and (c,d) are identical
@@ -126,7 +130,7 @@ def _split_lines(self): | |||
out_line.append( | |||
[ | |||
part, | |||
_compute_orientation(part), | |||
[], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since the COINS algorithm operates with position-based (index-based) attributes of lines, the very first attribute being "orientation": this is now obsolete, so this list will always be empty (we're not computing orientation anymore), but keeping it there nevertheless for the moment not to mess up with the index-based accessing of attributes in the rest of the algorithm. (would probably require major refactoring if we wanted to get rid of this issue, for now i guess it's best just not to touch it)
One thing I am not super excited about is that this significantly affects performance. On the network from the user guide: main: |
(sorry for interfering - again)
I have noticed a similar performance degradation when testing for #630 . I think it is the overhead of creating many very small numpy arrays, as this is carried for each of the line segments in the network. In the test I have run, using native python types and functions from |
And with a6fcacb to |
You do not need to apologize and you are not interferring! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all good with me!
How about this 310 error? |
@jGaboardi present on main https://github.com/pysal/momepy/actions/runs/9688801724/job/26747565038 and has nothing to do with our code. xref #634 |
Based on #629 (solved) and #630 (superseded)
Refactor computation of interior angle between 2 lines.
Previously, the interior angle between 2 lines was computed by:
this is now simplified into making use of the fact that by definition, the two lines we're computing interior angles between will always start in the same point, hence we can reduce the entire problem to the computation of an angle between 2 vectors in 2dim space from the same origin, hence referencing the horizontal plane // orientation // direction becomes obsolete. this pr supersedes #630 in that orientation is dropped completely from the code.
just for the records, the bug mentioned in #629 resulted from the fact that the use case of sharp angles (<90deg) was not considered in the use case distinction.
thanks to @fnattino for the input!!
Fixes #629 and closes #630