Skip to content

Instantly share code, notes, and snippets.

View luispedro's full-sized avatar

Luis Pedro Coelho luispedro

View GitHub Profile
@luispedro
luispedro / environment.yml
Created January 23, 2019 03:22
Conda conflict
name: ngless-bench-env
channels:
- bioconda
- conda-forge
- defaults
dependencies:
- subread=1.6.1=0
- bottle=0.12.13=py36_0
- jug=1.6.5=py_0
- pyyaml=3.12=py36_1
Verifying that +luispedro is my openname (Bitcoin username). https://onename.com/luispedro
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@luispedro
luispedro / pdio.py
Last active March 22, 2019 14:05
Save & load from a pandas DataFrame/Series
import numpy.lib
import numpy as np
import pandas as pd
import cPickle as pickle
def save_pandas(fname, data):
'''Save DataFrame or Series
Parameters
----------
import mahotas as mh
from jug import TaskGenerator
from glob import glob
@TaskGenerator
def method1(image):
image = mh.imread(image)[:,:,0]
image = mh.gaussian_filter(image, 2)
binimage = (image > image.mean())
labeled, _ = mh.label(binimage)
@luispedro
luispedro / julia-eigen.cpp
Created December 5, 2012 14:43
Julia C++ benchmark using Eigen
#include <sys/time.h>
#include <utility>
#include <iostream>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <eigen3/Eigen/Dense>
using namespace Eigen;
import numpy as np
from matplotlib import pyplot as plt
def irs_paid(val):
paid = 0
def sub0(y, x):
if (val <= y): return 0;
if (val < x): return val - y;
return x - y;
return sub0(0,7000)*0.145 + sub0(7000,20000)*0.285 + sub0(20000,40000)*0.37 + sub0(40000,80000)*0.45 + (val - 80000 if (val > 80000) else 0) * 0.48;
@luispedro
luispedro / population-portugal.py
Created October 11, 2012 23:03
Population of Portugal: projection
import numpy as np
from matplotlib import pyplot as plt
#### From XKCD plot generator
"""
XKCD plot generator
-------------------
Author: Jake Vanderplas
This is a script that will take any matplotlib line diagram, and convert it
@luispedro
luispedro / readroi.py
Last active December 16, 2020 07:50
Read ImageJ's ROI files
# UPDATE IN 2020
# You almost always will want to use the version at
# https://github.com/luispedro/imread, which is
# up-to-date and works with Python 3
# Copyright: Luis Pedro Coelho <[email protected]>, 2012
@luispedro
luispedro / output.py
Created May 13, 2011 20:15
Matplotlib plotting for quality LaTeXing
#vim: set ts=4 sts=4 expandtab sw=4:
from sys import argv
import matplotlib as mpl
import matplotlib.pyplot as plt
from math import sqrt
mpl.rcdefaults()
_golden_mean = (sqrt(5)-1.)/2.
bronzetan = '#BD3600'