Skip to content

Instantly share code, notes, and snippets.

View asford's full-sized avatar

Alex Ford asford

View GitHub Profile
@ufechner7
ufechner7 / linalg_3.py
Created April 1, 2015 11:07
Fast linear algebra for 3D vectors using numba 0.17 or newer
# -*- coding: utf-8 -*-
"""
* This file is part of FreeKiteSim.
*
* FreeKiteSim -- A kite-power system power simulation software.
* Copyright (C) 2013 by Uwe Fechner, Delft University
* of Technology, The Netherlands. All rights reserved.
*
* FreeKiteSim is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@hgrecco
hgrecco / tasks.py
Last active June 22, 2022 07:49
Simple concurrent tasks with dependencies in Python.
from collections import defaultdict
import concurrent.futures
class TasksGroup(object):
"""A group of tasks with dependencies.
>>> tasks = TasksGroup()
>>> @tasks.add()
@tmcw
tmcw / xyz_vs_tms.md
Last active April 3, 2024 06:18
The difference between XYZ and TMS tiles and how to convert between them

The difference between XYZ and TMS tiles and how to convert between them

Lots of tile-based maps use either the XYZ or TMS scheme. These are the maps that have tiles ending in /0/0/0.png or something. Sometimes if it's a script, it'll look like &z=0&y=0&x=0 instead. Anyway, these are usually maps in Spherical Mercator.

Good examples are OpenStreetMap, Google Maps, MapBox, MapQuest, etc. Lots of maps.

Most of those are in XYZ. The best documentation for that is slippy map tilenames on the OSM Wiki, and Klokan's Tiles a la Google.

@ogrisel
ogrisel / class_def_pickling.py
Last active December 10, 2015 17:48
Pickling class definitions for IPython.parallel
import inspect
from pickle import loads, dumps
from IPython.utils import pickleutil
def class_dumps(cls):
canned_dict = pickleutil.canDict(
dict((k, v) for k, v in cls.__dict__.items()
if k not in ('__weakref__', '__dict__')))
parents = tuple(cls.mro())
@seberg
seberg / rolling_window.py
Created October 10, 2012 14:38
Multidimensional rolling_window for numpy
def rolling_window(array, window=(0,), asteps=None, wsteps=None, axes=None, toend=True):
"""Create a view of `array` which for every point gives the n-dimensional
neighbourhood of size window. New dimensions are added at the end of
`array` or after the corresponding original dimension.
Parameters
----------
array : array_like
Array to which the rolling window is applied.
window : int or tuple