55from collections .abc import Callable
66import inspect
77from pathlib import Path
8- from typing import Any , Callable
9-
8+ from typing import Any
109import warnings
1110
1211from ase import Atoms , constraints , filters , units
@@ -125,10 +124,10 @@ def __init__(
125124 filter_class : Callable | str | None = FrechetCellFilter ,
126125 filter_func : Callable | str | None = None ,
127126 filter_kwargs : dict [str , Any ] | None = None ,
128- optimizer : Callable | str = LBFGS ,
129- opt_kwargs : ASEOptArgs | None = None ,
130127 constraint_func : Callable | str | None = None ,
131128 constraint_kwargs : dict [str , Any ] | None = None ,
129+ optimizer : Callable | str = LBFGS ,
130+ opt_kwargs : ASEOptArgs | None = None ,
132131 write_results : bool = False ,
133132 write_kwargs : OutputKwargs | None = None ,
134133 write_traj : bool = False ,
@@ -185,6 +184,11 @@ def __init__(
185184 Deprecated. Please use `filter_class`.
186185 filter_kwargs
187186 Keyword arguments to pass to filter_class. Default is {}.
187+ constraint_func
188+ Constraint function, or name of function from ase.constraints. Default is
189+ None.
190+ constraint_kwargs
191+ Keyword arguments to pass to constraint_func. Default is {}.
188192 optimizer
189193 Optimization function, or name of function from ase.optimize. Default is
190194 `LBFGS`.
@@ -202,9 +206,21 @@ def __init__(
202206 "filename" keyword is inferred from `file_prefix` if not given.
203207 Default is {}.
204208 """
205- read_kwargs , constraint_kwargs , filter_kwargs , opt_kwargs , write_kwargs , traj_kwargs = (
209+ (
210+ read_kwargs ,
211+ constraint_kwargs ,
212+ filter_kwargs ,
213+ opt_kwargs ,
214+ write_kwargs ,
215+ traj_kwargs ,
216+ ) = list (
206217 none_to_dict (
207- (read_kwargs , constraint_kwargs , filter_kwargs , opt_kwargs , write_kwargs , traj_kwargs )
218+ read_kwargs ,
219+ constraint_kwargs ,
220+ filter_kwargs ,
221+ opt_kwargs ,
222+ write_kwargs ,
223+ traj_kwargs ,
208224 )
209225 )
210226
@@ -220,7 +236,7 @@ def __init__(
220236 self .filter_class = filter_class
221237 self .filter_kwargs = filter_kwargs
222238 self .constraint_func = constraint_func
223- self .constraint_kwargs = constraint_kwargs
239+ self .constraint_kwargs = constraint_kwargs
224240 self .optimizer = optimizer
225241 self .opt_kwargs = opt_kwargs
226242 self .write_results = write_results
@@ -312,7 +328,8 @@ def output_files(self) -> None:
312328 }
313329
314330 def _set_mandatory_constraint_kwargs (self ) -> None :
315- """Inspect constraint class for mandatory arguments
331+ """
332+ Inspect constraint class for mandatory arguments.
316333
317334 For now we are just looking for the "atoms" parameter of FixSymmetry
318335 """
@@ -369,9 +386,11 @@ def _set_functions(self) -> None:
369386 try :
370387 self .constraint_func = getattr (constraints , self .constraint_func )
371388 except AttributeError as e :
372- raise AttributeError (f"No such constraint: { self .constraint_func } " ) from e
389+ raise AttributeError (
390+ f"No such constraint: { self .constraint_func } "
391+ ) from e
373392
374- if self .filter_class is not None and isinstance (self .filter_func , str ):
393+ if self .filter_class is not None and isinstance (self .filter_class , str ):
375394 try :
376395 self .filter_class = getattr (filters , self .filter_class )
377396 except AttributeError as e :
0 commit comments