Package mvpa :: Package support :: Module griddata

[hide private]
[frames] | no frames]

# Source Code for Module mvpa.support.griddata

     1  # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
     2  # vi: set ft=python sts=4 ts=4 sw=4 et:
     3  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
     4  #
     5  #   See COPYING file distributed along with the PyMVPA package for the
     6  #   copyright and license terms.
     7  #
     8  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
     9  """Import griddata with preference to the version from matplotlib
    10  """
    11
    12  __docformat__ = 'restructuredtext'
    13
    14  import sys
    15  from mvpa.base import externals
    16
    17  if externals.exists('griddata', raiseException=True):
    18      if __debug__:
    19          from mvpa.base import debug
    20
    21      try:
    22          if sys.version_info[:2] >= (2, 5):
    23              # enforce absolute import
    24              griddata = __import__('griddata', globals(),
    25                                    locals(), [], 0).griddata
    26          else:
    27              # little trick to be able to import 'griddata' package (which
    28              # has same name)
    29              oldname = __name__
    30              # crazy name with close to zero possibility to cause whatever
    31              __name__ = 'iaugf9zrkjsbdv91'
    32              try:
    33                  from griddata import griddata
    34                  # restore old settings
    35                  __name__ = oldname
    36              except ImportError:
    37                  # restore old settings
    38                  __name__ = oldname
    39                  raise
    40              if __debug__:
    41                  debug('EXT', 'Using python-griddata')
    42      except ImportError:
    43          from matplotlib.mlab import griddata
    44          if __debug__:
    45              debug('EXT', 'Using matplotlib.mlab.griddata')
    46