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
[ "Optional[int]" ]
Dict[str, Any]
def v0(self, v1: Optional[int]=None) -> Dict[str, Any]: if v1 is None: return self.get('/map/get-edits').json() else: return self.get('/map/get-edit-road-command', params={'id': v1}).json()
[]
[]
[]
5
import requests from typing import Any, Dict, List, Optional import pandas as pd class Simulation: __SECONDS_IN_A_DAY: int = 60 * 60 * 24 def __init__( self, api: str, scenario: Optional[str] = None, country_code: Optional[str] = None, city_name: Optional[str] = None...
null
v0
[ "Optional[int]" ]
Any
def v0(self, v1: Optional[int]=None): if v1 is None: v2 = self.get('/map/get-all-geometry').json() else: v2 = self.get('/map/get-intersection-geometry', params={'id': v1}).json() v2 = v2['features'] for (v3, v4) in enumerate(v2): v5 = v4['properties'] for (v6, v7) in v5.i...
[]
[ "pandas" ]
[ "import pandas as pd" ]
16
import requests from typing import Any, Dict, List, Optional import pandas as pd class Simulation: __SECONDS_IN_A_DAY: int = 60 * 60 * 24 def __init__( self, api: str, scenario: Optional[str] = None, country_code: Optional[str] = None, city_name: Optional[str] = None...
null
v2
[ "str" ]
str
def v2(v3: str) -> str: def v4(v5): """ Return adjacent character + extra escaped double quote. """ return v5.group(1) + '\\"' return re.sub('([^\\\\])\\"', v4, v3)
[ { "name": "v0", "input_types": [ "Any" ], "output_type": "Any", "code": "def v0(v1):\n return v1.group(1) + '\\\\\"'", "dependencies": [] } ]
[ "re" ]
[ "import re" ]
6
#!/usr/bin/env python3 import os from distutils.version import LooseVersion import argparse import base64 import collections import copy import itertools import json import jsonschema import pathlib import shutil import sys import tempfile import re import zipfile dir_path = os.path.dirname(os.path.realpath(__file__)...
null
v0
[ "str" ]
Any
def v0(self, v1: str): assert os.path.isdir(v1) assert pathlib.Path(v1).parent == self.TEST_DIR assert os.path.exists(os.path.join(v1, 'dummy.txt')) assert os.path.exists(os.path.join(v1, 'folder/utf-8_sample.txt')) assert os.path.exists(v1 + '.json')
[]
[ "os", "pathlib" ]
[ "import os", "import pathlib" ]
6
from collections import Counter import os import pathlib import json import time import shutil from filelock import Timeout import pytest import responses import torch from requests.exceptions import ConnectionError, HTTPError from allennlp.common import file_utils from allennlp.common.file_utils import ( FileLoc...
null
v0
[ "Any" ]
'ApplyResult[typing.Tuple[DocumentDirectoriesRoot, int, typing.MutableMapping]]'
def v0(self, v1='Client:folder1/folder2', **v2) -> 'ApplyResult[typing.Tuple[DocumentDirectoriesRoot, int, typing.MutableMapping]]': self.apply_kwargs_defaults(kwargs=v2, return_http_data_only=False, async_req=True) v2['path'] = v1 return self.get_axioma_equity_strategy_documents_endpoint.call_with_http_inf...
[]
[]
[]
4
""" Axioma Equity API Allow clients to fetch Analytics through APIs. # noqa: E501 The version of the OpenAPI document: 3 Contact: analytics.api.support@factset.com Generated by: https://openapi-generator.tech """ import re # noqa: F401 import sys # noqa: F401 from multiprocessing.pool import ...
null
v0
[ "list" ]
bool
def v0(v1: list) -> bool: if not v1: return False for v2 in v1: if not v2.get('Time', None) or not v2.get('Character', None) or (not v2.get('Item Type', None)) or (not v2.get('Quantity', None)) or (not v2.get('Item Group', None)): return False return True
[]
[]
[]
7
from eve_module.storage import MarketManager from evelib import EVEManager, SolarSystemData, RegionData, TypeData from eve_module.loot_history import text from discord.ext import commands from datetime import datetime import logging from typing import Dict, List, Optional, Union from io import StringIO import discord #...
null
v9
[ "v0" ]
Any
def v9(self, v10: v0): if self.time_started is None or self.time_started > v10.time: self.time_started = v10.time if self.time_ended is None or self.time_ended < v10.time: self.time_ended = v10.time self.item_loot.append(v10)
[]
[]
[]
6
from eve_module.storage import MarketManager from evelib import EVEManager, SolarSystemData, RegionData, TypeData from eve_module.loot_history import text from discord.ext import commands from datetime import datetime import logging from typing import Dict, List, Optional, Union from io import StringIO import discord #...
[ "class v0:\n\n def __init__(self, v1: TypeData, v2: int, v3: datetime, v4: float):\n self.type_data = v1\n self.name: str = self.type_data.name\n self.quantity: int = v2\n self.price_per_unit: float = v4\n self.volume_per_unit: float = self.type_data.volume\n self.time: ...
v0
[ "set" ]
Any
def v0(self, v1: set): super().set_affected_address(v1) v1.add(self.multi_sig_address) for v2 in self.addrs_to: v1.add(v2)
[]
[]
[]
5
from pyxrdlib.pyxrdlib import bin2hstr from xrd.core.State import State from xrd.core.StateContainer import StateContainer from xrd.core.VoteStats import VoteStats from xrd.core.OptimizedAddressState import OptimizedAddressState from xrd.core.MultiSigAddressState import MultiSigAddressState from xrd.core.misc import l...
null
v0
[]
zipfile.ZipFile
def v0() -> zipfile.ZipFile: v1 = io.BytesIO() v2 = zipfile.ZipFile(v1, 'w') v2.writestr('a.txt', b'content of a') v2.writestr('b/c.txt', b'content of c') v2.writestr('b/d/e.txt', b'content of e') v2.writestr('b/f.txt', b'content of f') v2.writestr('g/h/i.txt', b'content of i') v2.filena...
[]
[ "io", "zipfile" ]
[ "import io", "import zipfile" ]
10
# Copyright 2022 The etils Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in wr...
null
v21
[ "np.ndarray" ]
v0
def v21(self, v22: np.ndarray) -> v0: self.mu_ = np.mean(v22, axis=0) self.cov_ = np.cov(v22, bias=False, rowvar=False) self.fitted_ = True return self
[]
[ "numpy" ]
[ "import numpy as np", "from numpy.linalg import inv, det, slogdet" ]
5
from __future__ import annotations import numpy as np from numpy.linalg import inv, det, slogdet class UnivariateGaussian: """ Class for univariate Gaussian Distribution Estimator """ def __init__(self, biased_var: bool = False) -> UnivariateGaussian: """ Estimator for univariate Gauss...
[ "class v0:\n\n def __init__(self):\n \"\"\"\n Initialize an instance of multivariate Gaussian estimator\n\n Attributes\n ----------\n fitted_ : bool\n Initialized as false indicating current estimator instance has not been fitted.\n To be set as True in `M...
v0
[ "np.ndarray" ]
float
def v0(self, v1: np.ndarray) -> float: v2 = v1.shape[0] v3 = 1 / v2 * np.sum(np.power(v1 - self.mu_, 2)) return float(v3)
[]
[ "numpy" ]
[ "import numpy as np", "from numpy.linalg import inv, det, slogdet" ]
4
from __future__ import annotations import numpy as np from numpy.linalg import inv, det, slogdet class UnivariateGaussian: """ Class for univariate Gaussian Distribution Estimator """ def __init__(self, biased_var: bool = False) -> UnivariateGaussian: """ Estimator for univariate Gauss...
null
v0
[ "np.ndarray" ]
float
def v0(self, v1: np.ndarray) -> float: v2 = v1.shape[0] return v2 / (v2 - 1) * self.estimate_biased_var(v1)
[]
[]
[]
3
from __future__ import annotations import numpy as np from numpy.linalg import inv, det, slogdet class UnivariateGaussian: """ Class for univariate Gaussian Distribution Estimator """ def __init__(self, biased_var: bool = False) -> UnivariateGaussian: """ Estimator for univariate Gauss...
null
v0
[ "np.ndarray" ]
Any
def v0(self, v1: np.ndarray): if not self.fitted_: raise ValueError('Estimator must first be fitted before calling `pdf` function') v2 = v1.shape[1] v3 = 1 / np.sqrt(np.power(2 * np.pi, v2) * np.linalg.det(self.cov_)) v4 = v1 - self.mu_ v5 = v3 * np.exp(-0.5 * np.diagonal(v4 @ np.linalg.inv(...
[]
[ "numpy" ]
[ "import numpy as np", "from numpy.linalg import inv, det, slogdet" ]
8
from __future__ import annotations import numpy as np from numpy.linalg import inv, det, slogdet class UnivariateGaussian: """ Class for univariate Gaussian Distribution Estimator """ def __init__(self, biased_var: bool = False) -> UnivariateGaussian: """ Estimator for univariate Gauss...
null
v0
[ "Sequence[int]", "np.ndarray", "Sequence[int]" ]
dict
def v0(self, v1: Sequence[int], v2: np.ndarray, v3: Sequence[int]) -> dict: v4 = {} for v5 in self.hashes: v6 = v2.copy() v7 = np.zeros(v1) for v8 in v3: if v5[v8] == '1': v6[v8] += 1 v7 = (v7 + v6[v8]).astype(int) v7 = np.take(self.tab...
[]
[ "numpy" ]
[ "import numpy as np", "from numpy.random import default_rng" ]
12
""" unit ~~~~ Unit noise classes for the pjinoise module. """ from typing import Any, List, Sequence, Tuple, Union import numpy as np from numpy.random import default_rng from pjinoise import common as c from pjinoise.constants import X, Y, Z, P from .caching import CachingMixin from .source import Source, eased #...
null
v0
[ "np.ndarray", "Sequence[int]" ]
Tuple[np.ndarray, np.ndarray]
def v0(self, v1: np.ndarray, v2: Sequence[int]) -> Tuple[np.ndarray, np.ndarray]: v3 = np.zeros(v1.shape, int) v4 = np.zeros(v1.shape, float) for v5 in v2: v1[v5] = v1[v5] / self.unit[v5] v3[v5] = v1[v5] // 1 v4[v5] = v1[v5] - v3[v5] return (v3, v4)
[]
[ "numpy" ]
[ "import numpy as np", "from numpy.random import default_rng" ]
8
""" unit ~~~~ Unit noise classes for the pjinoise module. """ from typing import Any, List, Sequence, Tuple, Union import numpy as np from numpy.random import default_rng from pjinoise import common as c from pjinoise.constants import X, Y, Z, P from .caching import CachingMixin from .source import Source, eased #...
null
v0
[ "Union[Sequence[int], str]" ]
Sequence[int]
def v0(self, v1: Union[Sequence[int], str]) -> Sequence[int]: if isinstance(v1, str): v2 = v1.split(',') v2 = [int(n) for v3 in v2[::-1]] return v2 return v1
[]
[]
[]
6
""" unit ~~~~ Unit noise classes for the pjinoise module. """ from typing import Any, List, Sequence, Tuple, Union import numpy as np from numpy.random import default_rng from pjinoise import common as c from pjinoise.constants import X, Y, Z, P from .caching import CachingMixin from .source import Source, eased #...
null
v0
[ "float", "float", "float" ]
float
def v0(self, v1: float, v2: float, v3: float) -> float: v3 = (1 - np.cos(v3 * np.pi)) / 2 return super()._lerp(v1, v2, v3)
[]
[ "numpy" ]
[ "import numpy as np", "from numpy.random import default_rng" ]
3
""" unit ~~~~ Unit noise classes for the pjinoise module. """ from typing import Any, List, Sequence, Tuple, Union import numpy as np from numpy.random import default_rng from pjinoise import common as c from pjinoise.constants import X, Y, Z, P from .caching import CachingMixin from .source import Source, eased #...
null
v0
[ "Sequence[int]", "Sequence[int]" ]
np.ndarray
def v0(self, v1: Sequence[int], v2: Sequence[int]=None) -> np.ndarray: v3 = 0 v4 = 0 for v5 in range(self.octaves): v6 = self.amplitude + self.persistence * v5 v7 = self.frequency * 2 ** v5 v8 = self.asdict() v8['unit'] = [n * v7 for v9 in self.unit] v10 = ['octaves',...
[]
[]
[]
17
""" unit ~~~~ Unit noise classes for the pjinoise module. """ from typing import Any, List, Sequence, Tuple, Union import numpy as np from numpy.random import default_rng from pjinoise import common as c from pjinoise.constants import X, Y, Z, P from .caching import CachingMixin from .source import Source, eased #...
null
v0
[ "np.ndarray" ]
Any
def v0(self, v1: np.ndarray) -> Any: assert len(v1) == self._vect_dim if self._previous_vector is None: self._previous_vector = v1 self._class_labels.append(self._default_label) else: v2 = np.append(v1, self._previous_vector) self._previous_vector = v1 v3 = self._mode...
[]
[ "numpy" ]
[ "import numpy as np" ]
12
import numpy as np import copy import pickle from typing import Tuple, Dict, List, Any from keras.models import Sequential import keras.utils class TransientKerasClassifier(): ''' Wraps a keras neural network to generate class labels for sequences of vector data. Provides functionality to train the netwo...
null
v0
[]
None
def v0(self) -> None: self._previous_vector = None self._class_labels = []
[]
[]
[]
3
import numpy as np import copy import pickle from typing import Tuple, Dict, List, Any from keras.models import Sequential import keras.utils class TransientKerasClassifier(): ''' Wraps a keras neural network to generate class labels for sequences of vector data. Provides functionality to train the netwo...
null
v0
[ "int" ]
Optional[int]
async def v0(self, v1: int) -> Optional[int]: v2 = await self.db.execute('SELECT MIN(height) from full_blocks WHERE is_fully_compactified=0 AND height>=?', (v1,)) v3 = await v2.fetchone() await v2.close() if v3 is None: return None return int(v3[0])
[]
[]
[]
7
import logging from typing import Dict, List, Optional, Tuple import aiosqlite from taco.consensus.block_record import BlockRecord from taco.types.blockchain_format.sized_bytes import bytes32 from taco.types.blockchain_format.sub_epoch_summary import SubEpochSummary from taco.types.full_block import FullBlock from ta...
null
v0
[ "List[int]", "int" ]
List[int]
def v0(v1: List[int], v2: int) -> List[int]: for (v3, v4) in enumerate(v1): v5 = v2 - v4 if v5 in v1[v3 + 1:]: return [v1.index(v4), v1[v3 + 1:].index(v5) + (v3 + 1)]
[]
[]
[]
5
from typing import List def two_sum_brute_force(nums: List[int], target: int) -> List[int]: for i in range(len(nums)): for j in range(i + 1, len(nums)): if nums[i] + nums[j] == target: return [i, j] def two_some_in(nums: List[int], target: int) -> List[int]: for i, n in en...
null
v0
[ "list", "int" ]
list
def v0(v1: list, v2: int) -> list: v3 = {} for (v4, v5) in enumerate(v1): v3[v5] = v4 for (v4, v5) in enumerate(v1): if v2 - v5 in v3 and v4 != v3[v2 - v5]: return [v4, v3[v2 - v5]] return None
[]
[]
[]
8
"""Two sum, leetcode #1""" import time def two_sum_ver1(nums: list, target: int) -> list: """Use try and except""" for i, num in enumerate(nums): try: return [nums.index(num), nums.index(target - num, i + 1)] except ValueError: continue return None def two_sum_ver2...
null
v0
[ "List[int]", "int" ]
List[int]
def v0(v1: List[int], v2: int) -> List[int]: v1.sort() (v3, v4) = (0, len(v1) - 1) while not v3 == v4: if v1[v3] + v1[v4] < v2: v3 += 1 elif v1[v3] + v1[v4] > v2: v4 += 1 else: return [v3, v4]
[]
[]
[]
10
from typing import List def two_sum_brute_force(nums: List[int], target: int) -> List[int]: for i in range(len(nums)): for j in range(i + 1, len(nums)): if nums[i] + nums[j] == target: return [i, j] def two_some_in(nums: List[int], target: int) -> List[int]: for i, n in en...
null
v0
[ "torch.Tensor" ]
str
def v0(self, v1: torch.Tensor) -> str: v2 = torch.argmax(v1, dim=-1) v2 = torch.unique_consecutive(v2, dim=-1) v3 = [] for v4 in v2: v5 = self.labels[v4] if v5 not in ['<s>', '<pad>']: v3.append(v5) return ''.join(v3)
[]
[ "torch" ]
[ "import torch" ]
9
import torch from torchaudio_unittest.common_utils import get_asset_path import pytest class GreedyCTCDecoder(torch.nn.Module): def __init__(self, labels): super().__init__() self.labels = labels def forward(self, logits: torch.Tensor) -> str: """Given a sequence logits over labels, g...
null
v0
[ "Any" ]
bool
def v0(v1) -> bool: if isinstance(v1, ABCSeries) and is_object_dtype(v1.dtype): if any((isinstance(v, ABCSeries) for v2 in v1._values)): return True return False
[]
[ "pandas" ]
[ "from pandas._libs import lib, tslib, tslibs", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, Period, Timedelta, Timestamp, conversion, iNaT, ints_to_pydatetime, ints_to_pytimedelta", "from pandas._libs.tslibs.timezones import tz_compare", "from pandas._typing import AnyArrayLike, ArrayLike, Dtype...
5
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v0
[ "Scalar", "Optional[Dtype]" ]
Scalar
def v0(v1: Scalar, v2: Optional[Dtype]=None) -> Scalar: if v2 == object: pass elif isinstance(v1, (np.datetime64, datetime)): v1 = tslibs.Timestamp(v1) elif isinstance(v1, (np.timedelta64, timedelta)): v1 = tslibs.Timedelta(v1) return v1
[]
[ "datetime", "numpy", "pandas" ]
[ "from datetime import date, datetime, timedelta", "import numpy as np", "from pandas._libs import lib, tslib, tslibs", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, Period, Timedelta, Timestamp, conversion, iNaT, ints_to_pydatetime, ints_to_pytimedelta", "from pandas._libs.tslibs.timezones impo...
8
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v2
[ "ArrayLike", "DtypeObj", "bool" ]
ArrayLike
def v2(v3: ArrayLike, v4: DtypeObj, v5: bool=False) -> ArrayLike: if not isinstance(v4, np.dtype) or not isinstance(v3.dtype, np.dtype): return v3 def v6(v7): if v5: return v7.round() return v7 if v4.kind == v3.dtype.kind: if v3.dtype.itemsize <= v4.itemsize and ...
[ { "name": "v0", "input_types": [ "Any" ], "output_type": "Any", "code": "def v0(v1):\n if do_round:\n return v1.round()\n return v1", "dependencies": [] } ]
[ "numpy", "pandas" ]
[ "import numpy as np", "from pandas._libs import lib", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, OutOfBoundsTimedelta, Timedelta, Timestamp, conversion", "from pandas._libs.tslibs.timedeltas import array_to_timedelta64", "from pandas._typing import ArrayLike, Dtype, DtypeObj, Scalar", "fro...
38
""" Routines for casting. """ from __future__ import annotations from datetime import ( date, datetime, timedelta, ) import functools from typing import ( TYPE_CHECKING, Any, Sized, TypeVar, cast, overload, ) import warnings from dateutil.parser import ParserError import numpy as ...
null
v25
[ "Any", "'Series'", "bool", "str" ]
Any
def v25(v26, v27: 'Series', v28: bool=False, v29: str=''): if v27.ndim > 1: v30 = v27._values.dtype else: v30 = v27.dtype v30 = v0(v30, v29) if not is_scalar(v26): if is_extension_array_dtype(v30) and (not is_categorical_dtype(v30)) and (v30.kind != 'M'): v31 = v30.co...
[ { "name": "v0", "input_types": [ "DtypeObj", "str" ], "output_type": "DtypeObj", "code": "def v0(v1: DtypeObj, v2: str) -> DtypeObj:\n from pandas.core.arrays.boolean import BooleanDtype\n from pandas.core.arrays.integer import Int64Dtype\n if v2 in ['add', 'cumsum', 'sum'] ...
[ "contextlib", "numpy", "pandas" ]
[ "from contextlib import suppress", "import numpy as np", "from pandas._libs import lib, tslib, tslibs", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, Period, Timedelta, Timestamp, conversion, iNaT, ints_to_pydatetime, ints_to_pytimedelta", "from pandas._libs.tslibs.timezones import tz_compare",...
13
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v17
[ "np.ndarray", "np.ndarray", "Scalar" ]
Tuple[np.ndarray, bool]
def v17(v18: np.ndarray, v19: np.ndarray, v20: Scalar) -> Tuple[np.ndarray, bool]: if not isinstance(v18, np.ndarray): raise ValueError('The result input must be a ndarray.') if not is_scalar(v20): raise ValueError('other must be a scalar') if v19.any(): if v18.dtype.kind in ['m', 'M...
[ { "name": "v0", "input_types": [ "Any", "DtypeObj" ], "output_type": "Any", "code": "def v0(v1, v2: DtypeObj):\n if is_extension_array_dtype(v2):\n return v1\n elif v2 == np.object_:\n return v1\n elif isna(v1):\n return v1\n return v2.type(v1)", ...
[ "datetime", "numpy", "pandas" ]
[ "from datetime import date, datetime, timedelta", "import numpy as np", "from pandas._libs import lib, tslib, tslibs", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, Period, Timedelta, Timestamp, conversion, iNaT, ints_to_pydatetime, ints_to_pytimedelta", "from pandas._libs.tslibs.timezones impo...
28
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v32
[ "'Index'", "Optional[np.ndarray]" ]
ArrayLike
def v32(v33: 'Index', v34: Optional[np.ndarray]=None) -> ArrayLike: v35 = v33._values if not isinstance(v33, (ABCPeriodIndex, ABCDatetimeIndex)): if v35.dtype == np.object_: v35 = lib.maybe_convert_objects(v35) if v34 is not None: v36: np.ndarray = v34 == -1 if v36.size >...
[ { "name": "v0", "input_types": [ "Any", "DtypeObj" ], "output_type": "Any", "code": "def v0(v1, v2: DtypeObj):\n if is_extension_array_dtype(v2):\n return v1\n elif v2 == np.object_:\n return v1\n elif isna(v1):\n return v1\n return v2.type(v1)", ...
[ "datetime", "numpy", "pandas" ]
[ "from datetime import date, datetime, timedelta", "import numpy as np", "from pandas._libs import lib, tslib, tslibs", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, Period, Timedelta, Timestamp, conversion, iNaT, ints_to_pydatetime, ints_to_pytimedelta", "from pandas._libs.tslibs.timezones impo...
19
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v0
[ "Any", "DtypeObj" ]
Any
def v0(v1, v2: DtypeObj): if is_extension_array_dtype(v2): return v1 elif v2 == np.object_: return v1 elif isna(v1): return v1 return v2.type(v1)
[]
[ "numpy", "pandas" ]
[ "import numpy as np", "from pandas._libs import lib, tslib, tslibs", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, Period, Timedelta, Timestamp, conversion, iNaT, ints_to_pydatetime, ints_to_pytimedelta", "from pandas._libs.tslibs.timezones import tz_compare", "from pandas._typing import AnyArr...
8
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v10
[ "Any", "bool" ]
tuple[DtypeObj, Any]
def v10(v11, v12: bool=False) -> tuple[DtypeObj, Any]: if not is_list_like(v11): return v4(v11, pandas_dtype=v12) return v0(v11, pandas_dtype=v12)
[ { "name": "v0", "input_types": [ "Any", "bool" ], "output_type": "tuple[DtypeObj, ArrayLike]", "code": "def v0(v1, v2: bool=False) -> tuple[DtypeObj, ArrayLike]:\n if isinstance(v1, np.ndarray):\n return (v1.dtype, v1)\n if not is_list_like(v1):\n raise TypeError(...
[ "datetime", "numpy", "pandas" ]
[ "from datetime import date, datetime, timedelta", "import numpy as np", "from pandas._libs import lib", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, OutOfBoundsTimedelta, Timedelta, Timestamp, conversion, ints_to_pydatetime", "from pandas._libs.tslibs.timedeltas import array_to_timedelta64", ...
4
""" Routines for casting. """ from __future__ import annotations from datetime import ( date, datetime, timedelta, ) import functools import inspect from typing import ( TYPE_CHECKING, Any, Sequence, Sized, cast, overload, ) import warnings import numpy as np from pandas._libs im...
null
v0
[ "Any", "bool" ]
Tuple[DtypeObj, ArrayLike]
def v0(v1, v2: bool=False) -> Tuple[DtypeObj, ArrayLike]: if isinstance(v1, np.ndarray): return (v1.dtype, v1) if not is_list_like(v1): raise TypeError("'arr' must be list-like") if v2 and is_extension_array_dtype(v1): return (v1.dtype, v1) elif isinstance(v1, ABCSeries): ...
[]
[ "numpy", "pandas" ]
[ "import numpy as np", "from pandas._libs import lib, missing as libmissing, tslib", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, Period, Timedelta, Timestamp, conversion, iNaT, ints_to_pydatetime", "from pandas._libs.tslibs.timezones import tz_compare", "from pandas._typing import AnyArrayLike...
14
""" Routines for casting. """ from contextlib import suppress from datetime import datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, cast, ) import warnings import numpy as np from pandas._libs i...
null
v8
[ "ArrayLike", "Scalar", "Dtype", "bool" ]
Tuple[ArrayLike, Scalar]
def v8(v9: ArrayLike, v10: Scalar=np.nan, v11: Dtype=None, v12: bool=False) -> Tuple[ArrayLike, Scalar]: if not is_scalar(v10) and (not is_object_dtype(v9.dtype)): raise ValueError('fill_value must be a scalar') if is_extension_array_dtype(v9): if v12: v9 = v9.copy() else: ...
[ { "name": "v0", "input_types": [ "Any", "DtypeObj" ], "output_type": "Any", "code": "def v0(v1, v2: DtypeObj):\n if is_extension_array_dtype(v2):\n return v1\n elif v2 == np.object_:\n return v1\n elif isna(v1):\n return v1\n return v2.type(v1)", ...
[ "datetime", "numpy", "pandas" ]
[ "from datetime import date, datetime, timedelta", "import numpy as np", "from pandas._libs import lib, tslib, tslibs", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, Period, Timedelta, Timestamp, conversion, iNaT, ints_to_pydatetime, ints_to_pytimedelta", "from pandas._libs.tslibs.timezones impo...
15
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v0
[ "Set[DtypeObj]" ]
Any
def v0(v1: Set[DtypeObj]): v2 = v1 - {np.dtype('S').type, np.dtype('<U').type} if v2 != v1: raise TypeError("string dtypes are not allowed, use 'object' instead")
[]
[ "numpy" ]
[ "import numpy as np" ]
4
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v3
[ "Sequence[Scalar]", "Sequence[Dtype]" ]
List[Scalar]
def v3(v4: Sequence[Scalar], v5: Sequence[Dtype]) -> List[Scalar]: if len(v4) != len(v5): raise AssertionError('_coerce_to_dtypes requires equal len arrays') def v6(v7, v8): if np.any(isna(v7)): pass elif v8 == DT64NS_DTYPE: v7 = Timestamp(v7) elif v8 == ...
[ { "name": "v0", "input_types": [ "Any", "Any" ], "output_type": "Any", "code": "def v0(v1, v2):\n if np.any(isna(v1)):\n pass\n elif v2 == DT64NS_DTYPE:\n v1 = Timestamp(v1)\n elif v2 == TD64NS_DTYPE:\n v1 = Timedelta(v1)\n elif v2 == np.bool_:\n ...
[ "numpy", "pandas" ]
[ "import numpy as np", "from pandas._libs import lib, tslib, tslibs", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, Period, Timedelta, Timestamp, conversion, iNaT, ints_to_pydatetime, ints_to_pytimedelta", "from pandas._libs.tslibs.timezones import tz_compare", "from pandas._typing import AnyArr...
21
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v0
[ "np.ndarray", "bool" ]
Union[np.ndarray, 'DatetimeIndex']
def v0(v1: np.ndarray, v2: bool=True) -> Union[np.ndarray, 'DatetimeIndex']: validate_bool_kwarg(v2, 'convert_numeric') v3 = v1 if is_object_dtype(v1.dtype): v1 = lib.maybe_convert_objects(v1, convert_datetime=True) if is_object_dtype(v1.dtype): v1 = lib.maybe_convert_objects(v1, convert...
[]
[ "pandas" ]
[ "from pandas._libs import lib, tslib, tslibs", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, Period, Timedelta, Timestamp, conversion, iNaT, ints_to_pydatetime, ints_to_pytimedelta", "from pandas._libs.tslibs.timezones import tz_compare", "from pandas._typing import AnyArrayLike, ArrayLike, Dtype...
21
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v0
[ "np.ndarray" ]
bool
def v0(v1: np.ndarray) -> bool: assert isinstance(v1, np.ndarray) v2 = v1.dtype.kind if v2 == 'M': return is_datetime64_ns_dtype(v1.dtype) elif v2 == 'm': return is_timedelta64_ns_dtype(v1.dtype) return v1.dtype.name not in POSSIBLY_CAST_DTYPES
[]
[ "numpy", "pandas" ]
[ "import numpy as np", "from pandas._libs import lib, tslib, tslibs", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, Period, Timedelta, Timestamp, conversion, iNaT, ints_to_pydatetime, ints_to_pytimedelta", "from pandas._libs.tslibs.timezones import tz_compare", "from pandas._typing import AnyArr...
8
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v0
[ "List[DtypeObj]" ]
DtypeObj
def v0(v1: List[DtypeObj]) -> DtypeObj: if len(v1) == 0: raise ValueError('no types given') v2 = v1[0] if all((is_dtype_equal(v2, t) for v3 in v1[1:])): return v2 v1 = list(dict.fromkeys(v1).keys()) if any((isinstance(v3, ExtensionDtype) for v3 in v1)): for v3 in v1: ...
[]
[ "numpy", "pandas" ]
[ "import numpy as np", "from pandas._libs import lib, tslib, tslibs", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, Period, Timedelta, Timestamp, conversion, iNaT, ints_to_pydatetime, ints_to_pytimedelta", "from pandas._libs.tslibs.timezones import tz_compare", "from pandas._typing import AnyArr...
24
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v6
[ "Shape", "Scalar", "Optional[DtypeObj]" ]
np.ndarray
def v6(v7: Shape, v8: Scalar, v9: Optional[DtypeObj]=None) -> np.ndarray: if v9 is None: (v9, v10) = v0(v8) else: v10 = v8 v11 = np.empty(v7, dtype=v9) v11.fill(v10) return v11
[ { "name": "v0", "input_types": [ "Any", "bool" ], "output_type": "Tuple[DtypeObj, Any]", "code": "def v0(v1, v2: bool=False) -> Tuple[DtypeObj, Any]:\n v3: DtypeObj = np.dtype(object)\n if isinstance(v1, np.ndarray):\n v4 = 'invalid ndarray passed to infer_dtype_from_sca...
[ "datetime", "numpy", "pandas" ]
[ "from datetime import date, datetime, timedelta", "import numpy as np", "from pandas._libs import lib, tslib, tslibs", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, Period, Timedelta, Timestamp, conversion, iNaT, ints_to_pydatetime, ints_to_pytimedelta", "from pandas._libs.tslibs.timezones impo...
8
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v0
[ "Scalar", "int", "DtypeObj" ]
ArrayLike
def v0(v1: Scalar, v2: int, v3: DtypeObj) -> ArrayLike: if is_extension_array_dtype(v3): v4 = v3.construct_array_type() v5 = v4._from_sequence([v1] * v2, dtype=v3) else: if v2 and is_integer_dtype(v3) and isna(v1): v3 = np.dtype('float64') elif isinstance(v3, np.dtype...
[]
[ "numpy", "pandas" ]
[ "import numpy as np", "from pandas._libs import lib, tslib, tslibs", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, Period, Timedelta, Timestamp, conversion, iNaT, ints_to_pydatetime, ints_to_pytimedelta", "from pandas._libs.tslibs.timezones import tz_compare", "from pandas._typing import AnyArr...
16
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v0
[ "Sized" ]
np.ndarray
def v0(v1: Sized) -> np.ndarray: v2 = np.empty(len(v1), dtype='object') v2[:] = v1 return v2
[]
[ "numpy" ]
[ "import numpy as np" ]
4
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v0
[ "Sequence", "Optional[DtypeObj]", "bool" ]
np.ndarray
def v0(v1: Sequence, v2: Optional[DtypeObj]=None, v3: bool=False) -> np.ndarray: if v2 is not None and v2.kind == 'U': v4 = lib.ensure_string_array(v1, convert_na_value=False, copy=v3) else: v4 = np.array(v1, dtype=v2, copy=v3) return v4
[]
[ "numpy", "pandas" ]
[ "import numpy as np", "from pandas._libs import lib, tslib, tslibs", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, Period, Timedelta, Timestamp, conversion, iNaT, ints_to_pydatetime, ints_to_pytimedelta", "from pandas._libs.tslibs.timezones import tz_compare", "from pandas._typing import AnyArr...
6
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v3
[ "Scalar", "np.dtype" ]
Scalar
def v3(v4: Scalar, v5: np.dtype) -> Scalar: if v5.kind == 'm': if isinstance(v4, (timedelta, np.timedelta64)): return Timedelta(v4).asm8.view('timedelta64[ns]') elif v4 is None or v4 is NaT or (is_float(v4) and np.isnan(v4)): return np.timedelta64('NaT', 'ns') if v5.kind ...
[ { "name": "v0", "input_types": [ "np.dtype", "Scalar" ], "output_type": "None", "code": "def v0(v1: np.dtype, v2: Scalar) -> None:\n if issubclass(v1.type, (np.integer, np.bool_)):\n if is_float(v2) and np.isnan(v2):\n raise ValueError('Cannot assign nan to integ...
[ "datetime", "numpy", "pandas" ]
[ "from datetime import date, datetime, timedelta", "import numpy as np", "from pandas._libs import lib, tslib, tslibs", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, Period, Timedelta, Timestamp, conversion, iNaT, ints_to_pydatetime, ints_to_pytimedelta", "from pandas._libs.tslibs.timezones impo...
14
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v0
[ "np.dtype", "Scalar" ]
None
def v0(v1: np.dtype, v2: Scalar) -> None: if issubclass(v1.type, (np.integer, np.bool_)): if is_float(v2) and np.isnan(v2): raise ValueError('Cannot assign nan to integer series') if issubclass(v1.type, (np.integer, np.floating, complex)) and (not issubclass(v1.type, np.bool_)): if i...
[]
[ "numpy", "pandas" ]
[ "import numpy as np", "from pandas._libs import lib, tslib, tslibs", "from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, Period, Timedelta, Timestamp, conversion, iNaT, ints_to_pydatetime, ints_to_pytimedelta", "from pandas._libs.tslibs.timezones import tz_compare", "from pandas._typing import AnyArr...
7
""" Routines for casting. """ from contextlib import suppress from datetime import date, datetime, timedelta from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Set, Sized, Tuple, Type, Union, ) import numpy as np from pandas._libs import lib, tslib, t...
null
v0
[ "'Camera'" ]
'Controller'
def v0(self, v1: 'Camera') -> 'Controller': (v2, v3, v4) = self.get_view() v1.rotation.copy(v2) v1.position.copy(v3) v1.zoom = v4 return self
[]
[]
[]
6
from typing import Tuple, Union from ..linalg import Vector3 from ..utils.viewport import Viewport from ..renderers import Renderer class Controller: """Base camera controller.""" def get_view(self): raise NotImplementedError() def handle_event(self, event, viewport, camera): raise NotI...
null
v20
[ "np.ndarray", "v0" ]
(v1, v1)
def v20(v21: np.ndarray, v22: v0) -> (v1, v1): v23 = v2(v21, v22, toLeft=True) v24 = v2(v21, v22, toLeft=False) return (v23, v24)
[ { "name": "v2", "input_types": [ "np.ndarray", "v0", "bool" ], "output_type": "v1", "code": "def v2(v3: np.ndarray, v4: v0, v5: bool) -> v1:\n if v5:\n\n def v6(v7):\n return v7 - 1 > 0\n\n def v8(v9):\n return v9 - 1\n else:\n\n ...
[]
[]
4
import numpy as np import re from collections import namedtuple, deque from typing import List compiledScanLine = re.compile(r"(.)=(\d+), (.)=(\d+)\.\.(\d+)") Coordinate = namedtuple('Coordinate', ['x', 'y']) Extent = namedtuple('Extent', ['clay', 'dropoff']) def readGrid(fileName): # Get extents minX = 1e...
[ "v0 = namedtuple('Coordinate', ['x', 'y'])", "v1 = namedtuple('Extent', ['clay', 'dropoff'])" ]
v1
[ "np.ndarray", "v0", "v0" ]
bool
def v1(v2: np.ndarray, v3: v0, v4: v0) -> bool: v5 = v3.y + 1 v6 = v3.x while v6 - 1 >= 0 and v2[v5, v6 - 1] == '.': v6 -= 1 if v6 == 0: return False v7 = v4.x v8 = len(v2[0]) while v7 + 1 < v8 and v2[v5, v7 + 1] == '.': v7 += 1 if v7 + 1 == v8: return Fal...
[]
[]
[]
20
import numpy as np import re from collections import namedtuple, deque from typing import List compiledScanLine = re.compile(r"(.)=(\d+), (.)=(\d+)\.\.(\d+)") Coordinate = namedtuple('Coordinate', ['x', 'y']) Extent = namedtuple('Extent', ['clay', 'dropoff']) def readGrid(fileName): # Get extents minX = 1e...
[ "v0 = namedtuple('Coordinate', ['x', 'y'])" ]
v0
[ "Any", "Any", "Any" ]
None
def v0(self, v1, v2, v3) -> None: assert v1 in self.proxy._owned_keys if self.proxy.check_version(v1, v2): self.proxy.inc_grad(v1[0], v1[1], v3) self.n_grads_used += 1 else: self.n_grads_discarded += 1
[]
[]
[]
7
""" PyTorch version: https://github.com/pytorch/examples/blob/master/mnist/main.py TensorFlow version: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/mnist/mnist.py """ # pip install thinc ml_datasets typer import threading from typing import Optional import time from thinc.types imp...
null
v0
[ "str", "str" ]
None
def v0(v1: str, v2: str) -> None: while v1.startswith('\n'): v1 = v1[1:] for (v3, v4) in zip(v1.split('\n'), v2.split('\n')): v3 = v3.strip() v4 = v4.strip() if not re.match(v3, v4): print(repr(v3)) print(repr(v4)) assert re.match(v3, v4)
[]
[ "re" ]
[ "import re" ]
10
import asyncio import contextlib import io import logging import pickle import re import time from typing import Generator import charmonium.time_block as ch_time_block def check_lines(expected: str, actual: str) -> None: while expected.startswith("\n"): expected = expected[1:] for expected_line, li...
null
v11
[]
None
def v11() -> None: with v1() as v12: v9(3) v4('\n > foo\\(3\\): running\n > foo\\(3\\) > bar: running\n > foo\\(3\\) > bar: 0.1s \\d+.\\d+(Ki)?B \\(gc: 0.\\d+s\\)\n > foo\\(3\\): 0.3s\n', v12.getvalue())
[ { "name": "v0", "input_types": [], "output_type": "None", "code": "@ch_time_block.decor(do_gc=True)\ndef v0() -> None:\n time.sleep(0.1)", "dependencies": [] }, { "name": "v1", "input_types": [], "output_type": "Generator[io.StringIO, None, None]", "code": "@contextlib.con...
[ "io", "logging", "re" ]
[ "import io", "import logging", "import re" ]
4
import asyncio import contextlib import io import logging import pickle import re import time from typing import Generator import charmonium.time_block as ch_time_block def check_lines(expected: str, actual: str) -> None: while expected.startswith("\n"): expected = expected[1:] for expected_line, li...
null
v11
[]
None
def v11() -> None: with v3() as v12: v13 = asyncio.get_event_loop() v13.run_until_complete(asyncio.gather(v2(), v0())) v13.close() v6('\n > afoo: running\n > abar: running\n > abar > abaz: running\n > abar > abaz: 0.1s\n > abar: 0.2s\n > afoo: 0.3s\n', v12.getvalue())
[ { "name": "v0", "input_types": [], "output_type": "int", "code": "async def v0() -> int:\n await asyncio.sleep(0.02)\n with ch_time_block.ctx('abar'):\n await asyncio.sleep(0.1)\n 1 + await abaz()\n return 1", "dependencies": [ "v1" ] }, { "name": "v1", ...
[ "asyncio", "io", "logging", "re" ]
[ "import asyncio", "import io", "import logging", "import re" ]
6
import asyncio import contextlib import io import logging import pickle import re import time from typing import Generator import charmonium.time_block as ch_time_block def check_lines(expected: str, actual: str) -> None: while expected.startswith("\n"): expected = expected[1:] for expected_line, li...
null
v0
[ "'Series'", "Any" ]
Any
def v0(self, v1: 'Series', v2): if not is_scalar(v2): raise InvalidIndexError v3 = self.get_loc(v2) if not is_scalar(v3): return v1.iloc[v3] v4 = v1._values[v3] return v4
[]
[ "pandas" ]
[ "from pandas._libs import index as libindex, lib", "from pandas._typing import Dtype", "from pandas.util._decorators import Appender, cache_readonly", "from pandas.core.dtypes.cast import astype_nansafe", "from pandas.core.dtypes.common import is_bool, is_bool_dtype, is_dtype_equal, is_extension_array_dtype...
8
from typing import TYPE_CHECKING, Any import numpy as np from pandas._libs import index as libindex, lib from pandas._typing import Dtype from pandas.util._decorators import Appender, cache_readonly from pandas.core.dtypes.cast import astype_nansafe from pandas.core.dtypes.common import ( is_bool, is_bool_dt...
null
v0
[ "Callable", "str" ]
List
def v0(v1: Callable, v2: str, **v3) -> List: v4 = [] v5 = v1(limit=500, **v3) v4.extend(v5[v2]) v6 = v5['response_metadata'].get('next_cursor') while v6: v5 = v1(limit=500, cursor=v6, **v3) v4.extend(v5[v2]) v6 = v5['response_metadata'].get('next_cursor') return v4
[]
[]
[]
10
import logging from typing import Callable, Dict, List import asyncio from slack.web.client import WebClient from slack.rtm.client import RTMClient from machine.models import User from machine.models import Channel from machine.settings import import_settings from machine.utils import Singleton logger = logging.getL...
null
v0
[ "dict" ]
Any
def v0(v1: dict): if 'cfgpull' not in v1: return 0 elif 'version' not in v1['cfgpull']: return 0 return v1['cfgpull']['version']
[]
[]
[]
6
import struct import random def get_esp_image_description(image_data: bytes): """ Attempt to determine the version information for a given esp binary image. Returns (project_version, project_name) or raises a ValueError """ magic, num_segments = struct.unpack_from("<BB", image_data, 0) if mag...
null
v0
[ "dict" ]
Any
def v0(v1: dict): if 'cfgpull' not in v1: v1['cfgpull'] = {} v1['cfgpull']['version'] = random.randint(0, 2147483647)
[]
[ "random" ]
[ "import random" ]
4
import struct import random def get_esp_image_description(image_data: bytes): """ Attempt to determine the version information for a given esp binary image. Returns (project_version, project_name) or raises a ValueError """ magic, num_segments = struct.unpack_from("<BB", image_data, 0) if mag...
null
v0
[ "float" ]
AsyncGenerator[float, None]
async def v0(v1: float=0.5) -> AsyncGenerator[float, None]: v2 = asyncio.get_event_loop() v3 = v2.time() while True: v4 = v2.time() yield (v4 - v3) v5 = v2.time() v6 = max([0, v1 - v5 + v4]) await asyncio.sleep(v6)
[]
[ "asyncio" ]
[ "import asyncio" ]
9
import asyncio import time from datetime import datetime, timedelta from typing import Any, AsyncGenerator, Dict, Sequence, Union from tortoise import timezone def to_ms_timestamp(value: Union[None, int, float, timedelta, datetime]): """ covert to timestamp :param value: :return: """ if isins...
null
v0
[ "Sequence[Any]", "Dict[str, Any]" ]
str
def v0(v1: Sequence[Any], v2: Dict[str, Any]) -> str: v3 = '' if v1: v3 = ', '.join(map(repr, v1)) if v2: if v3: v3 += ', ' v3 += ', '.join((f'{k}={v!r}' for (v4, v5) in sorted(v2.items()))) return v3
[]
[]
[]
9
import asyncio import time from datetime import datetime, timedelta from typing import Any, AsyncGenerator, Dict, Sequence, Union from tortoise import timezone def to_ms_timestamp(value: Union[None, int, float, timedelta, datetime]): """ covert to timestamp :param value: :return: """ if isins...
null
v0
[]
'io.BufferedWriter'
def v0(self) -> 'io.BufferedWriter': if self.compress_level > 0: return gzip.open(self.index_abspath, 'ab', compresslevel=self.compress_level) else: return open(self.index_abspath, 'ab')
[]
[ "gzip" ]
[ "import gzip" ]
5
__copyright__ = "Copyright (c) 2020 Jina AI Limited. All rights reserved." __license__ = "Apache-2.0" import gzip import io import os from functools import lru_cache from os import path from typing import Optional, Iterable, Tuple, Dict import numpy as np from . import BaseVectorIndexer from ..decorators import batc...
null
v0
[ "Iterable[str]", "'np.ndarray'" ]
None
def v0(self, v1: Iterable[str], v2: 'np.ndarray', *v3, **v4) -> None: v5 = np.array(v1, (np.str_, self.key_length)) self._add(v5, v2)
[]
[ "numpy" ]
[ "import numpy as np" ]
3
__copyright__ = "Copyright (c) 2020 Jina AI Limited. All rights reserved." __license__ = "Apache-2.0" import gzip import io import os from functools import lru_cache from os import path from typing import Optional, Iterable, Tuple, Dict import numpy as np from . import BaseVectorIndexer from ..decorators import batc...
null
v0
[ "'np.ndarray'", "'np.ndarray'" ]
Any
def v0(self, v1: 'np.ndarray', v2: 'np.ndarray'): self._validate_key_vector_shapes(v1, v2) if 'default' in self.write_handler.array_keys(): self.write_handler['default'].append(data=v2) else: self.write_handler.array(name='default', data=v2) self.valid_indices = np.concatenate((self.vali...
[]
[ "numpy" ]
[ "import numpy as np" ]
9
from os import path from typing import Optional, Iterable import numpy as np from jina.executors.decorators import as_update_method from jina.executors.indexers.vector import NumpyIndexer from jina.helper import cached_property if False: import zarr class ZarrIndexer(NumpyIndexer): """ Indexing based o...
null
v0
[ "Iterable[str]", "'np.ndarray'" ]
None
def v0(self, v1: Iterable[str], v2: 'np.ndarray', *v3, **v4) -> None: if self.size: (v1, v5) = self._filter_nonexistent_keys_values(v1, v2, self._ext2int_id.keys()) if v1: v6 = np.array(v1, (np.str_, self.key_length)) self._delete(v6) self._add(v6, np.array(v5)) ...
[]
[ "numpy" ]
[ "import numpy as np" ]
9
__copyright__ = "Copyright (c) 2020 Jina AI Limited. All rights reserved." __license__ = "Apache-2.0" import gzip import io import os from functools import lru_cache from os import path from typing import Optional, Iterable, Tuple, Dict import numpy as np from . import BaseVectorIndexer from ..decorators import batc...
null
v0
[ "Iterable[str]" ]
None
def v0(self, v1: Iterable[str], *v2, **v3) -> None: if self.size: v1 = self._filter_nonexistent_keys(v1, self._ext2int_id.keys()) if v1: v4 = np.array(v1, (np.str_, self.key_length)) self._delete(v4) else: self.logger.error(f'{self!r} is empty, deletion is aborted...
[]
[ "numpy" ]
[ "import numpy as np" ]
8
__copyright__ = "Copyright (c) 2020 Jina AI Limited. All rights reserved." __license__ = "Apache-2.0" import gzip import io import os from functools import lru_cache from os import path from typing import Optional, Iterable, Tuple, Dict import numpy as np from . import BaseVectorIndexer from ..decorators import batc...
null
v0
[]
Optional['np.ndarray']
def v0(self) -> Optional['np.ndarray']: if np.all(self.valid_indices): v1 = self._raw_ndarray else: v1 = self._raw_ndarray[self.valid_indices] if v1 is not None: return self.build_advanced_index(v1)
[]
[ "numpy" ]
[ "import numpy as np" ]
7
__copyright__ = "Copyright (c) 2020 Jina AI Limited. All rights reserved." __license__ = "Apache-2.0" import gzip import io import os from functools import lru_cache from os import path from typing import Optional, Iterable, Tuple, Dict import numpy as np from . import BaseVectorIndexer from ..decorators import batc...
null
v0
[ "str", "Any" ]
Optional['np.ndarray']
def v0(self, v1: str, v2='rb') -> Optional['np.ndarray']: try: self.logger.info(f'loading index from {v1}...') with gzip.open(v1, v2) as v3: return np.frombuffer(v3.read(), dtype=self.dtype).reshape([-1, self.num_dim]) except EOFError: self.logger.error(f'{v1} is broken/incom...
[]
[ "gzip", "numpy" ]
[ "import gzip", "import numpy as np" ]
7
__copyright__ = "Copyright (c) 2020 Jina AI Limited. All rights reserved." __license__ = "Apache-2.0" import gzip import io import os from functools import lru_cache from os import path from typing import Optional, Iterable, Tuple, Dict import numpy as np from . import BaseVectorIndexer from ..decorators import batc...
null
v0
[ "Iterable[str]" ]
Optional['np.ndarray']
def v0(self, v1: Iterable[str], *v2, **v3) -> Optional['np.ndarray']: v1 = self._filter_nonexistent_keys(v1, self._ext2int_id.keys()) if v1: v4 = [self._ext2int_id[key] for v5 in v1] return self._raw_ndarray[v4] else: return None
[]
[]
[]
7
__copyright__ = "Copyright (c) 2020 Jina AI Limited. All rights reserved." __license__ = "Apache-2.0" import gzip import io import os from functools import lru_cache from os import path from typing import Optional, Iterable, Tuple, Dict import numpy as np from . import BaseVectorIndexer from ..decorators import batc...
null
v10
[ "'np.ndarray'", "int" ]
Tuple[Optional['np.ndarray'], Optional['np.ndarray']]
def v10(self, v11: 'np.ndarray', v12: int, *v13, **v14) -> Tuple[Optional['np.ndarray'], Optional['np.ndarray']]: if self.size == 0: return (None, None) if self.metric not in {'cosine', 'euclidean'} or self.backend == 'scipy': v15 = self._cdist(v11, self.query_handler) elif self.metric == 'e...
[ { "name": "v0", "input_types": [ "Any" ], "output_type": "Any", "code": "def v0(v1):\n (v2, v3) = v1.shape\n v4 = _get_ones(v2, v3 * 3)\n v4[:, v3:2 * v3] = v1\n v4[:, 2 * v3:] = v1 ** 2\n return v4", "dependencies": [ "v5" ] }, { "name": "v5", "inp...
[ "numpy" ]
[ "import numpy as np" ]
16
__copyright__ = "Copyright (c) 2020 Jina AI Limited. All rights reserved." __license__ = "Apache-2.0" import gzip import os from functools import lru_cache from os import path from typing import Optional, List, Union, Tuple, Dict, Sequence import numpy as np from . import BaseVectorIndexer from ..decorators import b...
null
v0
[ "xr.DataArray" ]
pd.DataFrame
def v0(v1: xr.DataArray) -> pd.DataFrame: if v1.ndim > 2: v2 = v1.to_series().unstack().T v2.columns = ['_'.join(col).strip() for v3 in v2.columns] return v2 return v1.to_series().unstack().T
[]
[]
[]
6
from pathlib import Path from typing import Union, Optional import pandas as pd import xarray as xr from scipy.io import savemat def to_wide_dataframe(array: xr.DataArray) -> pd.DataFrame: if array.ndim > 2: df = array.to_series().unstack().T df.columns = ["_".join(col).strip() for col in df.colu...
null
v0
[ "xr.DataArray", "Union[str, Path]", "Optional[bool]" ]
Any
def v0(v1: xr.DataArray, v2: Union[str, Path], v3: Optional[bool]=True): if v3: v1.meca.to_wide_dataframe().to_csv(v2) else: v1.to_dataframe().to_csv(v2)
[]
[]
[]
5
from pathlib import Path from typing import Union, Optional import pandas as pd import xarray as xr from scipy.io import savemat def to_wide_dataframe(array: xr.DataArray) -> pd.DataFrame: if array.ndim > 2: df = array.to_series().unstack().T df.columns = ["_".join(col).strip() for col in df.colu...
null
v0
[ "dict" ]
str
def v0(self, v1: dict) -> str: v2 = [] for (v3, v4) in dict(v1).items(): if not v4: continue v5 = self.d.emojis.badges[v3] if isinstance(v5, list): v2.append(v5[v4 - 1]) else: v2.append(v5) return ' '.join(v2)
[]
[]
[]
11
from discord.ext import commands from typing import List import asyncpg from util.misc import calc_total_wealth class Badges(commands.Cog): def __init__(self, bot): self.bot = bot self.db = bot.get_cog("Database") self.d = bot.d # self.badges = {} # {user_id: {badge: value}} ...
null
v0
[ "int", "List[asyncpg.Record]" ]
None
async def v0(self, v1: int, v2: List[asyncpg.Record]=None) -> None: v3 = await self.fetch_user_badges(v1) v4 = v3['collector'] if v4 == 5: return if v2 is None: v2 = await self.db.fetch_items(v1) v5 = len(v2) if v4 < 5 and v5 >= 256: await self.update_user_badges(v1, coll...
[]
[]
[]
18
from discord.ext import commands from typing import List import asyncpg from util.misc import calc_total_wealth class Badges(commands.Cog): def __init__(self, bot): self.bot = bot self.db = bot.get_cog("Database") self.d = bot.d # self.badges = {} # {user_id: {badge: value}} ...
null
v0
[ "int", "int" ]
None
async def v0(self, v1: int, v2: int=None) -> None: v3 = await self.fetch_user_badges(v1) v4 = v3['beekeeper'] if v4 == 3: return if v2 is None: v2 = await self.db.fetch_item(v1, 'Jar Of Bees') if v2 is None: v2 = 0 else: v2 = v2['amount'] if v4...
[]
[]
[]
17
from discord.ext import commands from typing import List import asyncpg from util.misc import calc_total_wealth class Badges(commands.Cog): def __init__(self, bot): self.bot = bot self.db = bot.get_cog("Database") self.d = bot.d # self.badges = {} # {user_id: {badge: value}} ...
null
v0
[ "int", "int" ]
None
async def v0(self, v1: int, v2: int) -> None: v3 = await self.fetch_user_badges(v1) v4 = v3['pillager'] if v4 == 3: return if v4 < 3 and v2 >= 100000: await self.update_user_badges(v1, pillager=3) elif v4 < 2 and v2 >= 1000: await self.update_user_badges(v1, pillager=2) e...
[]
[]
[]
11
from discord.ext import commands from typing import List import asyncpg from util.misc import calc_total_wealth class Badges(commands.Cog): def __init__(self, bot): self.bot = bot self.db = bot.get_cog("Database") self.d = bot.d # self.badges = {} # {user_id: {badge: value}} ...
null
v0
[ "int", "int" ]
None
async def v0(self, v1: int, v2: int) -> None: v3 = await self.fetch_user_badges(v1) v4 = v3['fisherman'] if v4 == 4: return if v4 < 4 and v2 >= 20000: await self.update_user_badges(v1, fisherman=4) elif v4 < 3 and v2 >= 10000: await self.update_user_badges(v1, fisherman=3) ...
[]
[]
[]
13
from discord.ext import commands from typing import List import asyncpg from util.misc import calc_total_wealth class Badges(commands.Cog): def __init__(self, bot): self.bot = bot self.db = bot.get_cog("Database") self.d = bot.d # self.badges = {} # {user_id: {badge: value}} ...
null
v0
[ "Union[torch.Tensor, float]" ]
Any
def v0(self, v1: Union[torch.Tensor, float]): if not torch.is_tensor(v1): v1 = torch.as_tensor(v1).to(self.raw_mixture_scales) self.initialize(raw_mixture_scales=self.raw_mixture_scales_constraint.inverse_transform(v1))
[]
[ "torch" ]
[ "import torch" ]
4
#!/usr/bin/env python3 import logging import math from typing import Optional, Tuple, Union import torch from ..constraints import Interval, Positive from ..priors import Prior from .kernel import Kernel logger = logging.getLogger() class SpectralMixtureKernel(Kernel): r""" Computes a covariance matrix ba...
null
v0
[ "List[str]" ]
Tuple[str, str]
def v0(v1: List[str]) -> Tuple[str, str]: v2 = tempfile.mkdtemp() v3 = '%s%sinput.txt' % (v2, os.path.sep) with open(v3, 'w') as v4: v4.writelines(v1) v5 = '%s%soutput' % (v2, os.path.sep) return (v3, v5)
[]
[ "os", "tempfile" ]
[ "import os", "import tempfile" ]
7
import os import tempfile from typing import Tuple, List from pyspark.sql import SparkSession from data_transformations import word_count SPARK = SparkSession.builder.appName("Tests").getOrCreate() def _get_file_paths(input_file_lines: List[str]) -> Tuple[str, str]: base_path = tempfile.mkdtemp() input_te...
null
v0
[ "list[float]" ]
float
def v0(self, v1: list[float]) -> float: (v2, v3) = v1 return (v3 * self.f(v2) - v2 * self.f(v3)) / (self.f(v2) - self.f(v3))
[]
[]
[]
3
#!/usr/bin/env python3 from typing import Callable from abc import ABC, abstractmethod from IPython.display import HTML, display class RootDoesNotExit(Exception): """Exception to be raised when root does not exist for the given set of values""" class TranscendentalEq(ABC): """Abstract Base class to represen...
null
v4
[]
Callable[[list[float]], tuple[float, float]]
def v4(self) -> Callable[[list[float]], tuple[float, float]]: def v5(v6: list[float]) -> tuple[float, float]: v7 = self.getNextX(v6) v8 = self.f(v7) self.table.append([*v6, v7, v8]) return (v7, v8) return v5
[ { "name": "v0", "input_types": [ "list[float]" ], "output_type": "tuple[float, float]", "code": "def v0(v1: list[float]) -> tuple[float, float]:\n v2 = self.getNextX(v1)\n v3 = self.f(v2)\n self.table.append([*v1, v2, v3])\n return (v2, v3)", "dependencies": [] } ]
[]
[]
8
#!/usr/bin/env python3 from typing import Callable from abc import ABC, abstractmethod from IPython.display import HTML, display class RootDoesNotExit(Exception): """Exception to be raised when root does not exist for the given set of values""" class TranscendentalEq(ABC): """Abstract Base class to represen...
null
v0
[ "float", "float", "float", "int" ]
float
def v0(self, v1: float, v2: float, v3: float, v4: int=100) -> float: self.table = [] v5 = self.deco() for v6 in range(v4): (v7, v8) = v5([v1, v2]) if abs(v8) <= v3: break else: (v1, v2) = (v2, v7) self.__display__() return v7
[]
[]
[]
11
#!/usr/bin/env python3 from typing import Callable from abc import ABC, abstractmethod from IPython.display import HTML, display class RootDoesNotExit(Exception): """Exception to be raised when root does not exist for the given set of values""" class TranscendentalEq(ABC): """Abstract Base class to represen...
null
v0
[ "list[float]" ]
tuple[float, float]
def v0(v1: list[float]) -> tuple[float, float]: v2 = self.getNextX(v1) v3 = self.f(v2) self.table.append([*v1, v2, v3]) return (v2, v3)
[]
[]
[]
5
#!/usr/bin/env python3 from typing import Callable from abc import ABC, abstractmethod from IPython.display import HTML, display class RootDoesNotExit(Exception): """Exception to be raised when root does not exist for the given set of values""" class TranscendentalEq(ABC): """Abstract Base class to represen...
null
v0
[ "List[int]" ]
int
def v0(self, v1: List[int]) -> int: v2 = float('-inf') for v3 in range(len(v1)): for v4 in range(v3 + 1, len(v1)): if v1[v4] - v1[v3] > v2: v2 = v1[v4] - v1[v3] return v2 if v2 > 0 else 0
[]
[]
[]
7
# https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ # Related Topics: Array, Dynamic Programming # Difficulty: Easy # Initial thoughts: # The brute force approach is to create a nested loop and check each pair of elements in the input array # searching for the maximum profit # Time complexity: O(n^2)...
null
v0
[ "List[int]" ]
int
def v0(self, v1: List[int]) -> int: if not len(v1): return 0 v2 = float('-inf') v3 = v1[0] for v4 in range(1, len(v1)): v2 = max(v2, v1[v4] - v3) v3 = min(v3, v1[v4]) return v2 if v2 > 0 else 0
[]
[]
[]
9
# https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ # Related Topics: Array, Dynamic Programming # Difficulty: Easy # Initial thoughts: # The brute force approach is to create a nested loop and check each pair of elements in the input array # searching for the maximum profit # Time complexity: O(n^2)...
null
v0
[ "List[int]" ]
int
def v0(self, v1: List[int]) -> int: (v2, v3) = (0, float('inf')) for v4 in v1: v2 = max(v2, v4 - v3) v3 = min(v3, v4) return v2
[]
[]
[]
6
# https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ # Related Topics: Array, Dynamic Programming # Difficulty: Easy # Initial thoughts: # The brute force approach is to create a nested loop and check each pair of elements in the input array # searching for the maximum profit # Time complexity: O(n^2)...
null
v0
[ "Type" ]
str
def v0(v1: Type) -> str: if sys.version_info < (3, 7): v2 = v1.__origin__.__name__ else: v2 = v1._name v3 = v1.__args__ return f"{v2}[{','.join((arg.__name__ for v4 in v3))}]"
[]
[ "sys" ]
[ "import sys" ]
7
from collections import defaultdict from typing import Any, Callable, Dict, List, Set, Tuple, Type, Union import inspect import logging import sys import traceback import types from nltk import Tree from allennlp.common.util import START_SYMBOL from allennlp.semparse import util logger = logging.getLogger(__name__) ...
null
v0
[ "Callable" ]
Callable
def v0(v1: Callable) -> Callable: setattr(v1, '_is_predicate', True) return v1
[]
[]
[]
3
from collections import defaultdict from typing import Any, Callable, Dict, List, Set, Tuple, Type, Union import inspect import logging import sys import traceback import types from nltk import Tree from allennlp.common.util import START_SYMBOL from allennlp.semparse import util logger = logging.getLogger(__name__) ...
null
v4
[ "List[str]" ]
Callable
def v4(v5: List[str]) -> Callable: def v6(v7: Callable) -> Callable: setattr(v7, '_side_arguments', v5) return v2(v7) return v6
[ { "name": "v0", "input_types": [ "Callable" ], "output_type": "Callable", "code": "def v0(v1: Callable) -> Callable:\n setattr(v1, '_side_arguments', side_arguments)\n return predicate(v1)", "dependencies": [ "v2" ] }, { "name": "v2", "input_types": [ ...
[]
[]
6
from collections import defaultdict from typing import Any, Callable, Dict, List, Set, Tuple, Type, Union import inspect import logging import sys import traceback import types from nltk import Tree from allennlp.common.util import START_SYMBOL from allennlp.semparse import util logger = logging.getLogger(__name__) ...
null
v0
[]
List[str]
def v0(self) -> List[str]: v1 = set() for v2 in self.get_nonterminal_productions().values(): v1.update(v2) return sorted(v1)
[]
[]
[]
5
from collections import defaultdict from typing import Any, Callable, Dict, List, Set, Tuple, Type, Union import inspect import logging import sys import traceback import types from nltk import Tree from allennlp.common.util import START_SYMBOL from allennlp.semparse import util logger = logging.getLogger(__name__) ...
null
v0
[ "str" ]
bool
def v0(self, v1: str) -> bool: v2 = self.get_nonterminal_productions() return v1 in v2
[]
[]
[]
3
from collections import defaultdict from typing import Any, Callable, Dict, List, Set, Tuple, Type, Union import inspect import logging import sys import traceback import types from nltk import Tree from allennlp.common.util import START_SYMBOL from allennlp.semparse import util logger = logging.getLogger(__name__) ...
null
v2
[ "List[str]", "List[Dict]" ]
Tuple[Any, List[str], List[Dict]]
def v2(self, v3: List[str], v4: List[Dict]) -> Tuple[Any, List[str], List[Dict]]: v5 = v3[0] v6 = v3[1:] v7 = v4[1:] if v4 else None v8 = v5.split(' -> ')[1] if v8 in self._functions: v9 = self._functions[v8] if isinstance(v9, Callable): v10 = inspect.signature(v9).parame...
[ { "name": "v0", "input_types": [], "output_type": "Any", "code": "def v0(*v1):\n return function(*v1, **kwargs)", "dependencies": [] } ]
[ "inspect", "typing" ]
[ "from typing import Any, Callable, Dict, List, Set, Tuple, Type, Union", "import inspect" ]
39
from collections import defaultdict from typing import Any, Callable, Dict, List, Set, Tuple, Type, Union import inspect import logging import sys import traceback import types from nltk import Tree from allennlp.common.util import START_SYMBOL from allennlp.semparse import util logger = logging.getLogger(__name__) ...
null
v7
[ "str", "str" ]
str
def v7(v8: str, v9: str) -> str: (v10, v11) = os.path.splitext(v9) v8 = v8.split('\\quartz\\') v8 = v8[1] if v11 != '.md': v10 += v11 else: v12 = v8 + v10 + '.md' return v0(v8, v10)
[ { "name": "v0", "input_types": [ "str", "str" ], "output_type": "str", "code": "def v0(v1: str, v2: str) -> str:\n v3 = v1\n if len(v3) > 0:\n v3 += '/'\n v4 = f'({v3}{v2})'\n v5 = v4.replace(' ', '%20').replace('\\\\', '/')\n v5 = v5.replace('%20%20', ' ')\n ...
[ "os" ]
[ "import os" ]
9
from fileinput import filename import os # 🚨 def get_all_file_for_moc(moc_directory): output = '' files = [] # print("###"+moc_directory) for file in os.listdir(moc_directory): # print(files) f = os.path.join(moc_directory, file) if os.path.isfile(f): forbidden_fi...
null
v0
[ "str", "str" ]
str
def v0(v1: str, v2: str) -> str: v3 = v1 if len(v3) > 0: v3 += '/' v4 = f'({v3}{v2})' v5 = v4.replace(' ', '%20').replace('\\', '/') v5 = v5.replace('%20%20', ' ') v2 = v2.split('\\')[0] v6 = f'- [{v2}]{v5}\n' return v6
[]
[]
[]
10
from fileinput import filename import os # 🚨 def get_all_file_for_moc(moc_directory): output = '' files = [] # print("###"+moc_directory) for file in os.listdir(moc_directory): # print(files) f = os.path.join(moc_directory, file) if os.path.isfile(f): forbidden_fi...
null
v14
[ "Any", "Optional[str]", "Any", "Any" ]
Any
def v14(v15, v16: Optional[str]=None, v17=True, v18='png', *v19, **v20): if v15.need_sync: v15.sync_template() v21 = v15.template v22 = v11(v8(img_type=v18)) return v0(v22, v21, v16, v17, *v19, **v20)
[ { "name": "v0", "input_types": [ "Any", "Any", "Optional[str]", "Any" ], "output_type": "Any", "code": "def v0(v1, v2, v3: Optional[str]=None, v4=True, *v5, **v6):\n if v3 is not None:\n v1.drawIntoFile(v2, os.path.abspath(v3))\n return\n v7 = v1.drawI...
[ "os" ]
[ "import os" ]
6
import os from typing import Optional from neuralogic import get_neuralogic from neuralogic.core.settings import Settings, SettingsProxy from py4j.java_gateway import set_field def get_drawing_settings(img_type: str = "png") -> SettingsProxy: """Returns the default settings instance for drawing with a specified...
null
v9
[ "Any" ]
str
def v9(v10) -> str: if v10.need_sync: v10.sync_template() v11 = v10.template v12 = v3(v0()) return v6(v12, v11)
[ { "name": "v0", "input_types": [ "str" ], "output_type": "SettingsProxy", "code": "def v0(v1: str='png') -> SettingsProxy:\n v2 = Settings().create_proxy()\n set_field(v2.settings, 'drawing', False)\n set_field(v2.settings, 'storeNotShow', True)\n set_field(v2.settings, 'imgTyp...
[]
[]
6
import os from typing import Optional from neuralogic import get_neuralogic from neuralogic.core.settings import Settings, SettingsProxy from py4j.java_gateway import set_field def get_drawing_settings(img_type: str = "png") -> SettingsProxy: """Returns the default settings instance for drawing with a specified...
null
v9
[ "Any" ]
str
def v9(v10) -> str: v11 = v3(v0()) return v6(v11, v10)
[ { "name": "v0", "input_types": [ "str" ], "output_type": "SettingsProxy", "code": "def v0(v1: str='png') -> SettingsProxy:\n v2 = Settings().create_proxy()\n set_field(v2.settings, 'drawing', False)\n set_field(v2.settings, 'storeNotShow', True)\n set_field(v2.settings, 'imgTyp...
[]
[]
3
import os from typing import Optional from neuralogic import get_neuralogic from neuralogic.core.settings import Settings, SettingsProxy from py4j.java_gateway import set_field def get_drawing_settings(img_type: str = "png") -> SettingsProxy: """Returns the default settings instance for drawing with a specified...
null
v0
[ "str", "str" ]
None
def v0(v1: str, v2: str) -> None: for (v3, v4, v5) in os.walk(v1): v6 = os.path.relpath(v3, v1) for v7 in v5: v8 = os.path.join(v3, v7) v9 = os.path.normpath(os.path.join(v2, v6, v7)) print(v8, '->', v9) shutil.copy(v8, v9)
[]
[ "os", "shutil" ]
[ "import os", "import shutil" ]
8
# -*- coding: utf-8 -*- # Copyright (c) 2020 Nekokatt # # 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, me...
null
v0
[ "Union[sp.CompletedProcess, Tuple[str, str]]" ]
Any
def v0(v1: Union[sp.CompletedProcess, Tuple[str, str]]): if isinstance(v1, tuple): (v2, v3) = v1 else: v1.terminate() v1.kill() try: (v2, v3) = v1.communicate(timeout=10) except sp.TimeoutExpired: return None if v2: print(v2) if v3:...
[]
[ "subprocess" ]
[ "import subprocess as sp" ]
15
#!/usr/bin/env python3 # Copyright 2019-2021 ETH Zurich and the DaCe authors. All rights reserved. import click from datetime import datetime import multiprocessing as mp from multiprocessing import pool as mpool from pathlib import Path import re import subprocess as sp import sys from typing import Union, Tuple TEST...
null
v0
[ "cirq.Operation" ]
cirq.Duration
def v0(self, v1: cirq.Operation) -> cirq.Duration: v2 = self._find_operation_type(v1) if v2 is None: raise ValueError(f'Operation {v1} does not have a known duration') return v2.duration
[]
[]
[]
5
# Copyright 2019 The Cirq Developers # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in ...
null
v0
[ "'cirq.Operation'" ]
None
def v0(self, v1: 'cirq.Operation') -> None: for v2 in v1.qubits: if v2 not in self.qubits: raise ValueError('Qubit not on device: {!r}'.format(v2)) v3 = self._find_operation_type(v1) if v3 is None: raise ValueError(f'{v1} is not a supported gate') v4 = v3.number_of_qubits ...
[]
[]
[]
23
# Copyright 2019 The Cirq Developers # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in ...
null
v0
[ "Path", "str" ]
(List, int)
def v0(v1: Path, v2: str) -> (List, int): if not v1.is_dir(): raise ValueError(f'Not a directory: {v1}') v3 = sorted(v1.glob('*' + v2)) v4 = len(v3) if v4 == 0: raise ValueError(f"No files found matching '{v2}' in dir '{v1}'") return (v3, v4)
[]
[]
[]
8
import concurrent.futures import itertools import json import logging import math import random from dataclasses import dataclass from pathlib import Path from typing import List, Dict import cv2 import hydra import jsonlines import numpy as np from omegaconf import OmegaConf, DictConfig from scipy.spatial.transform i...
null