Beispiel #1
0
    def write_splash():
        if not NexusCore.wrote_splash:
            splash_text = '''
_____________________________________________________

                     Nexus {}.{}.{}

        (c) Copyright 2012-  Nexus developers

                     Please cite:
  J. T. Krogel Comput. Phys. Commun. 198 154 (2016)
     https://doi.org/10.1016/j.cpc.2015.08.012
_____________________________________________________
          
            '''.format(*nexus_version)
            log(splash_text)
            NexusCore.wrote_splash = True
Beispiel #2
0
 def __call__(self,msg,level='low',n=0,time=False,mem=False,width=75):
     if self.verbosity==self.verbosity_levels.none:
         return
     elif self.verbosity >= self.verbosity_levels[level]:
         if mem or time:
             npad = max(0,width-2*(n+self.indent)-len(msg)-36)
             if npad>0:
                 msg += npad*' '
             #end if
             if mem:
                 dm = 1e6 # MB
                 mnow = memory.resident(children=True)
                 msg += '  (mem add {:6.2f}, tot {:6.2f})'.format((mnow-self.mlast)/dm,(mnow-self.mstart)/dm)
                 self.mlast = mnow
             #end if
             if time:
                 tnow = process_time()
                 msg += '  (t elap {:7.3f}, tot {:7.3f})'.format(tnow-self.tlast,tnow-self.tstart)
                 self.tlast = tnow
             #end if
         #end if
         log(msg,n=n+self.indent)
def extract_input_specification(*ezfio_paths):
    if len(ezfio_paths) == 1 and isinstance(ezfio_paths[0], (list, tuple)):
        ezfio_paths = ezfio_paths[0]
    #end if
    log('\nextracting Quantum Package input specification from ezfio directories'
        )
    typedict = {bool: 'bool', int: 'int', float: 'float', str: 'str'}
    new_input_spec = obj()
    for vpath, vtype in input_specification.items():
        new_input_spec[vpath] = typedict[vtype]
    #end for
    for epath in ezfio_paths:
        epath = epath.rstrip('/')
        if not epath.endswith('.ezfio'):
            error(
                'cannot extract input spec from path\ninput path provided is not an ezfio directory\ninput path provided: {0}'
                .format(epath), 'Quantum Package')
        elif not os.path.exists(epath):
            error(
                'cannot extract input spec from path\ninput path provided does not exist\ninput path provided: {0}'
                .format(epath), 'Quantum Package')
        #end if
        log('  extracting from: {0}'.format(epath))
        for path, dirs, files in os.walk(epath):
            for file in files:
                if 'save' not in path and 'work' not in path:
                    if not file.startswith('.') and not file.endswith('.gz'):
                        filepath = os.path.join(path, file)
                        vtype = read_qp_value_type(filepath)
                        vpath = filepath.replace(epath, '').strip('/')
                        if vpath not in new_input_spec:
                            new_input_spec[vpath] = vtype
                        #end if
                    #end if
                #end if
            #end for
        #end for
    #end for
    log('  extraction complete')

    old_vpaths = set(input_specification.keys())
    new_vpaths = set(new_input_spec.keys())
    if new_vpaths == old_vpaths:
        log('\ninput specification in quantum_package_input.py needs no changes\n'
            )
    else:
        log('\nplease replace input_specification in quantum_package_input.py with the following:\n'
            )
        log('input_specification = obj({')
        s = ''
        for vpath in sorted(new_input_spec.keys()):
            vtype = new_input_spec[vpath]
            s += "    '{0}' : {1},\n".format(vpath, vtype)
        #end for
        s += '    })\n'
        log(s)