コード例 #1
0
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())
コード例 #2
0
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())
コード例 #3
0
# 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())