Skip to content

Instantly share code, notes, and snippets.

View Dapid's full-sized avatar

David Menéndez Hurtado Dapid

  • Savantic AB
  • Stockholm
View GitHub Profile
@Dapid
Dapid / plot_vmemstat.py
Last active August 29, 2015 13:57
Performance graph on a Linux system
#!/bin/python
import sys
import numpy as np
import pylab as plt
import bottleneck as bn
total = int(open('/proc/meminfo').readline().split()[1])
if len(sys.argv) == 1:
@Dapid
Dapid / scalogram
Created May 23, 2014 00:41
Seeing sound
'''
Created on 23 May 2014
@author: david
@licence: CRAPL
http://matt.might.net/articles/crapl/
'''
import numpy as np
from scipy.io import wavfile
from scipy.misc import imsave
@Dapid
Dapid / prob_trees.pyx
Created March 17, 2015 00:23
Probability trees
import numpy as np
cimport numpy as np
cimport cython
import random
from math import ceil
from libc.math cimport log2
building 'ceygen.core' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -march=core-avx-i -O2 -pipe -mtune=native -fPIC -Iceygen -I/usr/include/eigen3 -I/usr/include/python2.7 -c ceygen/core.cpp -o build/temp.linux-x86_64-2.7/ceygen/core.o -O2 -march=native -fopenmp
g++ -pthread -shared -Wl,-z,relro -march=core-avx-i -O2 -pipe -mtune=native build/temp.linux-x86_64-2.7/ceygen/core.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/ceygen/core.so -fopenmp
building 'ceygen.dtype' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
import time
import collections
import multiprocessing
def save_data(q):
while True:
try:
# pk = q.popleft()
#!python
import numpy as np
cimport numpy as np
from cpython cimport bool
ctypedef np.float64_t data_t
cdef bool[:] alt_argrelmax(double[:] data, int order):
cdef int N = data.shape[0]
@Dapid
Dapid / garbage.log
Last active February 19, 2016 10:55
(py27)[david@SQUIDS gpy_memtest]$ python memtest.py gpy
/home/david/.virtualenvs/py27/lib/python2.7/site-packages/numpy/core/numeric.py:294: FutureWarning:in the future, full((3, 3), 666) will return an array of dtype('int64')
/home/david/.virtualenvs/py27/lib/python2.7/site-packages/numpy/core/numeric.py:294: FutureWarning:in the future, full((3, 1), 42) will return an array of dtype('int64')
0
[]
191
[<GPy.models.gp_regression.GPRegression object at 0x7f97ce48f0d0>, {'_added_names_': set(['Gaussian_noise', 'rbf']), 'sampling_runs': [], 'mean_function': None, 'Y_normalized': ObsAr([[ 42.],
[ 42.],
[ 42.]]), '_fixes_': None, '_optimizer_copy_transformed': False, 'size': 3, 'parameters': [<GPy.core.parameterization.ties_and_remappings.Tie object at 0x7f97ce48fd90>, <GPy.kern._src.rbf.RBF object at 0x7f97ce48f1d0>, <GPy.likelihoods.gaussian.Gaussian object at 0x7f97ce48f850>], 'priors': <GPy.core.parameterization.index_operations.ParameterIndexOperations object at 0x7f97ce48fb50>, 'output_dim':
import tables
class H5Generator(object):
def __init__(self, h5file):
self.h5 = tables.open_file(h5file)
self.n_rows = int(self.h5.root.target.shape[0])
self.ix = 0
self.feature_keys = ('atom_contacts', 'residue_contacts', 'rsa', 'surface_area_bins', 'dssp_ss', 'pssm')
self.target_key = 's_score'
@Dapid
Dapid / first_step.sh
Last active March 9, 2017 15:28
My setup of a Fedora box. Some of the dnf installed packages may be repeated or redundant, but it doesn't matter.
echo "deltarpm=0" >> /etc/dnf/dnf.conf
# Basic tools, quick install:
dnf install -y firefox htop kernel-tools vim-enhanced iotop nload
# Scientifc python dependencies:
dnf install -y python3-devel python3-virtualenv gcc-gfortran gcc gcc-c++ python3-pip hdf5-devel zlib-devel xz-devel libstdc++-devel lapack-devel glibc-devel graphviz graphviz-devel lzo-devel fftw fftw-devel boost boost-devel boost-openmpi-devel openblas-devel openblas openblas-openmp openblas-openmp64 openblas-threads openblas-threads64 redhat-rpm-config
# Mostly Matplotlib dependencies
dnf install -y libpng-devel agg-devel tcl-devel vtk-qt-tcl vtk-tcl vtk-devel vtk-qt-python tkinter gtk2-devel wxPython-devel wxGTK-devel wxGTK-gl wxGTK-media freetype-devel bzip2-devel PyQt4-devel cairo-devel pygtk2-devel tk-devel texlive-dvipng ffmpeg ffmpeg-devel ffmpeg-libs gstreamer-ffmpeg openjpeg-devel openjpeg2-devel python-qt5-devel
@Dapid
Dapid / scratch_4.py
Created October 12, 2017 14:03
Profile results
$ kernprof -lv scratch_4.py
Line # Hits Time Per Hit % Time Line Contents
==============================================================
13 @profile
14 def run():
15 1 47 47.0 0.1 midpoints = k[:-1] + np.diff(k)/2
16 1 43 43.0 0.1 idx_aux = np.searchsorted(sortedA, midpoints)
17 1 1 1.0 0.0 idx = []