Yield arguments with improper dimensionality.
973155
def _check_argument_units(args, dimensionality):
    """"""
    for arg, val in args.items():
        # Get the needed dimensionality (for printing) as well as cached, parsed version
        # for this argument.
        try:
            need, parsed = dimensionality[arg]
        except KeyError:
            # Argument did not have units specified in decorator
            continue

        # See if the value passed in is appropriate
        try:
            if val.dimensionality != parsed:
                yield arg, val.units, need
        # No dimensionality
        except AttributeError:
            # If this argument is dimensionless, don't worry
            if parsed != '':
                yield arg, 'none', need
605587
def flatten(*args):
    ''''''
    for arg in args:
        if isinstance(arg, collections.Iterable) and not isinstance(arg, (str, bytes)):
            yield from flatten(*arg)
        else:
            yield arg
378789
def argtypes(self):
        
        if self.dimension is not None:
            result = []
            if "in" in self.direction:
                #The only complication here is that the 'known' dimensionality could actually
                #be a function like "size" that needs information about other variables.
                #If we choose to ignore known shapes, we lose the error checking for the passed
                #in variables from the python side.
                if self.direction == "(inout)" and ":" not in self.dimension:
                    wstr = ", writeable"
                else:
                    wstr = ""

                if ":" in self.dimension or "size" in self.dimension:
                    template = 'ndpointer(dtype={}, ndim={}, flags="F{}")'
                    result.append(template.format(self.pytype, self.D, wstr))
                else:
                    template = 'ndpointer(dtype={}, ndim={}, shape=({}), flags="F{}")'
                    sdim = self.dimension + ("" if self.D > 1 else ",")
                    result.append(template.format(self.pytype, self.D, sdim, wstr))
            elif self.direction == "(out)":
                result.append("c_void_p")

            if self.D > 0 and ":" in self.dimension:
                result.extend(["c_int_p" for i in range(self.D)])
            if (self.direction == "(inout)" and ":" in self.dimension and
                ("allocatable" in self.modifiers or "pointer" in self.modifiers)):
                result.append("c_void_p")
            return result
        else:
            ctype = self.ctype
            if ctype is not None:
                return ["{}_p".format(ctype.lower())]
74424
def resolve_broadcast_params(inputs, function_proto, batch_size):
    '''
    '''
    f = function_proto  # alias

    # A. Detect multiple negative dimensions (not allowed).
    negative_count = 0
    for d in f.broadcast_param.shape.dim:
        if d < 0:
            negative_count += 1
    if negative_count > 1:
        raise ValueError('Reshape: shape has multiple negative number.')

    # B. Fill negative dimensions with batch size.
    shape = tuple(
        [d if d >= 0 else batch_size for d in f.broadcast_param.shape.dim])
    return shape
1264995
def yield_string_argument(node, pos):
    

    if not isinstance(node.args.items[pos], asttypes.String):
        return
    yield to_str(node.args.items[pos])
1356660
def convert_args(self, command, args):
		

		for wanted, arg in zip(command.argtypes(), args):
			wanted = wanted.type_
			if(wanted == "const"):
				try:
					yield to_int(arg)
				except:
					if(arg in self.processor.constants):
						yield self.processor.constants[arg]
					else:
						yield arg
			if(wanted == "register"):
				yield self.register_indices[arg]
1118670
def chain(*args):
    """"""
    has_iter = partial(hasattr, name='__iter__')
    # check if a single iterable is being passed for
    # the case that it's a generator of generators
    if len(args) == 1 and hasattr(args[0], '__iter__'):
        args = args[0]

    for arg in args:
        # if the arg is iterable
        if hasattr(arg, '__iter__'):
            # iterate through it
            for i in arg:
                yield i
        # otherwise
        else:
            # yield the whole argument
            yield arg
1337142
def iter_slices(string, slice_length):
    """"""
    pos = 0
    if slice_length is None or slice_length <= 0:
        slice_length = len(string)
    while pos < len(string):
        yield string[pos:pos + slice_length]
        pos += slice_length
601157
def safeArgs(args):
    
    return (arg for arg in args
            if arg is not None and not math.isnan(arg) and not math.isinf(arg))
1176360
def genslices_ndim(ndim, shape):
    """"""
    iterables = [genslices(shape[n]) for n in range(ndim)]
    yield from product(*iterables)
1093086
def _dims2shape(*dims):
    """"""
    if not dims:
        raise ValueError("expected at least one dimension spec")
    shape = list()
    for dim in dims:
        if isinstance(dim, int):
            dim = (0, dim)
        if isinstance(dim, tuple) and len(dim) == 2:
            if dim[0] < 0:
                raise ValueError("expected low dimension to be >= 0")
            if dim[1] < 0:
                raise ValueError("expected high dimension to be >= 0")
            if dim[0] > dim[1]:
                raise ValueError("expected low <= high dimensions")
            start, stop = dim
        else:
            raise TypeError("expected dimension to be int or (int, int)")
        shape.append((start, stop))
    return tuple(shape)
1247671
def _layer_norm_new_params(input_shape, rng, epsilon=1e-6):  # pylint: disable=invalid-name
  """"""
  del rng, epsilon
  features = input_shape[-1]
  scale = np.ones(features)
  bias = np.zeros(features)
  return (scale, bias)
708768
def args_kvp_nodup(s):
    
    if s is None:
        return {}
    d = {}
    for item in [e.strip() for e in s.split(",")]:
        try:
            key, value = item.split("=", 1)
        except ValueError:
            msg = "argument item '{}' not in form key=value".format(item)
            if _argparse_is_dumb:
                _alog.warn(msg)
            raise ValueError(msg)
        if key in d:
            msg = "Duplicate key for '{}' not allowed".format(key)
            if _argparse_is_dumb:
                _alog.warn(msg)
            raise ValueError(msg)
        d[key] = value
    return d
1313269
def _custom_argv(argv):
    """"""
    backup_argv = sys.argv
    sys.argv = backup_argv[:1] + argv
    try:
        yield
    finally:
        sys.argv = backup_argv
760622
def chunks(lista, size):
    """"""
    if not isinstance(lista, list):
        logger.error('Erron in chunks, arg introduced is not a list.', lista=lista)
        return lista

    for i in range(0, len(lista), size):
        yield lista[i:i + size]
319138
def args_as_tuple(self):
        """"""
        if "," in self.arguments["header-names"]:
            result = tuple(tools.to_list(self.arguments["header-names"]))
        else:
            result = (self.arguments["header-names"].strip('"'),)
        result = result + (self.arguments["match-type"],)
        if "," in self.arguments["key-list"]:
            result = result + tuple(
                tools.to_list(self.arguments["key-list"], unquote=False))
        else:
            result = result + (self.arguments["key-list"].strip('"'),)
        return result
1237601
def fix_list_arguments(self):
        """"""
        either = [list(c.children) for c in self.either.children]
        for case in either:
            case = [c for c in case if case.count(c) > 1]
            for a in [e for e in case if type(e) == Argument]:
                a.value = []
        return self