Calculating distances with np.nan gives incorrect result
See original GitHub issueRunning the following code:
from shapely.geometry import Point
import numpy as np
a = Point(1, 1)
b = Point(np.nan, np.nan)
a.distance(b)
a.hausdorff_distance(b)
will output np.nan for the hausdorff_distance
which I believe is correct but the distance
function outputs a huge number. Shouldn’t it output np.nan?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Issue in handling NaN for distance calculation? - Stack Overflow
I wanted to calculate distance between two NaN which should result as 0 and distance between NaN to any number or any string...
Read more >Don't Fall Into the NaN Trap - Level Up Coding
Floating point calculation NaN (not a number) results can cause ... this whole test is bogus because the property name distance is wrong....
Read more >Pdist gives NAN but there are no missing values in input array
I am using the pdist function to calculate pairwise distances (jaccard) between two observations. Now what happens sometimes, seemingly at ...
Read more >How to count the number of NaN values in Pandas?
We can use the describe() method which returns a table containing details about the dataset. The count property directly gives the count of...
Read more >Cosine similarity with arrays contaning NaN
I am trying to calculate a cosine similarity using Python in order to find similar users basing on ratings they have given to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Opened https://github.com/libgeos/geos/issues/569 on the GEOS side
All the example cases from above, both with empty Point or empty GeometryCollection, and both with distance and hausdorff_distance, now return NaN with the latest GEOS version on the main branch.
So I think this can be closed?