From 1790a73d782de98aa3d223eb39426d67ec38891d Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 20 Jan 2025 10:46:24 -0500 Subject: [PATCH 1/2] improved regex --- python/damask/_rotation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index dee69e5f2..694d865db 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -95,8 +95,8 @@ def __str__(self) -> str: 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__()) + return re.sub(r'\[([ +-]*[0-9.]+)(\s*)([ +-]*[0-9.]+)(\s*)([ +-]*[0-9.]+)(\s*)([ +-]*[0-9.]+)(\s*)\]', + r'\1\2 \3\4\5\6\7\8',self.quaternion.__str__()) def __repr__(self) -> str: @@ -106,7 +106,7 @@ def __repr__(self) -> str: Give unambiguous representation. """ - return re.sub(r'\[(\+|-| )([^,]+,)\s*(\+|-| )([^,]+,)\s*(\+|-| )([^,]+,)\s*(\+|-| )(.+?)\]', + return re.sub(r'\[(\+|-| )*(?=\d)([^,]+,)\s*?(\+|-| )*(?=\d)([^,]+,)\s*?(\+|-| )*(?=\d)([^,]+,)\s*?(\+|-| )*(?=\d)(.+?)\]', r'(\1\2 \3\4 \5\6 \7\8)',self.quaternion.__repr__()) From 3155dd6b1aaeb18fd4a9a1495dba449a4ad73be5 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 20 Jan 2025 16:32:01 -0500 Subject: [PATCH 2/2] include scientific notation in regex --- python/damask/_rotation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index 694d865db..77eb165cd 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -95,7 +95,7 @@ def __str__(self) -> str: Give short, human-readable summary. """ - return re.sub(r'\[([ +-]*[0-9.]+)(\s*)([ +-]*[0-9.]+)(\s*)([ +-]*[0-9.]+)(\s*)([ +-]*[0-9.]+)(\s*)\]', + return re.sub(r'\[([ +-]*[0-9.eE+-]+)(\s*)([ +-]*[0-9.eE+-]+)(\s*)([ +-]*[0-9.eE+-]+)(\s*)([ +-]*[0-9.eE+-]+)(\s*)\]', r'\1\2 \3\4\5\6\7\8',self.quaternion.__str__())