Commit 37ca24a1 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Moved all matplotlib imports from module level to function/class level to...


Moved all matplotlib imports from module level to function/class level to avoid static TLS ImportError. Updated version info.
Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent b825d85e
Pipeline #12915 passed with stages
in 3 minutes and 36 seconds
......@@ -25,6 +25,7 @@ import warnings
import os
from copy import copy
from six import PY2
from typing import TYPE_CHECKING
# custom
try:
......@@ -36,9 +37,9 @@ try:
except ImportError:
pyfftw = None
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.colorbar import ColorbarBase
from matplotlib.colors import Normalize
if TYPE_CHECKING:
from matplotlib import pyplot as plt # noqa F401
from .Tie_Point_Grid import Tie_Point_Grid
from .CoReg import COREG
......@@ -391,6 +392,10 @@ class COREG_LOCAL(object):
:param zoomable: <bool> enable or disable zooming via mpld3
:return:
"""
from matplotlib import pyplot as plt # noqa
from matplotlib.colorbar import ColorbarBase
from matplotlib.colors import Normalize
# get a map showing target image
if backgroundIm not in ['tgt', 'ref']:
raise ValueError('backgroundIm')
......
......@@ -33,7 +33,6 @@ try:
except ImportError:
from osgeo import gdal
import numpy as np
from matplotlib import pyplot as plt
from geopandas import GeoDataFrame
from pandas import DataFrame, Series
from shapely.geometry import Point
......@@ -464,6 +463,8 @@ class Tie_Point_Grid(object):
:param fontsize: size of all used fonts
:param title: the title to be plotted above the figure
"""
from matplotlib import pyplot as plt
if unit not in ['m', 'px']:
raise ValueError("Parameter 'unit' must have the value 'm' (meters) or 'px' (pixels)! Got %s." % unit)
......
......@@ -22,8 +22,6 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
import numpy as np
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 # this is needed for fig.add_subplot(..., projection='3d')
def _norm(array, normto):
......@@ -31,6 +29,8 @@ def _norm(array, normto):
def subplot_2dline(XY_tuples, titles=None, shapetuple=None, grid=False):
from matplotlib import pyplot as plt
shapetuple = (1, len(XY_tuples)) if shapetuple is None else shapetuple
assert titles is None or len(titles) == len(XY_tuples), \
'List in titles keyword must have the same length as the passed XY_tuples.'
......@@ -50,6 +50,8 @@ def subplot_2dline(XY_tuples, titles=None, shapetuple=None, grid=False):
def subplot_imshow(ims, titles=None, shapetuple=None, grid=False):
from matplotlib import pyplot as plt
ims = [ims] if not isinstance(ims, list) else ims
assert titles is None or len(titles) == len(ims), 'Error: Got more or less titles than images.'
......@@ -69,6 +71,9 @@ def subplot_imshow(ims, titles=None, shapetuple=None, grid=False):
def subplot_3dsurface(ims, shapetuple=None):
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 # this is needed for fig.add_subplot(..., projection='3d')
ims = [ims] if not isinstance(ims, list) else ims
shapetuple = (1, len(ims)) if shapetuple is None else shapetuple
fig = plt.figure(figsize=_norm(plt.figaspect((shapetuple[0] / 2.) / shapetuple[1] * 1.), 20))
......
......@@ -22,5 +22,5 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
__version__ = '0.9.22'
__versionalias__ = '2020-09-25_01'
__version__ = '0.9.23'
__versionalias__ = '2020-09-25_02'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment