-
Notifications
You must be signed in to change notification settings - Fork 557
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
API: use equals_identical for __eq__ #1760
base: main
Are you sure you want to change the base?
API: use equals_identical for __eq__ #1760
Conversation
Additional complication: I forgot that The other reason that some tests are failing is because this PR actually changes behaviour regarding NaNs. On main, we don't regard such geometries as equal:
while with this PR, I made NaNs in the same location as equal (following what was done for GEOSEqualsIdentical upstream in libgeos/geos#810). With shapely 1.x, this also resulted in False, because we implemented |
@jorisvandenbossche Thanks for fixing this issue! |
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.
Thanks @jorisvandenbossche
A few relatively minor comments on this so far; assume that this is still WIP waiting on GEOSCoordSeq_copyToBuffer_r
.
Should this use GEOSEqualsIdentical
if available from GEOS and skip the custom implementation here?
@brendan-ward thanks a lot for the detailed review. |
For me the proposed behavior makes much more sense, that NaNs would be considered equal. |
Good to call me on it; I intentionally sidestepped answering that question. 😄 I personally haven't relied on this behavior and thus would not be impacted either way (so take my perspective with a grain of salt), and find NaNs to be challenging in coordinate sequences throughout the codebase (I always go back to the comment in pygeos #306 of So long as this is clearly noted in the changelog, that hopefully avoids surprises for users, and I really hope very few if any are relying on specific comparisons where NaNs suddenly switch from incomparable (equals is false) to equivalent if functionally equal. |
Yes, fully agreed on that ideally you never have NaNs in coordinate sequences to start with, and we can improve APIs to prevent users from getting that. I also don't have real-world experience to base an opinion on, but I have the feeling it makes sense to let |
(Hope I understood correctly) I strongly agree that |
Co-authored-by: Brendan Ward <bcward@astutespruce.com>
OK, updated this PR for the review comments. This is now "generally" passing, i.e. for most GEOS versions except for some corner cases where GEOS 3.8 seems to behave differently (for empty geometries, have to further diagnose this). The tests for GEOS main are failing, but those are failing on main as well (and related to libgeos/geos#832). I also opened a dedicated issue for the API question regarding how NaNs are treated for visibility: #1775 |
Hi @jorisvandenbossche is there an estimated release date for the next release including this important fix? Thanks!!! |
Thanks for the updates here @jorisvandenbossche . Can you please add a CHANGELOG entry? The only part I'm still struggling with is the equality tests with Z nan values that are dependent on the GEOS version, where it returns |
Hi @jorisvandenbossche @brendan-ward , |
Co-authored-by: Idan Miara <idan@miara.com>
Co-authored-by: Idan Miara <idan@miara.com>
Pull Request Test Coverage Report for Build 8233067448Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
This is ready for another review. |
@mwtoews I added some minimal tests for (in)equality with M coordinates |
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.
Looks good! I have a few suggestions which you can take or leave.
@@ -203,6 +203,6 @@ extern enum ShapelyErrorCode coordseq_from_buffer(GEOSContextHandle_t ctx, | |||
npy_intp cs2, | |||
GEOSCoordSequence** coord_seq); | |||
extern int coordseq_to_buffer(GEOSContextHandle_t ctx, const GEOSCoordSequence* coord_seq, | |||
double* buf, unsigned int size, unsigned int dims); | |||
double* buf, unsigned int size, int hasZ, int hasM); |
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.
for a consistent naming convention:
double* buf, unsigned int size, int hasZ, int hasM); | |
double* buf, unsigned int size, int has_z, int has_m); |
(same with src/geos.c
)
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.
It's indeed more consistent style here, but in several other places in the src files, we already use hasZ
pattern, so going to leave this one as is for this PR
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.
This can be left for now and further discussed in #1648 as it can change later.
But to clarify my suggestion a bit more, the argument naming convention "foo_bar" is used in src/*.h
header files, and even skimming header files from numpy.get_include()
too. Data types and internal variables are fine to take whatever convention they wish (i.e. "fooBar").
Co-authored-by: Mike Taves <mwtoews@gmail.com>
@mwtoews thanks for the review! |
Closes #1732, closes #1775
This might be a bit overkill for just implementing
__eq__
, but this should also allow to actually expose "equals_identical" as a ufunc for all GEOS versions (and not only for GEOS>=3.12). And it is also faster than the easier python alternative (but not sure how significant this will be in real-world cases):