query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
isPrime(n, [s = 50]) > boolean isPrime uses the Miller Rabin primality test for efficient testing of the primality of n. Optional argument s is number of test iterations. Before beginning the Miller Rabin test, isPrime tests if any known prime < 20000 can factor n. | def isPrime(n, s=50):
from random import randrange
for x in primes:
if x < n:
if n % x == 0:
return False
for j in range(1, s + 1):
a = randrange(1, n)
if witness(a, n):
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isPrime(n, primes):\n\n k = math.log(n, 2) # number of bits in n\n r = getRounds(k)\n\n return checks(n, primes, r) # run checks",
"def basicIsPrime(n,K=100):\n if n % 2 == 0:\n return n == 2\n if n in primesList.lessThanHundredThousand:\n ... | [
"0.75833243",
"0.75059754",
"0.7438362",
"0.74137187",
"0.74054563",
"0.7376554",
"0.7366905",
"0.7339588",
"0.7255724",
"0.7255181",
"0.72468954",
"0.7245205",
"0.7239938",
"0.7239603",
"0.72300446",
"0.7228178",
"0.7224438",
"0.7208048",
"0.72071564",
"0.7177317",
"0.717193... | 0.8323775 | 0 |
Returns the value to which the specified key is mapped, or 1 if this map contains no mapping for the key | def get(self, key: int) -> int:
if key < self.len:
return self._map[key]
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, key: int) -> int:\n if key not in self.map:\n return -1\n return self.map[key]",
"def get(self, key: int) -> int:\n if key in self.hashmap.keys():return self.hashmap[key]\n else:return -1",
"def get(self, key: int) -> int:\n sh = key % 37\n if ... | [
"0.800388",
"0.79098475",
"0.762993",
"0.75650334",
"0.7556994",
"0.7529803",
"0.7493149",
"0.73738897",
"0.7294419",
"0.72940016",
"0.72216845",
"0.72175443",
"0.7181078",
"0.71774393",
"0.71633786",
"0.6980779",
"0.69289523",
"0.67850846",
"0.6757027",
"0.6734023",
"0.66126... | 0.75259614 | 6 |
Provisioning status of the origin group. | def provisioning_state(self) -> str:
return pulumi.get(self, "provisioning_state") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def provisioning_state(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"provisioning_state\")",
"def provisioning_state(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"provisioning_state\")",
"def provisioning_state(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"... | [
"0.64781475",
"0.64781475",
"0.64781475",
"0.64781475",
"0.64781475",
"0.64781475",
"0.64781475",
"0.64781475",
"0.64781475",
"0.64781475",
"0.64781475",
"0.64781475",
"0.64781475",
"0.6211141",
"0.6211141",
"0.6211141",
"0.6211141",
"0.6211141",
"0.60596436",
"0.60596436",
"... | 0.64656705 | 36 |
Return string in format "_". If attachment has "access_key" fields it will be properly appended. | def prepared(self) -> str:
template = "{}{}_{}"
if self.access_key:
template = "{}{}_{}_" + self.access_key
return template.format(self.type, self.owner_id, self.id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _format_key(self, k: str) -> str:\n if k[0] == '.':\n k = k[1:]\n k = k.replace('.', '_')\n k = k.upper()\n k = re.sub(self.KEY_REGEX, '', k)\n return k",
"def _add_key(self, key):\n key = key.strip().strip('@').lower()\n if self.homogenise_fields:\... | [
"0.601121",
"0.5992594",
"0.5980442",
"0.58966154",
"0.58067435",
"0.57335025",
"0.57258004",
"0.5689883",
"0.5681948",
"0.56528604",
"0.56083816",
"0.55849546",
"0.55333155",
"0.5518894",
"0.5518894",
"0.54825556",
"0.5474323",
"0.5472895",
"0.5461718",
"0.54522395",
"0.5440... | 0.4954808 | 81 |
Transform X using onehot encoding. | def transform(self, X):
X = check_array(X, accept_sparse='csc', dtype=np.object, copy=True)
n_samples, n_features = X.shape
X_int = np.zeros_like(X, dtype=np.int)
X_mask = np.ones_like(X, dtype=np.bool)
for i in range(n_features):
valid_mask = np.in1d(X[:, i], self.c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot_encode(x):\n # TODO: Implement Function\n lb = preprocessing.LabelBinarizer()\n lb.fit([0,1,2,3,4,5,6,7,8,9])\n \n return lb.transform(x)",
"def one_hot_encode(x):\n # TODO: Implement Function\n output = np.zeros((len(x), 10))\n \n for i, j in enumerate(x):\n output[... | [
"0.8219971",
"0.81998163",
"0.8187003",
"0.80171347",
"0.80086917",
"0.7953275",
"0.7925757",
"0.7909148",
"0.7731275",
"0.764463",
"0.76382214",
"0.7606447",
"0.75770795",
"0.7576713",
"0.7539266",
"0.75064456",
"0.75040966",
"0.74916536",
"0.7488146",
"0.7440699",
"0.742351... | 0.0 | -1 |
returns one string for each "+", followed by a list of strings when a trailing "" is present | def unpack_topic(pattern, topic):
pattern_parts = iter(pattern.split("/"))
topic_parts = iter(topic.split("/"))
while True:
try:
cur_pattern = next(pattern_parts)
except StopIteration:
try:
cur_topic = next(topic_parts)
raise Exception(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_concat(infix_regex: str):\n\n result = \"\"\n\n # we use None to symbolize the start of the string\n cant_concat_from = ['(', '|', None]\n cant_concat_to = ['*', '+', ')', '|']\n last_char = None\n\n for char in infix_regex:\n if char not in cant_concat_to and last_char not in cant... | [
"0.6251761",
"0.61776274",
"0.6086631",
"0.60642487",
"0.5914317",
"0.5893167",
"0.584809",
"0.58134824",
"0.57906926",
"0.5787478",
"0.578389",
"0.5666463",
"0.5656535",
"0.56516045",
"0.5649417",
"0.5640997",
"0.5622021",
"0.557132",
"0.55478626",
"0.55410564",
"0.5533461",... | 0.0 | -1 |
dtypeaware variant of numpy.testing.assert_allclose This variant introspects the least precise floating point dtype in the input argument and automatically sets the relative tolerance parameter to 1e4 float32 and use 1e7 otherwise (typically float64 in scikitlearn). `atol` is always left to 0. by default. It should be ... | def assert_allclose(
actual, desired, rtol=None, atol=0.0, equal_nan=True, err_msg="", verbose=True
):
dtypes = []
actual, desired = np.asanyarray(actual), np.asanyarray(desired)
dtypes = [actual.dtype, desired.dtype]
if rtol is None:
rtols = [1e-4 if dtype == np.float32 else 1e-7 for dtyp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_allclose_cast(actual, desired, rtol=1e-7, atol=0):\n if actual.dtype.kind == 'O':\n dtype = np.array(actual.flat[0]).dtype\n actual, desired = actual.astype(dtype), desired.astype(dtype)\n assert_allclose(actual, desired, rtol, atol)",
"def assert_allclose(actual, desired, rtol=1e-... | [
"0.77832764",
"0.7216723",
"0.6794316",
"0.67372864",
"0.6672169",
"0.6622535",
"0.643778",
"0.6433592",
"0.6411333",
"0.63372993",
"0.6278972",
"0.61899114",
"0.61448026",
"0.6136797",
"0.6043122",
"0.59772116",
"0.59683317",
"0.59271544",
"0.5925225",
"0.5923132",
"0.589800... | 0.7752753 | 1 |
Convert a given container to a specific arraylike with a dtype. | def _convert_container(
container, constructor_name, columns_name=None, dtype=None, minversion=None
):
if constructor_name == "list":
if dtype is None:
return list(container)
else:
return np.asarray(container, dtype=dtype).tolist()
elif constructor_name == "tuple":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def astype(self, dtype):\n res = []\n if self is not NoneArray:\n for a in self.Arrays:\n if a is NoneArray:\n res.append(NoneArray)\n else:\n res.append(a.astype(dtype))\n return VTKCompositeDataArray(\n ... | [
"0.6569977",
"0.61873806",
"0.6150881",
"0.61135584",
"0.6084547",
"0.60752517",
"0.6071889",
"0.6067872",
"0.6049874",
"0.60412914",
"0.59836036",
"0.596474",
"0.594815",
"0.59291434",
"0.59253794",
"0.5924668",
"0.5914558",
"0.59038544",
"0.5844783",
"0.5831471",
"0.5814225... | 0.6198965 | 1 |
Returns a function that is itself a higherorder function. | def cycle(f1, f2, f3):
def how_many(n):
def what(x):
if n >= 1:
x = f1(x)
if n >= 2:
x = f2(x)
if n >= 3:
x = f3(x)
if n > 3:
return how_many(n - 3)(x)
else:
return x
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lift(func: Callable) -> Callable:\n return lambda f: compose2(func, f)",
"def curry2(f):\n return lambda x: lambda y: f(x, y)",
"def two():\n return lambda f: lambda x: f(f(x))",
"def one():\n return lambda f: lambda x: f(x)",
"def curry(f: Callable) -> Callable:\n @functools.wraps(f)\n ... | [
"0.6576693",
"0.63378894",
"0.6233256",
"0.6153265",
"0.6129069",
"0.6070844",
"0.6052302",
"0.6001915",
"0.5964916",
"0.594681",
"0.58936214",
"0.58842826",
"0.57823807",
"0.57667005",
"0.56814593",
"0.56791604",
"0.5664517",
"0.5645075",
"0.55790377",
"0.5564775",
"0.548919... | 0.0 | -1 |
Returns True if n is a prime number and False otherwise. >>> is_prime(2) True >>> is_prime(16) False >>> is_prime(521) True | def is_prime(n):
x = 2
def divide_x(x):
if x > round(pow(n, 0.5)):
return True
elif n % x == 0:
return False
else:
return divide_x(x + 1)
return divide_x(x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isprime(n: int) -> bool:\r\n if n > 1:\r\n for i in range(2, int(n / 2) + 1):\r\n if (n % i) == 0:\r\n return False\r\n else:\r\n return True\r\n\r\n else:\r\n return False",
"def if_prime(cls, n):\n\n if (n <= 1):\n return Fal... | [
"0.83589226",
"0.834986",
"0.8314097",
"0.8293446",
"0.82890725",
"0.8277064",
"0.82589996",
"0.8252419",
"0.8244945",
"0.82420766",
"0.8232813",
"0.8216686",
"0.81842816",
"0.817332",
"0.8130635",
"0.8117115",
"0.81070226",
"0.8102639",
"0.80844885",
"0.8077988",
"0.8076873"... | 0.769177 | 59 |
Return the number of tenpairs within positive integer n. >>> ten_pairs(7823952) 3 >>> ten_pairs(55055) 6 >>> ten_pairs(9641469) 6 | def ten_pairs(n):
def counter(x, n):
if n == 0:
return 0
else:
if x == n % 10:
return 1 + counter(x, n // 10)
else:
return counter(x, n // 10)
def one_to_five(k):
if k == 5:
return round(counter(k,n) * (count... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ten_pairs(n):\n def digit_in_n(num, i):\n if num < 10:\n return 1 if num == i else 0\n else:\n if num % 10 == i:\n return 1 + digit_in_n(num // 10, i)\n else:\n return digit_in_n(num // 10, i)\n\n def pairs_calc(num):\n i... | [
"0.79464",
"0.7579056",
"0.66567963",
"0.65444773",
"0.6310897",
"0.6175135",
"0.6159747",
"0.6158203",
"0.6155827",
"0.6029832",
"0.59624743",
"0.59334177",
"0.58463377",
"0.58436567",
"0.5838836",
"0.58342487",
"0.5808244",
"0.5791592",
"0.5760908",
"0.5753911",
"0.56947964... | 0.80242497 | 0 |
Get URL version of URI. is always activated since URL is readonly. URIs on cloud buckets can be converted to presigned URLs. Local path URI can also be converted to a URL. | def get_url(self):
return self.get_file(uri_type=URI_URL, no_copy=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_url(self, uri):\n # TODO make this a prepend_if_needed type method\n return urllib.parse.urljoin(self.hostname, uri)",
"def get_uri(self):\n return self.url",
"def full_uri(path):\n protocol = 'https' if settings.USE_HTTPS else 'http'\n domain = Site.objects.get_current().dom... | [
"0.6869486",
"0.66566515",
"0.66456234",
"0.6548765",
"0.63195515",
"0.6311959",
"0.6263784",
"0.62445486",
"0.6209761",
"0.62056875",
"0.61738807",
"0.61730576",
"0.61724585",
"0.61674076",
"0.6112843",
"0.6101857",
"0.61015904",
"0.609824",
"0.609263",
"0.606307",
"0.604491... | 0.67116094 | 1 |
Set columns and rows as zeros in a 2D array. | def row_col_make_zero(two_dimensional_array):
columns = []
rows = []
for row, rvalue in enumerate(two_dimensional_array):
check = [column for column, cvalue in enumerate(rvalue) if cvalue == 0]
if check:
columns.extend(check)
rows.append(row)
for row in two_dimens... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setZeroes(self, matrix) -> None:\n if not matrix: return\n h, w = len(matrix), len(matrix[0])\n col0 = False\n for i in range(h):\n if matrix[i][0] == 0:\n col0 = True # 第一列是否要全置为0\n for j in range(1, w): # 从第二列开始\n if matrix[i][... | [
"0.74898076",
"0.7449223",
"0.7444616",
"0.7428816",
"0.74253553",
"0.7416765",
"0.74102473",
"0.73864466",
"0.7383826",
"0.7371137",
"0.73677963",
"0.73417467",
"0.7303975",
"0.7266936",
"0.72544247",
"0.72466135",
"0.7214006",
"0.72122943",
"0.71970767",
"0.7174618",
"0.716... | 0.69712514 | 38 |
Set precision for Decimal number operations and return previous precision value. | def set_precision(prec = None):
context = decimal.getcontext()
oldprec = context.prec
if prec is not None:
context.prec = prec
return oldprec | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_precision(self, precision) :\n self.__precision = self.parent().action().filter(precision)",
"def _set_precision(self, precision) :\n self.__precision = self.parent().monoid().filter(precision)",
"def change_precision(self, precision):\n if precision <= 0:\n print(\"Pre... | [
"0.7551775",
"0.73985076",
"0.7223718",
"0.72050005",
"0.7052748",
"0.7034678",
"0.70021915",
"0.70021915",
"0.697628",
"0.6956528",
"0.69377047",
"0.6903805",
"0.677108",
"0.677108",
"0.6732852",
"0.6615876",
"0.66121644",
"0.6564906",
"0.6557831",
"0.6510031",
"0.6469269",
... | 0.81375986 | 0 |
Return 1,0,1 if the object is smaller, equal, or greater than other (not always in mathematical sense). If the object is of different type from other then their classes are ordered according to sorted_classes list. | def compare(self, other):
# all redefinitions of __cmp__ method should start with the
# following three lines:
if self is other: return 0
c = cmp(self.__class__, other.__class__)
if c: return c
#
st = self._hashable_content()
ot = other._hashable_content()... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare(self, other):\n # all redefinitions of __cmp__ method should start with the\n # following lines:\n if self is other:\n return 0\n n1 = self.__class__\n n2 = other.__class__\n c = _old_compare(n1, n2)\n if c:\n return c\n #\n ... | [
"0.6408841",
"0.63635767",
"0.63318133",
"0.62984914",
"0.6243454",
"0.62407756",
"0.6223615",
"0.6158124",
"0.60770106",
"0.6067739",
"0.6065404",
"0.6055721",
"0.60147506",
"0.60086536",
"0.6005923",
"0.59957886",
"0.5988989",
"0.5971055",
"0.59683406",
"0.59669715",
"0.596... | 0.62705976 | 4 |
Add trains to a given platform object from a given platform tree. | def xmlPlatformGetTrains(platformObj, platformElement, whenCreated):
for trainElement in platformElement.iter("{http://trackernet.lul.co.uk}T"):
lcid = trainElement.get("LCID")
setNo = trainElement.get("SetNo")
tripNo = trainElement.get("TripNo")
secondsTo = int(trainElement.get("Sec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_platform(self, platform: KetraPlatformBase):\n self.platforms.append(platform)",
"def xmlStationGetPlatforms(stationObj, stationElement, whenCreated):\n for platformElement in \\\n stationElement.iter(\"{http://trackernet.lul.co.uk}P\"):\n name = platformElement.get(\"N\")\n ... | [
"0.68632346",
"0.5942993",
"0.5712395",
"0.56471145",
"0.5149665",
"0.5062592",
"0.50463736",
"0.49979433",
"0.49832192",
"0.48066327",
"0.48063007",
"0.47350553",
"0.4696873",
"0.46723402",
"0.4664614",
"0.46636504",
"0.46581462",
"0.46474063",
"0.4639339",
"0.46361893",
"0.... | 0.6055445 | 1 |
return a list of arrays so that each array has a maxlength of max_len and as many earlier sublists as possible have length max_len and the last one has the remaining content (tail) of L and np.concatenate(the return value) is L | def split_into_subarrays_of_max_len(arr, max_len=44100):
return np.split(arr, np.arange(max_len, len(arr), max_len)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_lis(seq, prev, index_of_max_size) -> list:\n a = []\n\n while index_of_max_size != -1:\n a.append(seq[index_of_max_size])\n index_of_max_size = prev[index_of_max_size]\n\n a.reverse()\n return a",
"def split_array(array, max_len=2000):\n new_array_lst = []\n for x in ra... | [
"0.6897349",
"0.65989584",
"0.6263467",
"0.6041981",
"0.5872584",
"0.5829015",
"0.57620275",
"0.5758574",
"0.57255185",
"0.57189834",
"0.5623612",
"0.5573832",
"0.55627006",
"0.5558145",
"0.5554015",
"0.5537631",
"0.5536698",
"0.5534564",
"0.5533743",
"0.5488414",
"0.5481954"... | 0.6923737 | 0 |
Excludes any questions that aren't published yet. | def get_queryset(self):
return Question.objects.filter(pub_date__lte=timezone.now()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n # the filter says that it only returns those w/ the pub_date\n # less or equal to timezone.now() (earlier or now)\n questions = Question.objects.filter(\n pub_date__lte=timezone.now()\n ).order_by('-pub_date')\n\n excludes = []\n for qu... | [
"0.66057587",
"0.6447535",
"0.6222388",
"0.6170101",
"0.6170101",
"0.6101224",
"0.6100283",
"0.6083196",
"0.6055842",
"0.60525465",
"0.5971601",
"0.5893893",
"0.5893893",
"0.5890032",
"0.5882812",
"0.58696455",
"0.58696455",
"0.58696455",
"0.58696455",
"0.58689994",
"0.585721... | 0.62109476 | 16 |
Should return status 201. | def test_create_startliste(http_service: Any) -> None:
url = f"{http_service}/start"
with open("tests/files/G11KvartStart.json") as json_file:
data = json.load(json_file)
headers = {"content-type": "application/json; charset=utf-8"}
response = requests.post(url, headers=headers, json=data)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def response_201_created(self, body):\n return self.create_response(201, 'Created', body)",
"def post(self, request, *args, **kwargs):\n response = super().post(request, *args, **kwargs)\n response.status_code = status.HTTP_201_CREATED\n return response",
"def assertHttpCreated(self... | [
"0.76533127",
"0.76511204",
"0.75510144",
"0.7464336",
"0.72224194",
"0.7132459",
"0.7100688",
"0.67412347",
"0.67198664",
"0.66333616",
"0.65841836",
"0.65819937",
"0.6568218",
"0.6549674",
"0.6549674",
"0.6538043",
"0.65112066",
"0.6479552",
"0.6461541",
"0.6418576",
"0.635... | 0.0 | -1 |
just ignore the transformer and return a random df of strings | def transform(X, transformer, y=None):
return pd.DataFrame([random_str_generator() for x in range(len(X))]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_1():\n number_of_rows = 1000000\n map_gender = {0 : 'Female', 1: 'Male'}\n\n # Generating a list of random strings as Names\n list_names = [randstr.randstr(16) for row in range(number_of_rows)]\n\n # Generating a list of random integers between 1 - 100 as Ages\n list_age = [random.ra... | [
"0.63359356",
"0.60732955",
"0.588697",
"0.58770263",
"0.5726989",
"0.5726989",
"0.57029647",
"0.5641231",
"0.56273395",
"0.5553163",
"0.54869944",
"0.5457556",
"0.54571825",
"0.54100806",
"0.5395605",
"0.5392028",
"0.5391058",
"0.53723717",
"0.530884",
"0.5305257",
"0.530470... | 0.7522376 | 0 |
Create a new album. Optional parameter of ids is an array of image ids to add to the album; you have to be logged in as the user for adding the image ids. This method is available without authenticating an account, and may be used | def cmd_album_create(client, args):
fields = data_fields(args, client.allowed_album_fields)
album = client.create_album(fields)
generate_output({'album': album}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_album(self, title=None, description=None, images=None,\n cover=None):\n url = \"https://api.imgur.com/3/album/\"\n payload = {'ids': images, 'title': title,\n 'description': description, 'cover': cover}\n resp = self._send_request(url, params=pa... | [
"0.71060133",
"0.6729655",
"0.65858775",
"0.6583446",
"0.6227867",
"0.6013501",
"0.5950661",
"0.5696025",
"0.5508621",
"0.5228729",
"0.5165092",
"0.5118961",
"0.5063792",
"0.49938264",
"0.49716452",
"0.4949737",
"0.49016353",
"0.4880397",
"0.48460948",
"0.48458472",
"0.480997... | 0.65685374 | 4 |
Get the comment with all of the replies for the comment | def cmd_comment_replies(client, args):
comment_replies = client.get_comment_replies(args.comment_id)
data = format_comment_tree(comment_replies)
generate_output({'comment_replies': data}, args.output_file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replies(self):\n keys = {}\n comments = self.comments.order('-score').fetch(1000)\n for comment in comments:\n keys[str(comment.key())] = comment\n comment.replies = []\n for comment in comments:\n parent_key = Comment.reply_to.get_value_for_datastor... | [
"0.80614966",
"0.79362017",
"0.7154024",
"0.70583296",
"0.68521935",
"0.68225664",
"0.6727376",
"0.6722152",
"0.67106235",
"0.65210116",
"0.6505564",
"0.6502786",
"0.64655274",
"0.63230026",
"0.63086355",
"0.62354404",
"0.61569613",
"0.61479384",
"0.6112512",
"0.6085547",
"0.... | 0.77197665 | 2 |
Create a reply for the given comment | def cmd_comment_reply(client, args):
comment_reply = client.post_comment_reply(args.comment_id, args.image_id,
args.comment)
generate_output({'comment_reply': comment_reply}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def create_reply(*, comment: models.Comment = Depends(resolve_comment), created_comment: CreateComment,\n current_user: models.User = Depends(resolve_current_user), db: Session = Depends(get_db)):\n return crud.create_comment(db, author_id=current_user.id, parent_resub_id=comment.par... | [
"0.85108405",
"0.77590686",
"0.70710206",
"0.69517535",
"0.69128376",
"0.6906068",
"0.68195975",
"0.6809562",
"0.6682857",
"0.6673473",
"0.6651297",
"0.6565192",
"0.65049386",
"0.6492582",
"0.64875966",
"0.6450746",
"0.64480036",
"0.6404118",
"0.6372667",
"0.63615",
"0.633491... | 0.71514606 | 2 |
x = np.array([[[[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]]]]) pad = [0, 0, 0, 0, 0, 0, 1, 1, 0, 0] mode = "constant" value = 0 | def test_pad1():
x = np.array([[[[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]]]])
pad = [0, 0, 0, 0, 0, 0, 1, 1, 0, 0]
mode = "constant"
value = 0
res = np.array([[[[[0.0, 0.0, 0.0], [1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [0.0, 0.0, 0.0]]]]])
# data_format = "NCDHW"
obj.run(res=res, x=x, pad=pad, mode=mode... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_pad3():\n x = np.array([[[[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]]]])\n pad = [0, 0, 1, 1, 0, 0]\n mode = \"constant\"\n value = 0\n data_format = \"NCDHW\"\n res = np.array([[[[[0.0, 0.0, 0.0], [1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [0.0, 0.0, 0.0]]]]])\n obj.run(res=res, x=x, pad=pad, mode=mo... | [
"0.6698328",
"0.66958964",
"0.6690412",
"0.65119356",
"0.6278268",
"0.6272346",
"0.61976653",
"0.61386716",
"0.60923636",
"0.6091921",
"0.6073236",
"0.60632783",
"0.6052736",
"0.6032814",
"0.60286623",
"0.59842104",
"0.59614986",
"0.59614986",
"0.59589773",
"0.5951221",
"0.59... | 0.70277035 | 0 |
x = np.array([[[[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]]]]) pad = (0, 1, 1, 1, 2, 0) mode = "constant" value = 0 data_format = "NCDHW" | def test_pad2():
x = np.array([[[[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]]]])
pad = (0, 1, 1, 1, 2, 0)
mode = "constant"
value = 0
data_format = "NCDHW"
res = np.array(
[
[
[
[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_pad1():\n x = np.array([[[[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]]]])\n pad = [0, 0, 0, 0, 0, 0, 1, 1, 0, 0]\n mode = \"constant\"\n value = 0\n res = np.array([[[[[0.0, 0.0, 0.0], [1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [0.0, 0.0, 0.0]]]]])\n # data_format = \"NCDHW\"\n obj.run(res=res, x=x, pa... | [
"0.7623521",
"0.71405995",
"0.7011633",
"0.68526816",
"0.6786315",
"0.6657954",
"0.6650885",
"0.6516278",
"0.645092",
"0.62391603",
"0.61919445",
"0.61528045",
"0.6142095",
"0.6119765",
"0.61167043",
"0.6115934",
"0.61052406",
"0.6091794",
"0.60748076",
"0.60581493",
"0.60545... | 0.73220307 | 1 |
x = np.array([[[[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]]]]) pad = [0, 0, 1, 1, 0, 0] mode = "constant" value = 0 data_format = "NCDHW" | def test_pad3():
x = np.array([[[[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]]]])
pad = [0, 0, 1, 1, 0, 0]
mode = "constant"
value = 0
data_format = "NCDHW"
res = np.array([[[[[0.0, 0.0, 0.0], [1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [0.0, 0.0, 0.0]]]]])
obj.run(res=res, x=x, pad=pad, mode=mode, value=value,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_pad1():\n x = np.array([[[[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]]]])\n pad = [0, 0, 0, 0, 0, 0, 1, 1, 0, 0]\n mode = \"constant\"\n value = 0\n res = np.array([[[[[0.0, 0.0, 0.0], [1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [0.0, 0.0, 0.0]]]]])\n # data_format = \"NCDHW\"\n obj.run(res=res, x=x, pa... | [
"0.74623936",
"0.7157762",
"0.6833125",
"0.67360485",
"0.6633727",
"0.65201956",
"0.65062326",
"0.6383284",
"0.6315743",
"0.61346817",
"0.60859257",
"0.6050707",
"0.60170645",
"0.6015586",
"0.6012826",
"0.6012826",
"0.60085744",
"0.5994829",
"0.596389",
"0.59563076",
"0.59432... | 0.69549215 | 2 |
x = np.array([[[[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]]]]) pad = (2, 1, 3, 0, 2, 0) mode = "replicate" data_format = "NDHWC" | def test_pad6():
x = np.array([[[[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]]]])
pad = (2, 1, 3, 0, 2, 0)
mode = "replicate"
data_format = "NDHWC"
res = np.array(
[
[
[
[[1.0, 2.0, 3.0], [1.0, 2.0, 3.0], [1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [4.0, 5.0, 6.0]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_Pad3D16():\n input_shape = (1, 2, 3)\n pad = [1, 2]\n mode = \"replicate\"\n res = [[[1, 1, 2, 3, 3, 3], [4, 4, 5, 6, 6, 6]]]\n data = np.arange(np.prod(input_shape)).reshape(input_shape) + 1\n obj.base(res=res, padding=pad, mode=mode, data=data, data_format=\"NCL\")",
"def test_Pad3D1... | [
"0.7327433",
"0.72835165",
"0.72708315",
"0.7149601",
"0.7104649",
"0.70132464",
"0.7001106",
"0.6986501",
"0.69471544",
"0.68403816",
"0.67669135",
"0.67362154",
"0.6720227",
"0.66746354",
"0.6665593",
"0.6640587",
"0.66361946",
"0.658165",
"0.6556689",
"0.65506375",
"0.6543... | 0.77382594 | 0 |
x = np.array([[[[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]]]]) pad = (2, 2, 1, 1, 0, 0) mode = "reflect" data_format = "NCDHW" | def test_pad7():
x = np.array([[[[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]]]])
pad = (2, 2, 1, 1, 0, 0)
mode = "reflect"
data_format = "NCDHW"
res = np.array(
[
[
[
[
[6.0, 5.0, 4.0, 5.0, 6.0, 5.0, 4.0],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_Pad3D12():\n input_shape = (1, 2, 3)\n # pad = np.array([1, 2]).astype('int32')\n pad = [1, 2]\n mode = \"reflect\"\n res = [[[2, 1, 2, 3, 2, 1], [5, 4, 5, 6, 5, 4]]]\n data = np.arange(np.prod(input_shape)).reshape(input_shape) + 1\n obj.run(res=res, padding=pad, mode=mode, data=data... | [
"0.68910044",
"0.6837027",
"0.6824683",
"0.67878646",
"0.669256",
"0.6686706",
"0.66790485",
"0.6668692",
"0.6646214",
"0.6614676",
"0.6499914",
"0.6456223",
"0.64117163",
"0.639324",
"0.63833404",
"0.62231374",
"0.6190965",
"0.61640817",
"0.61539394",
"0.6135249",
"0.6085471... | 0.73705363 | 0 |
x = np.array([[1, 3], [3, 1]]) pad = [1, 1, 2, 3] mode = "constant" value = Tensor(2.0) data_format = "NCHW" | def test_pad_8():
paddle.disable_static()
x = np.array([[[[1.0, 3.0], [-3.0, 1.0]]]])
pad = [1, 1, 1, 2]
mode = "constant"
value = np.array(2.0)
data_format = "NCHW"
res = np.array(
[
[
[
[2.0, 2.0, 2.0, 2.0],
[2.0, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_pad():\n x = randtool(\"float\", -10, 10, [3, 2, 1, 2])\n pad = [1, 1, 2, 3]\n mode = \"constant\"\n value = 2.0\n data_format = \"NCHW\"\n res = np.array(\n [\n [\n [\n [2.0, 2.0, 2.0, 2.0],\n [2.0, 2.0, 2.0, 2.0],\n... | [
"0.7084172",
"0.7037379",
"0.70100534",
"0.68440944",
"0.67859715",
"0.6725408",
"0.6699503",
"0.66414475",
"0.66107965",
"0.64776206",
"0.6404393",
"0.6342569",
"0.6274884",
"0.6268529",
"0.6268461",
"0.6266077",
"0.6243942",
"0.62393004",
"0.62374854",
"0.6211512",
"0.61827... | 0.6970348 | 3 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
plt.imshow(cm, interpolation='nearest', cmap=cmap)
plt.title(title)
plt.colorbar()
tick_marks = np.arange(len(classes))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.8194862",
"0.80949175",
"0.8029915",
"0.8019153",
"0.79941195",
"0.7991258",
"0.7980955",
"0.7976606",
"0.79610753",
"0.79590565",
"0.79378676",
"0.7934962",
"0.7934504",
"0.79313844",
"0.7926313",
"0.7924577",
"0.79241234",
"0.7923211",
"0.7923023",
"0.7921931",
"0.791787... | 0.78436774 | 55 |
The stone parity value is based on the players' immediate score after a specific move. | def stone_parity(self, board):
computer_score = sum(sum(board == self.computer_num))
opponent_score = sum(sum(board == self.opponent_num))
return 100 * (computer_score - opponent_score) / (computer_score + opponent_score) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parity_player(self, board):\n valid_moves = self.game.find_valid_moves(self.computer_color, board, self.board_size)\n rows, columns = np.where(valid_moves == 1)\n max_parity = -200\n location = (-2, -2)\n for i in range(len(rows)):\n temp_board = np.copy(board)\n ... | [
"0.7013714",
"0.62829936",
"0.615159",
"0.605926",
"0.60563177",
"0.6048984",
"0.60476047",
"0.5961625",
"0.5891619",
"0.5807195",
"0.5801265",
"0.5799314",
"0.5780686",
"0.5770093",
"0.5709785",
"0.56669337",
"0.5665021",
"0.5647279",
"0.56365454",
"0.5602205",
"0.55976766",... | 0.7434731 | 0 |
Return the number of seconds between two dates. | def compute_duration(date1, date2):
duration = 0
if date1 and date2:
delta = abs(date1 - date2)
duration = delta.days * 86400 + delta.seconds
return duration | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seconds_elapsed(date1, date2):\n return (date1 - date2).total_seconds()",
"def secondsCount(timestamp1, timestamp2):\n return timestamp1 - timestamp2",
"def diff_secs(self, other):\n if not isinstance(other, datetime):\n types = (type(other), datetime)\n raise TypeError('Type mismatch: %... | [
"0.81940275",
"0.722263",
"0.71853626",
"0.68199396",
"0.67970294",
"0.67518437",
"0.6731858",
"0.66094476",
"0.65771496",
"0.6576583",
"0.6575861",
"0.6504075",
"0.64582103",
"0.6445168",
"0.6377559",
"0.62831557",
"0.6277148",
"0.62718666",
"0.62706804",
"0.626912",
"0.6264... | 0.7088195 | 3 |
Returns a list of sentences given an input batch. | def decode_reference(self, model, x, out_lens):
model = getattr(model, 'module', model)
with torch.no_grad():
# Apply optional preprocessing
logits, out_lens = model.encode(x, out_lens)
output = []
for batch_idx in range(logits.size(0)):
in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sentences(self, batch=None):\n\t\t\n\t\t# loop through the paragraph stream for this document database\n\t\tfor paragraph in self.get_paragraphs(batch):\n\t\t\t# loop through the sentences\n\t\t\tfor sentence in paragraph[\"sentences\"]:\n\t\t\t\t# yield the individual tokens\n\t\t\t\tyield sentence[\"toke... | [
"0.7045197",
"0.6999629",
"0.6999629",
"0.6811488",
"0.67944044",
"0.67918575",
"0.6684785",
"0.6655991",
"0.6654197",
"0.6563033",
"0.6538207",
"0.65153295",
"0.6505902",
"0.64953995",
"0.646527",
"0.643292",
"0.64170915",
"0.63184696",
"0.631131",
"0.6308585",
"0.6293186",
... | 0.0 | -1 |
Returns a list of sentences given an input batch. | def decode_batch(self, x, out_lens):
def next_multiple_of_eight(x):
return math.ceil(x/8) * 8
assert self.max_symbol_per_sample is not None, "max_symbol_per_sample needs to be specified in order to use batch_eval"
with torch.no_grad():
# Apply optional preprocessing
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sentences(self, batch=None):\n\t\t\n\t\t# loop through the paragraph stream for this document database\n\t\tfor paragraph in self.get_paragraphs(batch):\n\t\t\t# loop through the sentences\n\t\t\tfor sentence in paragraph[\"sentences\"]:\n\t\t\t\t# yield the individual tokens\n\t\t\t\tyield sentence[\"toke... | [
"0.7045197",
"0.6999629",
"0.6999629",
"0.6811488",
"0.67944044",
"0.67918575",
"0.6684785",
"0.6655991",
"0.6654197",
"0.6563033",
"0.6538207",
"0.65153295",
"0.6505902",
"0.64953995",
"0.646527",
"0.643292",
"0.64170915",
"0.63184696",
"0.631131",
"0.6308585",
"0.6293186",
... | 0.0 | -1 |
Checks if activities in flowbyactivity that appear to be like sectors are actually sectors | def check_if_activities_match_sectors(fba):
# Get list of activities in a flowbyactivity file
activities = []
for f in fba_activity_fields:
activities.extend(fba[f])
# Get list of module default sectors
flowsa_sector_list = list(load_crosswalk('sector_timeseries')[
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_course_based_activity(self):\n return False",
"def has_sector(self,s):\n for run in self.byteruns():\n if run.has_sector(s): return True\n return False",
"def compare_activity_to_sector_flowamounts(fba_load, fbs_load,\n activity_s... | [
"0.5700458",
"0.56310457",
"0.54803336",
"0.541371",
"0.5327765",
"0.5326533",
"0.52770287",
"0.5196451",
"0.5156743",
"0.513289",
"0.50811964",
"0.50524026",
"0.5043073",
"0.49783942",
"0.4968298",
"0.4948216",
"0.49338338",
"0.49254033",
"0.4853778",
"0.4837848",
"0.4820222... | 0.71237683 | 0 |
Get the names of the output layers, i.e. the layers with unconnected outputs | def getOutputsNames(self):
self.layersNames = self.net.getLayerNames()
# Get the names of the output layers, i.e. the layers with unconnected outputs
return [self.layersNames[i[0] - 1] for i in self.net.getUnconnectedOutLayers()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getOutputsNames(net):\r\n # Get the names of all the layers in the network\r\n layersNames = net.getLayerNames()\r\n # Get the names of the output layers, i.e. the layers with unconnected outputs\r\n return [layersNames[i[0] - 1] for i in net.getUnconnectedOutLayers()]",
"def getOutputsNames(net):\n #... | [
"0.85490966",
"0.8501413",
"0.74311286",
"0.7000126",
"0.698524",
"0.69192314",
"0.6824727",
"0.6792042",
"0.6716075",
"0.67010486",
"0.662227",
"0.65866697",
"0.6554005",
"0.653272",
"0.6521707",
"0.6503979",
"0.65005594",
"0.64170825",
"0.6379317",
"0.6374442",
"0.6361116",... | 0.87982345 | 0 |
Applies month,date,city filters and loads the appropriate csv file | def load_data(city, month, day ,city_num, month_num, day_num):
try:
df = pd.read_csv(CITY_DATA[city])
df['Start Time'] = pd.to_datetime(df['Start Time'])
df['End Time'] = pd.to_datetime(df['End Time'])
df['month'] = df['Start Time'].dt.month
df['day_of_week'] = df['Star... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(city, month, day):\r\n\r\n #creating data frame from csv\r\n df = pd.read_csv(CITY_DATA[city])\r\n\r\n #converting Start Time row into datetime data type\r\n df['Start Time']=pd.to_datetime(df['Start Time'])\r\n\r\n #Extracting month and week day from 'Start Time' row\r\n df['Month'... | [
"0.7252327",
"0.7149716",
"0.7149142",
"0.7037811",
"0.70136905",
"0.7007522",
"0.7002948",
"0.6998037",
"0.69888705",
"0.6979818",
"0.6978237",
"0.6956194",
"0.6950382",
"0.69262695",
"0.6925763",
"0.69057786",
"0.6903432",
"0.6892163",
"0.687471",
"0.6872459",
"0.686594",
... | 0.6869215 | 20 |
Displays statistics on the most frequent times of travel. | def time_stats(df, city):
print("\n"*2+'*' * 20)
print('Calculating The Most Frequent Times of Travel...\n')
start_time = time.time()
# TO DO: display the most common month
try:
fav_month_num = df['Start Time'].dt.month.mode()[0]
fav_month = VALID_MONTHS[fav_month_num-1]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_stats(df):\n\n print('\\nDisplaying the statistics on the most frequent times of '\n 'travel...\\n')\n start_time = time.time()\n\n # display the most common month\n most_common_month = df['Month'].mode()[0]\n print('For the selected filter, the month with the most travels is: ' +\... | [
"0.80247396",
"0.80233026",
"0.7915788",
"0.78266186",
"0.7822246",
"0.78143597",
"0.77659196",
"0.7740343",
"0.773628",
"0.77344066",
"0.76867086",
"0.7668633",
"0.7651731",
"0.7644636",
"0.76399267",
"0.76367253",
"0.7625196",
"0.7623158",
"0.7612803",
"0.76002145",
"0.7583... | 0.7328224 | 53 |
Displays statistics on the most common stations and trip. | def station_stats(df, city):
print("\n" * 2 + '*' * 20)
print('Calculating The Most common Stations and Trip...\n')
start_time = time.time()
# TO DO: display most commonly used start station
try:
fav_start_position = df['Start Station'].mode()[0]
fav_start_position_amount ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def station_stats(df):\n\n print('\\nCalculating The Most Popular Stations and Trip...\\n')\n start_time = time.time()\n\n # display most commonly used start station\n print(popular_start_station(df))\n\n # display most commonly used end station\n print(popular_end_station(df))\n\n # display m... | [
"0.7901626",
"0.7715784",
"0.7671896",
"0.7668778",
"0.7668326",
"0.76551634",
"0.76498485",
"0.76345825",
"0.7613175",
"0.7586053",
"0.7579622",
"0.7578734",
"0.7569658",
"0.75602",
"0.7545632",
"0.75365746",
"0.752678",
"0.7526316",
"0.7525989",
"0.7521815",
"0.75197047",
... | 0.7387228 | 49 |
Displays statistics on the total and average trip duration. | def trip_duration_stats(df, city):
print("\n" * 2 + '*' * 20)
print('Calculating Trip Duration...\n')
start_time = time.time()
# TO DO: display total travel time
try:
df['Time Delta'] = df['End Time'] - df['Start Time']
total_time_delta = df['Time Delta'].sum()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trip_duration_stats(data):\n print('\\nCalculating Trip Duration...\\n')\n start_time = time.time()\n # display total travel time\n total_trip_time= data['Trip Duration'].sum()\n print('The Total Travel Time is {} Hours'. format(total_trip_time/3600))\n # display mean travel time\n avg_tri... | [
"0.814274",
"0.8025143",
"0.80041367",
"0.79496753",
"0.7937415",
"0.79312176",
"0.7926815",
"0.7915187",
"0.79142886",
"0.7908032",
"0.79055744",
"0.7900715",
"0.7891682",
"0.78894734",
"0.7886722",
"0.78851086",
"0.7884266",
"0.7882474",
"0.78738385",
"0.78686154",
"0.78664... | 0.0 | -1 |
yaml creation must be implemented | def user_create_yaml(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yaml(self):\n raise NotImplementedError",
"def create_yaml(self):\n if self._language == PYTHON:\n language_str = 'python'\n package_route = '$(System.DefaultWorkingDirectory)'\n dependencies = self._python_dependencies()\n elif self._language == NODE:\n ... | [
"0.7599795",
"0.683523",
"0.6826942",
"0.6811914",
"0.6776606",
"0.6691083",
"0.65454257",
"0.6494215",
"0.64344805",
"0.6399853",
"0.63765305",
"0.6251445",
"0.62067336",
"0.62010264",
"0.6091217",
"0.606059",
"0.6051349",
"0.60390854",
"0.6016576",
"0.5976309",
"0.59681475"... | 0.853896 | 0 |
Given multiple categories with multiple spending's | def test_display_spending_multiple_all(self):
date = datetime.today()
transaction = {self.user.spend_categories[0]: [{"Date": date, "Value": 10.00},
{"Date": date, "Value": 15.00}],
self.user.spend_categories[1]: [{"Date": dat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_spend_chart(categories):\n graph = \"Percentage spent by category\\n\"\n total_spendings = 0\n spendings = {}\n for category in categories:\n spendings[category.name] = 0\n for x in category.ledger:\n if x['amount'] < 0: #the withdraws are the ones with negative valu... | [
"0.5780244",
"0.5649281",
"0.5462674",
"0.54124606",
"0.53440905",
"0.52922875",
"0.5255903",
"0.52313936",
"0.51370287",
"0.5061858",
"0.50573885",
"0.5055613",
"0.5025716",
"0.5021886",
"0.50211114",
"0.50146586",
"0.5014407",
"0.49962452",
"0.4975167",
"0.49702838",
"0.495... | 0.5843974 | 0 |
Calculates safe gain functions for NDCG. In applications such as distillation, the labels could have extreme values that might result in numerical error when using the original gain function. This should only be applied to NDCG related losses, but not DCG ones. It should be applied on both the numerator and the denomin... | def _safe_default_gain_fn(labels):
max_labels = tf.reduce_max(labels, axis=-1, keepdims=True)
gains = tf.pow(2., labels - max_labels) - tf.pow(2., -max_labels)
return gains | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ndcg_score(y_true, y_score, k=5, gains=\"exponential\"):\n best = dcg_score(y_true, y_true, k, gains)\n actual = dcg_score(y_true, y_score, k, gains)\n return actual / best",
"def inverse_max_dcg(labels,\n gain_fn=lambda labels: tf.pow(2.0, labels) - 1.,\n rank_... | [
"0.6275459",
"0.61991256",
"0.6040917",
"0.59718245",
"0.5954194",
"0.5875212",
"0.5873505",
"0.58520514",
"0.5819191",
"0.579242",
"0.579099",
"0.57747126",
"0.56441504",
"0.56361747",
"0.5621107",
"0.5606787",
"0.55661964",
"0.5556794",
"0.5527544",
"0.5518475",
"0.55081385... | 0.62979054 | 0 |
Normalizes weights. This is needed for `tf.estimator` given that the reduction may be `SUM_OVER_NONZERO_WEIGHTS`. This method is also needed to compute normalized weights when calling `compute_unreduced_loss`, which is done in the tf.keras losses. | def normalize_weights(self, labels, weights):
if self._ragged:
labels, _, weights, _ = utils.ragged_to_dense(labels, None, weights)
return self._normalize_weights_impl(labels, weights) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_weights(self):\n total_weight = sum(self.weights)\n self.norm_weights = self.weights / float(total_weight)",
"def normalize_weights(self):\n \n # Set negative weights to zero\n # Normalize to sum to one.\n \n\n\n self.new_weight=[]\n for i in ... | [
"0.80921537",
"0.79740083",
"0.77553517",
"0.7692007",
"0.72982264",
"0.72140104",
"0.7116527",
"0.707865",
"0.69299203",
"0.68483096",
"0.6842551",
"0.6842551",
"0.6761088",
"0.6756076",
"0.6720158",
"0.6625788",
"0.662374",
"0.6592362",
"0.6586581",
"0.65742975",
"0.6543985... | 0.7269922 | 5 |
Precomputes Tensors for softmax cross entropy inputs. | def precompute(self, labels, logits, weights, mask=None):
if mask is None:
mask = utils.is_label_valid(labels)
ranks = _compute_ranks(logits, mask)
# Reset the masked labels to 0 and reset the masked logits to a logit with
# ~= 0 contribution in softmax.
labels = tf.compat.v1.where(mask, label... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax_cross_entropy(inputs, axis=1, reduction='mean', **kwargs):\n args = ArgHelper.parse(locals())\n args['reduction'] = reduction.upper()\n op_lib = loss_ops_lib.SoftmaxCrossEntropy\n if context.executing_eagerly():\n return op_lib \\\n .instantiate(\n axis=axis... | [
"0.6294574",
"0.62445164",
"0.62135494",
"0.61892",
"0.6166029",
"0.611509",
"0.60037404",
"0.59988225",
"0.5974861",
"0.59615487",
"0.5920296",
"0.58770967",
"0.58770967",
"0.5871205",
"0.578603",
"0.57850116",
"0.57614225",
"0.57433224",
"0.57413954",
"0.57410914",
"0.57366... | 0.5476127 | 66 |
Decorator for views that checks that the user passes the given test, redirecting to the login page if necessary. The test should be a callable that takes the user object and returns True if the user passes. | def is_logged(function=None):
def _dec(view_func):
def _view(request, *args, **kwargs):
if request.session.get('login',None):
return view_func(request, *args, **kwargs)
else:
return redirect('idx')
_view.__name__ = view_func.__name__
_view.__dict__ = view_func.__dict__
_view.__doc__ = view_func.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME):\r\n if not login_url:\r\n login_url = LOGIN_URL\r\n def decorator(view_func):\r\n def _wrapped_view(request, *args, **kwargs):\r\n if test_func(request):\r\n return view_func(requ... | [
"0.86692935",
"0.8127949",
"0.73803514",
"0.7348166",
"0.72726977",
"0.72690284",
"0.721602",
"0.721602",
"0.72042924",
"0.7178119",
"0.71673524",
"0.7165245",
"0.7154046",
"0.7137484",
"0.7130413",
"0.7118211",
"0.7076953",
"0.70569366",
"0.7054225",
"0.7047779",
"0.70328164... | 0.0 | -1 |
\brief test if the filename is a 3D extension \input{just the filename} \output{True if the media is a good extention, False otherwise} | def test_3D_extension(filename):
# We need to make a test for extention :
import os
extension = (os.path.splitext(filename)[1]).upper()
ext_ok=['.3DMF','.3DM','.3DS','.ABC','.AC','.AMF','.AN8','.AOI','.B3D','.BLEND','.BLOCK','.C4D','.CAL3D','.CCP4','.CFL','.COB','.CORE3D','.CTM','.DAE','.DFF','.DPM','.DTS','.EGG... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_mp3_file(filename):\n ext = str(os.path.splitext(filename)[1]).lower()\n return ext == '.mp3'",
"def have_mp3_extension(l):\r\n if \".mp3\" in str(l):\r\n return 1\r\n else:\r\n return 0",
"def test_audio_extension(filename):\n\t\n\t# We need to make a test for extention :\n\ti... | [
"0.75100595",
"0.7268719",
"0.7089922",
"0.70141685",
"0.6979657",
"0.68592703",
"0.68336046",
"0.67777115",
"0.6773775",
"0.6765604",
"0.6743798",
"0.6647401",
"0.663245",
"0.65915865",
"0.65601534",
"0.6556652",
"0.6531535",
"0.6515739",
"0.644066",
"0.6359014",
"0.63546216... | 0.8217823 | 0 |
\brief test if the filename is an audio extension \input{just the filename} \output{True if the media is a good extention, False otherwise} | def test_audio_extension(filename):
# We need to make a test for extention :
import os
extension = os.path.splitext(filename)[1]
ext_ok=['.aif','.aifc','.aiff','.au','.cda','.m4a','.m4b','.m4p','.mid','.midi','.mka','.mkv','.mod','.mp1','.mp2','.mp3','.mpa','.nst','.odm','.ogg','.ptm','.ra','.s3m','.snd','.wav',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def have_mpeg_extension(l):\r\n if \".mpeg\" in str(l):\r\n return 1\r\n else:\r\n return 0",
"def have_mp3_extension(l):\r\n if \".mp3\" in str(l):\r\n return 1\r\n else:\r\n return 0",
"def audio_media_type(name):\n return name.endswith(('.ogg', '.oga', '.m4a'))",
... | [
"0.75304824",
"0.7510191",
"0.730822",
"0.7303251",
"0.7301561",
"0.70185375",
"0.6994868",
"0.6993379",
"0.69521993",
"0.6948078",
"0.6920086",
"0.69145083",
"0.6719989",
"0.67055815",
"0.66273206",
"0.66249937",
"0.6607858",
"0.6579843",
"0.6537617",
"0.652492",
"0.6520289"... | 0.86149424 | 0 |
\brief test if the filename is a text extension \input{just the filename} \output{True if the media is a good extention, False otherwise} | def test_pdf_extension(filename):
# We need to make a test for extention :
import os
extension = os.path.splitext(filename)[1]
ext_ok=['.pdf','.doc','.zip','.gz','.tar','.7z','.abw','.docx','.ppt','.pptx','.html','.odt','.tex','.txt','.wps','.xml','.ps','.odp','.pps','.PDF','.DOC','.ZIP','.GZ','.TAR','.7Z','.ABW... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def have_txt_extension(l):\r\n if \".txt\" in str(l):\r\n return 1\r\n else:\r\n return 0",
"def text_media_type(name):\n return name.endswith(('.txt', '.py', '.lg', '.doc', '.rtf'))",
"def test_audio_extension(filename):\n\t\n\t# We need to make a test for extention :\n\timport os\n\te... | [
"0.7731831",
"0.75325483",
"0.7379994",
"0.71847624",
"0.71580476",
"0.71067816",
"0.70733225",
"0.70301586",
"0.70293784",
"0.6890832",
"0.6848036",
"0.68206245",
"0.68110937",
"0.67830586",
"0.67621785",
"0.6738103",
"0.6730544",
"0.6724974",
"0.67126554",
"0.67099345",
"0.... | 0.65384066 | 35 |
Give a readable representation of an instance. | def __unicode__(self):
return '%s' % self.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return \"<instance of {}>\".format(self.__class__.__name__)",
"def to_representation(self, instance):\n return instance",
"def __repr__(self):\n return repr(self.__dict__['_obj'])",
"def __repr__(self):\n return self.pretty_print(self.__dict__)",
"d... | [
"0.7497366",
"0.73179793",
"0.72952557",
"0.7288701",
"0.7233661",
"0.72258234",
"0.72258234",
"0.72258234",
"0.72258234",
"0.72258234",
"0.72258234",
"0.72258234",
"0.72258234",
"0.72258234",
"0.72258234",
"0.72258234",
"0.72258234",
"0.72258234",
"0.72258234",
"0.72258234",
... | 0.0 | -1 |
Give a unambiguous representation of an instance. | def __repr__(self):
return '<%s#%s>' % (self.__class__.__name__, self.id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def represent(instance, *args, **kwargs):\n arguments = []\n if args:\n arguments.append(', '.join([f'{v!r}' for v in args]))\n if kwargs:\n arguments.append(', '.join([f'{k}={v!r}' for k, v in kwargs.items()]))\n return f\"{instance.__class__.__name__}({', '.join(arguments)})\"",
"def ... | [
"0.66376984",
"0.6537621",
"0.6477478",
"0.6430123",
"0.641789",
"0.6415765",
"0.6366801",
"0.6353466",
"0.6337205",
"0.6300465",
"0.6299766",
"0.62791187",
"0.6257913",
"0.6257781",
"0.62315995",
"0.623087",
"0.62297136",
"0.62293833",
"0.62238556",
"0.6221245",
"0.6207133",... | 0.61025745 | 37 |
Validates publish/inherit relationships between OCM organizations and environments from the provided label containers. This function returns a dictionary of OCM organizations and their version data inheritance relationships. | def build_version_data_inheritance_network(
labels_per_org: dict[OrgRef, LabelContainer]
) -> dict[OrgRef, VersionDataInheritance]:
label_set_per_org = {
org_ref: build_labelset(labels, VersionDataInheritanceLabelSet)
for org_ref, labels in labels_per_org.items()
}
org_ref_lookup = {org_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_org_upgrade_specs_for_ocm_env(\n ocm_env: OCMEnvironment,\n orgs: dict[str, OCMOrganization],\n clusters_by_org: dict[str, list[ClusterDetails]],\n labels_by_org: dict[str, LabelContainer],\n inheritance_network: dict[str, \"VersionDataInheritance\"],\n) -> dict[str, OrganizationUpgradeSp... | [
"0.63974506",
"0.56098485",
"0.5120724",
"0.48090276",
"0.4790744",
"0.4749151",
"0.47080114",
"0.46753547",
"0.46570888",
"0.45688558",
"0.45651835",
"0.45581236",
"0.45428792",
"0.45008314",
"0.44916868",
"0.4421378",
"0.44168192",
"0.44111776",
"0.44094425",
"0.44034505",
... | 0.5948876 | 1 |
Initialize the transaction handler class. This is setting the "notary" TF namespace prefix. | def __init__(self, namespace_prefix):
self._namespace_prefix = namespace_prefix | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_init(self, prefix='space', **kwargs):\n assert prefix not in (None, '')\n self.prefix = prefix",
"def _init_temporary_namespace(cls, nsObj):\n pass",
"def __init__(self, tns: TNSInterface = None) -> None:\n self.tns = tns or TNSInterface()",
"def __init__(self, node_namespa... | [
"0.6126181",
"0.6015541",
"0.60107577",
"0.57663345",
"0.57387084",
"0.57083964",
"0.56642693",
"0.56526357",
"0.56511223",
"0.5614905",
"0.55185163",
"0.5504862",
"0.54785436",
"0.54532135",
"0.5447338",
"0.5390921",
"0.5376174",
"0.5353153",
"0.5344493",
"0.5326442",
"0.530... | 0.66629773 | 0 |
Performs forward pass of the input. Here an input tensor x is transformed through several layer transformations. | def forward(self, x):
x = F.max_pool2d(F.relu(self.batch_norm1(self.conv1(x))), 3, stride=2, padding=1)
x = F.max_pool2d(F.relu(self.batch_norm2(self.conv2(x))), 3, stride=2, padding=1)
x = F.max_pool2d(F.relu(self.batch_norm3_b(self.conv3_b(F.relu(self.batch_norm3_a(self.conv3_a(x)))))), 3, stride=2, padd... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, x_in):\r\n # x_out = torch.zeros_like(x_in)\r\n\r\n for layer in self.layers: #Call forward function of each layer in order\r\n x_out = layer.forward(x_in)\r\n # print(\"Forward pass Seq: \", layer, x_in, x_out)\r\n x_in = x_out ... | [
"0.8100517",
"0.7859832",
"0.7810853",
"0.7802328",
"0.77643955",
"0.7756715",
"0.77400374",
"0.7734368",
"0.7728727",
"0.7698818",
"0.7695517",
"0.767733",
"0.76744854",
"0.7636695",
"0.76255643",
"0.76098365",
"0.7592621",
"0.75790083",
"0.7549981",
"0.7541161",
"0.75391316... | 0.0 | -1 |
Gets the maximum_over_capacity of this V2appsUpgradeStrategy. A number between 0 and 1 which is multiplied with the instance count. This is the maximum number of additional instances launched at any point of time during the upgrade process. | def maximum_over_capacity(self):
return self._maximum_over_capacity | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_capacity(self) -> int:\n return self._max_capacity",
"def maximum_over_capacity(self, maximum_over_capacity):\n self._maximum_over_capacity = maximum_over_capacity",
"def max_instance_count(self) -> Optional[pulumi.Input[int]]:\n return pulumi.get(self, \"max_instance_count\")",
... | [
"0.72054356",
"0.677187",
"0.6522295",
"0.6522295",
"0.65013754",
"0.63126993",
"0.62846804",
"0.62846804",
"0.62846804",
"0.6159562",
"0.60822916",
"0.60822916",
"0.60482824",
"0.59722114",
"0.59682614",
"0.59503824",
"0.59305084",
"0.5918024",
"0.5886042",
"0.5885742",
"0.5... | 0.74832827 | 0 |
Sets the maximum_over_capacity of this V2appsUpgradeStrategy. A number between 0 and 1 which is multiplied with the instance count. This is the maximum number of additional instances launched at any point of time during the upgrade process. | def maximum_over_capacity(self, maximum_over_capacity):
self._maximum_over_capacity = maximum_over_capacity | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maximum_over_capacity(self):\n return self._maximum_over_capacity",
"def set_max_vehicle_capacity(self, new_max_vehicle):\n if(new_max_vehicle == None):\n self._logger.write(\"Error! new_max_vehicle cannot be a NoneType\")\n elif(type(new_max_vehicle) != int):\n sel... | [
"0.6355313",
"0.62644476",
"0.61756676",
"0.6133707",
"0.60169375",
"0.58443147",
"0.5800573",
"0.57372534",
"0.57372534",
"0.5707722",
"0.5559721",
"0.55577517",
"0.5506668",
"0.5506668",
"0.54706883",
"0.5466889",
"0.5464387",
"0.54585886",
"0.54446185",
"0.5426552",
"0.542... | 0.82790416 | 0 |
Gets the minimum_health_capacity of this V2appsUpgradeStrategy. A number between 0 and 1 that is multiplied with the instance count. This is the minimum number of healthy nodes that do not sacrifice overall application purpose. Marathon will make sure, during the upgrade process, that at any point of time this number o... | def minimum_health_capacity(self):
return self._minimum_health_capacity | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minimum_health_capacity(self, minimum_health_capacity):\n self._minimum_health_capacity = minimum_health_capacity",
"def min_capacity(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"min_capacity\")",
"def min_capacity(self) -> Optional[pulumi.Input[str]]:\n return pul... | [
"0.6638245",
"0.62344915",
"0.62344915",
"0.62344915",
"0.60762584",
"0.60762584",
"0.6029936",
"0.5936676",
"0.59195393",
"0.58408344",
"0.58012384",
"0.5790563",
"0.5772729",
"0.5763091",
"0.57185423",
"0.57185423",
"0.57185423",
"0.57185423",
"0.57185423",
"0.57185423",
"0... | 0.78458744 | 0 |
Sets the minimum_health_capacity of this V2appsUpgradeStrategy. A number between 0 and 1 that is multiplied with the instance count. This is the minimum number of healthy nodes that do not sacrifice overall application purpose. Marathon will make sure, during the upgrade process, that at any point of time this number o... | def minimum_health_capacity(self, minimum_health_capacity):
self._minimum_health_capacity = minimum_health_capacity | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minimum_health_capacity(self):\n return self._minimum_health_capacity",
"def scale_min_capacity(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"scale_min_capacity\")",
"def scale_min_capacity(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"scale_min_... | [
"0.6954073",
"0.6120552",
"0.6120552",
"0.6073684",
"0.5860526",
"0.58378685",
"0.5817863",
"0.58121866",
"0.56785095",
"0.56785095",
"0.56785095",
"0.5632717",
"0.5602262",
"0.55589217",
"0.54112",
"0.53726214",
"0.5348369",
"0.53340715",
"0.53340715",
"0.53340715",
"0.53340... | 0.80831677 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.7961088",
"0.7961088",
"0.79433626",
"0.79303336",
"0.7926563",
"0.7897525",
"0.78826123",
"0.78826123",
"0.78806067",
"0.7872423",
"0.7868354",
"0.78668815",
"0.7825702",
"0.7819993",
"0.78162885",
"0.78078854",
"0.78068... | 0.79670393 | 51 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
The same as _fetch_results_dir defined above, but will return run directory, as a child directory to the results directory with the run_id name. At most one of backend/results_dir might be passed. If none is, nominal results directory is used. | def _fetch_run_dir(self, run_id, backend=None, results_dir=None):
results_dir = self._fetch_results_dir(backend=backend, results_dir=results_dir)
return os.path.join(results_dir, run_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fetch_results_dir(self, backend=None, results_dir=None):\n if backend is None and results_dir is not None:\n return results_dir\n elif backend is not None and results_dir is None:\n return Config().get_results_dir(backend)\n elif backend is None and results_dir is No... | [
"0.80836767",
"0.7007751",
"0.67803013",
"0.6696585",
"0.66036296",
"0.6493991",
"0.6411563",
"0.63786435",
"0.6353539",
"0.61759424",
"0.61106306",
"0.6028463",
"0.5882529",
"0.5869954",
"0.5833259",
"0.5808749",
"0.5660742",
"0.56550723",
"0.56528574",
"0.5643335",
"0.56230... | 0.8547342 | 0 |
A method to get production and consumption rates for all the volumetric reactions producing or consuming the species "sp". Positive values are volume production processes and negative values are volume consumption processes. The returned Series is sorted by descending values. | def get_volumetric_rates(sp, chemistry, rates_frame, annotate=False):
ResultsParser._assert_consistency(sp=sp, chemistry=chemistry, rates_frame=rates_frame)
sp_id = chemistry.get_rp(sp).id
stoichiomatrix = chemistry.get_stoichiomatrix(disabled=False, special=True, method='net')
# I'm cer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_surface_rates(sp, chemistry, model_params, wall_fluxes_frame, annotate=False):\n ResultsParser._assert_consistency(sp=sp, chemistry=chemistry, wall_fluxes_frame=wall_fluxes_frame)\n\n # surface rates do not make sense for special species, which do not get converted!\n if chemistry.get_... | [
"0.58945405",
"0.5540061",
"0.51905453",
"0.5135951",
"0.5074571",
"0.5038579",
"0.4976755",
"0.4922435",
"0.48829064",
"0.4836347",
"0.48075646",
"0.48002702",
"0.478819",
"0.47851408",
"0.47655484",
"0.47527915",
"0.47398123",
"0.4735167",
"0.47310278",
"0.47033834",
"0.470... | 0.6469927 | 0 |
Returns the value of the 'fileas' attribute of the first creator listed in the manifest file. If the attribute is not present, it returns the text value enclosed by the creator tag. | def author(self):
for item in self.metadata:
if item.tag.localname == "creator":
if 'file-as' in item.tag:
return item.tag['file-as']
else:
return item.tag.text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def creator(self) -> str:\n return pulumi.get(self, \"creator\")",
"def creator(self) -> str:\n return pulumi.get(self, \"creator\")",
"def fn(self):\n if not self.meta.get(\"FileName\"):\n self.meta[\"FileName\"] = self.tags[\"AccessionNumber\"]\n return self.meta.get('F... | [
"0.5881758",
"0.5881758",
"0.586475",
"0.5729594",
"0.5668894",
"0.5507867",
"0.5507867",
"0.5507867",
"0.5507867",
"0.5503164",
"0.5292945",
"0.52865165",
"0.5236233",
"0.5236233",
"0.5236233",
"0.5236233",
"0.5236233",
"0.5236233",
"0.518018",
"0.5179198",
"0.5179198",
"0... | 0.7854815 | 0 |
Returns the bytes of the favicon of this site | def fetch_favicon(url, retry=3):
favicon_url = get_favicon_url(url, retry=retry)
return fetch_url(favicon_url, retry=retry) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def favicon(self):\n return self._favicon",
"def favicon_url(self):\n return self.get_url(\"favicon\", \"images/favicon.png\")",
"def favicon():\n return ''",
"def fetch_favicon(self): \n favurl = \"%s://%s/favicon.ico\" % (self.urlparts.scheme, self.domain)\n r = requests.g... | [
"0.7765254",
"0.7606847",
"0.73426634",
"0.72743523",
"0.72126406",
"0.6926064",
"0.68181723",
"0.6716929",
"0.6563802",
"0.6533688",
"0.6515958",
"0.6448762",
"0.6347678",
"0.62884855",
"0.62279457",
"0.61547583",
"0.6099863",
"0.6078016",
"0.6057801",
"0.58463687",
"0.57795... | 0.5714963 | 22 |
Testing no of collection item ids available in given collection url | def test_get_collection_item_ids(self, mock_get):
# Arrange
mock_page1_result = MockResponse(mock_data.ITEM_IDS_DATA, 200)
mock_page2_result = MockResponse({}, 200)
mock_get.side_effect = [mock_page1_result, mock_page2_result]
# Act
response = get_collection_item_ids(sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_collection_item_ids_no_ids(self, mock_get):\n # Arrange\n mock_page1_result = MockResponse({}, 200)\n mock_page2_result = MockResponse({}, 200)\n mock_get.side_effect = [mock_page1_result, mock_page2_result]\n\n # Act\n response = get_collection_item_ids(self.... | [
"0.6904069",
"0.66909957",
"0.63645947",
"0.6326903",
"0.61733764",
"0.60338116",
"0.6008624",
"0.5951256",
"0.5929107",
"0.59081036",
"0.59020084",
"0.5882644",
"0.5865856",
"0.5825486",
"0.5798208",
"0.57418245",
"0.57267624",
"0.5726573",
"0.5719601",
"0.57115996",
"0.5691... | 0.6597615 | 2 |
Testing no of collection item ids not availabel collection url | def test_get_collection_item_ids_no_ids(self, mock_get):
# Arrange
mock_page1_result = MockResponse({}, 200)
mock_page2_result = MockResponse({}, 200)
mock_get.side_effect = [mock_page1_result, mock_page2_result]
# Act
response = get_collection_item_ids(self.url, 2)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_collection_no_asset_urls(self, mock_get):\n # Arrange\n mock_resp = MockResponse({}, 200)\n mock_get.return_value = mock_resp\n\n # Act\n response = get_collection_item_asset_urls(self.item_id)\n\n # Assert\n self.assertListEqual(response, [])",
"def ... | [
"0.654401",
"0.64490443",
"0.62408584",
"0.61988384",
"0.61750036",
"0.609602",
"0.600228",
"0.5864778",
"0.5820793",
"0.58032787",
"0.5764215",
"0.57594204",
"0.5744564",
"0.57374007",
"0.5734433",
"0.57323617",
"0.5727451",
"0.5725577",
"0.5693351",
"0.5683588",
"0.56652397... | 0.6164394 | 5 |
Testing no of collection item asset urls available in given item id | def test_get_collection_asset_urls(self, mock_get):
# Arrange
mock_resp = MockResponse(mock_data.COLLECTION_ITEM_URLS_DATA, 200)
mock_get.return_value = mock_resp
# Act
response = get_collection_item_asset_urls(self.item_id)
# Assert
self.assertListEqual(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_collection_no_asset_urls(self, mock_get):\n # Arrange\n mock_resp = MockResponse({}, 200)\n mock_get.return_value = mock_resp\n\n # Act\n response = get_collection_item_asset_urls(self.item_id)\n\n # Assert\n self.assertListEqual(response, [])",
"def ... | [
"0.7535087",
"0.59788144",
"0.59486926",
"0.5937698",
"0.5871058",
"0.5836033",
"0.5802878",
"0.5792013",
"0.5767495",
"0.5763955",
"0.5763064",
"0.57339627",
"0.57336396",
"0.5732366",
"0.5725953",
"0.571687",
"0.57039344",
"0.5703036",
"0.56883204",
"0.5673993",
"0.56607413... | 0.7122616 | 1 |
Testing no of collection item asset urls not available in given item id | def test_get_collection_no_asset_urls(self, mock_get):
# Arrange
mock_resp = MockResponse({}, 200)
mock_get.return_value = mock_resp
# Act
response = get_collection_item_asset_urls(self.item_id)
# Assert
self.assertListEqual(response, []) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_collection_asset_urls(self, mock_get):\n # Arrange\n mock_resp = MockResponse(mock_data.COLLECTION_ITEM_URLS_DATA, 200)\n mock_get.return_value = mock_resp\n\n # Act\n response = get_collection_item_asset_urls(self.item_id)\n\n # Assert\n self.assertLis... | [
"0.681002",
"0.6328567",
"0.61067283",
"0.6052613",
"0.5997696",
"0.59630543",
"0.595966",
"0.5901177",
"0.5899223",
"0.58304346",
"0.58248043",
"0.5822432",
"0.58203757",
"0.5813112",
"0.57811326",
"0.576888",
"0.57592297",
"0.57579416",
"0.57513845",
"0.5744528",
"0.5731538... | 0.73760736 | 0 |
Testing no of collection item asset urls available in given collection url | def test_download_write_collection_item_asstes(self, mock_get, mock_save):
# Arrange
collection = {
"collection_name": self.name,
"collection_slug": slugify(self.name),
"collection_task_id": "123",
"subcollection_name": self.project,
"subcolle... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_collection_no_asset_urls(self, mock_get):\n # Arrange\n mock_resp = MockResponse({}, 200)\n mock_get.return_value = mock_resp\n\n # Act\n response = get_collection_item_asset_urls(self.item_id)\n\n # Assert\n self.assertListEqual(response, [])",
"def ... | [
"0.7653996",
"0.7336379",
"0.64031714",
"0.6220773",
"0.6147619",
"0.6033041",
"0.587556",
"0.5831847",
"0.5816081",
"0.5810742",
"0.5807949",
"0.5783775",
"0.5754823",
"0.57312125",
"0.57204837",
"0.5692368",
"0.5655098",
"0.56114614",
"0.56058955",
"0.5597286",
"0.5589733",... | 0.0 | -1 |
Testing no of collection item asset urls available in given item id | def test_download_write_item_asstes(self, mock_get, mock_save):
# Arrange
collection = {
"collection_name": self.name,
"collection_slug": slugify(self.name),
"collection_task_id": "123",
"subcollection_name": self.project,
"subcollection_slug"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_collection_no_asset_urls(self, mock_get):\n # Arrange\n mock_resp = MockResponse({}, 200)\n mock_get.return_value = mock_resp\n\n # Act\n response = get_collection_item_asset_urls(self.item_id)\n\n # Assert\n self.assertListEqual(response, [])",
"def ... | [
"0.7535087",
"0.7122616",
"0.59788144",
"0.59486926",
"0.5937698",
"0.5871058",
"0.5836033",
"0.5802878",
"0.5792013",
"0.5767495",
"0.5763955",
"0.5763064",
"0.57339627",
"0.57336396",
"0.5732366",
"0.5725953",
"0.571687",
"0.57039344",
"0.5703036",
"0.56883204",
"0.5673993"... | 0.517821 | 90 |
Testing no of collection item asset urls available in given item id wiht no db entry in CollectionTaskDetails | def test_download_write_item_asstes_no_db_entry(self, mock_get, mock_save):
# Arrange
mock_resp = MockResponse(mock_data.COLLECTION_ITEM_URLS_DATA, 200)
mock_get.return_value = mock_resp
mock_save.return_value = None
# Act
download_write_item_assets(self.name, self.proje... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_collection_no_asset_urls(self, mock_get):\n # Arrange\n mock_resp = MockResponse({}, 200)\n mock_get.return_value = mock_resp\n\n # Act\n response = get_collection_item_asset_urls(self.item_id)\n\n # Assert\n self.assertListEqual(response, [])",
"def ... | [
"0.7041072",
"0.6606606",
"0.60610026",
"0.5857897",
"0.5840089",
"0.57437086",
"0.5669981",
"0.5644753",
"0.5573791",
"0.55395555",
"0.5521496",
"0.5520711",
"0.5503842",
"0.5501755",
"0.5497198",
"0.5492218",
"0.5483147",
"0.54656106",
"0.5455271",
"0.5426969",
"0.54160255"... | 0.6328421 | 2 |
Build a dictionary through a list of words | def buildDict(self, words):
for word in words:
self.word_set.add(word)
for candidate in self.candidates(word):
self.neighbors[candidate] += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_dict(word_list):\r\n\r\n # initialize a dictonary\r\n d = dict()\r\n\r\n # iterate through the word_list, mapping sorted letters to word\r\n for i in word_list:\r\n\r\n # key - sorted letters in the word\r\n # how to sort ? --> convert to list, then sort. Finally join the sorted... | [
"0.77699906",
"0.7715609",
"0.7666073",
"0.7590654",
"0.75074077",
"0.7402528",
"0.7372786",
"0.7257193",
"0.72470814",
"0.7220795",
"0.71518236",
"0.71224153",
"0.7089357",
"0.7033362",
"0.6941951",
"0.692757",
"0.6901821",
"0.6863035",
"0.68164855",
"0.68103427",
"0.6762273... | 0.69923383 | 14 |
Returns if there is any word in the trie that equals to the given word after modifying exactly one character | def search(self, word):
for candidate in self.candidates(word):
if self.neighbors[candidate] > 1:
return True
elif self.neighbors[candidate] == 1 and word not in self.word_set:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_word(trie, string: str) -> bool:\n return any(w == string for w in trie)",
"def search(self, word):\n curr = self.trie\n for i, ch in enumerate(word):\n curr = curr.get(ch, {})\n if curr:\n continue\n else:\n break\n \n... | [
"0.78987586",
"0.7713067",
"0.76827085",
"0.7650699",
"0.74977815",
"0.74953616",
"0.7492678",
"0.74721324",
"0.7441035",
"0.7440776",
"0.7415909",
"0.7413349",
"0.73969525",
"0.7383449",
"0.7365638",
"0.7334273",
"0.73318183",
"0.72946453",
"0.72943574",
"0.72771394",
"0.727... | 0.6652687 | 84 |
Get absolute path to resource, works for dev and for PyInstaller !!!THANK YOU STACK_OVERFLOW!!! | def resource_path(self, relative_path):
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_path, relative_path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource_path(relative_path) :\n\n try :\n # PyInstaller creates a temp folder and stores path in _MEIPASS\n base_path = sys._MEIPASS\n except :\n base_path = os.path.abspath(\".\")\n return os.path.join(base_path, relative_path)",
"def resourcePath(relative):\r\n try:\r\n ... | [
"0.8318081",
"0.8296801",
"0.8246657",
"0.8175339",
"0.8148962",
"0.8146455",
"0.81354916",
"0.81279325",
"0.81171346",
"0.81169724",
"0.8116567",
"0.8116087",
"0.8116087",
"0.8116087",
"0.8116087",
"0.8116087",
"0.8116087",
"0.8116087",
"0.81148094",
"0.8109839",
"0.8109839"... | 0.76113206 | 52 |
Calculate the directivity for a pyramidal horn. | def directivity(horn_width, horn_height, eplane_effective_length, hplane_effective_length, frequency):
# Calculate the wavelength
wavelength = c / frequency
# Calculate the arguments for the Fresnel integrals
u = 1.0 / sqrt(2.0) * (sqrt(wavelength * hplane_effective_length) / horn_width +
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def directivity(self) -> int:\n return self._directivity",
"def calc_directivity(dire, alpha, Lambda_y, beta, omega, c, f, dir_meas, dir_meas_deg, n):\n if dire == 'Circular Piston':\n R_circ = alpha * Lambda_y / 2\n with np.errstate(invalid='ignore', divide='ignore'):\n H_post... | [
"0.618278",
"0.5666809",
"0.56508255",
"0.56410545",
"0.5546424",
"0.55103517",
"0.54803956",
"0.54742706",
"0.54589415",
"0.5452148",
"0.5426667",
"0.54149616",
"0.538793",
"0.5386051",
"0.53833735",
"0.53763276",
"0.5364096",
"0.53433466",
"0.53235686",
"0.5320168",
"0.5318... | 0.0 | -1 |
Closes the BertClient connection to BertServer | def end(self):
self._bc.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closeConnecetion(self):\n client.close()",
"def close(self):\n self._client.close()\n self._transport.close()",
"def close(self):\n if self.client:\n self.client.connection.close()\n self.client = None",
"def close(self) -> None:\n if self.client is No... | [
"0.7510907",
"0.7075644",
"0.6985471",
"0.68227196",
"0.66258734",
"0.6622013",
"0.65964663",
"0.658709",
"0.6576201",
"0.6552941",
"0.6538077",
"0.652239",
"0.65165234",
"0.65164506",
"0.6514529",
"0.6514486",
"0.6503944",
"0.64714724",
"0.64712316",
"0.6464942",
"0.6444812"... | 0.0 | -1 |
Load the App's Home tab. | def load_app_home(user_id):
ticket_ids = []
tickets = []
user = user_profile(user_id)
if user['ok']:
email = user['user']['profile']['email']
ticket_ids = sorted(rt_api.simple_ticket_search(requestor=email, status="__Active__"), reverse=True)
for ticket_id in ticket_ids:
tic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def go_to_home_application(self):\n self.parent.show()\n self.hide()",
"def goHome():\n\t#Go to pod home\n\tif screen.lastScreen in screen.protectedScreens:\n\t\tpodScreen.show()\n\telse:\n\t\tsplashScreen.show()",
"def go_home(self):\r\n if self.home_url is not None:\r\n self.s... | [
"0.7048857",
"0.6937351",
"0.6875719",
"0.68368715",
"0.65984756",
"0.6447604",
"0.6445646",
"0.6391582",
"0.6389873",
"0.6270182",
"0.62523764",
"0.623332",
"0.61885756",
"0.61685574",
"0.6158028",
"0.6116955",
"0.6105745",
"0.60986906",
"0.6090661",
"0.6034473",
"0.6033202"... | 0.57187855 | 57 |
Same as x(), including the effect of offset and muloffset on output. | def x_offsets(self, **kwargs):
reserved = ['minmax', '0max']
special = None
x = self.x(**kwargs)
offset = self.attr('offset', None)
if offset is not None:
o = offset[0] if isinstance(offset, list) else 0
if isinstance(o, str):
if o in reser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def OffsetX(*args, **kwargs):\n return _gdi_.NativePixelData_Accessor_OffsetX(*args, **kwargs)",
"def OffsetX(*args, **kwargs):\n return _gdi_.AlphaPixelData_Accessor_OffsetX(*args, **kwargs)",
"def pos_x(self, *args, **kwargs) -> Any:\n pass",
"def setXOffset(self, *args):\n retu... | [
"0.7001128",
"0.6999453",
"0.69734776",
"0.6967133",
"0.67032915",
"0.66408384",
"0.6553602",
"0.65299004",
"0.650492",
"0.64821553",
"0.64821553",
"0.64821553",
"0.64821553",
"0.64821553",
"0.64821553",
"0.64821553",
"0.64821553",
"0.64821553",
"0.64821553",
"0.64821553",
"0... | 0.70429236 | 0 |
Returns the x data. | def x(self, index=np.nan, alter='', xyValue=None, errorIfxyMix=False, neutral=False):
if alter != '':
if alter == 'nmeV':
# invert order of xyValue, to help for graph xlim and ylim
if xyValue is not None:
xyValue = np.array(xyValue)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data(self):\n return getXarray(self.__mdsnode__,strict=self.__strict__)",
"def x(self):\n return self._data[0]",
"def x_data(self):\n if not self.__applied:\n self.__apply_accumulators()\n return self.__xdata",
"def GetX(self):\r\n\r\n return self._x",
"def... | [
"0.8107276",
"0.79952973",
"0.7989443",
"0.75255966",
"0.7445135",
"0.74287343",
"0.7335098",
"0.7325699",
"0.7270629",
"0.7158081",
"0.7145937",
"0.7145937",
"0.7145937",
"0.7145937",
"0.7145937",
"0.7145937",
"0.7145937",
"0.7145937",
"0.7145937",
"0.7145937",
"0.7145937",
... | 0.0 | -1 |
Returns the y data. | def y(self, index=np.nan, alter='', xyValue=None, errorIfxyMix=False, neutral=False):
# if some alteration required: make operation on data requested by
# itself, without operation
if alter != '':
if alter == 'log10abs':
jsc = self.attr('Jsc') if self.attr('Jsc') != ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_y_data(self):\n return self.y(self.xs)",
"def ydata(self):\n return self._ydata",
"def y(self):\n return self._data[1]",
"def y_data(self):\n if not self.__applied:\n self.__apply_accumulators()\n return self.__ydata",
"def y(self):\n return sel... | [
"0.8950273",
"0.8909771",
"0.83912134",
"0.8298615",
"0.8284316",
"0.8128603",
"0.80454874",
"0.7956152",
"0.78963536",
"0.7821887",
"0.780163",
"0.779564",
"0.7728187",
"0.7717617",
"0.7717617",
"0.7717617",
"0.7717617",
"0.7717617",
"0.7717617",
"0.7717617",
"0.7717617",
... | 0.0 | -1 |
Legacy getter of attribute | def getAttribute(self, key, default=''):
return self.attr(key, default=default) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getattr__(self, attr):\n return self.get(attr)",
"def get_attribute(self, name):\n\n pass",
"def get_attribute(self, attr):\n super().get_attribute(attr) # Keep this line, it triggers the parent class method.\n return getattr(self, attr)",
"def get(self, att):\n retu... | [
"0.798612",
"0.79735875",
"0.7805334",
"0.76515526",
"0.7629522",
"0.7627099",
"0.7480565",
"0.74779737",
"0.74747866",
"0.74747866",
"0.7469613",
"0.7464983",
"0.7463307",
"0.7463307",
"0.74413687",
"0.74391073",
"0.7365741",
"0.73519593",
"0.73252493",
"0.7317242",
"0.73172... | 0.0 | -1 |
Given an index in the Curve data, returns a modified data which has some sense to the user. Is overloaded in some child Curve classes, see for example CurveCf If strDescription is True, then returns a string which describes what this method is doing. | def getDataCustomPickerXY(self, idx, alter='', strDescription=False):
if strDescription:
return '(x,y) data with offset and transform'
if isinstance(alter, str):
alter = ['', alter]
attr = {}
return (self.x_offsets(index=idx, alter=alter[0]),
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def curve(self, index):\n if index >= len(self) or len(self) == 0:\n print('ERROR Class Graph method Curve: cannot find Curve (index',\n index, ', max possible', len(self), ')')\n return\n return self.data[index]",
"def __getitem__(self, index):\n ind =... | [
"0.62826306",
"0.57250136",
"0.5723747",
"0.56971",
"0.559068",
"0.55228966",
"0.5518181",
"0.5489106",
"0.54572964",
"0.54300255",
"0.5426397",
"0.5370641",
"0.5368358",
"0.5368358",
"0.536242",
"0.5357312",
"0.5341563",
"0.5339272",
"0.5339272",
"0.53289413",
"0.5308285",
... | 0.49819675 | 51 |
Check the given 'categories' exist | def _check_categories(categories: list) -> bool:
categories_count = Category.objects.all() \
.filter(id__in=categories) \
.distinct().count()
if categories_count != len(set(categories)):
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _verify_basic_categories(self):\n for cat in CATEGORIES:\n if not Category.objects.filter(name=cat).exists():\n self.add_category(cat)",
"def category_exists(self, category: str) -> bool:\n return all(category in self.data[letter] for letter in self.data)",
"def test_get... | [
"0.7865186",
"0.7413959",
"0.71073216",
"0.6967679",
"0.67952543",
"0.67169356",
"0.67024523",
"0.66450167",
"0.66322666",
"0.6590427",
"0.65761447",
"0.6563388",
"0.65604395",
"0.6512943",
"0.6481562",
"0.6468809",
"0.64576155",
"0.6453508",
"0.6439076",
"0.6406985",
"0.6371... | 0.77250004 | 1 |
Returns the current state from the environment. The current state is the last environment observation optionally processed by the obs_hook. | def current_state(self):
return self.obs_hook(self._current_obs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state(self):\r\n return self.currentObservation",
"def get_state(self):\n return self._env.get_state()",
"def getObservation(self):\n return self._cur_state",
"def get_current_state(self):\n return self.world.get_state()",
"def _get_obs(self):\n return self.observ... | [
"0.7642118",
"0.7438743",
"0.7378617",
"0.7282528",
"0.7153013",
"0.71044976",
"0.7097995",
"0.69626004",
"0.6959068",
"0.6855924",
"0.67864376",
"0.6777616",
"0.67464614",
"0.6734189",
"0.6706248",
"0.6693671",
"0.66870767",
"0.66200036",
"0.6609841",
"0.6609841",
"0.6609841... | 0.81486917 | 0 |
Returns True if this object's admin form has at least one of the given field_type (e.g. FileField). | def has_field_type(self, field_type):
if not hasattr(self, '_field_types'):
self._field_types = {}
if not self._field_types.has_key(field_type):
try:
# First check self.fields.
for f in self.fields:
if isinstance(f, field_type):... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_multipart(self):\n for field in self.fields.values():\n if field.widget.needs_multipart_form:\n return True\n return False",
"def has_field(self, field):\n return field in self.extra_fields",
"def is_valid_field(self, field: DSLSelectable) -> bool:\n\n ... | [
"0.65298486",
"0.6524098",
"0.61010647",
"0.60757464",
"0.60438436",
"0.6036546",
"0.5968335",
"0.593395",
"0.59040415",
"0.5821903",
"0.58143944",
"0.5793632",
"0.57448184",
"0.5743549",
"0.57411057",
"0.56777686",
"0.5669897",
"0.5609508",
"0.5601394",
"0.5574921",
"0.55548... | 0.6878717 | 0 |
Nodes a and b share an edge add the edge to the data structure. | def union(self, a, b):
if (a in self.node_id) and (b in self.node_id) and (self.node_id[a] != self.node_id[b]):
self.merge(a, b)
elif (a in self.node_id) or (b in self.node_id):
self.add(a,b)
else:
self.create_new_group(a,b) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addEdge(this, a, b):\n if not a in this.m:\n this.m[a]=set()\n this.m[a].add(b)",
"def add_edge_between(self, a: tuple, b: tuple):\n if a not in self.graph:\n self.graph[a] = set()\n if b not in self.graph:\n self.graph[b] = set()\n self.graph[a].add(b)\n... | [
"0.8146868",
"0.7963319",
"0.77699476",
"0.76428115",
"0.7472739",
"0.73616576",
"0.73306245",
"0.7313536",
"0.72943425",
"0.7257468",
"0.71834683",
"0.7162399",
"0.715093",
"0.7147865",
"0.7141861",
"0.7117082",
"0.7110188",
"0.7108705",
"0.7106769",
"0.7099276",
"0.70880306... | 0.0 | -1 |
Sets the learning rate to the initial LR decayed by 10 every 30 epochs | def poly_adjust_learning_rate(optimizer, lr0, step, n_step):
lr = lr0 * (1.0 - step*1.0/n_step)
for param_group in optimizer.param_groups:
param_group['lr'] = lr
return lr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_learning_rate(init_lr, optimizer, epoch, n=100):\n init_lr = init_lr * (0.1 ** (epoch // n))\n print('learning rate : ', init_lr)\n for param_group in optimizer.param_groups:\n param_group['lr'] = init_lr",
"def adjust_learning_rate(start_lr, optimizer, epoch, total_epoch_num):\n #l... | [
"0.7913536",
"0.7906521",
"0.7849834",
"0.777524",
"0.77338326",
"0.77306354",
"0.7722718",
"0.77224237",
"0.771982",
"0.77092624",
"0.7693604",
"0.76742035",
"0.7665748",
"0.7665748",
"0.7665748",
"0.7655329",
"0.76419765",
"0.76399755",
"0.7637868",
"0.7626077",
"0.76247585... | 0.0 | -1 |
Sets the learning rate to the initial LR decayed by 10 every 30 epochs | def step_adjust_learning_rate(optimizer, lr0, step, step_size, gamma):
if len(step_size) == 0:
lr = lr0 * (gamma ** (step // step_size))
else:
lr = lr0 * gamma ** (sum([step > i for i in step_size]))
for param_group in optimizer.param_groups:
param_group['lr'] = lr
return lr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_learning_rate(init_lr, optimizer, epoch, n=100):\n init_lr = init_lr * (0.1 ** (epoch // n))\n print('learning rate : ', init_lr)\n for param_group in optimizer.param_groups:\n param_group['lr'] = init_lr",
"def adjust_learning_rate(start_lr, optimizer, epoch, total_epoch_num):\n #l... | [
"0.79138637",
"0.7907123",
"0.78501725",
"0.77759194",
"0.77345806",
"0.77311844",
"0.7723001",
"0.77227825",
"0.772003",
"0.7709925",
"0.76942194",
"0.7674993",
"0.7666409",
"0.7666409",
"0.7666409",
"0.7654975",
"0.7642442",
"0.764",
"0.7638515",
"0.7626761",
"0.7625353",
... | 0.0 | -1 |
Computes the precision for the specified values of k | def accuracy(output, target, topk=(1,)):
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
correct_k = correct[:k].view(-1).float().sum(0)
res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\... | [
"0.76427615",
"0.74189496",
"0.7418079",
"0.72710466",
"0.72456723",
"0.72446615",
"0.7237539",
"0.72213703",
"0.7210107",
"0.7058935",
"0.6852219",
"0.6786084",
"0.67836976",
"0.6768417",
"0.67273885",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.... | 0.0 | -1 |
Retrieves a string representation of the package status. Relates to section F of the requirements. | def status_by_package_id(self, package_id):
return self._delivery_service.package_status(int(package_id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_status_as_string(self):\n if self.downloaded == 0:\n return \"[Starting... ]\"\n return \"[%s, %s, %s]\" % self.get_status()",
"def _get_status(self):\n return u'%s' % (self.get_status_display())",
"def detailed_status(self) -> pulumi.Output[str]:\n return pulumi.... | [
"0.71626514",
"0.6997189",
"0.6878268",
"0.6878268",
"0.68320113",
"0.6830941",
"0.6830941",
"0.67950886",
"0.6783765",
"0.6783765",
"0.6783765",
"0.6783765",
"0.6783765",
"0.6783765",
"0.6783765",
"0.6783765",
"0.6783765",
"0.6783765",
"0.6783765",
"0.6783765",
"0.6783765",
... | 0.0 | -1 |
Returns the minimax action using self.depth and self.evaluationFunction | def getAction(self, gameState):
"*** YOUR CODE HERE ***"
# For this problem we will be reusing the majority of our work from question 2, but we will be
# implementing alpha-beta pruning on top of our existing minimax infrastructure
actionList = gameState.getLegalActions(0)
pacman... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAction(self, gameState: GameState):\n _max = float(\"-inf\")\n action = None\n for move in gameState.getLegalActions(0):\n util = minimax(self.evaluationFunction, 1, 0,\n gameState.generateSuccessor(0, move), self.depth)\n if util > _max o... | [
"0.7482982",
"0.73845285",
"0.7181575",
"0.71107405",
"0.70889926",
"0.70698124",
"0.70696664",
"0.70484525",
"0.7005484",
"0.69664097",
"0.69640785",
"0.69612634",
"0.69459844",
"0.68992436",
"0.6896572",
"0.6886153",
"0.6827345",
"0.67672485",
"0.67579806",
"0.6752876",
"0.... | 0.6663393 | 25 |
Get player with the given name. | def get(name: str) -> dict:
player = graphql("""
query ($name: String!) {
getPlayer(name: $name) {
name
clan {
name
}
}
}
""", {
'name': name,
}
)['getPlayer']
return pl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_player(self, player_name):\n return self._collection.find_one({'name': player_name})",
"def find_player(self, name):\n for index in range(0, len(self.player_list)):\n if self.player_list[index].name == name:\n return self.player_list[index]",
"def get_player(pla... | [
"0.84272826",
"0.82339275",
"0.8024249",
"0.7683846",
"0.76587564",
"0.7602995",
"0.7510318",
"0.74664646",
"0.7370733",
"0.7318315",
"0.7076412",
"0.7060022",
"0.7052386",
"0.6998766",
"0.696483",
"0.6954607",
"0.69478905",
"0.68639946",
"0.6822522",
"0.6788078",
"0.67383355... | 0.6551747 | 29 |
Apply a multivariate function to a list of arguments in a distributed fashion. Uses Apache Spark's map() and collect() functions provided by a resilient distributed dataset (RDD). | def spark(function, argument_list):
if _cluster_setup.spark._connection is None:
error_message = (
'No connection ("context") was established to a Spark scheduler ("master") that '
'distributes jobs to workers ("slaves"). '
"Please use unified_map.cluster_setup.spark and/... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multi_apply(func, *args, **kwargs):\n\n pfunc = partial(func, **kwargs) if kwargs else func\n map_results = map(pfunc, *args)\n return tuple(map(list, zip(*map_results)))",
"def map(self, func, args_list):\n for args in args_list:\n self.add_task(func, args)",
"def map(self, func... | [
"0.7013394",
"0.67897797",
"0.67897797",
"0.67897797",
"0.67897797",
"0.67897797",
"0.67401904",
"0.663029",
"0.6341223",
"0.631325",
"0.6276779",
"0.62688166",
"0.6231729",
"0.6218795",
"0.6177423",
"0.6157222",
"0.6155667",
"0.6112402",
"0.61121416",
"0.6021264",
"0.5998994... | 0.66243523 | 8 |
Get the name of the current hash_table | def get_current_hash_table(conn):
# get the number
q = "SELECT cnt FROM num_hash_tables LIMIT 1"
res = conn.execute(q)
num_tables = res.fetchone()[0]
return 'hashes' + str(num_tables + 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table_name(self):\n return self._new_table.name",
"def get_table_name(self):\n return self._table",
"def table_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"table_name\")",
"def name(self) -> str:\n return f\"lookup_table_{self.table_number}\"",
"def table(se... | [
"0.743976",
"0.74046886",
"0.7403458",
"0.739508",
"0.71723133",
"0.69462574",
"0.6925788",
"0.68860376",
"0.68860376",
"0.68860376",
"0.6801599",
"0.6788476",
"0.6725935",
"0.67089486",
"0.6663271",
"0.661204",
"0.65686953",
"0.65484923",
"0.65484923",
"0.65484923",
"0.65484... | 0.70763487 | 5 |
Loads saved weights into the model | def load(self, path):
with path.open('rb') as f:
weights = torch.load(f)
load_model_from_dict(self.align, weights)
# model_params = dict(self.align.named_parameters())
# model_keys = sorted(model_params.keys())
# print(model_keys)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_model_weights(self):\n raise NotImplementedError",
"def load_model_weights(self, filename):\n self.model.load_weights(filename)",
"def load_model(self):\n saved_path = self.config.path_tmp / self.model.model_name\n if saved_path.exists():\n self.model.load_weight... | [
"0.8584854",
"0.8051734",
"0.7975459",
"0.7843039",
"0.78217083",
"0.7783254",
"0.7780757",
"0.77486104",
"0.77474076",
"0.76526576",
"0.76364684",
"0.7628087",
"0.7606195",
"0.7592399",
"0.7569124",
"0.75608027",
"0.7512203",
"0.74789596",
"0.7412149",
"0.74093217",
"0.73599... | 0.0 | -1 |
Initialize the last level of the submodule by copying the trained weights of the previous level. If the submodule has only one level, this does nothing. | def init_last(self):
if len(self.aligners) > 1:
state_dict = self.aligners[-2].state_dict()
self.aligners[-1].load_state_dict(state_dict)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_weights(self):\n tf.nest.map_structure(\n weights_initializer.WeightsInitializer.initialize_layer_or_model,\n self._layer_nest)",
"def init_weights(self):\n with torch.no_grad():\n self._init_weights()",
"def init_weights(self):\n # Initialize weights\n ... | [
"0.6555308",
"0.65542924",
"0.6516142",
"0.6435867",
"0.6367791",
"0.6320743",
"0.6299895",
"0.6299895",
"0.6244288",
"0.624122",
"0.61636996",
"0.61531466",
"0.613866",
"0.61125994",
"0.60946697",
"0.60602593",
"0.6050328",
"0.6047783",
"0.6025299",
"0.5995144",
"0.59872377"... | 0.0 | -1 |
The ratio of the pixel size of the submodule's highest level to the pixel size at its lowest level. By assumption, each level of the network has equal ability, so this is a measure of the power of the submodule to detect and correct large misalignments in its input scale. | def pixel_size_ratio(self):
return 2**(self.levels[-1] - self.levels[0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bw_ratio(self):\r\n bw = self.bwstats.mean\r\n if bw == 0.0: return 0\r\n else: return self.bw/(1024.*bw)",
"def adv_ratio(self): # XXX\r\n bw = StatsRouter.global_bw_mean\r\n if bw == 0.0: return 0\r\n else: return self.bw/bw",
"def calculateRatio(levelDims):\n highestReso = np.asarra... | [
"0.7090294",
"0.69187427",
"0.6845626",
"0.68056935",
"0.6804496",
"0.6689286",
"0.6546418",
"0.6481675",
"0.6480454",
"0.64782405",
"0.64707774",
"0.64487565",
"0.64093184",
"0.6394367",
"0.63651735",
"0.6363298",
"0.63385826",
"0.6244807",
"0.6220742",
"0.6217956",
"0.61915... | 0.8347412 | 0 |
Constructor for bilstm model | def __init__(self,
config,
is_training,
input_ids,
input_length,
scope=None):
if not is_training: # 如果是training则设置dropout为0
config.hidden_dropout_prob = 0.0
# if config.use_pretrained_embedding != '':
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, input_size, hidden_size, num_layers=1, num_classes=2, device=None):\n super(BiRNN, self).__init__()\n self.device = device\n self.hidden_size = hidden_size\n self.num_layers = num_layers\n self.lstm = nn.LSTM(input_size, hidden_size, num_layers, batch_first=Tru... | [
"0.6946383",
"0.6768358",
"0.66468894",
"0.6636445",
"0.66240674",
"0.661152",
"0.6581458",
"0.65509546",
"0.65425116",
"0.6492243",
"0.64898944",
"0.64890593",
"0.6465945",
"0.64503247",
"0.64472294",
"0.6425319",
"0.6422641",
"0.6419229",
"0.6404975",
"0.6390169",
"0.638796... | 0.0 | -1 |
Extract velocity (delta) and acceleration (deltadelta) of MFCC | def extract_deltas_of_mfccs(data_list: List[AudioData]) -> List[AudioData]:
result = []
for audio_data in data_list:
mfccs = audio_data.features.mfccs
if mfccs is None:
warnings.warn("MFCCS is None. Ignoring.", RuntimeWarning)
else:
first_col = numpy.reshape(numpy... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delta_coeffs(self, mfcc_seq):\n\n length = mfcc_seq.shape[1]\n deltas = np.empty(mfcc_seq.shape)\n deltas2 = np.empty(mfcc_seq.shape)\n\n for (coeff, samp), value in np.ndenumerate(deltas):\n if samp == 0 or samp == length-1:\n deltas[coeff, samp] = 0\n ... | [
"0.6925445",
"0.60472375",
"0.5825626",
"0.5779192",
"0.574993",
"0.5702058",
"0.56942064",
"0.56308836",
"0.560489",
"0.5593632",
"0.5593474",
"0.5593474",
"0.55859834",
"0.55846334",
"0.55585855",
"0.5551218",
"0.55039656",
"0.5503926",
"0.5503592",
"0.55031115",
"0.5497280... | 0.6318472 | 1 |
Returns `True` if the pmf is valid and `False` otherwise. | def is_pmf(pmf, ops):
try:
validate_normalization(pmf, ops)
except InvalidNormalization:
return False
try:
validate_probabilities(pmf, ops)
except InvalidProbability:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_pmf(pmf, ops):\n validate_normalization(pmf, ops)\n validate_probabilities(pmf, ops)\n return True",
"def valid(self):\n try:\n if self.getPret() > 0 and self.getAn() > 0 and self.validProgram(self.getProgram()):\n return True\n except:\n r... | [
"0.72629184",
"0.683525",
"0.67881906",
"0.66712445",
"0.6650179",
"0.6612086",
"0.655477",
"0.6534502",
"0.65112597",
"0.6476417",
"0.64688957",
"0.64662915",
"0.64555866",
"0.6453171",
"0.6413354",
"0.64053214",
"0.6337531",
"0.63033265",
"0.6303076",
"0.629972",
"0.6294986... | 0.75679886 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.