Skip to content

Commit

Permalink
White listed keyword arguments are initialized to None.
Browse files Browse the repository at this point in the history
If white listed keyword arguments are not passed by users we initialized
them to None.
  • Loading branch information
muammar committed Nov 6, 2019
1 parent b5c9fc0 commit f7cb1c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 16 additions & 8 deletions ml4chem/models/autoencoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,15 @@ def __init__(self, hiddenlayers=None, activation="relu", **kwargs):
self.activation = activation

# A white list of supported kwargs.
supported_kwargs = ["multivariate"]
supported_keys = ["multivariate"]

for k, v in kwargs.items():
if k in supported_kwargs:
setattr(self, k, v)
if len(kwargs.items()) == 0:
for k in supported_keys:
setattr(self, k, None)
else:
for k, v in kwargs.items():
if k in supported_keys:
setattr(self, k, v)

def prepare_model(
self, input_dimension, output_dimension, data=None, purpose="training"
Expand Down Expand Up @@ -652,11 +656,15 @@ def __init__(
**kwargs
):

supported_kwargs = ["anneal", "penalize_latent"]
supported_keys = ["anneal", "penalize_latent"]

for k, v in kwargs.items():
if k in supported_kwargs:
setattr(self, k, v)
if len(kwargs.items()) == 0:
for k in supported_keys:
setattr(self, k, None)
else:
for k, v in kwargs.items():
if k in supported_keys:
setattr(self, k, v)

self.initial_time = time.time()

Expand Down
2 changes: 2 additions & 0 deletions ml4chem/potentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ def save(model=None, features=None, path=None, label="ml4chem"):
if model_name in Potentials.autoencoders:
output_dimension = {"output_dimension": model.output_dimension}
params["model"].update(output_dimension)
multivariate = {"multivariate": model.multivariate}
params["model"].update(multivariate)
else:
params = {}

Expand Down

0 comments on commit f7cb1c9

Please sign in to comment.