Skip to content

Instantly share code, notes, and snippets.

View andersy005's full-sized avatar
:octocat:

Anderson Banihirwe andersy005

:octocat:
View GitHub Profile
@andersy005
andersy005 / keybase.md
Created November 30, 2017 00:55
Keybase proof

Keybase proof

I hereby claim:

  • I am andersy005 on github.
  • I am andersy005 (https://keybase.io/andersy005) on keybase.
  • I have a public key ASA6MpC7M7i67D6zZeY9fWDj-1fF_lNTOwjBKhPFQ8Uefwo

To claim this, I am signing this object:

@andersy005
andersy005 / list_tricks_1.md
Last active March 7, 2018 04:38
Python List tricks

Extending and Appending Lists with the '+'-Operator

import time

n = 100000

start_time = time.time()
l = []
for i in range(n):
@andersy005
andersy005 / copy.md
Last active March 7, 2018 05:04
Shallow and Deep Copy in Python

Shallow Copy

>>> x = 3
>>> y = x
>>> print(id(x), id(y))
9251744 9251744
>>> y = 4
>>> print(id(x), id(y))
9251744 9251776
#!/bin/bash
usage="$(basename "$0") [-h] [-s n] -- program to calculate the answer to life, the universe and everything
where:
-h show this help text
-s set the seed value (default: 42)"
seed=42
while getopts ':hs:' option; do
case "$option" in
@andersy005
andersy005 / dask-env.yml
Last active August 21, 2018 20:41
Dask-Cluster
name: dask-dev
channels:
- conda-forge
- defaults
dependencies:
- dask
- dask-ml
- numpy
- python=3.6
- bokeh
import pandas as pd
import dask.dataframe as dd
import numpy as np
import dask.array as da
import inspect
from numpydoc.docscrape import NumpyDocString
import pydoc
def maybe_build_signature(obj, name):
@andersy005
andersy005 / dask_sparse_corr.py
Created September 12, 2018 10:24 — forked from twiecki/dask_sparse_corr.py
Compute large, sparse correlation matrices in parallel using dask.
import dask
import dask.array as da
import dask.dataframe as dd
import sparse
@dask.delayed(pure=True)
def corr_on_chunked(chunk1, chunk2, corr_thresh=0.9):
return sparse.COO.from_numpy((np.dot(chunk1, chunk2.T) > corr_thresh))
def chunked_corr_sparse_dask(data, chunksize=5000, corr_thresh=0.9):
#!/bin/bash
#PBS -N dask-scheduler
#PBS -q economy
#PBS -A NIOW0001
#PBS -l select=1:ncpus=36:mpiprocs=6:ompthreads=6
#PBS -l walltime=00:30:00
#PBS -j oe
# module purge
module load gnu
@andersy005
andersy005 / geotools.py
Created November 6, 2018 01:08
Geotools
from __future__ import absolute_import, division, print_function
import numpy as np
import xarray as xr
#-------------------------------------------------------------------------------
#-- function
#-------------------------------------------------------------------------------
def weighted_rmsd(da_x,da_y,weights,avg_over_dims=[]):
@andersy005
andersy005 / calc.py
Last active November 28, 2018 23:58
ESMLAB
#! /usr/bin/env python
from __future__ import absolute_import, division, print_function
import xarray as xr
import numpy as np
import cftime
xr_open_ds = {'chunks' : {'time':1},
'decode_coords' : False,
'decode_times' : False,
'data_vars' : 'minimal'}