Skip to content

Instantly share code, notes, and snippets.

View walkingpendulum's full-sized avatar

walkingpendulum walkingpendulum

View GitHub Profile
@walkingpendulum
walkingpendulum / main.py
Created August 3, 2017 09:49
asyncio tutorial
"""
$ python3 main.py
Compute 1 + 10 ...
Compute 10 - 1 ...
10 - 1 = 9
1 + 10 = 11
"""
import asyncio
import numpy as np
from itertools import combinations
Alearn=np.array([
[5.1, 3.5, 1.4, 0.2],
[4.9, 3.0, 1.4, 0.2],
[4.7, 3.2, 1.3, 0.2],
[4.6, 3.1, 1.5, 0.2],
[5.0, 3.6, 1.4, 0.2],
import numpy as np
from itertools import combinations
Alearn=np.array([
[5.1, 3.5, 1.4, 0.2],
[4.9, 3.0, 1.4, 0.2],
[4.7, 3.2, 1.3, 0.2],
[4.6, 3.1, 1.5, 0.2],
[5.0, 3.6, 1.4, 0.2],
import numpy as np
from itertools import combinations
Alearn=np.array([
[5.1, 3.5, 1.4, 0.2],
[4.9, 3.0, 1.4, 0.2],
[4.7, 3.2, 1.3, 0.2],
[4.6, 3.1, 1.5, 0.2],
[5.0, 3.6, 1.4, 0.2],
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
X, y = np.matrix([np.array([58.8,65.2,70.9,77.4,79.3,81.0,71.9,63.9,54.5,39.5,44.5,43.6,56.0,64.7,73.0,78.9,79.4]),np.array([7107,6373,6796,9208,14792,14564,11964,13526,12656,14119,16691,14571,13619,14575,14556,18573,15618]),np.array([21,22,22,20,25,23,20,23,20,20,22,19,22,22,21,21,22]),np.array([129,141,153,166,193,189,175,186,190,187,195,206,198,192,191,200,200]),np.array([0.26,1.48,1.58,1.70,0.43,0.35,-0.07,-0.03,-0.73,1.88,-0.18,0.08,0.97,-0.37,0.18,-0.88,-0.89])]).T,np.matrix(np.array([3067,2828,2891,2994,3082,3898,3502,3060,3211,3286,3542,3125,3022,2922,3950,4488,3295])).T
X = (X - X.mean(axis=0)) / X.std(axis=0)
import time
from itertools import zip_longest
import random
from multiprocessing import Process
def f(inflow_cache):
time.sleep(random.randint(2, 5))
inflow_cache = list(filter(lambda t: t is not None, inflow_cache))
class Tuple(tuple):
def __setitem__(self, key, value):
print('tuple setitem', key, value)
super().__setitem__(key, value)
def __getitem__(self, item):
print('tuple getitem', item)
return super().__getitem__(item)
@walkingpendulum
walkingpendulum / test.py
Created August 5, 2018 13:49
multiprocessing: shared mem vs separate mem
"""
$ dd if=/dev/urandom of=sample.txt bs=16M count=1
$ python test.py
shared:
process 44666, memory 1M
process 44667, memory 1M
process 44668, memory 1M
total: 9M
separate:
@walkingpendulum
walkingpendulum / inner_points.py
Last active December 18, 2018 21:13
check if point belongs to polygon
# coding: utf-8
import cmath
import unittest
from itertools import chain
def eq_to_zero(x, eps=1e-7):
return abs(x) < eps
@walkingpendulum
walkingpendulum / gist:710e47853da3661b7b3aca5becd695db
Created December 4, 2019 10:41
gdalinfo assumed and assumed>global>assumed diff
# diff -y <(gdalinfo alpha-48-manual-buffalo-preprocessed-data-2019-11-01-dem.scan.tms.float.assumed-2276-assumed.tif) <(gdalinfo alpha-48-manual-buffalo-preprocessed-data-2019-11-01-dem.scan.tms.float.assumed.tif)
Driver: GTiff/GeoTIFF Driver: GTiff/GeoTIFF
Files: alpha-48-manual-buffalo-preprocessed-data-2019-11-01-d | Files: alpha-48-manual-buffalo-preprocessed-data-2019-11-01-d
Size is 3355, 3692 Size is 3355, 3692
Coordinate System is: Coordinate System is:
PROJCS["NAD83 / Texas North Central (ftUS)", | LOCAL_CS["unnamed",
GEOGCS["NAD83", | UNIT["foot",0.3048,
DATUM["North_American_Datum_1983", | AUTHORITY["EPSG","9002"]]]
SPHEROID["GRS 1980",6378137,298.257222101, | Origin = (2499916.634541186038405,7183205.565398516133428)
AUTHORITY["EPSG","7019"]], | Pixel Size = (0.300000011920929,-0.300000011920929)