unified.
the default python description "Return repr(self)." is pretty useless, so better agree on a DAMASK standard
This commit is contained in:
parent
59755c67ce
commit
77e57a268c
|
@ -111,7 +111,7 @@ class Crystal():
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
"""Represent."""
|
"""Give short human-readable summary."""
|
||||||
family = f'Crystal family: {self.family}'
|
family = f'Crystal family: {self.family}'
|
||||||
return family if self.lattice is None else \
|
return family if self.lattice is None else \
|
||||||
'\n'.join([family,
|
'\n'.join([family,
|
||||||
|
|
|
@ -58,7 +58,7 @@ class Grid:
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Basic information on grid definition."""
|
"""Give short human-readable summary."""
|
||||||
mat_min = np.nanmin(self.material)
|
mat_min = np.nanmin(self.material)
|
||||||
mat_max = np.nanmax(self.material)
|
mat_max = np.nanmax(self.material)
|
||||||
mat_N = self.N_materials
|
mat_N = self.N_materials
|
||||||
|
|
|
@ -120,7 +120,7 @@ class Orientation(Rotation,Crystal):
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Represent."""
|
"""Give short human readable summary."""
|
||||||
return '\n'.join([Crystal.__repr__(self),
|
return '\n'.join([Crystal.__repr__(self),
|
||||||
Rotation.__repr__(self)])
|
Rotation.__repr__(self)])
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,7 @@ class Result:
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
"""Show summary of file content."""
|
"""Give short human-readable summary."""
|
||||||
with h5py.File(self.fname,'r') as f:
|
with h5py.File(self.fname,'r') as f:
|
||||||
header = [f'Created by {f.attrs["creator"]}',
|
header = [f'Created by {f.attrs["creator"]}',
|
||||||
f' on {f.attrs["created"]}',
|
f' on {f.attrs["created"]}',
|
||||||
|
|
|
@ -88,7 +88,7 @@ class Rotation:
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Represent rotation as unit quaternion(s)."""
|
"""Give short human readable summary."""
|
||||||
return f'Quaternion{" " if self.quaternion.shape == (4,) else "s of shape "+str(self.quaternion.shape[:-1])+chr(10)}'\
|
return f'Quaternion{" " if self.quaternion.shape == (4,) else "s of shape "+str(self.quaternion.shape[:-1])+chr(10)}'\
|
||||||
+ str(self.quaternion)
|
+ str(self.quaternion)
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ class Table:
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Brief overview."""
|
"""Give short human-readable summary."""
|
||||||
self._relabel('shapes')
|
self._relabel('shapes')
|
||||||
data_repr = self.data.__repr__()
|
data_repr = self.data.__repr__()
|
||||||
self._relabel('uniform')
|
self._relabel('uniform')
|
||||||
|
|
|
@ -459,6 +459,7 @@ class VTK:
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
|
"""Give short human-readable summary."""
|
||||||
info = []
|
info = []
|
||||||
if isinstance(self.vtk_data,vtk.vtkImageData):
|
if isinstance(self.vtk_data,vtk.vtkImageData):
|
||||||
info.append('vtkImageData')
|
info.append('vtkImageData')
|
||||||
|
|
Loading…
Reference in New Issue