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 | |
import numpy as np | |
from itertools import product | |
from time import time | |
from functional import seq, pseq | |
from pipe import * | |
from typing import Callable |
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
from multiprocessing import Process, Queue, Event | |
from queue import Empty as QueueEmpty | |
from random import randint, seed | |
from time import monotonic as now | |
from datetime import timedelta | |
TASKS_COUNT = 12 | |
ARRAY_SIZE = 2_000_000 | |
POOL_SIZE = 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
import functools | |
import cv2 | |
from skimage import io | |
from PIL import Image | |
def time_logger(func): | |
@functools.wraps(func) | |
def wrapped(*args, **kwargs): |
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
class FunctionalWrapper(object): | |
def __init__(self, data): | |
self.data = data | |
def map(self, function): | |
"""Call `map` on the items in `data` using the provided `function`""" | |
return FunctionalWrapper(list(map(function, self.data))) | |
def reduce(self, function): | |
"""Call `reduce` on the items in `data` using the provided `function`""" | |
return list(reduce(function, self.data)) | |
def filter(self, function): |
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
#A plain vanilla BST | |
class BSTNode(object): | |
"""A node in the vanilla BST tree.""" | |
def __init__(self, parent, k): | |
"""Creates a node. | |
Args: | |
parent: The node's parent. |