Skip to content

Instantly share code, notes, and snippets.

@ljwolf
ljwolf / gist:61bbfdb70852e4d40aac
Created November 19, 2014 04:32
folium_notebook
{
"metadata": {
"name": "",
"signature": "sha256:757bae3d1c46461b74ec91af4b14ba7c0b8aa312faf196602171864e35bfed90"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@ljwolf
ljwolf / gist:7498bb6eab38b199d1bd
Created January 14, 2015 01:27
Floyd Warshall for PySAL Networks
import pysal as ps
#Lots of reload for dev.
try:
reload(network)
except:
import network
try:
reload(analysis)
@ljwolf
ljwolf / fw.py
Created February 18, 2015 20:47
Floyd-Warshall for PySAL Networks
#!/bin/python
##ljw
##./$GIT_ROOT/pysal/network/fw.py
from collections import defaultdict
import pysal as ps
import numpy as np
ntw = ps.network.network.Network(ps.examples.get_path('geodanet/streets.shp'))
def floyd_warshall(ntw, cost = None, directed = False):
@ljwolf
ljwolf / esda: test_smoothing.py
Last active August 29, 2015 14:24
Pysal 2to3 nose errors
................F...
======================================================================
FAIL: test_assuncao_rate (__main__.TestUtils)
----------------------------------------------------------------------
Traceback (most recent call last):
File "pysal/esda/tests/test_smoothing.py", line 236, in test_assuncao_rate
exp_assuncao, sm.assuncao_rate(e, b)[:4])
File "/usr/lib/python3.4/site-packages/numpy/testing/utils.py", line 842, in assert_array_almost_equal
precision=decimal)
File "/usr/lib/python3.4/site-packages/numpy/testing/utils.py", line 665, in assert_array_compare
@ljwolf
ljwolf / induce.py
Last active April 15, 2016 23:19
inducing bug #587
import pysal as ps
import numpy as np
df = ps.pdio.read_files(ps.examples.get_path('columbus.shp'))
W = ps.queen_from_shapefile(ps.examples.get_path('columbus.shp'))
y = df['HOVAL'].values
y.reshape(W.n,1)
X = df[['CRIME', 'INC']].values
@ljwolf
ljwolf / A Model Proposal.ipynb
Last active May 20, 2016 20:42
RFC for ljwolf's GSOC
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Notes from ljwolf's GSOC call, 5/23

  • Blog posts proceeding fine, should be simple to continue making them on schedule, at the pace at which I blog normally.
  • Questions about Request for Comment:
    • What should I prioritize? NOGR or Labeled Array Interface?
      • Labeled Array. This is critical to get correct, and will make NOGR need and scope clearer.
  • How deep into PySAL should the Labeled Array interface go?
@ljwolf
ljwolf / final_submission.ipynb
Last active February 14, 2017 18:09
Overview of Labelled Array Development work
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ljwolf
ljwolf / rolling_strings.py
Last active June 14, 2018 19:15
Pandas Rolling String example
import pandas as pd
import string
df = pd.DataFrame([[*string.ascii_letters[0:26:2]],
*string.ascii_letters[1:26:2]])
rolled = df.rolling(window=2, center=False, axis=1).apply(lambda x: ''.join(x))
#expected: [['ac', 'ce', 'eg', 'gi', 'ik', 'km', 'mo', 'oq', 'qs', 'su', 'uw', 'wy'],
# 'bd', 'df', 'fh', 'hj', 'jl', 'ln', 'np', 'pr', 'rt', 'tv', 'vx', 'xz']]
print(rolled.values)
@ljwolf
ljwolf / divergent_convergence_diags.ipynb
Created September 29, 2016 04:11
While poking around some traces, I was surprised by discrepancies between PyMC3 and the R CODA package for convergence diagnostics. So, I documented the differences I saw in one of the estimators in the following notebook.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.