Skip to content

Commit

Permalink
Merge branch '445-pretty-reporting-for-rotation-and-orientation' into…
Browse files Browse the repository at this point in the history
… 'development'

increased readability

Closes #445

See merge request damask/DAMASK!971
  • Loading branch information
eisenlohr committed Aug 30, 2024
2 parents 5d31244 + c84e545 commit e58d2fe
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions python/damask/_rotation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import copy
import re
import builtins
from typing import Optional, Union, Sequence, Tuple, Literal, List, TypeVar

Expand Down Expand Up @@ -87,15 +88,26 @@ def __init__(self,
raise TypeError('"rotation" is neither a Rotation nor a quaternion')


def __str__(self) -> str:
"""
Return str(self).
Give short, human-readable summary.
"""
return re.sub(r'\[(\+|-| )([^\s]+)\s*(\+|-| )([^\s]+)\s*(\+|-| )([^\s]+)\s*(\+|-| )(.+?)\]',
r'\1\2 \3\4 \5\6 \7\8',self.quaternion.__str__())


def __repr__(self) -> str:
"""
Return repr(self).
Give short, human-readable summary.
Give unambiguous representation.
"""
return f'Quaternion{" " if self.quaternion.shape == (4,) else "s of shape "+str(self.quaternion.shape[:-1])+chr(10)}'\
+ str(self.quaternion)
return re.sub(r'\[(\+|-| )([^,]+,)\s*(\+|-| )([^,]+,)\s*(\+|-| )([^,]+,)\s*(\+|-| )(.+?)\]',
r'(\1\2 \3\4 \5\6 \7\8)',self.quaternion.__repr__())


def __copy__(self: MyType,
Expand Down

0 comments on commit e58d2fe

Please sign in to comment.