<commit_before><commit_msg>Create test_piezo_sensitivity.py<commit_after># coding: utf-8
# Copyright (c) Pymatgen Development Team.
# Distributed under the terms of the MIT License.


"""
Test for the piezo tensor class
"""

__author__ = "<NAME>ing
__version__ = "0.1"
__maintainer__ = "<NAME>"
__email__ = "<EMAIL>"
__status__ = "Development"
__date__ = "4/23/19"

import os
import unittest
import numpy as np
from pymatgen.analysis.piezo import PiezoTensor
from pymatgen.analysis.piezo_sensitivity import *
from pymatgen.util.testing import PymatgenTest
from pymatgen.analysis.symmetry import sitesymmeties as ss
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer as sga
try:
    from phonopy import Phonopy
    from phonopy.structure.atoms import PhonopyAtoms
    from phonopy.file_IO import write_disp_yaml
except ImportError:
    Phonopy = None

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

class PiezoSensitivityTest(PymatgenTest):
	def setUp(self):
		self.piezo_struc = self.get_structure('Pb2TiZrO6')
        self.BEC = np.load(os.path.join(test_dir, "pztborn.npy"))
        self.IST = np.load(os.path.join(test_dir, "pztist.npy"))
        self.FCM = np.load(os.path.join(test_dir, "pztfcm.npy"))
    def test_BornEffectiveChargeTensor(self):
    	bt = BornEffectiveChargeTensor(self.BEC)
    	self.assertArrayAlmostEqual(bt, self.BEC)
        bad_dim_array = np.zeros((3, 3))
        self.assertRaises(ValueError, BornEffectiveChargeTensor, bad_dim_array)
    def test_get_rand_BEC(self):
    	btrand = BornEffectiveChargeTensor.get_rand_BEC()
    def test_BornEffectiveChargeTensor(self):
    	bt = BornEffectiveChargeTensor(self.IST)
    	self.assertArrayAlmostEqual(bt, self.IST)
        bad_dim_array = np.zeros((3, 3))
        self.assertRaises(ValueError, InternalStrainTensor, bad_dim_array)
    def test_get_rand_IST(self):
    def test_ForceConstantMatrix(self):
    	fcmt = BornEffectiveChargeTensor(self.FCM)
    	self.assertArrayAlmostEqual(fcmt, self.FCM)
        bad_dim_array = np.zeros((3, 3))
        self.assertRaises(ValueError, ForceConstantMatrix, bad_dim_array)
    def test_get_rand_FCM(self):








{'fraction_non_alphanumeric': 0.10431654676258993, 'fraction_numerical': 0.007194244604316547, 'mean_word_length': 4.247641509433962, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4620341', 'n_tokens_mistral': 815, 'n_tokens_neox': 777, 'n_words': 146}