I have the following array that I want to replace values in based on what it corresponds with in a dictionary.
Array:
[[ 0. -1. 1. 1.]
[ 0. 1. -2. -3.]
[-1. 1. 1. -5.]
[-3. -1. -1. 2.]
[-5. 2. -4. -2.]
[-1. -3. -1. 2.]
[ 0. 1. -3. 1.]
[-2. -3. 0. -2.]
[-2. -2. 1. -6.]
[-0. -2. 2. -0.]]
Dictionary:
dict = {-13: 13.0,
-12: 9.375,
-11: 9.4,
-10: 8.6,
-9: 8.3,
-8: 7.8,
-7: 7.1,
-6: 6.4,
-5: 5.8,
-4: 5.2,
-3: 4.6,
-2: 4.0,
-1: 3.6,
0: 3.2,
1: 2.8,
2: 2.5,
3: 2.2,
4: 2.0,
5: 1.8,
6: 1.6}
As an example, any 0 in the array would be replaced with 3.2, any -1 in the array would be replaced with a 3.6, so on and so forth. The original array is 120x10000x4 so any speed optimization would be ideal.
Thanks in advance for any help!