@@ -24,9 +24,14 @@ impl PyBondValenceModel {
24
24
/// * mol: The molecule to evaluate.
25
25
/// * opts: optional bond valence parameters
26
26
#[ staticmethod]
27
- fn evaluate ( mol : PyMolecule , opts : Option < Options > ) -> HashMap < usize , Evaluated > {
28
- let opts = opts. unwrap_or_else ( || Options :: default_from ( & mol. inner ) ) ;
29
- BondValenceModel :: evaluate ( & mol. inner , & opts)
27
+ fn evaluate ( mol : PyMolecule , opts : Option < & mut Options > ) -> HashMap < usize , Evaluated > {
28
+ // let mut opts = opts.unwrap_or_else(|| Options::default_from(&mol.inner));
29
+ if let Some ( opts) = opts {
30
+ BondValenceModel :: evaluate ( & mol. inner , opts)
31
+ } else {
32
+ let mut opts = Options :: default_from ( & mol. inner ) ;
33
+ BondValenceModel :: evaluate ( & mol. inner , & mut opts)
34
+ }
30
35
}
31
36
32
37
/// Create chemical bonds from nearest neighbors based on bond
@@ -36,10 +41,15 @@ impl PyBondValenceModel {
36
41
/// created.
37
42
#[ staticmethod]
38
43
#[ pyo3( signature = ( mol, /, opts=None , ignore_pbc=false ) ) ]
39
- fn rebond ( mol : & mut PyMolecule , opts : Option < Options > , ignore_pbc : bool ) -> usize {
40
- let opts = opts. unwrap_or_else ( || Options :: default_from ( & mol. inner ) ) ;
44
+ fn rebond ( mol : & mut PyMolecule , opts : Option < & mut Options > , ignore_pbc : bool ) -> usize {
41
45
let lat = if ignore_pbc { mol. unbuild_crystal ( ) } else { None } ;
42
- let nbonds = BondValenceModel :: rebond ( & mut mol. inner , & opts) ;
46
+ let nbonds = if let Some ( opts) = opts {
47
+ BondValenceModel :: rebond ( & mut mol. inner , opts)
48
+ } else {
49
+ let mut opts = Options :: default_from ( & mol. inner ) ;
50
+ BondValenceModel :: rebond ( & mut mol. inner , & mut opts)
51
+ } ;
52
+
43
53
if ignore_pbc {
44
54
if let Some ( lat) = lat {
45
55
mol. set_lattice ( lat) ;
0 commit comments