- Bijective functions are commonly found in a variety of mathematical areas, such as in the definitions of isomorphism, homeomorphism, diffeomorphism, permutation group, and projective maps. The following example only demonstrates how a bijection object is created and checked, but doesn't go into extensive detail on implementation:
>>> from collections_extended import bijection >>> bij = bijection({'a': 1, 'b': 2, 'c': 3}) >>> bij.inverse[2] 'b' >>> bij['a'] = 2 >>> bij == bijection({'a': 2, 'c': 3}) True >>> bij.inverse[1] = 'a' >>> bij == bijection({'a': 1, 'c': 3}) True
-
- As usual, the class is imported from the module and an instance is created. The instance argument is a simple dictionary, mapping a string to an integer. ...