correct printing of error messages
'{}'.format(np.ones(3)) gives only '1', but we want to see '[1 1 1]'
This commit is contained in:
parent
bc1d356d21
commit
a608310920
|
@ -148,7 +148,7 @@ class Geom():
|
||||||
"""
|
"""
|
||||||
if microstructure is not None:
|
if microstructure is not None:
|
||||||
if len(microstructure.shape) != 3:
|
if len(microstructure.shape) != 3:
|
||||||
raise ValueError('Invalid microstructure shape {}'.format(*microstructure.shape))
|
raise ValueError('Invalid microstructure shape {}'.format(microstructure.shape))
|
||||||
elif microstructure.dtype not in np.sctypes['float'] + np.sctypes['int']:
|
elif microstructure.dtype not in np.sctypes['float'] + np.sctypes['int']:
|
||||||
raise TypeError('Invalid data type {} for microstructure'.format(microstructure.dtype))
|
raise TypeError('Invalid data type {} for microstructure'.format(microstructure.dtype))
|
||||||
else:
|
else:
|
||||||
|
@ -169,7 +169,7 @@ class Geom():
|
||||||
self.size = grid/np.max(grid)
|
self.size = grid/np.max(grid)
|
||||||
else:
|
else:
|
||||||
if len(size) != 3 or any(np.array(size)<=0):
|
if len(size) != 3 or any(np.array(size)<=0):
|
||||||
raise ValueError('Invalid size {}'.format(*size))
|
raise ValueError('Invalid size {}'.format(size))
|
||||||
else:
|
else:
|
||||||
self.size = np.array(size)
|
self.size = np.array(size)
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ class Geom():
|
||||||
"""
|
"""
|
||||||
if origin is not None:
|
if origin is not None:
|
||||||
if len(origin) != 3:
|
if len(origin) != 3:
|
||||||
raise ValueError('Invalid origin {}'.format(*origin))
|
raise ValueError('Invalid origin {}'.format(origin))
|
||||||
else:
|
else:
|
||||||
self.origin = np.array(origin)
|
self.origin = np.array(origin)
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ class Geom():
|
||||||
i += len(items)
|
i += len(items)
|
||||||
|
|
||||||
if i != grid.prod():
|
if i != grid.prod():
|
||||||
raise TypeError('Invalid file: expected {} entries,found {}'.format(grid.prod(),i))
|
raise TypeError('Invalid file: expected {} entries, found {}'.format(grid.prod(),i))
|
||||||
|
|
||||||
microstructure = microstructure.reshape(grid,order='F')
|
microstructure = microstructure.reshape(grid,order='F')
|
||||||
if not np.any(np.mod(microstructure.flatten(),1) != 0.0): # no float present
|
if not np.any(np.mod(microstructure.flatten(),1) != 0.0): # no float present
|
||||||
|
@ -458,7 +458,7 @@ class Geom():
|
||||||
if not all(isinstance(d, str) for d in directions):
|
if not all(isinstance(d, str) for d in directions):
|
||||||
raise TypeError('Directions are not of type str.')
|
raise TypeError('Directions are not of type str.')
|
||||||
elif not set(directions).issubset(valid):
|
elif not set(directions).issubset(valid):
|
||||||
raise ValueError('Invalid direction specified {}'.format(*set(directions).difference(valid)))
|
raise ValueError('Invalid direction specified {}'.format(set(directions).difference(valid)))
|
||||||
|
|
||||||
limits = [None,None] if reflect else [-2,0]
|
limits = [None,None] if reflect else [-2,0]
|
||||||
ms = self.get_microstructure()
|
ms = self.get_microstructure()
|
||||||
|
|
Loading…
Reference in New Issue