numpy.loadtxt loading floats from single line file when ndmin=1

<p><strong>Problem:</strong> I have a text file containing several numbers. I am trying to grab some of them and load them into arrays. I would like arrays, even when only 1 line is present in the file. I have an issue when there is a single line only. The values are loading as floats and are not loaded into arrays.</p><p><strong>Tried:</strong> From the numpy documentation I would expect arrays of length 1 for the single line text file when using ndmin=1. However, I am still getting a series of floats, see below:</p><pre><br /><code>>>> ra_deg,dec_deg,l_deg,b_deg=np.loadtxt(args.infile,ndmin=1,usecols=[0,1,2,3],unpack=True)<br />>>> ra_deg<br />127.55905<br />>>> np.__version__<br />'1.8.1'<br /></code><br /></pre><p><strong>Expected:</strong></p><pre><br /><code>>>> ra_deg<br />array([127.55905])<br /></code><br /></pre><p>Example args.infile input:</p><pre><br /><code>127.55905 +00.00000 224.77661 +21.83227<br /></code><br /></pre><p>I am not sure if this is my error, or there is something up with numpy? Any advice before opening a numpy issue would be great, thanks.</p><br /><h2>Click here view more answers <a href="%20http://stackoverflow.com/questions/34470283/numpy-loadtxt-loading-floats-from-single-line-file-when-ndmin-1">http://ift.tt/1IvhbmA</a></h2>

Nhận xét

Bài đăng phổ biến từ blog này

Align div to bottom of the page in bootstrap

Align elements inside an tag vertically

Javascript is unable to stop page loading