Skip to Content
Secret Recipes of the Python Ninja
book

Secret Recipes of the Python Ninja

by Cody Jackson
May 2018
Intermediate to advanced content levelIntermediate to advanced
380 pages
9h 37m
English
Packt Publishing
Content preview from Secret Recipes of the Python Ninja

Bijection

  1. 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. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Expanding World of Python

The Expanding World of Python

Dane Hillard

Publisher Resources

ISBN: 9781788294874Supplemental Content