Search Results

Search found 2 results on 1 pages for 'mishaf'.

Page 1/1 | 1 

  • How detect length of a numpy array with only one element?

    - by mishaF
    I am reading in a file using numpy.genfromtxt which brings in columns of both strings and numeric values. One thing I need to do is detect the length of the input. This is all fine provided there are more than one value read into each array. But...if there is only one element in the resulting array, the logic fails. I can recreate an example here: import numpy as np a = np.array(2.3) len(a) returns an error saying: TypeError: len() of unsized object however, If a has 2 or more elements, len() behaves as one would expect. import numpy as np a = np.array([2.3,3.6]) len(a) returns 2 My concern here is, if I use some strange exception handling, I can't distinguish between a being empty and a having length = 1.

    Read the article

  • How can I left-justify numerical output in fortran?

    - by mishaF
    I am writing some simple output in fortran, but I want whitespace delimiters. If use the following statement, however: format(A20,ES18.8,A12,ES18.8) I get output like this: p001t0000 3.49141273E+01obsgp_oden 1.00000000E+00 I would prefer this: p001t0000 3.49141273E+01 obsgp_oden 1.00000000E+00 I tried using negative values for width (like in Python) but no dice. So, is there a way to left-justify the numbers? Many thanks in advance!

    Read the article

1