473,320 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Two dimensional lists

I might get an answer since I didn't call them arrays. :^)

Ok, I have 2 lists that I need to process individually, then merge
them into a 2x list and fill with data.

arinc429 = ['ab', '2b', '0b', '21', 'c1', '61', '11', 'db', '9b', '5b', 'eb',
'6b', '1b', '6e', '3e']
iPIDs = [300, 301, 320, 321]

merged[arinc429, iPIDs]

# PID & a429 are defined elsewhere

a_idx = iPIDs.index[PID]
p_idx = [arinc429.index[a429]

# shouldn't I be able to fill the lists simply by pointing to a location?

matrix[a_idx, p_idx] = 0x219 # and so on?

tia
Jan 25 '07 #1
1 1976
gonzlobo wrote:
I might get an answer since I didn't call them arrays. :^)

Ok, I have 2 lists that I need to process individually, then merge
them into a 2x list and fill with data.

arinc429 = ['ab', '2b', '0b', '21', 'c1', '61', '11', 'db', '9b', '5b',
'eb',
'6b', '1b', '6e', '3e']
iPIDs = [300, 301, 320, 321]

merged[arinc429, iPIDs]

# PID & a429 are defined elsewhere

a_idx = iPIDs.index[PID]
p_idx = [arinc429.index[a429]

# shouldn't I be able to fill the lists simply by pointing to a location?

matrix[a_idx, p_idx] = 0x219 # and so on?
The simplest approach is to go with a dictionary:
>>matrix = {}
arinc = ['ab', '2b', '0b']
pids = [300, 321]
for x in arinc:
.... for y in pids:
.... matrix[x, y] = y + int(x, 16) # replace with your actual data
....
>>matrix
{('ab', 300): 471, ('2b', 300): 343, ('ab', 321): 492, ('0b', 321): 332,
('2b', 321): 364, ('0b', 300): 311}

Get one entry:
>>matrix["2b", 321]
364

Get all items along an axis:
>>[matrix[x, 300] for x in arinc]
[471, 343, 311]

Peter
Jan 25 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Rodrigo Daunaravicius | last post by:
Is there an elegant way to directly refer the 2nd dimension of a multi-dimensional sequence (like the nth character in a list of strings). An example would be deleting the newline in all the...
15
by: anthonyberet | last post by:
Hello again - rather a newbie here... I want to work on a sudoku brute-forcer, just for fun. I am considering different strategies, but first I need to decide on the data-structure to use for...
22
by: spam.noam | last post by:
Hello, I discovered that I needed a small change to the Python grammar. I would like to hear what you think about it. In two lines: Currently, the expression "x" is a syntax error. I suggest...
4
by: TG | last post by:
Hi there ! I'm just starting to use Numeric here, and I'm wondering : how can I efficiently initialize every values of a N-dimensional array, given I don't know the number of dimensions ? I'm...
3
by: acosgaya | last post by:
Hi, I would like some help as how to approach the following problem: I have a set of d-dimensional points (e.g (3,5,8,9,5) is a 5-dimensional point), and I need to sort the points on each of the...
2
by: bruce | last post by:
hi... basic question.. how do i define a multi dimensional array a is there a kind of a = array(10,10)
8
by: per9000 | last post by:
Hi all, I have a two-dimensional array of data, f.x int's. We can imagine that the array is "really large". Now I want the data in it and store this in a one-dimensional array. The obvious...
272
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
16
by: agent-s | last post by:
Basically I'm programming a board game and I have to use a list of lists to represent the board (a list of 8 lists with 8 elements each). I have to search the adjacent cells for existing pieces and...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.