mapbox / mapbox/vector-tile-base
`_points_equal` incorrectly compares floats with `is not`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 57
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
Description
I noticed add_ring is not treating my closed ring like a closed ring:
```python
ipdb> pt1
(19188372.37109346, -5402212.477493137)
ipdb> pt2
(19188372.37109346, -5402212.477493137)
ipdb> n
> /Users/cdestigter/checkout/sno/sno/pyvendor/vector_tile_base/engine.py(314)_points_equal()
313 if pt1[0] is not pt2[0] or pt1[1] is not pt2[1] or (self._has_elevation and pt1[2] is not pt2[2]):
--> 314 return False
315 return True
ipdb> pt1[0] == pt2[0]
True
ipdb> pt1[0] is pt2[0]
False
```
`is not` isn't the appropriate comparator here, it shoudl be `!=`. python doesn't guarantee two equal floats are the same float.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open sno/pyvendor/vector_tile_base/engine.py and inspect _points_equal around line 313. Replace the identity comparison with value comparison, then run the project's existing tests and verify that equal float coordinates allow a closed ring to be recognized.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100