Skip to content

Instantly share code, notes, and snippets.

import numpy as np
import matplotlib.pyplot as plt
def kalman_xy(x, P, measurement, R,
motion = np.matrix('0. 0. 0. 0.').T,
Q = np.matrix(np.eye(4))):
"""
Parameters:
x: initial state 4-tuple of location and velocity: (x0, x1, x0_dot, x1_dot)
P: initial uncertainty convariance matrix
MAX_TRACKS = 20
MAX_VECTORS = 200
SHOP_ID = 1
MAX_SECONDS_IN_THE_PAST = 30 * 60
from random import randint
from sklearn.datasets import make_regression
import numpy as np
import pylab
import time
public class Percolation {
private WeightedQuickUnionUF percolations;
private boolean[] state;
private int width;
public Percolation(int N) {
int total = N * N;
width = N;
percolations = new WeightedQuickUnionUF(total);
public class Percolation {
private WeightedQuickUnionUF percolations;
private boolean[] state;
private int width;
public Percolation(int N) {
int total = N * N;
width = N;
percolations = new WeightedQuickUnionUF(total);
package main
import (
"fmt"
)
type StringValue struct {
Next *StringValue
Value string
}
{
"name": "Daniel",
"friends": {
22: [
{ x: 22.4, z: 43.2, timestamp: 127386812 },
{ x: 22.4, z: 43.2, timestamp: 127386812 },
{ x: 22.4, z: 43.2, timestamp: 127386812 },
{ x: 22.4, z: 43.2, timestamp: 127386812 },
{ x: 22.4, z: 43.2, timestamp: 127386812 },
{ x: 22.4, z: 43.2, timestamp: 127386812 },
def get_field(self, field_name, **kwargs):
"""
Returns a field instance given a field name. The field can be either a forward
or reverse field
"""
if not apps.ready:
try:
return next(
f for f in opts.get_fields()
if f.name == field_name or f.attname == field_name
def test_get_fields_only_searaches_forward_on_apps_not_ready(self):
opts = Person._meta
# If apps registry is not ready, get_field() searches
# over only forward fields.
opts.apps.ready = False
# 'data_abstract' is a forward field, and therefore will be found
self.assertTrue(opts.get_field('data_abstract'))
package main
import (
"fmt"
"math/rand"
"runtime"
)
func qsort(data []int, mychan chan(bool)) {
if len(data) < 2 {
@PirosB3
PirosB3 / gist.rs
Last active August 29, 2015 14:07
fn qsort(data: &mut [int]) {
if data.len() < 2 {
return
} else {
let pivot = data[0];
let mut i = 1;
let mut j = data.len()-1;
while i <= j {
while (i <= j) && (data[i] <= pivot) {