anjaroesel / netcdf4-python

Automatically exported from code.google.com/p/netcdf4-python
Other
0 stars 0 forks source link

time2index assumes time variable of length > 1 #215

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a time variable of length 1
2. call time2index with the time variable and any timestamp
3.

What is the expected output? What do you see instead?

- Expected: result of 0 as the index

- Instead an error occurs:

  File "/usr/lib/python2.7/dist-packages/netcdftime.py", line 1104, in time2index
    t0, t1 = nctime[:2]
ValueError: need more than 1 value to unpack

What version of the product are you using? On what operating system?

Netcdf4 1.0.4 , Linux Mint 14

Please provide any additional information below.

It seems the time2index function assumes the time variable is of length 2 or 
more. Although a bit of a corner case, it would be nice if it would handle a 
single time index value properly

Original issue reported on code.google.com by niels.dr...@gmail.com on 11 Feb 2014 at 8:50

GoogleCodeExporter commented 8 years ago
Would you mind creating a self contained script that triggers this error? 

Original comment by whitaker.jeffrey@gmail.com on 11 Feb 2014 at 8:52

GoogleCodeExporter commented 8 years ago
No problem. I extracted a small test script from my code that triggers the 
error.

Note that it also shows it _does_ work if the time variable is of length 2.

Let me know if you need any more input.

Original comment by niels.dr...@gmail.com on 12 Feb 2014 at 10:41

Attachments:

GoogleCodeExporter commented 8 years ago
OK, thanks.  Now fixed in svn (r1353).

Original comment by whitaker.jeffrey@gmail.com on 12 Feb 2014 at 1:06

GoogleCodeExporter commented 8 years ago
Thank you for the quick response and fix!

Original comment by niels.dr...@gmail.com on 12 Feb 2014 at 1:50

GoogleCodeExporter commented 8 years ago

Original comment by whitaker.jeffrey@gmail.com on 26 Feb 2014 at 2:04