This file contains 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 | |
def predict(*features): | |
""" Performs a prediction on the features. | |
Parameters | |
---------- | |
features : List[float] | |
The feature values the model needs to make a prediction. | |
This file contains 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 average_agreement(list1, list2, max_depth): | |
# Empty lists evaluate to false. | |
if (not list1) or (not list2): | |
return 0.0 | |
### NEW CODE ### | |
# Truncate the depth | |
max_list_len = max(len(list1), len(list2)) | |
max_depth = min(max_depth, max_list_len) |
This file contains 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
from hypothesis import given, settings # <- NEW CODE | |
from hypothesis.strategies import lists, integers | |
@given( | |
list1=lists(integers(min_value=1)), | |
list2=lists(integers(min_value=1)), | |
depth=integers(min_value=1) | |
) | |
@settings(deadline=300) # <- NEW CODE | |
def test_average_agreement_properties(list1, list2, depth): |
This file contains 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 average_agreement(list1, list2, max_depth): | |
agreements = [] | |
for depth in range(1, max_depth+1): | |
set1 = set(list1[:depth]) | |
set2 = set(list2[:depth]) | |
intersection = set1 & set2 | |
This file contains 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 average_agreement(list1, list2, max_depth): | |
### NEW CODE ### | |
# Empty lists evaluate to false. | |
if (not list1) or (not list2): | |
return 0.0 | |
agreements = [] | |
for depth in range(1, max_depth+1): |
This file contains 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
from hypothesis import given | |
from hypothesis.strategies import lists, integers | |
@given( | |
list1=lists(integers(min_value=1)), | |
list2=lists(integers(min_value=1)), | |
depth=integers(min_value=1) | |
) | |
def test_average_agreement_properties(list1, list2, depth): | |
This file contains 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 aiohttp | |
import asyncio | |
import json | |
from toolz import get_in, assoc, concat | |
url = "http://localhost:9200" | |
index = "stocks" | |
doc_type = "stock" |
This file contains 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 pandas as pd | |
import matplotlib.pyplot as plt | |
import cartopy.crs as ccrs | |
import cartopy.feature as cfeature | |
import cartopy.io.shapereader as shpreader | |
from shapely.ops import cascaded_union | |
non_conus_states = {'VI', 'AK', 'HI', 'PR', 'GU', 'MP', 'AS'} |
This file contains 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
(ns gorilla-to-markdown.core | |
(:require [clojure.string :as str] | |
[cheshire.core :as json])) | |
(defn- process-output-json | |
"Builds the HTML from the output JSON. | |
Assumes the JSON has already been parsed, and that j is a map." | |
[j] | |
(case (:type j) | |
"html" (:content j) |
This file contains 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
using DataFrames | |
keys = rand(1:100000, 500000); | |
values = randn(length(keys)); | |
df = DataFrame(); | |
df[:KEY] = keys; | |
df[:VALUE] = values; | |
@time by(df, :KEY, x -> sum(x[:VALUE])); |
NewerOlder