Consistent formatting of raised messages
This commit is contained in:
parent
744f5755ff
commit
aeb0e527ec
|
@ -141,7 +141,7 @@ class Colormap(mpl.colors.ListedColormap):
|
|||
)
|
||||
|
||||
if model.lower() not in toMsh:
|
||||
raise ValueError(f'Invalid color model: {model}.')
|
||||
raise ValueError(f'Invalid color model "{model}"')
|
||||
|
||||
low_high = np.vstack((low,high)).astype(float)
|
||||
out_of_bounds = np.bool_(False)
|
||||
|
@ -156,7 +156,7 @@ class Colormap(mpl.colors.ListedColormap):
|
|||
out_of_bounds = np.any(low_high[:,0]<0)
|
||||
|
||||
if out_of_bounds:
|
||||
raise ValueError(f'{model.upper()} colors {low_high[0]} | {low_high[1]} are out of bounds.')
|
||||
raise ValueError(f'{model.upper()} colors {low_high[0]} | {low_high[1]} are out of bounds')
|
||||
|
||||
low_,high_ = map(toMsh[model.lower()],low_high)
|
||||
msh = map(functools.partial(Colormap._interpolate_msh,low=low_,high=high_),np.linspace(0,1,N))
|
||||
|
|
|
@ -64,9 +64,9 @@ class Crystal():
|
|||
|
||||
"""
|
||||
if family is not None and family not in list(lattice_symmetries.values()):
|
||||
raise KeyError(f'invalid crystal family "{family}"')
|
||||
raise KeyError(f'Invalid crystal family "{family}"')
|
||||
if lattice is not None and family is not None and family != lattice_symmetries[lattice]:
|
||||
raise KeyError(f'incompatible family "{family}" for lattice "{lattice}"')
|
||||
raise KeyError(f'Incompatible family "{family}" for lattice "{lattice}"')
|
||||
|
||||
self.family = lattice_symmetries[lattice] if family is None else family
|
||||
self.lattice = lattice
|
||||
|
@ -101,13 +101,13 @@ class Crystal():
|
|||
or (self.alpha is None or ('alpha' in self.immutable and self.alpha != self.immutable['alpha'])) \
|
||||
or (self.beta is None or ('beta' in self.immutable and self.beta != self.immutable['beta'])) \
|
||||
or (self.gamma is None or ('gamma' in self.immutable and self.gamma != self.immutable['gamma'])):
|
||||
raise ValueError (f'incompatible parameters {self.parameters} for crystal family {self.family}')
|
||||
raise ValueError (f'Incompatible parameters {self.parameters} for crystal family {self.family}')
|
||||
|
||||
if np.any(np.array([self.alpha,self.beta,self.gamma]) <= 0):
|
||||
raise ValueError ('lattice angles must be positive')
|
||||
raise ValueError ('Lattice angles must be positive')
|
||||
if np.any([np.roll([self.alpha,self.beta,self.gamma],r)[0]
|
||||
>= np.sum(np.roll([self.alpha,self.beta,self.gamma],r)[1:]) for r in range(3)]):
|
||||
raise ValueError ('each lattice angle must be less than sum of others')
|
||||
raise ValueError ('Each lattice angle must be less than sum of others')
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
|
@ -269,7 +269,7 @@ class Crystal():
|
|||
|
||||
"""
|
||||
if self.parameters is None:
|
||||
raise KeyError('missing crystal lattice parameters')
|
||||
raise KeyError('Missing crystal lattice parameters')
|
||||
return np.array([
|
||||
[1,0,0],
|
||||
[np.cos(self.gamma),np.sin(self.gamma),0],
|
||||
|
@ -309,7 +309,7 @@ class Crystal():
|
|||
],
|
||||
}
|
||||
|
||||
if self.lattice is None: raise KeyError('no lattice type specified')
|
||||
if self.lattice is None: raise KeyError('No lattice type specified')
|
||||
return np.array([[0,0,0]]
|
||||
+ _lattice_points.get(self.lattice if self.lattice == 'hP' else \
|
||||
self.lattice[-1],None),dtype=float)
|
||||
|
@ -333,7 +333,7 @@ class Crystal():
|
|||
|
||||
"""
|
||||
if (direction is not None) ^ (plane is None):
|
||||
raise KeyError('specify either "direction" or "plane"')
|
||||
raise KeyError('Specify either "direction" or "plane"')
|
||||
basis,axis = (self.basis_reciprocal,np.array(direction)) \
|
||||
if plane is None else \
|
||||
(self.basis_real,np.array(plane))
|
||||
|
@ -358,7 +358,7 @@ class Crystal():
|
|||
|
||||
"""
|
||||
if (uvw is not None) ^ (hkl is None):
|
||||
raise KeyError('specify either "uvw" or "hkl"')
|
||||
raise KeyError('Specify either "uvw" or "hkl"')
|
||||
basis,axis = (self.basis_real,np.array(uvw)) \
|
||||
if hkl is None else \
|
||||
(self.basis_reciprocal,np.array(hkl))
|
||||
|
@ -930,7 +930,7 @@ class Crystal():
|
|||
}
|
||||
orientation_relationships = {k:v for k,v in _orientation_relationships.items() if self.lattice in v}
|
||||
if model not in orientation_relationships:
|
||||
raise KeyError(f'unknown orientation relationship "{model}"')
|
||||
raise KeyError(f'Unknown orientation relationship "{model}"')
|
||||
r = orientation_relationships[model]
|
||||
|
||||
sl = self.lattice
|
||||
|
|
|
@ -105,9 +105,9 @@ class Grid:
|
|||
def material(self,
|
||||
material: np.ndarray):
|
||||
if len(material.shape) != 3:
|
||||
raise ValueError(f'invalid material shape {material.shape}')
|
||||
raise ValueError(f'Invalid material shape {material.shape}')
|
||||
if material.dtype not in np.sctypes['float'] and material.dtype not in np.sctypes['int']:
|
||||
raise TypeError(f'invalid material data type {material.dtype}')
|
||||
raise TypeError(f'Invalid material data type {material.dtype}')
|
||||
|
||||
self._material = np.copy(material)
|
||||
|
||||
|
@ -125,7 +125,7 @@ class Grid:
|
|||
def size(self,
|
||||
size: FloatSequence):
|
||||
if len(size) != 3 or any(np.array(size) < 0):
|
||||
raise ValueError(f'invalid size {size}')
|
||||
raise ValueError(f'Invalid size {size}')
|
||||
|
||||
self._size = np.array(size)
|
||||
|
||||
|
@ -138,7 +138,7 @@ class Grid:
|
|||
def origin(self,
|
||||
origin: FloatSequence):
|
||||
if len(origin) != 3:
|
||||
raise ValueError(f'invalid origin {origin}')
|
||||
raise ValueError(f'Invalid origin {origin}')
|
||||
|
||||
self._origin = np.array(origin)
|
||||
|
||||
|
@ -228,7 +228,7 @@ class Grid:
|
|||
except ValueError:
|
||||
header_length,keyword = (-1, 'invalid')
|
||||
if not keyword.startswith('head') or header_length < 3:
|
||||
raise TypeError('header length information missing or invalid')
|
||||
raise TypeError('Header length information missing or invalid')
|
||||
|
||||
comments = []
|
||||
content = f.readlines()
|
||||
|
@ -258,7 +258,7 @@ class Grid:
|
|||
i += len(items)
|
||||
|
||||
if i != cells.prod():
|
||||
raise TypeError(f'invalid file: expected {cells.prod()} entries, found {i}')
|
||||
raise TypeError(f'Invalid file: expected {cells.prod()} entries, found {i}')
|
||||
|
||||
if not np.any(np.mod(material,1) != 0.0): # no float present
|
||||
material = material.astype('int') - (1 if material.min() > 0 else 0)
|
||||
|
@ -811,7 +811,7 @@ class Grid:
|
|||
|
||||
"""
|
||||
if not set(directions).issubset(valid := ['x', 'y', 'z']):
|
||||
raise ValueError(f'invalid direction {set(directions).difference(valid)} specified')
|
||||
raise ValueError(f'Invalid direction {set(directions).difference(valid)} specified')
|
||||
|
||||
limits: Sequence[Optional[int]] = [None,None] if reflect else [-2,0]
|
||||
mat = self.material.copy()
|
||||
|
@ -847,7 +847,7 @@ class Grid:
|
|||
|
||||
"""
|
||||
if not set(directions).issubset(valid := ['x', 'y', 'z']):
|
||||
raise ValueError(f'invalid direction {set(directions).difference(valid)} specified')
|
||||
raise ValueError(f'Invalid direction {set(directions).difference(valid)} specified')
|
||||
|
||||
|
||||
mat = np.flip(self.material, [valid.index(d) for d in directions if d in valid])
|
||||
|
@ -1184,7 +1184,7 @@ class Grid:
|
|||
|
||||
"""
|
||||
if not set(directions).issubset(valid := ['x', 'y', 'z']):
|
||||
raise ValueError(f'invalid direction {set(directions).difference(valid)} specified')
|
||||
raise ValueError(f'Invalid direction {set(directions).difference(valid)} specified')
|
||||
|
||||
o = [[0, self.cells[0]+1, np.prod(self.cells[:2]+1)+self.cells[0]+1, np.prod(self.cells[:2]+1)],
|
||||
[0, np.prod(self.cells[:2]+1), np.prod(self.cells[:2]+1)+1, 1],
|
||||
|
|
|
@ -247,7 +247,7 @@ class Orientation(Rotation,Crystal):
|
|||
if isinstance(other, (Orientation,Rotation)):
|
||||
return self.copy(Rotation(self.quaternion)*Rotation(other.quaternion))
|
||||
else:
|
||||
raise TypeError('use "O@b", i.e. matmul, to apply Orientation "O" to object "b"')
|
||||
raise TypeError('Use "O@b", i.e. matmul, to apply Orientation "O" to object "b"')
|
||||
|
||||
|
||||
@staticmethod
|
||||
|
@ -550,7 +550,7 @@ class Orientation(Rotation,Crystal):
|
|||
|
||||
"""
|
||||
if self.family != other.family:
|
||||
raise NotImplementedError('disorientation between different crystal families')
|
||||
raise NotImplementedError('Disorientation between different crystal families')
|
||||
|
||||
blend = util.shapeblender(self.shape,other.shape)
|
||||
s = self.equivalent
|
||||
|
@ -649,7 +649,7 @@ class Orientation(Rotation,Crystal):
|
|||
"""
|
||||
vector_ = np.array(vector,float)
|
||||
if vector_.shape[-1] != 3:
|
||||
raise ValueError('input is not a field of three-dimensional vectors')
|
||||
raise ValueError('Input is not a field of three-dimensional vectors')
|
||||
eq = self.equivalent
|
||||
blend = util.shapeblender(eq.shape,vector_.shape[:-1])
|
||||
poles = eq.broadcast_to(blend,mode='right') @ np.broadcast_to(vector_,blend+(3,))
|
||||
|
@ -686,7 +686,7 @@ class Orientation(Rotation,Crystal):
|
|||
"""
|
||||
vector_ = np.array(vector,float)
|
||||
if vector_.shape[-1] != 3:
|
||||
raise ValueError('input is not a field of three-dimensional vectors')
|
||||
raise ValueError('Input is not a field of three-dimensional vectors')
|
||||
|
||||
if self.standard_triangle is None: # direct exit for no symmetry
|
||||
return np.ones_like(vector_[...,0],bool)
|
||||
|
@ -744,7 +744,7 @@ class Orientation(Rotation,Crystal):
|
|||
|
||||
"""
|
||||
if np.array(vector).shape[-1] != 3:
|
||||
raise ValueError('input is not a field of three-dimensional vectors')
|
||||
raise ValueError('Input is not a field of three-dimensional vectors')
|
||||
|
||||
vector_ = self.to_SST(vector,proper) if in_SST else \
|
||||
self @ np.broadcast_to(vector,self.shape+(3,))
|
||||
|
|
|
@ -132,7 +132,7 @@ class Result:
|
|||
self.increments = sorted([i for i in f.keys() if r.match(i)],key=util.natural_sort)
|
||||
self.times = [round(f[i].attrs['t/s'],12) for i in self.increments]
|
||||
if len(self.increments) == 0:
|
||||
raise ValueError('incomplete DADF5 file')
|
||||
raise ValueError('Incomplete DADF5 file')
|
||||
|
||||
self.N_materialpoints, self.N_constituents = np.shape(f['cell_to/phase'])
|
||||
|
||||
|
@ -939,7 +939,7 @@ class Result:
|
|||
elif T_sym['meta']['unit'] == 'Pa':
|
||||
k = 'stress'
|
||||
if k not in ['stress', 'strain']:
|
||||
raise ValueError(f'invalid von Mises kind {kind}')
|
||||
raise ValueError(f'Invalid von Mises kind {kind}')
|
||||
|
||||
return {
|
||||
'data': (mechanics.equivalent_strain_Mises if k=='strain' else \
|
||||
|
@ -993,7 +993,7 @@ class Result:
|
|||
t = 'tensor'
|
||||
if o is None: o = 'fro'
|
||||
else:
|
||||
raise ValueError(f'invalid shape of {x["label"]}')
|
||||
raise ValueError(f'Invalid shape of {x["label"]}')
|
||||
|
||||
return {
|
||||
'data': np.linalg.norm(x['data'],ord=o,axis=axis,keepdims=True),
|
||||
|
@ -1633,7 +1633,7 @@ class Result:
|
|||
elif mode.lower()=='point':
|
||||
v = VTK.from_poly_data(self.coordinates0_point)
|
||||
else:
|
||||
raise ValueError(f'invalid mode {mode}')
|
||||
raise ValueError(f'Invalid mode {mode}')
|
||||
|
||||
v.set_comments(util.execution_stamp('Result','export_VTK'))
|
||||
|
||||
|
|
|
@ -731,7 +731,7 @@ class Rotation:
|
|||
"""
|
||||
qu = np.array(q,dtype=float)
|
||||
if qu.shape[:-2:-1] != (4,):
|
||||
raise ValueError('Invalid shape.')
|
||||
raise ValueError('Invalid shape')
|
||||
if abs(P) != 1:
|
||||
raise ValueError('P ∉ {-1,1}')
|
||||
|
||||
|
@ -740,9 +740,9 @@ class Rotation:
|
|||
qu[qu[...,0] < 0.0] *= -1
|
||||
else:
|
||||
if np.any(qu[...,0] < 0.0):
|
||||
raise ValueError('Quaternion with negative first (real) component.')
|
||||
raise ValueError('Quaternion with negative first (real) component')
|
||||
if not np.all(np.isclose(np.linalg.norm(qu,axis=-1), 1.0,rtol=0.0)):
|
||||
raise ValueError('Quaternion is not of unit length.')
|
||||
raise ValueError('Quaternion is not of unit length')
|
||||
|
||||
return Rotation(qu)
|
||||
|
||||
|
@ -767,11 +767,11 @@ class Rotation:
|
|||
"""
|
||||
eu = np.array(phi,dtype=float)
|
||||
if eu.shape[:-2:-1] != (3,):
|
||||
raise ValueError('Invalid shape.')
|
||||
raise ValueError('Invalid shape')
|
||||
|
||||
eu = np.radians(eu) if degrees else eu
|
||||
if np.any(eu < 0.0) or np.any(eu > 2.0*np.pi) or np.any(eu[...,1] > np.pi): # ToDo: No separate check for PHI
|
||||
raise ValueError('Euler angles outside of [0..2π],[0..π],[0..2π].')
|
||||
raise ValueError('Euler angles outside of [0..2π],[0..π],[0..2π]')
|
||||
|
||||
return Rotation(Rotation._eu2qu(eu))
|
||||
|
||||
|
@ -798,7 +798,7 @@ class Rotation:
|
|||
"""
|
||||
ax = np.array(axis_angle,dtype=float)
|
||||
if ax.shape[:-2:-1] != (4,):
|
||||
raise ValueError('Invalid shape.')
|
||||
raise ValueError('Invalid shape')
|
||||
if abs(P) != 1:
|
||||
raise ValueError('P ∉ {-1,1}')
|
||||
|
||||
|
@ -806,10 +806,10 @@ class Rotation:
|
|||
if degrees: ax[..., 3] = np.radians(ax[...,3])
|
||||
if normalize: ax[...,0:3] /= np.linalg.norm(ax[...,0:3],axis=-1,keepdims=True)
|
||||
if np.any(ax[...,3] < 0.0) or np.any(ax[...,3] > np.pi):
|
||||
raise ValueError('Axis–angle rotation angle outside of [0..π].')
|
||||
raise ValueError('Axis–angle rotation angle outside of [0..π]')
|
||||
if not np.all(np.isclose(np.linalg.norm(ax[...,0:3],axis=-1), 1.0)):
|
||||
print(np.linalg.norm(ax[...,0:3],axis=-1))
|
||||
raise ValueError('Axis–angle rotation axis is not of unit length.')
|
||||
raise ValueError('Axis–angle rotation axis is not of unit length')
|
||||
|
||||
return Rotation(Rotation._ax2qu(ax))
|
||||
|
||||
|
@ -832,7 +832,7 @@ class Rotation:
|
|||
"""
|
||||
om = np.array(basis,dtype=float)
|
||||
if om.shape[-2:] != (3,3):
|
||||
raise ValueError('Invalid shape.')
|
||||
raise ValueError('Invalid shape')
|
||||
|
||||
if reciprocal:
|
||||
om = np.linalg.inv(tensor.transpose(om)/np.pi) # transform reciprocal basis set
|
||||
|
@ -841,11 +841,11 @@ class Rotation:
|
|||
(U,S,Vh) = np.linalg.svd(om) # singular value decomposition
|
||||
om = np.einsum('...ij,...jl',U,Vh)
|
||||
if not np.all(np.isclose(np.linalg.det(om),1.0)):
|
||||
raise ValueError('Orientation matrix has determinant ≠ 1.')
|
||||
raise ValueError('Orientation matrix has determinant ≠ 1')
|
||||
if not np.all(np.isclose(np.einsum('...i,...i',om[...,0],om[...,1]), 0.0)) \
|
||||
or not np.all(np.isclose(np.einsum('...i,...i',om[...,1],om[...,2]), 0.0)) \
|
||||
or not np.all(np.isclose(np.einsum('...i,...i',om[...,2],om[...,0]), 0.0)):
|
||||
raise ValueError('Orientation matrix is not orthogonal.')
|
||||
raise ValueError('Orientation matrix is not orthogonal')
|
||||
|
||||
return Rotation(Rotation._om2qu(om))
|
||||
|
||||
|
@ -879,7 +879,7 @@ class Rotation:
|
|||
a_ = np.array(a)
|
||||
b_ = np.array(b)
|
||||
if a_.shape[-2:] != (2,3) or b_.shape[-2:] != (2,3) or a_.shape != b_.shape:
|
||||
raise ValueError('Invalid shape.')
|
||||
raise ValueError('Invalid shape')
|
||||
am = np.stack([ a_[...,0,:],
|
||||
a_[...,1,:],
|
||||
np.cross(a_[...,0,:],a_[...,1,:]) ],axis=-2)
|
||||
|
@ -910,16 +910,16 @@ class Rotation:
|
|||
"""
|
||||
ro = np.array(rho,dtype=float)
|
||||
if ro.shape[:-2:-1] != (4,):
|
||||
raise ValueError('Invalid shape.')
|
||||
raise ValueError('Invalid shape')
|
||||
if abs(P) != 1:
|
||||
raise ValueError('P ∉ {-1,1}')
|
||||
|
||||
ro[...,0:3] *= -P
|
||||
if normalize: ro[...,0:3] /= np.linalg.norm(ro[...,0:3],axis=-1,keepdims=True)
|
||||
if np.any(ro[...,3] < 0.0):
|
||||
raise ValueError('Rodrigues vector rotation angle is negative.')
|
||||
raise ValueError('Rodrigues vector rotation angle is negative')
|
||||
if not np.all(np.isclose(np.linalg.norm(ro[...,0:3],axis=-1), 1.0)):
|
||||
raise ValueError('Rodrigues vector rotation axis is not of unit length.')
|
||||
raise ValueError('Rodrigues vector rotation axis is not of unit length')
|
||||
|
||||
return Rotation(Rotation._ro2qu(ro))
|
||||
|
||||
|
@ -939,14 +939,14 @@ class Rotation:
|
|||
"""
|
||||
ho = np.array(h,dtype=float)
|
||||
if ho.shape[:-2:-1] != (3,):
|
||||
raise ValueError('Invalid shape.')
|
||||
raise ValueError('Invalid shape')
|
||||
if abs(P) != 1:
|
||||
raise ValueError('P ∉ {-1,1}')
|
||||
|
||||
ho *= -P
|
||||
|
||||
if np.any(np.linalg.norm(ho,axis=-1) >_R1+1e-9):
|
||||
raise ValueError('Homochoric coordinate outside of the sphere.')
|
||||
raise ValueError('Homochoric coordinate outside of the sphere')
|
||||
|
||||
return Rotation(Rotation._ho2qu(ho))
|
||||
|
||||
|
@ -966,12 +966,12 @@ class Rotation:
|
|||
"""
|
||||
cu = np.array(x,dtype=float)
|
||||
if cu.shape[:-2:-1] != (3,):
|
||||
raise ValueError('Invalid shape.')
|
||||
raise ValueError('Invalid shape')
|
||||
if abs(P) != 1:
|
||||
raise ValueError('P ∉ {-1,1}')
|
||||
|
||||
if np.abs(np.max(cu)) > np.pi**(2./3.) * 0.5+1e-9:
|
||||
raise ValueError('Cubochoric coordinate outside of the cube.')
|
||||
raise ValueError('Cubochoric coordinate outside of the cube')
|
||||
|
||||
ho = -P * Rotation._cu2ho(cu)
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ class VTK:
|
|||
reader = vtk.vtkGenericDataObjectReader()
|
||||
reader.SetFileName(str(fname))
|
||||
if dataset_type is None:
|
||||
raise TypeError('Dataset type for *.vtk file not given.')
|
||||
raise TypeError('Dataset type for *.vtk file not given')
|
||||
elif dataset_type.lower().endswith(('imagedata','image_data')):
|
||||
reader.Update()
|
||||
vtk_data = reader.GetStructuredPointsOutput()
|
||||
|
@ -220,7 +220,7 @@ class VTK:
|
|||
reader.Update()
|
||||
vtk_data = reader.GetPolyDataOutput()
|
||||
else:
|
||||
raise TypeError(f'Unknown dataset type {dataset_type} for vtk file')
|
||||
raise TypeError(f'Unknown dataset type "{dataset_type}" for vtk file')
|
||||
else:
|
||||
if ext == '.vti':
|
||||
reader = vtk.vtkXMLImageDataReader()
|
||||
|
@ -231,7 +231,7 @@ class VTK:
|
|||
elif ext == '.vtp':
|
||||
reader = vtk.vtkXMLPolyDataReader()
|
||||
else:
|
||||
raise TypeError(f'Unknown file extension {ext}')
|
||||
raise TypeError(f'Unknown file extension "{ext}"')
|
||||
|
||||
reader.SetFileName(str(fname))
|
||||
reader.Update()
|
||||
|
@ -336,7 +336,7 @@ class VTK:
|
|||
elif N_data == N_cells:
|
||||
self.vtk_data.GetCellData().AddArray(d)
|
||||
else:
|
||||
raise ValueError(f'Cell / point count ({N_cells} / {N_points}) differs from data ({N_data}).')
|
||||
raise ValueError(f'Cell / point count ({N_cells} / {N_points}) differs from data ({N_data})')
|
||||
elif isinstance(data,Table):
|
||||
raise NotImplementedError('damask.Table')
|
||||
else:
|
||||
|
@ -383,7 +383,7 @@ class VTK:
|
|||
# string array
|
||||
return np.array([vtk_array.GetValue(i) for i in range(vtk_array.GetNumberOfValues())]).astype(str)
|
||||
except UnboundLocalError:
|
||||
raise ValueError(f'Array "{label}" not found.')
|
||||
raise ValueError(f'Array "{label}" not found')
|
||||
|
||||
|
||||
def get_comments(self) -> List[str]:
|
||||
|
|
|
@ -300,7 +300,7 @@ def cellsSizeOrigin_coordinates0_point(coordinates0: _np.ndarray,
|
|||
origin[_np.where(cells==1)] = 0.0
|
||||
|
||||
if cells.prod() != len(coordinates0):
|
||||
raise ValueError(f'Data count {len(coordinates0)} does not match cells {cells}.')
|
||||
raise ValueError(f'Data count {len(coordinates0)} does not match cells {cells}')
|
||||
|
||||
start = origin + delta*.5
|
||||
end = origin - delta*.5 + size
|
||||
|
@ -309,11 +309,11 @@ def cellsSizeOrigin_coordinates0_point(coordinates0: _np.ndarray,
|
|||
if not (_np.allclose(coords[0],_np.linspace(start[0],end[0],cells[0]),atol=atol) and \
|
||||
_np.allclose(coords[1],_np.linspace(start[1],end[1],cells[1]),atol=atol) and \
|
||||
_np.allclose(coords[2],_np.linspace(start[2],end[2],cells[2]),atol=atol)):
|
||||
raise ValueError('Regular cell spacing violated.')
|
||||
raise ValueError('Non-uniform cell spacing')
|
||||
|
||||
if ordered and not _np.allclose(coordinates0.reshape(tuple(cells)+(3,),order='F'),
|
||||
coordinates0_point(list(cells),size,origin),atol=atol):
|
||||
raise ValueError('Input data is not ordered (x fast, z slow).')
|
||||
raise ValueError('Input data is not ordered (x fast, z slow)')
|
||||
|
||||
return (cells,size,origin)
|
||||
|
||||
|
@ -460,17 +460,17 @@ def cellsSizeOrigin_coordinates0_node(coordinates0: _np.ndarray,
|
|||
origin = mincorner
|
||||
|
||||
if (cells+1).prod() != len(coordinates0):
|
||||
raise ValueError(f'Data count {len(coordinates0)} does not match cells {cells}.')
|
||||
raise ValueError(f'Data count {len(coordinates0)} does not match cells {cells}')
|
||||
|
||||
atol = _np.max(size)*5e-2
|
||||
if not (_np.allclose(coords[0],_np.linspace(mincorner[0],maxcorner[0],cells[0]+1),atol=atol) and \
|
||||
_np.allclose(coords[1],_np.linspace(mincorner[1],maxcorner[1],cells[1]+1),atol=atol) and \
|
||||
_np.allclose(coords[2],_np.linspace(mincorner[2],maxcorner[2],cells[2]+1),atol=atol)):
|
||||
raise ValueError('Regular cell spacing violated.')
|
||||
raise ValueError('Non-uniform cell spacing')
|
||||
|
||||
if ordered and not _np.allclose(coordinates0.reshape(tuple(cells+1)+(3,),order='F'),
|
||||
coordinates0_node(list(cells),size,origin),atol=atol):
|
||||
raise ValueError('Input data is not ordered (x fast, z slow).')
|
||||
raise ValueError('Input data is not ordered (x fast, z slow)')
|
||||
|
||||
return (cells,size,origin)
|
||||
|
||||
|
|
|
@ -273,7 +273,7 @@ def _polar_decomposition(T: _np.ndarray,
|
|||
output+=[_np.einsum('...ji,...jk',R,T)]
|
||||
|
||||
if len(output) == 0:
|
||||
raise ValueError('output needs to be out of V, R, U')
|
||||
raise ValueError('Output not in {V, R, U}')
|
||||
|
||||
return tuple(output)
|
||||
|
||||
|
|
|
@ -575,7 +575,7 @@ def DREAM3D_base_group(fname: Union[str, Path]) -> str:
|
|||
base_group = f.visit(lambda path: path.rsplit('/',2)[0] if '_SIMPL_GEOMETRY/SPACING' in path else None)
|
||||
|
||||
if base_group is None:
|
||||
raise ValueError(f'Could not determine base group in file {fname}.')
|
||||
raise ValueError(f'Could not determine base group in file {fname}')
|
||||
|
||||
return base_group
|
||||
|
||||
|
@ -606,7 +606,7 @@ def DREAM3D_cell_data_group(fname: Union[str, Path]) -> str:
|
|||
else None)
|
||||
|
||||
if cell_data_group is None:
|
||||
raise ValueError(f'Could not determine cell data group in file {fname}/{base_group}.')
|
||||
raise ValueError(f'Could not determine cell data group in file {fname}/{base_group}')
|
||||
|
||||
return cell_data_group
|
||||
|
||||
|
|
Loading…
Reference in New Issue