# Path: paratemp/tools.py
# @contextmanager
# def cd(new_dir):
#     prev_dir = os.getcwd()
#     os.chdir(os.path.expanduser(new_dir))
#     try:
#         yield
#     finally:
#         os.chdir(prev_dir)


import numpy as np
import pathlib
import re
from paratemp.tools import cd
    from paratemp.energy_histo import find_energies
    from paratemp.energy_histo import make_indices
        from paratemp.energy_histo import import_energies, find_energies
# See the License for the specific language governing permissions and  #
# limitations under the License.                                       #
#                                                                      #
########################################################################

from __future__ import absolute_import



n_gro, n_top, n_template, n_ndx = ('spc-and-methanol.gro',
                                   'spc-and-methanol.top',
                                   'templatemdp.txt',
                                   'index.ndx')
n_gro_o1, n_gro_o2 = 'PT-out0.gro', 'PT-out1.gro'
n_edr_o1, n_edr_o2 = 'PT-out0.edr', 'PT-out1.edr'
n_log_o1, n_log_o2 = 'PT-out0.log', 'PT-out1.log'
n_trr_o1, n_trr_o2 = 'PT-out0.trr', 'PT-out1.trr'


def test_pt_run_dir(pt_run_dir: pathlib.PosixPath):
    files_present = {f.name for f in pt_run_dir.iterdir()}
    must_contain = {n_gro_o1, n_gro_o2, n_log_o1, n_log_o2,
                    n_edr_o1, n_edr_o2, n_trr_o1, n_trr_o2}
    assert must_contain - files_present == set()


def test_find_energies(pt_run_dir: pathlib.PosixPath):
    # Doesn't currently test:
    #    content of the outputs
    #    what happens if they already exist

# Path: paratemp/tools.py
# @contextmanager
# def cd(new_dir):
#     prev_dir = os.getcwd()
#     os.chdir(os.path.expanduser(new_dir))
#     try:
#         yield
#     finally:
#         os.chdir(prev_dir)


# Path: tests/test_energy_histo.py
import numpy as np
import pathlib
import re
from paratemp.tools import cd
    from paratemp.energy_histo import find_energies
    from paratemp.energy_histo import make_indices
        from paratemp.energy_histo import import_energies, find_energies

# See the License for the specific language governing permissions and  #
# limitations under the License.                                       #
#                                                                      #
########################################################################

from __future__ import absolute_import



n_gro, n_top, n_template, n_ndx = ('spc-and-methanol.gro',
                                   'spc-and-methanol.top',
                                   'templatemdp.txt',
                                   'index.ndx')
n_gro_o1, n_gro_o2 = 'PT-out0.gro', 'PT-out1.gro'
n_edr_o1, n_edr_o2 = 'PT-out0.edr', 'PT-out1.edr'
n_log_o1, n_log_o2 = 'PT-out0.log', 'PT-out1.log'
n_trr_o1, n_trr_o2 = 'PT-out0.trr', 'PT-out1.trr'


def test_pt_run_dir(pt_run_dir: pathlib.PosixPath):
    files_present = {f.name for f in pt_run_dir.iterdir()}
    must_contain = {n_gro_o1, n_gro_o2, n_log_o1, n_log_o2,
                    n_edr_o1, n_edr_o2, n_trr_o1, n_trr_o2}
    assert must_contain - files_present == set()


def test_find_energies(pt_run_dir: pathlib.PosixPath):
    # Doesn't currently test:
    #    content of the outputs
    #    what happens if they already exist

    with cd(pt_run_dir):