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


import json
import os
import unittest
import warnings
from io import open

from monty.serialization import loadfn
import numpy

from pymatgen.core.lattice import Lattice
from pymatgen.electronic_structure.bandstructure import (
    BandStructureSymmLine,
    Kpoint,
    LobsterBandStructureSymmLine,
    get_reconstructed_band_structure,
)
from pymatgen.electronic_structure.core import Orbital, Spin
from pymatgen.electronic_structure.plotter import BSPlotterProjected
from pymatgen.io.vasp import BSVasprun
from pymatgen.util.testing import PymatgenTest


class KpointTest(unittest.TestCase):
    def setUp(self):
        self.lattice = Lattice.cubic(10.0)
        self.kpoint = Kpoint([0.1, 0.4, -0.5], self.lattice, label="X")

    def test_properties(self):
        self.assertEqual(self.kpoint.frac_coords[0], 0.1)
        self.assertEqual(self.kpoint.frac_coords[1], 0.4)
        self.assertEqual(self.kpoint.frac_coords[2], -0.5)
        self.assertEqual(self.kpoint.a, 0.1)
        self.assertEqual(self.kpoint.b, 0.4)
        self.assertEqual(self.kpoint.c, -0.5)
        self.assertEqual(self.lattice, Lattice.cubic(10.0))
        self.assertEqual(self.kpoint.cart_coords[0], 1.0)
        self.assertEqual(self.kpoint.cart_coords[1], 4.0)
        self.assertEqual(self.kpoint.cart_coords[2], -5.0)
        self.assertEqual(self.kpoint.label, "X")

    def test_as_dict(self):
        self.assertIsInstance(self.kpoint.as_dict()["fcoords"], list)
        self.assertIsInstance(self.kpoint.as_dict()["ccoords"], list)
        self.assertNotIsInstance(self.kpoint.as_dict()["fcoords"][0], numpy.float64)
        self.assertNotIsInstance(self.kpoint.as_dict()["ccoords"][0], numpy.float64)
        self.assertListEqual(self.kpoint.as_dict()["fcoords"], [0.1, 0.4, -0.5])
        self.assertListEqual(self.kpoint.as_dict()["ccoords"], [1.0, 4.0, -5.0])


class BandStructureSymmLine_test(PymatgenTest):
    def setUp(self):
        self.bs = loadfn(os.path.join(PymatgenTest.TEST_FILES_DIR, "Cu2O_361_bandstructure.json"))
        self.bs2 = loadfn(os.path.join(PymatgenTest.TEST_FILES_DIR, "CaO_2605_bandstructure.json"))
        self.bs_spin = loadfn(os.path.join(PymatgenTest.TEST_FILES_DIR, "NiO_19009_bandstructure.json"))
        self.bs_cbm0 = loadfn(os.path.join(PymatgenTest.TEST_FILES_DIR, "InN_22205_bandstructure.json"))
        self.bs_cu = loadfn(os.path.join(PymatgenTest.TEST_FILES_DIR, "Cu_30_bandstructure.json"))<commit_msg>from_dict test added for Kpoint<commit_after># coding: utf-8
# Copyright (c) Pymatgen Development Team.
# Distributed under the terms of the MIT License.


import json
import os
import unittest
import warnings
from io import open

from monty.serialization import loadfn
import numpy

from pymatgen.core.lattice import Lattice
from pymatgen.electronic_structure.bandstructure import (
    BandStructureSymmLine,
    Kpoint,
    LobsterBandStructureSymmLine,
    get_reconstructed_band_structure,
)
from pymatgen.electronic_structure.core import Orbital, Spin
from pymatgen.electronic_structure.plotter import BSPlotterProjected
from pymatgen.io.vasp import BSVasprun
from pymatgen.util.testing import PymatgenTest


class KpointTest(unittest.TestCase):
    def setUp(self):
        self.lattice = Lattice.cubic(10.0)
        self.kpoint = Kpoint([0.1, 0.4, -0.5], self.lattice, label="X")

    def test_properties(self):
        self.assertEqual(self.kpoint.frac_coords[0], 0.1)
        self.assertEqual(self.kpoint.frac_coords[1], 0.4)
        self.assertEqual(self.kpoint.frac_coords[2], -0.5)
        self.assertEqual(self.kpoint.a, 0.1)
        self.assertEqual(self.kpoint.b, 0.4)
        self.assertEqual(self.kpoint.c, -0.5)
        self.assertEqual(self.lattice, Lattice.cubic(10.0))
        self.assertEqual(self.kpoint.cart_coords[0], 1.0)
        self.assertEqual(self.kpoint.cart_coords[1], 4.0)
        self.assertEqual(self.kpoint.cart_coords[2], -5.0)
        self.assertEqual(self.kpoint.label, "X")

    def test_as_dict(self):
        self.assertIsInstance(self.kpoint.as_dict()["fcoords"], list)
        self.assertIsInstance(self.kpoint.as_dict()["ccoords"], list)
        self.assertNotIsInstance(self.kpoint.as_dict()["fcoords"][0], numpy.float64)
        self.assertNotIsInstance(self.kpoint.as_dict()["ccoords"][0], numpy.float64)
        self.assertListEqual(self.kpoint.as_dict()["fcoords"], [0.1, 0.4, -0.5])
        self.assertListEqual(self.kpoint.as_dict()["ccoords"], [1.0, 4.0, -5.0])

    def test_from_dict(self):

        d = self.kpoint.as_dict()

        kpoint = Kpoint.from_dict(d)

        self.assertEqual(kpoint.frac_coords[0], 0.1)
        self.assertEqual(kpoint.frac_coords[1], 0.4)
        self.assertEqual(kpoint.frac_coords[2], -0.5)
        self.assertEqual(kpoint.a, 0.1)
        self.assertEqual(kpoint.b, 0.4)
        self.assertEqual(kpoint.c, -0.5)
        self.assertEqual(kpoint.lattice, Lattice.cubic(10.0))
        self.assertEqual(kpoint.cart_coords[0], 1.0)
        self.assertEqual(kpoint.cart_coords[1], 4.0)
        self.assertEqual(kpoint.cart_coords[2], -5.0)
        self.assertEqual(kpoint.label, "X")


class BandStructureSymmLine_test(PymatgenTest):
    def setUp(self):
        self.bs = loadfn(os.path.join(PymatgenTest.TEST_FILES_DIR, "Cu2O_361_bandstructure.json"))
        self.bs2 = loadfn(os.path.join(PymatgenTest.TEST_FILES_DIR, "CaO_2605_bandstructure.json"))
        self.bs_spin = loadfn(os.path.join(PymatgenTest.TEST_FILES_DIR, "NiO_19009_bandstructure.json"))
        self.bs_cbm0 = loadfn(os.path.join(PymatgenTest.TEST_FILES_DIR, "InN_22205_bandstructure.json"))
        self.bs_cu = loadfn(os.path.join(PymatgenTest.TEST_FILES_DIR, "Cu_30_bandstructure.json"))
{'fraction_non_alphanumeric': 0.12968052215733425, 'fraction_numerical': 0.0310889728615596, 'mean_word_length': 3.8768844221105527, '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': '4737455', 'n_tokens_mistral': 2214, 'n_tokens_neox': 2106, 'n_words': 301}