Upgrading tests of model, and adding better file management, Model.calculate_volumes method and Model.plot_geometry method. These last two still need to be tested as well as Model.deplete

This commit is contained in:
agnelson 2021-09-28 08:44:31 -05:00
parent d45af5a4ef
commit e62ba9b85a
5 changed files with 396 additions and 87 deletions

View file

@ -1,10 +1,25 @@
from collections.abc import Iterable
from numbers import Integral
import subprocess
from contextlib import contextmanager
from pathlib import Path
import os
import openmc
@contextmanager
def change_directory(working_dir):
"""A context manager for executing in a provided working directory"""
start_dir = Path().absolute()
try:
Path.mkdir(working_dir, exist_ok=True)
os.chdir(working_dir)
yield
finally:
os.chdir(start_dir)
def _run(args, output, cwd):
# Launch a subprocess
p = subprocess.Popen(args, cwd=cwd, stdout=subprocess.PIPE,