0

Dimensional Array
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Dimensional Array

by sashaT on Sun Jan 10, 2021 9:51 am

Hi! I have a computer (python) application that will send a dimensional array through serial to a board. I need to generate a dimensional array from lists. I want an empty array, arr = [] or arr = np.array([]). Next, I have a list named writearr that is constantly refilled with data. I want to write the data into a new dimension, for example, if writearr = [3,4,5], when I run a command, I want the arr list, which previously contained [0,1,2,] to be arr = [[0,1,2],[3,4,5]]. How can I do this?

sashaT
 
Posts: 31
Joined: Thu Dec 24, 2020 1:06 pm

Re: Dimensional Array

by bludin on Sun Jan 10, 2021 1:15 pm

I'm not sure I understand your question fully, but you can generate a list of lists by using append.
Code: Select all | TOGGLE FULL SIZE
>>> a = []
>>>a.append([1,2,3])
>>> a
[[1, 2, 3]]
>>> a.append([3,4,5])
>>> a
[[1, 2, 3], [3, 4, 5]]

bludin
 
Posts: 40
Joined: Thu Apr 16, 2020 8:57 am

Re: Dimensional Array

by mikeysklar on Mon Jan 11, 2021 8:37 pm

This post provides a good walk-through on 2D arrays in CircuitPython:

https://ecampusontario.pressbooks.pub/r ... nd-spaces/

mikeysklar
 
Posts: 2880
Joined: Mon Aug 01, 2016 8:10 pm

Please be positive and constructive with your questions and comments.