nineml.utility.invert_dictionary

nineml.utility.invert_dictionary(dct)[source]

Takes a dictionary mapping (keys => values) and returns a new dictionary mapping (values => keys). i.e. given a dictionary:

{k1:v1, k2:v2, k3:v3, ...} 

it returns a dictionary:

{v1:k1, v2:k2, v3:k3, ...} 

It checks to make sure that no values are duplicated before converting.