This is an archival dump of old wiki content --- see scipy.org for current material

Attachment 'typed_array_converter.py'

Download

   1 """ Modified version of array_converter that adds a type definition macro
   2    for each array.
   3 """
   4 
   5 from scipy.weave.standard_array_spec import array_converter
   6 from scipy.weave import c_spec
   7 
   8 ##############################################################################
   9 # Weave modifications
  10 ##############################################################################
  11 
  12 class typed_array_converter(array_converter):
  13     """ Minor change to the original array type converter that adds a macro
  14         for the array's data type.
  15     """
  16     
  17     def declaration_code(self, templatize = 0,inline=0):
  18         code = array_converter.declaration_code(self, templatize, 
  19                                                 inline)
  20         res = self.template_vars(inline=inline)
  21         # need to add a macro that defines the array's data type
  22         code += '#define %(name)s_data_type %(num_type)s\n' % res
  23         
  24         return code
  25 
  26 # Create a list of type converters that includes this array converter instead
  27 # of the standard one.
  28 converters = [c_spec.int_converter(),
  29               c_spec.float_converter(),
  30               c_spec.complex_converter(),
  31               c_spec.unicode_converter(),
  32               c_spec.string_converter(),
  33               c_spec.list_converter(),
  34               c_spec.dict_converter(),
  35               c_spec.tuple_converter(),
  36               c_spec.file_converter(),
  37               c_spec.instance_converter(),
  38               typed_array_converter()]
  39 
  40 
  41 ##############################################################################

New Attachment

File to upload
Rename to
Overwrite existing attachment of same name

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.