Turn a set of keyword arguments into a transformation matrix.
769779
def kwargs_to_matrix(**kwargs):
    
    matrix = np.eye(4)
    if 'matrix' in kwargs:
        # a matrix takes precedence over other options
        matrix = kwargs['matrix']
    elif 'quaternion' in kwargs:
        matrix = transformations.quaternion_matrix(kwargs['quaternion'])
    elif ('axis' in kwargs) and ('angle' in kwargs):
        matrix = transformations.rotation_matrix(kwargs['angle'],
                                                 kwargs['axis'])
    else:
        raise ValueError('Couldn\'t update transform!')

    if 'translation' in kwargs:
        # translation can be used in conjunction with any of the methods of
        # specifying transforms. In the case a matrix and translation are passed,
        # we add the translations together rather than picking one.
        matrix[0:3, 3] += kwargs['translation']
    return matrix
905914
def convert_tokens_into_matrix(self, token_list):
        '''
        
        '''
        return np.array(self.vectorize(token_list)).astype(np.float32)
1144701
def prepare_arguments(self, attributes):
        """"""
        kwargs = dict(attributes)
        # 1. Extension points
        kwargs = self.factory._adjust_kwargs(**kwargs)

        # 2. Remove hidden objects
        kwargs = {
            k: v for k, v in kwargs.items()
            if k not in self.exclude and k not in self.parameters and v is not declarations.SKIP
        }

        # 3. Rename fields
        for old_name, new_name in self.rename.items():
            if old_name in kwargs:
                kwargs[new_name] = kwargs.pop(old_name)

        # 4. Extract inline args
        args = tuple(
            kwargs.pop(arg_name)
            for arg_name in self.inline_args
        )

        return args, kwargs
743606
def fit_transform(self, input, **fit_kwargs):
        """"""
        self.fit(input, **fit_kwargs)
        X = self.transform(input)
        return X
386997
def argmin(input_, key=None):
    
    # if isinstance(input_, dict):
    #     return list(input_.keys())[argmin(list(input_.values()))]
    # elif hasattr(input_, 'index'):
    #     return input_.index(min(input_))
    # else:
    #     return min(enumerate(input_), key=operator.itemgetter(1))[0]
    if isinstance(input, dict):
        return list(input.keys())[argmin(list(input.values()), key=key)]
    else:
        if key is None:
            def _key(item):
                return item[1]
        else:
            def _key(item):
                return key(item[1])
        return min(enumerate(input), key=_key)[0]
176925
def make_mapping(args):
    """"""
    mapping = {}

    if args:
        for arg in args:
            name_value = arg.split('=', 1)
            mapping[name_value[0]] = (name_value[1]
                                      if len(name_value) > 1
                                      else None)

    return mapping
54540
def _transform_data(self, X):
        """"""

        if self._binarizers == []:
            raise NotFittedError()

        if self.binarize is not None:
            X = binarize(X, threshold=self.binarize)

        if len(self._binarizers) != X.shape[1]:
            raise ValueError(
                "Expected input with %d features, got %d instead" %
                (len(self._binarizers), X.shape[1]))

        X_parts = []

        for i in range(X.shape[1]):

            X_i = self._binarizers[i].transform(X[:, i])

            # sklearn returns ndarray with shape (samples, 1) on binary input.
            if self._binarizers[i].classes_.shape[0] == 2:
                X_parts.append(1 - X_i)

            X_parts.append(X_i)

        return np.concatenate(X_parts, axis=1)
232592
def _replace_scalars_in_kwargs(self, kwargs):
        
        _check_type('kwargs', kwargs, dict)

        new_kwargs = {}
        for (name, value) in iteritems(kwargs):
            if isinstance(value, list):
                new_kwargs[name] = self._replace_scalars_in_args(value)
            elif isinstance(value, dict):
                new_kwargs[name] = self._replace_scalars_in_kwargs(value)
            elif isinstance(value, string_types):
                new_kwargs[name] = self._replace_scalar(value)
            else:
                new_kwargs[name] = value
        return new_kwargs
973820
def transform_frame(frame, transform, columns=None, direction='forward',
                    return_all=True, args=(), **kwargs):
    
    tfun, tname = parse_transform(transform, direction)
    columns = to_list(columns)
    if columns is None:
        columns = frame.columns
    if return_all:
        transformed = frame.copy()
        for c in columns:
            transformed[c] = tfun(frame[c], *args, **kwargs)
    else:
        transformed = frame.filter(columns).apply(tfun, *args, **kwargs)
    return transformed
512579
def translate(self):
        """"""
        varnames = set()
        ident = self.ident
        funcnames = set([ident])

        arg_exprs = []
        for arg in self.args:
            subexprs, subvars, subfuncs = arg.translate()
            varnames.update(subvars)
            funcnames.update(subfuncs)

            # Create a subexpression that joins the result components of
            # the arguments.
            arg_exprs.append(ex_call(
                ast.Attribute(ex_literal(u''), 'join', ast.Load()),
                [ex_call(
                    'map',
                    [
                        ex_rvalue(str.__name__),
                        ast.List(subexprs, ast.Load()),
                    ]
                )],
            ))

        subexpr_call = ex_call(
            FUNCTION_PREFIX + ident,
            arg_exprs
        )
        return [subexpr_call], varnames, funcnames
48036
def normalize_listargument(arg):
    """"""
    if isinstance(arg, np.ndarray):
        return arg.flatten()
    if isinstance(arg, str):
        return [arg]
    if isinstance(arg, list) or isinstance(arg, tuple) or isinstance(arg, dict) or isinstance(arg, set):
        return list(arg)
    return [arg]
192264
def transform(transform_func):
    """"""
    def decorator(func):
        @wraps(func)
        def f(*args, **kwargs):
            return transform_func(
                func(*args, **kwargs)
            )
        return f
    return decorator
1254357
def convert_argmax(node, **kwargs):
    
    name, input_nodes, attrs = get_inputs(node, kwargs)

    axis = int(attrs.get("axis"))
    keepdims = get_boolean_attribute_value(attrs, "keepdims")

    node = onnx.helper.make_node(
        'ArgMax',
        inputs=input_nodes,
        axis=axis,
        keepdims=keepdims,
        outputs=[name],
        name=name
    )
    return [node]
943532
def transform_array(rot_mtx,vec_array):

    '''

    '''

    return map( lambda x,m=rot_mtx:transform(m,x), vec_array )
1227479
def to_python(self):
        """"""
        mapping = {}
        for row in self.rows:
            mapping[row[0]] = _format_python_value(row[1])
        return mapping
1108669
def _transform_in(self):
        """"""
        return np.array([
            [self.left, self.bottom, 0, 1],
            [self.right, self.top, 0, 1]])
599402
def process_kwargs(obj, kwargs):
    '''
    
    '''
    with Modules() as m:
        kwargs = m.kwargs(obj, kwargs)
    return kwargs