Als ik een numpy array print, krijg ik een afgeknotte representatie, maar ik wil de volledige array.
Is er een manier om dit te doen?
Voorbeelden:
>>> numpy.arange(10000)
array([ 0, 1, 2, ..., 9997, 9998, 9999])
>>> numpy.arange(10000).reshape(250,40)
array([[ 0, 1, 2, ..., 37, 38, 39],
[ 40, 41, 42, ..., 77, 78, 79],
[ 80, 81, 82, ..., 117, 118, 119],
...,
[9880, 9881, 9882, ..., 9917, 9918, 9919],
[9920, 9921, 9922, ..., 9957, 9958, 9959],
[9960, 9961, 9962, ..., 9997, 9998, 9999]])
Gebruik numpy.set_printoptions
:
import sys
import numpy
numpy.set_printoptions(threshold=sys.maxsize)
Dit klinkt alsof je numpy gebruikt.
Als dat het geval is, kun je toevoegen:
import numpy as np
np.set_printoptions(threshold=np.nan)
Dat zal het afdrukken van de hoeken uitschakelen. Voor meer informatie, zie deze NumPy Tutorial.
Hier is een eenmalige manier om dit te doen, die handig is als u uw standaardinstellingen niet wilt wijzigen:
def fullprint(*args, **kwargs):
from pprint import pprint
import numpy
opt = numpy.get_printoptions()
numpy.set_printoptions(threshold='nan')
pprint(*args, **kwargs)
numpy.set_printoptions(**opt)