Skip to content

Instantly share code, notes, and snippets.

View holgi's full-sized avatar

Holger Frey holgi

View GitHub Profile
@holgi
holgi / pipe_ellipsis.py
Last active August 30, 2023 21:00
Python pipe decorator with Ellipsis
""" A proposal for yet another pipe decorator
I'm still missing a nice way to do method chaining in python.
I'd like to have something like `func_a() | func_b()` as a syntax and I'm quite
aware that there are some "pipe" libraries on pypi like `pipe` or `pipe21` that
offer such functionality.
But what I don't like is, that the result of `func_a` (in the example above) is
piped directly as the first argument to `func_b`.
@holgi
holgi / settings.json
Created May 7, 2020 13:09
vscode jupyter notebook settings
{
"python.pythonPath": "C:\\ProgramData\\Anaconda3\\python.exe",
"python.formatting.provider": "black",
"python.linting.flake8Enabled": true,
"python.testing.pytestEnabled": true,
"python.dataScience.jupyterCommandLineArguments": [
"--NotebookApp.port=9999"
]
}
@holgi
holgi / Peakplot Fix.ipynb
Created May 16, 2019 10:20
Fix for peakutils.plot.peakplot
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@holgi
holgi / asyncio-mock-example.py
Created January 30, 2019 13:31
Example for mocking async context managers
import pytest
import aiohttp
import asyncio
from asynctest import CoroutineMock, MagicMock, patch
# Example Code
async def fetch(session, url):