Determine the DFT+U type and parameters from the output
557597
def get_U_settings(self):
        ''''''
        with open(self.outputf) as fp:
            for line in fp:
                if "LDA+U calculation" in line:
                    U_param = {}
                    U_param['Type'] = line.split()[0]
                    U_param['Values'] = {}
                    # look through next several lines
                    for nl in range(15):
                        line2 = next(fp).split()
                        if len(line2) > 1 and line2[0] == "atomic":
                            pass # column titles
                        elif len(line2) == 6:
                            U_param['Values'][line2[0]] = {}
                            U_param['Values'][line2[0]]['L'] = float(line2[1])
                            U_param['Values'][line2[0]]['U'] = float(line2[2])
                            U_param['Values'][line2[0]]['J'] = float(line2[4])
                        else: break # end of data block
                    return Value(**U_param)
            return None
1200576
def _ctypes_variables(parameter):
    
    if parameter.dimension is not None and ":" in parameter.dimension:
        #For arrays that provide input (including 'inout'), we pass the output separately
        #through a c-pointer. They will always be input arrays. For pure (out) parameters
        #we use *only* a c-ptr, but it needs intent (inout) since it is created by ctypes.
        if "in" in parameter.direction or parameter.direction == "":
            #We have to get the ctypes-compatible data type for the parameters.
            #stype = _ctypes_dtype(parameter)
            splice = _ctypes_splice(parameter)
            name = parameter.ctypes_parameter()[0]
            if parameter.direction == "(inout)" and not ("allocatable" in parameter.modifiers or
                                                         "pointer" in parameter.modifiers):
                return (parameter.definition(optionals=False, customdim=splice), False)
            else:
                return ("{}, intent(in) :: {}({})".format(parameter.strtype, name, splice), False)
    else:
        if parameter.dtype == "logical":
            stype = _ctypes_dtype(parameter)
            suffix = "_c"
            modifiers = None
        elif hasattr(parameter, "parameters"):
            stype = None
            suffix = "_f"
            modifiers = ["intent(out)"]
        else:
            stype = None
            suffix = ""
            modifiers = None
            
        return (parameter.definition(ctype=stype, optionals=False, suffix=suffix,
                                     modifiers=modifiers), False)
1126972
def _str_dtype(dtype):
        
        assert dtype.byteorder != '>'
        if dtype.kind == 'i':
            assert dtype.itemsize == 8
            return 'int64'
        elif dtype.kind == 'f':
            assert dtype.itemsize == 8
            return 'float64'
        elif dtype.kind == 'U':
            return 'U%d' % (dtype.itemsize / 4)
        else:
            raise UnhandledDtypeException("Bad dtype '%s'" % dtype)
803959
def _paramstr(ins):
    
    (tmp, output) = _str_oper(ins.quad[1])
    output.pop()  # Remove a register flag (useless here)
    tmp = ins.quad[1][0] in ('#', '_')  # Determine if the string must be duplicated

    if tmp:
        output.append('call __LOADSTR')  # Must be duplicated
        REQUIRES.add('loadstr.asm')

    output.append('push hl')
    return output
950571
def calculate_u(dt, dx, dy, u, um, k):
    up = numpy.zeros((u.shape[0], u.shape[1]))
    ""
    for i in xrange(1, u.shape[0]-1):
        for j in xrange(1, u.shape[1]-1):
            up[i,j] = 2*u[i,j] - um[i,j] + \
                (dt/dx)**2*(
                        (0.5*(k[i+1,j] + k[i,j])*(u[i+1,j] - u[i,j]) -
                            0.5*(k[i,j] + k[i-1,j])*(u[i,j] - u[i-1,j]))) + \
                        (dt/dy)**2*(
                                (0.5*(k[i,j+1] + k[i,j])*(u[i,j+1] - u[i,j]) -
                                    0.5*(k[i,j] + k[i,j-1])*(u[i,j] - u[i,j-1])))
    return up
