Import formulas specified in :attr:`parameters`.

        :returns: formulas
        :rtype: dict
555282
def import_formulas(self):
        
        # TODO: unit tests!
        # TODO: move this to somewhere else and call it "importy", maybe
        # core.__init__.py since a lot of modules might use it.
        module = self.meta.module  # module read from parameters
        package = getattr(self.meta, 'package', None)  # package read from meta
        name = package + module if package else module  # concat pkg + name
        path = getattr(self.meta, 'path', None)  # path read from parameters
        # import module using module and package
        mod = None
        # SEE ALSO: http://docs.python.org/2/library/imp.html#examples
        try:
            # fast path: see if module was already imported
            mod = sys.modules[name]
        except KeyError:
            try:
                # import module specified in parameters
                mod = importlib.import_module(module, package)
            except ImportError as err:
                if not path:
                    msg = ('%s could not be imported either because it was not '
                           'on the PYTHONPATH or path was not given.')
                    LOGGER.exception(msg, name)
                    raise err
                else:
                    # import module using path
                    # expand ~, environmental variables and make path absolute
                    if not os.path.isabs(path):
                        path = os.path.expanduser(os.path.expandvars(path))
                        path = os.path.abspath(path)
                    # paths must be a list
                    paths = [path]
                    # imp does not find hierarchical module names, find and load
                    # packages recursively, then load module, see last paragraph
                    # https://docs.python.org/2/library/imp.html#imp.find_module
                    pname = ''  # full dotted name of package to load
                    # traverse namespace
                    while name:
                        # if dot in name get first package
                        if '.' in name:
                            pkg, name = name.split('.', 1)
                        else:
                            pkg, name = name, None  # pkg is the module
                        # Find package or module by name and path
                        fp, filename, desc = imp.find_module(pkg, paths)
                        # full dotted name of package to load
                        pname = pkg if not pname else '%s.%s' % (pname, pkg)
                        LOGGER.debug('package name: %s', pname)
                        # try to load the package or module
                        try:
                            mod = imp.load_module(pname, fp, filename, desc)
                        finally:
                            if fp:
                                fp.close()
                        # append package paths for imp.find_module
                        if name:
                            paths = mod.__path__
        formulas = {}  # an empty list of formulas
        formula_param = self.parameters  # formulas key
        # FYI: iterating over dictionary is equivalent to iterkeys()
        if isinstance(formula_param, (list, tuple, dict)):
            # iterate through formulas
            for f in formula_param:
                formulas[f] = getattr(mod, f)
        elif isinstance(formula_param, basestring):
            # only one formula
            # FYI: use basestring to test for str and unicode
            # SEE: http://docs.python.org/2/library/functions.html#basestring
            formulas[formula_param] = getattr(mod, formula_param)
        else:
            # autodetect formulas assuming first letter is f
            formulas = {f: getattr(mod, f) for f in dir(mod) if f[:2] == 'f_'}
        if not len(formulas):
            for f in dir(mod):
                mod_attr = getattr(mod, f)
                if inspect.isfunction(mod_attr):
                    formulas[f] = mod_attr
        return formulas
1068281
def as_dict(self):
        
        structure = self.final_structure
        d = {"has_gaussian_completed": self.properly_terminated,
             "nsites": len(structure)}
        comp = structure.composition
        d["unit_cell_formula"] = comp.as_dict()
        d["reduced_cell_formula"] = Composition(comp.reduced_formula).as_dict()
        d["pretty_formula"] = comp.reduced_formula
        d["is_pcm"] = self.is_pcm
        d["errors"] = self.errors
        d["Mulliken_charges"] = self.Mulliken_charges

        unique_symbols = sorted(list(d["unit_cell_formula"].keys()))
        d["elements"] = unique_symbols
        d["nelements"] = len(unique_symbols)
        d["charge"] = self.charge
        d["spin_multiplicity"] = self.spin_multiplicity

        vin = {"route": self.route_parameters, "functional": self.functional,
               "basis_set": self.basis_set,
               "nbasisfunctions": self.num_basis_func,
               "pcm_parameters": self.pcm}

        d["input"] = vin

        nsites = len(self.final_structure)

        vout = {
            "energies": self.energies,
            "final_energy": self.final_energy,
            "final_energy_per_atom": self.final_energy / nsites,
            "molecule": structure.as_dict(),
            "stationary_type": self.stationary_type,
            "corrections": self.corrections
        }

        d['output'] = vout
        d["@module"] = self.__class__.__module__
        d["@class"] = self.__class__.__name__

        return d
194566
def to_dict(self):
        
        return {
            'mean': self.mean,
            'var': self.var,
            'min': self.min,
            'max': self.max,
            'num': self.num
        }
838357
def params(self):
        
        return [{"name": p_name, "type": p_type.__name__}
                for (p_name, p_type) in self.signature.parameter_types]
769526
def params(self):
        
        params = MultiDict(self.GET)
        for key, value in self.forms.iterallitems():
            params[key] = value
        return params
