From e0e39b1d926f1b45fa76c3c2f9d3dad1fadae124 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" <1330696+mr-c@users.noreply.github.com> Date: Tue, 10 Sep 2024 12:56:24 +0200 Subject: [PATCH] mark several strings as raw To deal with a Windows slash, and other sequences that get misinterpreted as escape sequences Prevents the following warnings: ``` /usr/share/invesalius/app.py:507: SyntaxWarning: invalid escape sequence '\I' key = "InVesalius 3.1\InstalliationDir" /usr/share/invesalius/invesalius/data/transformations.py:33: SyntaxWarning: invalid escape sequence '\*' """Homogeneous Transformation Matrices and Quaternions. /usr/share/invesalius/invesalius/data/transformations.py:890: SyntaxWarning: invalid escape sequence '\*' """Return affine transform matrix to register two point sets. /usr/share/invesalius/invesalius/data/transformations.py:999: SyntaxWarning: invalid escape sequence '\*' """Return matrix to transform given 3D point set into second point set. /usr/share/invesalius/invesalius/reader/bitmap_reader.py:121: SyntaxWarning: invalid escape sequence '\d' c_re = re.compile("\d+") ``` --- app.py | 2 +- invesalius/data/transformations.py | 6 +++--- invesalius/reader/bitmap_reader.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 6ce84a0ff..c18452f43 100644 --- a/app.py +++ b/app.py @@ -520,7 +520,7 @@ def init(): if hasattr(sys, "frozen") and sys.platform.startswith("win"): # Click in the .inv3 file support root = winreg.HKEY_CLASSES_ROOT - key = "InVesalius 3.1\InstallationDir" + key = r"InVesalius 3.1\InstallationDir" hKey = winreg.OpenKey(root, key, 0, winreg.KEY_READ) value, type_ = winreg.QueryValueEx(hKey, "") path = os.path.join(value, "dist") diff --git a/invesalius/data/transformations.py b/invesalius/data/transformations.py index b50ecb1ea..451c3b2ab 100644 --- a/invesalius/data/transformations.py +++ b/invesalius/data/transformations.py @@ -30,7 +30,7 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -"""Homogeneous Transformation Matrices and Quaternions. +r"""Homogeneous Transformation Matrices and Quaternions. A library for calculating 4x4 matrices for translating, rotating, reflecting, scaling, shearing, projecting, orthogonalizing, and superimposing arrays of @@ -896,7 +896,7 @@ def orthogonalization_matrix(lengths, angles): def affine_matrix_from_points(v0, v1, shear=True, scale=True, usesvd=True): - """Return affine transform matrix to register two point sets. + r"""Return affine transform matrix to register two point sets. v0 and v1 are shape (ndims, \*) arrays of at least ndims non-homogeneous coordinates, where ndims is the dimensionality of the coordinate space. @@ -1007,7 +1007,7 @@ def affine_matrix_from_points(v0, v1, shear=True, scale=True, usesvd=True): def superimposition_matrix(v0, v1, scale=False, usesvd=True): - """Return matrix to transform given 3D point set into second point set. + r"""Return matrix to transform given 3D point set into second point set. v0 and v1 are shape (3, \*) or (4, \*) arrays of at least 3 points. diff --git a/invesalius/reader/bitmap_reader.py b/invesalius/reader/bitmap_reader.py index dda01bbbe..bc9dabfc4 100644 --- a/invesalius/reader/bitmap_reader.py +++ b/invesalius/reader/bitmap_reader.py @@ -127,7 +127,7 @@ def Add(self, bmp): self.bitmapfiles.append(bmp) def Sort(self, x): - c_re = re.compile("\d+") + c_re = re.compile(r"\d+") if len(c_re.findall(x[6])) > 0: return [int(i) for i in c_re.findall(x[6])] else: