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 pathlib | |
| import sys | |
| import libcst as cst | |
| def main(root): | |
| root = pathlib.Path(root) | |
| fn = functools.partial(remove_annotations, annotations_remover=AnnotationRemover()) |
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 typing import Any | |
| from metadata_filter import MetadataFilter, MetadataFilterOperator | |
| # https://docs.trychroma.com/usage-guide#using-where-filters | |
| OPERATOR_MAP = { | |
| MetadataFilterOperator.AND: "$and", | |
| MetadataFilterOperator.OR: "$or", | |
| MetadataFilterOperator.EQ: "$eq", | |
| MetadataFilterOperator.NE: "$ne", |
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 unittest | |
| from concurrent.futures import ThreadPoolExecutor | |
| def multi_threaded(*, threads=2): | |
| def decorator(test_cls): | |
| for name, test_fn in test_cls.__dict__.copy().items(): | |
| if not (name.startswith("test") and callable(test_fn)): | |
| continue |
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 | |
| def haversine_distance_matrix(lats, longs): | |
| lats = np.radians(lats.reshape(-1, 1)) | |
| longs = np.radians(longs.reshape(1, -1)) | |
| return 2 * np.arcsin(np.sqrt((1 - np.cos(lats - lats.T) + np.cos(lats) * np.cos(lats.T) * (1 - np.cos(longs - longs.T))) / 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 re | |
| def delimited_case(s: str, *, delimiter: str) -> str: | |
| return re.sub( | |
| r"(([a-z0-9])(?=[A-Z][a-zA-Z0-9])|([A-Z0-9])(?=[A-Z0-9][a-z]))", | |
| rf"\1{delimiter}", | |
| re.sub(r"[^a-zA-Z0-9]+", delimiter, s), | |
| ) |
OlderNewer