I think you want
Import numpy as np

On Sat, Jun 22, 2019, at 9:22 PM, Barry Duggan wrote:
> I am trying to build an Out of Tree block in Python, but having a 
> problem. The tutorial on building a Python block (squareme) didn't 
> address input and output ports :(
> 
> Here is my code (just to get the basic structure):
> """
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
> #
> # Copyright 2019 Barry Duggan KV4FV
> #
> from gnuradio import gr
> from numpy import np
> 
> ITA2 = [ 0x00, 'E', '\n', 'A', ' ', 'S', 'I', 'U', '\r', 'D', 'R', 'J', 
> 'N', 'F', 'C', 'K',
>  'T', 'Z', 'L', 'W', 'H', 'Y', 'P', 'Q', 'O', 'B', 'G', 0x0e, 
> 'M', 'X', 'V', 0x0f,
>  0x00, '3', '\n', '-', ' ', 0x07, '8', '7', '\r', '$', '4', 
> '\'', ',', '!', ':', '(',
>  '5', '\"', ')', '2', '#', '6', '0', '1', '9', '\?', '\&', 
> 0x0e, '.', '/', ';', 0x0f ]
> 
> _figs = 0x1b
> _ltrs = 0x1f
> _shift = 0
> 
> class convUtoI_bb(gr.sync_block):
>  """convert UTF-8 to ITA2 (Baudot)"""
>  def __init__(self):
>  gr.sync_block.__init__(self,
>  name="convUtoI_bb",
>  in_sig=[np.byte],
>  out_sig=[np.byte])
> 
>  def work(self, input_items, output_items):
>  in0 = input_items[0]
>  out = output_items[0]
> 
> # if char is in ITA2
>  if (in0 in ITA2):
>  _idx = ITA2.index
> # store ITA2 char
>  _idx &= 0x1F
>  out[:] = int(_idx)
>  else:
>  out[:] = in0
> 
>  return len(output_items[0])
> """
> and at execution I get:
> Traceback (most recent call last):
>  File "/home/pi/gnuradio/test0621.py", line 26, in <module>
>  import UTFtoITA
>  File "/usr/lib/python2.7/dist-packages/UTFtoITA/__init__.py", line 34, 
> in <module>
>  from convUtoI_bb import convUtoI_bb
>  File "/usr/lib/python2.7/dist-packages/UTFtoITA/convUtoI_bb.py", line 
> 23, in <module>
>  from numpy import np
> ImportError: cannot import name np
> 
> If importing numpy is not correct, how do I specify the size of the 
> input and output ports?
> 
> Thanks.
> -- 
> Barry Duggan
> 
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> 
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to