# coding: utf-8
# Copyright (c) Pymatgen Development Team.
# Distributed under the terms of the MIT License.

from __future__ import division, unicode_literals
import os
import random
import unittest2 as unittest
import json
import six

from monty.os.path import which
from pymatgen import Lattice, PeriodicSite
from monty.json import MontyDecoder
from pymatgen.io.vasp.inputs import Poscar
from pymatgen.transformations.standard_transformations import *
from pymatgen.symmetry.structure import SymmetrizedStructure

'''
Created on Sep 23, 2011
'''

__author__ = "Shyue Ping Ong"
__copyright__ = "Copyright 2011, The Materials Project"
__version__ = "0.1"
__maintainer__ = "Shyue Ping Ong"
__email__ = "shyuep@gmail.com"
__date__ = "Sep 23, 2011"


test_dir = os.path.join(os.path.dirname(__file__), "..", "..", "..",
                        'test_files')

enumlib_present = which('enum.x') and which('makestr.x')


class RotationTransformationsTest(unittest.TestCase):
    def setUp(self):
        coords = list()
        coords.append([0, 0, 0])
        coords.append([0.75, 0.5, 0.75])
        lattice = Lattice([[3.8401979337, 0.00, 0.00],
                           [1.9200989668, 3.3257101909, 0.00],
                           [0.00, -2.2171384943, 3.1355090603]])
        self.struct = Structure(lattice, ["Si"] * 2, coords)

    def test_as_from_dict(self):
        t = RotationTransformation([0, 1, 0], 30, False)
        d = t.as_dict()
        self.assertEqual(type(RotationTransformation.from_dict(d)),
                         RotationTransformation)

    def test_rotation_transformation(self):
        t = RotationTransformation([0, 1, 0], 30, False)
        s2 = t.apply_transformation(self.struct)
        s1 = t.inverse.apply_transformation(s2)