This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
type StringValue struct { | |
Next *StringValue | |
Value string | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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 }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"runtime" | |
) | |
func qsort(data []int, mychan chan(bool)) { | |
if len(data) < 2 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |