Skip to content

Instantly share code, notes, and snippets.

View almarklein's full-sized avatar

Almar Klein almarklein

View GitHub Profile
class PointSet(np.ndarray):
""" The PointSet class can be used to represent sets of points or
vectors, as well as singleton points. The dimensionality of the
vectors in the pointset can be anything, and the dtype can be any
of those supported by numpy.
This class inherits from np.ndarray, which makes it very flexible;
you can threat it as a regular array, and also pass it to functions
that require a numpy array. The shape of the array is NxD, with N
the number of points, and D the dimensionality of each point.
@almarklein
almarklein / git_black_magic.py
Created August 23, 2013 19:49
Some tools for analyzing the files (also deleted files) in the repo and removing them completely from history. Warning: black magic is involved, and the commit hashes will be changed.
#!/usr/bin/env python3
"""
Functionality for cleaning up your git repository.
This uses commands found on:
https://help.github.com/articles/remove-sensitive-data
"""
from skimage.graph.heap import BinaryHeap as BinaryHeap_sk
import time
VALUE_T = nb.float64
REFERENCE_T = nb.int32
@nb.jit # jit is slightly faster, compile time for autojit is ~2s
class BinaryHeap:
@nb.void(nb.int32)
@almarklein
almarklein / gist:5683681
Last active July 1, 2021 13:42
Visualize marching cubes output
import skimage.measure
import skimage.morphology
import visvis as vv
from visvis.utils import iso
import numpy as np
def ball(radius, dtype=np.uint8):
# New from skimage.morphology
class MouseEvent(Event):
""" Class describing mouse events.
Input arguments
---------------
source : object
The visualization object that this event is created from or applies to.
type : str
string indicating the event type (e.g. mouse_press, key_release)
kwds : keyword arguments