Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 importlib | |
import inspect | |
def worthy(obj): | |
return inspect.isclass(obj) and hasattr(obj, 'partial_fit') | |
for _, submodule in inspect.getmembers(importlib.import_module('sklearn'), inspect.ismodule): | |
for _, obj in inspect.getmembers(submodule, worthy): | |
print(submodule.__name__, obj.__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
import numpy as np | |
cimport cython | |
cimport numpy as np | |
ctypedef np.uint_t uint | |
ctypedef np.uint8_t uint8 | |
@cython.boundscheck(False) |
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 pandas as pd | |
def iter_batches(X_y, batch_size): | |
x_batch = [None] * batch_size | |
y_batch = [None] * batch_size | |
j = 0 | |
for i, (x, y) in enumerate(X_y, start=1): |
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 abc | |
class Rule(abc.ABC): | |
def __init__(self, var_name): | |
self.var_name = var_name | |
@abc.abstractmethod | |
def __repr__(self): | |
"""String representation of the Python expression.""" |
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
"""Generic branch and leaf implementation.""" | |
import operator | |
import textwrap | |
import typing | |
class Op: | |
"""An operator that is part of a split.""" | |
__slots__ = "symbol", "func" |
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 math | |
import random | |
def poisson(l, rng=random): | |
"""From https://www.johndcook.com/blog/2010/06/14/generating-poisson-random-values/""" | |
L = math.exp(-l) | |
k = 0 | |
p = 1 | |
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 urllib.parse | |
import requests | |
import time | |
import xml.dom.minidom | |
def get_abbyy_transcription(doc, app, password): | |
proxies = {} | |
url_params = { |
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 itertools | |
def merge_components(cs): | |
while True: | |
for (i, a), (j, b) in itertools.combinations(enumerate(cs), 2): | |
if a[0] == b[0]: | |
a[1].extend(b[1]) | |
del cs[j] | |
break | |
else: |
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
<!DOCTYPE html> | |
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> | |
<div id="app"> | |
<div class="grid-container"> | |
<button class="grid-item" v-for="key in keys" @click="click(key[0], key[1])"> | |
{{ key[2] }} | |
</button> | |
</div> |