This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| def doi2bib(doi): | |
| """ | |
| Return a bibTeX string of metadata for a given DOI. | |
| """ | |
| url = "http://dx.doi.org/" + doi | |
| headers = {"accept": "application/x-bibtex"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def matprint(mat, fmt="g"): | |
| col_maxes = [max([len(("{:"+fmt+"}").format(x)) for x in col]) for col in mat.T] | |
| for x in mat: | |
| for i, y in enumerate(x): | |
| print(("{:"+str(col_maxes[i])+fmt+"}").format(y), end=" ") | |
| print("") | |
| # Try it! | |
| import numpy as np |