Skip to content

Commit

Permalink
Reusing set_models_path in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-noel committed May 7, 2020
1 parent 5918c6f commit 9658ed2
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions maboss/ensemble/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,12 @@ class Ensemble(object):

def __init__(self, path, cfg_filename=None, individual_istates=collections.OrderedDict(), individual_mutations=collections.OrderedDict(), models=None, *args, **kwargs):

if path.lower().endswith(".zip"):
self.models_path = tempfile.mkdtemp(prefix="maboss-ensemble")
def cleanup(d):
shutil.rmtree(d)
atexit.register(cleanup, self.models_path)
with ZipFile(path) as zin:
zin.extractall(self.models_path)
else:
self.models_path = path
self.set_models_path(path)

self.param = _default_parameter_list
self.param["use_physrandgen"] = 0

if models is None:
self.models_files = [
os.path.join(self.models_path, filename)
for filename in os.listdir(self.models_path)
if filename.endswith(".bnet") or filename.endswith(".bnd")
]
else:
if models is not None:
self.models_files = [
os.path.join(self.models_path, filename)
for filename in models
Expand Down

0 comments on commit 9658ed2

Please sign in to comment.