# Path: cclib/method/calculationmethod.py
# class Method:
#     """Abstract base class for all cclib method classes.
# 
#     Subclasses defined by cclib:
#         CDA - charde decomposition analysis
#         CSPA - C-squared population analysis
#         Density - density matrix calculation
#         FragmentAnalysis - fragment analysis for ADF output
#         LPA - Löwdin population analysis
#         MBO - Mayer's bond orders
#         Moments - multipole moments calculations
#         MPA - Mulliken population analysis
#         Nuclear - properties of atomic nuclei
#         OPA - overlap population analysis
#         Population - base class for population analyses
#         Volume - volume/grid calculations
# 
#     All the modules containing methods should be importable.
#     """
#     required_attrs = ()
#     def __init__(self, data, progress=None, loglevel=logging.INFO, logname="Log"):
#         """Initialise the Logfile object.
# 
#         This constructor is typically called by the constructor of a subclass.
#         """
# 
#         self.data = data
#         self.progress = progress
#         self.loglevel = loglevel
#         self.logname = logname
#         self._check_required_attributes()
#         self.logger = logging.getLogger('%s %s' % (self.logname, self.data))
#         self.logger.setLevel(self.loglevel)
#         self.logformat = "[%(name)s %(levelname)s] %(message)s"
#         handler = logging.StreamHandler(sys.stdout)
#         handler.setFormatter(logging.Formatter(self.logformat))
#         self.logger.addHandler(handler)
# 
#     def _check_required_attributes(self):
#         """Check if required attributes are present in data."""
#         missing = [x for x in self.required_attrs
#                     if not hasattr(self.data, x)]
#         if missing:
#             missing = ' '.join(missing)
#             raise MissingAttributeError(
#                 'Could not parse required attributes to use method: ' + missing)
# 
# Path: cclib/method/population.py
# class Population(Method):
#     """An abstract base class for population-type methods."""
# 
#     # All of these are typically required for population analyses.
#     required_attrs = ('homos', 'mocoeffs', 'nbasis')
# 
#     # At least one of these are typically required.
#     overlap_attributes = ('aooverlaps', 'fooverlaps')
# 
#     def __init__(self, data, progress=None, \
#                  loglevel=logging.INFO, logname="Log"):
#         super().__init__(data, progress, loglevel, logname)
# 
#         self.fragresults = None
# 
#     def __str__(self):
#         """Return a string representation of the object."""
#         return "Population"
# 
#     def __repr__(self):
#         """Return a representation of the object."""
#         return "Population"
# 
#     def _check_required_attributes(self):
#         super()._check_required_attributes()
#         
#         if self.overlap_attributes and not any(hasattr(self.data, a) for a in self.overlap_attributes):
#             raise MissingAttributeError(
#                     'Need overlap matrix (aooverlaps or fooverlaps attribute) for Population methods')
# 
#     def partition(self, indices=None):
# 
#         if not hasattr(self, "aoresults"):
#             self.calculate()
# 
#         if not indices:
# 
#             # Build list of groups of orbitals in each atom for atomresults.
#             if hasattr(self.data, "aonames"):
#                 names = self.data.aonames
#             elif hasattr(self.data, "fonames"):
#                 names = self.data.fonames
# 
#             atoms = []
#             indices = []
# 
#             name = names[0].split('_')[0]
#             atoms.append(name)
#             indices.append([0])
# 
#             for i in range(1, len(names)):
#                 name = names[i].split('_')[0]
#                 try:
#                     index = atoms.index(name)
#                 except ValueError: #not found in atom list
#                     atoms.append(name)
#                     indices.append([i])
#                 else:
#                     indices[index].append(i)
# 
#         natoms = len(indices)
#         nmocoeffs = len(self.aoresults[0])
# 
#         # Build results numpy array[3].
#         alpha = len(self.aoresults[0])
#         results = []
#         results.append(numpy.zeros([alpha, natoms], "d"))
# 
#         if len(self.aoresults) == 2:
#             beta = len(self.aoresults[1])
#             results.append(numpy.zeros([beta, natoms], "d"))
# 
#         # For each spin, splice numpy array at ao index,
#         #   and add to correct result row.
#         for spin in range(len(results)):
# 
#             for i in range(natoms): # Number of groups.
# 
#                 for j in range(len(indices[i])): # For each group.
# 
#                     temp = self.aoresults[spin][:, indices[i][j]]
#                     results[spin][:, i] = numpy.add(results[spin][:, i], temp)
# 
#         self.logger.info("Saving partitioned results in fragresults: [array[2]]")
#         self.fragresults = results
# 
#         return True


import random
import numpy
from cclib.method.calculationmethod import Method
from cclib.method.population import Population

# -*- coding: utf-8 -*-
#
# Copyright (c) 2018, the cclib development team
#
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.

"""Calculation of overlap population analysis based on cclib data."""





def func(x):
    if x==1:
        return 1
    else:
        return x+func(x-1)