1137815
def calculate_padding_output_shapes(operator):
    '''
    
    '''
    check_input_and_output_numbers(operator, input_count_range=1, output_count_range=1)
    check_input_and_output_types(operator, good_input_types=[FloatTensorType])

    output_shape = copy.deepcopy(operator.inputs[0].type.shape)

    params = operator.raw_operator.padding
    if len(params.paddingAmounts.borderAmounts) > 0:
        output_shape[2] += params.paddingAmounts.borderAmounts[0].startEdgeSize
        output_shape[2] += params.paddingAmounts.borderAmounts[0].endEdgeSize
        output_shape[3] += params.paddingAmounts.borderAmounts[1].startEdgeSize
        output_shape[3] += params.paddingAmounts.borderAmounts[1].endEdgeSize

    operator.outputs[0].type.shape = output_shape
890108
def pprint(self):
        

        s = u"ASF (%s) %d bps, %s Hz, %d channels, %.2f seconds" % (
            self.codec_type or self.codec_name or u"???", self.bitrate,
            self.sample_rate, self.channels, self.length)
        return s
423784
function parseLdOutput(output) {
    const libraryList = output.split('\n').filter(ln => ln.includes('=>'));

    const result = {};
    libraryList.forEach(s => {
        const [name, _, libPath] = s.trim().split(' ');
        result[name] = libPath;
    });

    return result;
}
446669
def _get_stddevs(self, C, stddev_types, rup, imt, num_sites):
        
        stddevs = []
        for stddev_type in stddev_types:
            sigma_mean = self._compute_standard_dev(rup, imt, C)
            sigma_tot = np.sqrt((sigma_mean ** 2) + (C['SigmaReg'] ** 2))
            sigma_tot = np.log10(np.exp(sigma_tot))
            stddevs.append(sigma_tot + np.zeros(num_sites))
        return stddevs
15845
def get_prtfmt(self, key="fmta"):
        """"""
        prtfmt = self.sortobj.grprobj.gosubdag.prt_attr[key]
        prtfmt = prtfmt.replace("{NS}", "{NS} {num_usrgos:>4} uGOs")
        return "".join(['{hdr1usr01:2}', prtfmt, '\n'])
1175823
def UXTH(self, params):
        
        Ra, Rb = self.get_two_parameters(r'\s*([^\s,]*),\s*([^\s,]*)(,\s*[^\s,]*)*\s*', params)

        self.check_arguments(low_registers=(Ra, Rb))

        def UXTH_func():
            self.register[Ra] = (self.register[Rb] & 0xFFFF)

        return UXTH_func
554787
def guess_param_types(**kwargs):
    
    params = {}
    for k, v in kwargs.items():
        kws = dict(default=v, constant=True)
        if isinstance(v, Parameter):
            params[k] = v
        elif isinstance(v, dt_types):
            params[k] = Date(**kws)
        elif isinstance(v, bool):
            params[k] = Boolean(**kws)
        elif isinstance(v, int):
            params[k] = Integer(**kws)
        elif isinstance(v, float):
            params[k] = Number(**kws)
        elif isinstance(v, str):
            params[k] = String(**kws)
        elif isinstance(v, dict):
            params[k] = Dict(**kws)
        elif isinstance(v, tuple):
            if all(_is_number(el) for el in v):
                params[k] = NumericTuple(**kws)
            elif all(isinstance(el. dt_types) for el in v) and len(v)==2:
                params[k] = DateRange(**kws)
            else:
                params[k] = Tuple(**kws)
        elif isinstance(v, list):
            params[k] = List(**kws)
        elif isinstance(v, np.ndarray):
            params[k] = Array(**kws)
        else:
            from pandas import DataFrame as pdDFrame
            from pandas import Series as pdSeries

            if isinstance(v, pdDFrame):
                params[k] = DataFrame(**kws)
            elif isinstance(v, pdSeries):
                params[k] = Series(**kws)
            else:
                params[k] = Parameter(**kws)

    return params
