@@ -20,7 +20,7 @@ class SetDefinition(Enum):
2020 SCAN = 3
2121
2222
23- def float_or_keep (temp_or_field : str )-> Optional [float ]:
23+ def float_or_keep (temp_or_field : str ) -> Optional [float ]:
2424 """
2525 Convert the input to a float or None if the input is keep (to allow not changing of a
2626 temperature or field).
@@ -45,7 +45,7 @@ def float_or_keep(temp_or_field: str)-> Optional[float]:
4545magnet_not_applicable = "N/A"
4646
4747
48- def magnet_device_type (magnet_device : str )-> str :
48+ def magnet_device_type (magnet_device : str ) -> str :
4949 """
5050 Take the shortened magnet selection input e.g. ZF, LF or TF and cast it to the
5151 required string i.e. Active ZF, Danfysik, T20 Coils.
@@ -69,7 +69,7 @@ def magnet_device_type(magnet_device: str)-> str:
6969 raise ValueError ("Magnet device must be one of {} or N/A" .format (list (magnet_devices .keys ())))
7070
7171
72- def cast_custom_expression (expression :str )-> str :
72+ def cast_custom_expression (expression : str ) -> str :
7373 """
7474 Ensure a custom python expression is not empty (this will cause an error) by filling it with
7575 None (does nothing).
@@ -87,7 +87,7 @@ def cast_custom_expression(expression:str)-> str:
8787 return expression
8888
8989
90- def inclusive_float_range_with_step_flip (start : float , stop :float , step :float ) -> Generator :
90+ def inclusive_float_range_with_step_flip (start : float , stop : float , step : float ) -> Generator :
9191 """
9292 If we are counting downwards from start to stop automatically flips step to be negative.
9393 Inclusive of stop. Only tested for float values.
@@ -120,9 +120,11 @@ class DoRun(ScriptDefinition):
120120 active_zf = "Active ZF"
121121 possible_magnet_devices = [active_zf , "Danfysik" , "T20 Coils" ]
122122
123- def get_help (self )-> str :
124- return (f"Magnet device must be one of { list (magnet_devices .keys ())} or if the field is "
125- f"KEEP then it can be N/A.\n If the field is zero magnet device must be ZF.\n " )
123+ def get_help (self ) -> str :
124+ return (
125+ f"Magnet device must be one of { list (magnet_devices .keys ())} or if the field is "
126+ f"KEEP then it can be N/A.\n If the field is zero magnet device must be ZF.\n "
127+ )
126128
127129 @cast_parameters_to (
128130 start_temperature = float_or_keep ,
@@ -144,9 +146,9 @@ def estimate_time(
144146 stop_field : Optional [float ] = 1.0 ,
145147 step_field : float = 1.0 ,
146148 custom : str = "None" ,
147- mevents :float = 10 ,
149+ mevents : float = 10 ,
148150 magnet_device : str = "N/A" ,
149- )-> int :
151+ ) -> int :
150152 return 0
151153
152154 # Loop through a set of temperatures or fields using a start, stop and step mechanism
@@ -163,22 +165,22 @@ def estimate_time(
163165 )
164166 def run (
165167 self ,
166- start_temperature : Optional [float ]= "keep" , # type: ignore[reportArgumentType],
167- stop_temperature : Optional [float ]= "keep" , # type: ignore[reportArgumentType],
168- step_temperature : float = 0 ,
169- start_field : Optional [float ]= "keep" , # type: ignore[reportArgumentType],
170- stop_field : Optional [float ]= "keep" , # type: ignore[reportArgumentType],
171- step_field :float = 0 ,
172- custom :str = "None" ,
173- mevents :float = 10 ,
174- magnet_device :str = "N/A" ,
175- )-> None :
168+ start_temperature : Optional [float ] = "keep" , # type: ignore[reportArgumentType],
169+ stop_temperature : Optional [float ] = "keep" , # type: ignore[reportArgumentType],
170+ step_temperature : float = 0 ,
171+ start_field : Optional [float ] = "keep" , # type: ignore[reportArgumentType],
172+ stop_field : Optional [float ] = "keep" , # type: ignore[reportArgumentType],
173+ step_field : float = 0 ,
174+ custom : str = "None" ,
175+ mevents : float = 10 ,
176+ magnet_device : str = "N/A" ,
177+ ) -> None :
176178 # Scan if start and stop are different, set once if they are equal or do not set if they are
177179 # None
178180 temp_set_definition = self .check_set_definition (start_temperature , stop_temperature )
179181 field_set_definition = self .check_set_definition (start_field , stop_field )
180182 # Use the instrument scripts to set the magnet device correctly
181- import inst # type:ignore
183+ import inst # type:ignore
182184
183185 if field_set_definition != SetDefinition .UNDEFINED :
184186 self .set_magnet_device (magnet_device , inst )
@@ -210,7 +212,11 @@ def run(
210212 assert start_temperature is not None
211213 assert stop_temperature is not None
212214 self .run_scans (
213- start_temperature , stop_temperature , step_temperature , mevents , inst .settemp
215+ start_temperature ,
216+ stop_temperature ,
217+ step_temperature ,
218+ mevents ,
219+ inst .settemp ,
214220 )
215221 elif field_set_definition == SetDefinition .SCAN : # Run scans for the field
216222 assert start_field is not None
@@ -240,11 +246,17 @@ def set_magnet_device(self, magnet_device: str, inst: ModuleType) -> None:
240246 magnet_device (str): The string representation of the magnet device to select.
241247 inst (module): The instrument scripts module to set the magnet device with.
242248 """
243- magnet_to_function_map = {"Active ZF" : inst .f0 , "Danfysik" : inst .lf0 , "T20 Coils" : inst .tf0 }
249+ magnet_to_function_map = {
250+ "Active ZF" : inst .f0 ,
251+ "Danfysik" : inst .lf0 ,
252+ "T20 Coils" : inst .tf0 ,
253+ }
244254 if g .cget ("a_selected_magnet" )["value" ] != magnet_device :
245255 magnet_to_function_map [magnet_device ]()
246256
247- def check_set_definition (self , start_temp_or_field : Optional [float ], stop_temp_or_field : Optional [float ]) -> Enum :
257+ def check_set_definition (
258+ self , start_temp_or_field : Optional [float ], stop_temp_or_field : Optional [float ]
259+ ) -> Enum :
248260 """
249261 Check if we are running a scan, doing one set (a point) or not setting at all.
250262
@@ -297,7 +309,12 @@ def run_temp_and_field_scans(
297309 self .run_scans (start_field , stop_field , step_field , mevents , inst .setmag )
298310
299311 def run_scans (
300- self , start : float , stop : float , step : float , mevents : float , set_parameter_func : Callable
312+ self ,
313+ start : float ,
314+ stop : float ,
315+ step : float ,
316+ mevents : float ,
317+ set_parameter_func : Callable ,
301318 ) -> None :
302319 """
303320 Run a scan for the given set_parameter_func
@@ -358,7 +375,9 @@ def parameters_valid(
358375 else :
359376 return None
360377
361- def check_start_and_stop_valid (self , start : Optional [float ], stop : Optional [float ], variable_name : str ) -> str :
378+ def check_start_and_stop_valid (
379+ self , start : Optional [float ], stop : Optional [float ], variable_name : str
380+ ) -> str :
362381 """
363382 Check that start and stop are either both None or both values.
364383
@@ -399,7 +418,11 @@ def check_if_start_or_stop_field_are_keep_then_magnet_is_na(
399418 return ""
400419
401420 def check_step_set_correctly (
402- self , start : Optional [float ], stop : Optional [float ], step : float , variable_name : str
421+ self ,
422+ start : Optional [float ],
423+ stop : Optional [float ],
424+ step : float ,
425+ variable_name : str ,
403426 ) -> str :
404427 """
405428 If we are scanning check that the step is positive and not zero.
@@ -426,7 +449,10 @@ def check_step_set_correctly(
426449 return reason
427450
428451 def check_magnet_selected_correctly (
429- self , start_field : Optional [float ], stop_field : Optional [float ], magnet_device : str
452+ self ,
453+ start_field : Optional [float ],
454+ stop_field : Optional [float ],
455+ magnet_device : str ,
430456 ) -> str :
431457 """
432458 If we are setting a field check:
0 commit comments