Skip to content

Instantly share code, notes, and snippets.

@haakov
Created July 24, 2018 16:30
Show Gist options
  • Save haakov/fb381bf3de1dd6a02b697c9d92d7dae5 to your computer and use it in GitHub Desktop.
Save haakov/fb381bf3de1dd6a02b697c9d92d7dae5 to your computer and use it in GitHub Desktop.
Multiply Const block
id: blocks_multiply_const_vxx
label: Multiply Const
parameters:
- id: type
label: IO Type
dtype: enum
options: [complex, float, int, short]
option_attributes:
const_type: [complex_vector, real_vector, int_vector, int_vector]
fcn: [cc, ff, ii, ss]
hide: part
- id: const
label: Constant
dtype: ${ type.const_type }
default: '0'
- id: vlen
label: Vec Length
dtype: int
default: '1'
hide: ${ 'part' if vlen == 1 else 'none' }
inputs:
- domain: stream
dtype: ${ type }
vlen: ${ vlen }
outputs:
- domain: stream
dtype: ${ type }
vlen: ${ vlen }
asserts:
- ${ (len(const) == vlen) if str(const).strip().startswith('[') else (vlen == 1) }
- ${ vlen > 0 }
templates:
imports: from gnuradio import blocks
make: blocks.multiply_const_v${type.fcn}(${ str(const) if str(const).strip().startswith('[') else ('[' + str(const) + ']') })
callbacks:
- set_k(${const})
file_format: 1
@dl1ksv
Copy link

dl1ksv commented Jul 25, 2018

I think, the type substitution for the constant dtype entry does not work. If I replace the dtype of const by real_vector the type of constant is now displayed as real_vector and the assertion does not fail any longer.
So why does the type of the constant keep raw and does not change depending on the selected type ?

So far as I can see the dtype entry in the constans parameter recognizes ${type} but not ${type.const_type}. ${type.const_type} seems to evaluate to '' !

@haakov
Copy link
Author

haakov commented Jul 27, 2018

Hm, looks like you're right!

@haakov
Copy link
Author

haakov commented Jul 28, 2018

Okay so I've found the problem.

This namespace property ignores the option_attributes. This is why type is recognized but not type.const_type.

@haakov
Copy link
Author

haakov commented Jul 28, 2018

Pull request created: gnuradio/gnuradio#1925

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment