Parses `priorstring` and returns `prior` tuple.
342386
def diffPrefsPrior(priorstring):
    """"""
    assert isinstance(priorstring, str)
    prior = priorstring.split(',')
    if len(prior) == 3 and prior[0] == 'invquadratic':
        [c1, c2] = [float(x) for x in prior[1 : ]]
        assert c1 > 0 and c2 > 0, "C1 and C2 must be > 1 for invquadratic prior"
        return ('invquadratic', c1, c2)
    else:
        raise ValueError("Invalid diffprefsprior: {0}".format(priorstring))
1249585
def __parse(self, string=''):
        '''
        
        '''
        self.string = string
        self.string = self.wiki_re.sub('', self.string)
        # search for lists
        self.listmatch = re.search('^(\*+)', self.string)
        if self.listmatch:
            self.string = self.__list(self.listmatch) + re.sub('^(\*+)', \
                          '', self.string)
        return self.string
1022640
def get_priors(self):
		'''
		
		'''
		priors = self.priors
		priors[~np.isfinite(priors)] = 0
		priors += self.starting_count
		return priors
252353
def _parse_vertex_tuple(s):
  """"""
  vt = [0, 0, 0]
  for i, c in enumerate(s.split('/')):
    if c:
      vt[i] = int(c)
  return tuple(vt)
875462
def gaussian_tuple_prior_for_arguments(self, arguments):
        
        tuple_prior = TuplePrior()
        for prior_tuple in self.prior_tuples:
            setattr(tuple_prior, prior_tuple.name, arguments[prior_tuple.prior])
        return tuple_prior
514389
def parse(key_string: str) -> 'Key':
        
        parts = key_string.split(Key.PARTITION)
        key_type = KeyType.DIMENSION
        if parts[3]:
            key_type = KeyType.TIMESTAMP
        return Key(key_type, parts[0], parts[1], parts[2].split(Key.DIMENSION_PARTITION)
                   if parts[2] else [],
                   parser.parse(parts[3]) if parts[3] else None)
218340
def parse(cls, version_string):
        
        match = RE.match(version_string)
        if match:
            major_str, minor_str, patch_str, postrelease_alpha, \
                postrelease_digit, prerelease_str, build_metadata = \
                match.groups()

            if postrelease_digit:
                postrelease = int(postrelease_digit)
            else:
                postrelease = postrelease_alpha

            # A well-defined version cannot both have a pre- and a
            # post-release identifier.
            if postrelease and prerelease_str:
                raise InvalidVersionExpression(version_string)

            major = int(major_str)

            if minor_str:
                minor = int(minor_str)
            else:
                minor = 0

            if patch_str:
                patch = int(patch_str)
            else:
                patch = 0

            if prerelease_str:
                try:
                    prerelease = int(prerelease_str)
                except ValueError:
                    prerelease = prerelease_str
            else:
                prerelease = None

            return cls(major, minor, patch,
                       postrelease, prerelease, build_metadata)

        else:
            raise InvalidVersionExpression(version_string)
866801
def _prepare_prior(self, prior, _type):
        '''
        
        '''

        if prior is None and not self.auto_scale:
            prior = self.default_priors.get(term=_type + '_flat')

        if isinstance(prior, Prior):
            prior._auto_scale = False
        else:
            _scale = prior
            prior = self.default_priors.get(term=_type)
            prior.scale = _scale
            if prior.scale is not None:
                prior._auto_scale = False
        return prior
1063424
def _ParseDocstring(function):
  """"""
  if not function.__doc__:
    return {}

  type_check_dict = {}
  for match in param_regexp.finditer(function.__doc__):
    param_str = match.group(1).strip()
    param_splitted = param_str.split(" ")
    if len(param_splitted) >= 2:
      type_str = " ".join(param_splitted[:-1])
      name = param_splitted[-1]
      type_check_dict[name] = type_str

  for match in returns_regexp.finditer(function.__doc__):
    type_check_dict["returns"] = match.group(1)

  for match in type_regexp.finditer(function.__doc__):
    name = match.group(1)
    type_str = match.group(2)
    type_check_dict[name] = type_str
  for match in rtype_regexp.finditer(function.__doc__):
    type_check_dict["returns"] = match.group(1)
  return type_check_dict
