From b061b4911ddb6f217b661418dd4851f44303539b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 29 Apr 2021 08:56:40 +0200 Subject: [PATCH] compatible with older scipy versions --- python/damask/_grid.py | 8 ++++++-- python/damask/seeds.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/python/damask/_grid.py b/python/damask/_grid.py index 9e30ba5f9..237d56ba1 100644 --- a/python/damask/_grid.py +++ b/python/damask/_grid.py @@ -436,8 +436,12 @@ class Grid: """ coords = grid_filters.coordinates0_point(cells,size).reshape(-1,3) - KDTree = spatial.cKDTree(seeds,boxsize=size) if periodic else spatial.cKDTree(seeds) - devNull,material_ = KDTree.query(coords, workers = int(os.environ.get('OMP_NUM_THREADS',4))) + tree = spatial.cKDTree(seeds,boxsize=size) if periodic else \ + spatial.cKDTree(seeds) + try: + material_ = tree.query(coords, workers = int(os.environ.get('OMP_NUM_THREADS',4)))[1] + except TypeError: + material_ = tree.query(coords, n_jobs = int(os.environ.get('OMP_NUM_THREADS',4)))[1] # scipy <1.6 return Grid(material = (material_ if material is None else material[material_]).reshape(cells), size = size, diff --git a/python/damask/seeds.py b/python/damask/seeds.py index 02a050e66..126f138aa 100644 --- a/python/damask/seeds.py +++ b/python/damask/seeds.py @@ -78,7 +78,7 @@ def from_Poisson_disc(size,N_seeds,N_candidates,distance,periodic=True,rng_seed= candidates = rng.random((N_candidates,3))*_np.broadcast_to(size,(N_candidates,3)) tree = _spatial.cKDTree(coords[:s],boxsize=size) if periodic else \ _spatial.cKDTree(coords[:s]) - distances, dev_null = tree.query(candidates) + distances = tree.query(candidates)[0] best = distances.argmax() if distances[best] > distance: # require minimum separation coords[s] = candidates[best] # maximum separation to existing point cloud