It would be better to split this into the module (this file), tests to be located in the `tests/` directory, and examples to be included in the docs.  That means you should move the code below `if __name__ == '__main__'` into a different file too.