From 2c3eae6bf0b43d6cab68c12ac5430209c67976ce Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 7 Mar 2018 18:58:28 -0500 Subject: [PATCH] fixed tests and bug for very small unit cube fractions when grid is also small --- PRIVATE | 2 +- processing/pre/seeds_fromRandom.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/PRIVATE b/PRIVATE index 8de4f792a..8546f9bda 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 8de4f792a46d98d98418dbf2d3e621b22c13b18a +Subproject commit 8546f9bda04b58c3b26979048288a8a01f607876 diff --git a/processing/pre/seeds_fromRandom.py b/processing/pre/seeds_fromRandom.py index 3045359ef..77bacdc8e 100755 --- a/processing/pre/seeds_fromRandom.py +++ b/processing/pre/seeds_fromRandom.py @@ -166,14 +166,15 @@ for name in filenames: grainEuler[2,:] *= 360.0 # phi_2 is uniformly distributed if not options.selective: - n = np.array(options.grid * options.fraction,dtype=int) # find valid grid indices within fraction + n = np.maximum(np.ones(3),np.array(options.grid*options.fraction), + dtype=int,casting='unsafe') # find max grid indices within fraction meshgrid = np.meshgrid(*map(np.arange,n),indexing='ij') # create a meshgrid within fraction - coords = np.vstack((meshgrid[0],meshgrid[1],meshgrid[2])).reshape(3,n.prod()).T # assemble list of 3D coordinates - seeds = ((random.sample(coords,options.N)+np.random.random(options.N*3).reshape(options.N,3))/options.grid).T # pick options.N of those and rattle position - + seeds = ((random.sample(coords,options.N)+np.random.random(options.N*3).reshape(options.N,3))\ + / \ + (n/options.fraction)).T # pick options.N of those, rattle position, + # and rescale to fall within fraction else: - seeds = np.zeros((options.N,3),dtype=float) # seed positions array seeds[0] = np.random.random(3)*options.grid/max(options.grid) i = 1 # start out with one given point