lm.py 362 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""
Functions and classes
"""

import numpy as np


def vec_translate(a, my_dict):
    """
    Function to apply my_dict to each element in in array a. See:
    https://stackoverflow.com/questions/16992713/translate-every-element-in-numpy-array-according-to-key

    Note that key errors are not caught!
    """
    return np.vectorize(my_dict.__getitem__)(a)