Commit 92636c0d authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Force mp_alg = 'tiles' in case SensorMapGeometryTransformer3D is called within a nosetest.

parent ef68c862
Pipeline #3812 passed with stages
in 1 minute and 9 seconds
......@@ -5,6 +5,7 @@ import multiprocessing
import os
from tempfile import TemporaryDirectory
from typing import Union, Tuple, List, Any # noqa: F401
import inspect
# custom
try:
......@@ -873,6 +874,13 @@ class SensorMapGeometryTransformer3D(object):
self.opts['nprocs'] = opts.get('nprocs', multiprocessing.cpu_count())
self.mp_alg = ('bands' if self.lons.shape[2] >= opts['nprocs'] else 'tiles') if mp_alg == 'auto' else mp_alg
# override self.mp_alg if SensorMapGeometryTransformer3D is called by nosetests
is_called_by_nose = any(x[0].f_globals['__name__'].startswith('nose.') for x in inspect.stack())
if self.opts['nprocs'] > 1 and self.mp_alg == 'bands' and is_called_by_nose:
warnings.warn("mp_alg='bands' causes deadlocks if SensorMapGeometryTransformer3D is called within a "
"nosetest. Using mp_alg='tiles'.")
self.mp_alg = 'tiles'
@staticmethod
def _to_map_geometry_2D(kwargs_dict):
# type: (dict) -> Tuple[np.ndarray, tuple, str, int]
......
......@@ -120,8 +120,8 @@ class Test_SensorMapGeometryTransformer3D(TestCase):
def test_to_map_geometry_lonlat_3D_geolayer(self):
SMGT = SensorMapGeometryTransformer3D(lons=self.lons_3D,
lats=self.lats_3D,
resamp_alg='nearest',
mp_alg='tiles' # 'bands', i.e., Pool() causes problems with nosetests
# resamp_alg='nearest',
resamp_alg='bilinear',
)
# to Lon/Lat
......@@ -140,7 +140,6 @@ class Test_SensorMapGeometryTransformer3D(TestCase):
SMGT = SensorMapGeometryTransformer3D(lons=self.lons_3D,
lats=self.lats_3D,
resamp_alg='nearest',
mp_alg='tiles' # 'bands', i.e., Pool() causes problems with nosetests)
)
dem_sensors_geo = SMGT.to_sensor_geometry(self.data_map_geo_3D,
src_prj=32632, src_extent=self.dem_area_extent_coarse_subset_utm)
......
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