Skip to content

Commit

Permalink
Also lazy load numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 17, 2019
1 parent a4052f9 commit 6337ed6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 5 additions & 1 deletion python/plugins/processing/algs/qgis/HypsometricCurves.py
Expand Up @@ -22,7 +22,6 @@
__copyright__ = '(C) 2014, Alexander Bruy'

import os
import numpy
import csv

from osgeo import gdal, ogr, osr
Expand Down Expand Up @@ -79,6 +78,11 @@ def displayName(self):
return self.tr('Hypsometric curves')

def processAlgorithm(self, parameters, context, feedback):
try:
import numpy
except ImportError:
raise QgsProcessingException(self.tr('This algorithm requires the Python “numpy” library. Please install this library and try again.'))

raster_layer = self.parameterAsRasterLayer(parameters, self.INPUT_DEM, context)
target_crs = raster_layer.crs()
rasterPath = raster_layer.source()
Expand Down
5 changes: 4 additions & 1 deletion python/plugins/processing/algs/qgis/PolarPlot.py
Expand Up @@ -74,7 +74,10 @@ def processAlgorithm(self, parameters, context, feedback):
except ImportError:
raise QgsProcessingException(self.tr('This algorithm requires the Python “plotly” library. Please install this library and try again.'))

import numpy as np
try:
import numpy as np
except ImportError:
raise QgsProcessingException(self.tr('This algorithm requires the Python “numpy” library. Please install this library and try again.'))

source = self.parameterAsSource(parameters, self.INPUT, context)
if source is None:
Expand Down
2 changes: 0 additions & 2 deletions python/plugins/processing/tools/raster.py
Expand Up @@ -21,10 +21,8 @@
__date__ = 'February 2013'
__copyright__ = '(C) 2013, Victor Olaya and Alexander Bruy'

import os
import struct

import numpy
from osgeo import gdal

from qgis.core import QgsProcessingException
Expand Down

0 comments on commit 6337ed6

Please sign in to comment.