0

I am solving a set of Coupled ODEs and facing two problems: speed and memory storage. As such I use cython_gsl to create a module which solves my ODEs. Until now I had simply written the data to a .txt file but I think it will be more useful to use PyTables.

As such I define in my .pyx file something like

from cython_gsl cimport *
from tables import *

def main (parameters for run ):

class vector(IsDescription):
    name= StringCol(16)                     # 16-character String
    i  = Int32Col()                 # 32-bit integer
    j  = Int32Col()             # 32-bit integer
    k  = Int32Col()             # 32-bit integer

h5file = tables.openFile("tutorial1.h5", mode = "r", title = "Test file")
group = h5file.createGroup("/", 'spin_vectors',"Spin vectors of the crust and core")
table = h5file.createTable(group, 'shellvector', vector, "  ")


... Setup the ODEs ...

while (t < t1):
    status = gsl_odeiv_evolve_apply (e, c, s, &sys, &t, t1, &h, y)

    if (status != GSL_SUCCESS):
        break

    #write_file.write("%.16e %.16e %.16e %.16e %.16e %.16e %.16e\n" %(t, y[0], y[1],y[2],y[3], y[4],y[5]) ) 
        shell_table.row['i']=y[0]
        shell_table.row['j']=y[1]
        shell_table.row['k']=y[2]
            shell_table.row.append()

shell_table.flush()

I then compile it using a setup.py file which outputs (successfully) a .so file. Unfortunately upon importing this into Ipython I get the error

NameError: Int32

Which I believe is a PyTables thing. So it seems it is not being imported correctly? While I think this a good way to do this if anyone has better suggestions on how to handle data from python/cython I would be very happy to hear..Google has almost nothing!

Greg
  • 11,654
  • 3
  • 44
  • 50

1 Answers1

1

unfortunately there is not enough information here to be able to answer your question. What you are trying to do should work. However, I don't think this error is coming from PyTables (which doesn't have any lone "Int32" classes, though it does have an "Int32Atom" and an "Int32Col"). I suspect instead that this is from CythonGSL. Is there any way that you could please post the full traceback -- rather than just the last error -- so that we can know for sure?

Anthony Scopatz
  • 3,265
  • 2
  • 15
  • 14