<commit_before># -*- coding: utf-8 -*-
# Copyright (c) 2015-2016, Exa Analytics Development Team
# Distributed under the terms of the Apache License 2.0
"""
The Atomic Universe
#########################
The :class:`~exatomic.container.Universe` object is a subclass of
:class:`~exa.container.Container` that stores data coming from computational
chemistry experiments in a unified and systematic way. Data is organized into
"frames". A frame is an axis that can represent time (e.g. molecular dynamics
simulations), step number (e.g. geometry optimization), or an arbitrary index
(e.g. density functional theory exchange correlation functional).
"""
import six
import numpy as np
import pandas as pd
from exa import Field, DataFrame, Container, TypedMeta
from .error import BasisSetNotFoundError
from .frame import Frame, compute_frame_from_atom
from .atom import Atom, UnitAtom, ProjectedAtom, VisualAtom, Frequency
from .two import (AtomTwo, MoleculeTwo, compute_atom_two,
                  compute_bond_count, compute_molecule_two)
from .molecule import (Molecule, compute_molecule, compute_molecule_com,
                       compute_molecule_count)
from .field import AtomicField
from .orbital import Orbital, Excitation, MOMatrix, DensityMatrix
from .basis import Overlap, BasisSet, BasisSetOrder
from exatomic.algorithms.orbital import add_molecular_orbitals
#from exatomic.interfaces.cclib import universe_from_cclib
from exatomic.widget import UniverseWidget


class Universe(six.with_metaclass(TypedMeta, Container)):
    """
    The atomic container is called a universe because it represents everything
    known about the atomistic simulation (whether quantum or classical). This
    includes data such as atomic coordinates, molecular orbital energies, as
    well as (classical phenomena) such as two body distances, etc.

    Attributes:
        atom (:class:`~exatomic.atom.Atom`): Atomic coordinates, symbols, forces, etc.
    """
    atom = Atom
    frame = Frame
    atom_two = AtomTwo
    unit_atom = UnitAtom
    projected_atom = ProjectedAtom
    visual_atom = VisualAtom
    frequency = Frequency
    molecule = Molecule
    molecule_two = MoleculeTwo
    field = AtomicField
    orbital = Orbital
    overlap = Overlap
    multipole = DataFrame
    momatrix = MOMatrix
    excitation = Excitation
    density = DensityMatrix
    contribution = DataFrame
    basis_set_order = BasisSetOrder
    basis_set = BasisSet
    _cardinal = "frame"
    _getter_prefix = "parse"

    @classmethod
    def from_cclib(cls, ccobj):
        return cls(**universe_from_cclib(ccobj))

    # Note that compute_* function may be called automatically by typed
    # properties defined in UniverseMeta
    def compute_frame(self):
        """
        Compute a minmal frame table.
        """
        self.frame = compute_frame_from_atom(self.atom)

    def compute_unit_atom(self):
        """Compute minimal image for periodic systems."""
        self.unit_atom = UnitAtom.from_universe(self)

    def compute_visual_atom(self):
        self.visual_atom = VisualAtom.from_universe(self)
        self.compute_molecule_com()

    def compute_atom_two(self, mapper=None, bond_extra=0.45):
        """<commit_msg>Fixed type checking on the universe<commit_after># -*- coding: utf-8 -*-
# Copyright (c) 2015-2016, Exa Analytics Development Team
# Distributed under the terms of the Apache License 2.0
"""
The Atomic Universe
#########################
The :class:`~exatomic.container.Universe` object is a subclass of
:class:`~exa.container.Container` that stores data coming from computational
chemistry experiments in a unified and systematic way. Data is organized into
"frames". A frame is an axis that can represent time (e.g. molecular dynamics
simulations), step number (e.g. geometry optimization), or an arbitrary index
(e.g. density functional theory exchange correlation functional).
"""
import six
import numpy as np
import pandas as pd
from exa import Field, DataFrame, Container, TypedMeta
from .error import BasisSetNotFoundError
from .frame import Frame, compute_frame_from_atom
from .atom import Atom, UnitAtom, ProjectedAtom, VisualAtom, Frequency
from .two import (AtomTwo, MoleculeTwo, compute_atom_two,
                  compute_bond_count, compute_molecule_two)
from .molecule import (Molecule, compute_molecule, compute_molecule_com,
                       compute_molecule_count)
from .field import AtomicField
from .orbital import Orbital, Excitation, MOMatrix, DensityMatrix
from .basis import Overlap, BasisSet, BasisSetOrder
from exatomic.algorithms.orbital import add_molecular_orbitals
#from exatomic.interfaces.cclib import universe_from_cclib
from exatomic.widget import UniverseWidget


class Meta(TypedMeta):
    atom = Atom
    frame = Frame
    atom_two = AtomTwo
    unit_atom = UnitAtom
    projected_atom = ProjectedAtom
    visual_atom = VisualAtom
    frequency = Frequency
    molecule = Molecule
    molecule_two = MoleculeTwo
    field = AtomicField
    orbital = Orbital
    overlap = Overlap
    multipole = DataFrame
    momatrix = MOMatrix
    excitation = Excitation
    density = DensityMatrix
    contribution = DataFrame
    basis_set_order = BasisSetOrder
    basis_set = BasisSet


class Universe(six.with_metaclass(Meta, Container)):
    """
    The atomic container is called a universe because it represents everything
    known about the atomistic simulation (whether quantum or classical). This
    includes data such as atomic coordinates, molecular orbital energies, as
    well as (classical phenomena) such as two body distances, etc.

    Attributes:
        atom (:class:`~exatomic.atom.Atom`): Atomic coordinates, symbols, forces, etc.
    """
    _cardinal = "frame"
    _getter_prefix = "parse"

    @classmethod
    def from_cclib(cls, ccobj):
        return cls(**universe_from_cclib(ccobj))

    # Note that compute_* function may be called automatically by typed
    # properties defined in UniverseMeta
    def compute_frame(self):
        """
        Compute a minmal frame table.
        """
        self.frame = compute_frame_from_atom(self.atom)

    def compute_unit_atom(self):
        """Compute minimal image for periodic systems."""
        self.unit_atom = UnitAtom.from_universe(self)

    def compute_visual_atom(self):
        self.visual_atom = VisualAtom.from_universe(self)
        self.compute_molecule_com()

    def compute_atom_two(self, mapper=None, bond_extra=0.45):
        """
{'fraction_non_alphanumeric': 0.07738646895273402, 'fraction_numerical': 0.004324992276799506, 'mean_word_length': 3.832089552238806, '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': '2611464', 'n_tokens_mistral': 1880, 'n_tokens_neox': 1772, 'n_words': 603}