Menu

#2 Bug fix : NC_CHAR array handling under numpy

open-fixed
nobody
None
5
2007-03-08
2007-03-08
No

Tony Hill kindly reported a bug in the handling of NC_CHAR arrays under numpy. This patch fixes this. The following code now works as expected :

from pycdf import pycdf
output = CDF('file.nc',NC.WRITE|NC.CREATE|NC.TRUNC)
output.automode()
tdim = output.def_dim('testdim1',4)
tvar = output.def_var('testvar1',NC.CHAR,[tdim])
tvar.put('Test')
v = ''.join(tvar[:].tolist())
assert v == 'Test'
tvar[:] = '1234'
v = ''.join(tvar[:].tolist())
assert v == '1234'

To apply the patch, get the pycdf-0.6-3b.tar.gz distribution and the pycdf-0.6-3c.patch file, then execute :

tar xfz pycdf-0.6-3b.tar.gz
cd pycdf-0.6-3b
patch -p1 < ../pycdf-0.6-3c.patch

Enjoy!

Discussion

  • Andre Gosselin

    Andre Gosselin - 2007-03-08

    patch file to correct bad handling of NC_CHAR arrays under numpy

     
  • Andre Gosselin

    Andre Gosselin - 2007-03-08
    • status: open --> open-fixed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.