0

Iam trying to get a FULL string representation of an 2D float32 512x512 array. I can either use numpys string2array(array) or repr(array). But the problem is that I always get a shortened output like that:

 '...[2.0886018e-04 1.7029114e-04 2.8904244e-05 ... 4.1985390e-06
  1.4982919e-06 4.7537060e-06]]'

Is there a possibility of full representation?

Varlor
  • 1,421
  • 3
  • 22
  • 46
  • 1
    Does this help: https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.printoptions.html – Gus Long Mar 01 '19 at 12:51
  • I will test it but I think the problem is more that elements are missed out – Varlor Mar 01 '19 at 12:55
  • 1
    There's another question on SO which might help, looks similar: https://stackoverflow.com/questions/1987694/how-to-print-the-full-numpy-array-without-truncation – Gus Long Mar 01 '19 at 12:59
  • Found it, array2string has a threshold option which can be set to np.inf just like in the printoptions! Thank you! :) – Varlor Mar 01 '19 at 13:12
  • Possible duplicate of [How to print the full NumPy array, without truncation?](https://stackoverflow.com/questions/1987694/how-to-print-the-full-numpy-array-without-truncation) – fountainhead Mar 01 '19 at 13:17
  • @Varlor, I tried out the threshold options of `numpy.array2string()`, by setting it to None, as documented, but it did not work when I tried it out in Jupyter notebook. But the same threshold option works if you set it its value to `np.nan`. Also, have a look at other alternatives at the duplicate reference that I've mentioned. The `numpy.set_printoptions()` mentioned there, works too,. – fountainhead Mar 01 '19 at 13:24
  • why not use np.inf? – Varlor Mar 01 '19 at 13:31
  • What are you going do with that full string display? – hpaulj Mar 01 '19 at 13:37
  • some unconventional stuff, writing it to csv and unwrapping it when reading the csv but its way too slow how I recognized now with the full representation so the only other idea is to save it with np.save and load it to panda dataframe column after it. Can not write it to panda dataframe directly because the dataframe is written to a csv file and read after a long process. In this writing csv process the array is ofcourse automatically converted to string. – Varlor Mar 01 '19 at 13:41
  • Getting an array back from a string representation is not fun. The [] get in the way. of simple splits. – hpaulj Mar 01 '19 at 15:33

1 Answers1

0

The answer is that numpy array2string has a threshold option which can be set to np.inf. Then a full representation is possible! :)

Varlor
  • 1,421
  • 3
  • 22
  • 46