Skip to content

Instantly share code, notes, and snippets.

@denis-bz
denis-bz / countpy
Created Aug 7, 2020
count number of /example*.py, other *.py in .zip or .whl 7 Aug 2020
View countpy
#!/bin/bash
# count number of /example*.py, other *.py in .zip or .whl or .tar.gz
# to look through Python packages
# PKG.whl: pip download -d . --only-binary :all: --no-deps PKG # wheel
# PKG.tar.gz: pip download -d . --no-binary :all: --no-deps PKG # sdist
# PKG.zip: download from github -- may have more examples
[[ $1 ]] ||
set -- `ls *.whl *.zip *.tar.gz 2> /dev/null`
@denis-bz
denis-bz / 0-How-to-make-a-Python-package-for-other-people-to-use.md
Created Jul 27, 2020
How to make a Python package for other people to use 27 Jul 2020
View 0-How-to-make-a-Python-package-for-other-people-to-use.md

How to make a Python package for other people to use

Keywords, tags: python packaging setup.py setuptools

Purpose: describe how to make a "package" of a Python program for other people to use. This introduction builds on the excellent oa-packaging-guide-preview.readthedocs.io — read that first.

@denis-bz
denis-bz / 5letterwords
Created Jul 17, 2020
5-letter words not in Knuth's words.dat of 5758 words
View 5letterwords
source less-or-grep.sh # less or grep this file
# more 5-letter words not in Knuth's words.dat of 5758 words
# The Stanford GraphBase 0321606329 p. 41: words.dat closed
dunch
taiga
abjad a consonantal alphabet, too ugly a word to catch on: McEvedy ancient p. 42
adust burnt, gloomy
@denis-bz
denis-bz / 0-eigvals-numpy-scipy.md
Last active Jul 16, 2020
Do numpy and scipy use different LAPACK drivers for eigvalsh ? 3 Jul 2020
View 0-eigvals-numpy-scipy.md

Do numpy and scipy use different LAPACK drivers for eigvalsh on macos ?

eigvals-numpy-scipy.py below runs numpy vs scipy eigvalsh on a dense random matrix:

np.linalg.eigvalsh: 201 sec
scipy.linalg.eigvalsh: 83 sec  driver ev
scipy.linalg.eigvalsh: 84 sec  driver evd

Maybe this is only on macos ?

@denis-bz
denis-bz / 0-Shift-invert-in-pictures.md
Created Jul 2, 2020
How shift-invert finds eigenvalues, in pictures 2 Jul 2020
View 0-Shift-invert-in-pictures.md

How shift-invert finds eigenvalues, in pictures

Keywords: eigenvalues, eigenvectors, shift-invert, ARPACK, scipy, python

Pictures first:

shiftinvert-randomsparse-n100

Background

@denis-bz
denis-bz / 0-umfpack-setup.py
Created Jun 26, 2020
How to make scikit-umfpack with scipy 1.5 openblas 26 Jun 2020
View 0-umfpack-setup.py
#!/usr/bin/env python
"""How to make scikit-umfpack with scipy 1.5 openblas
The scipy sparse linear solver `spsolve( A, b )` can be ~ 50 times faster
when scikit-umfpack is installedC -- see *spsolve-umfpack-random.log .
This is a bare-bones HowTo, a simple setup.py script with which `pip install` works on my mac.
(Else pip: no swig, no __umfpack*.so ??)
However I'm no setup.py maven, comments welcome
@denis-bz
denis-bz / 0-Eigplots.md
Last active Jun 20, 2020
Plots of some eigenvalues and eigenvectors 20 Jun 2020
View 0-Eigplots.md

Plots of some eigenvalues and eigenvectors

Keywords: eigenvalues, eigenvectors, test-matrix, scipy, python

Eigenvectors of Suitesparse Norris/fv1

27feb2020-Suitesparse-Norris-fv1-evecs

See SuiteSparse Matrix Collection / Norris, "Finite element modelling of human body parts, Laplace equation on a 2D mesh".

@denis-bz
denis-bz / avblocks.py
Created Jun 16, 2020
average e.g. 4 x 4 blocks in a sparse matrix A 16 Jun 2020
View avblocks.py
#!/usr/bin/env python
"""average e.g. 4 x 4 blocks in a sparse matrix A
N x N -> N/4 x N/4, nnz roughly *= blksize
why: reduce big matrices to plot, q+d approximate inverse
Keywords: sparse-matrix, python, scipy, data-compression
"""
# pretty fast -- coo sums duplicate (i,j) entries
from __future__ import division, print_function
@denis-bz
denis-bz / cheblinop.py
Created Jun 7, 2020
Chebyshev series of matrices 7 Jun 2020
View cheblinop.py
#!/usr/bin/env python
"""Chebyshev series of matrices
polyD = Cheblinop( A, [c0 c1 c2 ...] ) # a LinearOperator
A: a square numpy array
| scipy.sparse matrix
| scipy.sparse LinearOperator
coefs: [c0 c1 ...] arraylike
| numpy Chebyshev polynomial T( coefs [, domain=] )
| filename to polyload
@denis-bz
denis-bz / 0-covid19-per100000-perweek-allgermany.md
Created May 25, 2020
Covid-19 cases per 100000 population per week in Germany 25 May 2020
View 0-covid19-per100000-perweek-allgermany.md

Covid-19 cases per 100000 population per day / per week in Germany

Keywords: Covid-19, Germany, python, pandas

With data from jgehrcke/covid-19-germany-gae and ags-population data from destatis.de, the python programs here write reports like

You can’t perform that action at this time.