Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Keys of a dictionary

Hello guys, I have a piece of code to get a dictionary of preimages of a function. These look like this:

{[0.0]: [[0 0 0 0 0]], [1.27]: [[0 0 0 0 1]], [2.63]: [[1 1 1 0 0]], ..... , [5.619999999999999]: [[1 0 1 1 1]]}

if I look for preimages.keys(), I get the following:

[[0.0], [1.27], [2.63], ....... , [5.619999999999999]]

But when I try to get a particular preimage like preimages[1.27] I get an error

KeyError: 1.27000000000000

even though it is in a dictionary. Or if I try

preimages [[1.27]]

I get another error

TypeError: unhashable type: 'list'

Could someone please help to solve this ploblem ?

Keys of a dictionary

Hello guys, I have a piece of code to get a dictionary of preimages of a function. These look like this:

{[0.0]: [[0 0 0 0 0]], [1.27]: [[0 0 0 0 1]], [2.63]: [[1 1 1 0 0]], ..... , [5.619999999999999]: [[1 0 1 1 1]]}

if I look for preimages.keys(), I get the following:

[[0.0], [1.27], [2.63], ....... , [5.619999999999999]]

But when I try to get a particular preimage like preimages[1.27] I get an error

KeyError: 1.27000000000000

even though it is in a dictionary. Or if I try

preimages [[1.27]]

I get another error

TypeError: unhashable type: 'list'

Could someone please help to solve this ploblem ?