name stringclasses 293
values | input_types listlengths 0 49 | output_type stringlengths 1 180 | code stringlengths 37 97.8k | dependencies listlengths 0 6 | lib_used listlengths 0 11 | imports listlengths 0 40 | line_count int64 3 155 | full_code stringlengths 51 996k | input_type_defs listlengths 1 11 ⌀ |
|---|---|---|---|---|---|---|---|---|---|
v0 | [] | float | def v0() -> float:
torch.cuda.synchronize()
return timeit.default_timer() | [] | [
"timeit",
"torch"
] | [
"import timeit",
"import torch",
"from torch.utils.benchmark.utils import common, cpp_jit",
"from torch.utils.benchmark.utils._stubs import TimerClass, TimeitModuleType",
"from torch.utils.benchmark.utils.valgrind_wrapper import timer_interface as valgrind_timer_interface"
] | 3 | """Timer class based on the timeit.Timer class, but torch aware."""
import enum
import timeit
import textwrap
from typing import Any, Callable, Dict, List, NoReturn, Optional, Type, Union
import numpy as np
import torch
from torch.utils.benchmark.utils import common, cpp_jit
from torch.utils.benchmark.utils._stubs imp... | null |
v0 | [
"int"
] | common.Measurement | def v0(self, v1: int=1000000) -> common.Measurement:
with common.set_torch_threads(self._task_spec.num_threads):
self._timer.timeit(number=max(int(v1 // 100), 1))
return common.Measurement(number_per_run=v1, raw_times=[self._timer.timeit(number=v1)], task_spec=self._task_spec) | [] | [
"torch"
] | [
"import torch",
"from torch.utils.benchmark.utils import common, cpp_jit",
"from torch.utils.benchmark.utils._stubs import TimerClass, TimeitModuleType",
"from torch.utils.benchmark.utils.valgrind_wrapper import timer_interface as valgrind_timer_interface"
] | 4 | """Timer class based on the timeit.Timer class, but torch aware."""
import enum
import timeit
import textwrap
from typing import Any, Callable, Dict, List, NoReturn, Optional, Type, Union
import numpy as np
import torch
from torch.utils.benchmark.utils import common, cpp_jit
from torch.utils.benchmark.utils._stubs imp... | null |
v0 | [
"int",
"Callable[[], float]",
"Callable[[List[float]], bool]",
"float",
"Optional[float]",
"Optional[Callable[[int, float], NoReturn]]"
] | List[float] | def v0(self, v1: int, v2: Callable[[], float], v3: Callable[[List[float]], bool], v4: float, v5: Optional[float]=None, v6: Optional[Callable[[int, float], NoReturn]]=None) -> List[float]:
v7 = 0.0
v8 = False
v9: List[float] = []
with common.set_torch_threads(self._task_spec.num_threads):
while v... | [] | [
"torch"
] | [
"import torch",
"from torch.utils.benchmark.utils import common, cpp_jit",
"from torch.utils.benchmark.utils._stubs import TimerClass, TimeitModuleType",
"from torch.utils.benchmark.utils.valgrind_wrapper import timer_interface as valgrind_timer_interface"
] | 15 | """Timer class based on the timeit.Timer class, but torch aware."""
import enum
import timeit
import textwrap
from typing import Any, Callable, Dict, List, NoReturn, Optional, Type, Union
import numpy as np
import torch
from torch.utils.benchmark.utils import common, cpp_jit
from torch.utils.benchmark.utils._stubs imp... | null |
v0 | [
"float"
] | int | def v0(self, v1: float) -> int:
with common.set_torch_threads(self._task_spec.num_threads):
v2 = np.median([self._timer.timeit(0) for v3 in range(5)])
v4 = 1
while True:
v5 = self._timer.timeit(v4)
v6 = v2 / v5
if v6 <= 0.0001 and v5 >= v1 / 1000:
... | [] | [
"numpy",
"torch"
] | [
"import numpy as np",
"import torch",
"from torch.utils.benchmark.utils import common, cpp_jit",
"from torch.utils.benchmark.utils._stubs import TimerClass, TimeitModuleType",
"from torch.utils.benchmark.utils.valgrind_wrapper import timer_interface as valgrind_timer_interface"
] | 13 | """Timer class based on the timeit.Timer class, but torch aware."""
import enum
import timeit
import textwrap
from typing import Any, Callable, Dict, List, NoReturn, Optional, Type, Union
import numpy as np
import torch
from torch.utils.benchmark.utils import common, cpp_jit
from torch.utils.benchmark.utils._stubs imp... | null |
v3 | [
"float",
"float",
"float",
"Optional[Callable[[int, float], NoReturn]]"
] | common.Measurement | def v3(self, v4: float=0.1, *, v5: float=0.01, v6: float=10.0, v7: Optional[Callable[[int, float], NoReturn]]=None) -> common.Measurement:
v8 = self._estimate_block_size(min_run_time=0.05)
def v9() -> float:
return self._timer.timeit(v8)
def v10(v11: List[float]) -> bool:
if len(v11) > 3:
... | [
{
"name": "v0",
"input_types": [
"List[float]"
],
"output_type": "bool",
"code": "def v0(v1: List[float]) -> bool:\n return True",
"dependencies": []
},
{
"name": "v2",
"input_types": [],
"output_type": "float",
"code": "def v2() -> float:\n return self._timer... | [
"torch"
] | [
"import torch",
"from torch.utils.benchmark.utils import common, cpp_jit",
"from torch.utils.benchmark.utils._stubs import TimerClass, TimeitModuleType",
"from torch.utils.benchmark.utils.valgrind_wrapper import timer_interface as valgrind_timer_interface"
] | 12 | """Timer class based on the timeit.Timer class, but torch aware."""
import enum
import timeit
import textwrap
from typing import Any, Callable, Dict, List, NoReturn, Optional, Type, Union
import numpy as np
import torch
from torch.utils.benchmark.utils import common, cpp_jit
from torch.utils.benchmark.utils._stubs imp... | null |
v3 | [
"Optional[Callable[[int, float], NoReturn]]",
"float"
] | common.Measurement | def v3(self, v4: Optional[Callable[[int, float], NoReturn]]=None, v5: float=0.2) -> common.Measurement:
v6 = self._estimate_block_size(v5)
def v7() -> float:
return self._timer.timeit(v6)
def v8(v9: List[float]) -> bool:
return True
v10 = self._threaded_measurement_loop(v6, v7, v8, min... | [
{
"name": "v0",
"input_types": [
"List[float]"
],
"output_type": "bool",
"code": "def v0(v1: List[float]) -> bool:\n return True",
"dependencies": []
},
{
"name": "v2",
"input_types": [],
"output_type": "float",
"code": "def v2() -> float:\n return self._timer... | [
"torch"
] | [
"import torch",
"from torch.utils.benchmark.utils import common, cpp_jit",
"from torch.utils.benchmark.utils._stubs import TimerClass, TimeitModuleType",
"from torch.utils.benchmark.utils.valgrind_wrapper import timer_interface as valgrind_timer_interface"
] | 10 | """Timer class based on the timeit.Timer class, but torch aware."""
import enum
import timeit
import textwrap
from typing import Any, Callable, Dict, List, NoReturn, Optional, Type, Union
import numpy as np
import torch
from torch.utils.benchmark.utils import common, cpp_jit
from torch.utils.benchmark.utils._stubs imp... | null |
v0 | [] | None | def v0(self) -> None:
if self._cfg_path and os.path.isfile(self._cfg_path):
if self.run_as_user:
subprocess.call(['sudo', 'rm', self._cfg_path], close_fds=True)
else:
os.remove(self._cfg_path)
try:
self._error_file.close()
except FileNotFoundError:
pas... | [] | [
"os",
"subprocess"
] | [
"import os",
"import subprocess"
] | 10 | #
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not... | null |
v0 | [
"torch.Tensor",
"int",
"bool"
] | WeightedRandomSampler | def v0(v1: torch.Tensor, v2: int=10, v3: bool=False) -> WeightedRandomSampler:
v4 = pd.qcut if v3 else pd.cut
v5 = torch.LongTensor(v4(v1.tolist(), v2, labels=False, duplicates='drop'))
v6 = torch.LongTensor([(v5 == t).sum() for v7 in torch.arange(v2)])
v8 = 1.0 / v6.float()
v9 = torch.zeros_like(v1... | [] | [
"pandas",
"torch"
] | [
"import pandas as pd",
"import torch",
"from torch import optim",
"from torch.utils.data import DataLoader, Subset, TensorDataset, WeightedRandomSampler"
] | 9 | """Train (basic) densely-connected oracle."""
import os
import time
import multiprocessing as mp
import pandas as pd
import torch
from torch import optim
from torch.utils.data import DataLoader, Subset, TensorDataset, WeightedRandomSampler
from profit.dataset.splitters import split_method_dict
from profit.models.to... | null |
v3 | [
"str",
"v0"
] | None | def v3(v4: str, v5: v0=os.environ) -> None:
if not v1(v5):
return
v6 = json.loads(v5['VCAP_SERVICES'])
for v7 in v6.get('user-provided', []):
if v7['name'] == v4:
for (v8, v9) in v7['credentials'].items():
v5[v8] = v9 | [
{
"name": "v1",
"input_types": [
"v0"
],
"output_type": "bool",
"code": "def v1(v2: v0=os.environ) -> bool:\n return 'VCAP_SERVICES' in v2",
"dependencies": []
}
] | [
"json"
] | [
"import json"
] | 8 | import os
import json
Environ = os._Environ
def is_on_cloudfoundry(env: Environ=os.environ) -> bool:
return 'VCAP_SERVICES' in env
def load_cups_from_vcap_services(name: str, env: Environ=os.environ) -> None:
'''
Detects if VCAP_SERVICES exists in the environment; if so, parses
it and imports all t... | [
"v0 = os._Environ"
] |
v3 | [
"str",
"str",
"v0"
] | str | def v3(v4: str, v5: str, v6: v0=os.environ) -> str:
if not v1(v6):
return
v7 = json.loads(v6['VCAP_SERVICES'])
v6['DATABASE_URL'] = v7[v5][0]['credentials']['uri'] | [
{
"name": "v1",
"input_types": [
"v0"
],
"output_type": "bool",
"code": "def v1(v2: v0=os.environ) -> bool:\n return 'VCAP_SERVICES' in v2",
"dependencies": []
}
] | [
"json"
] | [
"import json"
] | 5 | import os
import json
Environ = os._Environ
def is_on_cloudfoundry(env: Environ=os.environ) -> bool:
return 'VCAP_SERVICES' in env
def load_cups_from_vcap_services(name: str, env: Environ=os.environ) -> None:
'''
Detects if VCAP_SERVICES exists in the environment; if so, parses
it and imports all t... | [
"v0 = os._Environ"
] |
v0 | [
"str"
] | Any | def v0(v1: str):
v1 = f'''{os.getenv('SHELL')} -c "{v1}"'''
v2 = subprocess.Popen(v1, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
v3 = ''
if v2.stdout is not None:
v3 = ''.join([line.decode('utf-8') for v4 in iter(v2.stdout.readline, b'')])
v2.stdout.close()
v5 = v2... | [] | [
"os",
"subprocess"
] | [
"import os",
"import subprocess"
] | 10 | """
Input: tsv file in the form
Input Video filename | topic | subtopic | title greek | title english | start time | end time | delete segments
input.mp4 | 1 | 1 | έξοδος | output | 00:10:05 | 00:30:10 | 00:11:15-00:12:30,00:20:35-00:22:10
"""
import os
import subprocess
import sys... | null |
v0 | [
"str"
] | Any | def v0(self, v1: str):
v2 = self.layer.edge_color_mode
try:
self.layer.edge_color = v1
self.layer.edge_color_mode = v2
except TypeError:
self._on_edge_color_mode_change()
raise | [] | [] | [] | 8 | import numpy as np
from qtpy.QtCore import Qt
from qtpy.QtWidgets import QComboBox, QDoubleSpinBox, QLabel
from ...layers.utils._color_manager_constants import ColorMode
from ...utils.translations import trans
from ..utils import qt_signals_blocked
from ..widgets.qt_color_swatch import QColorSwatchEdit
from .qt_layer_... | null |
v0 | [
"str"
] | Any | def v0(self, v1: str):
v2 = self.layer.edge_color_mode
with self.layer.events.edge_color_mode.blocker():
try:
self.layer.edge_color_mode = v1
self._update_edge_color_gui(v1)
except ValueError:
self.layer.edge_color_mode = v2
raise | [] | [] | [] | 9 | import numpy as np
from qtpy.QtCore import Qt
from qtpy.QtWidgets import QComboBox, QDoubleSpinBox, QLabel
from ...layers.utils._color_manager_constants import ColorMode
from ...utils.translations import trans
from ..utils import qt_signals_blocked
from ..widgets.qt_color_swatch import QColorSwatchEdit
from .qt_layer_... | null |
v0 | [
"str"
] | Any | def v0(self, v1: str):
if v1 in ('cycle', 'colormap'):
self.edgeColorEdit.setHidden(True)
self.edge_color_label.setHidden(True)
self.color_prop_box.setHidden(False)
self.edge_prop_label.setHidden(False)
elif v1 == 'direct':
self.edgeColorEdit.setHidden(False)
self... | [] | [] | [] | 11 | import numpy as np
from qtpy.QtCore import Qt
from qtpy.QtWidgets import QComboBox, QDoubleSpinBox, QLabel
from ...layers.utils._color_manager_constants import ColorMode
from ...utils.translations import trans
from ..utils import qt_signals_blocked
from ..widgets.qt_color_swatch import QColorSwatchEdit
from .qt_layer_... | null |
End of preview. Expand in Data Studio
Functions-53K
fifty-three thousand samples of code, annotated with input and output types as well as any dependencies or libraries required for their use. completely anonymized variables. i anonymized all the variables to sort of low-pass a bunch of high frequency features... a model of the space should be smoother to navigate. what ever you think i'm doing with this it's cooler than that.
550k files from the stack -> 68k cleanly typed functions w/ dependencies -> variable names anonymized -> 53k de-duplicated w minhash+lsh
licenses: check https://hf.co/datasets/bigcode/the-stack
filtering libraries:
use the following:dataset.filter(lambda x: False not in [label in allowed_set for label in x['lib_used']])where
allowed_set is a subset of this list, which is the master list of allowed libraries in the dataset:
"math", "cmath", "random", "statistics", "fractions", "decimal", "numbers",
"itertools", "functools", "operator",
"collections", "array", "bisect", "heapq", "weakref", "enum", "typing",
"string", "re", "textwrap", "pprint", "reprlib", "difflib",
"hashlib", "hmac", "secrets", "base64", "binascii", "quopri", "uu",
"copy", "contextlib", "abc", "dataclasses", "warnings", "gc",
"datetime", "calendar",
"inspect", "traceback", "ast", "tokenize", "keyword", "dis", "sys",
"json", "csv", "marshal",
"uuid",
"numpy", "scipy", "sympy", "sklearn", "statsmodels", "xgboost", "tqdm",
"shapely", "PyWavelets", "z3", "cvxpy",
"os", "io", "pathlib", "glob", "fnmatch", "linecache", "tempfile", "shutil",
"fileinput", "stat",
"pickle", "shelve", "dbm", "sqlite3",
"zipfile", "tarfile", "gzip", "bz2", "lzma", "zlib",
"configparser", "argparse", "getopt", "optparse", "logging", "getpass",
"profile", "cProfile", "pstats", "timeit", "tracemalloc", "faulthandler", "pdb",
"curses", "termios", "tty", "pty", "platform",
"plistlib", "netrc", "xdrlib", "mailbox", "mimetypes", "wave", "aifc",
"sndhdr", "imghdr", "colorsys", "chunk",
"sysconfig", "site", "resource",
"pandas", "matplotlib", "seaborn", "plotly", "torch", "tensorflow", "keras",
"gensim", "skimage", "PIL", "cv2", "nltk", "spacy", "dask", "polars",
"vaex", "h5py", "netCDF4", "xarray",
"Bio", "scikit-bio", "PyCogent",
"geopandas", "rasterio",
"rdkit", "openbabel", "pymatgen",
"astropy", "sunpy", "healpy",
"librosa",
"MDAnalysis", "OpenMM", "cartopy",
"subprocess", "shlex",
"socket", "ssl", "select", "selectors", "asyncio", "socketserver",
"http", "urllib", "ftplib", "poplib", "imaplib", "smtplib", "telnetlib",
"xmlrpc", "webbrowser", "cgi", "cgitb", "wsgiref", "http.server",
"threading", "multiprocessing", "concurrent", "queue", "sched",
"contextvars", "signal", "mmap",
"importlib", "runpy", "code", "codeop",
"ctypes", "cffi", "msvcrt", "winreg", "winsound", "posix", "pwd", "spwd",
"grp", "crypt", "fcntl", "syslog", "pipes",
"email",
"ossaudiodev", "audioop",
"bdb", "trace",
"transformers", "datasets", "requests", "beautifulsoup4", "selenium",
"folium", "qiskit"
- Downloads last month
- 9