Skip to content

Instantly share code, notes, and snippets.

Click me

Heading

  1. Foo
  2. Bar
    • Baz
    • Qux

Some Code

import logging
#### to reset the logging basicConfig, you need to reload the module
# from importlib import reload
# reload(logging)
logging.basicConfig(filename='debugging.log',
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JanHomann
JanHomann / _jupyter notebooks.md
Last active August 30, 2023 15:44
jupyter notebooks

Jupyter notebook configurations and interactive examples

@JanHomann
JanHomann / plotting_in_debugger.md #VSCode
Last active September 2, 2020 18:59
VSCode #vscode
Plotting does actually currently work on my end. You just have to add plt.show() after the plot command.
```
plt.matshow(df)
plt.show()
```
This pops up an external plot window. The debug console is then blocked and will complain that plt.show() did not finish after 3 seconds, but the plot is there and fully functional.
Then when i am done analyzing the figure, I click on close, or press q (the shortcut for closing a matplotlib window) and that unblocks the debugger. The plot window though doesn't disappear, but freezes. But it's still possible to do additional plots like that, which will then use the same window. It's also possible to prepare several figure objects in one or several debugging commands, and plt.show() will show all of them. In addition if you show the plot with plt.pause(0.001) instead of plt.show(), then you return immediately back to the debug terminal.
import time
import numba
# @numba.jit
@numba.vectorize(([numba.float64(numba.float64)]))
def count_triples(limit):
result = 0
for a in range(1, limit+1):
for b in range(a+1, limit+1):
import inspect, re
def varname(p):
for line in inspect.getframeinfo(inspect.currentframe().f_back)[3]:
m = re.search(r'\bvarname\s*\(\s*([A-Za-z_][A-Za-z0-9_]*)\s*\)', line)
if m:
return m.group(1)
print(varname(df_stimulus))
@JanHomann
JanHomann / reveal_type.py
Created April 4, 2020 04:31
mypy #linter
from typing import TYPE_CHECKING
from typing import List
# l: List[int] = [1, 2, 3]
l = [1, 2, 3]
if TYPE_CHECKING:
reveal_type(l) # pylint: disable=undefined-variable
print(TYPE_CHECKING)
@JanHomann
JanHomann / pytest.ini
Last active September 2, 2020 19:01
pytest
[pytest]
junit_family=xunit1
addopts= --cov=src/primitive_types --cov-report=xml # needs pip install pytest-cov