def test_disorientation_blending(self, lattice, a, b): o = Orientation.from_random(lattice=lattice, shape=a) p = Orientation.from_random(lattice=lattice, shape=b) blend = util.shapeblender(o.shape, p.shape) for loc in np.random.randint(0, blend, (10, len(blend))): assert o[tuple(loc[:len(o.shape)])].disorientation(p[tuple(loc[-len(p.shape):])]) \ .isclose(o.disorientation(p)[tuple(loc)])
def test_to_SST_blending(self, family, left, right): o = Orientation.from_random(family=family, shape=left) v = np.random.random(right + (3, )) blend = util.shapeblender(o.shape, v.shape[:-1]) for loc in np.random.randint(0, blend, (10, len(blend))): assert np.allclose( o[tuple(loc[:len(o.shape)])].to_SST(v[tuple( loc[-len(v.shape[:-1]):])]), o.to_SST(v)[tuple(loc)])
def test_disorientation_blending(self, family, left, right): o = Orientation.from_random(family=family, shape=left) p = Orientation.from_random(family=family, shape=right) blend = util.shapeblender(o.shape, p.shape) for loc in np.random.randint(0, blend, (10, len(blend))): # print(f'{a}/{b} @ {loc}') # print(o[tuple(loc[:len(o.shape)])].disorientation(p[tuple(loc[-len(p.shape):])])) # print(o.disorientation(p)[tuple(loc)]) assert o[tuple(loc[:len(o.shape)])].disorientation(p[tuple(loc[-len(p.shape):])]) \ .isclose(o.disorientation(p)[tuple(loc)])
def test_to_SST_blending(self, lattice, a, b): o = Orientation.from_random(lattice=lattice, shape=a) v = np.random.random(b + (3, )) blend = util.shapeblender(o.shape, b) for loc in np.random.randint(0, blend, (10, len(blend))): print(f'{a}/{b} @ {loc}') print(o[tuple(loc[:len(o.shape)])].to_SST(v[tuple(loc[-len(b):])])) print(o.to_SST(v)[tuple(loc)]) assert np.allclose( o[tuple(loc[:len(o.shape)])].to_SST(v[tuple(loc[-len(b):])]), o.to_SST(v)[tuple(loc)])
def test_to_pole_blending(self, lattice, a, b, c, alpha, beta, gamma, left, right): o = Orientation.from_random(shape=left, lattice=lattice, a=a, b=b, c=c, alpha=alpha, beta=beta, gamma=gamma) v = np.random.random(right + (3, )) blend = util.shapeblender(o.shape, v.shape[:-1]) for loc in np.random.randint(0, blend, (10, len(blend))): assert np.allclose( o[tuple(loc[:len(o.shape)])].to_pole( uvw=v[tuple(loc[-len(v.shape[:-1]):])]), o.to_pole(uvw=v)[tuple(loc)])
def test_shapeblender(self,a,b,answer): assert util.shapeblender(a,b) == answer