Merge branch 'development' into env-reporting

This commit is contained in:
Martin Diehl 2021-04-29 08:40:29 +02:00
commit 3c41cd609f
5 changed files with 25 additions and 9 deletions

@ -1 +1 @@
Subproject commit 7f0594060779d9a8a4e774d558134309ab77b96e
Subproject commit ab64793bb04c506d815ebc850672ed0f2d013e67

View File

@ -1 +1 @@
v3.0.0-alpha3-37-ge9cfb2f96
v3.0.0-alpha3-40-ga1c46b445

View File

@ -71,18 +71,25 @@ def from_Poisson_disc(size,N_seeds,N_candidates,distance,periodic=True,rng_seed=
coords = _np.empty((N_seeds,3))
coords[0] = rng.random(3) * size
i = 1
s = 1
i = 0
progress = util._ProgressBar(N_seeds+1,'',50)
while i < N_seeds:
while s < N_seeds:
candidates = rng.random((N_candidates,3))*_np.broadcast_to(size,(N_candidates,3))
tree = _spatial.cKDTree(coords[:i],boxsize=size) if periodic else \
_spatial.cKDTree(coords[:i])
tree = _spatial.cKDTree(coords[:s],boxsize=size) if periodic else \
_spatial.cKDTree(coords[:s])
distances, dev_null = tree.query(candidates)
best = distances.argmax()
if distances[best] > distance: # require minimum separation
coords[i] = candidates[best] # maximum separation to existing point cloud
coords[s] = candidates[best] # maximum separation to existing point cloud
s += 1
progress.update(s)
i = 0
else:
i += 1
progress.update(i)
if i == 100:
raise ValueError('Seeding not possible')
return coords

View File

@ -4,7 +4,7 @@ import re
# https://www.python.org/dev/peps/pep-0440
with open(Path(__file__).parent/'damask/VERSION') as f:
version = re.sub(r'(-([^-]*)).*$',r'.\2',re.sub(r'^v(\d+\.\d+(\.\d+)?)',r'\1',f.readline().strip()))
version = re.sub(r'(-([^-]*)).*$',r'.\2',re.sub(r'^v(\d+\.\d+(\.\d+)?)',r'\1',f.readline().strip()))
setuptools.setup(
name='damask',

View File

@ -26,6 +26,15 @@ class TestSeeds:
cKDTree(coords).query(coords, 2)
assert (0<= coords).all() and (coords<size).all() and np.min(min_dists[:,1])>=distance
@pytest.mark.parametrize('periodic',[True,False])
def test_from_Poisson_disc_invalid(self,periodic):
N_seeds = np.random.randint(30,300)
N_candidates = N_seeds//15
distance = np.random.random()
size = np.ones(3)*distance
with pytest.raises(ValueError):
seeds.from_Poisson_disc(size,N_seeds,N_candidates,distance,periodic=periodic)
def test_from_grid_reconstruct(self):
cells = np.random.randint(10,20,3)
N_seeds = np.random.randint(30,300)