Skip to content

BUG: fixup the hash-ability of geometries#1239

Merged
jorisvandenbossche merged 1 commit intoshapely:mainfrom
jorisvandenbossche:fixup-hashability
Dec 2, 2021
Merged

BUG: fixup the hash-ability of geometries#1239
jorisvandenbossche merged 1 commit intoshapely:mainfrom
jorisvandenbossche:fixup-hashability

Conversation

@jorisvandenbossche
Copy link
Copy Markdown
Member

On top of #1237, so only the last commit is relevant.

The tests for hash-ability were still failing, for two reasons:

  • There was still a __hash__ = None in the code, effectively making a class unhashable
  • We defined a __eq__ in the python-level BaseGeometry class, and when you subclass, you need to implement neither or both of __eq__ and __hash__ (see https://docs.python.org/3/reference/datamodel.html#object.__hash__)
    • I now removed the __eq__ in the python layer, keeping the GeometryObject_richcompare in the C extension type in pygeos.c (but in principle we could also do it the other way around I think)

@jorisvandenbossche jorisvandenbossche merged commit 200cb6d into shapely:main Dec 2, 2021
@jorisvandenbossche jorisvandenbossche deleted the fixup-hashability branch December 2, 2021 08:38
@jorisvandenbossche
Copy link
Copy Markdown
Member Author

Merging this, so I can try to get the tests passing in #1241 (we can later still revisit the exact approach of doing it in C vs python)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants