matplotlib / matplotlib/basemap

nan causes segfaults in merc projection

Open
#262 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
817
Forks
395
PR merge metrics
No merged PRs in 30d

Description

Moving issue from matplotlib https://github.com/matplotlib/matplotlib/issues/5991

---

@mnky9800n commented 12 hours ago

When passing a value when creating the Basemap object, if that value is a numpy.nan then python 2.x crashes on windows.

This example code crashes in an ipython 2.7 notebook.

minlat = np.nan
maxlat = np.nan
minlon = np.nan
maxlon = np.nan
m = Basemap(projection='merc'
, llcrnrlat=minlat
, urcrnrlat=maxlat
, llcrnrlon=minlon
, urcrnrlon=maxlon)
I think the expected behavior would be a ValueError or something like that so that it is easier to debug. Instead of a message like this:

---

You get that windows message because python is segfaulting. If executed in
the terminal, you get the following:

```
ben@tigger:~$ python
Python 2.7.10 |Continuum Analytics, Inc.| (default, May 28 2015, 17:02:03)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>> import numpy as np
>> from mpl_toolkits.basemap import Basemap
>> minlat = np.nan
>> maxlat = np.nan
>> minlon = np.nan
>> maxlon = np.nan
>> m = Basemap(projection='merc'
... , llcrnrlat=minlat
... , urcrnrlat=maxlat
... , llcrnrlon=minlon
... , urcrnrlon=maxlon)
GEOS_ERROR: IllegalArgumentException: Points of LinearRing do not form a
closed linestring
Segmentation fault (core dumped)
```

---

Possibly closed by #261

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the Basemap constructor with the Mercator projection and NaN values for all four bounds, as shown in the issue. Trace the validation path for those projection arguments and make the completed behavior a clear ValueError instead of a Python crash or segmentation fault.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.