Skip to content

Add diagnostics functions: proj4 ver. & Inv. Hammer #281

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

Merged
merged 2 commits into from
Mar 21, 2016
Merged

Add diagnostics functions: proj4 ver. & Inv. Hammer #281

merged 2 commits into from
Mar 21, 2016

Conversation

micahcochran
Copy link
Contributor

This is a refactor of the package_version function to move getting the proj4 version number into a new function, proj4_version. check_proj_inv_hammer function is added for checking if the inverse of the hammer projection is available (which should be in the yet to be released proj.4 version 4.9.3).

check_proj_inv_hammer() and proj4_version() are intended to end up in setup.py, but may provide some use in the main basemap library. Due to that reason, the imports are mostly self-contained for the function.

So, Proj.4 verion 4.9.3 has not been released, nor has the current development version of pyproj which has code that raises a RuntimeError when a projection's inverse function isn't available (pyproj 1.9.5.1 and before will segfault). At the moment, I'm a little uncertain about putting these the check_proj_inv_hammer() into setup.py without one of the two libraries being released. This effectively requires installation one of the development versions for the check_proj_inv_hammer function to pass the test, otherwise they risk a segfault. This originates from discussion in PR #240.

Editing setup.py seems a little daunting because I'm a bit overwhelmed by what all setup.py can do/should do. setup.py seems to work like a swiss army knife by doing a couple tasks well and other tasks not so well.

Here are my local test results of the functions, which where copied an pasted into ipython:

In [3]: proj4_version()
Out[3]: '4.9.2'

In [4]: package_versions()
Out[4]: BasemapPackageVersions(Python='2.7.4 (default, Apr  6 2013, 19:54:46) [M
SC v.1500 32 bit (Intel)]', basemap='1.0.8', matplotlib='1.5.1', numpy='1.10.4',
 pyproj='1.9.5.1', pyshp='1.2.3', PROJ4='4.9.2', GEOS='3.5.0-CAPI-1.9.0 r4084',
OWSLib='not installed', PIL='not installed', Pillow='not installed')

In [5]: check_proj_inv_hammer()
Out[5]: 'Unknown'

In [6]: check_proj_inv_hammer(True)
Out[6]: True

Refactored package_version function to move proj4 version checking into proj4_version function.  check_proj_inv_hammer function added to check if the inverse of the hammer projection is available (which should be in the yet to be released proj.4 version 4.9.3).

check_proj_inv_hammer() and proj4_version() are intended to end up in setup.py, but may provide some use in the main basemap library.  Due to that reason, the imports are mostly self-contained for the function.
@WeatherGod
Copy link
Member

Ok, this is an incremental improvement of the diagnostic functions. A nitpick: the double-negative for segfault_protection_off made me have to read the logic twice before I got it.

@micahcochran
Copy link
Contributor Author

I can understand the confusion. In a few days, I'll do a commit to update the flag variable to just segfault_protection.Thanks for the quick feedback.

Docstring for check_proj_inv_hammer() improvement.
@micahcochran
Copy link
Contributor Author

I changed the parameter's name to segfault_protection and made another commit.

IPython console

In [3]: check_proj_inv_hammer(segfault_protection=True) # default
Out[3]: 'Unknown'

In [4]: check_proj_inv_hammer(segfault_protection=False)
Out[4]: True

In [5]: check_proj_inv_hammer()
Out[5]: 'Unknown'

If you have an older version of Proj.4 or a version without the inverse hammer patch applied it will segfault Python.

WeatherGod added a commit that referenced this pull request Mar 21, 2016
Add diagnostics functions: proj4 ver. & Inv. Hammer
@WeatherGod WeatherGod merged commit 116aefb into matplotlib:master Mar 21, 2016
@micahcochran
Copy link
Contributor Author

Thanks.

@micahcochran micahcochran deleted the patch-1 branch March 21, 2016 19:46
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