dtype.pyx 1.11 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

cimport numpy as np
import numpy as np

import cython as ct

from dtype cimport C_param, C_datatype, getOne, display, change

np.import_array()

cdef class P_datatype(object):

  cdef int id
  cdef C_datatype f_image

  cdef public np.ndarray rtab

  @ct.locals(i=int)
  def __init__(self, i):
    self.id = i
    getOne(i,&self.f_image)
    self.rtab = np.PyArray_SimpleNewFromData(1, [self.f_image.itab[0]], np.NPY_DOUBLE, self.f_image.rtab)

  def cythonChange(self,nn,rv,iv):
    #&self.f_image.nickname[0] = nn
    self.f_image.rsingle  = rv
    self.f_image.isingle  = iv

  def fortranChange(self,nn,rv,iv):
    change(self.id, nn, rv, iv)

  def getWeirdCopy(self,i):
    if i < self.f_image.itab[1]:
      return self.f_image.weird[i]
    else:
      raise IndexError

  def fortranContent(self):
    display(self.id)

  def cythonContent(self):
    cdef int i
    print self.f_image.nickname
    print self.f_image.rsingle
    print self.f_image.isingle
    for i in range(self.f_image.itab[0]):
      print self.f_image.rtab[i]
    print self.rtab
    for i in range(self.f_image.itab[1]):
      print self.f_image.weird[i]