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

ENH: improved node consolidation functions #377

Merged
merged 32 commits into from
Jan 23, 2024
Merged

Conversation

gsagostini
Copy link
Contributor

Function for consolidating intersections on street networks based on graph-distances along with edge reconstruction. Tests to come.

momepy/preprocessing.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Aug 9, 2022

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (24672bf) 97.5% compared to head (e0949e4) 97.4%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main    #377     +/-   ##
=======================================
- Coverage   97.5%   97.4%   -0.2%     
=======================================
  Files         26      26             
  Lines       4189    4317    +128     
=======================================
+ Hits        4086    4203    +117     
- Misses       103     114     +11     
Files Coverage Δ
momepy/datasets/__init__.py 100.0% <100.0%> (ø)
momepy/tests/test_preprocess.py 100.0% <100.0%> (ø)
momepy/preprocessing.py 93.3% <90.2%> (-0.9%) ⬇️

momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
# Create a buffer around the new origin:
new_origin_buffer = new_origin.buffer(buff)
# Use shapely.ops.split to break the edge where it intersects the buffer:
geometry_split_by_buffer_list = list(split(geometry, new_origin_buffer))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you tried using difference instead? It may be more efficient that split + linemerge (but may not and may cause more trouble than good).

Copy link
Member

@martinfleis martinfleis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gsagostini have you had a chance to work on tests?

@martinfleis
Copy link
Member

@gsagostini Have you closed it intentionally?

@gsagostini
Copy link
Contributor Author

gsagostini commented Sep 10, 2022

I discarded edits while trying to fetch upstream in order to bring my fork up to date. Will open the PR again soon with the new commits.

@gsagostini gsagostini reopened this Sep 11, 2022
@gsagostini
Copy link
Contributor Author

@martinfleis @jGaboardi I reopened it with the tests and updated commits.

@jGaboardi
Copy link
Member

@gsagostini Did you run black with pre-commit for code in this PR before pushing up the latest commits?

@gsagostini
Copy link
Contributor Author

@jGaboardi I had ran black only in the momepy directory but now it should have been fine for the tests too

@martinfleis
Copy link
Member

You will need to add consolidate_intersections to the list called __all__ on top of the file.

@gsagostini
Copy link
Contributor Author

Tests are still failing for the consolidate_intersections function on the minimal environment. Is this expected? Seems like the tests fail for other functions too, not just for the one I added

tests/test_preprocess.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Show resolved Hide resolved
momepy/preprocessing.py Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Show resolved Hide resolved
Copy link
Member

@martinfleis martinfleis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is a great PR! Left just a couple of minor comments.

momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
@gsagostini
Copy link
Contributor Author

@jGaboardi @martinfleis thanks! yes those are all commits I wanted to do in the preprocessing.py file. I need to fetch the new user guide structure (with the preprocessing directory) to add the notebook, is it better to do it in a new PR once this one gets merged? Also I think CodeFactor check is not successful, but I can't see what lines of code are causing it---is it an issue?

@martinfleis
Copy link
Member

@gsagostini I synced this with main. You will need to pull the changes.

flake8 is complaining about long lines in docstrings, you'll need to fix that. CodeFactor can be ignored.

@gsagostini
Copy link
Contributor Author

@martinfleis sounds good will do. Is flake8 something I can install and run like black?

@martinfleis
Copy link
Member

Yes -> https://flake8.pycqa.org/en/latest/. We also use isort now to check the order of imports. The easiest way of ensuring it is all checked on every commit is to install a pre-commit hook.

You propably must first install pre-commit:

pip install pre-commit

From the root of the repository, you should then install the pre-commit included in momepy:

pre-commit install

Then black and flake8 and sort will be run automatically each time you commit changes. You can skip these checks with git commit --no-verify.

@gsagostini
Copy link
Contributor Author

gsagostini commented Oct 12, 2022

Great! I added the notebook too. Let me know if there is more to be said on the user guide, and I will take a look :)

EDIT: Seems like there is a notebook error from building the docs. Let me know if it's easier to create a separate PR for the user guide.

momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
@martinfleis
Copy link
Member

@gsagostini It would be great if this can be finished soon, so we can release 0.6. Any updates from your side? Do you have a bit of time or shall we try to resolve remaining issues?

@martinfleis martinfleis added this to the 0.6.0 milestone Jan 1, 2023
@martinfleis martinfleis mentioned this pull request Jan 12, 2023
@martinfleis martinfleis marked this pull request as ready for review January 23, 2024 15:32
@martinfleis martinfleis modified the milestones: 0.6.0, 0.8.0 Jan 23, 2024
@martinfleis
Copy link
Member

I have revived this. Resolved conflicts, fixed shapely 2.0 compatibility, fixed some minor lint issues.

I did not do thorough review of the code hoping that my former self in 2022 did :D. I believe this can be merged now. All this functionality will undergo some testing and momepy 1.0 may or may not include it, depending on the results.

@jGaboardi
Copy link
Member

hoping that my former self in 2022 did :D.

Dangerous assumption 🤣

Copy link
Member

@jGaboardi jGaboardi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All suggestions are minor doc adjustments.

momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
momepy/preprocessing.py Outdated Show resolved Hide resolved
Co-authored-by: James Gaboardi <jgaboardi@gmail.com>
@jGaboardi
Copy link
Member

@martinfleis shall we squash & merge?

@martinfleis martinfleis merged commit 97c6e03 into pysal:main Jan 23, 2024
12 checks passed
@martinfleis
Copy link
Member

@gsagostini Thanks for all the work that went into this!

@jGaboardi
Copy link
Member

As Martin said, congrats @gsagostini !!! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants