def main(): packages = discover() # Write new/updated rst files if needed fns_rst = [] for package, modules in sorted(packages.iteritems()): # write the new file to a StringIO f = StringIO() print >> f, '..' print >> f, ' This file is automatically generated. Do not make ' print >> f, ' changes as these will be overwritten. Rather edit ' print >> f, ' the docstrings in the source code.' print >> f underline('``%s`` -- %s' % (package, get_first_docline(package)), '#', f) print >> f for module in sorted(modules): full = package + '.' + module underline('``%s`` -- %s' % (full, get_first_docline(full)), '=', f) print >> f, '.. automodule::', full print >> f, ' :members:' print >> f print >> f # write if the contents have changed fn_rst = 'rg_%s.rst' % package.replace('.', '_') fns_rst.append(fn_rst) write_if_changed(fn_rst, f.getvalue()) # Remove other rst files for fn_rst in glob('rg_yaff*.rst'): if fn_rst not in fns_rst: print 'Removing %s' % fn_rst os.remove(fn_rst)
def main(): packages = discover() # Write new/updated rst files if needed fns_rst = [] for package, modules in sorted(packages.iteritems()): # write the new file to a StringIO f1 = StringIO() write_disclaimer(f1) underline('``%s`` -- %s' % (package, get_first_docline(package)), '#', f1) print >> f1 print >> f1, '.. automodule::', package print >> f1, ' :members:' print >> f1 print >> f1, '.. toctree::' print >> f1, ' :maxdepth: 1' print >> f1, ' :numbered:' print >> f1 for module in modules: f2 = StringIO() write_disclaimer(f2) if module.endswith('.h'): #full = package + '/' + module fn_h = package.replace('.', '/') + '/' + module underline('``%s`` -- %s' % (fn_h, get_first_doxygenline(fn_h)), '#', f2) print >> f2, '.. doxygenfile::', fn_h print >> f2, ' :project: horton' print >> f2 print >> f2 else: full = package + '.' + module underline('``%s`` -- %s' % (full, get_first_docline(full)), '#', f2) print >> f2, '.. automodule::', full print >> f2, ' :members:' print >> f2 print >> f2 # write if the contents have changed rst_name = 'mod_%s_%s' % (package.replace( '.', '_'), module.replace('.', '_')) fn2_rst = 'lib/%s.rst' % rst_name fns_rst.append(fn2_rst) write_if_changed(fn2_rst, f2.getvalue()) print >> f1, ' %s' % rst_name # write if the contents have changed fn1_rst = 'lib/pck_%s.rst' % package.replace('.', '_') fns_rst.append(fn1_rst) write_if_changed(fn1_rst, f1.getvalue()) # Remove other rst files for fn_rst in glob('lib/*.rst'): if fn_rst not in fns_rst: print 'Removing %s' % fn_rst os.remove(fn_rst)
def main(): packages = discover() # Write new/updated rst files if needed fns_rst = [] for package, modules in sorted(packages.iteritems()): # write the new file to a StringIO f1 = StringIO() write_disclaimer(f1) underline('``%s`` -- %s' % (package, get_first_docline(package)), '#', f1) print >> f1 print >> f1, '.. automodule::', package print >> f1, ' :members:' print >> f1 print >> f1, '.. toctree::' print >> f1, ' :maxdepth: 1' print >> f1, ' :numbered:' print >> f1 for module in modules: f2 = StringIO() write_disclaimer(f2) if module.endswith('.h'): #full = package + '/' + module fn_h = package.replace('.', '/') + '/' + module underline('``%s`` -- %s' % (fn_h, get_first_doxygenline(fn_h)), '#', f2) print >> f2, '.. doxygenfile::', fn_h print >> f2, ' :project: horton' print >> f2 print >> f2 else: full = package + '.' + module underline('``%s`` -- %s' % (full, get_first_docline(full)), '#', f2) print >> f2, '.. automodule::', full print >> f2, ' :members:' print >> f2 print >> f2 # write if the contents have changed rst_name = 'mod_%s_%s' % (package.replace('.', '_'), module.replace('.', '_')) fn2_rst = 'lib/%s.rst' % rst_name fns_rst.append(fn2_rst) write_if_changed(fn2_rst, f2.getvalue()) print >> f1, ' %s' % rst_name # write if the contents have changed fn1_rst = 'lib/pck_%s.rst' % package.replace('.', '_') fns_rst.append(fn1_rst) write_if_changed(fn1_rst, f1.getvalue()) # Remove other rst files for fn_rst in glob('lib/*.rst'): if fn_rst not in fns_rst: print 'Removing %s' % fn_rst os.remove(fn_rst)
def main(): packages = discover() # Write new/updated rst files if needed fns_rst = [] for package, modules in sorted(packages.iteritems()): # write the new file to a StringIO f = StringIO() print >> f, '..' print >> f, ' This file is automatically generated. Do not make ' print >> f, ' changes as these will be overwritten. Rather edit ' print >> f, ' the documentation in the source code.' print >> f underline('``%s`` -- %s' % (package, get_first_docline(package)), '#', f) print >> f for module in modules: if module.endswith('.h'): #full = package + '/' + module fn_h = package.replace('.', '/') + '/' + module underline('``%s``' % fn_h, '=', f) print >> f, '.. doxygenfile::', fn_h print >> f, ' :project: horton' print >> f print >> f else: full = package + '.' + module underline('``%s`` -- %s' % (full, get_first_docline(full)), '=', f) print >> f, '.. automodule::', full print >> f, ' :members:' print >> f print >> f # write if the contents have changed fn_rst = 'lib/%s.rst' % package.replace('.', '_') fns_rst.append(fn_rst) write_if_changed(fn_rst, f.getvalue()) # Remove other rst files for fn_rst in glob('lib/*.rst'): if fn_rst not in fns_rst: print 'Removing %s' % fn_rst os.remove(fn_rst)
def main(): packages = discover() # Write new/updated rst files if needed fns_rst = [] for package, modules in sorted(packages.iteritems()): print package, modules # write the new file to a StringIO f = StringIO() print >> f, '..' print >> f, ' This file is automatically generated. Do not make ' print >> f, ' changes as these will be overwritten. Rather edit ' print >> f, ' the docstrings in the source code.' print >> f underline('``%s`` -- %s' % (package, get_first_docline(package)), '#', f) print >> f for module in sorted(modules): full = package + '.' + module print >> f, '.. _seclab_rg_%s_%s:' print >> f underline('``%s`` -- %s' % (full, get_first_docline(full)), '=', f) print >> f, '.. automodule::', full print >> f, ' :members:' print >> f print >> f # write if the contents have changed fn_rst = 'rg_%s.rst' % package.replace('.', '_') fns_rst.append(fn_rst) write_if_changed(fn_rst, f.getvalue()) fns_rst.append('rg_qff.rst') fns_rst.append('rg_qffinputei.rst') # Remove other rst files for fn_rst in glob('rg_*.rst'): if fn_rst not in fns_rst: print 'Removing %s' % fn_rst os.remove(fn_rst)
def main(): packages = discover() # Write new/updated rst files if needed fns_rst = [] for package, modules in sorted(packages.items()): # write the new file to a StringIO f = StringIO() f.write(u'..\n') f.write(u' This file is automatically generated. Do not make\n') f.write(u' changes as these will be overwritten. Rather edit\n') f.write(u' the docstrings in the source code.\n') f.write(u'\n') underline('``%s`` -- %s' % (package, get_first_docline(package)), '#', f) f.write(u'\n') for module in sorted(modules): f.write(u'\n') f.write(u'\n') full = package + '.' + module underline(u'``%s`` -- %s' % (full, get_first_docline(full)), '=', f) f.write(u'.. automodule:: ' + full + '\n') f.write(u' :members:\n') # write if the contents have changed fn_rst = 'rg_%s.rst' % package.replace('.', '_') fns_rst.append(fn_rst) write_if_changed(fn_rst, f.getvalue()) # Remove other rst files for fn_rst in glob('rg_yaff*.rst'): if fn_rst not in fns_rst: print('Removing %s' % fn_rst) os.remove(fn_rst)
# # You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/> # # -- from cStringIO import StringIO from horton.log import Biblio from horton.context import context from common import write_if_changed biblio = Biblio(context.get_fn('references.bib')) def key(item): return int(item[1].tags['year']), item[0] f = StringIO() print >> f, 'Literature' print >> f, '##########' items = biblio._records.items() items.sort(key=key) for key, reference in items: print >> f print >> f, '.. [%s] %s' % (key, reference.format_rst()) s = f.getvalue() write_if_changed('tech_ref_literature.rst', s)
from cStringIO import StringIO import os from horton.periodic import periodic from horton.log import log from horton.gbasis.gobasis import go_basis_families_list from common import write_rst_table, write_if_changed log.set_level(log.silent) table = [['Basis set name', 'Supported elements']] for family in go_basis_families_list: family.load() numbers = sorted(family.basis_atom_map.keys()) s = [] for i in xrange(len(numbers)): if (i > 0 and i < len(numbers)-1) and numbers[i-1] == numbers[i]-1 \ and numbers[i+1] == numbers[i]+1: if s[-1] != '-': s.append('-') else: s.append(periodic[numbers[i]].symbol) range_str = ' '.join(s).replace(' - ', '--').replace(' ', ', ') table.append([family.name, range_str]) f = StringIO() write_rst_table(f, table, nhead=1) write_if_changed('basis.rst.inc', f.getvalue())
npoint = None elements.add((int(words[0]), int(words[1]))) grids = sorted(grids) alts = ['coarse', 'medium', 'fine', 'veryfine', 'ultrafine', 'insane'] elements = sorted(elements) f = StringIO() def print_markers(): print >> f, '======= === ====', ' '.join(['========='] * len(grids)) print_markers() print >> f, 'Element Z Zeff', ' '.join([grid.ljust(9) for grid in grids]) print >> f, '\ \ \ ', ' '.join([alt.ljust(9) for alt in alts]) print_markers() for z, zeff in elements: print >> f, '%7s %3i %4i' % (periodic[z].symbol, z, zeff), for grid in grids: npoint = npoints.get((z, zeff, grid)) if npoint is None: print >> f, '-- ', else: print >> f, '%9i' % npoint, print >> f print_markers() write_if_changed('grids.rst.inc', f.getvalue())
def main(): """Main program.""" # Load dependency information -> libxc version with open('../dependencies.json') as f: dependencies = json.load(f) # Order does not matter here. Just make it easy to look things up dependencies = dict((d['name'], d) for d in dependencies) libxc_version = dependencies['libxc']['version_ci'] # find the qaworkdir qaworkdir = os.getenv('QAWORKDIR') if qaworkdir is None: qaworkdir = '../qaworkdir' # find all the functional keys by processing funcs_key.c keys = [] with open('%s/cached/libxc-%s/funcs_key.c' % (qaworkdir, libxc_version)) as f: for line in f: if line.startswith('{'): words = line.strip()[1:-3].split(',') key = words[0][1:-1] if len(key) > 0: keys.append(key) # sort the functions splitkeys = [] for key in keys: words = key.split('_') if words[0] == 'hyb': prefix = '_'.join(words[:2]) mid = words[2] suffix = '_'.join(words[3:]) else: prefix = words[0] mid = words[1] suffix = '_'.join(words[2:]) splitkeys.append((prefix, mid, suffix)) splitkeys.sort(cmp=cmp_splitkey) keys = [] for splitkey in splitkeys: splitkey = [part for part in splitkey if len(part) > 0] keys.append('_'.join(splitkey)) # make a rst table of all functionals s = StringIO() print >> s, '.. _ref_functionals:' print >> s print >> s, 'LibXC Functionals' print >> s, '#################' print >> s print >> s, 'The following functionals are available in HORTON through `LibXC' print >> s, '<http://www.tddft.org/programs/octopus/wiki/index.php/Libxc>`_ %s.' % \ libxc_version print >> s, '[marques2012]_' print >> s for key in keys: try: w = ULibXCWrapper(key) print >> s, '**%s**' % key print >> s, ' | %s' % w.name for line in w.refs.split('\n'): line = line.strip() if len(line) > 0: print >> s, ' | *%s*' % line print >> s except ValueError: # A bug in libxc ... print 'FAILED to load functional', key write_if_changed('tech_ref_functionals.rst', s.getvalue())
words = line.strip()[1:-3].split(',') key = words[0][1:-1] if len(key) > 0 and 'mgga' not in key: keys.append(key) # make a rst table of all functionals from horton import LibXCWrapper from cStringIO import StringIO from common import write_if_changed s = StringIO() print >> s, '.. _ref_functionals:' print >> s print >> s, 'LibXC Functionals' print >> s, '#################' print >> s print >> s, 'The following functionals are available in Horton through `LibXC <http://www.tddft.org/programs/octopus/wiki/index.php/Libxc>`_ %s. [marques2012]_' % libxc_version print >> s, '(The MGGA functionals are not supported yet in Horton.)' print >> s for key in keys: print >> s, '**%s**' % key w = LibXCWrapper(key) print >> s, ' | %s' % w.name for line in w.refs.split('\n'): print >> s, ' | *%s*' % line print >> s write_if_changed('ref_functionals.rst', s.getvalue())
from glob import glob from cStringIO import StringIO import json, os from common import write_rst_table, write_if_changed cases = [] for fn_py in sorted(glob('../data/examples/hf_dft/*.py')): with open(fn_py) as f: s = '' for line in f: if line.startswith('#JSON'): s += line[5:] if len(s) == 0: raise RuntimeError( 'Could not find JSON line in HF/DFT example script.') meta = json.loads(s) case = [ meta['difficulty'], os.path.basename(fn_py), meta['lot'], meta['scf'], meta['description'] ] cases.append(case) cases.sort() table = [['File name', 'LOT', 'SCF', 'Description'] ] + [case[1:] for case in cases] f = StringIO() write_rst_table(f, table) write_if_changed('hf_dft_examples.rst.inc', f.getvalue())
npoint = int(line.split()[-1]) words = line.split() if line[0] != '#' and len(words) == 2: assert isinstance(npoint, int) npoints[int(words[0]), int(words[1]), grid] = npoint npoint = None elements.add((int(words[0]), int(words[1]))) grids = sorted(grids) alts = ['coarse', 'medium', 'fine', 'veryfine', 'ultrafine', 'insane'] elements = sorted(elements) table = [ ['Element', 'Z', 'Zeff'] + grids, [' ', ' ', ' '] + alts, ] for z, zeff in elements: row = [periodic[z].symbol, str(z), str(zeff)] for grid in grids: npoint = npoints.get((z, zeff, grid)) if npoint is None: row.append('--') else: row.append(str(npoint)) table.append(row) f = StringIO() write_rst_table(f, table, nhead=2) write_if_changed('grids.rst.inc', f.getvalue())
def main(): """Main program.""" # Load dependency information -> libxc version with open('../dependencies.json') as f: dependencies = json.load(f) # Order does not matter here. Just make it easy to look things up dependencies = dict((d['name'], d) for d in dependencies) libxc_version = dependencies['libxc']['version_ci'] # find the qaworkdir qaworkdir = os.getenv('QAWORKDIR') if qaworkdir is None: qaworkdir = '../qaworkdir' # find all the functional keys by processing funcs_key.c keys = [] with open('%s/cached/libxc-%s/funcs_key.c' % (qaworkdir, libxc_version)) as f: for line in f: if line.startswith('{'): words = line.strip()[1:-3].split(',') key = words[0][1:-1] if len(key) > 0: keys.append(key) # sort the functions splitkeys = [] for key in keys: words = key.split('_') if words[0] == 'hyb': prefix = '_'.join(words[:2]) mid = words[2] suffix = '_'.join(words[3:]) else: prefix = words[0] mid = words[1] suffix = '_'.join(words[2:]) splitkeys.append((prefix, mid, suffix)) splitkeys.sort(cmp=cmp_splitkey) keys = [] for splitkey in splitkeys: splitkey = [part for part in splitkey if len(part) > 0] keys.append('_'.join(splitkey)) # make a rst table of all functionals s = StringIO() print >> s, '.. _ref_functionals:' print >> s print >> s, 'LibXC Functionals' print >> s, '#################' print >> s print >> s, 'The following functionals are available in HORTON through `LibXC' print >> s, '<http://www.tddft.org/programs/octopus/wiki/index.php/Libxc>`_ %s.' % \ libxc_version print >> s, '[marques2012]_' print >> s for key in keys: try: w = ULibXCWrapper(key) print >> s, '**{}**: {}'.format(key, w.name) print >> s for ref, doi, _biblio in w.refs: print >> s, ' | {}'.format(ref), if len(doi) > 0: print >> s, ' https://doi.org/{}'.format(doi) else: print >> s print >> s except ValueError: # A bug in libxc ... print 'FAILED to load functional', key write_if_changed('tech_ref_functionals.rst', s.getvalue())
# along with this program; if not, see <http://www.gnu.org/licenses/> # # -- '''Update the table with HF/DFT examples based on files in data/examples/hf_dft.''' from glob import glob from cStringIO import StringIO import json, os from common import write_rst_table, write_if_changed cases = [] for fn_py in sorted(glob('../data/examples/hf_dft/*.py')): with open(fn_py) as f: s = '' for line in f: if line.startswith('#JSON'): s += line[5:] if len(s) == 0: raise RuntimeError('Could not find JSON line in HF/DFT example script.') meta = json.loads(s) case = [meta['difficulty'], os.path.basename(fn_py), meta['lot'], meta['scf'], meta['description']] cases.append(case) cases.sort() table = [['File name', 'LOT', 'SCF', 'Description']] + [case[1:] for case in cases] f = StringIO() write_rst_table(f, table) write_if_changed('hf_dft_examples.rst.inc', f.getvalue())