From 3cff8b3e0c7ea1272f715596a3b71402e72e277e Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 23 Jul 2024 21:38:01 +0200 Subject: [PATCH] fix test with regular expression --- tests/field/test_normal_field.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/field/test_normal_field.py b/tests/field/test_normal_field.py index 3e55dd965..d5152c283 100644 --- a/tests/field/test_normal_field.py +++ b/tests/field/test_normal_field.py @@ -1,6 +1,7 @@ import os import unittest import logging +import re import numpy as np from monty.tempfile import ScratchDir @@ -576,9 +577,9 @@ def test_double_reduction(self): coilset = CoilSet(base_coils=base_coils, surface=surface) cnf = CoilNormalField(coilset) cnf.reduce_coilset() - num1 = int(cnf.dof_names[0][14]) # grab 'ReducedCoilSet*N* from first dof name + num1 = int(re.search(r'\d+', cnf.dof_names[0]).group()) # grab 'ReducedCoilSet*N* from first dof name cnf.reduce_coilset() - num2 = int(cnf.dof_names[0][14]) # grab 'ReducedCoilSet*N* from first dof name + num2 = int(re.search(r'\d+', cnf.dof_names[0]).group()) # grab 'ReducedCoilSet*N* from first dof name self.assertEqual(num2-num1, 1) # Coilset sucessfully replaced