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
[]
typing.NoReturn
def v0() -> typing.NoReturn: (v1, v2, v3, v4) = map(int, input().split()) v5 = 0 while True: if v1 * v3 < v1 + v4: if v1 * v3 >= v2: break v1 *= v3 v5 += 1 continue v5 += (v2 - 1 - v1) // v4 break print(v5)
[]
[]
[]
13
import typing def main() -> typing.NoReturn: x, y, a, b = map(int, input().split()) exp = 0 while True: if x * a < x + b: if x * a >= y: break x *= a exp += 1 continue exp += (y - 1 - x) // b break print(exp) main...
null
v0
[ "str", "str" ]
dict
def v0(v1: str, v2: str) -> dict: while True: v3 = requests.get(v1, headers={'Authorization': 'token {0}'.format(v2)}) v3.raise_for_status() yield v3.json() if 'next' not in v3.links: break v1 = v3.links['next']['url']
[]
[ "requests" ]
[ "import requests" ]
8
from config import Config import requests from filehandler import mkdir from gitlib import check_name, mirror from pathlib import Path from logger import log_message, log_error DEFAULT_HOST = "https://api.github.com/" def backup(config: Config) -> bool: if config.host is None or not config.host: config....
null
v0
[]
dict
def v0(self) -> dict: v1 = {} if hasattr(self, 'client_id'): v1['clientId'] = self.client_id if hasattr(self, 'country_code'): v1['countryCode'] = self.country_code if hasattr(self, 'namespace'): v1['namespace'] = self.namespace if hasattr(self, 'user_id'): v1['userId...
[]
[]
[]
11
# Copyright (c) 2021 AccelByte Inc. All Rights Reserved. # This is licensed software from AccelByte Inc, for limitations # and restrictions contact your company contract manager. # # Code generated. DO NOT EDIT! # template file: justice_py_sdk_codegen/__main__.py # pylint: disable=duplicate-code # pylint: disable=li...
null
v45
[ "str" ]
v0
def v45(self, v46: str) -> v0: self.parent_category_path = v46 return self
[]
[]
[]
3
# Auto-generated at 2021-09-27T17:12:36.153434+08:00 # from: Justice Platform Service (3.24.0) # Copyright (c) 2018 - 2021 AccelByte Inc. All Rights Reserved. # This is licensed software from AccelByte Inc, for limitations # and restrictions contact your company contract manager. # pylint: disable=duplicate-code # py...
[ "class v0(Model):\n v1: str\n v2: str\n v3: str\n v4: str\n v5: str\n v6: str\n v7: List[v0]\n v8: bool\n\n def v9(self, v10: str) -> v0:\n self.namespace = v10\n return self\n\n def v11(self, v12: str) -> v0:\n self.parent_category_path = v12\n return self\...
v45
[ "str" ]
v0
def v45(self, v46: str) -> v0: self.username = v46 return self
[]
[]
[]
3
# Copyright (c) 2021 AccelByte Inc. All Rights Reserved. # This is licensed software from AccelByte Inc, for limitations # and restrictions contact your company contract manager. # # Code generated. DO NOT EDIT! # template file: justice_py_sdk_codegen/__main__.py # justice-session-browser-service () # pylint: disab...
[ "class v0(Model):\n v1: ModelsGameSessionSetting\n v2: str\n v3: str\n v4: str\n v5: str\n\n def v6(self, v7: ModelsGameSessionSetting) -> v0:\n self.game_session_setting = v7\n return self\n\n def v8(self, v9: str) -> v0:\n self.game_version = v9\n return self\n\n ...
v0
[ "bool" ]
dict
def v0(self, v1: bool=False) -> dict: v2 = {} if hasattr(self, 'namespace') and self.namespace: v2['namespace'] = str(self.namespace) elif v1: v2['namespace'] = str() if hasattr(self, 'user_id') and self.user_id: v2['userId'] = str(self.user_id) elif v1: v2['userId'] ...
[]
[]
[]
27
# Auto-generated at 2021-09-27T17:01:27.299302+08:00 # from: Justice Social Service (1.17.1) # Copyright (c) 2018 - 2021 AccelByte Inc. All Rights Reserved. # This is licensed software from AccelByte Inc, for limitations # and restrictions contact your company contract manager. # pylint: disable=duplicate-code # pyli...
null
v13
[ "v0", "Any" ]
Any
def v13(self, v14: v0, v15): self.remove_household(v14) self.add_household_to_settlement(v14, v15)
[]
[]
[]
3
import statistics import VegetationModel import math import numpy as np import json from ECAgent.Core import * from ECAgent.Decode import IDecodable from ECAgent.Environments import PositionComponent, discreteGridPosToID from ECAgent.Collectors import Collector, FileCollector from VegetationModel import SoilMoistureC...
[ "class v0(Agent, IDecodable):\n\n def __init__(self, v1: str, v2: Model, v3: int):\n super().__init__(v1, v2)\n self.addComponent(ResourceComponent(self, v2))\n self.addComponent(HouseholdRelationshipComponent(self, v2, v3))\n\n @staticmethod\n def v4(v5: dict):\n ResourceCompon...
v0
[ "Any", "float" ]
Any
def v0(self, v1, v2: float): self.forage_utility += (v1.forage_utility - self.forage_utility) * self.conformity * v2 self.farm_utility += (v1.farm_utility - self.farm_utility) * self.conformity * v2 self.learning_rate += (v1.learning_rate - self.learning_rate) * self.conformity * v2 self.peer_transfer +...
[]
[]
[]
8
import json import logging import math import numpy as np import statistics import time from ECAgent.Core import * from ECAgent.Decode import IDecodable from ECAgent.Environments import PositionComponent, discreteGridPosToID from ECAgent.Collectors import Collector, FileCollector from VegetationModel import SoilMoistu...
null
v0
[ "str" ]
str
def v0(v1: str) -> str: v2 = re.sub('\\(#[+-]?[0-9]*[.]?[0-9]*\\)', '', v1) for v3 in punctuation: v2 = v2.replace(v3, '') return v2.strip().lower()
[]
[ "re", "string" ]
[ "import re", "from string import punctuation" ]
5
import re from string import punctuation def preprocess(text: str) -> str: prep_text = re.sub(r"\(#[+-]?[0-9]*[.]?[0-9]*\)", '', text) for punc in punctuation: prep_text = prep_text.replace(punc, '') return prep_text.strip().lower()
null
v0
[ "int" ]
bool
def v0(self, v1: int) -> bool: v2 = 2 ** 31 - 1 if -(v2 + 1) <= v1 <= v2: v3 = str(int(v1)) if v3 == v3[::-1]: return True return False else: return False
[]
[]
[]
9
from typing import List class Solution: def isPalindrome(self, x: int) -> bool: maxValue = 2 ** 31 - 1 if -(maxValue + 1) <= x <= maxValue: s = str(int(x)) if s == s[::-1]: return True return False else: return False if __na...
null
v0
[ "int", "Any" ]
QuantumCircuit
def v0(v1: int, v2) -> QuantumCircuit: v3 = QuantumRegister(v1, 'ofc') v4 = QuantumCircuit(v3, name='Zf') for v5 in range(2 ** v1): v6 = np.binary_repr(v5, v1) if v2(v6) == '1': for v7 in range(v1): if v6[v7] == '0': v4.x(v3[v7]) if...
[]
[ "math", "numpy", "qiskit" ]
[ "import qiskit", "from qiskit import IBMQ", "from qiskit.providers.ibmq import least_busy", "from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister", "from qiskit import BasicAer, execute, transpile", "from qiskit.test.mock import FakeVigo", "from math import log2, floor, sqrt, pi", "im...
15
# qubit number=5 # total number=57 import cirq import qiskit from qiskit import IBMQ from qiskit.providers.ibmq import least_busy from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister from qiskit import BasicAer, execute, transpile from pprint import pprint from qiskit.test.mock import FakeVigo from ma...
null
v8
[ "int", "Any" ]
QuantumCircuit
def v8(v9: int, v10) -> QuantumCircuit: v11 = QuantumRegister(v9, 'qc') v12 = ClassicalRegister(v9, 'qm') v13 = QuantumCircuit(v11, v12) v13.h(v11[0]) v13.h(v11[1]) v13.h(v11[2]) v13.h(v11[1]) v13.cz(v11[3], v11[1]) v13.h(v11[1]) v13.h(v11[3]) v13.h(v11[4]) v14 = v0(v9, v...
[ { "name": "v0", "input_types": [ "int", "Any" ], "output_type": "QuantumCircuit", "code": "def v0(v1: int, v2) -> QuantumCircuit:\n v3 = QuantumRegister(v1, 'ofc')\n v4 = QuantumCircuit(v3, name='Zf')\n for v5 in range(2 ** v1):\n v6 = np.binary_repr(v5, v1)\n ...
[ "math", "numpy", "qiskit" ]
[ "import qiskit", "from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister", "from qiskit import BasicAer, execute, transpile", "from qiskit.test.mock import FakeVigo", "from math import log2, floor, sqrt, pi", "import numpy as np" ]
68
# qubit number=5 # total number=71 import cirq import qiskit from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister from qiskit import BasicAer, execute, transpile from pprint import pprint from qiskit.test.mock import FakeVigo from math import log2,floor, sqrt, pi import numpy as np import networkx as ...
null
v0
[ "str" ]
None
def v0(self, v1: str) -> None: v2 = self.keys[v1] v3 = self.last_generated_index - v2.child_index() if self.gap_limit - v3 > 0: for v4 in range(self.gap_limit - v3): self.generate_new_key(self.last_generated_index + 1) self.last_shared_index = max(self.last_shared_index, v2.child_ind...
[]
[]
[]
7
import hashlib from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple from mnemonic import Mnemonic from hathor.pubsub import HathorEvents from hathor.wallet import BaseWallet from hathor.wallet.exceptions import InvalidWords if TYPE_CHECKING: from cryptography.hazmat.primitives.asymmetric.ec import Ellipt...
null
v0
[ "bytes", "'Key'" ]
Tuple[bytes, bytes]
def v0(self, v1: bytes, v2: 'Key') -> Tuple[bytes, bytes]: v3 = hashlib.sha256(hashlib.sha256(v1).digest()).digest() v4 = v2.sign(v3) return (v2.sec(), v4)
[]
[ "hashlib" ]
[ "import hashlib" ]
4
import hashlib from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple from mnemonic import Mnemonic from hathor.pubsub import HathorEvents from hathor.wallet import BaseWallet from hathor.wallet.exceptions import InvalidWords if TYPE_CHECKING: from cryptography.hazmat.primitives.asymmetric.ec import Ellipt...
null
v0
[ "np.ndarray", "np.ndarray" ]
Dict
def v0(self, v1: np.ndarray, v2: np.ndarray) -> Dict: v3 = len(v1) if v3 != len(v2): raise ValueError('Vectors have different lengths: true {} vs pred {}'.format(v3, len(v2))) if v1.shape[1] != 1: raise ValueError('Shape of true labels vector should be ({},1)'.format(v3)) if v2.shape[1] ...
[]
[]
[]
10
from typing import Dict import numpy as np import tensorflow as tf class Metric(object): def __init__(self, tf_metric: tf.keras.metrics.Metric): """ :param tf_metric: """ if not isinstance(tf_metric, tf.keras.metrics.Metric): raise TypeError("Only ten...
null
v0
[ "bool", "bool" ]
Any
def v0(v1: bool, v2: bool): v3 = getenv('IMMINENT_DESKTOP_BACKGROUND_COLOR') if v2 else getenv('NORMAL_DESKTOP_BACKGROUND_COLOR') system(f"gsettings set org.gnome.desktop.background primary-color '#{v3}'") if v1 != v2: system(f'ffplay -autoexit -nodisp -volume 30 alarm.mp3')
[]
[ "os" ]
[ "from os import getenv, system" ]
5
from os import getenv, system def show_imminent_event(was_imminent: bool, is_imminent: bool): color = getenv('IMMINENT_DESKTOP_BACKGROUND_COLOR') if is_imminent else getenv('NORMAL_DESKTOP_BACKGROUND_COLOR') system(f"gsettings set org.gnome.desktop.background primary-color '#{color}'") if was_imminent != i...
null
v0
[]
str
def v0() -> str: v1 = list(os.environ.keys()) if 'PYTEST_XDIST_WORKER' in v1 or 'PYTEST_XDIST_WORKER_COUNT' in v1: return os.environ['PYTEST_XDIST_WORKER'] else: return 'master'
[]
[ "os" ]
[ "import os" ]
6
"""This file is recognized by pytest for defining specified behaviour 'conftest.py' files are directory-scope files that are shared by all sub-directories from where this file is placed. pytest recognises 'conftest.py' for any unit test executed from within this directory tree. This file is used to define fixtures, ho...
null
v10
[]
None
def v10() -> None: global file_list v11 = v8() if v11 == 'master': v12 = v0()
[ { "name": "v0", "input_types": [], "output_type": "List[str]", "code": "def v0() -> List[str]:\n v1 = os.path.join(static_dir, 'tests/files/')\n if worker_id() == 'master':\n logger.info('Collecting file lists from: {}'.format(v1))\n v2 = os.walk(v1)\n v3 = []\n for (v4, v5, v6...
[ "os" ]
[ "import os" ]
5
"""This file is recognized by pytest for defining specified behaviour 'conftest.py' files are directory-scope files that are shared by all sub-directories from where this file is placed. pytest recognises 'conftest.py' for any unit test executed from within this directory tree. This file is used to define fixtures, ho...
null
v0
[ "str", "Any" ]
Any
def v0(self, v1: str, v2=False): if v2: v3 = tqdm(v1) else: v3 = v1 v4 = [[token.pos_ for v5 in self.nlp(sentence)] for v6 in v3] return v4
[]
[ "tqdm" ]
[ "from tqdm import tqdm" ]
7
from tqdm import tqdm from notebooks.utils import default_nlp class POSSentenceTokenizer: def __init__(self, nlp=None): self.nlp = nlp or default_nlp() def tokenize_list(self, sentences: str, show_loading=False): if show_loading: sentence_iter = tqdm(sentences) else: ...
null
v0
[ "str", "Any" ]
Any
def v0(self, v1: str, v2=False): if v2: print('NLP...', flush=True) v3 = self.nlp(v1) if v2: print('NLP done.', flush=True) if v2: v4 = tqdm(v3.sents) else: v4 = v3.sents v5 = [[token.pos_ for v6 in sentence] for v7 in v4] return v5
[]
[ "tqdm" ]
[ "from tqdm import tqdm" ]
12
from tqdm import tqdm from notebooks.utils import default_nlp class POSSentenceTokenizer: def __init__(self, nlp=None): self.nlp = nlp or default_nlp() def tokenize_list(self, sentences: str, show_loading=False): if show_loading: sentence_iter = tqdm(sentences) else: ...
null
v0
[ "list", "int", "Any" ]
Any
def v0(v1: list, v2: int, v3): v4 = {'input_word_ids': [], 'input_mask': [], 'input_type_ids': []} for v5 in v1: v6 = list(v5) v7 = [] for (v8, v9) in enumerate(v6): v10 = v3.tokenize(v9) v7.extend(v10) if len(v7) >= v2 - 1: v7 = v7[0:v2 - 2] ...
[]
[ "numpy" ]
[ "import numpy as np" ]
36
import tensorflow as tf import csv import numpy as np def decode_record(record, name_to_features): """Decodes a record to a TensorFlow example.""" example = tf.io.parse_single_example(record, name_to_features) # tf.Example only supports tf.int64, but the TPU only supports tf.int32. # So cast all int6...
null
v0
[ "str" ]
bool
def v0(self, v1: str) -> bool: if v1 not in self._object_lookup_table.keys(): return False else: return True
[]
[]
[]
5
from collections import namedtuple import itertools import os import numpy as np from typing import Tuple from typing import List from typing import Dict import random from itertools import product from GroundedScan.gym_minigrid.minigrid import MiniGridEnv from GroundedScan.gym_minigrid.minigrid import Grid from Groun...
null
v0
[ "str", "str", "int" ]
np.ndarray
def v0(self, v1: str, v2: str, v3: int) -> np.ndarray: assert self.has_object(v1, v2, v3), 'Trying to get an unavailable object vector from the vocabulary/' return self._object_vectors[v1][v2][v3]
[]
[]
[]
3
from collections import namedtuple import itertools import os import numpy as np from typing import Tuple from typing import List from typing import Dict import random from itertools import product from GroundedScan.gym_minigrid.minigrid import MiniGridEnv from GroundedScan.gym_minigrid.minigrid import Grid from Groun...
null
v1
[ "v0" ]
Any
def v1(self, v2: v0): if 0 <= v2.row < self.grid_size and 0 <= v2.column < self.grid_size: return True else: return False
[]
[]
[]
5
from collections import namedtuple import itertools import os import numpy as np from typing import Tuple from typing import List from typing import Dict import random from itertools import product from GroundedScan.gym_minigrid.minigrid import MiniGridEnv from GroundedScan.gym_minigrid.minigrid import Grid from Groun...
[ "v0 = namedtuple('Position', 'column row')" ]
v1
[ "v0" ]
Any
def v1(self, v2: v0): if not self.position_taken(v2): self.place_agent(top=(v2.column, v2.row), size=(1, 1), rand_dir=False) self._occupied_positions.add((v2.column, v2.row)) else: raise ValueError('Trying to place agent on cell that is already taken.')
[]
[]
[]
6
from collections import namedtuple import itertools import os import numpy as np from typing import Tuple from typing import List from typing import Dict import random from itertools import product from GroundedScan.gym_minigrid.minigrid import MiniGridEnv from GroundedScan.gym_minigrid.minigrid import Grid from Groun...
[ "v0 = namedtuple('Position', 'column row')" ]
v1
[ "v0" ]
Any
def v1(self, v2: v0): v3 = min(self.grid_size - v2.row, v2.row) v4 = min(self.grid_size - v2.column, v2.column) return min(v3, v4)
[]
[]
[]
4
from collections import namedtuple import itertools import os import numpy as np from typing import Tuple from typing import List from typing import Dict import random from itertools import product from GroundedScan.gym_minigrid.minigrid import MiniGridEnv from GroundedScan.gym_minigrid.minigrid import Grid from Groun...
[ "v0 = namedtuple('Position', 'column row')" ]
v2
[ "v0" ]
v1
def v2(self, v3: v0) -> v1: v4 = None for (v5, v6) in enumerate(self._placed_object_list): if v6.position == v3: if v6.object.shape == 'box': continue v4 = self._placed_object_list[v5] del self._placed_object_list[v5] break self._remove...
[]
[]
[]
14
from collections import namedtuple import itertools import os import numpy as np from typing import Tuple from typing import List from typing import Dict import random from itertools import product from gym_minigrid.minigrid import MiniGridEnv from gym_minigrid.minigrid import Grid from gym_minigrid.minigrid import ID...
[ "v0 = namedtuple('Position', 'column row')", "v1 = namedtuple('PositionedObject', 'object position vector overflow overlap', defaults=(None, None, None, False, False))" ]
v1
[ "v0", "v0" ]
Any
def v1(self, v2: v0, v3: v0): v4 = self._remove_object(v2) if not v4: raise ValueError('Trying to move an object from an empty grid location (row {}, col {})'.format(v2.row, v2.column)) self.place_object(v4.object, v3)
[]
[]
[]
5
from collections import namedtuple import itertools import os import numpy as np from typing import Tuple from typing import List from typing import Dict import random from itertools import product from GroundedScan.gym_minigrid.minigrid import MiniGridEnv from GroundedScan.gym_minigrid.minigrid import Grid from Groun...
[ "v0 = namedtuple('Position', 'column row')" ]
v1
[ "v0" ]
Any
def v1(self, v2: v0): self.agent_pos = (v2.column, v2.row) self._observed_commands.append('pull') self._observed_situations.append(self.get_current_situation())
[]
[]
[]
4
from collections import namedtuple import itertools import os import numpy as np from typing import Tuple from typing import List from typing import Dict import random from itertools import product from GroundedScan.gym_minigrid.minigrid import MiniGridEnv from GroundedScan.gym_minigrid.minigrid import Grid from Groun...
[ "v0 = namedtuple('Position', 'column row')" ]
v1
[ "v0" ]
Any
def v1(self, v2: v0): v3 = np.array([v2.column - self.agent_pos[0], v2.row - self.agent_pos[1]]) v3[v3 < 0] = 0 v4 = v3[0] v5 = v3[1] if v4 and v5: return ('SE', self.actions.left) elif v4 and (not v5): return ('NE', self.actions.right) elif v5 and (not v4): return ('...
[]
[ "numpy" ]
[ "import numpy as np" ]
13
from collections import namedtuple import itertools import os import numpy as np from typing import Tuple from typing import List from typing import Dict import random from itertools import product from GroundedScan.gym_minigrid.minigrid import MiniGridEnv from GroundedScan.gym_minigrid.minigrid import Grid from Groun...
[ "v0 = namedtuple('Position', 'column row')" ]
v1
[ "v0", "str", "str" ]
Any
def v1(self, v2: v0, v3: str, v4: str): if v3 == 'while spinning': self.spin() self.take_step_in_direction(direction=v2, primitive_command=v4) elif v3 == 'cautiously': self.turn_to_direction(direction=v2) self.look_left_and_right() self.take_step_in_direction(direction=v2...
[]
[]
[]
12
from collections import namedtuple import itertools import os import numpy as np from typing import Tuple from typing import List from typing import Dict import random from itertools import product from GroundedScan.gym_minigrid.minigrid import MiniGridEnv from GroundedScan.gym_minigrid.minigrid import Grid from Groun...
[ "v0 = namedtuple('Direction', 'name')" ]
v1
[ "str", "Any" ]
List[v0]
def v1(self, v2: str, v3=None) -> List[v0]: assert self.has_object(v2), "Trying to get an object's position that is not placed in the world." v4 = self._object_lookup_table[v2] if v3: v5 = [size for (v6, v7) in v4.items() if v7] v5.sort() assert len(v5) >= 2, 'referring to a {} objec...
[]
[]
[]
16
from collections import namedtuple import itertools import os import numpy as np from typing import Tuple from typing import List from typing import Dict import random from itertools import product from GroundedScan.gym_minigrid.minigrid import MiniGridEnv from GroundedScan.gym_minigrid.minigrid import Grid from Groun...
[ "v0 = namedtuple('Position', 'column row')" ]
v0
[ "Any", "str" ]
Any
def v0(self, v1, v2: str): self.step(action=v1) self._observed_situations.append(self.get_current_situation()) self._observed_commands.append(v2)
[]
[]
[]
4
from collections import namedtuple import itertools import os import numpy as np from typing import Tuple from typing import List from typing import Dict import random from itertools import product from GroundedScan.gym_minigrid.minigrid import MiniGridEnv from GroundedScan.gym_minigrid.minigrid import Grid from Groun...
null
v0
[ "Any", "Any", "Any" ]
str
def v0(self, v1, v2=[], v3=[]) -> str: v4 = os.path.join(self.save_directory, v1) assert v4.endswith('.png'), 'Invalid file name passed to save_situation, must end with .png.' v5 = self.render(mode='human', attention_weights=v2, agent_history=v3).save(v4) if not v5: print('WARNING: image with na...
[]
[ "os" ]
[ "import os" ]
9
from collections import namedtuple import itertools import os import numpy as np from typing import Tuple from typing import List from typing import Dict import random from itertools import product from GroundedScan.gym_minigrid.minigrid import MiniGridEnv from GroundedScan.gym_minigrid.minigrid import Grid from Groun...
null
v0
[ "logging.LogRecord" ]
bool
def v0(self, v1: logging.LogRecord) -> bool: if not super().filter(v1): return False if self.contains and self.contains not in v1.msg: return False if self.not_contains and self.not_contains in v1.msg: return False return True
[]
[]
[]
8
from __future__ import annotations import logging class SimpleFilter(logging.Filter): def __init__(self, name: str = '', contains: str | None = None, not_contains: str | None = None) -> None: super().__init__() self.contains = contains self.not_contains = not_contains def filter(self, record: logg...
null
v0
[ "str", "str", "str" ]
Any
def v0(self, v1: str, v2: str, v3: str): v4 = super()._parse_scope_in_mode(v1, v2, v3) v4 = self.resolver.visit(v4) v4 = self.typer.visit(v4) return v4
[]
[]
[]
5
"""Parsing Python.""" import ast import logging import pathlib import re import traceback import typing as t import horast import static_typing as st import typed_ast.ast3 as typed_ast3 from ..general import Language, Parser _LOG = logging.getLogger(__name__) PARSER_MODES = ('exec', 'eval', 'single') PARSER_MODES...
null
v4
[ "Callable", "Any", "Any" ]
Any
def v4(v5: Callable, v6=None, v7=None): if v7 is None: v7 = argv[1] v8 = v0(v7) if v6 is None: v5(v8) else: v5(v8, v6) if splitext(v7)[1] in ['.ust', '.UST']: v8.as_ust().write(v7) else: v8.write(v7)
[ { "name": "v0", "input_types": [ "str", "Any" ], "output_type": "Any", "code": "def v0(v1: str, v2='cp932'):\n v3 = UtauPlugin()\n v3.load(v1, encoding=v2)\n return v3", "dependencies": [] } ]
[ "os", "sys" ]
[ "from sys import argv", "from os.path import splitext" ]
12
#! /usr/bin/env python3 # coding: utf-8 # Copyright (c) oatsu """ UTAUのプラグイン用のモジュール utaupy.ust.Ust をもとに、ファイル入出力機能を変更したもの。 """ from copy import deepcopy from sys import argv from typing import Callable from os.path import splitext from utaupy import ust as _ust def run(your_function: Callable, option...
null
v0
[ "str", "str", "str" ]
str
def v0(self, v1: str, v2: str='w', v3: str='cp932') -> str: v4 = str(deepcopy(self)) + '\n' with open(v1, mode=v2, encoding=v3) as v5: v5.write(v4) return v4
[]
[ "copy" ]
[ "from copy import deepcopy" ]
5
#! /usr/bin/env python3 # coding: utf-8 # Copyright (c) oatsu """ UTAUのプラグイン用のモジュール utaupy.ust.Ust をもとに、ファイル入出力機能を変更したもの。 """ from copy import deepcopy from sys import argv from typing import Callable from os.path import splitext from utaupy import ust as _ust def run(your_function: Callable, option...
null
v0
[]
None
def v0(self) -> None: v1 = self.current_page.text v2 = self.opt.text if self.opt.replace: v1 = v2 elif self.opt.top: v1 = v2 + v1 else: v1 += v2 self.put_current(v1, summary=self.opt.summary)
[]
[]
[]
10
#!/usr/bin/python """ An incomplete sample script. This is not a complete bot; rather, it is a template from which simple bots can be made. You can rename it to mybot.py, then edit it in whatever way you want. Use global -simulate option for test purposes. No changes to live wiki will be done. The following paramet...
null
v0
[ "str", "Dict" ]
Optional[Dict]
def v0(v1: str, v2: Dict) -> Optional[Dict]: v3 = None for v4 in v2['jobs']: if v4['jobId'] == v1: v3 = v4 return v3
[]
[]
[]
6
# pylint: disable=bad-continuation # Copyright 2019-2021 Darren Weber # # 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
[ "int", "int", "int" ]
Any
def v0(self, v1: int, v2: int, v3: int): self._color['R'] = v1 self._color['G'] = v2 self._color['B'] = v3
[]
[]
[]
4
# light.py class Light: def __init__(self, name: str): self._name = name self._status = False self._color = {'R': 255, 'G': 255, 'B': 255} self._brightness = 0 def get_name(self) -> str: return self._name def set_name(self, name: str): self._name = name ...
null
v0
[ "list", "list" ]
Any
def v0(self, v1: list, v2: list): self.width = v1[0] self.height = v1[1] self.color = v2 self.set_rect()
[]
[]
[]
5
from constants import * class Key: def __init__(self): self.keys_pressed = list() def add(self, key): self.keys_pressed.append(key) def remove(self, key): try: self.keys_pressed.remove(key) except ValueError: pass def check_move(self): ...
null
v0
[ "Any", "Any", "float", "float", "Any", "Any", "Any" ]
Any
def v0(v1, v2, v3: float, v4: float, v5, v6, v7): v8 = (1, v1[1], 1, 1, v1[4]) v9 = 'float32' if v5: v10 = [v8] * 4 v11 = [v9] * 4 v12 = [v3] elif not v6: v10 = [v1] + [v8] * 4 v11 = [v2] + [v9] * 4 v12 = [v4] elif v6 and v7: v10 = [v1] * 2 + [...
[]
[]
[]
20
# Copyright 2019 Huawei Technologies Co., Ltd # # 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 agreed to...
null
v0
[ "Tensor", "float", "bool", "bool" ]
Tensor
def v0(v1: Tensor, v2: float=0.2, v3: bool=False, v4: bool=False) -> Tensor: if v2 == 0.0 or not v3: return v1 if not v4: v1 = v1.clone() v5 = 1 - v2 v6 = (v1.shape[0],) + (1,) * (v1.ndim - 1) v7 = v5 + torch.rand(v6, dtype=v1.dtype, device=v1.device) v7.floor_() v1.div_(v5)....
[]
[ "torch" ]
[ "import torch", "from torch import nn", "from torch import Tensor", "from torch.nn import Parameter", "import torch.nn.functional as F", "from torch.nn.utils.rnn import PackedSequence" ]
11
""" basic building blocks, for 1d signal (time series) """ import sys from copy import deepcopy from math import sqrt from itertools import repeat from typing import Union, Sequence, Tuple, List, Optional, NoReturn, Any from numbers import Real from packaging import version import numpy as np import torch from torch i...
null
v0
[]
None
def v0() -> None: (v1, v2, v3) = map(int, input().split()) v4 = 998244353 v5 = [1] * v2 for v6 in range(v1 - 1): v7 = [0] * v2 for v8 in range(v2): v9 = v8 - v3 if v9 >= 0: v7[0] += v5[v8] if v9 + 1 < v2: v7[v9 +...
[]
[]
[]
25
import typing def main() -> None: n, m, k = map(int, input().split()) mod = 998_244_353 # cumulative sum # imos algorithm dp = [1] * m for _ in range(n - 1): ndp = [0] * m for i in range(m): j = i - k if j >= 0: ndp[0] +...
null
v0
[ "'ProductVariant'" ]
Optional['CheckoutLine']
def v0(self, v1: 'ProductVariant') -> Optional['CheckoutLine']: v2 = (line for v3 in self if v3.variant.pk == v1.pk) return next(v2, None)
[]
[]
[]
3
"""Checkout-related ORM models.""" from operator import attrgetter from typing import TYPE_CHECKING, Optional from uuid import uuid4 from django.conf import settings from django.contrib.postgres.fields import JSONField from django.core.validators import MinValueValidator from django.db import models from django.utils....
null
v0
[]
Optional['Payment']
def v0(self) -> Optional['Payment']: v1 = [payment for v2 in self.payments.all() if v2.is_active] return max(v1, default=None, key=attrgetter('pk'))
[]
[ "operator" ]
[ "from operator import attrgetter" ]
3
"""Checkout-related ORM models.""" from operator import attrgetter from typing import TYPE_CHECKING, Optional from uuid import uuid4 from django.conf import settings from django.contrib.postgres.fields import JSONField from django.core.validators import MinValueValidator from django.db import models from django.utils....
null
v0
[ "T.Optional[T.Callable]" ]
Any
def v0(self: type, v1: T.Optional[T.Callable]=None, **v2: T.Any): v3: type = self.new(**v2) if v1 is not None: return v3(v1) return v3
[]
[]
[]
5
# -*- coding: utf-8 -*- """Base class for decorators. Most decorators are function-based. A function-based decorator is reasonably flexible, even permitting default values to be set dynamically. By using `~utilipy.utils.functools.wraps` in :mod:`~utility.utils.functools` these function-based decorators may can also m...
null
v0
[]
Any
def v0(self: type, **v1): v2: dict = self.__kwdefaults__.copy() v2.update(**v1) return self.__class__(function=None, **v2)
[]
[]
[]
4
# -*- coding: utf-8 -*- """Base class for decorators. Most decorators are function-based. A function-based decorator is reasonably flexible, even permitting default values to be set dynamically. By using `~utilipy.utils.functools.wraps` in :mod:`~utility.utils.functools` these function-based decorators may can also m...
null
v0
[ "Gio.SimpleAction", "Optional[GLib.Variant]" ]
Any
def v0(self, v1: Gio.SimpleAction, v2: Optional[GLib.Variant]=None): if self.gst_pipeline: self.btn_pause.set_active(True) self.dlg_about.present()
[]
[]
[]
4
import os import io from typing import Optional import gi import zbar import logbook from logbook import Logger from PIL import Image gi.require_version('GObject', '2.0') gi.require_version('GLib', '2.0') gi.require_version('Gtk', '3.0') gi.require_version('Gdk', '3.0') gi.require_version('Gio', '2.0') gi.require_ver...
null
v0
[ "int" ]
Any
def v0(v1: int): if v1 > 4 and v1 <= 12: return 'morn' elif v1 > 12 and v1 <= 17: return 'day' elif v1 > 17 and v1 <= 21: return 'eve' elif v1 > 21 or v1 <= 4: return 'night'
[]
[]
[]
9
import json import requests import os import streamlit as st from dotenv import load_dotenv # docs for 30 day climate forcast # https://openweathermap.org/api/forecast30#resp-year BASE_URL = "https://pro.openweathermap.org/data/2.5/forecast/climate" def get_weather_pred(loc: dict, local=True): if local == True:...
null
v2
[ "dict", "int", "int" ]
Any
def v2(v3: dict, v4: int, v5: int): if v4 > 30: return None v6 = v0(v5) v7 = v3['city']['coord'] v8 = v3['list'][v4] v9 = {'lat': v7['lat'], 'lon': v7['lon'], 'wind_speed': v8['speed'], 'wind_dir': v8['deg'], 'temp': v8['temp'], 'air_temp': v8['temp'][v6], 'feels_like': v8['feels_like'], 'we...
[ { "name": "v0", "input_types": [ "int" ], "output_type": "Any", "code": "def v0(v1: int):\n if v1 > 4 and v1 <= 12:\n return 'morn'\n elif v1 > 12 and v1 <= 17:\n return 'day'\n elif v1 > 17 and v1 <= 21:\n return 'eve'\n elif v1 > 21 or v1 <= 4:\n r...
[]
[]
8
import json import requests import os import streamlit as st from dotenv import load_dotenv # docs for 30 day climate forcast # https://openweathermap.org/api/forecast30#resp-year BASE_URL = "https://pro.openweathermap.org/data/2.5/forecast/climate" def get_weather_pred(loc: dict, local=True): if local == True:...
null
v0
[ "dict" ]
Any
def v0(v1: dict=None): if v1 is None: v1 = {} v1['User-Agent'] = 'ESDIS TEA Config Generator' return v1
[]
[]
[]
5
""" Utility methods """ import logging def standard_headers(base:dict = None): """ Return a dictionary containing the standard headers which should always be used when communicating to CMR from this app. Append to an existing dictionary if one exists. """ if base is None: base = {} ...
null
v0
[ "str" ]
None
def v0(self, v1: str) -> None: if not isinstance(v1, str): raise TypeError('Only strings are valid keys for DataSetAttributes.') if v1 not in self: raise KeyError(f'{v1} not present.') try: self.dataset.association_bitarray_names[self.association.name].remove(v1) except KeyError:...
[]
[]
[]
11
"""Implements DataSetAttributes, which represents and manipulates datasets.""" from collections.abc import Iterable from typing import Any, Dict, Iterator, List, Optional, Sequence, Tuple, Union import warnings import numpy as np from pyvista import _vtk import pyvista.utilities.helpers as helpers from pyvista.utili...
null
v0
[]
List[str]
def v0(self) -> List[str]: v1 = [] for v2 in range(self.GetNumberOfArrays()): v3 = self.VTKObject.GetAbstractArray(v2) v4 = v3.GetName() if v4: v1.append(v4) else: v4 = f'Unnamed_{v2}' v3.SetName(v4) v1.append(v4) return v1
[]
[]
[]
12
"""Implements DataSetAttributes, which represents and manipulates datasets.""" from collections.abc import Iterable from typing import Any, Dict, Iterator, List, Optional, Sequence, Tuple, Union import warnings import numpy as np from pyvista import _vtk import pyvista.utilities.helpers as helpers from pyvista.utili...
null
v0
[ "Union[Dict[str, np.ndarray], 'DataSetAttributes']" ]
Any
def v0(self, v1: Union[Dict[str, np.ndarray], 'DataSetAttributes']): for (v2, v3) in v1.items(): self[v2] = v3.copy()
[]
[]
[]
3
"""Implements DataSetAttributes, which represents and manipulates datasets.""" from collections.abc import Iterable from typing import Any, Dict, Iterator, List, Optional, Sequence, Tuple, Union import warnings import numpy as np from pyvista import _vtk import pyvista.utilities.helpers as helpers from pyvista.utili...
null
v0
[ "Any" ]
Any
def v0(self, v1: Any): v2 = self.VTKObject.GetNumberOfArrays() if isinstance(v1, int): if v1 < 0 or v1 >= self.VTKObject.GetNumberOfArrays(): raise KeyError(f'Array index ({v1}) out of range [0, {v2}]')
[]
[]
[]
5
"""Implements DataSetAttributes, which represents and manipulates datasets.""" from collections.abc import Iterable from typing import Any, Dict, Iterator, List, Optional, Sequence, Tuple, Union import warnings import numpy as np from pyvista import _vtk import pyvista.utilities.helpers as helpers from pyvista.utili...
null
v0
[ "Optional[dict]", "Optional[int]" ]
Dict[str, str]
def v0(self, *, v1: Optional[dict]=None, v2: Optional[int]=None) -> Dict[str, str]: if v1 is None: v1 = {} v1.update({'x-api-key': self.api_key}) return super()._get_headers(request_specific_headers=v1)
[]
[]
[]
5
from __future__ import annotations from typing import Dict, Optional from wyze_sdk.signature import RequestVerifier from .base import ExServiceClient, WyzeResponse class AuthServiceClient(ExServiceClient): """ Auth service client is the wrapper on the requests to https://auth-prod.api.wyze.com' """ ...
null
v0
[ "List[str]" ]
Any
def v0(self, v1: List[str]): self._data.setdefault('groupOverrideDetails', {}) self['groupOverrideDetails']['iamRolesToOverride'] = v1
[]
[]
[]
3
from typing import Any, Dict, List, Optional from aws_lambda_powertools.utilities.data_classes.common import DictWrapper class CallerContext(DictWrapper): @property def aws_sdk_version(self) -> str: """The AWS SDK version number.""" return self["callerContext"]["awsSdkVersion"] @property...
null
v0
[ "str" ]
Any
def v0(self, v1: str): self._data.setdefault('groupOverrideDetails', {}) self['groupOverrideDetails']['preferredRole'] = v1
[]
[]
[]
3
from typing import Any, Dict, List, Optional from aws_lambda_powertools.utilities.data_classes.common import DictWrapper class CallerContext(DictWrapper): @property def aws_sdk_version(self) -> str: """The AWS SDK version number.""" return self["callerContext"]["awsSdkVersion"] @property...
null
v0
[ "Dict", "Optional[bool]" ]
Any
def v0(v1: Dict, v2: Optional[bool]=False): v3 = v1['qubits'] v4 = len(v3) v5 = np.zeros((v4, v4)) v6 = {'xy_even': {}, 'xy_odd': {}, 'z': {}} for (v7, v8) in enumerate(v1['qubit_permutations']): for v9 in range(v4 - 1): if v9 % 2 == 0: v10 = v1['xy_even'][v7] ...
[]
[ "numpy" ]
[ "import numpy as np" ]
52
# Copyright 2020 Google # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, soft...
null
v0
[ "np.ndarray", "Optional[float]" ]
np.ndarray
def v0(v1: np.ndarray, v2: Optional[float]=1e-08) -> np.ndarray: v3 = np.infty v4 = v1.copy() while v3 > v2: v4 = 3 * (v4 @ v4) - 2 * (v4 @ v4 @ v4) v3 = np.linalg.norm(v4 @ v4 - v4) return v4
[]
[ "numpy" ]
[ "import numpy as np" ]
7
# Copyright 2020 Google # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, soft...
null
v0
[ "np.ndarray", "List[int]", "np.ndarray" ]
float
def v0(v1: np.ndarray, v2: List[int], v3: np.ndarray) -> float: v4 = v1.conj().T @ v3 @ v1 v5 = 1 for v6 in range(v3.shape[0]): v5 -= v4[v6, v6] + v2[v6] - 2 * v2[v6] * v4[v6, v6] return v5
[]
[]
[]
6
# Copyright 2020 Google # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, soft...
null
v0
[ "np.ndarray", "np.ndarray" ]
float
def v0(v1: np.ndarray, v2: np.ndarray) -> float: (v3, v4) = np.linalg.eigh(v2) v5 = np.where(np.isclose(v3, 1))[0] v6 = v4[:, v5] return abs(np.linalg.det(v1[:, :len(v5)].conj().T @ v6)) ** 2
[]
[ "numpy" ]
[ "import numpy as np" ]
5
# Copyright 2020 Google # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, soft...
null
v2
[ "Iterable[v1]", "Callable[[v1], Optional[Iterable[v1]]]", "bool", "bool", "Callable[[v1], int]" ]
Generator[Union[v1, v0], None, None]
def v2(v3: Iterable[v1], v4: Callable[[v1], Optional[Iterable[v1]]], v5: bool=True, v6: bool=False, v7: Callable[[v1], int]=id) -> Generator[Union[v1, v0], None, None]: v3 = deque(v3) v8: Set[int] = set() v9: Callable[[], v1] if v5: v9 = v3.popleft else: v9 = v3.pop while v3: ...
[]
[ "collections" ]
[ "from collections import deque" ]
20
"""Core graph classes.""" import warnings from collections import deque from copy import copy from itertools import count from typing import ( TYPE_CHECKING, Callable, Collection, Deque, Dict, Generator, Iterable, Iterator, List, Optional, Reversible, Sequence, Set, ...
[ "v0 = Tuple[T, Optional[Iterable[T]]]", "v1 = TypeVar('T', bound='Node')" ]
v129
[ "Sequence[v37]", "Sequence[v37]", "bool", "bool", "Optional[Dict[v31, v31]]" ]
Dict[v31, v31]
def v129(v130: Sequence[v37], v131: Sequence[v37], v132: bool=True, v133: bool=True, v134: Optional[Dict[v31, v31]]=None) -> Dict[v31, v31]: if v134 is None: v134 = {} for v135 in v130: if v132: v136 = v135.clone() v136.owner = None v136.index = None ...
[ { "name": "v74", "input_types": [ "Iterable[v36]", "Callable[[v36], Union[OrderedSet, List[v36]]]", "Optional[Callable[[v36], Optional[Union[OrderedSet, List[v36]]]]]", "Optional[Dict[v36, List[v36]]]", "Optional[Dict[v36, List[v36]]]" ], "output_type": "List[v36]", ...
[ "collections", "typing" ]
[ "from collections import deque", "from typing import TYPE_CHECKING, Callable, Collection, Deque, Dict, Generator, Iterable, Iterator, List, Optional, Reversible, Sequence, Set, Tuple, TypeVar, Union, cast" ]
27
"""Core graph classes.""" import warnings from collections import deque from copy import copy from itertools import count from typing import ( TYPE_CHECKING, Callable, Collection, Deque, Dict, Generator, Iterable, Iterator, List, Optional, Reversible, Sequence, Set, ...
[ "class v0(Node):\n\n def __init__(self, v1, v2, v3):\n \"\"\"\n Parameters\n ----------\n op : Op\n inputs : List[Variable]\n outputs : List[Variable]\n\n \"\"\"\n self.op = v1\n self.inputs: List[Variable] = []\n self.tag = Scratchpad()\n ...
v31
[ "v0", "v0" ]
bool
def v31(v32: v0, v33: v0) -> bool: v34 = set() v35 = [v32] while v35: v36 = v35.pop() if v36.outputs[0] in v34: continue if all((i in v34 or i.owner is None for v37 in v36.inputs)): v34.update(v36.outputs) if v36 is v33: return True...
[]
[]
[]
15
"""Core graph classes.""" import warnings from collections import deque from copy import copy from itertools import count from typing import ( TYPE_CHECKING, Callable, Collection, Deque, Dict, Generator, Iterable, Iterator, List, Optional, Reversible, Sequence, Set, ...
[ "class v0(Node):\n\n def __init__(self, v1, v2, v3):\n \"\"\"\n Parameters\n ----------\n op : Op\n inputs : List[Variable]\n outputs : List[Variable]\n\n \"\"\"\n self.op = v1\n self.inputs: List[Variable] = []\n self.tag = Scratchpad()\n ...
v0
[ "bool" ]
Any
def v0(self, v1: bool=True): if self.scaleDegree != 2: return False if not self.frontAlterationAccidental: return False if self.frontAlterationAccidental.name != 'flat': return False if self.quality != 'major': return False if v1 and self.inversion() != 1: ret...
[]
[]
[]
12
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Name: roman.py # Purpose: music21 classes for doing Roman Numeral / Tonal analysis # # Authors: Michael Scott Cuthbert # Christopher Ariza # # Copyright: Copyright © 2011-2013 Mic...
null
v6
[ "bool" ]
Any
def v6(self, v7: bool=False): if v7 and self.secondaryRomanNumeral: return self.secondaryRomanNumeral.isMixture(evaluateSecondaryNumeral=True) if not self.isTriad and (not self.isSeventh): return False if not self.key or not isinstance(self.key, v3.Key): return False v8 = self.ke...
[ { "name": "v0", "input_types": [ "str" ], "output_type": "key.Key", "code": "def v0(v1: str) -> key.Key:\n if v1 in _keyCache:\n v2 = copy.copy(_keyCache[v1])\n else:\n v2 = key.Key(v1)\n _keyCache[v2.tonicPitchNameWithCase] = v2\n return v2", "dependencie...
[ "copy" ]
[ "import copy" ]
33
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Name: roman.py # Purpose: music21 classes for doing Roman Numeral / Tonal analysis # # Authors: Michael Scott Cuthbert # Christopher Ariza # # Copyright: Copyright © 2011-2013 Mic...
null
v0
[ "Dict[str, Any]" ]
Dict[str, Any]
def v0(v1: Dict[str, Any]) -> Dict[str, Any]: v2 = list(v1.keys()) for v3 in v2: if 'arms' in v3: v1[v3.replace('arms', 'trials')] = v1.pop(v3) if v3 == 'recommended_max_parallelism': v1['max_parallelism'] = v1.pop(v3) return v1
[]
[]
[]
8
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import datetime import pickle from collections import OrderedDict from enum import Enum from inspect import isclass fro...
null
v12
[ "str", "owners_data.Owners" ]
None
def v12(v13: str, v14: owners_data.Owners) -> None: v15 = v14 v16 = set() while v15: if v15.owners_file in v16: return if not v14.owners and v15.owners: v14.owners.extend(v15.owners) if v14.owners: return v16.add(v15.owners_file) if...
[ { "name": "v0", "input_types": [ "str", "str" ], "output_type": "owners_data.Owners", "code": "def v0(v1: str, v2: str) -> owners_data.Owners:\n if not v2:\n return None\n assert v2.startswith(os.path.join(v1, ''))\n v3 = v2[len(v1) + 1:]\n if v3 in owners_map:\n ...
[ "os" ]
[ "import os" ]
17
#!/usr/bin/env python3 # Copyright 2020 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. r'''Get chromium OWNERS information for android directories. tools/android/modularization/owners/getowners.py -- \ --git-dir ~/c...
null
v0
[ "np.ndarray", "list" ]
Any
def v0(self, v1: np.ndarray, v2: list): v3 = [self.layer_dict[layer_id].output for v4 in v2] return self._feed_input(v3, v1)
[]
[]
[]
3
# standard imports from collections import OrderedDict # new in version 2.7 import sys import os import logging # third party imports import numpy as np from dltb.thirdparty.keras import keras from dltb.thirdparty.tensorflow.v1 import tf # toolbox imports from . import Network as BaseNetwork from .keras import Netwo...
null
v0
[ "list", "np.ndarray" ]
Any
def v0(self, v1: list, v2: np.ndarray): v3 = self._sess.graph.get_operations() v4 = [] for v5 in v1: v6 = self.layer_dict[v5].output.op v4.append(v6.inputs[0]) return self._feed_input(v4, v2)
[]
[]
[]
7
# standard imports from collections import OrderedDict # new in version 2.7 import sys import os import logging # third party imports import numpy as np from dltb.thirdparty.keras import keras from dltb.thirdparty.tensorflow.v1 import tf # toolbox imports from . import Network as BaseNetwork from .keras import Netwo...
null
v0
[ "list", "np.ndarray" ]
Any
def v0(self, v1: list, v2: np.ndarray): v3 = self._model.layers[0].input return self._sess.run(fetches=v1, feed_dict={v3: v2})
[]
[]
[]
3
# standard imports from collections import OrderedDict # new in version 2.7 import sys import os import logging # third party imports import numpy as np from dltb.thirdparty.keras import keras from dltb.thirdparty.tensorflow.v1 import tf # toolbox imports from . import Network as BaseNetwork from .keras import Netwo...
null
v0
[]
None
def v0(self) -> None: if not any([logging.getLogger().handlers, logging.getLogger('tornado').handlers, logging.getLogger('tornado.application').handlers]): logging.basicConfig()
[]
[ "logging" ]
[ "import logging" ]
3
# # Copyright 2009 Facebook # # 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 agreed to in writing, s...
null
v0
[]
None
def v0(self) -> None: self._running = False if self._timeout is not None: self.io_loop.remove_timeout(self._timeout) self._timeout = None
[]
[]
[]
5
# # Copyright 2009 Facebook # # 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 agreed to in writing, s...
null
v0
[ "Union[float, datetime.timedelta]", "Callable[..., Optional[Awaitable]]" ]
object
def v0(self, v1: Union[float, datetime.timedelta], v2: Callable[..., Optional[Awaitable]], *v3: Any, **v4: Any) -> object: if isinstance(v1, numbers.Real): return self.call_at(v1, v2, *v3, **v4) elif isinstance(v1, datetime.timedelta): return self.call_at(self.time() + v1.total_seconds(), v2, *v...
[]
[ "datetime", "numbers" ]
[ "import datetime", "import numbers" ]
7
# # Copyright 2009 Facebook # # 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 agreed to in writing, s...
null
v3
[ "Union[int, v0]" ]
Tuple[int, Union[int, v0]]
def v3(self, v4: Union[int, v0]) -> Tuple[int, Union[int, v0]]: if isinstance(v4, int): return (v4, v4) return (v4.fileno(), v4)
[]
[]
[]
4
# # Copyright 2009 Facebook # # 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 agreed to in writing, s...
[ "class v0(Protocol):\n\n def v1(self) -> int:\n pass\n\n def v2(self) -> None:\n pass" ]
v3
[ "Union[int, v0]" ]
None
def v3(self, v4: Union[int, v0]) -> None: try: if isinstance(v4, int): os.close(v4) else: v4.close() except OSError: pass
[]
[ "os" ]
[ "import os" ]
8
# # Copyright 2009 Facebook # # 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 agreed to in writing, s...
[ "class v0(Protocol):\n\n def v1(self) -> int:\n pass\n\n def v2(self) -> None:\n pass" ]
v0
[]
None
def v0(self) -> None: if self._running: self._update_next(self.io_loop.time()) self._timeout = self.io_loop.add_timeout(self._next_timeout, self._run)
[]
[]
[]
4
# # Copyright 2009 Facebook # # 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 agreed to in writing, s...
null
v0
[ "float" ]
None
def v0(self, v1: float) -> None: v2 = self.callback_time / 1000.0 if self.jitter: v2 *= 1 + self.jitter * (random.random() - 0.5) if self._next_timeout <= v1: self._next_timeout += (math.floor((v1 - self._next_timeout) / v2) + 1) * v2 else: self._next_timeout += v2
[]
[ "math", "random" ]
[ "import math", "import random" ]
8
# # Copyright 2009 Facebook # # 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 agreed to in writing, s...
null
v9
[ "List[str]", "List[str]" ]
Any
def v9(v10: List[str], v11: List[str]): assert len(v10) == len(v11) v12 = 0 for (v13, v14) in zip(v10, v11): v15 = v0(v13.lower(), v14.lower()) if v15: v12 += 1 return v12 / len(v10)
[ { "name": "v0", "input_types": [ "str", "str" ], "output_type": "Any", "code": "def v0(v1: str, v2: str):\n v3 = v1.split(delimiter)\n v4 = v2.split(delimiter)\n v5 = defaultdict(lambda : 0)\n v6 = defaultdict(lambda : 0)\n for v7 in v3:\n try:\n v5[f...
[ "collections" ]
[ "from collections import defaultdict" ]
8
#!/usr/bin/env python # coding=utf-8 # Copyright 2022 The Microsoft and The HuggingFace Inc. team. 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.apac...
null
v3
[ "str", "str", "str" ]
bool
def v3(self, v4: str, v5: str, v6: str) -> bool: @lru_cache(None) def v7(v8, v9): if v8 == -1 and v9 == -1: return True return v9 >= 0 and v5[v9] == v6[v8 + v9 + 1] and v7(v8, v9 - 1) or (v8 >= 0 and v4[v8] == v6[v8 + v9 + 1] and v7(v8 - 1, v9)) return len(v4) + len(v5) == len(v...
[ { "name": "v0", "input_types": [ "Any", "Any" ], "output_type": "Any", "code": "@lru_cache(None)\ndef v0(v1, v2):\n if v1 == -1 and v2 == -1:\n return True\n return v2 >= 0 and s2[v2] == s3[v1 + v2 + 1] and v0(v1, v2 - 1) or (v1 >= 0 and s1[v1] == s3[v1 + v2 + 1] and v0(...
[]
[]
8
# !/usr/bin/env python3 # Author: C.K # Email: theck17@163.com # DateTime:2021-10-04 20:40:16 # Description: class Solution: def isInterleave(self, s1: str, s2: str, s3: str) -> bool: @lru_cache(None) def dp(i, j): if i == -1 and j == -1: return True return (j >= 0 and s2[j] ...
null
v0
[ "Dict[str, Any]" ]
Any
def v0(self, v1: Dict[str, Any]): self.best_model_score = v1['best_model_score'] self.best_model_path = v1['best_model_path']
[]
[]
[]
3
# Copyright The PyTorch Lightning 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 applicable law or agreed to i...
null
v0
[ "str", "Any", "Any" ]
Any
def v0(self, v1: str, v2, v3): v2.dev_debugger.track_checkpointing_history(v1) if v2.is_global_zero: self._fs.makedirs(os.path.dirname(v1), exist_ok=True) if self.save_function is not None: self.save_function(v1, self.save_weights_only) else: raise ValueError('.save_function() no...
[]
[ "os" ]
[ "import os" ]
8
# Copyright The PyTorch Lightning 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 applicable law or agreed to i...
null
v0
[ "int", "int", "Dict[str, Any]", "Optional[int]" ]
str
def v0(self, v1: int, v2: int, v3: Dict[str, Any], v4: Optional[int]=None) -> str: v5 = self._format_checkpoint_name(self.filename, v1, v2, v3, auto_insert_metric_name=self.auto_insert_metric_name) if v4 is not None: v5 = self.CHECKPOINT_JOIN_CHAR.join((v5, f'v{v4}')) v6 = f'{v5}{self.FILE_EXTENSION...
[]
[ "os" ]
[ "import os" ]
6
# Copyright The PyTorch Lightning 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 applicable law or agreed to i...
null
v0
[ "Dict[str, Any]", "int", "int", "Any", "Optional[str]" ]
str
def v0(self, v1: Dict[str, Any], v2: int, v3: int, v4, v5: Optional[str]=None) -> str: v6 = self.format_checkpoint_name(v2, v3, v1) v7 = self.STARTING_VERSION while self.file_exists(v6, v4) and v6 != v5: v6 = self.format_checkpoint_name(v2, v3, v1, ver=v7) v7 += 1 return v6
[]
[]
[]
7
# Copyright The PyTorch Lightning 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 applicable law or agreed to i...
null
v0
[ "Union[str, Path]", "'pl.Trainer'" ]
bool
def v0(self, v1: Union[str, Path], v2: 'pl.Trainer') -> bool: v3 = self._fs.exists(v1) return v2.training_type_plugin.broadcast(v3)
[]
[]
[]
3
# Copyright The PyTorch Lightning 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 applicable law or agreed to i...
null
v0
[ "str" ]
Any
def v0(self, v1: str): if not self.connection: raise Exception('Connection has already been closed. Could not execute.') self.connection.execute(v1)
[]
[]
[]
4
import json from ingestion.sources.base import SQLAlchemyExtractor from .postgresql import PostgreSQLSource, PostgreSQLSourceConfiguration, PostgreSQLSourceDialect class RedshiftSourceConfiguration(PostgreSQLSourceConfiguration): def _connection_string_prefix(self) -> str: return "redshift+psycopg2" ...
null
v0
[ "Any", "Any" ]
bool
def v0(self, v1, v2) -> bool: self.isa = v2['hart0']['ISA'] if 'RV32' in self.isa: self.isa_bit = 'rv32' self.xlen = 32 self.offset_inc = 4 else: self.isa_bit = 'rv64' self.xlen = 64 self.offset_inc = 8 if 'M' in self.isa or 'Zmmul' in self.isa: re...
[]
[]
[]
14
from random import randint from typing import Dict, List, Union from yapsy.IPlugin import IPlugin class uatg_mbox_div_by_zero(IPlugin): """ This class contains methods to generate and validate the the division by zero operation with x0 as divisor(rs2) """ def __init__(self) -> None: supe...
null
v0
[ "str" ]
str
def v0(v1: str) -> str: v1 = os.path.abspath(os.path.expanduser(v1)) v1 = v1.replace('\\', '/') if v1.startswith('./'): return v1[2:] else: return v1
[]
[ "os" ]
[ "import os" ]
7
from __future__ import print_function import datetime import hashlib import io import logging import os import re import time import azure.batch.models as batch_models import azure.common import azure.storage.blob as blob import yaml import aztk.models from aztk import error _STANDARD_OUT_FILE_NAME = "stdout.txt" _...
null
v0
[ "bool" ]
Any
def v0(v1: bool): if v1 is True: return 'true' else: return 'false'
[]
[]
[]
5
from __future__ import print_function import datetime import hashlib import io import logging import os import re import time import azure.batch.models as batch_models import azure.common import azure.storage.blob as blob import yaml import aztk.models from aztk import error _STANDARD_OUT_FILE_NAME = "stdout.txt" _...
null
v0
[]
pd.DataFrame
def v0(self, *v1, **v2) -> pd.DataFrame: v3 = pd.read_csv(self.input_path, sep=self.separator) v4 = self.filter_df(v3) return v4
[]
[ "pandas" ]
[ "import pandas as pd" ]
4
import pandas as pd from typing import List, Tuple, Union import os from yolo_labels.shared import LabelReader from utils.images import normalize_bbox_coordinates class VoTTLabelReader(LabelReader): def __init__(self, input_path: str, label_id_mapper: dict, obje...
null
v0
[]
tuple
def v0(self) -> tuple: for (v1, v2) in self.data.groupby('image'): v3 = self.get_image_bboxes(v2) yield (v2.iloc[0, 0], v3)
[]
[]
[]
4
import pandas as pd from typing import List, Tuple, Union import os from yolo_labels.shared import LabelReader from utils.images import normalize_bbox_coordinates class VoTTLabelReader(LabelReader): def __init__(self, input_path: str, label_id_mapper: dict, obje...
null
v0
[ "pd.DataFrame" ]
List[Tuple[int, int, int, int, int]]
def v0(self, v1: pd.DataFrame) -> List[Tuple[int, int, int, int, int]]: v2 = [] for (v3, v4) in v1.iterrows(): v5 = self.get_image_bboxes_labels(v4) if v5 is None: continue v2 += [v5] return v2
[]
[]
[]
8
import pandas as pd from typing import List, Tuple, Union import os from yolo_labels.shared import LabelReader from utils.images import normalize_bbox_coordinates class VoTTLabelReader(LabelReader): def __init__(self, input_path: str, label_id_mapper: dict, obje...
null
v0
[ "pd.Series" ]
Any
def v0(self, v1: pd.Series): v2 = self.get_label_id(v1['label']) if v2 is None: return None v3 = (v1['xmin'], v1['ymin'], v1['xmax'], v1['ymax']) return (*self.get_bbox_coordinates(v1['image'], v3), v2)
[]
[]
[]
6
import pandas as pd from typing import List, Tuple, Union import os from yolo_labels.shared import LabelReader from utils.images import normalize_bbox_coordinates class VoTTLabelReader(LabelReader): def __init__(self, input_path: str, label_id_mapper: dict, obje...
null
v0
[ "pd.DataFrame" ]
pd.DataFrame
def v0(self, v1: pd.DataFrame) -> pd.DataFrame: if type(self.object_labels) is str: return v1[v1['label'] == self.object_labels] elif type(self.object_labels) is List[str]: return v1[v1['label'].isin(self.object_labels)]
[]
[ "typing" ]
[ "from typing import List, Tuple, Union" ]
5
import pandas as pd from typing import List, Tuple, Union import os from yolo_labels.shared import LabelReader from utils.images import normalize_bbox_coordinates class VoTTLabelReader(LabelReader): def __init__(self, input_path: str, label_id_mapper: dict, obje...
null
v0
[ "'cirq.ApplyUnitaryArgs'" ]
Any
def v0(self, v1: 'cirq.ApplyUnitaryArgs'): v2 = list(range(len(v1.target_tensor.shape))) for v3 in range(len(v1.axes)): v4 = self.permutation[v3] v5 = v1.axes[v3] v6 = v1.axes[v4] assert v1.target_tensor.shape[v5] == v1.target_tensor.shape[v6] v2[v6] = v5 v1.available...
[]
[]
[]
10
# Copyright 2020 The Cirq Developers # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in ...
null
v0
[ "np.ndarray", "np.ndarray", "np.ndarray", "float", "float" ]
Any
def v0(self, v1: np.ndarray, v2: np.ndarray, v3: np.ndarray, v4: float, v5: float): v6 = self.icre.estimate_lmda(v1) v7 = self.icre.estimate_mu(v2, v6) v8 = self.icre.compute_odometry(v6, v7, v5) v9 = 1 v10 = True while v10: (v11, v12, v13) = self.path_planner.compute_chassis_motion(v3, ...
[]
[]
[]
18
from icrestimator import ICREstimator from pathplanner import PathPlanner from kinematicmodel import KinematicModel from timescaler import TimeScaler from motionintegrator import MotionIntegrator import numpy as np from typing import List class ICRController: """ ICRController is the class that implements the...
null
v0
[]
str
def v0(self) -> str: v1 = os.path.join(self.app_dir, 'lib') logging.debug('Looking linker binary at: %s\n' % v1) v2 = self._find_binary_by_name(v1) v2 = self._resolve_symlink(v2) v2 = self._make_path_relative_to_app_dir(v2) return v2
[]
[ "logging", "os" ]
[ "import logging", "import os" ]
7
# Copyright 2020 Alexis Lopez Zubieta # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publi...
null