5
5
from collections .abc import Callable
6
6
import inspect
7
7
from pathlib import Path
8
- from typing import Any , Callable
9
-
8
+ from typing import Any
10
9
import warnings
11
10
12
11
from ase import Atoms , constraints , filters , units
@@ -125,10 +124,10 @@ def __init__(
125
124
filter_class : Callable | str | None = FrechetCellFilter ,
126
125
filter_func : Callable | str | None = None ,
127
126
filter_kwargs : dict [str , Any ] | None = None ,
128
- optimizer : Callable | str = LBFGS ,
129
- opt_kwargs : ASEOptArgs | None = None ,
130
127
constraint_func : Callable | str | None = None ,
131
128
constraint_kwargs : dict [str , Any ] | None = None ,
129
+ optimizer : Callable | str = LBFGS ,
130
+ opt_kwargs : ASEOptArgs | None = None ,
132
131
write_results : bool = False ,
133
132
write_kwargs : OutputKwargs | None = None ,
134
133
write_traj : bool = False ,
@@ -185,6 +184,11 @@ def __init__(
185
184
Deprecated. Please use `filter_class`.
186
185
filter_kwargs
187
186
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 {}.
188
192
optimizer
189
193
Optimization function, or name of function from ase.optimize. Default is
190
194
`LBFGS`.
@@ -202,9 +206,21 @@ def __init__(
202
206
"filename" keyword is inferred from `file_prefix` if not given.
203
207
Default is {}.
204
208
"""
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 (
206
217
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 ,
208
224
)
209
225
)
210
226
@@ -220,7 +236,7 @@ def __init__(
220
236
self .filter_class = filter_class
221
237
self .filter_kwargs = filter_kwargs
222
238
self .constraint_func = constraint_func
223
- self .constraint_kwargs = constraint_kwargs
239
+ self .constraint_kwargs = constraint_kwargs
224
240
self .optimizer = optimizer
225
241
self .opt_kwargs = opt_kwargs
226
242
self .write_results = write_results
@@ -312,7 +328,8 @@ def output_files(self) -> None:
312
328
}
313
329
314
330
def _set_mandatory_constraint_kwargs (self ) -> None :
315
- """Inspect constraint class for mandatory arguments
331
+ """
332
+ Inspect constraint class for mandatory arguments.
316
333
317
334
For now we are just looking for the "atoms" parameter of FixSymmetry
318
335
"""
@@ -369,9 +386,11 @@ def _set_functions(self) -> None:
369
386
try :
370
387
self .constraint_func = getattr (constraints , self .constraint_func )
371
388
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
373
392
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 ):
375
394
try :
376
395
self .filter_class = getattr (filters , self .filter_class )
377
396
except AttributeError as e :
0 commit comments