Skip to content

Instantly share code, notes, and snippets.

View masip85's full-sized avatar

Vicente Masip masip85

View GitHub Profile
@santi-pdp
santi-pdp / Generative Adversarial Networks toy example.ipynb
Created February 16, 2017 18:36
A toy example on Generative Adversarial Networks
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@simecek
simecek / iteration_on_combinations.ipynb
Last active January 15, 2020 21:49
Iteration_on_combinations.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@internaut
internaut / pandas_crossjoin_example.py
Last active June 12, 2020 14:30
Shows how to do a cross join (i.e. cartesian product) between two pandas DataFrames using an example on calculating the distances between origin and destination cities. See https://mkonrad.net/2016/04/16/cross-join--cartesian-product-between-pandas-dataframes.html
"""
Shows how to do a cross join (i.e. cartesian product) between two pandas DataFrames using an example on
calculating the distances between origin and destination cities.
Tested with pandas 0.17.1 and 0.18 on Python 3.4 and Python 3.5
Best run this with Spyder (see https://github.com/spyder-ide/spyder)
Author: Markus Konrad <post@mkonrad.net>
April 2016
import numpy as np
import fftw3
import pyfftw
import multiprocessing
import matplotlib
import matplotlib.pyplot as pl
import time
def fft_comparison_tests(size=2048, dtype=np.complex128, byte_align=False):
@endolith
endolith / fftconv-conv-timings-2d.ipynb
Created July 24, 2019 19:19 — forked from stsievert/fftconv-conv-timings-2d.ipynb
constant timing for convolution methods (fft and direct)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@endolith
endolith / istft.m
Created May 24, 2012 20:31
STFT ISTFT Matlab Python
function x = istft(d, ftsize, w, h)
% X = istft(D, F, W, H) Inverse short-time Fourier transform.
% Performs overlap-add resynthesis from the short-time Fourier transform
% data in D. Each column of D is taken as the result of an F-point
% fft; each successive frame was offset by H points (default
% W/2, or F/2 if W==0). Data is hann-windowed at W pts, or
% W = 0 gives a rectangular window (default);
% W as a vector uses that as window.
% This version scales the output so the loop gain is 1.0 for
% either hann-win an-syn with 25% overlap, or hann-win on
@endolith
endolith / fft_vs_fwt.md
Created November 14, 2011 04:52
FFT vs FWT face-off

Empirically testing whether FWT or FFT is faster. Disclaimer: I don't understand wavelets.

Speed of FFT implementation doesn't care what the data is:

In [23]: a = rand(2**20)

In [24]: timeit fft(a)
10 loops, best of 3: 128 ms per loop

In [25]: a = rand(2**20)
@endolith
endolith / diff of phase spectrogram.py
Last active September 9, 2020 09:54
Time derivative of phase spectrogram
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 03 2016
Show how the time derivative of phase spectrogram is constant, shows the
frequency offset within a bin
"""
from numpy import sin, linspace, pi, abs, angle, diff, unwrap
from numpy.random import randn
@mgwilliams
mgwilliams / lxc-agent-forward.sh
Last active September 30, 2020 13:50
example of how to forward ssh-agent into an lxc
#!/bin/bash
# Example Script to forward ssh-agent socket into an unprivileged lxc
# This allows access to the ssh-agent by commands executed with lxc-attach
set -m
CONTAINER=$1 # e.g., test-container
REMOTE=$2 # e.g, user@example.com
@jiffyclub
jiffyclub / snakeviz_magic.py
Last active February 8, 2021 14:16
Magics for starting Snakeviz from IPython. Use %snakeviz and %%snakeviz in place of %prun and %%prun to profile a block of code and launch a Snakeviz view of the profile.
import subprocess
import tempfile
import time
from IPython.core.magic import register_line_cell_magic
def snakeviz(line, cell=None):
"""
Profile code and display the profile in Snakeviz.