# Path: orbkit/tools.py
# def read_nist():
#   def rm_brackets(text,rm=['(',')','[',']']):
# def standard_mass(atom):
# def get_atom_symbol(atom):
# def l_deg(l=0,ao=None,cartesian_basis=True):
# def get_cart2sph(l,m):
# def remove_from_list(inlist, value):
# def validate_drv(drv):
# def each_ao_is_normalized(ao_spec):
# def prepare_ao_calc(ao_spec):    
# def is_mo_spec(mo):
# def moveaxis(array, source, target):
# def require(data,dtype='f',requirements='CA'):
# def convert(data,was_vector,N):
# def zeros(shape,name,hdf5_file=None,chunks=True):
# def reshape(data,shape,save_hdf5):
# def print2D(x,format='%+.2f ',start='\t',end=''):
# def pmat(matrix,vmax=lambda x: numpy.max(numpy.abs(x))):
# 
# Path: orbkit/display.py
# def display(string):
#   '''Prints :literal:`string` to the terminal output and to the .oklog file.'''
#   global log_fid
#   if not options.quiet:
#     print(string)
#   if not options.no_log:
#     if log_fid is None:
#       if options.outputname is None or options.outputname == '':
#         return
#       else:
#         log_fid = '%s.oklog' % options.outputname.split('@')[0]
#     if not is_initiated:
#       init_display(log_fid)
#     f = open(log_fid, 'a')
#     f.write('%s\n' % string)
#     f.close()


import numpy
import ctypes
import time
import os
from ..tools import lquant
from ..display import display
from itertools import chain, combinations_with_replacement
  from numpy import moveaxis
  from orbkit.tools import moveaxis

class AOIntegrals():
  '''Interface to calculate AO Integrals with libcint.
  https://github.com/sunqm/libcint
  '''
  def __init__(self, qc):

    # general parameters
    self.qc = qc
    self.clear_all_blocks()

    # libcint parameters
    ienv = 0
    self.basis = struct()
    self.env = [0]*ienv
    self.atm = []
    self.bas = []
    self.basis.cart_norm = []  # renormalization factors for cartesian integrals

    # build atm
    self.env.extend(qc.geo_spec.flatten())
    for center in qc.geo_info:
      # tuple for each center: (charge, coords offset, 0, 0, 0, 0)
      self.atm.append((float(center[2]), ienv, 0, 0, 0, 0))
      ienv += 3

    # build bas
    for ii, ao in enumerate(qc.ao_spec):

      # TODO: column-wise coefficients for contractions of same exponents

# Path: orbkit/tools.py
# def read_nist():
#   def rm_brackets(text,rm=['(',')','[',']']):
# def standard_mass(atom):
# def get_atom_symbol(atom):
# def l_deg(l=0,ao=None,cartesian_basis=True):
# def get_cart2sph(l,m):
# def remove_from_list(inlist, value):
# def validate_drv(drv):
# def each_ao_is_normalized(ao_spec):
# def prepare_ao_calc(ao_spec):    
# def is_mo_spec(mo):
# def moveaxis(array, source, target):
# def require(data,dtype='f',requirements='CA'):
# def convert(data,was_vector,N):
# def zeros(shape,name,hdf5_file=None,chunks=True):
# def reshape(data,shape,save_hdf5):
# def print2D(x,format='%+.2f ',start='\t',end=''):
# def pmat(matrix,vmax=lambda x: numpy.max(numpy.abs(x))):
# 
# Path: orbkit/display.py
# def display(string):
#   '''Prints :literal:`string` to the terminal output and to the .oklog file.'''
#   global log_fid
#   if not options.quiet:
#     print(string)
#   if not options.no_log:
#     if log_fid is None:
#       if options.outputname is None or options.outputname == '':
#         return
#       else:
#         log_fid = '%s.oklog' % options.outputname.split('@')[0]
#     if not is_initiated:
#       init_display(log_fid)
#     f = open(log_fid, 'a')
#     f.write('%s\n' % string)
#     f.close()


# Path: orbkit/libcint_interface/ao_integrals.py
import numpy
import ctypes
import time
import os
from ..tools import lquant
from ..display import display
from itertools import chain, combinations_with_replacement
  from numpy import moveaxis
  from orbkit.tools import moveaxis


class AOIntegrals():
  '''Interface to calculate AO Integrals with libcint.
  https://github.com/sunqm/libcint
  '''
  def __init__(self, qc):

    # general parameters
    self.qc = qc
    self.clear_all_blocks()

    # libcint parameters
    ienv = 0
    self.basis = struct()
    self.env = [0]*ienv
    self.atm = []
    self.bas = []
    self.basis.cart_norm = []  # renormalization factors for cartesian integrals

    # build atm
    self.env.extend(qc.geo_spec.flatten())
    for center in qc.geo_info:
      # tuple for each center: (charge, coords offset, 0, 0, 0, 0)
      self.atm.append((float(center[2]), ienv, 0, 0, 0, 0))
      ienv += 3

    # build bas
    for ii, ao in enumerate(qc.ao_spec):

      # TODO: column-wise coefficients for contractions of same exponents

      l = lquant[ao['type']]