# Path: cclib/method/calculationmethod.py
# class Method:
#     """Abstract base class for all cclib method classes.
# 
#     Subclasses defined by cclib:
#         CDA - charde decomposition analysis
#         CSPA - C-squared population analysis
#         Density - density matrix calculation
#         FragmentAnalysis - fragment analysis for ADF output
#         LPA - Löwdin population analysis
#         MBO - Mayer's bond orders
#         Moments - multipole moments calculations
#         MPA - Mulliken population analysis
#         Nuclear - properties of atomic nuclei
#         OPA - overlap population analysis
#         Population - base class for population analyses
#         Volume - volume/grid calculations
# 
#     All the modules containing methods should be importable.
#     """
#     required_attrs = ()
#     def __init__(self, data, progress=None, loglevel=logging.INFO, logname="Log"):
#         """Initialise the Logfile object.
# 
#         This constructor is typically called by the constructor of a subclass.
#         """
# 
#         self.data = data
#         self.progress = progress
#         self.loglevel = loglevel
#         self.logname = logname
#         self._check_required_attributes()
#         self.logger = logging.getLogger('%s %s' % (self.logname, self.data))
#         self.logger.setLevel(self.loglevel)
#         self.logformat = "[%(name)s %(levelname)s] %(message)s"
#         handler = logging.StreamHandler(sys.stdout)
#         handler.setFormatter(logging.Formatter(self.logformat))
#         self.logger.addHandler(handler)
# 
#     def _check_required_attributes(self):
#         """Check if required attributes are present in data."""
#         missing = [x for x in self.required_attrs
#                     if not hasattr(self.data, x)]
#         if missing:
#             missing = ' '.join(missing)
#             raise MissingAttributeError(
#                 'Could not parse required attributes to use method: ' + missing)
# 
# Path: cclib/method/population.py
# class Population(Method):
#     """An abstract base class for population-type methods."""
# 
#     # All of these are typically required for population analyses.
#     required_attrs = ('homos', 'mocoeffs', 'nbasis')
# 
#     # At least one of these are typically required.
#     overlap_attributes = ('aooverlaps', 'fooverlaps')
# 
#     def __init__(self, data, progress=None, \
#                  loglevel=logging.INFO, logname="Log"):
#         super().__init__(data, progress, loglevel, logname)
# 
#         self.fragresults = None
# 
#     def __str__(self):
#         """Return a string representation of the object."""
#         return "Population"
# 
#     def __repr__(self):
#         """Return a representation of the object."""
#         return "Population"
# 
#     def _check_required_attributes(self):
#         super()._check_required_attributes()
#         
#         if self.overlap_attributes and not any(hasattr(self.data, a) for a in self.overlap_attributes):
#             raise MissingAttributeError(
#                     'Need overlap matrix (aooverlaps or fooverlaps attribute) for Population methods')
# 
#     def partition(self, indices=None):
# 
#         if not hasattr(self, "aoresults"):
#             self.calculate()
# 
#         if not indices:
# 
#             # Build list of groups of orbitals in each atom for atomresults.
#             if hasattr(self.data, "aonames"):
#                 names = self.data.aonames
#             elif hasattr(self.data, "fonames"):
#                 names = self.data.fonames
# 
#             atoms = []
#             indices = []
# 
#             name = names[0].split('_')[0]
#             atoms.append(name)
#             indices.append([0])
# 
#             for i in range(1, len(names)):
#                 name = names[i].split('_')[0]
#                 try:
#                     index = atoms.index(name)
#                 except ValueError: #not found in atom list
#                     atoms.append(name)
#                     indices.append([i])
#                 else:
#                     indices[index].append(i)
# 
#         natoms = len(indices)
#         nmocoeffs = len(self.aoresults[0])
# 
#         # Build results numpy array[3].
#         alpha = len(self.aoresults[0])
#         results = []
#         results.append(numpy.zeros([alpha, natoms], "d"))
# 
#         if len(self.aoresults) == 2:
#             beta = len(self.aoresults[1])
#             results.append(numpy.zeros([beta, natoms], "d"))
# 
#         # For each spin, splice numpy array at ao index,
#         #   and add to correct result row.
#         for spin in range(len(results)):
# 
#             for i in range(natoms): # Number of groups.
# 
#                 for j in range(len(indices[i])): # For each group.
# 
#                     temp = self.aoresults[spin][:, indices[i][j]]
#                     results[spin][:, i] = numpy.add(results[spin][:, i], temp)
# 
#         self.logger.info("Saving partitioned results in fragresults: [array[2]]")
#         self.fragresults = results
# 
#         return True


# Path: cclib/method/opa.py
import random
import numpy
from cclib.method.calculationmethod import Method
from cclib.method.population import Population

# -*- coding: utf-8 -*-
#
# Copyright (c) 2018, the cclib development team
#
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.

"""Calculation of overlap population analysis based on cclib data."""





def func(x):
    if x==1:
        return 1
    else:
        return x+func(x-1)



class OPA(Population):
