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

from __future__ import unicode_literals

import unittest
import json
import os

from monty.json import MontyDecoder
from pymatgen.analysis.defects.dilute_solution_model import *
import random

test_dir = os.path.join(os.path.dirname(__file__), "..", "..", "..", "..",
                        'test_files')
with open(
        os.path.join(test_dir, 'mp1048_defect_formation_energies.json')) as fp:
    formation_energy_dict = json.load(fp, cls=MontyDecoder)
with open(os.path.join(test_dir, 'mp1048_raw_defect_energies.json')) as fp:
    raw_energy_dict = json.load(fp, cls=MontyDecoder)
with open(os.path.join(test_dir, 'mp1487_raw_defect_energies.json')) as fp:
    mp1487_raw_energy_dict = json.load(fp, cls=MontyDecoder)


PULL_REQ = os.environ.get("CI_PULL_REQUEST", None)

# TODO (from SP): You MUST redo this entire test. The whole test is
# monstrously slow. It takes more than 10 mins to get through this test alone.


@unittest.skipIf(PULL_REQ or random.randint(0, 10) % 10 != 0,
                 "Pull request or random skip.")
class DiluteSolutionModelTest(unittest.TestCase):
    def setUp(self):
        """
        Setup mandatory inputs for dilute_solution_model
        """
        self.e0 = raw_energy_dict['bulk_energy']
        self.asites = raw_energy_dict['antisites']
        self.vac = raw_energy_dict['vacancies']
        self.struct = raw_energy_dict['structure']
        self.T = 600
        self.trial_mu = formation_energy_dict[str(self.T)]['chemical_potential']

    def test_formation_energies_without_chem_pot(self):
        """
        Should generate formation energies without input chempot
        """
        energies, chem_pot = dilute_solution_model(
            self.struct, self.e0, self.vac, self.asites, self.T,
            generate='energy')
        self.assertIsNotNone(energies)
        self.assertIsNotNone(chem_pot)

    def test_formation_energies_with_chem_pot(self):<commit_msg>Fix PR.<commit_after># coding: utf-8
# Copyright (c) Pymatgen Development Team.
# Distributed under the terms of the MIT License.

from __future__ import unicode_literals

import unittest
import json
import os

from monty.json import MontyDecoder
from pymatgen.analysis.defects.dilute_solution_model import *
import random

test_dir = os.path.join(os.path.dirname(__file__), "..", "..", "..", "..",
                        'test_files')
with open(
        os.path.join(test_dir, 'mp1048_defect_formation_energies.json')) as fp:
    formation_energy_dict = json.load(fp, cls=MontyDecoder)
with open(os.path.join(test_dir, 'mp1048_raw_defect_energies.json')) as fp:
    raw_energy_dict = json.load(fp, cls=MontyDecoder)
with open(os.path.join(test_dir, 'mp1487_raw_defect_energies.json')) as fp:
    mp1487_raw_energy_dict = json.load(fp, cls=MontyDecoder)


PULL_REQ = os.environ.get("CI_PULL_REQUEST", None) or os.environ.get("TRAVIS_PULL_REQUEST", None)

# TODO (from SP): You MUST redo this entire test. The whole test is
# monstrously slow. It takes more than 10 mins to get through this test alone.


@unittest.skipIf(PULL_REQ or random.randint(0, 10) % 10 != 0,
                 "Pull request or random skip.")
class DiluteSolutionModelTest(unittest.TestCase):
    def setUp(self):
        """
        Setup mandatory inputs for dilute_solution_model
        """
        self.e0 = raw_energy_dict['bulk_energy']
        self.asites = raw_energy_dict['antisites']
        self.vac = raw_energy_dict['vacancies']
        self.struct = raw_energy_dict['structure']
        self.T = 600
        self.trial_mu = formation_energy_dict[str(self.T)]['chemical_potential']

    def test_formation_energies_without_chem_pot(self):
        """
        Should generate formation energies without input chempot
        """
        energies, chem_pot = dilute_solution_model(
            self.struct, self.e0, self.vac, self.asites, self.T,
            generate='energy')
        self.assertIsNotNone(energies)
        self.assertIsNotNone(chem_pot)

    def test_formation_energies_with_chem_pot(self):
{'fraction_non_alphanumeric': 0.10610079575596817, 'fraction_numerical': 0.014468290330359295, 'mean_word_length': 3.5185185185185186, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6887734', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1338, 'n_words': 297}