33import numpy as np
44import os
55import re
6- import sys
76from collections import OrderedDict
87
98from conftest import skipif
2423from devito .petsc .logging import PetscSummary
2524from devito .petsc .solver_parameters import linear_solve_defaults
2625
26+
2727@pytest .fixture (scope = 'session' )
2828def command_line ():
29- # one prefix per test
29+ # One random prefix to use per test that "tests" the command line args
3030 prefix = ('d17weqroegn' , 'riabfodkj' )
3131
3232 petsc_option = (
3333 ('ksp_rtol' ,),
34- ('ksp_rtol' ,'ksp_atol' )
34+ ('ksp_rtol' , 'ksp_atol' )
3535 )
3636 value = (
37- (' 1e-8' ,),
38- (' 1e-11' , ' 1e-15' ),
37+ (1e-8 ,),
38+ (1e-11 , 1e-15 ),
3939 )
4040 argv = []
41-
4241 expected = {}
4342 for p , opt , val in zip (prefix , petsc_option , value , strict = True ):
4443 for o , v in zip (opt , val , strict = True ):
45- argv .extend ([f'-{ p } _{ o } ' , v ])
46- expected [p ] = zip (opt ,val )
44+ argv .extend ([f'-{ p } _{ o } ' , str ( v ) ])
45+ expected [p ] = zip (opt , val )
4746 return argv , expected
4847
4948
@@ -1448,7 +1447,7 @@ def test_logging(self, log_level):
14481447 # the tolerances should match the default linear values.
14491448 tols = entry0 .KSPGetTolerances
14501449 assert tols ['rtol' ] == linear_solve_defaults ['ksp_rtol' ]
1451- assert tols ['abstol ' ] == linear_solve_defaults ['ksp_atol' ]
1450+ assert tols ['atol ' ] == linear_solve_defaults ['ksp_atol' ]
14521451 assert tols ['dtol' ] == linear_solve_defaults ['ksp_divtol' ]
14531452 assert tols ['maxits' ] == linear_solve_defaults ['ksp_max_it' ]
14541453
@@ -1655,7 +1654,7 @@ def test_tolerances(self, log_level):
16551654 # Test that the tolerances have been set correctly and therefore
16561655 # appear as expected in the `PetscSummary`.
16571656 assert tolerances ['rtol' ] == params ['ksp_rtol' ]
1658- assert tolerances ['abstol ' ] == params ['ksp_atol' ]
1657+ assert tolerances ['atol ' ] == params ['ksp_atol' ]
16591658 assert tolerances ['dtol' ] == params ['ksp_divtol' ]
16601659 assert tolerances ['maxits' ] == params ['ksp_max_it' ]
16611660
@@ -1754,7 +1753,7 @@ def test_command_line_priority_1(self, command_line):
17541753 petsc_summary = summary .petsc
17551754 entry = petsc_summary .get_entry ('section0' , prefix )
17561755 for opt , val in expected [prefix ]:
1757- assert str ( entry .KSPGetTolerances [opt .removeprefix ('ksp_' )]) == val
1756+ assert entry .KSPGetTolerances [opt .removeprefix ('ksp_' )] == val
17581757
17591758 @skipif ('petsc' )
17601759 def test_command_line_priority_2 (self , command_line ):
@@ -1774,7 +1773,7 @@ def test_command_line_priority_2(self, command_line):
17741773 petsc_summary = summary .petsc
17751774 entry = petsc_summary .get_entry ('section0' , prefix )
17761775 for opt , val in expected [prefix ]:
1777- assert str ( entry .KSPGetTolerances [opt .removeprefix ('ksp_' )]) == val
1776+ assert entry .KSPGetTolerances [opt .removeprefix ('ksp_' )] == val
17781777
17791778
17801779class TestHashing :
0 commit comments