Gr_sync_block, AttributeError: No constructor defined

I am trying to create a block using gr.gr_sync_block which will select
a value from an input vector, pass that value to output, and discard
the rest of the vector:

!/usr/bin/env python

from gnuradio import gr
import numpy

class vector_parser(gr.gr_sync_block):
def init(self):
name = “vector_parser”,
in_sig = [(numpy.float32, 5)],
out_sig = [numpy.float32]

def work(self, input_items, output_items):
output_items[0] = input_items[2]
return len(output_items[0])

class test(gr.top_block):

def init(self):

self.samp_rate = samp_rate = 32000

self.gr_vector_source_x_0 = gr.vector_source_f((1, 0, 2, 0, 3), 

True, 5)
self.gr_null_sink_0 = gr.null_sink(gr.sizeof_float*1)
self.vector_parser = vector_parser()

self.connect((self.gr_vector_source_x_0, 0), (self.vector_parser, 

self.connect((self.vector_parser, 0), (self.gr_null_sink_0, 0))

def get_samp_rate(self):
return self.samp_rate

def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate

if name == ‘main’:
tb = test()

Each time I try to run this script I receive the following error:

Traceback (most recent call last):
File “./”, line 40, in
tb = test()
File “./”, line 28, in init
self.vector_parser = vector_parser()
File “./”, line 12, in init
out_sig = [numpy.float32]
line 2121, in init
def init(self, *args, **kwargs): raise AttributeError(“No
constructor defined”)
AttributeError: No constructor defined

Can anyone tell me what is causing this error?



On 02/15/2012 04:22 PM, Jason Bonior wrote:

def init(self):

This should be gr.sync_block. gr.gr_sync_block is actually the swigged
representation of the c++ class, and I dont think it should be there. Oh

Also, to get this feature you will need to install my next branch or
python_blocks branch. Sorry, writing blocks in python is not a mainline
feature. I hope someday it will be accepted.

This is my git repo with said branches:


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs