name
stringclasses
844 values
input_types
listlengths
0
100
output_type
stringlengths
1
419
code
stringlengths
34
233k
dependencies
listlengths
0
6
lib_used
listlengths
0
11
imports
listlengths
0
66
line_count
int64
3
199
full_code
stringlengths
39
1.01M
input_type_defs
listlengths
1
12
v0
[]
None
def v0(self) -> None: with self.assertRaises(NotImplementedError): self._pathmgr.copy(self._remote_uri, self._remote_uri, foo='foo') with self.assertRaises(NotImplementedError): self._pathmgr.exists(self._remote_uri, foo='foo') with self.assertRaises(ValueError): self._pathmgr.get_lo...
[]
[]
[]
28
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import os import shutil import tempfile import unittest import uuid from contextlib import contextmanager from typing import Generator, Optional from unittest.mock import MagicMock, patch from iopath.common import file_io from iopath.common.file_...
null
v0
[]
None
def v0(self) -> None: with self.assertRaises(AssertionError): with self._pathmgr.open(self._remote_uri, 'w') as v1: v1.write('foobar')
[]
[]
[]
4
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import os import shutil import tempfile import unittest import uuid from contextlib import contextmanager from typing import Generator, Optional from unittest.mock import MagicMock, patch from iopath.common import file_io from iopath.common.file_...
null
v0
[]
None
def v0(self) -> None: with tempfile.NamedTemporaryFile(delete=True) as v1: v2 = v1.name with self._patch_download(): self._pathmgr.copy(self._remote_uri, v2) self.assertTrue(self._pathmgr.exists(v2)) self._pathmgr.rm(v2)
[]
[ "tempfile" ]
[ "import tempfile" ]
7
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import os import shutil import tempfile import unittest import uuid from contextlib import contextmanager from typing import Generator, Optional from unittest.mock import MagicMock, patch from iopath.common import file_io from iopath.common.file_...
null
v0
[ "str", "str", "str" ]
str
def v0(v1: str, v2: str, *, v3: str) -> str: v4 = os.path.join(v2, v3) with open(v4, 'w') as v5: v5.write('test') return v4
[]
[ "os" ]
[ "import os" ]
5
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import os import shutil import tempfile import unittest import uuid from contextlib import contextmanager from typing import Generator, Optional from unittest.mock import MagicMock, patch from iopath.common import file_io from iopath.common.file_...
null
v3
[ "Optional[v1]", "Optional[v0]" ]
np.ndarray
def v3(self, v4: Optional[v1]=None, v5: Optional[v0]=None) -> np.ndarray: if v4 is None: v6: Tuple = (...,) else: v6 = tuple((slice(*w) if isinstance(w, tuple) else w for v7 in v4)) @retry(on_exceptions=(RuntimeError, JSONDecodeError)) def v8() -> np.ndarray: return self.da[v6]....
[ { "name": "v2", "input_types": [], "output_type": "np.ndarray", "code": "@retry(on_exceptions=(RuntimeError, JSONDecodeError))\ndef v2() -> np.ndarray:\n return self.da[ix].values", "dependencies": [] } ]
[ "numpy" ]
[ "import numpy as np" ]
17
""" Zarr Storage driver for ODC Supports storage on S3 and Disk Should be able to handle hyperspectral data when ready. """ from contextlib import contextmanager from json.decoder import JSONDecodeError from typing import Any, Generator, Optional, Tuple, Union import numpy as np import xarray as xr from affine import...
[ "v0 = Tuple[int, ...]", "v1 = Tuple[Union[int, Tuple[int, int]], ...]" ]
v0
[ "torch.Tensor", "torch.Tensor" ]
Any
def v0(v1: torch.Tensor, v2: torch.Tensor): v2 = 2 * v2 return -0.5 * (1 + v2 - v1.pow(2) - v2.exp()).sum(-1)
[]
[]
[]
3
from typing import Sequence, Union from torch import nn import torch import math class InputPartlyTrainableLinear(nn.Module): """A linear layer with partially trainable input weights. The weights are divided into two parts, one of shape [I_trainable, O] is trainable, the other of shape [I_fixed, O] is fix...
null
v0
[ "torch.Tensor" ]
Any
def v0(self, v1: torch.Tensor): with torch.no_grad(): v2 = self.fixed(v1) if self.trainable_bias is not None: v2 = v2 + self.trainable_bias if self.n_trainable_output > 0: return torch.cat([v2, self.trainable(v1)], dim=-1) else: return v2
[]
[ "torch" ]
[ "from torch import nn", "import torch" ]
9
from typing import Sequence, Union from torch import nn import torch import math class InputPartlyTrainableLinear(nn.Module): """A linear layer with partially trainable input weights. The weights are divided into two parts, one of shape [I_trainable, O] is trainable, the other of shape [I_fixed, O] is fix...
null
v0
[]
Union[None, torch.Tensor]
def v0(self) -> Union[None, torch.Tensor]: v1 = [param for v2 in (self.fixed, self.trainable) if v2 is not None] if len(v1) == 2: return torch.cat(v1, dim=1) elif len(v1) == 1: return v1[0] else: return None
[]
[ "torch" ]
[ "from torch import nn", "import torch" ]
8
from typing import Sequence, Union from torch import nn import torch import math class InputPartlyTrainableLinear(nn.Module): """A linear layer with partially trainable input weights. The weights are divided into two parts, one of shape [I_trainable, O] is trainable, the other of shape [I_fixed, O] is fix...
null
v0
[ "str" ]
Iterable[Dict[str, str]]
def v0(v1: str) -> Iterable[Dict[str, str]]: v2 = requests.get(v1).content with zipfile.ZipFile(io.BytesIO(v2)) as v3: v4 = os.path.splitext(os.path.basename(v1))[0] with v3.open(v4) as v5: v6 = json.load(v5) v7 = {category['id']: category['name'] for v8 in v6['categories']} ...
[]
[ "io", "json", "logging", "os", "requests", "zipfile" ]
[ "import io", "import json", "import logging", "import os", "import zipfile", "import requests" ]
17
#!/usr/bin/env python # Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or...
null
v0
[ "Any", "str", "int", "int", "int" ]
Any
def v0(v1, v2: str, v3: int, v4: int, v5: int): v6 = {} if v1.sender: v6['sender'] = v1.sender.state_dict() if v1.visual_module: v6['visual_module'] = v1.visual_module.state_dict() if v1.receiver: v6['receiver'] = v1.receiver.state_dict() if v1.diagnostic_receiver: v6...
[]
[ "torch" ]
[ "import torch" ]
17
# Baseline setting in which there are only two agents # - no evolution import pickle import argparse import sys import torch # for logging of data import os import time import csv from itertools import zip_longest import datetime from helpers.game_helper import ( get_sender_receiver, get_trainer, get_tra...
null
v0
[ "Dict[int, List[int]]" ]
Generator[bytes, None, None]
def v0(v1: Dict[int, List[int]]) -> Generator[bytes, None, None]: for v2 in v1[1]: for v3 in v1[2]: for v4 in v1[3]: for v5 in v1[4]: for v6 in v1[5]: for v7 in v1[6]: for v8 in v1[7]: ...
[]
[]
[]
18
from collections import defaultdict from typing import Dict, Generator, List from .common import MULTIPLICATION_BY_2, MULTIPLICATION_BY_3, REVERSE_S_BOX, State def get_all_possible_keys(normal_state: State, faulty_state: State) -> List[Dict[int, List[int]]]: d1_equations = list(_compute_first_column(normal_state...
null
v0
[ "str", "str" ]
str
def v0(self, v1: str, v2: str) -> str: v3 = 'SELECT ID FROM Version WHERE wfName = %s AND version = %s;' v4 = self.__databaseTable.get_one(v3, (v1, v2)) return v4[0]
[]
[]
[]
4
import os.path from matflow.exceptionpackage import MatFlowException from matflow.database.DatabaseTable import DatabaseTable from matflow.workflow.workflow_instance import WorkflowInstance from matflow.workflow.database_version import DatabaseVersion from matflow.workflow.version_number import VersionNumber from path...
null
v0
[]
Dict[str, List[str]]
def v0(self) -> Dict[str, List[str]]: v1: Dict[str, List[str]] = {} v2 = 'SELECT DISTINCT v.wfName, vf.filename FROM Version v INNER JOIN VersionFile vf ON vf.versionID = v.ID;' v3 = self.__databaseTable.get_multiple(v2, ()) for (v4, v5) in v3: if v4 not in v1: v1[v4] = [v5] ...
[]
[]
[]
10
import os.path from matflow.exceptionpackage import MatFlowException from matflow.database.DatabaseTable import DatabaseTable from matflow.workflow.workflow_instance import WorkflowInstance from matflow.workflow.database_version import DatabaseVersion from matflow.workflow.version_number import VersionNumber from path...
null
v0
[ "str", "str" ]
Path
def v0(self, v1: str, v2: str) -> Path: v3 = 'SELECT cf.file \n FROM ConfFile cf INNER JOIN VersionFile vf \n ON cf.confKey = vf.confKey\n WHERE versionID = %s\n AND filename = %s\n ...
[]
[ "pathlib" ]
[ "from pathlib import Path" ]
6
import os.path from matflow.exceptionpackage import MatFlowException from matflow.database.DatabaseTable import DatabaseTable from matflow.workflow.workflow_instance import WorkflowInstance from matflow.workflow.database_version import DatabaseVersion from matflow.workflow.version_number import VersionNumber from path...
null
v102
[ "nn.Module", "Tensor", "Tensor", "Union[float, Tensor]", "float", "bool", "int", "int", "str", "int", "float", "bool", "bool", "bool" ]
Tensor
def v102(v103: nn.Module, v104: Tensor, v105: Tensor, v106: Union[float, Tensor], v107: float, v108: bool=False, v109: int=100, v110: int=1, v111: str='dlr', v112: int=1, v113: float=0.75, v114: bool=False, v115: bool=True, v116: bool=False) -> Tensor: assert v107 in [1, 2, float('inf')] v117 = v104.device ...
[ { "name": "v0", "input_types": [ "nn.Module", "Tensor", "Tensor", "Tensor", "float", "Optional[Tensor]", "bool", "int", "str", "int", "float" ], "output_type": "Tuple[Tensor, Tensor, Tensor, Tensor]", "code": "def v0(v1: nn.Module...
[ "functools", "math", "torch" ]
[ "import math", "from functools import partial", "import torch", "from torch import nn, Tensor", "from torch.nn import functional as F" ]
45
# Adapted from https://github.com/fra31/auto-attack import math from functools import partial from typing import Tuple, Optional, Union import torch from torch import nn, Tensor from torch.nn import functional as F from adv_lib.utils.losses import difference_of_logits_ratio def apgd(model: nn.Module, input...
null
v102
[ "nn.Module", "Tensor", "Tensor", "Union[float, Tensor]", "float", "bool", "int", "int", "str", "int", "float", "bool", "bool", "Optional[int]" ]
Tensor
def v102(v103: nn.Module, v104: Tensor, v105: Tensor, v106: Union[float, Tensor], v107: float, v108: bool=False, v109: int=100, v110: int=1, v111: str='dlr', v112: int=1, v113: float=0.75, v114: bool=False, v115: bool=True, v116: Optional[int]=None) -> Tensor: assert v108 == False v117 = v104.device v118 = ...
[ { "name": "v0", "input_types": [ "nn.Module", "Tensor", "Tensor", "Tensor", "float", "Optional[Tensor]", "bool", "int", "str", "int", "float" ], "output_type": "Tuple[Tensor, Tensor, Tensor, Tensor]", "code": "def v0(v1: nn.Module...
[ "functools", "math", "torch" ]
[ "import math", "from functools import partial", "import torch", "from torch import nn, Tensor", "from torch.nn import functional as F" ]
41
# Adapted from https://github.com/fra31/auto-attack import math from functools import partial from typing import Tuple, Optional, Union import torch from torch import nn, Tensor from torch.nn import functional as F from adv_lib.utils.losses import difference_of_logits_ratio def apgd(model: nn.Module, input...
null
v175
[ "nn.Module", "Tensor", "Tensor", "float", "float", "bool", "int", "bool", "int", "int", "str", "int", "float", "bool", "bool", "Optional[int]" ]
Tensor
def v175(v176: nn.Module, v177: Tensor, v178: Tensor, v179: float, v180: float, v181: bool=False, v182: int=20, v183: bool=False, v184: int=100, v185: int=1, v186: str='dlr', v187: int=1, v188: float=0.75, v189: bool=False, v190: bool=True, v191: Optional[int]=None) -> Tensor: v192 = v177.device v193 = len(v177...
[ { "name": "v0", "input_types": [ "nn.Module", "Tensor", "Tensor", "Tensor", "float", "Optional[Tensor]", "bool", "int", "str", "int", "float" ], "output_type": "Tuple[Tensor, Tensor, Tensor, Tensor]", "code": "def v0(v1: nn.Module...
[ "functools", "math", "torch" ]
[ "import math", "from functools import partial", "import torch", "from torch import nn, Tensor", "from torch.nn import functional as F" ]
19
# Adapted from https://github.com/fra31/auto-attack import math from functools import partial from typing import Tuple, Optional, Union import torch from torch import nn, Tensor from torch.nn import functional as F from adv_lib.utils.losses import difference_of_logits_ratio def apgd(model: nn.Module, input...
null
v0
[ "Tensor", "Tensor", "Tensor" ]
Tensor
def v0(v1: Tensor, v2: Tensor, v3: Tensor) -> Tensor: v4 = v1.device v5 = v1.shape (v1, v2) = (v1.flatten(1), v2.flatten(1)) v6 = v2.sign() v7 = torch.min(1 - v1 - v2, v1 + v2).clamp_max(0) v8 = -v2.abs() v9 = v7.clone() (v10, v11) = torch.sort(-torch.cat((v7, v8), dim=1), dim=1) v12...
[]
[ "math", "torch" ]
[ "import math", "import torch", "from torch import nn, Tensor", "from torch.nn import functional as F" ]
32
# Adapted from https://github.com/fra31/auto-attack import math from functools import partial from typing import Tuple, Optional, Union import torch from torch import nn, Tensor from torch.nn import functional as F from adv_lib.utils.losses import difference_of_logits_ratio def apgd(model: nn.Module, input...
null
v0
[ "Tensor", "int", "int", "float" ]
Tensor
def v0(v1: Tensor, v2: int, v3: int, v4: float=0.75) -> Tensor: v5 = torch.zeros_like(v1[0]) for v6 in range(v3): v5.add_(v1[v2 - v6] > v1[v2 - v6 - 1]) return v5 <= v3 * v4
[]
[ "torch" ]
[ "import torch", "from torch import nn, Tensor", "from torch.nn import functional as F" ]
5
# Adapted from https://github.com/fra31/auto-attack import math from functools import partial from typing import Tuple, Optional, Union import torch from torch import nn, Tensor from torch.nn import functional as F from adv_lib.utils.losses import difference_of_logits_ratio def apgd(model: nn.Module, input...
null
v0
[ "str" ]
Any
def v0(v1: str): v2 = {} with open(v1, 'r') as v3: for (v4, v5) in enumerate(v3.read().split('\n')): v2[v5] = v4 return v2
[]
[]
[]
6
import time import psutil import tensorflow as tf import tensorflow_hub as hub from cpuinfo import get_cpu_info # py-cpuinfo def print_device_info(): #################################### print("TF:", tf.__version__) #################################### print("Hub version:", hub.__version__) #####...
null
v0
[ "datetime", "int", "int", "bool" ]
typing.List
def v0(self, v1: datetime=None, v2: int=None, v3: int=None, v4: bool=False) -> typing.List: v5 = [] v6 = [] if v1: v5.append({'or': [['last_run_at', '<', v1], ['last_run_at', '=', None]]}) if v2: v5.append(['runs_unchanged', '>=', v2]) if v3: v5.append(['runs_unchanged', '<='...
[]
[]
[]
15
import typing from datetime import datetime from ioccontainer import provider, inject from runehistory_api.domain.models.account import Account from runehistory_api.app.repositories.account import AccountRepository class AccountService: def __init__(self, account_repository: AccountRepository): self.acc...
null
v0
[ "'Document'" ]
Any
def v0(self, v1: 'Document'): v1.adjacency = self._ref_doc.adjacency + 1 super().append(v1)
[]
[]
[]
3
from typing import ( TYPE_CHECKING, Iterable, ) from .memory import DocumentArrayInMemory if TYPE_CHECKING: from ..document import Document class MatchArray(DocumentArrayInMemory): """ :class:`MatchArray` inherits from :class:`DocumentArray`. It's a subset of Documents that represents the ma...
null
v0
[ "dict" ]
Any
def v0(self, v1: dict): v2 = v1.get(self.conf.namespace, {}) v2.update(user=self.user, pswd=self.pswd)
[]
[]
[]
3
# -*- coding: utf-8 -*- # Copyright Noronha Development Team # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
null
v0
[ "list" ]
list
def v0(v1: list) -> list: if any((not isinstance(x, int) or x < 0 for v2 in v1)): raise TypeError('Sequence must be list of non-negative integers') for v3 in range(len(v1)): for (v4, (v5, v6)) in enumerate(zip(v1, v1[1:])): if v5 > v6: v1[v4] -= v5 - v6 ...
[]
[]
[]
9
""" Bead sort only works for sequences of non-negative integers. https://en.wikipedia.org/wiki/Bead_sort """ def bead_sort(sequence: list) -> list: """ >>> bead_sort([6, 11, 12, 4, 1, 5]) [1, 4, 5, 6, 11, 12] >>> bead_sort([9, 8, 7, 6, 5, 4 ,3, 2, 1]) [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> bead_sor...
null
v0
[ "str" ]
int
def v0(self, v1: str) -> int: v1 = str(v1).lower() return int(self.user_info_by_username(v1).pk)
[]
[]
[]
3
from copy import deepcopy from json.decoder import JSONDecodeError from typing import Dict, List, Tuple from instagrapi import config from instagrapi.exceptions import ( ClientError, ClientJSONDecodeError, ClientLoginRequired, ClientNotFoundError, UserNotFound, ) from instagrapi.extractors import e...
null
v0
[]
bool
def v0(self) -> bool: v1 = self.private_request(f'feed/new_feed_posts_exist/') return v1.get('new_feed_posts_exist', False)
[]
[]
[]
3
from copy import deepcopy from json.decoder import JSONDecodeError from typing import Dict, List, Tuple from instagrapi import config from instagrapi.exceptions import ( ClientError, ClientJSONDecodeError, ClientLoginRequired, ClientNotFoundError, UserNotFound, ) from instagrapi.extractors import e...
null
v0
[ "int" ]
bool
def v0(self, v1: int) -> bool: assert self.user_id, 'Login required' v1 = int(v1) if v1 in self._users_following.get(self.user_id, []): self.logger.debug('User %s already followed', v1) return False v2 = self.with_action_data({'user_id': v1}) v3 = self.private_request(f'friendships/c...
[]
[]
[]
11
from copy import deepcopy from json.decoder import JSONDecodeError from typing import Dict, List, Tuple from instagrapi import config from instagrapi.exceptions import ( ClientError, ClientJSONDecodeError, ClientLoginRequired, ClientNotFoundError, UserNotFound, ) from instagrapi.extractors import e...
null
v0
[ "int" ]
bool
def v0(self, v1: int) -> bool: assert self.user_id, 'Login required' v1 = int(v1) v2 = self.with_action_data({'user_id': str(v1)}) v3 = self.private_request(f'friendships/remove_follower/{v1}/', v2) if self.user_id in self._users_followers: self._users_followers[self.user_id].pop(v1, None) ...
[]
[]
[]
8
from copy import deepcopy from json.decoder import JSONDecodeError from typing import Dict, List, Tuple from instagrapi import config from instagrapi.exceptions import ( ClientError, ClientJSONDecodeError, ClientLoginRequired, ClientNotFoundError, UserNotFound, ) from instagrapi.extractors import e...
null
v0
[ "int", "bool" ]
bool
def v0(self, v1: int, v2: bool=False) -> bool: v1 = int(v1) v3 = 'unmute' if v2 else 'mute' v4 = self.private_request(f'friendships/{v3}_posts_or_story_from_follow/', {'target_posts_author_id': str(v1), 'container_module': 'media_mute_sheet'}) return v4['status'] == 'ok'
[]
[]
[]
5
from copy import deepcopy from json.decoder import JSONDecodeError from typing import Dict, List, Tuple from instagrapi import config from instagrapi.exceptions import ( ClientError, ClientJSONDecodeError, ClientLoginRequired, ClientNotFoundError, UserNotFound, ) from instagrapi.extractors import e...
null
v78
[ "v0" ]
None
def v78(v79: v0) -> None: if False: v79.add_mypy('file setup.py', 'setup.py') v79.add_flake8('file setup.py', 'setup.py') v79.add_mypy('file runtests.py', 'runtests.py') v79.add_flake8('file runtests.py', 'runtests.py') v79.add_mypy('legacy entry script', 'scripts/mypy') v79.add_flake8('...
[]
[]
[]
13
#!/usr/bin/env python3 if False: import typing if True: # When this is run as a script, `typing` is not available yet. import sys from os.path import join, isdir def get_versions(): # type: () -> typing.List[str] major = sys.version_info[0] minor = sys.version_info[1] if ...
[ "class v0:\n\n def __init__(self, v1: List[str], v2: List[str], v3: List[str], v4: int, v5: List[str]) -> None:\n self.whitelist = v1\n self.blacklist = v2\n self.arglist = v3\n self.verbosity = v4\n self.waiter = Waiter(verbosity=v4, xfail=v5)\n self.versions = get_vers...
v0
[ "str" ]
str
def v0(v1: str) -> str: v2 = os.path.splitext(v1)[0].replace(os.sep, '.') if v2.endswith('.__init__'): v2 = v2[:-len('.__init__')] return v2
[]
[ "os" ]
[ "import os" ]
5
#!/usr/bin/env python3 if False: import typing if True: # When this is run as a script, `typing` is not available yet. import sys from os.path import join, isdir def get_versions(): # type: () -> typing.List[str] major = sys.version_info[0] minor = sys.version_info[1] if ...
null
v89
[ "v0" ]
None
def v89(v90: v0) -> None: for v91 in v81('mypy', suffix='.py'): v92 = v78(v91) if '.test.data.' in v92: continue v90.add_mypy_string('import %s' % v92, 'import %s' % v92) if not v92.endswith('.__main__'): v90.add_python_string('import %s' % v92, 'import %s' % ...
[ { "name": "v78", "input_types": [ "str" ], "output_type": "str", "code": "def v78(v79: str) -> str:\n v80 = os.path.splitext(v79)[0].replace(os.sep, '.')\n if v80.endswith('.__init__'):\n v80 = v80[:-len('.__init__')]\n return v80", "dependencies": [] }, { "name...
[ "os" ]
[ "import os" ]
9
#!/usr/bin/env python3 if False: import typing if True: # When this is run as a script, `typing` is not available yet. import sys from os.path import join, isdir def get_versions(): # type: () -> typing.List[str] major = sys.version_info[0] minor = sys.version_info[1] if ...
[ "class v0:\n\n def __init__(self, v1: List[str], v2: List[str], v3: List[str], v4: int, v5: List[str]) -> None:\n self.whitelist = v1\n self.blacklist = v2\n self.arglist = v3\n self.verbosity = v4\n self.waiter = Waiter(verbosity=v4, xfail=v5)\n self.versions = get_vers...
v89
[ "v0" ]
None
def v89(v90: v0) -> None: for v91 in v81('mypy', prefix='test', suffix='.py'): v92 = v78(v91) if '.codec.test.' in v92: v90.add_python_mod('unittest %s' % v92, 'unittest', v92) v90.add_python2('unittest %s' % v92, '-m', 'unittest', v92) elif v92 == 'mypy.test.testpyth...
[ { "name": "v78", "input_types": [ "str" ], "output_type": "str", "code": "def v78(v79: str) -> str:\n v80 = os.path.splitext(v79)[0].replace(os.sep, '.')\n if v80.endswith('.__init__'):\n v80 = v80[:-len('.__init__')]\n return v80", "dependencies": [] }, { "name...
[ "os" ]
[ "import os" ]
10
#!/usr/bin/env python3 if False: import typing if True: # When this is run as a script, `typing` is not available yet. import sys from os.path import join, isdir def get_versions(): # type: () -> typing.List[str] major = sys.version_info[0] minor = sys.version_info[1] if ...
[ "class v0:\n\n def __init__(self, v1: List[str], v2: List[str], v3: List[str], v4: int, v5: List[str]) -> None:\n self.whitelist = v1\n self.blacklist = v2\n self.arglist = v3\n self.verbosity = v4\n self.waiter = Waiter(verbosity=v4, xfail=v5)\n self.versions = get_vers...
v86
[ "v0" ]
None
def v86(v87: v0) -> None: for v88 in v78('samples', suffix='.py'): if 'codec' in v88: (v89, v90) = (os.path.dirname(v88), os.path.basename(v88)) v90 = v90[:-len('.py')] v87.add_mypy_string('codec file %s' % v88, 'import mypy.codec.register, %s' % v90, cwd=v89) els...
[ { "name": "v78", "input_types": [ "str", "str", "str" ], "output_type": "List[str]", "code": "def v78(v79: str, v80: str='', v81: str='') -> List[str]:\n return [join(root, f) for (v82, v83, v84) in os.walk(v79) for v85 in v84 if v85.startswith(v80) and v85.endswith(v81)]", ...
[ "os" ]
[ "import os" ]
8
#!/usr/bin/env python3 if False: import typing if True: # When this is run as a script, `typing` is not available yet. import sys from os.path import join, isdir def get_versions(): # type: () -> typing.List[str] major = sys.version_info[0] minor = sys.version_info[1] if ...
[ "class v0:\n\n def __init__(self, v1: List[str], v2: List[str], v3: List[str], v4: int, v5: List[str]) -> None:\n self.whitelist = v1\n self.blacklist = v2\n self.arglist = v3\n self.verbosity = v4\n self.waiter = Waiter(verbosity=v4, xfail=v5)\n self.versions = get_vers...
v0
[ "str" ]
bool
def v0(self, v1: str) -> bool: if any((f in v1 for v2 in self.whitelist)): if not any((v2 in v1 for v2 in self.blacklist)): if self.verbosity >= 2: print('SELECT #%d %s' % (len(self.waiter.queue), v1)) return True if self.verbosity >= 3: print('OMIT ...
[]
[]
[]
9
#!/usr/bin/env python3 if False: import typing if True: # When this is run as a script, `typing` is not available yet. import sys from os.path import join, isdir def get_versions(): # type: () -> typing.List[str] major = sys.version_info[0] minor = sys.version_info[1] if ...
null
v0
[ "str", "Optional[str]" ]
None
def v0(self, v1: str, *v3: str, v2: Optional[str]=None) -> None: self.add_mypy_string(v1, *v3, cwd=v2) self.add_python_string(v1, *v3, cwd=v2)
[]
[]
[]
3
#!/usr/bin/env python3 if False: import typing if True: # When this is run as a script, `typing` is not available yet. import sys from os.path import join, isdir def get_versions(): # type: () -> typing.List[str] major = sys.version_info[0] minor = sys.version_info[1] if ...
null
v0
[]
None
def v0(self) -> None: for (v1, v2) in enumerate(self.waiter.queue): print('{id}:{task}'.format(id=v1, task=v2.name))
[]
[]
[]
3
#!/usr/bin/env python3 if False: import typing if True: # When this is run as a script, `typing` is not available yet. import sys from os.path import join, isdir def get_versions(): # type: () -> typing.List[str] major = sys.version_info[0] minor = sys.version_info[1] if ...
null
v0
[]
None
def v0(self) -> None: if self.enable_cache is True: self.response = self.response_from_cache() else: self.response = self.response_from_upstream()
[]
[]
[]
5
""" This module contains objects for providing a RESTful proxy service; that is, an HTTP proxy which is controlled via RESTful requests. The APIRequestProxy object takes a simple dictionary which describes a proxy requext, instantiates the APIRequestProxyUpstream object to create the upstream request, and provides th...
null
v0
[ "Optional[Union[str, Set[str]]]", "Optional[Union[str, Set[str]]]", "Optional[Union[str, Set[str]]]", "Optional[Union[int, Set[int]]]", "Optional[Tuple[Optional[str], Optional[str]]]", "Optional[int]", "Optional[int]" ]
Iterable[str]
def v0(self, *, v1: Optional[Union[str, Set[str]]]=None, v2: Optional[Union[str, Set[str]]]=None, v3: Optional[Union[str, Set[str]]]=None, v4: Optional[Union[int, Set[int]]]=None, v5: Optional[Tuple[Optional[str], Optional[str]]]=None, v6: Optional[int]=None, v7: Optional[int]=None) -> Iterable[str]: v8 = self._get...
[]
[ "itertools" ]
[ "import itertools" ]
4
""" A collection of ~11k (almost all) speeches given by the main protagonists of the 2016 U.S. Presidential election that had previously served in the U.S. Congress -- including Hillary Clinton, Bernie Sanders, Barack Obama, Ted Cruz, and John Kasich -- from January 1996 through June 2016. Records include the followin...
null
v5
[ "int", "int", "int" ]
str
def v5(v6: int, v7: int, v8: int) -> str: def v9(v10, v11, v12, v13=0.001): return abs(1 - (v10 * v10 + v11 * v11) / (v12 * v12)) < v13 if v6 > 200 or v7 > 200 or v8 > 200: return 'InvalidInput' if v6 <= 0 or v7 <= 0 or v8 <= 0: return 'InvalidInput' if not (isinstance(v6, int) ...
[ { "name": "v0", "input_types": [ "Any", "Any", "Any", "Any" ], "output_type": "Any", "code": "def v0(v1, v2, v3, v4=0.001):\n return abs(1 - (v1 * v1 + v2 * v2) / (v3 * v3)) < v4", "dependencies": [] } ]
[]
[]
21
# -*- coding: utf-8 -*- """ Created on Thu Jan 14 13:44:00 2016 Updated Jan 21, 2018 The primary goal of this file is to demonstrate a simple python program to classify triangles @author: jrr @author: rk @ """ def classify_triangle(side1: int, side2: int, side3: int) -> str: """ Your correct code goes here....
null
v1
[ "v0", "List[int]", "List[int]", "List[int]", "Optional[List[int]]" ]
List[int]
def v1(v2: v0, v3: List[int], v4: List[int], v5: List[int], v6: Optional[List[int]]) -> List[int]: v7 = v2.size() v8 = torch.jit.annotate(List[int], []) for v9 in range(len(v3)): v8.append((v7[-len(v3) + v9] - 1) * v4[v9] + v3[v9] - 2 * v5[v9]) if v6 is None: v10 = v8 else: i...
[]
[ "torch", "typing" ]
[ "from typing import Callable, List, Optional, Tuple", "import torch", "from torch import _VF", "from torch._C import _infer_size, _add_docstr", "from torch._torch_docs import reproducibility_notes, tf32_notes" ]
19
r"""Functional interface""" from typing import Callable, List, Optional, Tuple import math import warnings import torch from torch import _VF from torch._C import _infer_size, _add_docstr from torch._torch_docs import reproducibility_notes, tf32_notes from .._jit_internal import boolean_dispatch, _overload, Broadcast...
[ "v0 = torch.Tensor" ]
v0
[ "str", "int", "int" ]
int
def v0(v1: str, v2: int, v3: int) -> int: warnings.warn('Implicit dimension choice for {} has been deprecated. Change the call to include dim=X as an argument.'.format(v1), stacklevel=v3) if v2 == 0 or v2 == 1 or v2 == 3: v4 = 0 else: v4 = 1 return v4
[]
[ "warnings" ]
[ "import warnings" ]
7
r"""Functional interface""" from typing import Callable, List, Optional, Tuple import math import warnings import torch from torch import _VF from torch._C import _infer_size, _add_docstr from torch._torch_docs import reproducibility_notes, tf32_notes from .._jit_internal import boolean_dispatch, _overload, Broadcast...
null
v1
[ "v0", "v0", "float", "float" ]
v0
def v1(v2: v0, v3: v0, v4: float, v5: float) -> v0: with torch.no_grad(): torch.embedding_renorm_(v2, v3, v4, v5)
[]
[ "torch" ]
[ "import torch", "from torch import _VF", "from torch._C import _infer_size, _add_docstr", "from torch._torch_docs import reproducibility_notes, tf32_notes" ]
3
r"""Functional interface""" from typing import Callable, List, Optional, Tuple import math import warnings import torch from torch import _VF from torch._C import _infer_size, _add_docstr from torch._torch_docs import reproducibility_notes, tf32_notes from .._jit_internal import boolean_dispatch, _overload, Broadcast...
[ "v0 = torch.Tensor" ]
v0
[ "List[int]" ]
None
def v0(v1: List[int]) -> None: v2 = v1[0] for v3 in range(len(v1) - 2): v2 *= v1[v3 + 2] if v2 == 1: raise ValueError('Expected more than 1 value per channel when training, got input size {}'.format(v1))
[]
[]
[]
6
r"""Functional interface""" from typing import Callable, List, Optional, Tuple import math import warnings import torch from torch import _VF from torch._C import _infer_size, _add_docstr from torch._torch_docs import reproducibility_notes, tf32_notes from .._jit_internal import boolean_dispatch, _overload, Broadcast...
null
v0
[ "List[int]" ]
None
def v0(v1: List[int]) -> None: v2 = 1 for v3 in range(2, len(v1)): v2 *= v1[v3] if v2 == 1: raise ValueError('Expected more than 1 spatial element when training, got input size {}'.format(v1))
[]
[]
[]
6
r"""Functional interface""" from typing import Callable, List, Optional, Tuple import math import warnings import torch from torch import _VF from torch._C import _infer_size, _add_docstr from torch._torch_docs import reproducibility_notes, tf32_notes from .._jit_internal import boolean_dispatch, _overload, Broadcast...
null
v1
[ "v0", "List[int]" ]
v0
def v1(v2: v0, v3: List[int]) -> v0: v4 = v2.shape v5 = v4[2:] v6 = len(v5) for (v7, v8) in enumerate(v5): assert v3[-(v7 * 2 + 1)] <= v8, 'Padding value causes wrapping around more than once.' assert v3[-(v7 * 2 + 2)] <= v8, 'Padding value causes wrapping around more than once.' ...
[]
[ "torch" ]
[ "import torch", "from torch import _VF", "from torch._C import _infer_size, _add_docstr", "from torch._torch_docs import reproducibility_notes, tf32_notes" ]
81
r"""Functional interface""" from typing import Callable, List, Optional, Tuple import math import warnings import torch from torch import _VF from torch._C import _infer_size, _add_docstr from torch._torch_docs import reproducibility_notes, tf32_notes from .._jit_internal import boolean_dispatch, _overload, Broadcast...
[ "v0 = torch.Tensor" ]
v5
[ "v0", "v0", "v0", "v0", "Optional[v0]" ]
List[v0]
def v5(v6: v0, v7: v0, v8: v0, v9: v0, v10: Optional[v0]=None) -> List[v0]: v11 = v6.size(-1) if v7 is v8: if v6 is v7: return v1(v6, v9, v10).chunk(3, dim=-1) else: (v12, v13) = v9.split([v11, v11 * 2]) if v10 is None: v14 = v15 = None ...
[ { "name": "v1", "input_types": [ "v0", "v0", "Optional[v0]" ], "output_type": "v0", "code": "def v1(v2: v0, v3: v0, v4: Optional[v0]=None) -> v0:\n if has_torch_function_variadic(v2, v3, v4):\n return handle_torch_function(v1, (v2, v3, v4), v2, v3, bias=v4)\n retur...
[ "torch" ]
[ "import torch", "from torch import _VF", "from torch._C import _infer_size, _add_docstr", "from torch._torch_docs import reproducibility_notes, tf32_notes" ]
19
r"""Functional interface""" from typing import Callable, List, Optional, Tuple import math import warnings import torch from torch import _VF from torch._C import _infer_size, _add_docstr from torch._torch_docs import reproducibility_notes, tf32_notes from .._jit_internal import boolean_dispatch, _overload, Broadcast...
[ "v0 = torch.Tensor" ]
v5
[ "v0", "v0", "v0", "v0", "v0", "v0", "Optional[v0]", "Optional[v0]", "Optional[v0]" ]
Tuple[v0, v0, v0]
def v5(v6: v0, v7: v0, v8: v0, v9: v0, v10: v0, v11: v0, v12: Optional[v0]=None, v13: Optional[v0]=None, v14: Optional[v0]=None) -> Tuple[v0, v0, v0]: (v15, v16, v17) = (v6.size(-1), v7.size(-1), v8.size(-1)) assert v9.shape == (v15, v15), f'expecting query weights shape of {(v15, v15)}, but got {v9.shape}' ...
[ { "name": "v1", "input_types": [ "v0", "v0", "Optional[v0]" ], "output_type": "v0", "code": "def v1(v2: v0, v3: v0, v4: Optional[v0]=None) -> v0:\n if has_torch_function_variadic(v2, v3, v4):\n return handle_torch_function(v1, (v2, v3, v4), v2, v3, bias=v4)\n retur...
[ "torch" ]
[ "import torch", "from torch import _VF", "from torch._C import _infer_size, _add_docstr", "from torch._torch_docs import reproducibility_notes, tf32_notes" ]
9
r"""Functional interface""" from typing import Callable, List, Optional, Tuple import math import warnings import torch from torch import _VF from torch._C import _infer_size, _add_docstr from torch._torch_docs import reproducibility_notes, tf32_notes from .._jit_internal import boolean_dispatch, _overload, Broadcast...
[ "v0 = torch.Tensor" ]
v17
[ "v0", "v0", "v0", "Optional[v0]", "float" ]
Tuple[v0, v0]
def v17(v18: v0, v19: v0, v20: v0, v21: Optional[v0]=None, v22: float=0.0) -> Tuple[v0, v0]: (v23, v24, v25) = v18.shape v18 = v18 / math.sqrt(v25) if v21 is not None: v26 = torch.baddbmm(v21, v18, v19.transpose(-2, -1)) else: v26 = torch.bmm(v18, v19.transpose(-2, -1)) v26 = v11(v26...
[ { "name": "v1", "input_types": [ "str", "int", "int" ], "output_type": "int", "code": "def v1(v2: str, v3: int, v4: int) -> int:\n warnings.warn('Implicit dimension choice for {} has been deprecated. Change the call to include dim=X as an argument.'.format(v2), stacklevel=v4...
[ "math", "torch", "warnings" ]
[ "import math", "import warnings", "import torch", "from torch import _VF", "from torch._C import _infer_size, _add_docstr", "from torch._torch_docs import reproducibility_notes, tf32_notes" ]
12
r"""Functional interface""" from typing import Callable, List, Optional, Tuple, Union import math import warnings import torch from torch import _VF from torch._C import _infer_size, _add_docstr from torch._torch_docs import reproducibility_notes, tf32_notes # A workaround to support both TorchScript and MyPy: from ty...
[ "v0 = torch.Tensor" ]
v5
[ "Any", "int" ]
Any
def v5(self, v6='', v7: int=15): if v6 == '': if v7 == 30: v6 = v0(self.edf_path, '.hypnogram.sta') else: v6 = v0(self.edf_path, '.hypnogram.txt') v8 = self.get_hypnogram(v7) np.savetxt(v6, v8, delimiter=',', fmt='%i')
[ { "name": "v0", "input_types": [ "Any", "Any" ], "output_type": "Any", "code": "def v0(v1, v2):\n (v3, v4) = os.path.splitext(v1)\n return v3 + v2", "dependencies": [] } ]
[ "numpy", "os" ]
[ "import os, sys, warnings", "import numpy as np" ]
8
# -*- coding: utf-8 -*- """ @author: jens @modifier: informaton inf_narco_biomarker --> inf_narco_app """ import json # for command line interface input and output. import os, sys, warnings from pathlib import Path import logging # from asyncore import file_dispatcher from datetime import datetime # from typing impor...
null
v0
[ "list", "list" ]
Any
def v0(v1: list, v2: list): v3 = [] for v4 in v1: v5 = True for v6 in v2: if v6 not in v4: v5 = False break if v5: v3.append(v4) return v3
[]
[]
[]
11
def corrPosFilter(dB: list, info: dict): #correct position filter if len(info) == 0: return dB res = list() if len(info) == 0: res = dB for item in dB: legal = True for letter in info: if(item[info[letter]...
null
v0
[ "list", "str", "Any" ]
Any
def v0(v1: list, v2: str, v3): v4 = [e for v5 in v1 if v5.startswith(v2)] v6 = [] for v7 in v4: v8 = copy.deepcopy(v3) v9 = v8.get_path(v7) v10 = [] for v11 in v9[-2].get_terminals(): v10.append(v11.name) v6.append(v10) return (v6, v4)
[]
[ "copy" ]
[ "import copy" ]
11
from collections import Counter import copy import re from Bio import Phylo from Bio import SeqIO def collapse_low_support_bipartitions(newtree, support: float): """ collapse bipartitions with support less than threshold """ newtree.collapse_all(lambda c: c.confidence is not None and c.confidence < ...
null
v19
[ "list", "list", "Any", "int", "str", "float", "dict", "list" ]
Any
def v19(v20: list, v21: list, v22, v23: int, v24: str, v25: float, v26: dict, v27: list): v22 = v3(v20, v21, v22) v22 = v0(v22, v25) (v23, v27) = v10(v24, v23, v21, v26, v27) return (v23, v27)
[ { "name": "v0", "input_types": [ "Any", "float" ], "output_type": "Any", "code": "def v0(v1, v2: float):\n v1.collapse_all(lambda c: c.confidence is not None and c.confidence < v2)\n return v1", "dependencies": [] }, { "name": "v3", "input_types": [ "list"...
[ "Bio" ]
[ "from Bio import Phylo", "from Bio import SeqIO" ]
5
from collections import Counter import copy import re from Bio import Phylo from Bio import SeqIO def collapse_low_support_bipartitions(newtree, support: float): """ collapse bipartitions with support less than threshold """ newtree.collapse_all(lambda c: c.confidence is not None and c.confidence < ...
null
v0
[ "Any", "dict", "list", "list" ]
Any
def v0(v1, v2: dict, v3: list, v4: list): v5 = dict() for v6 in v3: v5[v6] = len(re.sub('-', '', str(v2[v6].seq))) v7 = max(v5, key=v5.get) for (v8, v9) in v5.items(): if v8 != v7: v1.prune(v8) v4.remove(v8) return (v1, v4)
[]
[ "re" ]
[ "import re" ]
10
from collections import Counter import copy import re from Bio import Phylo from Bio import SeqIO def collapse_low_support_bipartitions(newtree, support: float): """ collapse bipartitions with support less than threshold """ newtree.collapse_all(lambda c: c.confidence is not None and c.confidence < ...
null
v0
[ "list", "list", "Any" ]
Any
def v0(v1: list, v2: list, v3): v4 = [i for v5 in v1 + v2 if v5 not in v1 or v5 not in v2] for v6 in v4: v3.prune(v6) return v3
[]
[]
[]
5
from collections import Counter import copy import re from Bio import Phylo from Bio import SeqIO def collapse_low_support_bipartitions(newtree, support: float): """ collapse bipartitions with support less than threshold """ newtree.collapse_all(lambda c: c.confidence is not None and c.confidence < ...
null
v0
[ "str", "str" ]
Any
def v0(v1: str, v2: str): v1 = Phylo.read(v1, 'newick') v1.root_at_midpoint() v2 = SeqIO.to_dict(SeqIO.parse(v2, 'fasta')) return (v1, v2)
[]
[ "Bio" ]
[ "from Bio import Phylo", "from Bio import SeqIO" ]
5
from collections import Counter import copy import re from Bio import Phylo from Bio import SeqIO def collapse_low_support_bipartitions(newtree, support: float): """ collapse bipartitions with support less than threshold """ newtree.collapse_all(lambda c: c.confidence is not None and c.confidence < ...
null
v0
[ "str", "int", "list", "dict", "list" ]
Any
def v0(v1: str, v2: int, v3: list, v4: dict, v5: list): v6 = f'{v1}.orthosnap.{v2}.fa' with open(v6, 'w') as v7: for v8 in v3: SeqIO.write(v4[v8], v7, 'fasta') v5.append(v8) v2 += 1 return (v2, v5)
[]
[ "Bio" ]
[ "from Bio import Phylo", "from Bio import SeqIO" ]
8
from collections import Counter import copy import re from Bio import Phylo from Bio import SeqIO def collapse_low_support_bipartitions(newtree, support: float): """ collapse bipartitions with support less than threshold """ newtree.collapse_all(lambda c: c.confidence is not None and c.confidence < ...
null
v0
[ "Any", "Any", "Any" ]
torch.Tensor
def v0(v1, v2, v3=1e-08) -> torch.Tensor: v4 = torch.mul(torch.log(v2 + v3), v1) v5 = torch.mul(torch.log(1 - v2 + v3), 1 - v1) v5[v5 != v5] = v3 return torch.sum(torch.add(v4, v5), dim=(1,))
[]
[ "torch" ]
[ "import torch", "from torch.utils.data import Dataset, Subset" ]
5
import torch from torch.utils.data import Dataset, Subset def class_accuracy(pred: torch.Tensor, true: torch.Tensor) -> float: """ Computes the percentage class accuracy of the predictions, given the correct class labels. Args: pred: the class predictions made by a model true: the gro...
null
v0
[ "Dataset", "torch.Tensor", "int" ]
torch.Tensor
def v0(v1: Dataset, v2: torch.Tensor, v3: int) -> torch.Tensor: v4 = torch.arange(0, len(v2))[v2 == v3] return Subset(v1, v4)
[]
[ "torch" ]
[ "import torch", "from torch.utils.data import Dataset, Subset" ]
3
import torch from torch.utils.data import Dataset, Subset def class_accuracy(pred: torch.Tensor, true: torch.Tensor) -> float: """ Computes the percentage class accuracy of the predictions, given the correct class labels. Args: pred: the class predictions made by a model true: the gro...
null
v0
[ "Any", "Any" ]
None
def v0(v1, v2) -> None: if isinstance(v1, pd.DataFrame) and (not isinstance(v2, pd.DataFrame)): raise TypeError('both source and destination must be DataFrames') if isinstance(v1, pd.Series) and (not isinstance(v2, pd.Series)): raise TypeError('both source and destination must be Series') if...
[]
[ "pandas", "warnings" ]
[ "import warnings", "import pandas as pd" ]
18
# Copyright © 2021. TIBCO Software Inc. # This file is subject to the license terms contained # in the license file that is distributed with this file. """User visible utility functions.""" import warnings import pandas as pd # Table and column metadata functions def copy_metadata(source, destination) -> None: ...
null
v4
[ "str" ]
t.Dict[str, t.Any]
def v4(v5: str) -> t.Dict[str, t.Any]: global config if len(config) > 0: raise Exception('Configuration should only be loaded once.') v6 = v0(v5) return v6
[ { "name": "v0", "input_types": [ "str" ], "output_type": "t.Union[t.Dict[str, t.Any], None]", "code": "def v0(v1: str) -> t.Union[t.Dict[str, t.Any], None]:\n if not v1.endswith('.yml'):\n raise ValueError(\"YAML config files should end with '.yml' extension (RTFMG).\")\n with...
[]
[]
6
""" Copyright 2019 EUROCONTROL ========================================== Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and...
null
v4
[ "str" ]
Any
def v4(self, v5: str): v6 = v0(v5) if v6 is None: return self.update(v6) return self
[ { "name": "v0", "input_types": [ "str" ], "output_type": "t.Union[t.Dict[str, t.Any], None]", "code": "def v0(v1: str) -> t.Union[t.Dict[str, t.Any], None]:\n if not v1.endswith('.yml'):\n raise ValueError(\"YAML config files should end with '.yml' extension (RTFMG).\")\n with...
[]
[]
6
""" Copyright 2019 EUROCONTROL ========================================== Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and...
null
v0
[ "str", "bool", "int" ]
None
def v0(self, v1: str, v2: bool, v3: int) -> None: self.username = v1 self.admin = v2 self.bias = v3
[]
[]
[]
4
"Script for everything User related in the database" from models import db class User(db.Model): "Class used for configuring the User model in the database" id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), unique=True, nullable=False) admin = db.Column(db.Boolean) b...
null
v0
[ "int" ]
str
def v0(v1: int) -> str: v2 = '' v1 = v1 + 1 while v1 > 0: (v1, v3) = divmod(v1 - 1, 26) v2 = chr(65 + v3) + v2 return v2
[]
[]
[]
7
import re from typing import Sequence, Union, Tuple, List, Dict, Any regex_az = re.compile(r'[a-zA-Z]+') regex_09 = re.compile(r'[0-9]+') def cell_tuple_to_str(col, row) -> str: """ used exclusively in conversions This function converts 0-indexed tuples cell notation to the cell notation used by excel...
null
v0
[ "str" ]
int
def v0(v1: str) -> int: v2 = 0 v1 = v1.upper() v1 = v1[::-1] for v3 in range(len(v1)): v2 += (ord(v1[v3]) % 65 + 1) * 26 ** v3 return v2 - 1
[]
[]
[]
7
from typing import Union from SPARQLWrapper import SPARQLWrapper, JSON import string import pyexcel import os import re from typing import Sequence from Code.property_type_map import property_type_map def get_column_letter(n: int) -> str: """ This function converts the column index to column letter 1 to A, 5 to E...
null
v4
[ "tuple" ]
str
def v4(v5: tuple) -> str: v6 = v0(int(v5[0]) + 1) v7 = str(int(v5[1]) + 1) return v6 + v7
[ { "name": "v0", "input_types": [ "int" ], "output_type": "str", "code": "def v0(v1: int) -> str:\n v2 = ''\n while v1 > 0:\n (v1, v3) = divmod(v1 - 1, 26)\n v2 = chr(65 + v3) + v2\n return v2", "dependencies": [] } ]
[ "string" ]
[ "import string" ]
4
from typing import Union from SPARQLWrapper import SPARQLWrapper, JSON import string import pyexcel import os import re from typing import Sequence from Code.property_type_map import property_type_map def get_column_letter(n: int) -> str: """ This function converts the column index to column letter 1 to A, 5 to E...
null
v0
[ "str" ]
str
def v0(v1: str) -> str: if v1 == '': return sys.stdin.read() else: with open(v1, 'r') as v2: return v2.read()
[]
[ "sys" ]
[ "import sys" ]
6
from redbaron import RedBaron import sys from optparse import OptionParser from src.optimize import optimize def read_input_code(input_file: str) -> str: if input_file == "": return sys.stdin.read() else: with open(input_file, "r") as input_file_handle: return input_file_handle.re...
null
v0
[ "str", "str" ]
None
def v0(self, v1: str, v2: str) -> None: with open(v1, 'w') as v3: v3.write(self.before) v3.write(f'FILE={v2}') v3.write(self.after)
[]
[]
[]
5
""" Collection of classes and methods for handling the committor sections of plumed used during the shooting point generation. """ from __future__ import annotations import os import re class PlumedInputHandler: """ Handles copying and modifying a template plumed file. This class is used to read a templ...
null
v3
[ "str" ]
bool
def v3(v4: str) -> bool: if v4 is None or str(v4).strip() == '' or v0(v4): return True return False
[ { "name": "v0", "input_types": [ "str" ], "output_type": "bool", "code": "def v0(v1: str) -> bool:\n return all((char in string.punctuation for v2 in str(v1)))", "dependencies": [] } ]
[ "string" ]
[ "import string" ]
4
from typing import Union from SPARQLWrapper import SPARQLWrapper, JSON import string import pyexcel import os import re from typing import Sequence from Code.property_type_map import property_type_map def get_column_letter(n: int) -> str: """ This function converts the column index to column letter 1 to A, 5 to E...
null
v0
[ "str" ]
int
def v0(v1: str) -> int: if isinstance(v1, int): return v1 v2 = {'gigayear': 0, 'gigayears': 0, '100 megayears': 1, '100 megayear': 1, '10 megayears': 2, '10 megayear': 2, 'megayears': 3, 'megayear': 3, '100 kiloyears': 4, '100 kiloyear': 4, '10 kiloyears': 5, '10 kiloyear': 5, 'millennium': 6, 'century'...
[]
[]
[]
5
from typing import Union from SPARQLWrapper import SPARQLWrapper, JSON import string import pyexcel import os import re from typing import Sequence from Code.property_type_map import property_type_map def get_column_letter(n: int) -> str: """ This function converts the column index to column letter 1 to A, 5 to E...
null
v6
[ "str" ]
Sequence[int]
def v6(v7: str) -> Sequence[int]: v8 = re.search('[0-9]+', v7) v9 = v8.span() v10 = v7[:v9[0]] v11 = v7[v9[0]:] return (v0(v10), v4(v11))
[ { "name": "v0", "input_types": [ "str" ], "output_type": "int", "code": "def v0(v1: str) -> int:\n v2 = 0\n v1 = v1.upper()\n v1 = v1[::-1]\n for v3 in range(len(v1)):\n v2 += (ord(v1[v3]) % 65 + 1) * 26 ** v3\n return v2 - 1", "dependencies": [] }, { "nam...
[ "re" ]
[ "import re" ]
6
from typing import Union from SPARQLWrapper import SPARQLWrapper, JSON import string import pyexcel import os import re from typing import Sequence from Code.property_type_map import property_type_map def get_column_letter(n: int) -> str: """ This function converts the column index to column letter 1 to A, 5 to E...
null
v12
[ "str" ]
Sequence[tuple]
def v12(v13: str) -> Sequence[tuple]: v14 = v13.split(':') v15 = v6(v14[0]) v16 = v6(v14[1]) return (v15, v16)
[ { "name": "v0", "input_types": [ "str" ], "output_type": "int", "code": "def v0(v1: str) -> int:\n v2 = 0\n v1 = v1.upper()\n v1 = v1[::-1]\n for v3 in range(len(v1)):\n v2 += (ord(v1[v3]) % 65 + 1) * 26 ** v3\n return v2 - 1", "dependencies": [] }, { "nam...
[ "re" ]
[ "import re" ]
5
from typing import Union from SPARQLWrapper import SPARQLWrapper, JSON import string import pyexcel import os import re from typing import Sequence from Code.property_type_map import property_type_map def get_column_letter(n: int) -> str: """ This function converts the column index to column letter 1 to A, 5 to E...
null
v0
[ "str" ]
Dict
def v0(self, v1: str) -> Dict: with open(os.path.join(self.path_to_output_data, v1)) as v2: v3 = json.load(v2) return v3
[]
[ "json", "os" ]
[ "import os", "import json" ]
4
""" Copyright (c) Microsoft Corporation. Licensed under the MIT license. """ import os import logging import numpy as np import json from ilp_utils import * from ilp_common import * from ilp_common_classes import * from typing import * from typing import List, Dict class ILPEval: def __init__(self, path_to_outpu...
null
v0
[ "UUID", "str" ]
None
def v0(self, v1: UUID, v2: str) -> None: v3: Dog = self.repository.get(v1) v3.add_trick(v2) self.save(v3)
[]
[]
[]
4
from typing import Any, Dict from uuid import UUID from eventsourcing.application import Application from eventsourcing.examples.aggregate2.domainmodel import Dog class DogSchool(Application): is_snapshotting_enabled = True def register_dog(self, name: str) -> UUID: dog = Dog(name) self.save...
null
v0
[ "UUID" ]
Dict[str, Any]
def v0(self, v1: UUID) -> Dict[str, Any]: v2: Dog = self.repository.get(v1) return {'name': v2.name, 'tricks': tuple(v2.tricks)}
[]
[]
[]
3
from typing import Any, Dict from uuid import UUID from eventsourcing.application import Application from eventsourcing.examples.aggregate2.domainmodel import Dog class DogSchool(Application): is_snapshotting_enabled = True def register_dog(self, name: str) -> UUID: dog = Dog(name) self.save...
null
v0
[ "Any" ]
QuantumCircuit
def v0(self, v1) -> QuantumCircuit: self._check_feature_vector(v1) v2 = QuantumCircuit(self.num_qubits) for v3 in range(self.num_qubits): v2.append(self.gate(2 * self.scaling * v1[v3]), [v3]) return v2
[]
[ "qiskit" ]
[ "from qiskit import QuantumCircuit", "from qiskit.circuit.library.standard_gates import RXGate, RYGate, RZGate" ]
6
from .encoding_map import EncodingMap import numpy as np from functools import reduce from qiskit import QuantumCircuit from qiskit.circuit.library.standard_gates import RXGate, RYGate, RZGate """Encoding classical data to quantum state via amplitude encoding.""" class AngleEncoding(EncodingMap): """ Angle...
null
v0
[ "str" ]
Any
def v0(self, v1: str): if self.state_changed_callback is None: return self.state_changed_callback(v1)
[]
[]
[]
4
import json import time from pathlib import Path from typing import Dict, Optional, List, Set, Tuple, Callable, Any import logging import asyncio import aiosqlite from chiabip158 import PyBIP158 from blspy import PublicKey, ExtendedPrivateKey from src.types.coin import Coin from src.types.spend_bundle import SpendBu...
null
v0
[ "float" ]
Any
async def v0(self, v1: float=0): if v1 > 0: await asyncio.sleep(v1) self._state_changed('peer_changed_peak')
[]
[ "asyncio" ]
[ "import asyncio" ]
4
import asyncio import dataclasses import logging import random import time import traceback from datetime import datetime from pathlib import Path from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union import aiosqlite from blspy import AugSchemeMPL import chia.server.ws_connection as ws # lgtm [p...
null
v0
[ "ws.WSLittlelambocoinConnection" ]
Any
def v0(self, v1: ws.WSLittlelambocoinConnection): self.log.info(f'peer disconnected {v1.get_peer_logging()}') self._state_changed('close_connection') self._state_changed('sync_mode') if self.sync_store is not None: self.sync_store.peer_disconnected(v1.peer_node_id) self.remove_subscriptions(...
[]
[]
[]
7
import asyncio import dataclasses import logging import random import time import traceback from pathlib import Path from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union import aiosqlite from blspy import AugSchemeMPL import littlelambocoin.server.ws_connection as ws # lgtm [py/import-and-import...
null
v0
[ "ws.WSLittlelambocoinConnection" ]
Any
def v0(self, v1: ws.WSLittlelambocoinConnection): v2 = v1.peer_node_id if v2 in self.peer_puzzle_hash: v3 = self.peer_puzzle_hash[v2] for v4 in v3: if v4 in self.ph_subscriptions: if v2 in self.ph_subscriptions[v4]: self.ph_subscriptions[v4].remove...
[]
[]
[]
16
import asyncio import dataclasses import logging import random import time import traceback from pathlib import Path from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union import aiosqlite from blspy import AugSchemeMPL import littlelambocoin.server.ws_connection as ws # lgtm [py/import-and-import...
null
v0
[]
int
def v0(self) -> int: assert self.server is not None assert self.server.all_connections is not None v1 = self.config['target_peer_count'] - len(self.server.all_connections) return v1 if v1 >= 0 else 0
[]
[]
[]
5
import asyncio import dataclasses import logging import random import time import traceback from datetime import datetime from pathlib import Path from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union import aiosqlite from blspy import AugSchemeMPL import chia.server.ws_connection as ws # lgtm [p...
null
v0
[ "str", "int", "int" ]
ImageTk.PhotoImage
def v0(v1: str, v2: int=int(root_w / 2), v3: int=int(root_h / 2)) -> ImageTk.PhotoImage: v4 = Image.open(v1) v5 = v4.resize((v2, v3)) return ImageTk.PhotoImage(v5)
[]
[ "PIL" ]
[ "from PIL import ImageTk, Image" ]
4
from tkinter import * from tkinter import filedialog, StringVar from PIL import ImageTk, Image from ImageColors import ImageColors import tkinter as tk img_container = None main_color_cv = None filepath_label = None root_w = 640 root_h = 640 def choose_image() -> None: destroy_image() destroy_main_color() ...
null
v0
[]
None
def v0() -> None: global img_container if img_container: img_container.grid_forget() img_container.destroy() v1 = None
[]
[]
[]
6
from tkinter import * from tkinter import filedialog, StringVar from PIL import ImageTk, Image from ImageColors import ImageColors import tkinter as tk img_container = None main_color_cv = None filepath_label = None root_w = 640 root_h = 640 def choose_image() -> None: destroy_image() destroy_main_color() ...
null
v0
[]
None
def v0() -> None: global main_color_cv if main_color_cv: main_color_cv.grid_forget() main_color_cv.destroy() v1 = None
[]
[]
[]
6
from tkinter import * from tkinter import filedialog, StringVar from PIL import ImageTk, Image from ImageColors import ImageColors import tkinter as tk img_container = None main_color_cv = None filepath_label = None root_w = 640 root_h = 640 def choose_image() -> None: destroy_image() destroy_main_color() ...
null
v0
[]
None
def v0() -> None: global filepath_label if filepath_label: filepath_label.grid_forget() filepath_label.destroy() v1 = None
[]
[]
[]
6
from tkinter import * from tkinter import filedialog, StringVar from PIL import ImageTk, Image from ImageColors import ImageColors import tkinter as tk img_container = None main_color_cv = None filepath_label = None root_w = 640 root_h = 640 def choose_image() -> None: destroy_image() destroy_main_color() ...
null
v0
[ "int", "int", "list", "Any", "Any", "Any", "Any" ]
None
def v0(self, v1: int, v2: int, v3: list, v4=31, v5=10, v6=0.002, v7=1) -> None: self.T = v1 self.n_experiments = v2 self.learners_to_test = v3 self.verbose = v7 self.metadata['TIME_HORIZON'] = self.T self.metadata['NUMBER_OF_EXPERIMENTS'] = self.n_experiments if self.pricing_context: ...
[]
[]
[]
20
import numpy as np import matplotlib.pyplot as plt import seaborn as sns from environments.complete_environment import CompleteEnvironment from learners.pricing.contextual_learner import ContextualLearner from utils.context_generator import ContextGenerator from utils.tasks.task import Task class CompleteTask(Task):...
null
v0
[ "Any", "Any", "Any", "Any", "Any" ]
None
def v0(self, v1=0, v2=(10, 8), v3='whitegrid', v4=False, v5=2500) -> None: assert self.ready if v1 < 0 or v1 > 2: raise TypeError('`plot_number` kwarg error: only 3 plot are available.') sns.set_theme(style=v3) if v1 == 0: plt.figure(0, figsize=v2) plt.ylabel('Regret') pl...
[]
[ "matplotlib", "numpy", "seaborn" ]
[ "import numpy as np", "import matplotlib.pyplot as plt", "import seaborn as sns" ]
50
import numpy as np import matplotlib.pyplot as plt import seaborn as sns from environments.complete_environment import CompleteEnvironment from learners.pricing.contextual_learner import ContextualLearner from utils.context_generator import ContextGenerator from utils.tasks.task import Task class CompleteTask(Task):...
null
v0
[ "str" ]
Any
def v0(v1: str): if not v1: return False if len(v1) < 3: return False if len(v1) > 25: return False if v1 in self.stop_words: return False if v1 in self.injected_stop_words: return False return True
[]
[]
[]
12
#!/usr/bin/env python # -*- coding: UTF-8 -*- import string from base import BaseObject from base import MandatoryParamError from datadict import the_stopwords_dict class TrigramGenerator(BaseObject): """ perform trigram generation on unstructured text """ def __init__(self, some_injected...
null
v2
[ "str" ]
list
def v2(self, v3: str) -> list: def v4(v5: str): if not v5: return False if len(v5) < 3: return False if len(v5) > 25: return False if v5 in self.stop_words: return False if v5 in self.injected_stop_words: return Fal...
[ { "name": "v0", "input_types": [ "str" ], "output_type": "Any", "code": "def v0(v1: str):\n if not v1:\n return False\n if len(v1) < 3:\n return False\n if len(v1) > 25:\n return False\n if v1 in self.stop_words:\n return False\n if v1 in self.inj...
[ "string" ]
[ "import string" ]
16
#!/usr/bin/env python # -*- coding: UTF-8 -*- import string from base import BaseObject from base import MandatoryParamError from datadict import the_stopwords_dict class TrigramGenerator(BaseObject): """ perform trigram generation on unstructured text """ def __init__(self, some_injected...
null
v0
[ "list", "int" ]
list
def v0(self, v1: list, v2: int) -> list: v3 = [] for v4 in range(0, v2): if v4 + 3 < v2 + 1: v5 = v1[v4] v6 = v1[v4 + 1] v7 = v1[v4 + 2] v8 = v1[v4 + 3] if self._is_valid([v5, v6, v7, v8]): v3.append('{} {} {} {}'.format(v5, v6,...
[]
[]
[]
11
#!/usr/bin/env python # -*- coding: UTF-8 -*- import string from base import BaseObject from base import MandatoryParamError from datadict import the_stopwords_dict class TrigramGenerator(BaseObject): """ perform trigram generation on unstructured text """ def __init__(self, some_injected...
null
v0
[ "list", "int" ]
list
def v0(self, v1: list, v2: int) -> list: v3 = [] for v4 in range(0, v2): if v4 < v2 + 1: v5 = v1[v4] if self._is_valid([v5]): v3.append(v5) return v3
[]
[]
[]
8
#!/usr/bin/env python # -*- coding: UTF-8 -*- import string from base import BaseObject from base import MandatoryParamError from datadict import the_stopwords_dict class TrigramGenerator(BaseObject): """ perform trigram generation on unstructured text """ def __init__(self, some_injected...
null
v1
[ "str" ]
list
def v1(self, v2: str) -> list: v3 = self._tokenize(v2) v4 = len(v3) - 1 def v5(): if self.gram_length == 4: return self._quadgrams(v3, v4) if self.gram_length == 3: return self._trigrams(v3, v4) if self.gram_length == 2: return self._bigrams(v3, v...
[ { "name": "v0", "input_types": [], "output_type": "Any", "code": "def v0():\n if self.gram_length == 4:\n return self._quadgrams(tokens, total_tokens)\n if self.gram_length == 3:\n return self._trigrams(tokens, total_tokens)\n if self.gram_length == 2:\n return self._bi...
[]
[]
18
#!/usr/bin/env python # -*- coding: UTF-8 -*- import string from base import BaseObject from base import MandatoryParamError from datadict import the_stopwords_dict class TrigramGenerator(BaseObject): """ perform trigram generation on unstructured text """ def __init__(self, some_injected...
null
v0
[ "str" ]
None
async def v0(self, v1: str) -> None: v2 = self._initializing.get(v1) if not v2: return await asyncio.wait(v2)
[]
[ "asyncio" ]
[ "import asyncio" ]
5
"""Classes to help gather user submissions.""" from __future__ import annotations import abc import asyncio from collections.abc import Mapping from types import MappingProxyType from typing import Any import uuid import voluptuous as vol from .core import HomeAssistant, callback from .exceptions import HomeAssistan...
null
v0
[ "base.TransformUpdateFn" ]
Any
def v0(v1: base.TransformUpdateFn): v2 = np.zeros([]) v3 = np.zeros([]) v4 = np.zeros([]) v1(v2, v4) v1(v2, v4, v3) v1(v2, v4, params=v3)
[]
[ "numpy" ]
[ "import numpy as np" ]
7
# Copyright 2021 DeepMind Technologies Limited. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
null
v0
[ "list", "int" ]
Any
def v0(self, v1: list, v2: int): self.nums = v1 self.target = v2 v3 = [] for v4 in range(len(v1)): for v5 in range(1, len(v1)): if v1[v4] + v1[v5] == v2: v3.append((v4, v5)) if len(v3) > 0: return v3 return 0
[]
[]
[]
11
# find the index location of two numbers in given list that sum to target class twoSum: def twoSum(self, nums: list, target: int): self.nums = nums self.target = target result = [] for i in range(len(nums)): for j in range(1, len(nums)): if nums[i] + nums...
null
v0
[ "str", "Optional[Tensor]", "bool" ]
None
def v0(self, v1: str, v2: Optional[Tensor], v3: bool=True) -> None: if v3 is False and isinstance(self, torch.jit.ScriptModule): raise RuntimeError('ScriptModule does not support non-persistent buffers') if '_buffers' not in self.__dict__: raise AttributeError('cannot assign buffer before Module...
[]
[ "torch" ]
[ "import torch", "import torch.utils.hooks as hooks", "from torch import Tensor, device, dtype" ]
21
from collections import OrderedDict, namedtuple import itertools import warnings import functools import torch from ..parameter import Parameter import torch.utils.hooks as hooks from torch import Tensor, device, dtype from typing import Union, Tuple, Any, Callable, Iterator, Set, Optional, overload, TypeVar, Mapping...
null
v0
[ "str" ]
nn.Module
def v0(self, v1: str) -> nn.Module: if v1 == '': return self v2: List[str] = v1.split('.') v3: torch.nn.Module = self for v4 in v2: if not hasattr(v3, v4): raise AttributeError(v3._get_name() + ' has no attribute `' + v4 + '`') v3 = getattr(v3, v4) if not isin...
[]
[ "torch" ]
[ "import torch", "import torch.nn as nn" ]
12
from collections import OrderedDict from typing import Any, Iterator, List, NamedTuple, Optional, Tuple, Union import torch import torch.nn as nn from kornia.augmentation.base import _AugmentationBase, MixAugmentationBase __all__ = ["SequentialBase", "ParamItem"] class ParamItem(NamedTuple): name: str data...
null
v0
[ "str" ]
'Parameter'
def v0(self, v1: str) -> 'Parameter': (v2, v3, v4) = v1.rpartition('.') v5: torch.nn.Module = self.get_submodule(v2) if not hasattr(v5, v4): raise AttributeError(v5._get_name() + ' has no attribute `' + v4 + '`') v6: torch.nn.Parameter = getattr(v5, v4) if not isinstance(v6, torch.nn.Paramet...
[]
[ "torch" ]
[ "import torch", "import torch.utils.hooks as hooks", "from torch import Tensor, device, dtype" ]
9
from collections import OrderedDict, namedtuple import itertools import warnings import functools import torch from ..parameter import Parameter import torch.utils.hooks as hooks from torch import Tensor, device, dtype from typing import Union, Tuple, Any, Callable, Iterator, Set, Optional, overload, TypeVar, Mapping...
null
v1
[ "Callable[['Module'], None]" ]
v0
def v1(self: v0, v2: Callable[['Module'], None]) -> v0: for v3 in self.children(): v3.apply(v2) v2(self) return self
[]
[]
[]
5
from collections import OrderedDict, namedtuple import itertools import warnings import functools import torch from ..parameter import Parameter import torch.utils.hooks as hooks from torch import Tensor, device, dtype from typing import Union, Tuple, Any, Callable, Iterator, Set, Optional, overload, TypeVar, Mapping...
[ "v0 = TypeVar('T', bound='Module')" ]
v0
[ "bool" ]
Iterator[Tensor]
def v0(self, v1: bool=True) -> Iterator[Tensor]: for (v2, v3) in self.named_torch_buffers(recurse=v1): yield v3
[]
[]
[]
3
# _ _ _ _ _ _ _ _ # /\ \ /\ \ _ / /\ /\ \ /\_\/\_\ _ _\ \ /\ \ # / \ \ \ \ \ /_/ / / / \ \ / / / / //\_\/\__ \ \ \ \ # / /\ \ \ \ \ \ \___\/ / /\ \ \ /\ \/ \ \/ / / /_ \...
null