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 | [
"Path"
] | Any | def v0(self, v1: Path):
with v1.open('r') as v2:
try:
v3 = self._import_statement_regex.findall(v2.read())
self._found_packages |= set(v3)
except:
pass | [] | [] | [] | 7 | # SPDX-FileCopyrightText: 2020 EACG GmbH
#
# SPDX-License-Identifier: Apache-2.0
import os
import re
from pathlib import Path
from importlib_metadata import distribution, Distribution, PackageNotFoundError
from typing import List
class Scanner:
def __init__(self, client):
self._client = client
... | null |
v0 | [
"Any",
"Optional[Dict[str, List[Tensor]]]",
"Optional[Dict[str, Dict[str, Optional[Tensor]]]]",
"bool",
"bool",
"Optional[int]",
"Optional[int]",
"Optional[Any]",
"bool"
] | Any | def v0(self, v1, v2: Optional[Dict[str, List[Tensor]]]=None, v3: Optional[Dict[str, Dict[str, Optional[Tensor]]]]=None, v4: bool=False, v5: bool=False, v6: Optional[int]=None, v7: Optional[int]=None, v8: Optional[Any]=None, v9: bool=False):
(v10, v11) = self.extract_features(v1, encoder_out=v2, incremental_state=v3... | [] | [] | [] | 10 | # 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 numpy as np
import math
from typing import Any, Dict, List, Optional, Tuple
import os
import torch
import torch.nn as nn
from fairseq ... | null |
v0 | [
"Any",
"Optional[torch.Tensor]"
] | Any | def v0(self, v1, v2: Optional[torch.Tensor]=None):
if v2 is None:
v2 = self.embed_tokens(v1)
v3 = v4 = self.embed_scale * v2
if self.embed_positions is not None:
v3 = v4 + self.embed_positions(v1, dict=self.dictionary)[0]
if self.layernorm_embedding is not None:
v3 = self.layerno... | [] | [] | [] | 12 | # 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 math
from typing import Any, Dict, List, Optional, Tuple
import logging
import torch
import torch.nn as nn
from fairseq import utils
f... | null |
v0 | [
"Any",
"Optional[torch.Tensor]",
"bool",
"Optional[torch.Tensor]"
] | Any | def v0(self, v1, v2: Optional[torch.Tensor]=None, v3: bool=False, v4: Optional[torch.Tensor]=None):
v5 = v1.eq(self.padding_idx)
v6 = v1.device.type == 'xla' or v5.any()
(v7, v8) = self.forward_embedding(v1, v4)
if v6:
v7 = v7 * (1 - v5.unsqueeze(-1).type_as(v7))
v7 = v7.transpose(0, 1)
... | [] | [
"torch"
] | [
"import torch",
"import torch.nn as nn",
"from torch import Tensor"
] | 27 | # 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 math
from typing import Dict, List, Optional
import torch
import torch.nn as nn
from fairseq import utils
from fairseq.distributed imp... | null |
v0 | [
"Any",
"Optional[Dict[str, List[Tensor]]]",
"Optional[Dict[str, Dict[str, Optional[Tensor]]]]",
"bool",
"Optional[int]",
"Optional[int]"
] | Any | def v0(self, v1, v2: Optional[Dict[str, List[Tensor]]], v3: Optional[Dict[str, Dict[str, Optional[Tensor]]]]=None, v4: bool=False, v5: Optional[int]=None, v6: Optional[int]=None):
(v7, v8) = v1.size()
if v5 is None:
v5 = self.num_layers - 1
v9: Optional[Tensor] = None
v10: Optional[Tensor] = Non... | [] | [] | [] | 55 | import functools
print = functools.partial(print, flush=True)
import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.nn.parameter import Parameter
from torch import Tensor
import numpy as np
from typing import Optional,Any, Callable, D... | null |
v0 | [
"int"
] | Any | async def v0(self, v1: int):
if self.use_local_keychain():
self.keychain.delete_key_by_fingerprint(v1)
else:
(v2, v3) = await self.get_response_for_request('delete_key_by_fingerprint', {'fingerprint': v1})
if not v3:
self.handle_error(v2) | [] | [] | [] | 7 | import logging
import ssl
from blspy import AugSchemeMPL, PrivateKey
from chia.cmds.init_funcs import check_keys
from chia.daemon.client import DaemonProxy
from chia.daemon.keychain_server import (
KEYCHAIN_ERR_KEYERROR,
KEYCHAIN_ERR_LOCKED,
KEYCHAIN_ERR_MALFORMED_REQUEST,
KEYCHAIN_ERR_NO_KEYS,
)
from ... | null |
v0 | [
"int",
"int"
] | Any | def v0(v1: int, v2: int):
v3 = numpy.empty((v1 * 4, 3))
v4 = 0
for v5 in range(1, v1 + 1):
v3[v4] = numpy.array([v5 / v1, v2, 0.5])
v4 += 1
v3[v4] = numpy.array([v5 / v1, v2, 0.25])
v4 += 1
v3[v4] = numpy.array([v5 / v1, v2, 1.0])
v4 += 1
v3[v4] = nump... | [] | [
"numpy"
] | [
"import numpy"
] | 13 | from asyncio import subprocess
from itertools import count
from re import A, S
import string
import numpy
import numba
from numba import njit, jit, prange
from tensorflow import keras
import os
import subprocess
from numba import int32, float32 # import the types
from numba.experimental import jitclass
numpy.seterr(... | null |
v0 | [
"int",
"int"
] | float | def v0(self, v1: int, v2: int) -> float:
if v1 <= 0:
return 1.0
if v1 > v2 * 2:
v2 = v2 - 1
v3 = v2 / v1
if v3 > 1:
v3 = 1.0
return v3 | [] | [] | [] | 9 | from summarizer.BertParent import BertParent
from typing import List
from summarizer.ClusterFeatures import ClusterFeatures
from abc import abstractmethod
import neuralcoref
from spacy.lang.en import English
import json
class ModelProcessor(object):
def __init__(self,
model='bert-large-uncased',
... | null |
v0 | [
"int",
"int"
] | float | def v0(self, v1: int, v2: int) -> float:
if v1 < v2:
return -self.bet_to_ante_ratio
return 1 + self.bet_to_ante_ratio | [] | [] | [] | 4 | from asyncio import subprocess
from itertools import count
from re import A, S
import string
import numpy
import numba
from numba import njit, jit, prange
from tensorflow import keras
import os
import subprocess
from numba import int32, float32 # import the types
from numba.experimental import jitclass
numpy.seterr(... | null |
v6 | [
"int"
] | bool | def v6(self, v7: int) -> bool:
if v7 in self.author_checks_to_open_check:
return self.author_checks_to_open_check[v7]
v8 = 0.0
for v9 in range(1, self.num_cards + 1):
if v9 == v7:
continue
v8 += self.chance_to_open_check[v9]
if v8 == 0:
return False
v10 = ... | [
{
"name": "v0",
"input_types": [
"int",
"int"
],
"output_type": "float",
"code": "def v0(self, v1: int, v2: int) -> float:\n if v1 > v2:\n return 1.0\n return 0.0",
"dependencies": []
},
{
"name": "v3",
"input_types": [
"int",
"int"
],
... | [] | [] | 19 | from asyncio import subprocess
from itertools import count
from re import A, S
import string
import numpy
import numba
from numba import njit, jit, prange
from tensorflow import keras
import os
import subprocess
from numba import int32, float32 # import the types
from numba.experimental import jitclass
numpy.seterr(... | null |
v3 | [
"int"
] | bool | def v3(self, v4: int) -> bool:
if v4 in self.author_folds_to_open_bet:
return self.author_folds_to_open_bet[v4]
v5 = 0.0
v6 = 0.0
for v7 in range(1, self.num_cards + 1):
if v7 == v4:
continue
v6 += v0(self, v4, v7) * (1.0 - self.chance_to_open_check[v7])
self.auth... | [
{
"name": "v0",
"input_types": [
"int",
"int"
],
"output_type": "float",
"code": "def v0(self, v1: int, v2: int) -> float:\n if v1 < v2:\n return -self.bet_to_ante_ratio\n return 1 + self.bet_to_ante_ratio",
"dependencies": []
}
] | [] | [] | 11 | from asyncio import subprocess
from itertools import count
from re import A, S
import string
import numpy
import numba
from numba import njit, jit, prange
from tensorflow import keras
import os
import subprocess
from numba import int32, float32 # import the types
from numba.experimental import jitclass
numpy.seterr(... | null |
v3 | [
"int"
] | bool | def v3(self, v4: int) -> bool:
if v4 in self.author_folds_to_check_bet:
return self.author_folds_to_check_bet[v4]
v5 = 0.0
for v6 in range(1, self.num_cards + 1):
if v6 == v4:
continue
v5 += 1 - self.chance_to_check_check[v6]
if v5 == 0:
return False
... | [
{
"name": "v0",
"input_types": [
"int",
"int"
],
"output_type": "float",
"code": "def v0(self, v1: int, v2: int) -> float:\n if v1 < v2:\n return -self.bet_to_ante_ratio\n return 1 + self.bet_to_ante_ratio",
"dependencies": []
}
] | [] | [] | 18 | from asyncio import subprocess
from itertools import count
from re import A, S
import string
import numpy
import numba
from numba import njit, jit, prange
from tensorflow import keras
import os
import subprocess
from numba import int32, float32 # import the types
from numba.experimental import jitclass
numpy.seterr(... | null |
v12 | [
"v0"
] | str | def v12(v13: v0) -> str:
v14 = ''
for v15 in range(1, v13.num_cards + 1):
v14 += f'{v15} open: check {v13.chance_to_open_check[v15]}\n'
v14 += f'{v15} check: check {v13.chance_to_check_check[v15]}\n'
v14 += f'{v15} bet: fold {v13.chance_to_bet_fold[v15]}\n'
v14 += f'{v15} check-b... | [] | [] | [] | 8 | from asyncio import subprocess
from itertools import count
from re import A, S
import string
import numpy
import numba
from numba import njit, jit, prange
from tensorflow import keras
import os
import subprocess
from numba import int32, float32 # import the types
from numba.experimental import jitclass
numpy.seterr(... | [
"class v0:\n\n def __init__(self, v1: int, v2: int, v3: numba.float32[:]):\n self.num_cards = v1\n self.bet_to_ante_ratio = v2\n self.chance_to_open_check = numpy.zeros(v1 + 1)\n self.chance_to_check_check = numpy.zeros(v1 + 1)\n self.chance_to_bet_fold = numpy.zeros(v1 + 1)\n ... |
v23 | [] | float | def v23(self) -> float:
v24 = 0
v25 = 0
for v26 in range(1, self.num_cards + 1):
v3(self, v26)
v9(self, v26)
if not v15(self, v26):
v25 += 1
self.authorOpenChecks(v26)
for v26 in range(1, self.num_cards + 1):
if not self.author_folds_to_open_bet[v26]:
... | [
{
"name": "v0",
"input_types": [
"int",
"int"
],
"output_type": "float",
"code": "def v0(self, v1: int, v2: int) -> float:\n if v1 > v2:\n return 1.0\n return 0.0",
"dependencies": []
},
{
"name": "v3",
"input_types": [
"int"
],
"output_type... | [] | [] | 45 | from asyncio import subprocess
from itertools import count
from re import A, S
import string
import numpy
import numba
from numba import njit, jit, prange
from tensorflow import keras
import os
import subprocess
from numba import int32, float32 # import the types
from numba.experimental import jitclass
numpy.seterr(... | null |
v16 | [
"string"
] | Any | def v16(self, v17: string='poker'):
v18 = open(os.getcwd() + '/' + v17 + '.in', 'w')
v18.write(str(self.num_cards) + ' ' + str(1) + ' ' + str(self.bet_to_ante_ratio))
v18.close()
v18 = open(os.getcwd() + '/' + v17 + '.out', 'w')
v18.write(v12(self))
v18.close() | [
{
"name": "v12",
"input_types": [
"v0"
],
"output_type": "str",
"code": "def v12(v13: v0) -> str:\n v14 = ''\n for v15 in range(1, v13.num_cards + 1):\n v14 += f'{v15} open: check {v13.chance_to_open_check[v15]}\\n'\n v14 += f'{v15} check: check {v13.chance_to_check_che... | [
"os"
] | [
"import os"
] | 7 | from asyncio import subprocess
from itertools import count
from re import A, S
import string
import numpy
import numba
from numba import njit, jit, prange
from tensorflow import keras
import os
import subprocess
from numba import int32, float32 # import the types
from numba.experimental import jitclass
numpy.seterr(... | [
"class v0:\n\n def __init__(self, v1: int, v2: int, v3: numba.float32[:]):\n self.num_cards = v1\n self.bet_to_ante_ratio = v2\n self.chance_to_open_check = numpy.zeros(v1 + 1)\n self.chance_to_check_check = numpy.zeros(v1 + 1)\n self.chance_to_bet_fold = numpy.zeros(v1 + 1)\n ... |
v19 | [] | float | def v19(self) -> float:
v12(self)
return float(subprocess.check_output([os.getcwd() + '/checker.exe', './poker.in', '--out', './poker.out']).decode()) | [
{
"name": "v12",
"input_types": [
"string"
],
"output_type": "Any",
"code": "def v12(self, v13: string='poker'):\n v14 = open(os.getcwd() + '/' + v13 + '.in', 'w')\n v14.write(str(self.num_cards) + ' ' + str(1) + ' ' + str(self.bet_to_ante_ratio))\n v14.close()\n v14 = open(os.... | [
"os",
"subprocess"
] | [
"import os",
"import subprocess"
] | 3 | from asyncio import subprocess
from itertools import count
from re import A, S
import string
import numpy
import numba
from numba import njit, jit, prange
from tensorflow import keras
import os
import subprocess
from numba import int32, float32 # import the types
from numba.experimental import jitclass
numpy.seterr(... | [
"class v0:\n\n def __init__(self, v1: int, v2: int, v3: numba.float32[:]):\n self.num_cards = v1\n self.bet_to_ante_ratio = v2\n self.chance_to_open_check = numpy.zeros(v1 + 1)\n self.chance_to_check_check = numpy.zeros(v1 + 1)\n self.chance_to_bet_fold = numpy.zeros(v1 + 1)\n ... |
v12 | [
"int"
] | bool | def v12(self, v13: int) -> bool:
if v13 in self.author_open_checks:
return self.author_open_checks[v13]
v14 = 0.0
v15 = 0.0
for v16 in range(1, self.num_cards + 1):
if v16 == v13:
continue
v15 += 1 * self.chance_to_bet_fold[v16] + v9(self, v13, v16) * (1 - self.chance... | [
{
"name": "v0",
"input_types": [
"int",
"int"
],
"output_type": "float",
"code": "def v0(self, v1: int, v2: int) -> float:\n if v1 > v2:\n return 1.0\n return 0.0",
"dependencies": []
},
{
"name": "v3",
"input_types": [
"int"
],
"output_type... | [] | [] | 14 | from asyncio import subprocess
from itertools import count
from re import A, S
import string
import numpy
import numba
from numba import njit, jit, prange
from tensorflow import keras
import os
import subprocess
from numba import int32, float32 # import the types
from numba.experimental import jitclass
numpy.seterr(... | null |
v4 | [
"Callable[..., None]"
] | Callable[..., None] | def v4(v5: Callable[..., None]) -> Callable[..., None]:
@wraps(v5)
def v6(*v7: Any, **v8: Any) -> Any:
if os.environ.get('PYTEST_CURRENT_TEST'):
return v5(*v7, **v8)
v9 = Thread(target=v5, args=v7, kwargs=v8)
v9.daemon = True
return v9.start()
return v6 | [
{
"name": "v0",
"input_types": [],
"output_type": "Any",
"code": "@wraps(func)\ndef v0(*v1: Any, **v2: Any) -> Any:\n if os.environ.get('PYTEST_CURRENT_TEST'):\n return func(*v1, **v2)\n v3 = Thread(target=func, args=v1, kwargs=v2)\n v3.daemon = True\n return v3.start()",
"dep... | [
"os",
"threading"
] | [
"import os",
"from threading import Thread"
] | 10 | import os
import platform
import subprocess
import time
from collections import OrderedDict, defaultdict
from functools import wraps
from itertools import chain, combinations
from re import ASCII, match
from threading import Thread
from typing import (
Any, Callable, DefaultDict, Dict, FrozenSet, Iterable, List, Se... | null |
v0 | [
"List[Any]",
"Any",
"Any"
] | Dict[str, Any] | def v0(v1: List[Any], v2: Any, v3: Any=None) -> Dict[str, Any]:
if v3 is None:
v3 = {'pointer': defaultdict(set), 'stream': defaultdict(dict), 'private': defaultdict(set), 'all_messages': set(), 'all_private': set(), 'all_stream': defaultdict(set), 'messages': defaultdict(dict), 'search': set()}
v4 = v2... | [] | [
"collections"
] | [
"from collections import defaultdict"
] | 26 | import time
from collections import defaultdict
from functools import wraps
from threading import Thread
from typing import Any, Dict, List
import os
def asynch(func: Any) -> Any:
"""
Decorator for executing a function in a separate :class:`threading.Thread`.
"""
@wraps(func)
def wrapper(*args: A... | null |
v0 | [
"Any"
] | Dict[str, Any] | def v0(v1: Any) -> Dict[str, Any]:
v2 = v1.initial_data['unread_msgs']
v3 = dict()
v3['all_msg'] = 0
v3['all_pms'] = 0
v3['unread_topics'] = dict()
v3['unread_pms'] = dict()
for v4 in v2['pms']:
v5 = len(v4['unread_message_ids'])
v3[v4['sender_id']] = v5
v3['unread_pm... | [] | [] | [] | 28 | import time
from collections import defaultdict
from functools import wraps
from threading import Thread
from typing import Any, Dict, List
import os
def asynch(func: Any) -> Any:
"""
Decorator for executing a function in a separate :class:`threading.Thread`.
"""
@wraps(func)
def wrapper(*args: A... | null |
v0 | [
"Any",
"str"
] | bool | def v0(v1: Any, v2: str) -> bool:
v3 = v1.caption.lower()
v4 = v3.split()
v4.append(v1.email.lower())
v4.append(v3)
for v5 in v4:
if v5.startswith(v2.lower()):
return True
return False | [] | [] | [] | 9 | import time
from collections import defaultdict
from functools import wraps
from threading import Thread
from typing import Any, Dict, List
import os
def asynch(func: Any) -> Any:
"""
Decorator for executing a function in a separate :class:`threading.Thread`.
"""
@wraps(func)
def wrapper(*args: A... | null |
v0 | [
"Optional[bool]",
"Optional[Sequence[str]]"
] | Dict[Any, Any] | def v0(self, v1: Optional[bool]=True, v2: Optional[Sequence[str]]=None) -> Dict[Any, Any]:
v3 = super().snapshot_base(v1, v2)
v3['dac_channel'] = self._dac_channel.name
return v3 | [] | [] | [] | 4 | import copy
import logging
import time
from math import isclose
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
import numpy as np
import qcodes as qc
from qcodes import ArrayParameter, Instrument, InstrumentChannel, Parameter
from qcodes import validators as vals
from qcodes.instrument.base impor... | null |
v0 | [] | dict | def v0(self) -> dict:
if not self.__val:
raise ValueError('Value of operation empty.')
return {'operation': self.__val, 'params': self.__query_params} | [] | [] | [] | 4 | """
PostgreSQL query operations generation module.
"""
from typing import Type, Union
import pandas as pd
from datetime import datetime
import numbers
from psycopg2 import sql
from psycopg2.extensions import connection
from hero_db_utils.utils import short_random_id
from hero_db_utils.utils.dtypes import Literal
from... | null |
v0 | [
"'Context'"
] | Any | def v0(self, v1: 'Context'):
v2 = self.hook.get_stack_status(self.stack_name)
if v2 in ('DELETE_COMPLETE', None):
return True
if v2 == 'DELETE_IN_PROGRESS':
return False
raise ValueError(f'Stack {self.stack_name} in bad state: {v2}') | [] | [] | [] | 7 | #
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not... | null |
v0 | [
"str"
] | bool | def v0(v1: str) -> bool:
(v2, v3) = (0, 0)
for v4 in v1:
if v4 == '[':
v2 += 1
if v2 > 1:
return False
if v4 == ']':
v2 -= 1
if v2 == 0:
v3 += 1
elif v2 < 0:
return False
if v3 > 1:
... | [] | [] | [] | 16 | # -*- coding: utf-8 -*-
"""ldndc2nc.extra: extra module within the ldndc2nc package."""
import logging
from typing import List, Optional, Tuple
log = logging.getLogger(__name__)
def identical(elements: List) -> bool:
return all([e == elements[0] for e in elements])
def valid_brackets(s: str) -> bool:
"""o... | null |
v3 | [
"str",
"List[str]"
] | bool | def v3(v4: str, v5: List[str]) -> bool:
v6 = [f'{v}_' for v7 in ['dC', 'dN', 'aC', 'aN']]
v8 = [p for v9 in v6 for v4 in v5 if v4.startswith(v9)]
for v10 in v6:
if v4.startswith(v10):
v8.append(v10)
if v0(v8):
return True
return False | [
{
"name": "v0",
"input_types": [
"List"
],
"output_type": "bool",
"code": "def v0(v1: List) -> bool:\n return all([e == v1[0] for v2 in v1])",
"dependencies": []
}
] | [] | [] | 9 | # -*- coding: utf-8 -*-
"""ldndc2nc.extra: extra module within the ldndc2nc package."""
import logging
from typing import List, Optional, Tuple
log = logging.getLogger(__name__)
def identical(elements: List) -> bool:
return all([e == elements[0] for e in elements])
def valid_brackets(s: str) -> bool:
"""o... | null |
v0 | [
"str"
] | float | def v0(v1: str) -> float:
if v1:
v2 = sum([1 for v3 in v1 if v3 in string.punctuation])
return round(v2 / (len(v1) - v1.count(' ')), 3) * 100
return 0 | [] | [
"string"
] | [
"import string"
] | 5 | #!/usr/bin/env python3
# encoding: UTF-8
"""
Filename: predict.py
Date: 2019-11-16 11:41:58 PM
Author: David Oniani
E-mail: onianidavid@gmail.com
License:
The code is licensed under MIT License. Please read the LICENSE file in
this distribution for details regarding the licensing of this code.
Description:
... | null |
v0 | [
"str"
] | float | def v0(v1: str) -> float:
v2 = {'black': 1597, 'police': 801, 'people': 476, 'all': 423, 'stop': 397, 'join': 388, "don't": 310, 'more': 305, 'can': 294, 'do': 284, 'american': 280, 'matters': 264, 'man': 262, 'bm': 259, 'only': 254, 'free': 248, 'white': 239, 'community': 224, 'follow': 223, 'should': 222, 'how': ... | [] | [
"re"
] | [
"import re"
] | 11 | #!/usr/bin/env python3
# encoding: UTF-8
"""
Filename: predict.py
Date: 2019-11-16 11:41:58 PM
Author: David Oniani
E-mail: onianidavid@gmail.com
License:
The code is licensed under MIT License. Please read the LICENSE file in
this distribution for details regarding the licensing of this code.
Description:
... | null |
v17 | [
"str"
] | str | def v17(v18: str) -> str:
v19 = pd.Series([v18])
v20 = pd.DataFrame({'text': v19})
v20['text_length'] = v20['text'].apply(v6)
v20['punctuation%'] = v20['text'].apply(v0)
v20['weight'] = v20['text'].apply(v8)
v21 = v20[['text_length', 'punctuation%', 'weight']]
for v22 in range(9078):
... | [
{
"name": "v0",
"input_types": [
"str"
],
"output_type": "float",
"code": "def v0(v1: str) -> float:\n if v1:\n v2 = sum([1 for v3 in v1 if v3 in string.punctuation])\n return round(v2 / (len(v1) - v1.count(' ')), 3) * 100\n return 0",
"dependencies": []
},
{
... | [
"pandas",
"pickle",
"re",
"string"
] | [
"import re",
"import pickle",
"import string",
"import pandas as pd"
] | 13 | #!/usr/bin/env python3
# encoding: UTF-8
"""
Filename: predict.py
Date: 2019-11-16 11:41:58 PM
Author: David Oniani
E-mail: onianidavid@gmail.com
License:
The code is licensed under MIT License. Please read the LICENSE file in
this distribution for details regarding the licensing of this code.
Description:
... | null |
v0 | [
"Union[float, int]",
"int",
"int"
] | str | def v0(v1: Union[float, int], v2: int=10, v3: int=4) -> str:
v4 = len(str(int(v1)))
v5 = v2 - (v4 + 1)
if v5 <= 1:
return str(int(v1))
else:
v5 = min(v5, v3)
v6 = '%.' + str(v5) + 'f'
return v6 % v1 | [] | [] | [] | 9 | from typing import Optional, Callable, Iterable, Union, List
from thinc.api import Config, fix_random_seed, set_gpu_allocator, Model, Optimizer
from thinc.api import set_dropout_rate
from pathlib import Path
from collections import Counter
import srsly
import time
import re
from thinc.config import ConfigValidationErr... | null |
v4 | [
"Any",
"str",
"str"
] | str | def v4(v5: Any, v6: str, v7: str) -> str:
v8 = v5.json()
v6 = v8['name']
v9 = v8['sys']['country']
v10 = v2(v8['main']['temp'])
v11 = v0(v8['main']['temp'])
v12 = v8['weather'][0]['description'].title()
return v7.format(v6, v9, v10, v11, v12) | [
{
"name": "v0",
"input_types": [
"float"
],
"output_type": "float",
"code": "def v0(v1: float) -> float:\n return int(v1) - 273.15",
"dependencies": []
},
{
"name": "v2",
"input_types": [
"float"
],
"output_type": "float",
"code": "def v2(v3: float) -> ... | [] | [] | 8 | # See readme.md for instructions on running this code.
from typing import Any, Dict
import requests
from zulip_bots.lib import BotHandler
api_url = "http://api.openweathermap.org/data/2.5/weather"
class WeatherHandler:
def initialize(self, bot_handler: BotHandler) -> None:
self.api_key = bot_handler.ge... | null |
v50 | [
"str"
] | v0 | def v50(self, v51: str) -> v0:
self.currency_code = v51
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-platform-service (4.10.0)
# pylint: disabl... | [
"class v0(Model):\n v1: str\n v2: str\n v3: str\n v4: str\n v5: str\n v6: str\n\n def v7(self, v8: str) -> v0:\n self.currency_code = v8\n return self\n\n def v9(self, v10: str) -> v0:\n self.item_id = v10\n return self\n\n def v11(self, v12: str) -> v0:\n ... |
v50 | [
"str"
] | v0 | def v50(self, v51: str) -> v0:
self.subscription_id = v51
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
# pylint: disable=duplicate-code
# pylint: disable=li... | [
"class v0(Operation):\n v1: str = '/platform/admin/namespaces/{namespace}/users/{userId}/subscriptions/{subscriptionId}/grant'\n v2: str = 'PUT'\n v3: List[str] = ['application/json']\n v4: List[str] = ['application/json']\n v5: List[List[str]] = [['BEARER_AUTH'], ['BEARER_AUTH']]\n v6: str = None... |
v50 | [
"str"
] | v0 | def v50(self, v51: str) -> v0:
self.namespace = v51
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
# pylint: disable=duplicate-code
# pylint: disable=li... | [
"class v0(Operation):\n v1: str = '/cloudsave/v1/admin/namespaces/{namespace}/users/{userId}/concurrent/records/{key}/public'\n v2: str = 'PUT'\n v3: List[str] = ['application/json']\n v4: List[str] = ['application/json']\n v5: List[List[str]] = [['BEARER_AUTH']]\n v6: str = None\n v7: ModelsAd... |
v0 | [
"bool"
] | dict | def v0(self, v1: bool=False) -> dict:
v2: dict = {}
if hasattr(self, 'currency_code'):
v2['currencyCode'] = str(self.currency_code)
elif v1:
v2['currencyCode'] = ''
if hasattr(self, 'item_id'):
v2['itemId'] = str(self.item_id)
elif v1:
v2['itemId'] = ''
if hasattr... | [] | [] | [] | 27 | # 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-platform-service (4.10.0)
# pylint: disabl... | null |
v0 | [
"str",
"str"
] | Any | def v0(self, v1: str, v2: str):
self.user_api_key = v1
self.org_api_key = v2 | [] | [] | [] | 3 | """
This module lets you get question and prediction information from Metaculus
and submit predictions, via the API (https://www.metaculus.com/api2/)
**Example**
In this example, we predict the admit rate for Harvard's class of 2029:
https://www.metaculus.com/questions/3622
We predict that the admit rate will be 20... | null |
v0 | [
"np.ndarray"
] | tf.Tensor | def v0(self, v1: np.ndarray) -> tf.Tensor:
v1 = self.dense1(v1)
return self.dense2(v1) | [] | [] | [] | 3 | import numpy as np
import pytest
import tensorflow as tf
from tensorflow.keras.layers import Dense, Input, InputLayer
from alibi_detect.cd.tensorflow import UAE, HiddenOutput
n, n_features, n_classes, latent_dim = 100, 10, 5, 2
X_uae = np.random.rand(n * n_features).reshape(n, n_features).astype('float32')
encoder_ne... | null |
v0 | [
"Any",
"Any",
"Any",
"Any",
"Any",
"Any",
"Any"
] | bool | def v0(self, v1, v2, v3, v4, v5, v6=None, v7=None) -> bool:
v8 = 'bash'
if 'alpine' in v5:
v8 = 'sh'
if v6 == None:
v9 = {str(v3) + '/tcp': str(v3)}
else:
v9 = {str(v3) + '/tcp': str(v3), str(v6) + '/tcp': str(v7)}
try:
self.client.containers.run(image='catone/inspire... | [] | [] | [] | 14 | import docker
class CreateContainer(object):
def __init__(self):
self.client = docker.from_env()
def is_create_container(self, mem, cpu, web_shell_port, container_name, os_name, open_port=None, rand_port=None) -> bool :
shell = "bash"
if "alpine" in os_name:
shell = ... | null |
v1 | [
"str",
"str"
] | str | def v1(v2: str, v3: str=None) -> str:
v4 = v0()[v2]
try:
if len(v4) > 0:
return v4
except:
return v3 | [
{
"name": "v0",
"input_types": [],
"output_type": "dict",
"code": "def v0() -> dict:\n return sc._jvm.scala.collection.JavaConversions.mapAsJavaMap(dbutils.entry_point.getDbutils().notebook().getContext().tags())",
"dependencies": []
}
] | [] | [] | 7 | # Databricks notebook source
import builtins as BI
from pyspark.sql import functions as FT
# Get all tags
def getTags() -> dict:
return sc._jvm.scala.collection.JavaConversions.mapAsJavaMap(
dbutils.entry_point.getDbutils().notebook().getContext().tags()
)
# Get a single tag's value
def getTag(tagName: str, ... | null |
v0 | [] | int | def v0(self) -> int:
self._display('grade')
return self.score | [] | [] | [] | 3 | # Databricks notebook source
import builtins as BI
from pyspark.sql import functions as FT
# Get all tags
def getTags() -> dict:
return sc._jvm.scala.collection.JavaConversions.mapAsJavaMap(
dbutils.entry_point.getDbutils().notebook().getContext().tags()
)
# Get a single tag's value
def getTag(tagName: str, ... | null |
v9 | [
"v0"
] | Any | def v9(self, v10: v0):
if not v10.id:
raise ValueError("The test cases' id must be specified")
if v10.id in self.ids:
raise ValueError(f'Duplicate test case id: {v10.id}')
self.testCases.append(v10)
self.ids.add(v10.id)
return self | [] | [] | [] | 8 | # Databricks notebook source
import builtins as BI
from pyspark.sql import functions as FT
# Get all tags
def getTags() -> dict:
return sc._jvm.scala.collection.JavaConversions.mapAsJavaMap(
dbutils.entry_point.getDbutils().notebook().getContext().tags()
)
# Get a single tag's value
def getTag(tagName: str, ... | [
"class v0(object):\n v1 = ('description', 'testFunction', 'id', 'uniqueId', 'dependsOn', 'escapeHTML', 'points', 'hint')\n\n def __init__(self, v2: str, v3: Callable[[], Any], v4: str=None, v5: Iterable[str]=[], v6: bool=False, v7: int=1, v8=None):\n self.id = v4\n self.hint = v8\n self.p... |
v4 | [
"v0"
] | Any | def v4(self, v5: v0):
self.testResults[v5.test.id] = v5
return v5 | [] | [] | [] | 3 | # Databricks notebook source
import builtins as BI
from pyspark.sql import functions as FT
# Get all tags
def getTags() -> dict:
return sc._jvm.scala.collection.JavaConversions.mapAsJavaMap(
dbutils.entry_point.getDbutils().notebook().getContext().tags()
)
# Get a single tag's value
def getTag(tagName: str, ... | [
"class v0(object):\n v1 = ('test', 'skipped', 'passed', 'status', 'points', 'exception', 'message')\n\n def __init__(self, v2, v3=False):\n try:\n self.test = v2\n self.skipped = v3\n if v3:\n self.status = 'skipped'\n self.passed = False\n... |
v0 | [
"str"
] | int | def v0(v1: str) -> int:
if v1 == 'CRITICAL':
return logging.CRITICAL
if v1 == 'ERROR':
return logging.ERROR
if v1 == 'WARNING':
return logging.WARNING
if v1 == 'INFO':
return logging.INFO
if v1 == 'DEBUG':
return logging.DEBUG
logging.warning(f'Unsupported... | [] | [
"logging"
] | [
"import logging"
] | 13 | # std
import argparse
import logging
import signal
import time
from pathlib import Path
# project
from src.chia_log.handlers.daily_stats.stats_manager import StatsManager
from src.chia_log.log_consumer import create_log_consumer_from_config
from src.chia_log.log_handler import LogHandler
from src.config import Config,... | null |
v0 | [
"dict",
"dict",
"str",
"str",
"str"
] | Any | def v0(self, v1: dict, v2: dict, v3: str, v4: str=None, v5: str=None):
self.build_templates = v2
self.template_directory = v3
self.build_configuration = v1.get('build-configuration', {}) | [] | [] | [] | 4 | import logging
import os
from typing import Dict
from cookiecutter.main import cookiecutter
from service_buddy_too.codegenerator.cookie_cutter_creator import _make_cookie_safe
from service_buddy_too.service.service import Service
from service_buddy_too.util import command_util
from service_buddy_too.util.command_util... | null |
v4 | [
"int",
"AnyStr",
"AnyStr",
"Optional[Tuple[float]]",
"AnyStr"
] | Any | def v4(v5: int=1, v6: AnyStr='linear', v7: AnyStr='ip', v8: Optional[Tuple[float]]=None, v9: AnyStr='link_inference'):
if v7 in ['ip', 'dot'] and v5 != 1:
warnings.warn('For inner product link method the output_dim will be ignored as it is fixed to be 1.', stacklevel=2)
v5 = 1
def v10(v11):
... | [
{
"name": "v0",
"input_types": [
"Any"
],
"output_type": "Any",
"code": "def v0(v1):\n v2 = LinkEmbedding(activation='linear', method=edge_embedding_method)(v1)\n if edge_embedding_method in ['ip', 'dot']:\n v3 = Activation(output_act)(v2)\n else:\n v3 = Dense(output... | [
"warnings"
] | [
"import warnings"
] | 17 | # -*- coding: utf-8 -*-
#
# Copyright 2018-2020 Data61, CSIRO
#
# 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 applicabl... | null |
v14 | [
"int",
"AnyStr",
"AnyStr"
] | Any | def v14(v15: int=1, v16: AnyStr='sigmoid', v17: AnyStr='ip'):
v18 = v4(output_dim=v15, output_act=v16, edge_embedding_method=v17, name='link_classification')
return v18 | [
{
"name": "v0",
"input_types": [
"Any"
],
"output_type": "Any",
"code": "def v0(v1):\n v2 = LinkEmbedding(activation='linear', method=edge_embedding_method)(v1)\n if edge_embedding_method in ['ip', 'dot']:\n v3 = Activation(output_act)(v2)\n else:\n v3 = Dense(output... | [
"warnings"
] | [
"import warnings"
] | 3 | # -*- coding: utf-8 -*-
#
# Copyright 2018-2020 Data61, CSIRO
#
# 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 applicabl... | null |
v14 | [
"int",
"Optional[Tuple[float]]",
"AnyStr"
] | Any | def v14(v15: int=1, v16: Optional[Tuple[float]]=None, v17: AnyStr='ip'):
v18 = v4(output_dim=v15, output_act='linear', edge_embedding_method=v17, clip_limits=v16, name='link_regression')
return v18 | [
{
"name": "v0",
"input_types": [
"Any"
],
"output_type": "Any",
"code": "def v0(v1):\n v2 = LinkEmbedding(activation='linear', method=edge_embedding_method)(v1)\n if edge_embedding_method in ['ip', 'dot']:\n v3 = Activation(output_act)(v2)\n else:\n v3 = Dense(output... | [
"warnings"
] | [
"import warnings"
] | 3 | # -*- coding: utf-8 -*-
#
# Copyright 2018-2020 Data61, CSIRO
#
# 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 applicabl... | null |
v4 | [
"'Tags'",
"Sequence[int]"
] | Any | def v4(v5: 'Tags', v6: Sequence[int]=(10, 11)):
def v7():
for v8 in v6:
yield v8
yield (v8 + 10)
yield (v8 + 20)
def v9(v10: int):
try:
yield coordinates[v10]
except KeyError:
pass
try:
yield coordinates[v1... | [
{
"name": "v0",
"input_types": [],
"output_type": "Any",
"code": "def v0():\n for v1 in codes:\n yield v1\n yield (v1 + 10)\n yield (v1 + 20)",
"dependencies": []
},
{
"name": "v2",
"input_types": [
"int"
],
"output_type": "Any",
"code": "def... | [] | [] | 39 | # Copyright (c) 2016-2022, Manfred Moitzi
# License: MIT License
from typing import (
Iterable,
Optional,
List,
TYPE_CHECKING,
Sequence,
Any,
Iterator,
)
from functools import partial
import logging
from .tags import DXFTag
from .types import POINT_CODES, NONE_TAG, VALID_XDATA_GROUP_CODES
l... | null |
v0 | [
"Any"
] | str | def v0(v1) -> str:
if isinstance(v1, bytes):
return v1.decode(encoding='ascii', errors='ignore')
return v1 | [] | [] | [] | 4 | # Copyright (c) 2016-2022, Manfred Moitzi
# License: MIT License
from typing import (
Iterable,
Optional,
List,
TYPE_CHECKING,
Sequence,
Any,
Iterator,
)
from functools import partial
import logging
from .tags import DXFTag
from .types import POINT_CODES, NONE_TAG, VALID_XDATA_GROUP_CODES
l... | null |
v0 | [
"np.matrix",
"np.matrix"
] | float | def v0(v1: np.matrix, v2: np.matrix) -> float:
v3 = v2.H
return v3 * v1 * v2 / (v3 * v2) | [] | [] | [] | 3 | """
https://en.wikipedia.org/wiki/Rayleigh_quotient
"""
import numpy as np
def is_hermitian(matrix:np.matrix) -> bool:
"""
Checks if a matrix is Hermitian.
>>> import numpy as np
>>> A = np.matrix([
... [2, 2+1j, 4],
... [2-1j, 3, 1j],
... [4, -1j, 1]])
>>> is_hermitian(A)
... | null |
v6 | [] | None | def v6() -> None:
v7 = np.matrix([[2, 2 + 1j, 4], [2 - 1j, 3, 1j], [4, -1j, 1]])
v8 = np.matrix([[1], [2], [3]])
assert v0(v7), f'{v7} is not hermitian.'
print(v2(v7, v8))
v7 = np.matrix([[1, 2, 4], [2, 3, -1], [4, -1, 1]])
assert v0(v7), f'{v7} is not hermitian.'
assert v2(v7, v8) == float(... | [
{
"name": "v0",
"input_types": [
"np.matrix"
],
"output_type": "bool",
"code": "def v0(v1: np.matrix) -> bool:\n return np.array_equal(v1, v1.H)",
"dependencies": []
},
{
"name": "v2",
"input_types": [
"np.matrix",
"np.matrix"
],
"output_type": "float... | [
"numpy"
] | [
"import numpy as np"
] | 8 | """
https://en.wikipedia.org/wiki/Rayleigh_quotient
"""
import numpy as np
def is_hermitian(matrix:np.matrix) -> bool:
"""
Checks if a matrix is Hermitian.
>>> import numpy as np
>>> A = np.matrix([
... [2, 2+1j, 4],
... [2-1j, 3, 1j],
... [4, -1j, 1]])
>>> is_hermitian(A)
... | null |
v0 | [
"Any"
] | None | def v0(self, v1) -> None:
v2 = int(os.getenv('LOCAL_RANK'))
if self.trainer.is_global_zero:
self.log('my_loss_2', 1 + v2, on_epoch=True, rank_zero_only=True)
v3 = str(self.global_rank)
v4 = [[v3], (v3,), set(v3)]
v5 = self.trainer.training_type_plugin.broadcast(v4)
assert v4 == [[str(sel... | [] | [
"os"
] | [
"import os"
] | 9 | # 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 | [
"bool"
] | bool | def v0(self, v1: bool=True) -> bool:
v2 = True
if self._f_x is None:
v2 = False
if v1:
raise AttributeError('The function to be approximated has not been set.')
if self._degree is None:
v2 = False
if v1:
raise AttributeError('The degree of the polynomi... | [] | [
"qiskit"
] | [
"from qiskit.circuit import QuantumRegister, AncillaRegister",
"from qiskit.circuit.library.blueprintcircuit import BlueprintCircuit",
"from qiskit.circuit.exceptions import CircuitError"
] | 23 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | null |
v0 | [
"Optional[int]"
] | None | def v0(self, v1: Optional[int]) -> None:
if v1:
v2 = QuantumRegister(v1)
v3 = QuantumRegister(1)
self.qregs = [v2, v3]
v4 = v1 + 1
if self.contains_zero_breakpoint:
v4 -= 1
if v4 > 0:
v5 = AncillaRegister(v4)
self.add_register(v5)
... | [] | [
"qiskit"
] | [
"from qiskit.circuit import QuantumRegister, AncillaRegister, QuantumCircuit",
"from qiskit.circuit.exceptions import CircuitError"
] | 21 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | null |
v0 | [
"dict",
"Any"
] | Any | def v0(self, v1: dict, v2=-1):
v3 = []
for (v4, v5) in v1.items():
v3.append(self._Handler(v5, v2))
for (v4, v6) in zip(v1, v3):
v6.links = [id(other_handler) for v7 in v3 if v7 is not v6]
self._observe(v4, v6) | [] | [] | [] | 7 | """ Dispatch events to handlers """
from copy import deepcopy
from threading import Lock
import structlog
from OpenCast.infra import Id
class EventDispatcher:
ANY_ID = None
class _Handler:
def __init__(self, evtcls_handler, count):
self.links = []
self._evtcls_handler = ev... | null |
v0 | [
"torch.Tensor",
"torch.Tensor",
"float",
"Optional[torch.Tensor]"
] | torch.Tensor | def v0(v1: torch.Tensor, v2: torch.Tensor, v3: float=0.1, v4: Optional[torch.Tensor]=None) -> torch.Tensor:
v5 = v1.device
v6 = v1.size(0)
v7 = torch.cat((v1, v2), dim=0)
v7 = F.normalize(v7, dim=-1)
v8 = torch.einsum('if, jf -> ij', v7, v7) / v3
(v9, v10) = torch.max(v8, dim=1, keepdim=True)
... | [] | [
"torch"
] | [
"import torch",
"import torch.nn.functional as F"
] | 19 | # Copyright 2021 solo-learn development team.
# 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, publ... | 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 | # Copyright 2021 solo-learn development team.
# 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, publ... | null |
v0 | [
"bool"
] | bool | def v0(self, v1: bool) -> bool:
if not self.active:
return v1
return False | [] | [] | [] | 4 | import logging
from decimal import Decimal
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Union
from urllib.parse import urljoin
from django.core.exceptions import ValidationError
from prices import Money, TaxedMoney, TaxedMoneyRange
from ...core.taxes import TaxError, TaxType, zero_taxed_money
from ...... | null |
v0 | [
"Any"
] | bool | def v0(v1: Any) -> bool:
if isinstance(v1, str):
try:
b64decode(bytes(v1, encoding='utf-8'), validate=True)
return True
except binascii.Error:
pass
return False | [] | [
"base64",
"binascii"
] | [
"import binascii",
"from base64 import b64decode"
] | 8 | """
This module provides functionality for creating a data model from a
set of example structures.
"""
import binascii
import collections
import collections.abc
import functools
from itertools import chain
import os
from base64 import b64decode
from copy import copy, deepcopy
from datetime import date, datetime
from ty... | null |
v0 | [
"abc.MarshallableTypes"
] | None | def v0(self, v1: abc.MarshallableTypes) -> None:
v2: Set[abc.MarshallableTypes] = copy(self._set)
v2.discard(v1)
self.clear()
self.__ior__(v2) | [] | [
"copy"
] | [
"from copy import copy, deepcopy"
] | 5 | """
This module provides functionality for creating a data model from a
set of example structures.
"""
import binascii
import collections
import collections.abc
import functools
from itertools import chain
import os
from base64 import b64decode
from copy import copy, deepcopy
from datetime import date, datetime
from ty... | null |
v0 | [
"Iterable[Union[abc.Readable, abc.MarshallableTypes]]"
] | 'Synonyms' | def v0(self, v1: Iterable[Union[abc.Readable, abc.MarshallableTypes]]) -> 'Synonyms':
v2: Synonyms = copy(self)
v2 |= v1
return v2 | [] | [
"copy"
] | [
"from copy import copy, deepcopy"
] | 4 | """
This module provides functionality for creating a data model from a
set of example structures.
"""
import binascii
import collections
import collections.abc
import functools
from itertools import chain
import os
from base64 import b64decode
from copy import copy, deepcopy
from datetime import date, datetime
from ty... | null |
v0 | [
"str",
"Callable[[str], str]"
] | Iterable[type] | def v0(self, v1: str='__main__', v2: Callable[[str], str]=class_name_from_pointer) -> Iterable[type]:
v3: str
v4: Synonyms
for (v3, v4) in self.items():
v5: type
for v5 in v4.get_models(v3, module=v1, name=v2):
yield v5 | [] | [] | [] | 7 | """
This module provides functionality for creating a data model from a
set of example structures.
"""
import binascii
import collections
import collections.abc
import functools
from itertools import chain
import os
from base64 import b64decode
from copy import copy, deepcopy
from datetime import date, datetime
from ty... | null |
v0 | [] | None | def v0(self, **v1: Synonyms) -> None:
v2: str
v3: Iterable[Union[abc.Readable, abc.MarshallableTypes]]
for (v2, v3) in v1.items():
self[v2] = v3 | [] | [] | [] | 5 | """
This module provides functionality for creating a data model from a
set of example structures.
"""
import binascii
import collections
import collections.abc
import functools
from itertools import chain
import os
from base64 import b64decode
from copy import copy, deepcopy
from datetime import date, datetime
from ty... | null |
v0 | [
"str",
"Callable[[str], str]"
] | None | def v0(self, v1: str, v2: Callable[[str], str]=class_name_from_pointer) -> None:
os.makedirs(os.path.dirname(v1), exist_ok=True)
v3: str = self.get_module_source(name=v2)
with open(v1, 'w') as v4:
v4.write(f'{v3}\n') | [] | [
"os"
] | [
"import os"
] | 5 | """
This module provides functionality for creating a data model from a
set of example structures.
"""
import binascii
import collections
import collections.abc
import functools
from itertools import chain
import os
from base64 import b64decode
from copy import copy, deepcopy
from datetime import date, datetime
from ty... | null |
v0 | [
"Path",
"str"
] | bool | def v0(self, v1: Path, v2: str=None) -> bool:
if isinstance(v1, str):
v1 = Path(v1)
if v1.name == 'setup.py':
return False
return v1.suffix == '.py' or (v1 / '__init__.py').exists() | [] | [
"pathlib"
] | [
"from pathlib import Path"
] | 6 | # built-in
import ast
from pathlib import Path
from typing import Dict, List, Set
# external
from dephell_discover import Root as PackageRoot
# app
from ..cache import TextCache
from ..cached_property import cached_property
from ..controllers import DependencyMaker
from ..models import RootDependency
from ..networkin... | null |
v0 | [
"Any"
] | Set[str] | def v0(self, v1) -> Set[str]:
v2 = set()
v3 = ast.parse(v1)
for v4 in ast.walk(v3):
if isinstance(v4, ast.Import):
for v5 in v4.names:
v2.add(v5.name)
elif isinstance(v4, ast.ImportFrom) and v4.level == 0:
v2.add(v4.module)
v6 = set()
for v7 in... | [] | [
"ast"
] | [
"import ast"
] | 19 | # built-in
import ast
from pathlib import Path
from typing import Dict, List, Set
# external
from dephell_discover import Root as PackageRoot
# app
from ..cache import TextCache
from ..cached_property import cached_property
from ..controllers import DependencyMaker
from ..models import RootDependency
from ..networkin... | null |
v0 | [
"torch.Tensor"
] | Any | def v0(self, v1: torch.Tensor):
for v2 in self.layers:
v3 = v2(v1)
(v4, v5) = v3.chunk(2, dim=-1)
v4 = self.activation(v4)
v5 = torch.sigmoid(v5)
v1 = v5 * v1 + (v5.new_tensor([1]) - v5) * v4
return v1 | [] | [
"torch"
] | [
"import torch",
"from torch import nn",
"import torch.nn.functional as F"
] | 8 | # 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 logging
from typing import List, Tuple
import torch
from torch import nn
import torch.nn.functional as F
from fairseq.dat... | null |
v0 | [
"dict"
] | Any | def v0(self, v1: dict):
v2 = 0.0
for (v3, v4) in v1.items():
v5 = self.dataset.id2datum[v3]
v6 = v5['label']
if v4 in v6:
v2 += v6[v4]
return v2 / len(v1) | [] | [] | [] | 8 | # coding=utf-8
# Copyleft 2019 project LXRT.
import json
import os
import pickle
import numpy as np
import torch
from torch.utils.data import Dataset
from param import args
from utils import load_obj_tsv
# Load part of the dataset for fast checking.
# Notice that here is the number of images instead of the number o... | null |
v0 | [
"dict",
"Any"
] | Any | def v0(self, v1: dict, v2):
with open(v2, 'w') as v3:
for (v4, (v5, v6)) in v1.items():
v7 = self.dataset.id2datum[v4]['identifier']
v5 = 'True' if v5 == 1 else 'False'
v3.write('%s,%s,%s\n' % (v7, v5, v6)) | [] | [] | [] | 6 | # coding=utf-8
# Copyright 2019 project LXRT.
import json
import numpy as np
from torch.utils.data import Dataset
from param import args
from utils import load_obj_tsv
# Load part of the dataset for fast checking.
# Notice that here is the number of images instead of the number of data,
# which means all related da... | null |
v0 | [
"dict"
] | Any | def v0(self, v1: dict):
v2 = self.dataset.data
v3 = v1
v4 = len(v2)
if len(v3) < v4:
print('Some predictions are missing!')
print('Got ' + str(len(v3)) + ' predictions but expected ' + str(v4))
for v5 in v2:
v6 = v5['identifier']
v7 = self.dataset.identifi... | [] | [] | [] | 39 | from torch.utils.data import DataLoader, Dataset, Sampler
from pathlib import Path
from collections import defaultdict
import json
import random
from multiprocessing import Pool
import h5py
import pickle
import math
from tqdm import tqdm
import torch
import numpy as np
from copy import deepcopy
from torch.utils.data.d... | null |
v0 | [
"datetime.datetime",
"str",
"str"
] | str | def v0(v1: datetime.datetime, v2: str, v3: str) -> str:
v2 = v2.upper()
v3 = v3.upper()
return f'{v1.year}-{v1.month:02d}-{v1.day:02d}-{v1.hour:02d}-{v1.minute:02d}-{v1.second:02d}-vote-{v2}-{v3}' | [] | [] | [] | 4 | """
CollecTor Filesystem Protocol.
"""
# TODO: path.join implementation that uses either filesystem or web semantics
import bz2
import datetime
import enum
import gzip
import logging
import os
import os.path
import typing
import lzma
LOG = logging.getLogger('bushel')
class CollecTorIndexCompression(enum.Enum):
"... | null |
v0 | [
"datetime.datetime",
"str"
] | str | def v0(v1: datetime.datetime, v2: str) -> str:
v2 = v2.lower()
return os.path.join(f'{v1.year}', f'{v1.month:02d}', f'{v2[0]}', f'{v2[1]}') | [] | [
"os"
] | [
"import os",
"import os.path"
] | 3 | """
CollecTor Filesystem Protocol.
"""
# TODO: path.join implementation that uses either filesystem or web semantics
import bz2
import datetime
import enum
import gzip
import logging
import os
import os.path
import typing
import lzma
LOG = logging.getLogger('bushel')
class CollecTorIndexCompression(enum.Enum):
"... | null |
v10 | [
"v1",
"v0",
"datetime.datetime",
"str"
] | str | def v10(v11: v1, v12: v0, v13: datetime.datetime, v14: str) -> str:
v14 = v14.lower()
return os.path.join(v11.value, v12.value, v7(v13, v14), f'{v14}') | [
{
"name": "v7",
"input_types": [
"datetime.datetime",
"str"
],
"output_type": "str",
"code": "def v7(v8: datetime.datetime, v9: str) -> str:\n v9 = v9.lower()\n return os.path.join(f'{v8.year}', f'{v8.month:02d}', f'{v9[0]}', f'{v9[1]}')",
"dependencies": []
}
] | [
"os"
] | [
"import os",
"import os.path"
] | 3 | """
CollecTor Filesystem Protocol.
"""
# TODO: path.join implementation that uses either filesystem or web semantics
import bz2
import datetime
import enum
import gzip
import logging
import os
import os.path
import typing
import lzma
LOG = logging.getLogger('bushel')
class CollecTorIndexCompression(enum.Enum):
"... | [
"v0 = typing.Union[CollectorOutRelayDescsMarker, CollectorOutBridgeDescsMarker]",
"class v1(enum.Enum):\n v2 = 'bridge-descriptors'\n v3 = 'exit-lists'\n v4 = 'relay-descriptors'\n v5 = 'torperf'\n v6 = 'webstats'"
] |
v0 | [
"T.Union[str, bytes]"
] | bool | def v0(v1: T.Union[str, bytes]) -> bool:
try:
if isinstance(v1, str):
v1.encode('ascii')
elif isinstance(v1, bytes):
v1.decode('ascii')
except UnicodeDecodeError:
return False
return True | [] | [] | [] | 9 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v4 | [
"T.Iterable['Compiler']",
"T.Sequence['FileOrString']"
] | T.Dict['Compiler', T.List['FileOrString']] | def v4(v5: T.Iterable['Compiler'], v6: T.Sequence['FileOrString']) -> T.Dict['Compiler', T.List['FileOrString']]:
v7: T.Dict['Compiler', T.List['FileOrString']] = {}
for v8 in v6:
v9 = v0(v5, v8)
if v9 not in v7:
v7[v9] = [v8]
else:
v7[v9].append(v8)
return v7 | [
{
"name": "v0",
"input_types": [
"T.Iterable['Compiler']",
"'FileOrString'"
],
"output_type": "'Compiler'",
"code": "def v0(v1: T.Iterable['Compiler'], v2: 'FileOrString') -> 'Compiler':\n for v3 in v1:\n if v3.can_compile(v2):\n return v3\n raise MesonExcepti... | [] | [] | 9 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v0 | [] | bool | def v0() -> bool:
v1 = platform.system().lower()
return v1 == 'windows' or 'mingw' in v1 | [] | [
"platform"
] | [
"import platform"
] | 3 | # Copyright 2016-2017 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v0 | [
"typing.List[str]"
] | bool | def v0(v1: typing.List[str]) -> bool:
try:
if subprocess.run(v1, timeout=10).returncode == 0:
return True
except (FileNotFoundError, subprocess.TimeoutExpired):
pass
return False | [] | [
"subprocess"
] | [
"import platform, subprocess, operator, os, shlex, shutil, re"
] | 7 | # Copyright 2012-2015 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v0 | [
"T.Union[str, Path]"
] | T.Optional[T.Dict[str, str]] | def v0(v1: T.Union[str, Path]) -> T.Optional[T.Dict[str, str]]:
v2 = [dict(name='git', cmd='git', repo_dir='.git', get_rev='git describe --dirty=+', rev_regex='(.*)', dep='.git/logs/HEAD'), dict(name='mercurial', cmd='hg', repo_dir='.hg', get_rev='hg id -i', rev_regex='(.*)', dep='.hg/dirstate'), dict(name='subvers... | [] | [
"collections",
"pathlib",
"shutil"
] | [
"from pathlib import Path",
"import platform, subprocess, operator, os, shlex, shutil, re",
"import collections"
] | 12 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v0 | [] | bool | def v0() -> bool:
v1 = os.environ.get('VSCMD_VER', '')
v2 = v1.split('.', 2)
v3 = int(v2[0])
if v3 >= 17:
return True
if v3 == 16 and int(v2[1]) >= 10:
return True
return v1.startswith('16.9.0') and '-pre.' in v1 | [] | [
"os"
] | [
"import platform, subprocess, operator, os, shlex, shutil, re"
] | 9 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v0 | [
"str"
] | typing.Tuple[typing.Callable[[typing.Any, typing.Any], bool], str] | def v0(v1: str) -> typing.Tuple[typing.Callable[[typing.Any, typing.Any], bool], str]:
if v1.startswith('>='):
v2 = operator.ge
v1 = v1[2:]
elif v1.startswith('<='):
v2 = operator.le
v1 = v1[2:]
elif v1.startswith('!='):
v2 = operator.ne
v1 = v1[2:]
elif v... | [] | [
"operator"
] | [
"import platform, subprocess, operator, os, shlex, shutil, re"
] | 25 | # Copyright 2012-2015 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v7 | [
"str",
"T.Union[str, T.Iterable[str]]"
] | T.Tuple[bool, T.List[str], T.List[str]] | def v7(v8: str, v9: T.Union[str, T.Iterable[str]]) -> T.Tuple[bool, T.List[str], T.List[str]]:
if isinstance(v9, str):
v9 = [v9]
v10 = []
v11 = []
for v12 in v9:
if not v3(v8, v12):
v11.append(v12)
else:
v10.append(v12)
return (v11 == [], v11, v10) | [
{
"name": "v0",
"input_types": [
"str"
],
"output_type": "T.Tuple[T.Callable[[T.Any, T.Any], bool], str]",
"code": "def v0(v1: str) -> T.Tuple[T.Callable[[T.Any, T.Any], bool], str]:\n if v1.startswith('>='):\n v2 = operator.ge\n v1 = v1[2:]\n elif v1.startswith('<='):\... | [
"operator"
] | [
"import platform, subprocess, operator, os, shlex, shutil, re"
] | 11 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v3 | [] | str | def v3() -> str:
if v0():
try:
v4 = subprocess.Popen(['dpkg-architecture', '-qDEB_HOST_MULTIARCH'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
(v5, v6) = v4.communicate()
if v4.returncode == 0:
v7 = v5.decode().strip()
return 'lib/'... | [
{
"name": "v0",
"input_types": [],
"output_type": "bool",
"code": "def v0() -> bool:\n return os.path.isfile('/etc/debian_version')",
"dependencies": []
},
{
"name": "v1",
"input_types": [],
"output_type": "bool",
"code": "def v1() -> bool:\n return platform.system().lo... | [
"os",
"platform",
"subprocess"
] | [
"import platform, subprocess, operator, os, shlex, shutil, re"
] | 15 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v5 | [] | typing.List[str] | def v5() -> typing.List[str]:
if v3():
return ['C:/mingw/lib']
if v1():
return ['/usr/lib']
v6 = ['/usr/local/lib', '/usr/lib', '/lib']
if v0():
return v6
v7 = platform.machine()
if v7 in ('i386', 'i486', 'i586', 'i686'):
v8 = 'i386'
elif v7.startswith('arm'):... | [
{
"name": "v0",
"input_types": [],
"output_type": "bool",
"code": "def v0() -> bool:\n return platform.system().lower() == 'freebsd'",
"dependencies": []
},
{
"name": "v1",
"input_types": [],
"output_type": "bool",
"code": "def v1() -> bool:\n return platform.system().l... | [
"os",
"pathlib",
"platform"
] | [
"from pathlib import Path",
"import platform, subprocess, operator, os, shlex, shutil, re"
] | 31 | # Copyright 2012-2015 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v0 | [
"str",
"str"
] | bool | def v0(v1: str, v2: str='/\\') -> bool:
for v3 in v2:
if v3 in v1:
return True
return False | [] | [] | [] | 5 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v0 | [
"str",
"str"
] | None | def v0(v1: str, v2: str) -> None:
v3 = True
try:
with open(v1, 'rb') as v4, open(v2, 'rb') as v5:
if v4.read() == v5.read():
v3 = False
except FileNotFoundError:
pass
if v3:
os.replace(v2, v1)
else:
os.unlink(v2) | [] | [
"os"
] | [
"import platform, subprocess, operator, os, shlex, shutil, re"
] | 12 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v7 | [
"T.Dict[v0, v1]",
"v0",
"bool"
] | T.List[v1] | def v7(v8: T.Dict[v0, v1], v9: v0, v10: bool=False) -> T.List[v1]:
v11: T.Callable[[v0], v1] = v8.get
if v10:
v11 = v8.pop
return v2(v11(v9) or [], flatten=True) | [
{
"name": "v2",
"input_types": [
"T.Any",
"bool"
],
"output_type": "T.List[T.Any]",
"code": "def v2(v3: T.Any, v4: bool=True) -> T.List[T.Any]:\n if not isinstance(v3, list):\n return [v3]\n v5 = []\n for v6 in v3:\n if v4 and isinstance(v6, list):\n ... | [] | [] | 5 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | [
"v0 = T.TypeVar('_T')",
"v1 = T.TypeVar('_U')"
] |
v1 | [
"T.Callable[[v0], object]",
"T.Iterable[v0]"
] | T.Tuple[T.Iterator[v0], T.Iterator[v0]] | def v1(v2: T.Callable[[v0], object], v3: T.Iterable[v0]) -> T.Tuple[T.Iterator[v0], T.Iterator[v0]]:
(v4, v5) = tee(v3)
return (filterfalse(v2, v4), filter(v2, v5)) | [] | [
"itertools"
] | [
"from itertools import tee, filterfalse"
] | 3 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | [
"v0 = T.TypeVar('_T')"
] |
v0 | [
"T.List[str]",
"T.Optional[str]",
"T.Union[T.TextIO, T.BinaryIO, int]",
"T.Union[T.TextIO, T.BinaryIO, int]"
] | T.Tuple['subprocess.Popen[str]', str, str] | def v0(v1: T.List[str], v2: T.Optional[str]=None, v3: T.Union[T.TextIO, T.BinaryIO, int]=subprocess.PIPE, v4: T.Union[T.TextIO, T.BinaryIO, int]=subprocess.PIPE, **v5: T.Any) -> T.Tuple['subprocess.Popen[str]', str, str]:
v6 = subprocess.Popen(v1, universal_newlines=False, close_fds=False, stdout=v3, stderr=v4, **v... | [] | [
"subprocess",
"sys"
] | [
"import sys",
"import platform, subprocess, operator, os, shlex, shutil, re"
] | 17 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v0 | [
"T.Iterable[str]",
"T.Iterable[str]"
] | T.Optional[str] | def v0(v1: T.Iterable[str], v2: T.Iterable[str]) -> T.Optional[str]:
for v3 in v1:
for v4 in v2:
if not isinstance(v4, str):
continue
v5 = re.search(v3, v4)
if v5:
return v5.group()
return None | [] | [
"re"
] | [
"import platform, subprocess, operator, os, shlex, shutil, re"
] | 9 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v0 | [
"T.List[str]",
"T.List[str]"
] | T.Dict[str, T.Union[str, T.List[str]]] | def v0(v1: T.List[str], v2: T.List[str]) -> T.Dict[str, T.Union[str, T.List[str]]]:
v3 = {}
if v1:
v3['@INPUT@'] = v1
for (v4, v5) in enumerate(v1):
v3['@INPUT{}@'.format(v4)] = v5
if len(v1) == 1:
v3['@PLAINNAME@'] = v6 = os.path.basename(v1[0])
v3['@... | [] | [
"os"
] | [
"import platform, subprocess, operator, os, shlex, shutil, re"
] | 17 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v0 | [
"str"
] | None | def v0(v1: str) -> None:
for (v2, v3, v4) in os.walk(v1):
os.chmod(v2, os.stat(v2).st_mode | stat.S_IWRITE | stat.S_IREAD)
for v5 in v4:
v6 = os.path.join(v2, v5)
if os.path.isfile(v6):
os.chmod(v6, os.stat(v6).st_mode | stat.S_IWRITE | stat.S_IREAD) | [] | [
"os",
"stat"
] | [
"import stat",
"import platform, subprocess, operator, os, shlex, shutil, re"
] | 7 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v0 | [
"str",
"[str]"
] | bool | def v0(v1: str, v2: [str]) -> bool:
if not v2:
return False
for v3 in v2:
if v1.startswith(v3 + '/'):
return True
return False | [] | [] | [] | 7 | #!/usr/bin/env python3
# Copyright 2021 Alibaba Group Holding Limited.
#
# 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 ... | null |
v0 | [
"str",
"str"
] | str | def v0(v1: str, v2: str) -> str:
try:
return os.path.relpath(v1, v2)
except (TypeError, ValueError):
return v1 | [] | [
"os"
] | [
"import platform, subprocess, operator, os, shlex, shutil, re"
] | 5 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v0 | [
"Path",
"Path",
"bool"
] | bool | def v0(v1: Path, v2: Path, v3: bool=False) -> bool:
try:
if v3:
v1.resolve().relative_to(v2.resolve())
else:
v1.relative_to(v2)
except ValueError:
return False
return True | [] | [] | [] | 9 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v0 | [
"Path",
"Path",
"bool"
] | Path | def v0(v1: Path, v2: Path, v3: bool=False) -> Path:
try:
if v3:
return v1.resolve().relative_to(v2.resolve())
else:
return v1.relative_to(v2)
except ValueError:
return v1 | [] | [] | [] | 8 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v4 | [
"T.Callable[..., v0]"
] | T.Callable[..., v0] | def v4(v5: T.Callable[..., v0]) -> T.Callable[..., v0]:
v6 = []
@wraps(v5)
def v7(*v8: T.Any, **v9: T.Any) -> v0:
if v6:
return v6[0]
v10 = v5(*v8, **v9)
v6.append(v10)
return v10
return v7 | [
{
"name": "v1",
"input_types": [],
"output_type": "T.List[v0]",
"code": "@wraps(func)\ndef v1(*v2: T.Any, **v3: T.Any) -> T.List[v0]:\n return list(func(*v2, **v3))",
"dependencies": []
}
] | [] | [] | 11 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | [
"v0 = T.TypeVar('_T')"
] |
v4 | [
"T.Callable[..., T.Generator[v0, None, None]]"
] | T.Callable[..., T.List[v0]] | def v4(v5: T.Callable[..., T.Generator[v0, None, None]]) -> T.Callable[..., T.List[v0]]:
@wraps(v5)
def v6(*v7: T.Any, **v8: T.Any) -> T.List[v0]:
return list(v5(*v7, **v8))
return v6 | [
{
"name": "v1",
"input_types": [],
"output_type": "T.List[v0]",
"code": "@wraps(func)\ndef v1(*v2: T.Any, **v3: T.Any) -> T.List[v0]:\n return list(func(*v2, **v3))",
"dependencies": []
}
] | [] | [] | 6 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | [
"v0 = T.TypeVar('_T')"
] |
v0 | [
"'Version'",
"T.Callable[[T.Any, T.Any], bool]"
] | bool | def v0(self, v1: 'Version', v2: T.Callable[[T.Any, T.Any], bool]) -> bool:
for (v3, v4) in zip(self._v, v1._v):
v5 = isinstance(v3, int)
v6 = isinstance(v4, int)
if v5 != v6:
return v2(v5, v6)
if v3 != v4:
return v2(v3, v4)
return v2(len(self._v), len(v1._... | [] | [] | [] | 9 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v0 | [
"str",
"'ConfigurationData'"
] | str | def v0(v1: str, v2: 'ConfigurationData') -> str:
v3 = v1.split()
v4 = []
for v5 in v3[2:]:
try:
(v6, v7) = v2.get(v5)
v4 += [str(v6)]
except KeyError:
v4 += [v5]
return ' '.join(v4) | [] | [] | [] | 10 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
v0 | [
"str",
"str"
] | bool | def v0(v1: str, v2: str) -> bool:
if v2 == 'meson':
if '#cmakedefine' in v1:
return False
elif '#mesondefine' in v1:
return False
return True | [] | [] | [] | 7 | # Copyright 2012-2020 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.