def numpy_str(arr, strvals=False, precision=None, pr=None,
              force_dtype=False,
              with_dtype=None, suppress_small=None, max_line_width=None,
              threshold=None, **kwargs):
    """
    suppress_small = False turns off scientific representation
    """
    # strvals = kwargs.get('strvals', False)
    itemsep = kwargs.get('itemsep', ' ')
    # precision = kwargs.get('precision', None)
    # suppress_small = kwargs.get('supress_small', None)
    # max_line_width = kwargs.get('max_line_width', None)
    # with_dtype = kwargs.get('with_dtype', False)
    newlines = kwargs.pop('nl', kwargs.pop('newlines', 1))
    data = arr

    # if with_dtype and strvals:
    #     raise ValueError('cannot format with strvals and dtype')

    separator = ',' + itemsep

    if strvals:
        prefix = ''
        suffix = ''
    else:
        modname = type(data).__module__
        # substitute shorthand for numpy module names
        np_nice = 'np'
        modname = re.sub('\\bnumpy\\b', np_nice, modname)
        modname = re.sub('\\bma.core\\b', 'ma', modname)

        class_name = type(data).__name__
        if class_name == 'ndarray':
            class_name = 'array'

        prefix = modname + '.' + class_name + '('

        if with_dtype:
            dtype_repr = data.dtype.name
            # dtype_repr = np.core.arrayprint.dtype_short_repr(data.dtype)
            suffix = ',{}dtype={}.{})'.format(itemsep, np_nice, dtype_repr)
        else:
            suffix = ')'

    if not strvals and data.size == 0 and data.shape != (0,):
        # Special case for displaying empty data
        prefix = modname + '.empty('
        body = repr(tuple(map(int, data.shape)))
    else:
        body = np.array2string(data, precision=precision,
                               separator=separator,
                               suppress_small=suppress_small,
                               prefix=prefix,
                               max_line_width=max_line_width)
    if not newlines:
        # remove newlines if we need to
        body = re.sub('\n *', '', body)
    formatted = prefix + body + suffix
    return formatted
def numpy_str ( arr , strvals = False , precision = None , pr = None , force_dtype = False , with_dtype = None , suppress_small = None , max_line_width = None , threshold = None , ** kwargs ) : itemsep = kwargs . get ( 'itemsep' , ' ' ) newlines = kwargs . pop ( 'nl' , kwargs . pop ( 'newlines' , 1 ) ) data = arr separator = ',' + itemsep if strvals : prefix = '' suffix = '' else : modname = type ( data ) . __module__ np_nice = 'np' modname = re . sub ( '\\bnumpy\\b' , np_nice , modname ) modname = re . sub ( '\\bma.core\\b' , 'ma' , modname ) class_name = type ( data ) . __name__ if class_name == 'ndarray' : class_name = 'array' prefix = modname + '.' + class_name + '(' if with_dtype : dtype_repr = data . dtype . name suffix = ',{}dtype={}.{})' . format ( itemsep , np_nice , dtype_repr ) else : suffix = ')' if not strvals and data . size == 0 and data . shape != ( 0 , ) : prefix = modname + '.empty(' body = repr ( tuple ( map ( int , data . shape ) ) ) else : body = np . array2string ( data , precision = precision , separator = separator , suppress_small = suppress_small , prefix = prefix , max_line_width = max_line_width ) if not newlines : body = re . sub ( '\n *' , '' , body ) formatted = prefix + body + suffix return formatted
suppress_small = False turns off scientific representation