1 year ago

#149459

test-img

Alberto MQ

How to read numpy array without truncation

I was surprised I couldn't find this more easily. How do we set the number of digits to truncate to when reading in a numpy array?

import numpy as np

np.set_printoptions(threshold=sys.maxsize)
pose_raw =  [0.8646331429481506, -0.22936344146728516, -0.4469817578792572, 0.0, 0.3616204857826233, 0.9017571806907654, 0.2367781400680542, 0.0, 0.3487676680088043, -0.3663671910762787, 0.8626390695571899, 0.0, -0.534120500087738, -2.0878100395202637, -0.4539491534233093, 1.0]

pose = np.array(pose_raw).reshape((4,4)).T
print("raw ", p["pose"])
print("processed ", pose)

Gives the following

raw [0.8646331429481506, -0.22936344146728516, -0.4469817578792572, 0.0, 0.3616204857826233, 0.9017571806907654, 0.2367781400680542, 0.0, 0.3487676680088043, -0.3663671910762787, 0.8626390695571899, 0.0, -0.534120500087738, -2.0878100395202637, -0.4539491534233093, 1.0] Blockquote

processed [[ 0.86463314 0.36162049 0.34876767 -0.5341205 ] [-0.22936344 0.90175718 -0.36636719 -2.08781004] [-0.44698176 0.23677814 0.86263907 -0.45394915] [ 0. 0. 0. 1. ]]

python

arrays

numpy

truncation

0 Answers

Your Answer

Accepted video resources