Skip to content

Instantly share code, notes, and snippets.

View jasmainak's full-sized avatar

Mainak Jas jasmainak

View GitHub Profile
@wmvanvliet
wmvanvliet / checker.py
Last active August 6, 2016 17:45
Script that extracts all docstrings from a Python module, saves them to a file, and proceeds to compile a list of possible duplicates based on levenshtein distance.
from __future__ import print_function
import os.path as op
import inspect
import distance
import numpy as np
from scipy.misc import comb
import progressbar as pb
import progressbar.widgets as pw
# -*- coding: utf-8 -*-
"""
PySurfer-like plotting using VisPy scene.
"""
import numpy as np
from vispy import scene, app
import mne
import nibabel
@jakevdp
jakevdp / convolution_matrix.py
Last active March 12, 2019 09:49
Convolution Matrix
# Author: Jake VanderPlas
# LICENSE: MIT
from __future__ import division
import numpy as np
def convolution_matrix(x, N=None, mode='full'):
"""Compute the Convolution Matrix
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wmvanvliet
wmvanvliet / haufe.ipynb
Last active July 14, 2017 09:25
Testing the Haufe trick
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@raghavrv
raghavrv / undecorate_python.py
Last active June 27, 2017 11:54
Undecorate an object python2.7 or 3.5
from types import FunctionType
import inspect
def undecorate(func):
funcs = []
# python 3.5
if hasattr(func, '__wrapped__'):
while hasattr(func, '__wrapped__'):
func = func.__wrapped__
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@0x4D31
0x4D31 / beautiful_idiomatic_python.md
Last active November 22, 2024 08:34 — forked from JeffPaine/beautiful_idiomatic_python.md
[Beautiful Idiomatic Python] Transforming Code into Beautiful, Idiomatic Python #python

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
name: hnn
channels:
- defaults
dependencies:
- python>=3.6
- pip
- numpy
- scipy
- matplotlib
- cython
@larsoner
larsoner / gist:4c964e21045fc499cb5e380dc79137c0
Created February 3, 2021 20:19
bems_brainsuite_fsl.py
# convert MGZ->NII
#
# $ bet T1.nii stripped.nii.gz -n -A -v -e
#
import numpy as np
import nibabel as nib
import pyvista as pv
import mne
img = nib.load('T1.mgz')