1352253
def _parse_formula(formula):
    
    #TODO: DEAL WITH BSPLINE HAS MULTIPLE ARGUEMENTS (NOT JUST ONE)

    # break formula apart from encoding instructions
    formula,instr = formula.replace(' ','').split('|')
    # break formula apart at + sign
    formula_terms = formula.split('+') 
    # examine the instructions term, first split by ),
    instr = instr.split('),')
    # elements in the instr list will match the number of non interaction 
    #      elements in formula
    # go through each formula term, making a dictionary whose key is variable name
    formula_dict = {}
    encoding     = []
    other_arg    = []
    inter_list   = []
    for term in formula_terms:
        if "*" in term:
            # then this is an interaction term, make 'list of lists'
            term = term.split('*')
            inter_list.append(term)
        else:
            # then this is not an interaction term, make blank dictionary
            formula_dict[term] = [encoding, other_arg]
    # loop through instructions, parse each term
    for term in instr:
        # remove punctuation in term
        term = re.sub('[()]','',term)
        # check for each encoding type
        if "Dev" in term:
            # remove first three letters (Dev)
            term = term[3:]
            # split on comma
            var_name,arg = term.split(',')
            # split on equals sign in arg, take part after
            drop_name = arg.split('=')[1]
            # put var_name and drop_name into proper key in formula_dict
            formula_dict[var_name] = ["Dev",drop_name]
        elif "Dum" in term:
            # remove first three letters (Dum)
            term = term[3:]
            # split on comma
            var_name,arg = term.split(',')
            # split on equals sign in arg, take part after
            ref_name = arg.split('=')[1]
            # put var_name and drop_name into proper key in formula_dict
            formula_dict[var_name] = ["Dum",ref_name]
        elif "Poly" in term:
            # remove first four letters (Poly)
            term = term[4:]
            # split on comma
            var_name,arg = term.split(',')
            # split on equals sign in arg, take part after
            degree = arg.split('=')[1]
            # put var_name and drop_name into proper key in formula_dict
            formula_dict[var_name] = ["Poly",degree]
        else:
            raise Exception("Unknown Encoding")
    return formula_dict,inter_list
882693
def params(self):
        
        def fmt_param(el):
            if isinstance(el, str) or isinstance(el, unicode):
                return el
            else:
                return '(%s)' % (', '.join(map(fmt_param, el)))
        try:
            getspec = getattr(inspect, 'getfullargspec', inspect.getargspec)
            s = getspec(self.func)
        except TypeError:
            # I guess this is for C builtin functions?
            return ['...']

        params = []
        for i, param in enumerate(s.args):
            if param.lower() == 'self':
                continue
            if s.defaults is not None and len(s.args) - i <= len(s.defaults):
                defind = len(s.defaults) - (len(s.args) - i)
                default_value = s.defaults[defind]
                value = repr(default_value).strip()
                if value[0] == '<' and value[-1] == '>':
                    if type(default_value) == types.TypeType:
                        value = default_value.__name__
                    elif type(default_value) == types.ObjectType:
                        value = '%s()'%(default_value.__class__.__name__)
                params.append('%s=%s' % (param, value))
            else:
                params.append(fmt_param(param))
        if s.varargs is not None:
            params.append('*%s' % s.varargs)

        # TODO: This needs to be adjusted in Python 3. There's more stuff
        #       returned from getfullargspec than what we're looking at here.
        keywords = getattr(s, 'varkw', getattr(s, 'keywords', None))
        if keywords is not None:
            params.append('**%s' % keywords)
        return params
444905
def get_parameters(self):
        
        d = {}
        for k in ['label', 'verbose_name', 'required', 'hint', 'placeholder', 'choices',
            'default', 'validators', 'max_length']:
            d[k] = getattr(self, k)
        return d
1197322
def as_dict(self):
        
        return {"@module": self.__class__.__module__,
                "@class": self.__class__.__name__,
                "additional_condition": self._additional_condition,
                "max_nabundant": self.max_nabundant,
                "target_environments": self.target_environments,
                "target_penalty_type": self.target_penalty_type,
                "max_csm": self.max_csm}
432756
def params(self):
        
        params = {}
        params["access_token"] = self.access_token
        params["account_id"] = self.account_id
        return params
718746
def __set_formulas(self, formulas):
        
        # Tuple of tuples is required
        array = tuple(tuple(self._clean_formula(col) for col in row) for row in formulas)
        self._get_target().setFormulaArray(array)
1057868
def to_param_dict(self):
        
        param_dict = {}
        for index, dictionary in enumerate(self.value):
            for key, value in dictionary.items():
                param_name = '{param_name}[{index}][{key}]'.format(
                                                    param_name=self.param_name,
                                                    index=index,
                                                    key=key)
                param_dict[param_name] = value
        return OrderedDict(sorted(param_dict.items()))
528753
def params(self):
        """"""
        ret = {}
        for rd in self.decorators:
            args = rd.args
            kwargs = rd.kwargs
            if param in rd:
                is_required =  kwargs.get('required', 'default' not in kwargs)
                ret[args[0]] = {'required': is_required, 'other_names': args[1:], 'options': kwargs}

        return ret
1142558
def getParam(self, name=None):
        
        if 'parameters' in self.keys():
            l = {x['name']: x['value'] for x in self['parameters'].values()}
            if name:
                if name in l.keys():
                    return l[name]
                else:
                    return False
            else:
                return l
20698
def get_import_data_kwargs(self, request, *args, **kwargs):
        
        form = kwargs.get('form')
        if form:
            kwargs.pop('form')
            return kwargs
        return {}
317654
def to_dict(self):
        
        return dict((parameter.name, parameter.value) for parameter in self.values())
215087
def params(self, hidden=True):
        
        param_names = self.class_param_names(hidden=hidden)
        return dict(
            (name, getattr(self, name))
            for name in param_names
        )