-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstream_lambda.py
More file actions
40 lines (34 loc) · 1.09 KB
/
Copy pathstream_lambda.py
File metadata and controls
40 lines (34 loc) · 1.09 KB
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2015,2020 Tim O'Shea, Jacob Gilbert
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
import numpy
from gnuradio import gr
import pmt
class stream_lambda(gr.sync_block):
"""
docstring for block stream_lambda
"""
def __init__(self, fn, insig=[numpy.complex64], outsig=[numpy.complex64]):
gr.sync_block.__init__(self,
name="stream_lambda",
in_sig=insig, out_sig=outsig)
self.set_fn(fn)
self.lvars = {}
# signature should be:
# (output_stream_items) = lambda input_items, output_stream_index: ....
def set_fn(self,fn):
self.fn = fn
def work(self, input_items, output_items):
n_out = 0;
for i in range(0,len(output_items)):
o = self.fn(input_items, i)
output_items[i][0:len(o)] = o[:]
if(n_out == 0 or n_out == len(o)):
n_out = len(o)
else:
raise Exception("Streams must produce same lengths for now with the current stream lambda block interface!")
return n_out