Skip to content

Commit 0edb156

Browse files
committed
use short names for submodule imports to ease imports out of mpl_toolkits
It is difficult to import the basemap module when it is not installed along with the rest of the mpl_toolkits package. This change uses local imports in the basemap package for submodules with potentially conflicting global modules. This way it is easier to include the basemap package when it is installed in a different location (e.g. a virtualenv using system mpl_toolkits). Python ensures that an import first looks in the containing package when importing, this way it is not necessary to specify the full module name: https://docs.python.org/2/tutorial/modules.html#intra-package-references It addresses issues like: http://stackoverflow.com/questions/18772557/how-can-one-locally-install-an-extension-to-an-existing-system-python-module
1 parent ee6a2f7 commit 0edb156

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from matplotlib.patches import Ellipse, Circle, Polygon, FancyArrowPatch
2828
from matplotlib.lines import Line2D
2929
from matplotlib.transforms import Bbox
30-
from mpl_toolkits.basemap import pyproj
30+
import pyproj # imports local version
3131
from mpl_toolkits.axes_grid1 import make_axes_locatable
3232
from matplotlib.image import imread
3333
import sys, os, math

lib/mpl_toolkits/basemap/proj.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import numpy as np
2-
from mpl_toolkits.basemap import pyproj
2+
import pyproj # import local version
33
import math
44
from matplotlib.cbook import dedent
55

lib/mpl_toolkits/basemap/pyproj.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
4848
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """
4949

50-
from mpl_toolkits.basemap import _proj
50+
from . import _proj # import local version
5151
__version__ = _proj.__version__
5252
set_datapath = _proj.set_datapath
5353
from array import array

0 commit comments

Comments
 (0)