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
""" | |
Test Harness | |
This module provides a set of utility functions and decorators to assist with | |
conditional test execution, platform-specific checks, and test result reporting | |
when running pytest tests locally. | |
It includes functionality to: | |
- Check the platform and Python implementation (e.g., ARM architecture, Windows, macOS, PyPy). |
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
# cython: language_level=3 | |
# cython: nonecheck=False | |
# cython: cdivision=True | |
# cython: initializedcheck=False | |
# cython: infer_types=True | |
# cython: wraparound=True | |
# cython: boundscheck=False | |
""" | |
This is a Cython memory pool, it reserves a block of memory and supports reading and writing |
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
""" | |
LRU-K evicts the page whose K-th most recent access is furthest in the past. | |
This is a basic implementation of LRU-2, which evicts entries according to the time | |
of their penultimate access. The main benefit of this approach is to prevent | |
a problem when the items being checked exceeds the number of items in the cache. A | |
classic LRU will evict and repopulate the cache for every call. LRU-2 reduces the | |
likelihood of this, but not preferring the MRU item to be retained. | |
LRU-K should be used in conjunction with eviction limits per query - this appears to |
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
function colorGradient(colors, fadeFraction) { | |
if (fadeFraction >= 1) { | |
return colors[colors.length - 1] | |
} else if (fadeFraction <= 0) { | |
return colors[0] | |
} | |
let fade = fadeFraction * (colors.length - 1); | |
let interval = Math.trunc(fade); | |
fade = fade - interval |
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
""" | |
Grammar: | |
======== | |
Expression --> AndTerm { OR AndTerm}+ | |
AndTerm --> Condition { AND Condition}+ | |
Condition --> Terminal (>,<,>=,<=,==) Terminal | (Expression) | |
Terminal --> Number or String or Variable | |
Usage: | |
====== |
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 matplotlib import pyplot as plt # type:ignore | |
from mabel.data.formats import dictset | |
import numpy as np # type:ignore | |
def bollinger_bands(series, length=20, sigmas=2): | |
index = 0 | |
window = series[0:length] | |
num_vals = len(window) |
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
bar_chars = (' ', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█') | |
def _draw_histogram(bins): | |
mx = max([v for k,v in bins.items()]) | |
bar_height = (mx / 7) | |
if mx == 0: | |
return ' ' * len(bins) | |
histogram = '' | |
for k,v in bins.items(): |
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
""" | |
B+Tree Code Adapted From: | |
https://gist.github.com/savarin/69acd246302567395f65ad6b97ee503d | |
No explicit license when accessed on 2nd March 2020. | |
Other code: | |
(C) 2021 Justin Joyce. |
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
""" | |
Threaded Google Cloud Storage Blob reader. | |
Reads a set of blobs parallel to speed up reading. Blobs are | |
read line by line, the usecase this was written for was jsonl | |
files, but any record-per-line format where you don't care | |
about the order of the lines should not have issues. | |
Limited performance testing reading a set of eight blobs, | |
4x 19Mb, 4x 5.4Mb in four threads ran in 20.1% of the time. |
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 datetime, re | |
from google.cloud import storage | |
from functools import lru_cache | |
try: | |
import ujson as json | |
except ImportError: | |
import json | |
def select_dictionary_values(dictionary, values): |
NewerOlder