numpy.set_string_function

numpy.set_string_function(f, repr=1)

Set a Python function to be used when pretty printing arrays.

Parameters:

f : Python function

Function to be used to pretty print arrays. The function should expect a single array argument and return a string of the representation of the array.

repr : int

Unknown.

Examples

>>> def pprint(arr):
...     return 'HA! - What are you going to do now?'
...
>>> np.set_string_function(pprint)
>>> a = np.arange(10)
>>> a
HA! - What are you going to do now?
>>> print a
[0 1 2 3 4 5 6 7 8 9]

Previous topic

numpy.get_printoptions

Next topic

numpy.binary_repr

This Page

Quick search