<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division,
                        print_function, unicode_literals)

__author__ = "<NAME>"

import os
import numpy as np
from ph_plotter.plotter import Plotter
from ph_plotter.file_io import read_band_hdf5_dict


class SFPlotter(Plotter):
    def __init__(
            self,
            variables=None,
            is_horizontal=False,
            is_separated=False):
        super(SFPlotter, self).__init__(variables, is_horizontal)

        if is_separated:
            tmp_func = self.load_spectral_functions_multiple
        else:
            tmp_func = self.load_spectral_functions_single
        self.load_spectral_functions = tmp_func

    def load_data(self, data_file="band.hdf5"):
        print("Reading band.hdf5: ", end="")
        data = read_band_hdf5_dict(data_file)
        print("Finished")

        self._distances   = data["distances"]

        npath, nqp = self._distances.shape
        nq = npath * nqp

        if "frequencies" in data:
            self._frequencies = data["frequencies"]
        if "pr_weights" in data:
            self._pr_weights = data["pr_weights"]
        if "nums_arms" in data:
            self._nums_arms = data["nums_arms"]
        if "rot_pr_weights" in data:
            self._rot_pr_weights = data["rot_pr_weights"]
        if "pg_symbols" in data:
            self._pg_symbols = data["pg_symbols"].reshape(nq)
        if "nums_irreps" in data:
            self._nums_irreps = data["nums_irreps"].reshape(nq)
        if "ir_labels" in data:
            self._ir_labels = data["ir_labels"].reshape(nq, -1)

    def load_density(self, filename="density.dat"):
        tmp = np.loadtxt(filename).T
        xs = tmp[0]
        ys = tmp[1]
        zs = tmp[2]
        n1, n2 = self._distances.shape
        n = n1 * n2<commit_msg>Modify to read natoms_primitive and elements from band.hdf5<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division,
                        print_function, unicode_literals)

__author__ = "<NAME>"

import os
import numpy as np
from ph_plotter.plotter import Plotter
from ph_plotter.file_io import read_band_hdf5_dict


class SFPlotter(Plotter):
    def __init__(
            self,
            variables=None,
            is_horizontal=False,
            is_separated=False):
        super(SFPlotter, self).__init__(variables, is_horizontal)

        if is_separated:
            tmp_func = self.load_spectral_functions_multiple
        else:
            tmp_func = self.load_spectral_functions_single
        self.load_spectral_functions = tmp_func

    def load_data(self, data_file="band.hdf5"):
        print("Reading band.hdf5: ", end="")
        data = read_band_hdf5_dict(data_file)
        print("Finished")

        self._distances   = data["distances"]

        npath, nqp = self._distances.shape
        nq = npath * nqp

        if "frequencies" in data:
            self._frequencies = data["frequencies"]
        if "pr_weights" in data:
            self._pr_weights = data["pr_weights"]
        if "nums_arms" in data:
            self._nums_arms = data["nums_arms"]
        if "rot_pr_weights" in data:
            self._rot_pr_weights = data["rot_pr_weights"]
        if "pg_symbols" in data:
            self._pg_symbols = data["pg_symbols"].reshape(nq)
        if "nums_irreps" in data:
            self._nums_irreps = data["nums_irreps"].reshape(nq)
        if "ir_labels" in data:
            self._ir_labels = data["ir_labels"].reshape(nq, -1)
        if "natoms_primitive" in data:
            self._natoms_primitive = data["natoms_primitive"]
        if "elements" in data:
            self._elements = data["elements"]

    def load_density(self, filename="density.dat"):
        tmp = np.loadtxt(filename).T
        xs = tmp[0]
        ys = tmp[1]
        zs = tmp[2]
        n1, n2 = self._distances.shape
        n = n1 * n2
{'fraction_non_alphanumeric': 0.10260913196186654, 'fraction_numerical': 0.006773707977922729, 'mean_word_length': 2.292320396366639, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1844737', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1280, 'n_words': 266}