name
stringclasses
293 values
input_types
listlengths
0
49
output_type
stringlengths
1
180
code
stringlengths
37
97.8k
dependencies
listlengths
0
6
lib_used
listlengths
0
11
imports
listlengths
0
40
line_count
int64
3
155
full_code
stringlengths
51
996k
input_type_defs
listlengths
1
11
v10
[ "Logger", "komand.connection", "list" ]
list
def v10(v11: Logger, v12: komand.connection, v13: list) -> list: v14 = [] for v15 in v13: v11.info(f'Getting user ID: {v15}') v16 = v0(v11, v12, v15) v17 = v16.get('id') v18 = f'https://graph.microsoft.com/v1.0/{v12.tenant_id}/users/{v17}' v14.append(v18) return v14
[ { "name": "v0", "input_types": [ "Logger", "komand.connection", "str" ], "output_type": "dict", "code": "def v0(v1: Logger, v2: komand.connection, v3: str) -> dict:\n v4 = f\"https://graph.microsoft.com/v1.0/{v2.tenant_id}/users?$filter=userPrincipalName eq '{v3}'\"\n v5 ...
[ "requests" ]
[ "import requests" ]
9
from komand.exceptions import PluginException from time import sleep import requests from logging import Logger import komand.connection def get_user_info(logger: Logger, connection: komand.connection, user_login: str) -> dict: """ This is used to get information about a user using the user login :param ...
null
v15
[ "object" ]
Tuple[Dict[int, object], Dict[int, Tuple[int, object]]]
def v15(v16: object) -> Tuple[Dict[int, object], Dict[int, Tuple[int, object]]]: v17 = {} v18 = {id(v16): v16} v19 = [v16] while v19: v20 = v19.pop() for (v21, v22) in v7(v20): if id(v22) in v18: continue v17[id(v22)] = (id(v20), v21) v...
[ { "name": "v0", "input_types": [ "object" ], "output_type": "Iterator[Tuple[object, object]]", "code": "def v0(v1: object) -> Iterator[Tuple[object, object]]:\n if type(v1) not in COLLECTION_TYPE_BLACKLIST:\n for v2 in dir(v1):\n if v2 not in ATTR_BLACKLIST and hasattr...
[ "collections", "typing" ]
[ "from collections.abc import Iterable", "from typing import List, Dict, Iterator, Tuple, Mapping" ]
13
"""Find all objects reachable from a root object.""" from collections.abc import Iterable from typing import List, Dict, Iterator, Tuple, Mapping import weakref import types method_descriptor_type = type(object.__dir__) method_wrapper_type = type(object().__ne__) wrapper_descriptor_type = type(object.__ne__) FUNCTI...
null
v0
[ "List[object]" ]
Dict[type, List[object]]
def v0(v1: List[object]) -> Dict[type, List[object]]: v2 = {} for v3 in v1: v2.setdefault(type(v3), []).append(v3) return v2
[]
[]
[]
5
"""Find all objects reachable from a root object.""" from collections.abc import Iterable from typing import List, Dict, Iterator, Tuple, Mapping import weakref import types method_descriptor_type = type(object.__dir__) method_wrapper_type = type(object().__ne__) wrapper_descriptor_type = type(object.__ne__) FUNCTI...
null
v0
[ "object", "Dict[int, object]", "Dict[int, Tuple[int, object]]" ]
List[Tuple[object, object]]
def v0(v1: object, v2: Dict[int, object], v3: Dict[int, Tuple[int, object]]) -> List[Tuple[object, object]]: v4 = [] while id(v1) in v3: (v5, v6) = v3[id(v1)] v1 = v2[v5] v4.append((v6, v1)) v4.reverse() return v4
[]
[]
[]
8
"""Find all objects reachable from a root object.""" from collections.abc import Iterable from typing import List, Dict, Iterator, Tuple, Mapping import weakref import types method_descriptor_type = type(object.__dir__) method_wrapper_type = type(object().__ne__) wrapper_descriptor_type = type(object.__ne__) FUNCTI...
null
v0
[ "discord.User" ]
Any
def v0(self, v1: discord.User): try: return self.players[str(v1.id)] except: return None
[]
[]
[]
5
import collections import datetime import uuid import struct from queue import Queue from typing import List from .strings import Strings import discord SELECTION_MODES = { 0x1F3B2: Strings.RANDOM_TS, # game_die 0x1F1E8: Strings.CAPTAINS_TS, # C 0x0262F: Strings.BALANCED_TS, # yin_yang 0x0FE0F...
null
v0
[ "str", "Any" ]
Any
def v0(v1: str, v2): v3 = min((i for (v4, v5, v4) in v2 if v5 > 0), default=0) v6 = max((v5 for (v4, v4, v5) in v2 if v5 > 0), default=v3) return [v1, v3, v6]
[]
[]
[]
4
# parser combinators """ This module defines basic parser combinators. Each 'Parse' object transforms an 'Item' to an 'Item'. Following the class functions for Parse, we give basic parsers for words, phrases, delimited expressions, and lists """ import msg import lib import lexer import word_lists import copy f...
null
v2
[ "Any" ]
str
def v2(v3) -> str: v4 = v3.value if v3.type == 'VAR': v4 = v4.lower() return v0(v4)
[ { "name": "v0", "input_types": [ "str" ], "output_type": "str", "code": "def v0(v1: str) -> str:\n if len(v1) < MIN_LEN_SYNONYM:\n return v1\n return synonym.get(v1, v1)", "dependencies": [] } ]
[]
[]
5
# parser combinators """ This module defines basic parser combinators. Each 'Parse' object transforms an 'Item' to an 'Item'. Following the class functions for Parse, we give basic parsers for words, phrases, delimited expressions, and lists """ import msg import lib import lexer import word_lists import copy f...
null
v121
[ "v0", "v0", "v0" ]
v0
def v121(v122: v0, v123: v0, v124: v0) -> v0: def v125(v126): try: v122.process(v126) except: return v124.process(v126) return v123.process(v126)
[]
[]
[]
8
# parser combinators """ This module defines basic parser combinators. Each 'Parse' object transforms an 'Item' to an 'Item'. Following the class functions for Parse, we give basic parsers for words, phrases, delimited expressions, and lists """ import msg import lib import lexer import word_lists import copy f...
[ "class v0:\n\n def __init__(self, v1):\n \"\"\"r:Item->Item, repr:str\"\"\"\n self.process = v1\n\n def v2(self, v3):\n self.repr = v3\n return self\n\n def v4():\n return v0(next_item)\n\n def v5():\n \"\"\"fails if tokens remain in stream, otherwise do nothing...
v128
[ "v0", "str", "str" ]
v0
def v128(v129: v0, v130: str, v131: str) -> v0: def v132(v133): ((v134, v135), v136) = v133 v135 = v135 if type(v135) is list else [v135] return [v134] + v135 + [v136] return (v126(v130) + v129 + v126(v131)).treat(v132)
[ { "name": "v121", "input_types": [ "Any" ], "output_type": "Any", "code": "def v121(v122):\n ((v123, v124), v125) = v122\n v124 = v124 if type(v124) is list else [v124]\n return [v123] + v124 + [v125]", "dependencies": [] }, { "name": "v126", "input_types": [ ...
[]
[]
7
# parser combinators """ This module defines basic parser combinators. Each 'Parse' object transforms an 'Item' to an 'Item'. Following the class functions for Parse, we give basic parsers for words, phrases, delimited expressions, and lists """ import msg import lib import lexer import word_lists import copy f...
[ "class v0:\n\n def __init__(self, v1):\n \"\"\"r:Item->Item, repr:str\"\"\"\n self.process = v1\n\n def v2(self, v3):\n self.repr = v3\n return self\n\n def v4():\n return v0(next_item)\n\n def v5():\n \"\"\"fails if tokens remain in stream, otherwise do nothing...
v139
[ "v0", "str", "str" ]
v0
def v139(v140: v0, v141: str, v142: str) -> v0: def v143(v144): return v144[1:-1] return v121(v140, v141, v142).treat(v143)
[ { "name": "v121", "input_types": [ "v0", "str", "str" ], "output_type": "v0", "code": "def v121(v122: v0, v123: str, v124: str) -> v0:\n\n def v125(v126):\n ((v127, v128), v129) = v126\n v128 = v128 if type(v128) is list else [v128]\n return [v127] + v12...
[]
[]
5
# parser combinators """ This module defines basic parser combinators. Each 'Parse' object transforms an 'Item' to an 'Item'. Following the class functions for Parse, we give basic parsers for words, phrases, delimited expressions, and lists """ import msg import lib import lexer import word_lists import copy f...
[ "class v0:\n\n def __init__(self, v1):\n \"\"\"r:Item->Item, repr:str\"\"\"\n self.process = v1\n\n def v2(self, v3):\n self.repr = v3\n return self\n\n def v4():\n return v0(next_item)\n\n def v5():\n \"\"\"fails if tokens remain in stream, otherwise do nothing...
v6
[]
str
def v6(self) -> str: v7 = self.github.graphql('\n query {\n repository(name: "pytorch", owner: "pytorch") {\n pullRequests {\n nodes {\n number\n baseRefName\n headRefName\n title\n b...
[ { "name": "v0", "input_types": [ "str", "str" ], "output_type": "str", "code": "def v0(v1: str, v2: str) -> str:\n return ''.join((v2 + line if line.strip() else line for v3 in v1.splitlines(True)))", "dependencies": [] }, { "name": "v4", "input_types": [ "st...
[ "re" ]
[ "import re" ]
11
from __future__ import print_function import contextlib import io import logging import os import re import shutil import sys import tempfile import unittest from typing import Dict, Iterator, List, NewType, Optional, Tuple import ghstack.expecttest as expecttest import ghstack.github import ghstack.github_fake impor...
null
v0
[]
None
def v0(self) -> None: print('####################') print('### test_simple') print('###') print('### First commit') self.writeFileAndAdd('a', 'asdf') self.sh.git('commit', '-m', 'Commit 1\n\nThis is my first commit') self.sh.test_tick() self.gh('Initial 1') self.substituteRev('HEAD',...
[]
[]
[]
22
from __future__ import print_function import contextlib import io import logging import os import re import shutil import sys import tempfile import unittest from typing import Dict, Iterator, List, NewType, Optional, Tuple import ghstack.expecttest as expecttest import ghstack.github import ghstack.github_fake impor...
null
v0
[]
None
def v0(self) -> None: print('####################') print('### test_empty_commit') print('###') print('### Empty commit') self.sh.git('commit', '--allow-empty', '-m', 'Commit 1\n\nThis is my first commit') self.writeFileAndAdd('bar', 'baz') self.sh.git('commit', '-m', 'Commit 2') self.sh...
[]
[]
[]
13
from __future__ import print_function import contextlib import io import logging import os import re import shutil import sys import tempfile import unittest from typing import Dict, Iterator, List, NewType, Optional, Tuple import ghstack.expecttest as expecttest import ghstack.github import ghstack.github_fake impor...
null
v0
[]
None
def v0(self) -> None: print('####################') print('### test_amend') print('###') print('### First commit') self.writeFileAndAdd('file1.txt', 'A') self.sh.git('commit', '-m', 'Commit 1\n\nA commit with an A') self.sh.test_tick() self.gh('Initial 1') self.substituteRev('HEAD', ...
[]
[]
[]
20
from __future__ import print_function import contextlib import io import logging import os import re import shutil import sys import tempfile import unittest from typing import Dict, Iterator, List, NewType, Optional, Tuple import ghstack.expecttest as expecttest import ghstack.github import ghstack.github_fake impor...
null
v0
[]
None
def v0(self) -> None: print('####################') print('### test_amend_out_of_date') print('###') print('### First commit') self.writeFileAndAdd('file1.txt', 'A') self.sh.git('commit', '-m', 'Commit 1\n\nA commit with an A') self.sh.test_tick() self.gh('Initial 1') v1 = self.sh.gi...
[]
[]
[]
21
from __future__ import print_function import contextlib import io import logging import os import re import shutil import sys import tempfile import unittest from typing import Dict, Iterator, List, NewType, Optional, Tuple import ghstack.expecttest as expecttest import ghstack.github import ghstack.github_fake impor...
null
v0
[]
None
def v0(self) -> None: print('####################') print('### test_amend_bottom') print('###') print('### First commit') self.writeFileAndAdd('file1.txt', 'A') self.sh.git('commit', '-m', 'Commit 1\n\nA commit with an A') self.sh.test_tick() self.gh('Initial 1') self.substituteRev('...
[]
[]
[]
38
from __future__ import print_function import contextlib import io import logging import os import re import shutil import sys import tempfile import unittest from typing import Dict, Iterator, List, NewType, Optional, Tuple import ghstack.expecttest as expecttest import ghstack.github import ghstack.github_fake impor...
null
v0
[]
None
def v0(self) -> None: print('####################') print('### test_no_clobber') self.writeFileAndAdd('b', 'asdf') self.sh.git('commit', '-m', 'Commit 1\n\nOriginal message') self.sh.test_tick() self.gh('Initial 1') self.sh.test_tick() self.substituteRev('HEAD', 'rCOM1') self.substit...
[]
[]
[]
25
from __future__ import print_function import contextlib import io import logging import os import re import shutil import sys import tempfile import unittest from typing import Dict, Iterator, List, NewType, Optional, Tuple import ghstack.expecttest as expecttest import ghstack.github import ghstack.github_fake impor...
null
v0
[]
None
def v0(self) -> None: self.writeFileAndAdd('a', 'asdf') self.sh.git('commit', '-m', 'Commit 1\n\nThis is my first commit') self.sh.test_tick() self.gh('Initial 1') self.substituteRev('HEAD', 'rCOM1') self.substituteRev('origin/gh/ezyang/1/head', 'rMRG1') self.sh.git('checkout', 'gh/ezyang/1/...
[]
[]
[]
12
from __future__ import print_function import contextlib import io import logging import os import re import shutil import sys import tempfile import unittest from typing import Dict, Iterator, List, NewType, Optional, Tuple import ghstack.expecttest as expecttest import ghstack.github import ghstack.github_fake impor...
null
v0
[]
None
def v0(self) -> None: print('####################') print('### test_update_fields') self.writeFileAndAdd('b', 'asdf') self.sh.git('commit', '-m', 'Commit 1\n\nOriginal message') self.sh.test_tick() self.gh('Initial 1') self.sh.test_tick() self.substituteRev('HEAD', 'rCOM1') self.subs...
[]
[]
[]
18
from __future__ import print_function import contextlib import io import logging import os import re import shutil import sys import tempfile import unittest from typing import Dict, Iterator, List, NewType, Optional, Tuple import ghstack.expecttest as expecttest import ghstack.github import ghstack.github_fake impor...
null
v5
[]
None
def v5(self) -> None: self.writeFileAndAdd('b', 'asdf') self.sh.git('commit', '-m', 'Commit 1\n\nThis is my first commit') self.sh.test_tick() with v0() as (v6, v7): self.gh('Initial', short=True) self.assertEqual(v6.getvalue(), 'https://github.com/pytorch/pytorch/pull/500\n')
[ { "name": "v0", "input_types": [], "output_type": "Iterator[Tuple[io.StringIO, io.StringIO]]", "code": "@contextlib.contextmanager\ndef v0() -> Iterator[Tuple[io.StringIO, io.StringIO]]:\n (v1, v2) = (io.StringIO(), io.StringIO())\n (v3, v4) = (sys.stdout, sys.stderr)\n try:\n (sys.s...
[ "io", "sys" ]
[ "import io", "import sys" ]
7
from __future__ import print_function import contextlib import io import logging import os import re import shutil import sys import tempfile import unittest from typing import Dict, Iterator, List, NewType, Optional, Tuple import ghstack.expecttest as expecttest import ghstack.github import ghstack.github_fake impor...
null
v0
[]
None
def v0(self) -> None: self.writeFileAndAdd('file1.txt', 'A') self.sh.git('commit', '-m', 'Commit 1\n\nThis is my first commit') self.sh.test_tick() (v1,) = self.gh('Initial') assert v1 is not None v2 = v1.pr_url self.substituteRev('HEAD', 'rCOM1') self.sh.git('reset', '--hard', 'origin/m...
[]
[]
[]
17
from __future__ import print_function import contextlib import io import logging import os import re import shutil import sys import tempfile import unittest from typing import Dict, Iterator, List, NewType, Optional, Tuple import ghstack.expecttest as expecttest import ghstack.github import ghstack.github_fake impor...
null
v0
[]
None
def v0(self) -> None: self.writeFileAndAdd('file1.txt', 'A') self.sh.git('commit', '-m', 'Commit 1\n\nThis is my first commit') self.sh.test_tick() self.writeFileAndAdd('file2.txt', 'B') self.sh.git('commit', '-m', 'Commit 2\n\nThis is my second commit') self.sh.test_tick() (v1, v2) = self.g...
[]
[]
[]
19
from __future__ import print_function import contextlib import io import logging import os import re import shutil import sys import tempfile import unittest from typing import Dict, Iterator, List, NewType, Optional, Tuple import ghstack.expecttest as expecttest import ghstack.github import ghstack.github_fake impor...
null
v0
[]
None
def v0(self) -> None: print('###') print('### First commit') self.writeFileAndAdd('file1.txt', 'A') self.sh.git('commit', '-m', 'Commit 1\n\nA commit with an A') self.sh.test_tick() self.writeFileAndAdd('file2.txt', 'B') self.sh.git('commit', '-m', 'Commit 1\n\nA commit with an B') self....
[]
[]
[]
17
from __future__ import print_function import contextlib import io import logging import os import re import shutil import sys import tempfile import unittest from typing import Dict, Iterator, List, NewType, Optional, Tuple import ghstack.expecttest as expecttest import ghstack.github import ghstack.github_fake impor...
null
v0
[]
None
def v0(self) -> None: self.writeFileAndAdd('file1.txt', 'A') self.sh.git('commit', '-m', 'Commit 1\n\nThis is my first commit') self.sh.test_tick() (v1,) = self.gh('Initial 1') assert v1 is not None self.substituteRev('origin/gh/ezyang/1/head', 'rMRG1') self.sh.git('branch', 'main', 'master'...
[]
[]
[]
28
from __future__ import print_function import contextlib import io import logging import os import re import shutil import sys import tempfile import unittest from typing import Dict, Iterator, List, NewType, Optional, Tuple import ghstack.expecttest as expecttest import ghstack.github import ghstack.github_fake impor...
null
v0
[]
Dict[str, Union[str, int, float]]
def v0(self) -> Dict[str, Union[str, int, float]]: v1 = {'name': self.name, 'value': self.value} if self.name_localizations is not None: v1['name_localizations'] = self.name_localizations return v1
[]
[]
[]
5
""" The MIT License (MIT) Copyright (c) 2021-present Pycord Development 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, ...
null
v0
[ "Union[Path, str]", "Union[Path, str]" ]
pd.DataFrame
def v0(v1: Union[Path, str], v2: Union[Path, str]) -> pd.DataFrame: v3 = pd.read_csv(v2).columns.values return pd.read_csv(v1, names=v3, parse_dates=True)
[]
[ "pandas" ]
[ "import pandas as pd" ]
3
import html import io from pathlib import Path from typing import Optional, Union import pandas as pd import numpy as np import pendulum import prefect from prefect import Flow, task, unmapped from prefect.core.parameter import Parameter from prefect.engine.results import S3Result from prefect.engine.serializers impo...
null
v0
[ "str", "str" ]
str
def v0(v1: str, v2: str) -> str: assert 2010 < v2.year, 'jday must be in range >= 2010' v3 = v1.capitalize()[:3] v4 = str(v2.year)[2:4] v5 = v2.timetuple().tm_yday return f'{v3}_M_{v4}_{v5}.dat'
[]
[]
[]
6
import html import io from pathlib import Path from typing import Optional, Union import pandas as pd import numpy as np import pendulum import prefect from prefect import Flow, task, unmapped from prefect.core.parameter import Parameter from prefect.engine.results import S3Result from prefect.engine.serializers impo...
null
v0
[ "BaseEstimator", "BaseEstimator" ]
Any
def v0(v1: BaseEstimator, v2: BaseEstimator): v3 = {k: v for (v4, v5) in vars(v1).items() if v4.endswith('_')} for (v4, v5) in v3.items(): setattr(v2, v4, v5)
[]
[]
[]
4
# Copyright 1999-2021 Alibaba Group Holding 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 a...
null
v0
[ "str" ]
str
def v0(v1: str) -> str: with open(v1, 'rb') as v2: v3 = v2.read() v4 = hashlib.sha256(v3).hexdigest() return v4
[]
[ "hashlib" ]
[ "import hashlib" ]
5
import os import time import pathlib import hashlib root = "C:/Users/icearrow256/Pictures/Screenshots/" def get_sha256(filename: str) -> str: with open(filename,"rb") as f: bytes = f.read() readable_hash = hashlib.sha256(bytes).hexdigest() return readable_hash def main(): files = list() ...
null
v9
[]
None
def v9() -> None: v10 = argparse.ArgumentParser(description='Rabit Tracker start.') v10.add_argument('--num-workers', required=True, type=int, help='Number of worker process to be launched.') v10.add_argument('--num-servers', default=0, type=int, help='Number of server process to be launched. Only used in P...
[ { "name": "v0", "input_types": [ "Optional[str]" ], "output_type": "str", "code": "def v0(v1: Optional[str]=None) -> str:\n if v1 is None or v1 == 'auto':\n v1 = 'ip'\n if v1 == 'dns':\n v1 = socket.getfqdn()\n elif v1 == 'ip':\n from socket import gaierror\n ...
[ "argparse", "logging", "socket", "sys" ]
[ "import socket", "import logging", "import argparse", "import sys" ]
19
# Copyright 1999-2021 Alibaba Group Holding 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 a...
null
v0
[ "int" ]
bytes
def v0(self, v1: int) -> bytes: v2 = [] v3 = 0 while v3 < v1: v4 = self.sock.recv(min(v1 - v3, 1024)) v3 += len(v4) v2.append(v4) return b''.join(v2)
[]
[]
[]
8
# Copyright 1999-2021 Alibaba Group Holding 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 a...
null
v0
[ "str" ]
None
def v0(self, v1: str) -> None: self.sendint(len(v1)) self.sock.sendall(v1.encode())
[]
[]
[]
3
# Copyright 1999-2021 Alibaba Group Holding 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 a...
null
v0
[]
str
def v0(self) -> str: v1 = self.recvint() return self.recvall(v1).decode()
[]
[]
[]
3
# Copyright 1999-2021 Alibaba Group Holding 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 a...
null
v0
[ "Dict[str, int]" ]
int
def v0(self, v1: Dict[str, int]) -> int: if self.rank >= 0: return self.rank if self.jobid != 'NULL' and self.jobid in v1: return v1[self.jobid] return -1
[]
[]
[]
6
# Copyright 1999-2021 Alibaba Group Holding 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 a...
null
v2
[ "int", "Dict[int, 'WorkerEntry']", "v1", "Dict[int, int]", "v0" ]
List[int]
def v2(self, v3: int, v4: Dict[int, 'WorkerEntry'], v5: v1, v6: Dict[int, int], v7: v0) -> List[int]: self.rank = v3 v8 = set(v5[v3]) (v9, v10) = v7[v3] self.sock.sendint(v3) self.sock.sendint(v6[v3]) self.sock.sendint(len(v5)) self.sock.sendint(len(v8)) for v11 in v8: self.sock....
[]
[]
[]
21
# Copyright 1999-2021 Alibaba Group Holding 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 a...
[ "v0 = Dict[int, Tuple[int, int]]", "v1 = Dict[int, List[int]]" ]
v0
[ "Dict[int, 'WorkerEntry']", "Set[int]" ]
List[int]
def v0(self, v1: Dict[int, 'WorkerEntry'], v2: Set[int]) -> List[int]: while True: v3 = self.sock.recvint() v4 = set([]) for v5 in range(v3): v4.add(self.sock.recvint()) assert v4.issubset(v2) v6 = v2 - v4 v7 = [] for v8 in v6: if v8 in...
[]
[]
[]
33
# Copyright 1999-2021 Alibaba Group Holding 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 a...
null
v1
[ "int" ]
Tuple[v0, Dict[int, int]]
def v1(self, v2: int) -> Tuple[v0, Dict[int, int]]: v3: v0 = {} v4: Dict[int, int] = {} for v5 in range(v2): v3[v5] = self._get_neighbor(v5, v2) v4[v5] = (v5 + 1) // 2 - 1 return (v3, v4)
[]
[]
[]
7
# Copyright 1999-2021 Alibaba Group Holding 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 a...
[ "v0 = Dict[int, List[int]]" ]
v1
[ "v0", "Dict[int, int]", "int" ]
List[int]
def v1(self, v2: v0, v3: Dict[int, int], v4: int) -> List[int]: v5 = set(v2[v4]) v6 = v5 - set([v3[v4]]) if not v6: return [v4] v7 = [v4] v8 = 0 for v9 in v6: v10 = self.find_share_ring(v2, v3, v9) v8 += 1 if v8 == len(v6): v10.reverse() v7 += ...
[]
[]
[]
14
# Copyright 1999-2021 Alibaba Group Holding 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 a...
[ "v0 = Dict[int, List[int]]" ]
v2
[ "v1", "Dict[int, int]" ]
v0
def v2(self, v3: v1, v4: Dict[int, int]) -> v0: assert v4[0] == -1 v5 = self.find_share_ring(v3, v4, 0) assert len(v5) == len(v3) v6: v0 = {} v7 = len(v3) for v8 in range(v7): v9 = (v8 + v7 - 1) % v7 v10 = (v8 + 1) % v7 v6[v5[v8]] = (v5[v9], v5[v10]) return v6
[]
[]
[]
11
# Copyright 1999-2021 Alibaba Group Holding 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 a...
[ "v0 = Dict[int, Tuple[int, int]]", "v1 = Dict[int, List[int]]" ]
v2
[ "int" ]
Tuple[v1, Dict[int, int], v0]
def v2(self, v3: int) -> Tuple[v1, Dict[int, int], v0]: (v4, v5) = self._get_tree(v3) v6 = self.get_ring(v4, v5) v7 = {0: 0} v8 = 0 for v9 in range(v3 - 1): v8 = v6[v8][1] v7[v8] = v9 + 1 v10: v0 = {} v11: v1 = {} v12: Dict[int, int] = {} for (v8, v13) in v6.items(): ...
[]
[]
[]
21
# Copyright 1999-2021 Alibaba Group Holding 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 a...
[ "v0 = Dict[int, Tuple[int, int]]", "v1 = Dict[int, List[int]]" ]
v1
[ "int" ]
None
def v1(self, v2: int) -> None: def v3() -> None: self.accept_workers(v2) self.thread = Thread(target=v3, args=(), daemon=True) self.thread.start()
[ { "name": "v0", "input_types": [], "output_type": "None", "code": "def v0() -> None:\n self.accept_workers(n_workers)", "dependencies": [] } ]
[ "threading" ]
[ "from threading import Thread" ]
6
# Copyright 1999-2021 Alibaba Group Holding 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 a...
null
v0
[]
None
def v0(self) -> None: while self.thread is not None and self.thread.is_alive(): self.thread.join(100)
[]
[]
[]
3
# Copyright 1999-2021 Alibaba Group Holding 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 a...
null
v0
[ "str", "Any", "Any" ]
Any
def v0(self, v1: str, v2='<input>', v3='multi'): try: v4 = self.interpreter.compile(v1, v2, v3) except (OverflowError, SyntaxError, ValueError): self.interpreter.showsyntaxerror(v2) return False if v4 is None: return True try: self.interpreter.exec(v4) pas...
[]
[]
[]
16
from matplotlib.backends.backend_qt5agg import \ FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure from .pyqtconsole.console import PythonConsole from .pyqtconsole.console import PythonInterpreter from .pyqtconsole.interpreter import redirected_io class MatplotlibPythonInterpreter(PythonInte...
null
v0
[ "int" ]
int
def v0(self, v1: int) -> int: v2 = [[i for v3 in range(5, 0, -1)] for v4 in range(v1)] for v3 in range(1, v1): for v5 in range(3, -1, -1): v2[v3][v5] = v2[v3 - 1][v5] + v2[v3][v5 + 1] return v2[v1 - 1][0]
[]
[]
[]
6
class Solution: def countVowelStrings(self, n: int) -> int: dp = [[i for i in range(5,0,-1)] for _ in range(n)] for i in range(1,n): for j in range(3,-1,-1): dp[i][j] = dp[i - 1][j] + dp[i][j + 1] return dp[n-1][0]
null
v0
[ "int", "torch.device" ]
Any
def v0(v1: int, v2: torch.device): v3 = ~torch.triu(torch.ones(1, v1, v1, device=v2, dtype=torch.bool), diagonal=1) return v3
[]
[ "torch" ]
[ "import torch", "import torch.nn as nn", "import torch.nn.functional as F" ]
3
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. import copy import logging import math from enum import Enum import torch import torch.nn as nn import torch.nn.functional as F logger = logging.getLogger(__name__) PADDING_SYMBOL = 0 DECODER_START_SYMBOL = 1 class Seq2S...
null
v4
[ "torch.Tensor", "torch.Tensor", "int" ]
Any
def v4(v5: torch.Tensor, v6: torch.Tensor, v7: int): (v8, v9, v10) = v5.shape v11 = v6.shape[1] v12 = v5.device v13 = torch.tril(v6.repeat(1, v11).reshape(v8, v11, v11), diagonal=0).to(v12) v14 = torch.zeros(v8, v11, v9 + 2, dtype=torch.bool, device=v12).scatter(2, v13, 1) v15 = v14[:, :, 2:].re...
[ { "name": "v0", "input_types": [ "int", "torch.device" ], "output_type": "Any", "code": "def v0(v1: int, v2: torch.device):\n v3 = ~torch.triu(torch.ones(1, v1, v1, device=v2, dtype=torch.bool), diagonal=1)\n return v3", "dependencies": [] } ]
[ "torch" ]
[ "import torch", "import torch.nn as nn", "import torch.nn.functional as F" ]
9
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. import copy import logging import math from enum import Enum import torch import torch.nn as nn import torch.nn.functional as F logger = logging.getLogger(__name__) PADDING_SYMBOL = 0 DECODER_START_SYMBOL = 1 class Seq2S...
null
v0
[ "Optional['DictConfig']" ]
None
def v0(self, v1: Optional['DictConfig']=None) -> None: if v1 is not None: if v1.get('force_fail') is True: raise Exception('Forced failure test exception was set') else: self.datastore.set_requester_registered(self.db_id, True)
[]
[]
[]
6
#!/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. from dataclasses import dataclass, field from mephisto.data_model.requester import Requester, RequesterArgs from mephist...
null
v0
[ "str", "int" ]
int
def v0(v1: str, v2: int) -> int: with open(v1) as v3: v4 = list(map(int, v3.read().split(','))) v5 = Counter(v4) for v6 in range(v2): v7 = defaultdict(int) for v8 in v5: if v8 == 0: v7[6] += v5[0] v7[8] += v5[0] else: ...
[]
[ "collections" ]
[ "from collections import Counter, defaultdict" ]
14
from collections import Counter, defaultdict def part_one(filename: str) -> int: return lanternfish_population(filename, 80) def part_two(filename: str) -> int: return lanternfish_population(filename, 256) def lanternfish_population(filename: str, days: int) -> int: with open(filename) as f: i...
null
v0
[]
bool
async def v0(self) -> bool: while True: self._evo.zone_lock.acquire() if self._evo.zone_lock_idx is None: self._evo.zone_lock_idx = self.idx self._evo.zone_lock.release() if self._evo.zone_lock_idx == self.idx: break await asyncio.sleep(0.1) return...
[]
[ "asyncio" ]
[ "import asyncio" ]
10
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # """RAMSES RF - a RAMSES-II protocol decoder & analyser. Construct a command (packet that is to be sent). """ import asyncio import json import logging import struct import zlib from datetime import datetime as dt from datetime import timedelta as td from typing import ...
null
v0
[]
None
def v0(self) -> None: self._evo.zone_lock.acquire() self._evo.zone_lock_idx = None self._evo.zone_lock.release()
[]
[]
[]
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # """RAMSES RF - a RAMSES-II protocol decoder & analyser. Construct a command (packet that is to be sent). """ import asyncio import json import logging import struct import zlib from datetime import datetime as dt from datetime import timedelta as td from typing import ...
null
v0
[ "str", "str" ]
Any
def v0(v1: str, v2: str): v3 = len(v1) if len(v1) >= len(v2) else len(v2) v4 = 0 v5 = math.log(v3, 2) if v5 % 1 != 0: v4 = v5 // 1 + 1 else: v4 = v5 v6 = 2 ** v4 if len(v1) < v6: v7 = '0' * int(v6 - len(v1)) v1 = v7 + v1 if len(v2) < v6: v7 = '0' *...
[]
[ "math" ]
[ "import math" ]
16
import math import functools import operator def fix_number_length(x_fix: str, y_fix: str): """ Fix the length of two number For the Karatsuba multiplication both numbers must be the same digits and the length of both numbers must be power of 2. For example, if the number is '987' then the length of ...
null
v28
[ "int", "int" ]
int
def v28(v29: int, v30: int) -> int: (v31, v32) = v0(str(v29), str(v30)) return v8(v31, v32)
[ { "name": "v0", "input_types": [ "str", "str" ], "output_type": "Any", "code": "def v0(v1: str, v2: str):\n v3 = len(v1) if len(v1) >= len(v2) else len(v2)\n v4 = 0\n v5 = math.log(v3, 2)\n if v5 % 1 != 0:\n v4 = v5 // 1 + 1\n else:\n v4 = v5\n v6 = 2 ...
[ "functools", "math", "operator" ]
[ "import math", "import functools", "import operator" ]
3
import math import functools import operator def fix_number_length(x_fix: str, y_fix: str): """ Fix the length of two number For the Karatsuba multiplication both numbers must be the same digits and the length of both numbers must be power of 2. For example, if the number is '987' then the length of ...
null
v0
[ "Any", "str" ]
dict
def v0(self, v1, v2: str) -> dict: v3 = super().node_command_options(v1, v2) v3['--casper-validator-private-key'] = self.content('validator-private.pem') v3['--casper-validator-public-key'] = self.content('validator-public.pem') v3['--tls-certificate'] = self.path('node.certificate.pem') v3['--tls-k...
[]
[]
[]
9
import os from dataclasses import dataclass from typing import Any, Optional, Callable from docker import DockerClient from casperlabs_local_net.casperlabs_accounts import Account from casperlabs_local_net.common import random_string, BOOTSTRAP_PATH, testing_root_path from casperlabs_local_net.cli import CLI DEFAUL...
null
v0
[]
None
def v0(self, **v1) -> None: self._used_fonts = v1['usedFonts'] self._original_font = v1['originalFont'] self._count = v1['count']
[]
[]
[]
4
# coding: utf-8 # # Copyright 2022 :Barry-Thomas-Paul: Moss # # 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 applicab...
null
v2
[ "str", "type" ]
Callable[[type], type]
def v2(self, v3: str, v4: type) -> Callable[[type], type]: def v5(v6: type) -> type: self.register[v4, v3] = v6 return v6 return v5
[ { "name": "v0", "input_types": [ "type" ], "output_type": "type", "code": "def v0(v1: type) -> type:\n self.register[anchor, tag] = v1\n return v1", "dependencies": [] } ]
[]
[]
6
# ------------------------------------------------------------------------------ # CodeHawk Binary Analyzer # Author: Henny Sipma # ------------------------------------------------------------------------------ # The MIT License (MIT) # # Copyright (c) 2021 Aarno Labs LLC # # Permission is hereby granted, free of charg...
null
v4
[ "str", "str" ]
bool
def v4(self, v5: str, v6: str) -> bool: def v7(v8): v9 = {} for v10 in v8: if v10 not in v9: v9[v10] = 0 v9[v10] += 1 return v9 v11 = v7(v5) for v12 in range(0, len(v6) - len(v5) + 1): if v7(v6[v12:v12 + len(v5)]) == v11: r...
[ { "name": "v0", "input_types": [ "Any" ], "output_type": "Any", "code": "def v0(v1):\n v2 = {}\n for v3 in v1:\n if v3 not in v2:\n v2[v3] = 0\n v2[v3] += 1\n return v2", "dependencies": [] } ]
[]
[]
14
class Solution: def checkInclusion(self, s1: str, s2: str) -> bool: def to_dict(s): hash_map = {} for c in s: if c not in hash_map: hash_map[c] = 0 hash_map[c] += 1 return hash_map hash_map = to_...
null
v0
[ "str", "str", "[str]" ]
List[Tuple[str, str, List[str]]]
def v0(self, v1: str, v2: str, v3: [str]) -> List[Tuple[str, str, List[str]]]: if not self._filter_phrase(v2): return [(v1, v2, v3)] v4 = self._transform(v2) return [(v1, v4, v3)]
[]
[]
[]
5
from typing import List, Tuple import nltk import numpy as np # Spacy needs this module, but it's used only implicitly import pyinflect # noqa: F401 import spacy from gender_extractor import GenderExtractor from initialize import spacy_nlp from interfaces.QuestionAnswerOperation import QuestionAnswerOperation from ...
null
v0
[ "list" ]
torch.Size
def v0(self, v1: list) -> torch.Size: v2 = [torch.prod(torch.Tensor([*self.input_features[k].output_shape])) for v3 in v1] return torch.Size([torch.sum(torch.Tensor(v2)).type(torch.int32)])
[]
[ "torch" ]
[ "import torch", "from torch.nn import Module, ModuleList, Linear" ]
3
#! /usr/bin/env python # coding=utf-8 # Copyright (c) 2019 Uber Technologies, Inc. # # 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 # # Unles...
null
v0
[ "str" ]
Any
def v0(self, v1: str): try: return self.__properties[v1] except KeyError: return None
[]
[]
[]
5
# -*- coding: utf-8 -*- __author__ = "MJ (tsngmj@gmail.com)" __license__ = "Apache 2.0" # standard library import sys from collections import OrderedDict # scip plugin from spring_cloud.utils.dot_map import DotMap DefaultClientConfig = DotMap( { "PRIORITIZE_VIP_ADDRESS_BASED_SERVERS": True, "NF_...
null
v0
[ "Any", "Any" ]
List
def v0(v1, v2) -> List: v3 = len(v1) v4 = [] v5 = 0 while v1: v6 = v1.find(v2, v5, v3) if v6 != -1: v4.append(v6) v5 += 2 elif v6 == -1: break return v4
[]
[]
[]
12
""" Given a string, we need to find , if it contains AB, and BA seperately and they are non-overlapping The strings can be in any order. """ from typing import List p = 31 m = 10 ** 9 + 9 def compute_hash(s): n = len(s) power_mod = [1] for i in range(n): power_mod.append((power_mod[-1] * p) % m)...
null
v0
[ "Path" ]
None
def v0(v1: Path) -> None: assert v1.is_file() v2 = v1.with_name('unzipped-' + v1.stem) with zipfile.ZipFile(v1, 'r') as v3: v3.extractall(v2)
[]
[ "zipfile" ]
[ "import zipfile" ]
5
import argparse import os import requests import shutil import zipfile import xml.etree.ElementTree as ET from pathlib import Path from typing import Dict, List, Any import rockset # type: ignore[import] import boto3 # type: ignore[import] PYTORCH_REPO = "https://api.github.com/repos/pytorch/pytorch" GITHUB_TOKEN =...
null
v0
[ "torch.Tensor", "torch.Tensor", "torch.Tensor", "float" ]
torch.Tensor
def v0(v1: torch.Tensor, v2: torch.Tensor, v3: torch.Tensor, v4: float=0.1) -> torch.Tensor: v1 = F.normalize(v1, dim=-1) v5 = torch.einsum('if, jf -> ij', v1, v1) / v4 (v6, v7) = torch.max(v5, dim=1, keepdim=True) v5 = v5 - v6.detach() v8 = torch.sum(torch.exp(v5) * v3, dim=1, keepdim=True) v9 ...
[]
[ "torch" ]
[ "import torch", "import torch.nn.functional as F" ]
14
import torch import torch.nn.functional as F from typing import Optional def simclr_loss_func( z1: torch.Tensor, z2: torch.Tensor, temperature: float = 0.1, extra_pos_mask: Optional[torch.Tensor] = None, ) -> torch.Tensor: """Computes SimCLR's loss given batch of projected features z1 from view 1 ...
null
v0
[ "int", "Any" ]
Any
def v0(self, v1: int=3, v2=None): if isinstance(v2, list) or isinstance(v2, np.ndarray): v3 = [indv is None for v4 in v2] if any(v3): v5 = self.rng.choice(np.arange(len(self.population)), v1, replace=False) return np.array(self.population)[v5] else: if len...
[]
[ "numpy" ]
[ "import numpy as np" ]
15
import numpy as np # from xbbo.configspace.feature_space import Uniform2Gaussian from xbbo.search_algorithm.base import AbstractOptimizer from xbbo.configspace.space import DenseConfiguration, DenseConfigurationSpace from xbbo.core.trials import Trials, Trial from . import alg_register @alg_register.register('de') c...
null
v0
[ "int" ]
bool
def v0(v1: int) -> bool: if v1 <= 3: return v1 > 1 elif not v1 % 2 or not v1 % 3: return False v2 = 5 while v2 ** 2 <= v1: if not v1 % v2 or not v1 % (v2 + 2): return False v2 += 6 return True
[]
[]
[]
11
# The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. # # Find the sum of all the primes below two million. def is_prime(n: int) -> bool: if n <= 3: return n > 1 elif not n%2 or not n%3: return False i = 5 while i**2 <= n: if not n%i or not n%(i+2): return False i += 6 return Tru...
null
v0
[ "str", "List[str]", "Any" ]
int
def v0(self, v1: str, v2: List[str], v3=0) -> int: v4 = set(v1) for v5 in v2: if all([c in v4 for v6 in v5]): v3 += 1 return v3
[]
[]
[]
6
# # 1684. Count the Number of Consistent Strings # # Q: https://leetcode.com/problems/count-the-number-of-consistent-strings/ # A: https://leetcode.com/problems/count-the-number-of-consistent-strings/discuss/969513/Kt-Js-Py3-Cpp-1-Liners # from typing import List # 1-liner class Solution: def countConsistentStrin...
null
v0
[ "int", "int" ]
int
def v0(self, v1: int, v2: int) -> int: v3 = 0 while v1: v3 += v1 % v2 v1 //= v2 return v3
[]
[]
[]
6
class Solution: def sumBase(self, n: int, k: int) -> int: ans = 0 while n: ans += n % k n //= k return ans
null
v0
[]
None
def v0(self, *v1, **v2) -> None: (v1, v2) = self.scatter(v1, v2, self.device_id) if not v1 and (not v2): v1 = ((),) v2 = ({},) return self.module.before_forward_support(*v1[0], **v2[0])
[]
[]
[]
6
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from mmcv.parallel.scatter_gather import scatter_kwargs class MetaTestParallel(nn.Module): """The MetaTestParallel module that supports DataContainer. Note that each task is tested on a single GPU. Thus the data and model on different ...
null
v0
[ "List[str]" ]
Any
def v0(self, v1: List[str]): if len(v1) == 0: return 1 return len([m for v2 in v1 if v2 in [machine.name for v3 in self.hosts]]) / len(v1)
[]
[]
[]
4
"""This module implements some machine clustering specific to H2.""" import pandas as pd from typing import List, Set from waad.utils.asset import Machine from waad.utils.clustering import LongestCommonSubstringClustering class H2SpecificClustering(LongestCommonSubstringClustering): """H2 very specific cluste...
null
v0
[ "float", "float" ]
float
def v0(v1: float, v2: float=0.0) -> float: if v2 == 0: return round(v1) v3 = 1.0 / v2 return round(v1 * v3) / v3
[]
[]
[]
5
# Copyright (c) 2010-2021, Manfred Moitzi # License: MIT License from typing import Union, Sequence # Using * imports to simplify namespace imports, therefore every module # has to have an export declaration: __all__ = [...] # Import base types as C-extensions if available: from ._ctypes import * # Everything else are...
null
v0
[]
None
def v0(self) -> None: self.time += self.delayed_time self.delayed_time = 0.0
[]
[]
[]
3
# -*- test-case-name: twisted.test.test_internet,twisted.internet.test.test_core -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Very basic functionality for a Reactor implementation. """ import builtins import socket # needed only for sync-dns import warnings from abc import ABC, ab...
null
v1
[ "v0" ]
None
def v1(self, v2: v0) -> None: try: (v3, v4, v5, v6) = v2 except (TypeError, ValueError): raise ValueError('invalid trigger handle') else: if v3 not in ('before', 'during', 'after'): raise KeyError('invalid phase') getattr(self, v3).remove((v4, v5, v6))
[]
[]
[]
9
# -*- test-case-name: twisted.test.test_internet,twisted.internet.test.test_core -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Very basic functionality for a Reactor implementation. """ import builtins import socket # needed only for sync-dns import warnings from abc import ABC, ab...
[ "v0 = NewType('_ThreePhaseEventTriggerHandle', Tuple[str, _ThreePhaseEventTriggerCallable, Tuple[object, ...], Dict[str, object]])" ]
v1
[ "v0" ]
None
def v1(self, v2: v0) -> None: (v3, v4, v5, v6) = v2 if v3 != 'before': return self.removeTrigger_BASE(v2) if (v4, v5, v6) in self.finishedBefore: warnings.warn('Removing already-fired system event triggers will raise an exception in a future version of Twisted.', category=DeprecationWarning,...
[]
[ "warnings" ]
[ "import warnings" ]
8
# -*- test-case-name: twisted.test.test_internet,twisted.internet.test.test_core -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Very basic functionality for a Reactor implementation. """ import builtins import socket # needed only for sync-dns import warnings from abc import ABC, ab...
[ "v0 = NewType('_ThreePhaseEventTriggerHandle', Tuple[str, _ThreePhaseEventTriggerCallable, Tuple[object, ...], Dict[str, object]])" ]
v0
[]
None
def v0(self) -> None: if self.waker: self.waker.wakeUp()
[]
[]
[]
3
# -*- test-case-name: twisted.test.test_internet,twisted.internet.test.test_core -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Very basic functionality for a Reactor implementation. """ import builtins import socket # needed only for sync-dns import warnings from abc import ABC, ab...
null
v0
[]
None
def v0(self) -> None: self._started = False self.running = False self.addSystemEventTrigger('during', 'startup', self._reallyStartRunning)
[]
[]
[]
4
# -*- test-case-name: twisted.test.test_internet,twisted.internet.test.test_core -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Very basic functionality for a Reactor implementation. """ import builtins import socket # needed only for sync-dns import warnings from abc import ABC, ab...
null
v0
[ "float" ]
None
def v0(self, v1: float=0.0) -> None: self.runUntilCurrent() self.doIteration(v1)
[]
[]
[]
3
# -*- test-case-name: twisted.test.test_internet,twisted.internet.test.test_core -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Very basic functionality for a Reactor implementation. """ import builtins import socket # needed only for sync-dns import warnings from abc import ABC, ab...
null
v0
[ "str" ]
None
def v0(self, v1: str) -> None: v2 = self._eventTriggers.get(v1) if v2 is not None: v2.fireEvent()
[]
[]
[]
4
# -*- test-case-name: twisted.test.test_internet,twisted.internet.test.test_core -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Very basic functionality for a Reactor implementation. """ import builtins import socket # needed only for sync-dns import warnings from abc import ABC, ab...
null
v1
[ "v0" ]
None
def v1(self, v2: v0) -> None: (v3, v4) = v2 self._eventTriggers[v3].removeTrigger(v4)
[]
[]
[]
3
# -*- test-case-name: twisted.test.test_internet,twisted.internet.test.test_core -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Very basic functionality for a Reactor implementation. """ import builtins import socket # needed only for sync-dns import warnings from abc import ABC, ab...
[ "v0 = NewType('_SystemEventID', Tuple[str, _ThreePhaseEventTriggerHandle])" ]
v1
[ "Callable[..., Any]" ]
Optional[v0]
def v1(self, v2: Callable[..., Any], *v3: object, **v4: object) -> Optional[v0]: if self.running: v2(*v3, **v4) return None else: return self.addSystemEventTrigger('after', 'startup', v2, *v3, **v4)
[]
[]
[]
6
# -*- test-case-name: twisted.test.test_internet,twisted.internet.test.test_core -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Very basic functionality for a Reactor implementation. """ import builtins import socket # needed only for sync-dns import warnings from abc import ABC, ab...
[ "v0 = NewType('_SystemEventID', Tuple[str, _ThreePhaseEventTriggerHandle])" ]
v0
[ "bool" ]
None
def v0(self, v1: bool=True) -> None: self.startRunning(installSignalHandlers=v1) self.mainLoop()
[]
[]
[]
3
# -*- test-case-name: twisted.test.test_internet,twisted.internet.test.test_core -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Very basic functionality for a Reactor implementation. """ import builtins import socket # needed only for sync-dns import warnings from abc import ABC, ab...
null
v30
[ "v0" ]
None
def v30(self, v31: v0) -> None: v32 = self._pendingTimedCalls try: v33 = v32.index(v31) v34 = v32[v33] while v33 != 0: v35 = (v33 - 1) // 2 if v32[v35] <= v34: break v32[v33] = v32[v35] v33 = v35 v32[v33] = v34 e...
[]
[]
[]
14
# -*- test-case-name: twisted.test.test_internet,twisted.internet.test.test_core -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Very basic functionality for a Reactor implementation. """ import builtins import socket # needed only for sync-dns import warnings from abc import ABC, ab...
[ "@implementer(IDelayedCall)\nclass v0:\n v1 = False\n v2: Optional[str] = None\n\n def __init__(self, v3: float, v4: Callable[..., Any], v5: Sequence[object], v6: Dict[str, object], v7: Callable[['DelayedCall'], None], v8: Callable[['DelayedCall'], None], v9: Callable[[], float]=runtimeSeconds) -> None:\n ...
v0
[]
None
def v0(self) -> None: for v1 in self._newTimedCalls: if v1.cancelled: self._cancellations -= 1 else: v1.activate_delay() heappush(self._pendingTimedCalls, v1) self._newTimedCalls = []
[]
[ "heapq" ]
[ "from heapq import heapify, heappop, heappush" ]
8
# -*- test-case-name: twisted.test.test_internet,twisted.internet.test.test_core -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Very basic functionality for a Reactor implementation. """ import builtins import socket # needed only for sync-dns import warnings from abc import ABC, ab...
null
v0
[]
Optional[float]
def v0(self) -> Optional[float]: self._insertNewDelayedCalls() if not self._pendingTimedCalls: return None v1 = self._pendingTimedCalls[0].time - self.seconds() v2 = 2147483 return max(0, min(v2, v1))
[]
[]
[]
7
# -*- test-case-name: twisted.test.test_internet,twisted.internet.test.test_core -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Very basic functionality for a Reactor implementation. """ import builtins import socket # needed only for sync-dns import warnings from abc import ABC, ab...
null
v0
[]
None
def v0(self) -> None: if self.state == 'connecting': self.stopConnecting() elif self.state == 'connected': assert self.transport is not None self.transport.loseConnection()
[]
[]
[]
6
# -*- test-case-name: twisted.test.test_internet,twisted.internet.test.test_core -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Very basic functionality for a Reactor implementation. """ import builtins import socket # needed only for sync-dns import warnings from abc import ABC, ab...
null
v0
[]
None
def v0(self) -> None: if self.timeoutID is not None: try: self.timeoutID.cancel() except ValueError: pass del self.timeoutID
[]
[]
[]
7
# -*- test-case-name: twisted.test.test_internet,twisted.internet.test.test_core -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Very basic functionality for a Reactor implementation. """ import builtins import socket # needed only for sync-dns import warnings from abc import ABC, ab...
null
v0
[ "Callable[..., Any]" ]
None
def v0(self, v1: Callable[..., Any], *v2: object, **v3: object) -> None: assert callable(v1), f'{v1} is not callable' self.threadCallQueue.append((v1, v2, v3))
[]
[]
[]
3
# -*- test-case-name: twisted.test.test_internet,twisted.internet.test.test_core -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Very basic functionality for a Reactor implementation. """ import builtins import socket # needed only for sync-dns import warnings from abc import ABC, ab...
null
v0
[]
None
def v0(self) -> None: v1 = [self._threadpoolStartupID, self.threadpoolShutdownID] for v2 in filter(None, v1): try: self.removeSystemEventTrigger(v2) except ValueError: pass self._threadpoolStartupID = None self.threadpoolShutdownID = None assert self.threadpoo...
[]
[]
[]
12
# -*- test-case-name: twisted.test.test_internet,twisted.internet.test.test_core -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Very basic functionality for a Reactor implementation. """ import builtins import socket # needed only for sync-dns import warnings from abc import ABC, ab...
null
v0
[ "Any", "dict", "dict" ]
Any
def v0(v1, v2: dict={'labels': [0, 1], 'predictions': [0, 1], 'masks': [1, 0]}, v3: dict={'train': {'accuracy': 1}}): v1.after_batch(stream_name='train', batch_data=v2) v1.after_epoch(epoch_id=0, epoch_data=v3) return v3
[]
[]
[]
4
""" Test case for :py:class:`emloop.hooks.SaveConfusionMatrix hook. """ import os import matplotlib import pytest from emloop.hooks.save_cm import SaveConfusionMatrix from ..main_loop_test import SimpleDataset class MockDataset(SimpleDataset): @staticmethod def num_classes(): return 4 @staticme...
null
v0
[ "torch.Tensor" ]
torch.Tensor
def v0(self, v1: torch.Tensor) -> torch.Tensor: v1 = self.conv1(v1) v1 = self.conv2(v1) v1 = self.conv3(v1) return v1
[]
[]
[]
5
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # pyre-ignore-all-errors[2] import typing import unittest from collections import Counter, defaultdict from typing import Any, Dict, List import torch import torch.nn as nn from fvcore.nn.activation_count import Handle, activation_count from nump...
null
v0
[ "torch.Tensor" ]
int
def v0(self, v1: torch.Tensor) -> int: v2 = 0 v1 = self.conv1(v1) v2 += prod(list(v1.size())) v1 = self.conv2(v1) v2 += prod(list(v1.size())) v1 = self.conv3(v1) v2 += prod(list(v1.size())) return v2
[]
[ "numpy" ]
[ "from numpy import prod" ]
9
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # pyre-ignore-all-errors[2] import typing import unittest from collections import Counter, defaultdict from typing import Any, Dict, List import torch import torch.nn as nn from fvcore.nn.activation_count import Handle, activation_count from nump...
null
v0
[ "List[int]", "List[int]" ]
int
def v0(self, v1: List[int], v2: List[int]) -> int: v3 = v1[-1] v4 = [0] * (v3 + 1) for v5 in range(0, v3 + 1): if v5 in v1: if v5 < 7: v4[v5] = min(v4[v5 - 1] + v2[0], v2[1], v2[2]) elif v5 < 30: v4[v5] = min(v4[v5 - 1] + v2[0], v4[v5 - 7] + v2...
[]
[]
[]
14
# 在一个火车旅行很受欢迎的国度,你提前一年计划了一些火车旅行。在接下来的一年里,你要旅行的日子将以一个名为 days 的数组给出。每一项是一个从 1 到 365 的整数。 # # 火车票有三种不同的销售方式: # # 一张为期一天的通行证售价为 costs[0] 美元; # 一张为期七天的通行证售价为 costs[1] 美元; # 一张为期三十天的通行证售价为 costs[2] 美元。 # 通行证允许数天无限制的旅行。 例如,如果我们在第 2 天获得一张为期 7 天的通行证,那么我们可以连着旅行 7 天:第 2 天、第 3 天、第 4 天、第 5 天、第 6 天、第 7 天和第 8 天。 # # 返回你想要完成在给定的列表 day...
null
v14
[ "int", "Any" ]
Any
def v14(self, v15: int, v16): v17 = self.queue.get_new_index(v15) v18 = self.queue[v17] v18.dat.p = v16 self.queue[v17] = v18 v7(self.queue, v17)
[ { "name": "v0", "input_types": [ "Any", "Any", "Any" ], "output_type": "Any", "code": "def v0(v1, v2, v3):\n v4 = v1[v3]\n while v3 > v2:\n v5 = v3 - 1 >> 1\n v6 = v1[v5]\n if v4 < v6:\n v1[v3] = v6\n v3 = v5\n continu...
[]
[]
6
from queue import Queue from typing import List class QNode: def __init__(self, dat, index): self.dat = dat self.index = index def __repr__(self): return f'QNode({self.dat}, index={self.index})' def __lt__(self, other): return self.dat < other.dat def __eq__(self, ot...
null
v0
[ "Type" ]
bool
def v0(v1: Type) -> bool: if hasattr(typing, '_GenericAlias'): return isinstance(v1, typing._GenericAlias) and v1.__origin__ is list else: return isinstance(v1, typing.GenericMeta) and v1.__origin__ is List
[]
[ "typing" ]
[ "import typing", "from typing import Dict, List, NewType, Type, Union" ]
5
from datetime import datetime import typing from typing import Dict, List, NewType, Type, Union bool_union_fix = NewType('bool_union_fix', bool) scalar_type_to_tag = { str: 'tag:yaml.org,2002:str', int: 'tag:yaml.org,2002:int', float: 'tag:yaml.org,2002:float', bool: 'tag:yaml.org,2002:bool', boo...
null
v0
[ "Type" ]
bool
def v0(v1: Type) -> bool: if hasattr(typing, '_GenericAlias'): return isinstance(v1, typing._GenericAlias) and v1.__origin__ is Union elif hasattr(typing, '_Union'): return isinstance(v1, typing._Union) else: return isinstance(v1, typing.UnionMeta) raise RuntimeError('Could not d...
[]
[ "typing" ]
[ "import typing", "from typing import Dict, List, NewType, Type, Union" ]
8
from datetime import datetime import typing from typing import Dict, List, NewType, Type, Union bool_union_fix = NewType('bool_union_fix', bool) scalar_type_to_tag = { str: 'tag:yaml.org,2002:str', int: 'tag:yaml.org,2002:int', float: 'tag:yaml.org,2002:float', bool: 'tag:yaml.org,2002:bool', boo...
null
v0
[ "Type" ]
List[Type]
def v0(v1: Type) -> List[Type]: if hasattr(v1, '__union_params__'): return list(v1.__union_params__) return list(v1.__args__)
[]
[]
[]
4
from datetime import datetime import typing from typing import Dict, List, NewType, Type, Union bool_union_fix = NewType('bool_union_fix', bool) scalar_type_to_tag = { str: 'tag:yaml.org,2002:str', int: 'tag:yaml.org,2002:int', float: 'tag:yaml.org,2002:float', bool: 'tag:yaml.org,2002:bool', boo...
null
v0
[ "str" ]
str
def v0(v1: str) -> str: if 'www.wikidata.org' in v1 and '/' in v1: v2 = v1.rindex('/') return v1[v2 + 1:] return v1
[]
[]
[]
5
def get_wiki_id(resource: str) -> str: '''Return Wikidata id (e.g. P31 or Q42).''' if "www.wikidata.org" in resource and "/" in resource: index = resource.rindex("/") return resource[index + 1:] return resource
null
v1
[ "v0" ]
None
def v1(self, v2: v0) -> None: with ZipFile(v2, 'w', ZIP_DEFLATED) as v3: v3.writestr(f'{self.ID}.content', json.dumps(self.content)) v3.writestr(f'{self.ID}.pagedata', self.pagedata) v3.writestr(f'{self.ID}.metadata', json.dumps(self.metadata)) if self.pdf: v3.writestr(f'...
[]
[ "io", "json", "zipfile" ]
[ "from io import BytesIO", "from zipfile import ZipFile, ZIP_DEFLATED", "import json" ]
16
import os from io import BytesIO from zipfile import ZipFile, ZIP_DEFLATED import shutil from uuid import uuid4 import json from typing import TypeVar, List, Tuple from requests import Response from .meta import Meta BytesOrString = TypeVar("BytesOrString", BytesIO, str) class RmPage(object): """A Remarkable Pag...
[ "v0 = TypeVar('BytesOrString', BytesIO, str)" ]