145355
def parse(s):
        
        start = s.find('(')
        if start == -1:
            raise ValueError("Tuple should start with '('")
        end = s.find(')')
        if end == -1:
            raise ValueError("Tuple should end with ')'")
        s = s[start + 1: end].strip()

        size = s[: s.find(',')]
        try:
            size = int(size)
        except ValueError:
            raise ValueError("Cannot parse size %s." % size)

        ind_start = s.find('[')
        if ind_start == -1:
            raise ValueError("Indices array should start with '['.")
        ind_end = s.find(']')
        if ind_end == -1:
            raise ValueError("Indices array should end with ']'")
        new_s = s[ind_start + 1: ind_end]
        ind_list = new_s.split(',')
        try:
            indices = [int(ind) for ind in ind_list if ind]
        except ValueError:
            raise ValueError("Unable to parse indices from %s." % new_s)
        s = s[ind_end + 1:].strip()

        val_start = s.find('[')
        if val_start == -1:
            raise ValueError("Values array should start with '['.")
        val_end = s.find(']')
        if val_end == -1:
            raise ValueError("Values array should end with ']'.")
        val_list = s[val_start + 1: val_end].split(',')
        try:
            values = [float(val) for val in val_list if val]
        except ValueError:
            raise ValueError("Unable to parse values from %s." % s)
        return SparseVector(size, indices, values)
96255
def prior_to_xarray(self):
        """"""
        prior = self.prior
        # filter posterior_predictive and log_likelihood
        prior_predictive = self.prior_predictive
        if prior_predictive is None:
            prior_predictive = []
        elif isinstance(prior_predictive, str):
            prior_predictive = [prior_predictive]

        ignore = prior_predictive + ["lp__"]

        data = get_draws(prior, ignore=ignore)
        return dict_to_dataset(data, library=self.pystan, coords=self.coords, dims=self.dims)
150906
def info(self):
        
        info = []

        for prior_model_name, prior_model in self.prior_model_tuples:
            info.append(prior_model.name + '\n')
            info.extend([f"{prior_model_name}_{item}" for item in prior_model.info])

        return '\n'.join(info)
43206
def parse_string(contents, name='tmp.cpp', **kwargs):
    
    idx = clang.cindex.Index.create()
    tu = idx.parse(name, unsaved_files=[(name, contents)], **kwargs)
    return _ensure_parse_valid(tu)
420313
def _parse_default(self, target):
        """"""
        if not isinstance(target, (list, tuple)):
            k, v, t = target, None, lambda x: x
        elif len(target) == 1:
            k, v, t = target[0], None, lambda x: x
        elif len(target) == 2:
            k, v, t = target[0], target[1], lambda x: x
        elif len(target) > 2:
            k, v, t = target[0], target[1], target[2]
        else:
            k = None  # should raise
        if not isinstance(k, string_types):
            msg = "{} is not a valid target, (name, default) expected.".format(target)
            raise ValueError(msg)
        return k, v, t
953267
def get_tuple_type_str_parts(s: str) -> Optional[Tuple[str, Optional[str]]]:
    
    match = TUPLE_TYPE_STR_RE.match(s)

    if match is not None:
        tuple_prefix = match.group(1)
        tuple_dims = match.group(2)

        return tuple_prefix, tuple_dims

    return None
23428
def parseParams(string):
    
    all = params_re.findall(string)
    allParameters = []
    for tup in all:
        paramList = [tup[0]]  # tup looks like (name, valuesString)
        for pair in param_values_re.findall(tup[1]):
            # pair looks like ('', value) or (value, '')
            if pair[0] != '':
                paramList.append(pair[0])
            else:
                paramList.append(pair[1])
        allParameters.append(paramList)
    return allParameters
1139741
def prior_to_xarray(self):
        """"""
        return dict_to_dataset(
            {k: np.expand_dims(v, 0) for k, v in self.prior.items()},
            library=self.pymc3,
            coords=self.coords,
            dims=self.dims,
        )