@@ -100,46 +100,53 @@ def test_IMAS_input_with_equilibrium_object(self):
100100
101101 def test_IMAS_loading_specific_slice (self ):
102102 filename = 'ITERhybrid_rampup_11_time_slices_COCOS17_IDS_ddv4.nc'
103- SLICE_TIME = 40
104- SLICE_INDEX = 5
105103 config_at_0 = geometry_pydantic_model .IMASConfig (imas_filepath = filename )
106104 config_at_slice_from_time = geometry_pydantic_model .IMASConfig (
107- imas_filepath = filename , slice_time = SLICE_TIME
105+ imas_filepath = filename , slice_time = 40
108106 )
109107 config_at_slice_from_index = geometry_pydantic_model .IMASConfig (
110- imas_filepath = filename , slice_index = SLICE_INDEX
108+ imas_filepath = filename , slice_index = 5
111109 )
110+
112111 geo_at_0 = config_at_0 .build_geometry ()
113112 geo_at_slice_from_time = config_at_slice_from_time .build_geometry ()
114113 geo_at_slice_from_index = config_at_slice_from_index .build_geometry ()
115114
116- for key in geo_at_0 .__dict__ .keys ():
117- if key not in ['geometry_type' , 'torax_mesh' , 'R_major' , 'B_0' , 'rho_hires_norm' , 'Phi_b_dot' , 'Ip_from_parameters' ]:
118- np .testing .assert_allclose (
119- geo_at_slice_from_time .__dict__ [key ],
120- geo_at_slice_from_index .__dict__ [key ],
121- err_msg = f'Value { key } mismatched between slice_time and slice_index' ,
122- )
123- with self .assertRaises (AssertionError ):
124- np .testing .assert_allclose (
125- geo_at_0 .__dict__ [key ],
126- geo_at_slice_from_time .__dict__ [key ],
127- )
128- with self .assertRaises (AssertionError ):
115+ # Check that the geometry is not the same as at t=0
116+ with self .assertRaises (AssertionError ):
117+ for key in geo_at_slice_from_time .__dict__ .keys ():
118+ if key not in [
119+ 'geometry_type' ,
120+ 'torax_mesh' ,
121+ 'R_major' ,
122+ 'B_0' ,
123+ 'rho_hires_norm' ,
124+ 'Phi_b_dot' ,
125+ 'Ip_from_parameters' ,
126+ ]:
129127 np .testing .assert_allclose (
130128 geo_at_0 .__dict__ [key ],
131129 geo_at_slice_from_index .__dict__ [key ],
132130 )
133131
134- def test_IMAS_raises_if_slice_specified_twice (self ):
135- filename = 'ITERhybrid_COCOS17_IDS_ddv4.nc'
136- with self .assertRaisesRegex (
137- pydantic .ValidationError ,
138- 'exactly one of `slice_time` and `slice_index`' ,
139- ):
140- geometry_pydantic_model .IMASConfig (
141- imas_filepath = filename , slice_index = 1 , slice_time = 1
142- )
132+ # Check that the geometry at index and time are the same
133+ for key in geo_at_slice_from_time .__dict__ .keys ():
134+ if key not in [
135+ 'geometry_type' ,
136+ 'torax_mesh' ,
137+ 'R_major' ,
138+ 'B_0' ,
139+ 'rho_hires_norm' ,
140+ 'Phi_b_dot' ,
141+ 'Ip_from_parameters' ,
142+ ]:
143+ np .testing .assert_allclose (
144+ geo_at_slice_from_time .__dict__ [key ],
145+ geo_at_slice_from_index .__dict__ [key ],
146+ err_msg = (
147+ f'Value { key } mismatched between slice_time and slice_index'
148+ ),
149+ )
143150
144151 def test_IMAS_raises_if_slice_out_of_range (self ):
145152 filename = 'ITERhybrid_COCOS17_IDS_ddv4.nc'
0 commit comments