from mdciao.flare import _utils import numpy as np from unittest import TestCase from itertools import combinations from unittest import skip from mdciao.plots.plots import _colorstring from mdciao.filenames import filenames import mdtraj as md from matplotlib import pyplot as plt from mdciao.flare import circle_plot_residues filenames = filenames() class TestAngulateSegments(TestCase): def test_works(self): angles = _utils.regspace_angles(10, circle=360) np.testing.assert_array_equal(angles, [0., -36., -72., -108., -144., -180., -216., -252., -288., -324.]) def test_anti_clockwise(self): angles = _utils.regspace_angles(10, circle=360, clockwise=False) np.testing.assert_array_equal(angles, [0, 36, 72, 108, 144, 180, 216, 252, 288, 324]) class TestFragmentSelectionParser(TestCase):
import unittest import numpy as _np import pytest from mdciao import filenames test_filenames = filenames.filenames() from mdciao.utils import lists import mdtraj as md #TODO correct the "just works" nomenclature and the repetition of names of the funciton in class methods class Test_exclude_same_fragments_from_residx_pairlist(unittest.TestCase): def test_exclude_same_fragments_from_residx_pairlist_just_works(self): assert (lists.exclude_same_fragments_from_residx_pairlist([[0, 1], [2, 3]], [[0, 1, 2], [3, 4]]) == [[2, 3]]) def test_exclude_same_fragments_from_residx_pairlist_return_excluded_id(self): assert (lists.exclude_same_fragments_from_residx_pairlist([[1, 2], [0, 3], [5, 6]], [[0, 1, 2], [3, 4], [5, 6]], return_excluded_idxs=True) == [0, 2]) class Test_unique_list_of_iterables_by_tuple_hashing(unittest.TestCase): def test_works(self): assert (lists.unique_list_of_iterables_by_tuple_hashing([1])) == [1] assert (lists.unique_list_of_iterables_by_tuple_hashing([["A"], ["B"]]) == lists.unique_list_of_iterables_by_tuple_hashing([["A"], ["B"]])) def test_returns_index(self): assert (lists.unique_list_of_iterables_by_tuple_hashing([1], return_idxs=True)) == [0] assert (lists.unique_list_of_iterables_by_tuple_hashing([[1], [1], [2], [2]], return_idxs=True)) == [[0], [2]]
import mdtraj as md import unittest from mdciao.filenames import filenames from mdciao.utils import str_and_dict test_filenames : filenames = filenames() import pytest #see https://stackoverflow.com/questions/169070/how-do-i-write-a-decorator-that-restores-the-cwd import contextlib @contextlib.contextmanager def remember_cwd(): curdir = os.getcwd() try: yield finally: os.chdir(curdir) import shutil from tempfile import TemporaryDirectory as _TDir import os from matplotlib import \ pyplot as _plt from mdciao import cli from mdciao import fragments as mdcfragments from mdciao import contacts from mdciao.cli import *