Closed GoogleCodeExporter closed 8 years ago
It works if data is an object array (dtype ='O' instead of '|S6')
The error message is not very informative, I'll give you that. I'll look into
that.
Original comment by whitaker.jeffrey@gmail.com
on 11 Apr 2012 at 1:48
Fixed the error message in svn: it now reads
'only numpy object arrays can be assigned to VLEN var slices'
Original comment by whitaker.jeffrey@gmail.com
on 11 Apr 2012 at 12:08
Ah -- Thank you so much for the help.
Nathan
Original comment by space.8...@gmail.com
on 11 Apr 2012 at 2:49
Actually, that doesn't seem to work either.
test = array([V09B01, V09B01, V09B01, V09B01, V09B01, V09B01, V09B01, V09B01,
V09B01, V09B01, V09B01, V09B01, V09B01, V09B01, V09B01, V09B01,
V09B01, V09B01], dtype=object)
cast_names[:] = test[0]
IndexError Traceback (most recent call last)
C:\netcdf_sandbox\<ipython-input-53-d7c2b6ded82a> in <module>()
----> 1 cast_names[:] = test[0]
C:\Python26\lib\site-packages\netCDF4.pyd in netCDF4.Variable.__setitem__ (netCD
F4.c:28519)()
C:\Python26\lib\site-packages\netCDF4.pyd in netCDF4.Variable._assign_vlen (netC
DF4.c:28038)()
IndexError: single element VLEN slices must be specified by integers only
Original comment by space.8...@gmail.com
on 11 Apr 2012 at 10:27
please update from svn and try again.
Original comment by whitaker.jeffrey@gmail.com
on 11 Apr 2012 at 10:59
You're right
cast_names[:] = test[0]
doesn't work, even with SVN. The problem is that test[0] is not a numpy object
array, but a python string.
cast_names[0] = test[0] does work though, or even
cast_names[:] = test[0:1]
If you want to assign to a slice, you need a slice on the rhs. If you assign
with a string on the rhs, you need a single element on the lhs.
This is particular to VLEN arrays, for technical reasons. Assigning to
primitive data type variables is much more flexible.
Original comment by whitaker.jeffrey@gmail.com
on 12 Apr 2012 at 1:01
Right. Got it. Thanks again for the help.
Original comment by space.8...@gmail.com
on 12 Apr 2012 at 3:28
Original comment by whitaker.jeffrey@gmail.com
on 26 Feb 2014 at 2:04
Original issue reported on code.google.com by
space.8...@gmail.com
on 10 Apr 2012 at 10:57