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 logging | |
| import resource | |
| from contextlib import ContextDecorator | |
| from time import perf_counter_ns | |
| class logprof(ContextDecorator): | |
| def __init__(self, label, logger=None, **kwds): | |
| self.label = label | |
| self.logger = logger or logging.getLogger(__name__) |
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
| """Copy text in remote Jupyter sessions. | |
| Copy text to OS clipboard when using Jupyter remotely. Uses web browsers | |
| clipboard via Javascript. | |
| NOTE: also available as extension. not suitable for large data, e.g df with 100k rows. | |
| """ | |
| from IPython.display import HTML | |
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
| """ | |
| This script enables python variables to be formatted in markdown. Similar | |
| to python-markdown. Save this script to your ipython startup folder. You | |
| can find this by running the following in a notebook cell: | |
| get_ipython().profile_dir.startup_dir | |
| To use: | |
| foo = "some python value" |
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
| """ monkey patch unittest to include numpy assertions. | |
| Maps numpy assert_func_name to numpyAssertFuncName. | |
| Example: | |
| class NumpyWrapperTest(unittest.TestCase): | |
| def test_allclose_example(self): | |
| a1 = np.array([1.,2.,3.]) | |
| self.numpyAssertAllclose(a1, np.array([1.,2.,3.1])) | |
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
| """ | |
| This script enables step-by-step debugging of jupyter notebooks remotely | |
| from pydev in Eclipse. Save this script to your ipython startup folder. You | |
| can find this by running the following in a notebook cell: | |
| get_ipython().profile_dir.startup_dir | |
| To trigger a breakpoint, start up pydevs remote debugging server and then | |
| insert the following code where you wish the breakpoint to start: |