<commit_before>from __future__ import division, unicode_literals

import unittest as unittest
import numpy as np

from pymatgen import Composition
from pymatgen.entries.computed_entries import ComputedEntry
from pymatgen.phasediagram.maker import PhaseDiagram,GrandPotentialPhaseDiagram
from pymatgen.analysis.interface_reactions import InterfacialReactivity

class InterfaceReactionTest(unittest.TestCase):

    def setUp(self):
        self.entries = [ComputedEntry(Composition('Li'), 0),
                ComputedEntry(Composition('Mn'), 0),
                ComputedEntry(Composition('O2'), 0),
                ComputedEntry(Composition('MnO2'), -10),
                ComputedEntry(Composition('Mn2O4'), -60),
                ComputedEntry(Composition('MnO3'), 20),
                ComputedEntry(Composition('Li2O'), -10),
                ComputedEntry(Composition('LiMnO2'), -30),
                        ]
        self.pd = PhaseDiagram(self.entries)
        chempots = {'Li':-3}
        self.gpd = GrandPotentialPhaseDiagram(self.entries, chempots)
        self.ir = []
        self.ir.append(InterfacialReactivity(Composition('O2'),Composition('Mn'),self.pd, norm=0, include_no_mixing_energy=0, pd_non_grand=None))
        self.ir.append(InterfacialReactivity(Composition('MnO2'),Composition('Mn'),self.gpd, norm=0, include_no_mixing_energy=1, pd_non_grand=self.pd))
        self.ir.append(InterfacialReactivity(Composition('Mn'),Composition('O2'),self.gpd, norm=1, include_no_mixing_energy=1, pd_non_grand=self.pd))
        self.ir.append(InterfacialReactivity(Composition('Li2O'),Composition('Mn'),self.gpd, norm=0, include_no_mixing_energy=1, pd_non_grand=self.pd))
        self.ir.append(InterfacialReactivity(Composition('Mn'),Composition('O2'),self.gpd, norm=1, include_no_mixing_energy=0, pd_non_grand=self.pd))
        self.ir.append(InterfacialReactivity(Composition('Mn'),Composition('Li2O'),self.gpd, norm=1, include_no_mixing_energy=1, pd_non_grand=self.pd))

    def test_get_entry_energy(self):
        comp = Composition('MnO3')
        # Test normal functionality
        comp = Composition('MnO2')
        test2 = np.isclose(self.ir[0]._get_entry_energy(self.pd,comp), -30,atol=1e-03)
        self.assertTrue(test2,'_get_entry_energy: energy for {} is wrong!'.format(comp.reduced_formula))<commit_msg>cleaned test_interface_reactions.py<commit_after>from __future__ import division, unicode_literals

import unittest as unittest
import numpy as np

from pymatgen import Composition
from pymatgen.entries.computed_entries import ComputedEntry
from pymatgen.phasediagram.maker import PhaseDiagram,GrandPotentialPhaseDiagram
from pymatgen.analysis.interface_reactions import InterfacialReactivity

class InterfaceReactionTest(unittest.TestCase):

    def setUp(self):
        self.entries = [ComputedEntry(Composition('Li'), 0),
                ComputedEntry(Composition('Mn'), 0),
                ComputedEntry(Composition('O2'), 0),
                ComputedEntry(Composition('MnO2'), -10),
                ComputedEntry(Composition('Mn2O4'), -60),
                ComputedEntry(Composition('MnO3'), 20),
                ComputedEntry(Composition('Li2O'), -10),
                ComputedEntry(Composition('LiMnO2'), -30),
                        ]
        self.pd = PhaseDiagram(self.entries)
        chempots = {'Li':-3}
        self.gpd = GrandPotentialPhaseDiagram(self.entries, chempots)
        self.ir = []
        self.ir.append(InterfacialReactivity(Composition('O2'),Composition('Mn'),self.pd, norm=0, include_no_mixing_energy=0, pd_non_grand=None))
        self.ir.append(InterfacialReactivity(Composition('MnO2'),Composition('Mn'),self.gpd, norm=0, include_no_mixing_energy=1, pd_non_grand=self.pd))
        self.ir.append(InterfacialReactivity(Composition('Mn'),Composition('O2'),self.gpd, norm=1, include_no_mixing_energy=1, pd_non_grand=self.pd))
        self.ir.append(InterfacialReactivity(Composition('Li2O'),Composition('Mn'),self.gpd, norm=0, include_no_mixing_energy=1, pd_non_grand=self.pd))
        self.ir.append(InterfacialReactivity(Composition('Mn'),Composition('O2'),self.gpd, norm=1, include_no_mixing_energy=0, pd_non_grand=self.pd))
        self.ir.append(InterfacialReactivity(Composition('Mn'),Composition('Li2O'),self.gpd, norm=1, include_no_mixing_energy=1, pd_non_grand=self.pd))

    def test_get_entry_energy(self):
        # Test normal functionality
        comp = Composition('MnO2')
        test2 = np.isclose(self.ir[0]._get_entry_energy(self.pd,comp), -30,atol=1e-03)
        self.assertTrue(test2,'_get_entry_energy: energy for {} is wrong!'.format(comp.reduced_formula))
{'fraction_non_alphanumeric': 0.12858683926645093, 'fraction_numerical': 0.0209277238403452, 'mean_word_length': 4.353348729792148, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5557909', 'n_tokens_mistral': 1580, 'n_tokens_neox': 1484, 'n_words': 196}