(data)
Infer variable information (type, number of components) from data.
    
    Arguments:
      * data: any value to be uploaded on the GPU.
    
    Returns:
      * varinfo: a dictionary with the information related to the data type.
Infer variable information (type, number of components) from data.
    
    Arguments:
      * data: any value to be uploaded on the GPU.
    
    Returns:
      * varinfo: a dictionary with the information related to the data type.
Infer variable information ( type number of components ) from data . Arguments : * data : any value to be uploaded on the GPU . Returns : * varinfo : a dictionary with the information related to the data type .
def _get_varinfo(data):
    """Infer variable information (type, number of components) from data.
    
    Arguments:
      * data: any value to be uploaded on the GPU.
    
    Returns:
      * varinfo: a dictionary with the information related to the data type.
      
    """
    
    # handle scalars
    if not hasattr(data, '__len__'):
        return dict(vartype=_get_vartype(data), ndim=1, size=None)
    
    # convert lists into array
    if type(data) == list:
        data = np.array(data)
        
    # handle tuples
    if type(data) == tuple:
        return dict(vartype=_get_vartype(data[0]),
            ndim=len(data), size=None)
    
    # handle arrays
    if isinstance(data, np.ndarray):
        vartype = VARINFO_DICT[data.dtype]
        if data.ndim == 1:
            ndim = 1
            size = len(data)
        elif data.ndim == 2:
            ndim = data.shape[1]
            size = data.shape[0]
        return dict(vartype=vartype, ndim=ndim, size=size)
def _get_varinfo ( data ) : # handle scalars if not hasattr ( data , '__len__' ) : return dict ( vartype = _get_vartype ( data ) , ndim = 1 , size = None ) # convert lists into array if type ( data ) == list : data = np . array ( data ) # handle tuples if type ( data ) == tuple : return dict ( vartype = _get_vartype ( data [ 0 ] ) , ndim = len ( data ) , size = None ) # handle arrays if isinstance ( data , np . ndarray ) : vartype = VARINFO_DICT [ data . dtype ] if data . ndim == 1 : ndim = 1 size = len ( data ) elif data . ndim == 2 : ndim = data . shape [ 1 ] size = data . shape [ 0 ] return dict ( vartype = vartype , ndim = ndim , size = size )