Page 1 of 1

uarray issues

Posted: Fri Apr 24, 2020 5:27 pm
by emp20
Hello, I have an issue with uarray on pyboard. Here is some code which I try to implement:

import uarray as array

data_array = array.array('f',[])
for i in range (counter, counter+N_SAMPLE):
data_array=data_array.append(float(f.readline()))

I have an issue in the last line and the error in REPL is that data_array does not have the attribute append
In the documentation, I see that attribute exists but I am not sure why do I get the error. I tried reading from file separately and that is a correct value. Can anyone give me some help or suggest another alternative I may use?

Re: uarray issues

Posted: Fri Apr 24, 2020 5:45 pm
by pythoncoder
The following works here on a Pyboard:

Code: Select all

>>> from array import array
>>> a = array('f',[])
>>> a.append(1.0)
>>> a.append(1.0)
>>> a
array('f', [1.0, 1.0])
>>> 

Re: uarray issues

Posted: Fri Apr 24, 2020 6:54 pm
by emp20
Dear Peter,

Thank you for your quick reply. I modified my code according to your code (which also worked on my pyboard) to:
from array import array

data = array('f',[])

for i in range (counter, counter+N_SAMPLE):
data=data.append(float(f.readline()))

and I still get the AttributeError : NoType object has no attribute append. Unfortunately I cannot see why is that
When I check the counter, N_SAMPLE they are all initialised but the error is still in the last line...

Re: uarray issues

Posted: Fri Apr 24, 2020 7:41 pm
by emp20
Dear Peter,

your comment was very useful. I used data_array=data_array.append(float(f.readline())) when I should have used data_array.append(float(f.readline()))
A rookie mistake.

best wishes,

emp20