Skip to content

Instantly share code, notes, and snippets.

@pv
pv / colorized_voronoi.py
Last active April 9, 2024 21:55
Colorized Voronoi diagram with Scipy, in 2D, including infinite regions
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import Voronoi
def voronoi_finite_polygons_2d(vor, radius=None):
"""
Reconstruct infinite voronoi regions in a 2D diagram to finite
regions.
Parameters
@pv
pv / splder.py
Created May 2, 2013 18:43
Derivative of B-spline in Python
r"""
Show how to compute a derivative spline.
Scipy's splines are represented in terms of the standard B-spline basis
functions. In short, a spline of degree ``k`` is represented in terms of the
knots ``t`` and coefficients ``c`` by:
.. math::
s(x) = \sum_{j=-\infty}^\infty c_{j} B^k_{j}(x)
import numpy as np
import scipy.linalg.blas
cdef extern from "f2pyptr.h":
void *f2py_pointer(object) except NULL
ctypedef int dgemm_t(
char *transa, char *transb,
int *m, int *n, int *k,
double *alpha,
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pv
pv / epsilon.py
Last active November 10, 2020 13:12
Wynn epsilon table algorithm
# -*- coding:utf-8 -*-
from __future__ import division, absolute_import, print_function
import sys
import math
import collections
try:
from math import inf, nan
except ImportError:
@pv
pv / timeit_asv_setup.py
Last active November 1, 2018 18:24
Timeit asv benchmark setup() routines, look for slow ones.
"""
Timeit asv benchmark setup() routines, look for slow ones.
Looks for benchmarks under './benchmarks/' directory.
"""
import os
import time
import itertools
import tempfile
import shutil
$ make diff
...
$ make diff
make -s run "PYTHON=/home/pauli/prj/scipy/cutestrunpy/env/bin/python" "SCRIPT=cutest_slsqp.py" PYCUTEST_CACHE="/home/pauli/prj/scipy/cutestrunpy/cache/installed" 2>&1|tee run-installed.log
1.1.0
==============================================================
| name | nit | nfev |success |cons_ok |ok_trust_constr|
--------------------------------------------------------------
| HS7 | 11 | 14 | 1 | 1 | 1 |
| HS10 | 11 | 12 | 1 | 1 | 1 |
@pv
pv / vg.log
Last active April 2, 2018 18:19
pypy3-2781-vg.log
$ pypy3
Python 3.5.3 (47bcad155e44, Mar 30 2018, 19:05:26)
[PyPy 5.11.0-alpha0 with GCC 7.3.1 20180303 (Red Hat 7.3.1-5)] on linux
$ OPT="-O0 -ggdb" pypy3 -mpip install numpy==1.14.2
$ cat runthis.py
import numpy as np
print(np.__file__, np.__version__)
x = np.zeros([1], dtype=int)
@pv
pv / Makefile
Last active August 12, 2017 15:08
LAPACK test suite makefile
#
# Makefile for running LAPACK testsuite
#
FC = gfortran
FFLAGS = -O2
LDFLAGS =
LIBS = -llapack -lblas
LD = $(FC)
AR = ar
! testdpotr_test_gh_2691.f90
!
! Direct Fortran translation of the Scipy test
! TestDpotr.test_gh_2691
!
subroutine garbage(okflag)
implicit none
integer, intent(out) :: okflag
double precision, dimension(3,3) :: a, a2
integer, parameter :: lwork = 100