Ensure `x` is of list type.
496068
def as_list(x):
    ''''''
    
    if x is None:
        x = []
    elif not isinstance(x, Sequence):
        x = [x]
    return list(x)
1302048
def set_data_matrix(self, X):
        
        X = check_array(X, accept_sparse=sparse_formats)
        self.X = X
944979
def _valid_numpy_subdtype(x, numpy_types):
    
    # If any of the types given in numpy_types is understood as numpy.generic,
    # all possible x will be considered valid.  This is probably unwanted.
    for t in numpy_types:
        assert not np.issubdtype(np.generic, t)

    return any(np.issubdtype(x.dtype, t) for t in numpy_types)
965673
def _maybe_repeat(self, x):
    
    if isinstance(x, list):
      assert len(x) == self.n
      return x
    else:
      return [x] * self.n
406217
def maybe_cast_list(value, types):
    
    if not isinstance(value, list):
        return value

    if type(types) not in (list, tuple):
        types = (types,)

    for list_type in types:
        if issubclass(list_type, list):
            try:
                return list_type(value)
            except (TypeError, ValueError):
                pass
    return value
803732
def _optional_list(value):
    ''''''
    if isinstance(value, str):
        return (value, )
    elif isinstance(value, list):
        return tuple(value)

    return None
865880
function isInList(value, listOfValues, msg) {
    value = value.toLowerCase().trim();
    if (listOfValues.indexOf(value) === -1) {
        throw new Error(msg);
    }
}
927726
def _check_typecode_list(ofwhat, tcname):
    ''''''
    for o in ofwhat:
        if callable(o): #skip if _Mirage
            continue
        if not isinstance(o, TypeCode):
            raise TypeError(
                tcname + ' ofwhat outside the TypeCode hierarchy, ' +
                str(o.__class__))
        if o.pname is None and not isinstance(o, AnyElement):
            raise TypeError(tcname + ' element ' + str(o) + ' has no name')
1066114
def flatten_list(x: List[Any]) -> List[Any]:
      # noqa
    return [item for sublist in x for item in sublist]
1128619
def list_data_type(type_list):
    """"""
    data_type = []
    for item in type_list:
        match = re.match(r"(\d+)(.+)", item)
        if not match:
            reps = 1
            if item[0] in "FfEegG":
                data_type.append("REAL")
            elif item[0] in "Ii":
                data_type.append("INTEGER")
        else:
            reps = match.group(1)
            fmt = match.group(2)
            if "(" in fmt and "," in fmt:
                fmt = fmt[1:-1].split(",")
            elif "(" in fmt:
                fmt = [fmt[1:-1]]
            else:
                fmt = [fmt]
            for i in range(int(reps)):
                for ft in fmt:
                    if ft[0] in "FfEegG":
                        data_type.append("REAL")
                    elif ft[0] in "Ii":
                        data_type.append("INTEGER")
    return data_type
1140897
def _sanitize_value(x):
    
    if isinstance(x, _six.string_types + _six.integer_types + (float,)):
        return x
    elif _HAS_SKLEARN and _sp.issparse(x):
        return x.todense()
    elif isinstance(x, _np.ndarray):
        return x
    elif isinstance(x, tuple):
        return (_sanitize_value(v) for v in x)
    elif isinstance(x, list):
        return [_sanitize_value(v) for v in x]
    elif isinstance(x, dict):
        return dict( (_sanitize_value(k), _sanitize_value(v)) for k, v in x.items())
    else:
        assert False, str(x)
1085802
def _check_array(self, X, **kwargs):
        
        if isinstance(X, np.ndarray):
            X = da.from_array(X, X.shape)
        X = check_array(X, **kwargs)
        return X
776389
def normalizeX(value):
    
    if not isinstance(value, (int, float)):
        raise TypeError("X coordinates must be instances of "
                        ":ref:`type-int-float`, not %s."
                        % type(value).__name__)
    return value
238745
def _check_L(self, L):
        """"""
        # TODO: Take this out?
        if issparse(L):
            L = L.todense()

        # Check for correct values, e.g. warning if in {-1,0,1}
        if np.any(L < 0):
            raise ValueError("L must have values in {0,1,...,k}.")
1102118
def _safe_match_list(inner_type, argument_value):
    """"""
    stripped_type = strip_non_null_from_type(inner_type)
    if isinstance(stripped_type, GraphQLList):
        raise GraphQLInvalidArgumentError(u'MATCH does not currently support nested lists, '
                                          u'but inner type was {}: '
                                          u'{}'.format(inner_type, argument_value))

    if not isinstance(argument_value, list):
        raise GraphQLInvalidArgumentError(u'Attempting to represent a non-list as a list: '
                                          u'{}'.format(argument_value))

    components = (
        _safe_match_argument(stripped_type, x)
        for x in argument_value
    )
    return u'[' + u','.join(components) + u']'
1208261
def _AssertDataIsList(key, lst):
  """"""

  # list and tuple are supported.  Not supported are direct strings
  # and dictionary; these indicate too much or two little structure.
  if not isinstance(lst, list) and not isinstance(lst, tuple):
    raise NotAListError('%s must be a list' % key)

  # each list entry must be a string
  for element in lst:
    if not isinstance(element, str):
      raise ElementNotAStringError('Unsupported list element %s found in %s',
                                   (element, lst))
844344
def _assert_is_type(name, value, value_type):
    """"""
    if not isinstance(value, value_type):
        if type(value_type) is tuple:
            types = ', '.join(t.__name__ for t in value_type)
            raise ValueError('{0} must be one of ({1})'.format(name, types))
        else:
            raise ValueError('{0} must be {1}'
                             .format(name, value_type.__name__))