119523
static function guessMimeType($file, $def = 'application/octet-stream')
	{
		// extract file extension (after . symbol)
		$ext = substr(strrchr(strtolower($file), '.'), 1);
	
		switch ( $ext )
		{
			case 'gif':
			case 'jpeg':
			case 'png':
				return "image/$ext";
			case 'jpg':
				return 'image/jpeg';
			case 'mp4':
			case 'mpeg':
			case 'avi':
				return "video/$ext";
			case 'mp3':
				return 'audio/mpeg3';
			case 'wav':
				return 'audio/wav';
			case 'pdf':
				return 'application/pdf';
			case 'htm':
			case 'html':
				return 'text/html';
			case 'txt':
				return 'text/plain';
			case 'eml':
				return 'message/rfc822';
			case 'doc':
				return 'application/msword';
			case 'docx':
				return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
			case 'xls':
				return 'application/vnd.ms-excel';
			case 'xlsx':
				return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
			case 'ppt':
			case 'pps':
				return 'application/vnd.ms-powerpoint';
			case 'pptx':
			case 'ppsx':
				return 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
			case 'odt':
				return 'application/vnd.oasis.opendocument.text';
			case 'ods':
				return 'application/vnd.oasis.opendocument.spreadsheet';
			case 'odp':
				return 'application/vnd.oasis.opendocument.presentation';
			case 'zip':
				return 'application/zip';
			default :
				return $def;
		}
	}
675916
def print_parameters(self):
        
        print("Static: ", self.params_hugoniot)
        print("Thermal: ", self.params_therm)
        print("Anharmonic: None")
        print("Electronic: None")
1179627
def _fcall_out_type(fcall):
    
    if isinstance(fcall, FunctionSpaceElement):
        call_has_out = fcall._call_has_out
        call_out_optional = fcall._call_out_optional

    # Numpy Ufuncs and similar objects (e.g. Numba DUfuncs)
    elif hasattr(fcall, 'nin') and hasattr(fcall, 'nout'):
        if fcall.nin != 1:
            raise ValueError('ufunc {} has {} input parameter(s), '
                             'expected 1'
                             ''.format(fcall.__name__, fcall.nin))
        if fcall.nout > 1:
            raise ValueError('ufunc {} has {} output parameter(s), '
                             'expected at most 1'
                             ''.format(fcall.__name__, fcall.nout))
        call_has_out = call_out_optional = (fcall.nout == 1)
    elif inspect.isfunction(fcall):
        call_has_out, call_out_optional = _check_out_arg(fcall)
    elif callable(fcall):
        call_has_out, call_out_optional = _check_out_arg(fcall.__call__)
    else:
        raise TypeError('object {!r} not callable'.format(fcall))

    return call_has_out, call_out_optional
81036
def F(self, **kwargs):
        '''
        
        '''
        Eg = self.Eg_Gamma_0(**kwargs)
        Delta_SO = self.Delta_SO(**kwargs)
        Ep = self.Ep(**kwargs)
        meff = self.meff_e_Gamma_0(**kwargs)
        return (1./meff-1-(Ep*(Eg+2.*Delta_SO/3.))/(Eg*(Eg+Delta_SO)))/2
333564
def check_argument_type(dtype, kernel_argument, i):
    """"""
    types_map = {"uint8": ["uchar", "unsigned char", "uint8_t"],
                 "int8": ["char", "int8_t"],
                 "uint16": ["ushort", "unsigned short", "uint16_t"],
                 "int16": ["short", "int16_t"],
                 "uint32": ["uint", "unsigned int", "uint32_t"],
                 "int32": ["int", "int32_t"],   #discrepancy between OpenCL and C here, long may be 32bits in C
                 "uint64": ["ulong", "unsigned long", "uint64_t"],
                 "int64": ["long", "int64_t"],
                 "float16": ["half"],
                 "float32": ["float"],
                 "float64": ["double"]}
    if dtype in types_map:
        return any([substr in kernel_argument for substr in types_map[dtype]])
    else:
        return False