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 |
|---|---|---|---|---|---|---|
The id of the sensor. | def unique_id(self):
return f"octopus_energy_gas_{self._serial_number}_{self._mprn}_previous_accumulative_cost_override_tariff" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unique_id(self):\n return self.device_id + '_' + self._sensor_type",
"def unique_id(self):\n id = \"{}{}{}\".format(\n DOMAIN, self._account, self.sensorName.lower().replace(\" \", \"\")\n )\n return id",
"def entity_id(self):\n return 'sensor.{}_{}'.format(sel... | [
"0.81542426",
"0.7885806",
"0.7845372",
"0.7695466",
"0.7657747",
"0.7657747",
"0.7657747",
"0.7657747",
"0.7657747",
"0.7657747",
"0.7657747",
"0.7657747",
"0.7657747",
"0.7657747",
"0.7657747",
"0.7657747",
"0.7657747",
"0.7657747",
"0.7657747",
"0.7657747",
"0.7657747",
... | 0.0 | -1 |
Name of the sensor. | def name(self):
return f"Gas {self._serial_number} {self._mprn} Previous Cost Override Tariff" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return self._sensor.name",
"def name(self):\n return f\"{self._name} {SENSOR_TYPES[self.sensor][0]}\"",
"def get_sensor_name(self):\n return self.data[1]",
"def name(self):\n return self.device.device_data[self.device_id]['name'] + \\\n f' {self._senso... | [
"0.9250166",
"0.90057385",
"0.89274466",
"0.8871892",
"0.8865032",
"0.8857324",
"0.85477203",
"0.85042745",
"0.8349108",
"0.8343337",
"0.82704717",
"0.8116982",
"0.7734933",
"0.7707925",
"0.76887643",
"0.7471656",
"0.7456977",
"0.7451284",
"0.7451284",
"0.7451284",
"0.7438701... | 0.0 | -1 |
Returns the name of the base image given a path to a docker file. | def get_base_docker_image(docker_file):
with open(docker_file) as f:
from_line = next(
line for line in f.read().split("\n") if line.startswith("FROM")
)
_from, base_image = from_line.split()
return base_image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def docker_image_name(self):\n raise NotImplementedError",
"def base_name(path):\n return os.path.basename(path)",
"def get_base_name(path):\n return os.path.basename(path).split('.')[0]",
"def __get_docker_file_path(path):\n if os.path.isfile(path):\n return path\n for dc_filename ... | [
"0.67118734",
"0.6431263",
"0.64250034",
"0.63595366",
"0.62548035",
"0.62206465",
"0.61929166",
"0.61649895",
"0.6095284",
"0.6067912",
"0.60411924",
"0.60336626",
"0.6005952",
"0.59286785",
"0.59183544",
"0.589465",
"0.5819696",
"0.57935494",
"0.57801765",
"0.5728594",
"0.5... | 0.7747933 | 0 |
Recall metric. Only computes a batchwise average of recall. Computes the recall, a metric for multilabel classification of how many relevant items are selected. | def recall(y_true, y_pred):
true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))
possible_positives = K.sum(K.round(K.clip(y_true, 0, 1)))
recall = true_positives / (possible_positives + K.epsilon())
return recall | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recall(y_true, y_pred, average, labels):\n\n y_true, y_pred = check_metric_args(y_true, y_pred, average, labels)\n\n result = None\n\n m = len(y_true)\n n = len(labels)\n\n confusion_matrix = get_confusion_matrix(y_true, y_pred, labels).T\n\n if average == \"micro\":\n numerator = np.t... | [
"0.76051724",
"0.74478096",
"0.7403709",
"0.7280632",
"0.72094977",
"0.71655965",
"0.71574295",
"0.7144915",
"0.7144915",
"0.7144915",
"0.7144915",
"0.7144915",
"0.7144915",
"0.7131453",
"0.71006256",
"0.70658225",
"0.7064264",
"0.70625037",
"0.70625037",
"0.70625037",
"0.706... | 0.70967335 | 30 |
Precision metric. Only computes a batchwise average of precision. Computes the precision, a metric for multilabel classification of how many selected items are relevant. | def precision(y_true, y_pred):
true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))
predicted_positives = K.sum(K.round(K.clip(y_pred, 0, 1)))
precision = true_positives / (predicted_positives + K.epsilon())
return precision | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(self):\n self.overall_precision = precision_score(\n self.y_true, self.y_pred, average = self.average_type).round(self.digits_count_fp)\n self.classes_precision = precision_score(\n self.y_true, self.y_pred, average = None).round(self.digits_count_fp)",
"def comp... | [
"0.74902284",
"0.7288312",
"0.71594113",
"0.7153371",
"0.7066212",
"0.698771",
"0.69665945",
"0.6955136",
"0.69132286",
"0.6835471",
"0.68181765",
"0.6809777",
"0.6805386",
"0.6805386",
"0.6805386",
"0.6805386",
"0.6805386",
"0.6805386",
"0.67860866",
"0.6758023",
"0.6758023"... | 0.6755406 | 46 |
Sets the value of merchant transaction id | def set_merchant_transaction_id(self, transaction_id):
self.merchant_transaction_id = transaction_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merchant_id(self, merchant_id):\n\n self._merchant_id = merchant_id",
"def transaction_id(self, transaction_id):\n\n self._transaction_id = transaction_id",
"def transaction_id(self, transaction_id):\n\n self._transaction_id = transaction_id",
"def set_AWSMerchantId(self, value):\n ... | [
"0.7554464",
"0.73930633",
"0.73930633",
"0.67346406",
"0.65843433",
"0.64936",
"0.62641764",
"0.62107474",
"0.6053218",
"0.60430235",
"0.58392227",
"0.57985413",
"0.57985413",
"0.5754542",
"0.573174",
"0.57255185",
"0.5675832",
"0.56598693",
"0.56463534",
"0.5619233",
"0.561... | 0.838844 | 0 |
Sets the value of reference id | def set_reference_id(self, reference_id):
self.reference_id = reference_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reference_id(self, reference_id):\n\n self._reference_id = reference_id",
"def _set_id(self, value):\n pass",
"def setReferenceId(self, *args):\n return _libsbml.ReferenceGlyph_setReferenceId(self, *args)",
"def set_id(self, refobj, identifier):\n cmds.setAttr(\"%s.identifier\... | [
"0.8207478",
"0.7747637",
"0.77244306",
"0.7660497",
"0.7592674",
"0.7508247",
"0.7439932",
"0.7418604",
"0.7323189",
"0.7252635",
"0.7055553",
"0.70419794",
"0.70278186",
"0.7004229",
"0.6998189",
"0.69893235",
"0.69533867",
"0.6925184",
"0.690119",
"0.690119",
"0.690119",
... | 0.83304 | 0 |
Return a copy of the dictionary's list of (key, value) pairs. | def get_all_keys(self):
r = []
with self.lock:
for key in self.keys():
if self.get(key):
r.append(key)
return r | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __dic2list(self,dic):\n return [(x,dic[x]) for x in dic]",
"def __dic2list(self,dic):\n\treturn map(lambda x:[x,dic[x]],dic)",
"def dictToLst(dictionary):\n keys = []\n values = []\n for key, value in dictionary.iteritems():\n keys.append(key)\n val... | [
"0.7185825",
"0.70879525",
"0.70782435",
"0.7045188",
"0.6948525",
"0.6946181",
"0.69349754",
"0.69193006",
"0.6917234",
"0.6885191",
"0.6838708",
"0.67713344",
"0.67195135",
"0.67195135",
"0.67195135",
"0.66976666",
"0.66877514",
"0.66877514",
"0.66820794",
"0.6669205",
"0.6... | 0.0 | -1 |
Verify that protocol and domain get removed for https. | def test_https(self):
r = self.r.post('/users/login',
{'next': 'https://su.mo.com/kb/new?f=b'})
eq_('/kb/new?f=b', get_next_url(r)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_nossl(request):\n if request.scheme == 'http':\n return True\n else:\n return False",
"def https(url):\n if url[:8] == 'https://':\n return url\n if url[:7] != 'http://':\n return False\n return 'https://' + url[7:]",
"def is_https_url(value):\n url = ur... | [
"0.7038004",
"0.7010072",
"0.69712543",
"0.69538397",
"0.66122985",
"0.6592762",
"0.6550432",
"0.6424503",
"0.63799495",
"0.63720006",
"0.6259424",
"0.6252115",
"0.62439805",
"0.61718243",
"0.61521494",
"0.6138009",
"0.6026733",
"0.6026651",
"0.6010846",
"0.59526217",
"0.5947... | 0.5288132 | 92 |
Verify that protocol and domain get removed for http. | def test_http(self):
r = self.r.post('/users/login',
{'next': 'http://su.mo.com/kb/new'})
eq_('/kb/new', get_next_url(r)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_http_url(form, value):\n scheme, netloc = urlparse.urlparse(value)[:2]\n if scheme not in ('http', 'https') or not netloc:\n raise forms.ValidationError(_(u'A valid HTTP URL is required.'))",
"def filter_nossl(request):\n if request.scheme == 'http':\n return True\n else:\n ... | [
"0.6658824",
"0.6591031",
"0.65440965",
"0.6543921",
"0.6436345",
"0.6296734",
"0.62924564",
"0.6281631",
"0.6264946",
"0.62169707",
"0.62075204",
"0.619762",
"0.61972237",
"0.6185842",
"0.61785316",
"0.6158402",
"0.61504245",
"0.6134108",
"0.6097925",
"0.6090806",
"0.6080563... | 0.0 | -1 |
Constructs a version of 'fn' that applies to smaller batches. | def batchify_cache(fn, chunk):
if chunk is None:
return fn
def ret(inputs, training = False):
ret_list = [fn(inputs[i:i+chunk], training=training) for i in range(0, int(inputs.shape[0]), chunk)]
return tf.concat([ret for ret in ret_list], 0)
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batchify(fn, chunk):\n if chunk is None:\n return fn\n\n def ret(inputs, styles, alpha, feature):\n results = []\n for i in range(0, inputs.shape[0], chunk):\n input_chunk = inputs[i:i + chunk]\n style_chunk = styles[i:i + chunk]\n alpha_chunk = alpha... | [
"0.6842734",
"0.68105495",
"0.6198147",
"0.6074036",
"0.5801554",
"0.5749767",
"0.5732074",
"0.5710369",
"0.5580144",
"0.5578785",
"0.55560505",
"0.5555935",
"0.55520225",
"0.54689574",
"0.5458952",
"0.5453996",
"0.5444037",
"0.5423487",
"0.5418939",
"0.54081756",
"0.5398068"... | 0.64979213 | 2 |
Constructs a version of 'fn' that applies to smaller batches. | def batchify(fn, chunk, world_fn = lambda x:x, gather_func = None):
if chunk is None:
return fn
def ret(inputs, training = False, world_fn=world_fn):
embedded = inputs[0]
attention_poses = inputs[1]
intrinsic = inputs[2]
images_features = inputs[3]
pts = inputs[4]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batchify(fn, chunk):\n if chunk is None:\n return fn\n\n def ret(inputs, styles, alpha, feature):\n results = []\n for i in range(0, inputs.shape[0], chunk):\n input_chunk = inputs[i:i + chunk]\n style_chunk = styles[i:i + chunk]\n alpha_chunk = alpha... | [
"0.68411267",
"0.68100464",
"0.64958173",
"0.607114",
"0.5799871",
"0.5749444",
"0.57317525",
"0.57095826",
"0.5580774",
"0.557718",
"0.55540234",
"0.5553517",
"0.55492264",
"0.5467045",
"0.5456915",
"0.5452786",
"0.54423714",
"0.5421315",
"0.5418292",
"0.5408055",
"0.5398568... | 0.61957973 | 3 |
Return True if a folder starts with any character in exclusion_folder_start | def enforce_exclusion(folder_name, verbosity):
exclusion_folder_start = [".", "_"] # skip folders that start with any of these characters
if any([str(PurePath(folder_name)).startswith(each) for each in exclusion_folder_start]):
if verbosity:
show_verbose_output(verbosity, folder_name, " star... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def folder_filter(folder_name):\n excluded_folders = get_setting('excluded_folders', [])\n folder_name = folder_name.rstrip(os.sep) + os.sep\n return True not in [exc in folder_name for exc in excluded_folders]",
"def dir_filter(item):\n return not item.startswith(\"_\")",
"def is_in_folder(base_pa... | [
"0.6929057",
"0.682931",
"0.6739146",
"0.66221505",
"0.6272218",
"0.6267551",
"0.6108738",
"0.5978019",
"0.59336466",
"0.59188104",
"0.5893266",
"0.5833374",
"0.57968",
"0.5792592",
"0.5789207",
"0.57792753",
"0.57718164",
"0.5693271",
"0.56708837",
"0.56519204",
"0.5628853",... | 0.7578445 | 0 |
Remove punctuation and split according to words | def tokenize(sentence):
lower_s = sentence.lower()
no_punc_s = lower_s.translate(TRANS, string.punctuation)
word_list = no_punc_s.split()
return word_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _run_split_on_punc(self, text):\n chars = list(text)\n i = 0\n start_new_word = True\n output = []\n while i < len(chars):\n char = chars[i]\n if _is_punctuation(char):\n output.append([char])\n start_new_word = True\n ... | [
"0.7465218",
"0.7465218",
"0.7397956",
"0.73744273",
"0.7369583",
"0.7336633",
"0.7323795",
"0.72154754",
"0.71889126",
"0.71081096",
"0.71021324",
"0.70737475",
"0.70666057",
"0.7061866",
"0.704859",
"0.7047527",
"0.70413125",
"0.70413125",
"0.70413125",
"0.70413125",
"0.704... | 0.6841861 | 35 |
Generate a random string of fixed length | def random_string(length=10):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in xrange(length)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_random_string(length: int):\n\tall_chars = string.ascii_letters + string.digits\n\treturn ''.join(random.choices(all_chars, k=length))",
"def generate_random_string(length=6):\n n = int(length / 2 + 1)\n x = binascii.hexlify(os.urandom(n))\n s = x[:length]\n return s.decode(\"utf-8\")",... | [
"0.8680464",
"0.8573714",
"0.85486245",
"0.85297275",
"0.85209286",
"0.84331024",
"0.8432044",
"0.84157014",
"0.84120053",
"0.8345882",
"0.8343962",
"0.83406156",
"0.83348686",
"0.83240855",
"0.82986933",
"0.82911193",
"0.8281826",
"0.82818025",
"0.82811046",
"0.82640225",
"0... | 0.8389201 | 9 |
Builds an ActivityPub article object. The timestamp must be in json format, not protobuf. | def build_article(self, ap_id, title, timestamp, author, content, summary, article_url=None):
if article_url is None:
article_url = ap_id
return {
"@context": self.rabble_context(),
"type": "Article",
"id": ap_id,
"name": title,
"pu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _transform_article(self, article):\n\n if \"_embedded\" in article:\n article[\"image\"] = article[\"_embedded\"].get(\n \"wp:featuredmedia\", [None]\n )[0]\n article[\"author\"] = article[\"_embedded\"].get(\"author\", [None])[0]\n\n if \"displ... | [
"0.5883132",
"0.5761445",
"0.54526764",
"0.5435352",
"0.5409629",
"0.5279417",
"0.52663416",
"0.52286",
"0.5209933",
"0.5208987",
"0.5154881",
"0.5142191",
"0.5140672",
"0.51322126",
"0.5124345",
"0.51080066",
"0.50956625",
"0.5087001",
"0.5060904",
"0.5028653",
"0.50142175",... | 0.7347353 | 0 |
Sets the currency_code of this BusinessInvoiceAnalysisRequest. | def currency_code(self, currency_code):
self._currency_code = currency_code | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transaction_currency_code(self, transaction_currency_code):\n\n self._transaction_currency_code = transaction_currency_code",
"def currency(self, currency):\n if self.local_vars_configuration.client_side_validation and currency is None: # noqa: E501\n raise ValueError(\"Invalid valu... | [
"0.697567",
"0.6185",
"0.6065736",
"0.6064262",
"0.6043505",
"0.6043505",
"0.6043505",
"0.6043505",
"0.599469",
"0.59784746",
"0.5870651",
"0.5870651",
"0.5870651",
"0.57856524",
"0.57294303",
"0.56779045",
"0.56379014",
"0.56012744",
"0.5568183",
"0.5568183",
"0.5536259",
... | 0.76323247 | 2 |
Sets the response_limit of this BusinessInvoiceAnalysisRequest. | def response_limit(self, response_limit):
if (self._configuration.client_side_validation and
response_limit is not None and response_limit < 1): # noqa: E501
raise ValueError("Invalid value for `response_limit`, must be a value greater than or equal to `1`") # noqa: E501
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def limit(self, limit):\n\n self._limit = limit",
"def limit(self, limit):\n\n self._limit = limit",
"def limit(self, limit):\n\n self._limit = limit",
"def limit(self, limit):\n self._limit = limit",
"def limit(self, limit):\n self._limit = limit\n\n return self",... | [
"0.6034049",
"0.6034049",
"0.6034049",
"0.59437406",
"0.5835259",
"0.5826074",
"0.5805424",
"0.5695868",
"0.5533527",
"0.5478626",
"0.54722434",
"0.5461262",
"0.5449552",
"0.5419226",
"0.5419209",
"0.53811395",
"0.5342677",
"0.5311301",
"0.528057",
"0.52745265",
"0.526809",
... | 0.7952719 | 0 |
Sets the end_date of this BusinessInvoiceAnalysisRequest. | def end_date(self, end_date):
self._end_date = end_date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_date(self, end_date):\n self._end_date = end_date",
"def end_date(self, end_date):\n if end_date is None:\n raise ValueError(\"Invalid value for `end_date`, must not be `None`\")\n\n self._end_date = end_date",
"def end_date(self, end_date: str):\n if end_date is ... | [
"0.7756798",
"0.76595",
"0.74524593",
"0.73128676",
"0.7265493",
"0.7251396",
"0.7054168",
"0.6997346",
"0.69679695",
"0.69679695",
"0.6886524",
"0.6741623",
"0.67079425",
"0.66745627",
"0.63654876",
"0.6322931",
"0.6166118",
"0.6117789",
"0.6115287",
"0.6101264",
"0.6101264"... | 0.78489524 | 5 |
Sets the currency_conversion of this BusinessInvoiceAnalysisRequest. | def currency_conversion(self, currency_conversion):
self._currency_conversion = currency_conversion | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def currency(self, currency):\n\n self._currency = currency",
"def currency(self, currency):\n\n self._currency = currency",
"def currency(self, currency):\n\n self._currency = currency",
"def currency(self, currency):\n\n self._currency = currency",
"def currency(self, currency... | [
"0.6268588",
"0.6268588",
"0.6268588",
"0.6268588",
"0.6215708",
"0.6159894",
"0.6138264",
"0.6115726",
"0.598387",
"0.58805525",
"0.57628304",
"0.5611137",
"0.55443144",
"0.54161334",
"0.54161334",
"0.54161334",
"0.54161334",
"0.54161334",
"0.5395169",
"0.5394204",
"0.538848... | 0.78471076 | 0 |
Sets the start_date of this BusinessInvoiceAnalysisRequest. | def start_date(self, start_date):
self._start_date = start_date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_date(self, start_date):\n \n self._start_date = start_date",
"def start_date(self, start_date):\n if start_date is None:\n raise ValueError(\"Invalid value for `start_date`, must not be `None`\")\n\n self._start_date = start_date",
"def start_date(self, start_da... | [
"0.78174496",
"0.77041495",
"0.76133084",
"0.75271297",
"0.73746943",
"0.7350132",
"0.7226218",
"0.7076159",
"0.6980753",
"0.6605808",
"0.65800387",
"0.65800387",
"0.6449838",
"0.63616306",
"0.6310154",
"0.6225277",
"0.6225277",
"0.6222034",
"0.6160333",
"0.6155331",
"0.61092... | 0.77015746 | 9 |
Sets the overdue_periods of this BusinessInvoiceAnalysisRequest. | def overdue_periods(self, overdue_periods):
self._overdue_periods = overdue_periods | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def payee_grace_period_days(self, payee_grace_period_days):\n\n self._payee_grace_period_days = payee_grace_period_days",
"def future_due_periods(self, future_due_periods):\n\n self._future_due_periods = future_due_periods",
"def due_days(self, due_days):\n\n self._due_days = due_days",
... | [
"0.50690204",
"0.5050242",
"0.49629074",
"0.48179442",
"0.47714677",
"0.46271735",
"0.46271735",
"0.4610164",
"0.45746517",
"0.45540738",
"0.4548321",
"0.45075378",
"0.446112",
"0.4401106",
"0.43438086",
"0.4276293",
"0.42307466",
"0.4138613",
"0.41277072",
"0.4123086",
"0.40... | 0.8449379 | 0 |
Sets the business_id of this BusinessInvoiceAnalysisRequest. | def business_id(self, business_id):
self._business_id = business_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def business_account(self, business_account):\n\n self._business_account = business_account",
"def business_phone(self, business_phone):\n\n self._business_phone = business_phone",
"def bus_ob_id(self, bus_ob_id):\n\n self._bus_ob_id = bus_ob_id",
"def bus_ob_id(self, bus_ob_id):\n\n ... | [
"0.6297323",
"0.61722696",
"0.60058355",
"0.60058355",
"0.6001613",
"0.5929678",
"0.58466035",
"0.5810847",
"0.58064693",
"0.5582011",
"0.5535934",
"0.5401595",
"0.52096385",
"0.51457965",
"0.50784725",
"0.50685155",
"0.49421903",
"0.49258333",
"0.48271197",
"0.48203462",
"0.... | 0.8110931 | 0 |
Sets the customer_id of this BusinessInvoiceAnalysisRequest. | def customer_id(self, customer_id):
self._customer_id = customer_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def customer_id(self, customer_id: str):\n self._customer_id = customer_id",
"def customer_id(self, customer_id):\n if customer_id is None:\n raise ValueError(\"Invalid value for `customer_id`, must not be `None`\") # noqa: E501\n\n self._customer_id = customer_id",
"def custom... | [
"0.79679954",
"0.7631803",
"0.7631803",
"0.695172",
"0.6813422",
"0.6747435",
"0.66831005",
"0.66831005",
"0.656075",
"0.62582725",
"0.6095496",
"0.60175836",
"0.60140336",
"0.5907835",
"0.5888745",
"0.58771956",
"0.56933546",
"0.56887835",
"0.5680594",
"0.5589217",
"0.558201... | 0.8002443 | 3 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, BusinessInvoiceAnalysisRequest):
return False
return self.to_dict() == other.to_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.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
if not isinstance(other, BusinessInvoiceAnalysisRequest):
return True
return self.to_dict() != other.to_dict() | {
"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.8455985",
"0.83913255",
"0.81440157",
"0.8140831",
"0.8132328",
"0.80937284",
"0.809181",
"0.809181",
"0.809181",
"0.808509",
"0.808509",
"0.8076134",
"0.8076134",
"0.8065528",
"0.80422795",
"0.80422795",
"0.80422795",
"0.80422795",
"0.80422795",
"0.80422795",
"0.80422795"... | 0.0 | -1 |
Only staff and creator can review | def get_queryset(self):
if self.request.user.is_staff:
return Job.objects.select_related()
else:
raise Http404() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_review_story_restrict_to_only_admin(self):\n self.client.post('/api/stories', headers={'token': user_token}, data=json.dumps(story1))\n res = self.client.put('/api/stories/1/review', headers={'token': user_token}, data=json.dumps({\n 'status': 'Approved'\n }))\n resu... | [
"0.67614764",
"0.6754483",
"0.65233713",
"0.6506883",
"0.64558226",
"0.64312387",
"0.6372799",
"0.63151383",
"0.6255467",
"0.62517416",
"0.6197781",
"0.61933273",
"0.61921334",
"0.61676115",
"0.61468977",
"0.61307395",
"0.6104877",
"0.60937226",
"0.60933554",
"0.6092204",
"0.... | 0.0 | -1 |
set the creator to the current user | def form_valid(self, form):
# Associate Job to user if they are logged in
if self.request.user.is_authenticated():
form.instance.creator = self.request.user
return super().form_valid(form) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def creator(self, creator):\n self._creator = creator",
"def creator(self, creator):\n\n self._creator = creator",
"def creator(self, creator):\n\n self._creator = creator",
"def creator(self, creator):\n\n self._creator = creator",
"def save_model(self, request, obj, form, chan... | [
"0.7734716",
"0.76061606",
"0.76061606",
"0.76061606",
"0.71235436",
"0.69892895",
"0.69527483",
"0.6872877",
"0.6872877",
"0.6862932",
"0.6816366",
"0.6794977",
"0.6794977",
"0.67005956",
"0.67005956",
"0.67005956",
"0.67005956",
"0.67005956",
"0.67005956",
"0.6681744",
"0.6... | 0.6663708 | 23 |
Make numpy array rows the same length by shortening long ones. | def arraycleaner(array):
lengths = [len(x) for x in array]
#shortindex = lengths.index(min(lengths))
shortest = min(lengths)
for n in range(len(array)):
line = array[n]
if len(array[n]) != shortest:
this = len(line)
cut = np.ceil(1/((this/shortest) - 1))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalizeArray(data):\n highestLength = 0\n for line in data:\n if len(line) > highestLength:\n highestLength = len(line)\n for line in data:\n if len(line) < highestLength:\n difference = highestLength - len(line)\n line.extend(['' for i in range(differe... | [
"0.60701644",
"0.5785023",
"0.5635883",
"0.5600343",
"0.5541946",
"0.5525345",
"0.5448698",
"0.5405504",
"0.5405504",
"0.53699225",
"0.53234947",
"0.52803123",
"0.5254797",
"0.5251641",
"0.52381927",
"0.5234166",
"0.5229408",
"0.5209653",
"0.5208833",
"0.5207058",
"0.5166235"... | 0.52826136 | 11 |
Computes the forward pass for an affine (fullyconnected) layer. The input x has shape (N, d_1, ..., d_k) and contains a minibatch of N examples, where each example x[i] has shape (d_1, ..., d_k). We will reshape each input into a vector of dimension D = d_1 ... d_k, and then transform it to an output vector of dimensio... | def affine_forward(x, w, b):
out = None
###########################################################################
# TODO: Implement the affine forward pass. Store the result in out. You #
# will need to reshape the input into rows. #
################################... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def affine_forward(x, w, b):\n out = None\n \n # reshape the input into (N, d_1 *...* d_k)\n input_shape = x.shape\n prod = 1\n for i in range(1,len(input_shape)):\n prod *= input_shape[i]\n\n a = x.reshape(x.shape[0],prod)\n out = np.dot(a,w) + b\n \n cache = (x, w, b)\n re... | [
"0.69979554",
"0.688257",
"0.6688148",
"0.651063",
"0.64576596",
"0.6447634",
"0.6414778",
"0.64066976",
"0.63563716",
"0.6355806",
"0.63486165",
"0.6345911",
"0.6335344",
"0.63225836",
"0.6308018",
"0.63038045",
"0.62985945",
"0.6297732",
"0.6296885",
"0.62916577",
"0.628804... | 0.6505953 | 4 |
Computes the backward pass for an affine layer. | def affine_backward(dout, cache):
x, w, b = cache
dx, dw, db = None, None, None
###########################################################################
# TODO: Implement the affine backward pass. #
####################################################################... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def affine_relu_backward(dout, cache):\n fc_cache, relu_cache = cache\n da = layers.relu_backward(dout, relu_cache)\n dx, dw, db = layers.affine_backward(da, fc_cache)\n return dx, dw, db",
"def affine_backward(dout, cache):\n x, w, b = cache\n dx, dw, db = None, None, None\n ###############... | [
"0.7518848",
"0.7515068",
"0.7301493",
"0.7301493",
"0.7301493",
"0.7301493",
"0.7243357",
"0.71775466",
"0.71740377",
"0.7173464",
"0.71660924",
"0.71318585",
"0.71068776",
"0.70977736",
"0.7084256",
"0.70685065",
"0.70448864",
"0.7040929",
"0.6993688",
"0.6986346",
"0.69835... | 0.7310804 | 2 |
Computes the forward pass for a layer of rectified linear units (ReLUs). | def relu_forward(x):
out = None
###########################################################################
# TODO: Implement the ReLU forward pass. #
###########################################################################
# *****START OF YOUR CODE (DO NOT DELETE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_relus(self):\n\n def relu_backward_hook_function(module, grad_in, grad_out):\n \"\"\"\n If there is a negative gradient, change it to zero\n \"\"\"\n # Get last forward output\n corresponding_forward_output = self.forward_relu_outputs[-1]\n ... | [
"0.67765754",
"0.6630487",
"0.6603554",
"0.6524658",
"0.65097666",
"0.64478433",
"0.6385381",
"0.62672025",
"0.62047166",
"0.6179713",
"0.61535424",
"0.61385596",
"0.6061572",
"0.6055216",
"0.6048094",
"0.6047937",
"0.6018342",
"0.59974337",
"0.59908754",
"0.59634507",
"0.594... | 0.59696555 | 19 |
Computes the backward pass for a layer of rectified linear units (ReLUs). | def relu_backward(dout, cache):
dx, x = None, cache
###########################################################################
# TODO: Implement the ReLU backward pass. #
###########################################################################
# *****START OF YOUR... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relu_backward(self, dUpper, cache):\n x = cache\n #############################################################################\n # TODO: Implement the ReLU backward pass. #\n #########################################################################... | [
"0.7040494",
"0.69480807",
"0.6898032",
"0.6847973",
"0.6847973",
"0.68467885",
"0.68186617",
"0.676775",
"0.67575246",
"0.67554206",
"0.6754426",
"0.6742765",
"0.67396927",
"0.6714778",
"0.670874",
"0.66994834",
"0.6696945",
"0.6696945",
"0.6686564",
"0.6665754",
"0.6665754"... | 0.68413866 | 6 |
Returns orgnaizations and their station groups. Get all organization and station group identifiers. | def getOrgsAndStationGroups(self, **kwargs):
searchQuery = self._client.factory.create('getOrgsAndStationGroupsSearchQuery')
for k, v in kwargs.items():
setattr(searchQuery, k, v)
response = self._soap_service.getOrgsAndStationGroups(searchQuery)
return CPAPIResponse(respons... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getStationGroups(self, orgID):\n\n response = self._soap_service.getStationGroups(orgID)\n return CPAPIResponse(response)",
"def get_org_list():\r\n\r\n resp = requests.get(''.join([Kegg.BASE_URL, 'list/organism']))\r\n return resp.text",
"def organizations(self):\n return se... | [
"0.6765716",
"0.65290684",
"0.62308997",
"0.6198153",
"0.61975",
"0.61779463",
"0.61180806",
"0.6108401",
"0.6018462",
"0.6004692",
"0.5984768",
"0.59534097",
"0.5945978",
"0.5921139",
"0.59210247",
"0.58934385",
"0.5866213",
"0.5837205",
"0.5836365",
"0.5809406",
"0.57943285... | 0.64683723 | 2 |
Returns station rights profiles as defined by the given query parameters. It is worth noting that there ay be more than one rights profile for a given station. A profile defined the relationship between a charge station and a group and a charge station may belong to multiple groups. | def getStationRights(self, **kwargs):
searchQuery = self._client.factory.create('stationRightsSearchRequest')
for k, v in kwargs.items():
setattr(searchQuery, k, v)
response = self._soap_service.getStationRights(searchQuery)
return CPAPIGetStationRightsResponse(response) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile():\n\n if not session.get('oauth_token'):\n return redirect(url_for('login'))\n tokenString = \"bearer {0}\".format(session['oauth_token']['access_token'])\n headers = {\"Authorization\": tokenString}\n profileInfo = {'access_token': session['oauth_token']['access_token']}\n\n # g... | [
"0.53217614",
"0.52930653",
"0.51522696",
"0.51350725",
"0.5086901",
"0.5070345",
"0.5043122",
"0.50005895",
"0.4978911",
"0.4917278",
"0.48973823",
"0.48927572",
"0.48927358",
"0.48502535",
"0.48378962",
"0.48293635",
"0.48282176",
"0.47943762",
"0.47767562",
"0.47638845",
"... | 0.535175 | 0 |
Back propagate the gradient from output to input | def back_prop(self, dout):
W, b, X, Z = self.W, self.b, self.X, self.Z
num_input, num_output = self.num_input, self.num_output
dZ_dW = X.T
dZ_dX = W.T
dout = dout * (Z != 0.)
dout_dW = dout @ dZ_dW # (out, train) x (train, in) = (out, in)
dout_db = dout.sum(axis=1) ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backward(self, out_grad, input):\n raise NotImplementedError",
"def backward(self):\n gradient = blah\n return gradient",
"def backward(self):\n gradient = blah\n return gradient",
"def backward(self, d_out):\n # TODO: Implement backward pass\n # Compute b... | [
"0.78424543",
"0.76750726",
"0.76750726",
"0.76672614",
"0.75890756",
"0.75851744",
"0.75851744",
"0.7548351",
"0.7539645",
"0.75374997",
"0.75297564",
"0.7340075",
"0.7311611",
"0.7311611",
"0.7307857",
"0.73035705",
"0.73035705",
"0.72805494",
"0.7271427",
"0.7251024",
"0.7... | 0.0 | -1 |
This function gets the duration of the ECG strip. | def get_duration(data):
try:
start_time = data.Time.min()
end_time = data.Time.max()
duration = end_time-start_time
print(duration)
return duration
except AttributeError:
logging.error("The dataframe needs to have a Time header")
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_duration(self):\n try:\n if self.is_skipped:\n return \"00:00\"\n assert self.start_time\n assert self.stop_time\n if self.stop_time < self.start_time:\n return \"XX:XX\"\n return(\n f\"{str(int(self.... | [
"0.7091488",
"0.7055618",
"0.6849837",
"0.68465245",
"0.6673342",
"0.6670944",
"0.665337",
"0.66172236",
"0.6603401",
"0.6603401",
"0.6600614",
"0.65750927",
"0.65644634",
"0.6562238",
"0.65572214",
"0.6550449",
"0.6537836",
"0.65308046",
"0.6527161",
"0.6521941",
"0.6504998"... | 0.0 | -1 |
Calculates the hypothesis for the given examples using the current self.theta values. | def _hypothesis(self, X):
# * is element wise multiplication
# numpy.dot(), or @ operator will work
result = np.transpose(self.theta)@ X
#emptyResult = np.zeros((1,X.shape[1]))
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_hypothesis_output(self):\n return np.matmul(self.X, self.theta_vector)",
"def update_thetas(self, X, y, theta_list, bias, learning_rate):\n total_samples = len(X)\n theta_derivative = [0]*len(theta_list)\n bias_derivative = 0\n\n for i in range(total_samples): ... | [
"0.67727107",
"0.5832738",
"0.57661307",
"0.5758714",
"0.5563677",
"0.5532701",
"0.54715043",
"0.54587907",
"0.54464555",
"0.53734076",
"0.5371957",
"0.536912",
"0.5325271",
"0.53055286",
"0.5296538",
"0.52918905",
"0.5272687",
"0.52632505",
"0.52036357",
"0.5198426",
"0.5186... | 0.6435389 | 1 |
Make reveal.js HTML5 slides from the doconce file `name`. | def reveal_slides(name, options='', postfix='reveal', theme='darkgray'):
if name.endswith('.do.txt'):
name = name.replace('.do.txt', '')
# Compile source
if '--pygments_html_style=' not in options:
from doconce.misc import recommended_html_styles_and_pygment_styles
combinations = re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deck_slides(name, options='', postfix='deck', theme='sandstone.default'):\n if name.endswith('.do.txt'):\n name = name.replace('.do.txt', '')\n\n # Compile source\n if '--pygments_html_style=' not in options:\n from doconce.misc import recommended_html_styles_and_pygment_styles\n ... | [
"0.6870641",
"0.65977275",
"0.6071153",
"0.5848276",
"0.5813762",
"0.57927704",
"0.57043546",
"0.56190366",
"0.55146956",
"0.5433361",
"0.5285804",
"0.52656996",
"0.5252888",
"0.5119041",
"0.5035769",
"0.50229895",
"0.4996925",
"0.4994819",
"0.49853408",
"0.49613583",
"0.4954... | 0.7441397 | 0 |
Gets database file. attached_db if True, add the list of attached databases the database file | def get_file(self, attached_db=False):
if attached_db:
files = [self._sql_file]
att = self.get_attached_database_list(True)
for alias, file in att:
files.append("%s,%s" % (alias, file))
temp = ";".join(files)
if self._engine != "SQLite"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_attached_database_list(self, file=False):\n if self.isMSSQL():\n return [] # pragma: no cover\n else:\n cur = self._connection.cursor()\n cur.execute(\"PRAGMA database_list;\")\n res = cur.fetchall()\n cur.close()\n res = [r f... | [
"0.6916049",
"0.6578247",
"0.6176285",
"0.6100035",
"0.6063422",
"0.6043342",
"0.59784216",
"0.5932231",
"0.59221953",
"0.59080017",
"0.59080017",
"0.5858477",
"0.5848627",
"0.5839604",
"0.57970726",
"0.5792348",
"0.57861024",
"0.57812977",
"0.57812977",
"0.57812977",
"0.5781... | 0.78399277 | 0 |
Closes the database connection | def close(self):
self.db.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_db_connection(cls):\n db.close()",
"def close_database(self):\n if self._conn is not None:\n self._conn.close()\n self._conn = None",
"def close(self):\n Log.debug('DB -> close')\n # 关闭数据库连接\n self.conn.close()",
"def close(self):\n if... | [
"0.85662735",
"0.8412375",
"0.8293456",
"0.8184272",
"0.81580645",
"0.80922866",
"0.8057031",
"0.80505526",
"0.80190814",
"0.79888546",
"0.7972568",
"0.79142356",
"0.7873472",
"0.7871479",
"0.7852316",
"0.782567",
"0.78119534",
"0.77649176",
"0.77649176",
"0.77649176",
"0.775... | 0.79306155 | 11 |
Takes Nd array (probably has to be 2d?) and returns an array containing the indices of the last nonzero element of each slice along axis. | def nonzero_last(arr, *, axis):
def nonzero_last_1d(arr):
try:
return np.nonzero(arr)[0][-1]
except IndexError:
return -1
return np.apply_along_axis(nonzero_last_1d, axis, arr) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trim_zeros(array):\n multislice = []\n for i in range(array.ndim):\n sum_axes = tuple(j for j in range(array.ndim) if j is not i)\n edges = np.where(np.sum(array, axis=sum_axes) > 0)\n if edges[0].size == 0:\n return np.array([], dtype=array.dtype)\n low = edges[0][... | [
"0.6477225",
"0.61762404",
"0.6112838",
"0.59012234",
"0.58375174",
"0.58153963",
"0.58129466",
"0.58112746",
"0.5807287",
"0.576203",
"0.5731323",
"0.5727065",
"0.5697212",
"0.56608844",
"0.5625623",
"0.5533452",
"0.5529357",
"0.5520514",
"0.5507549",
"0.5502993",
"0.5460928... | 0.71133775 | 0 |
Takes Nd array (probably has to be 2d?) and returns an array containing the indices of the first nonzero element of each slice along axis. | def nonzero_first(arr, *, axis):
def nonzero_first_1d(arr):
try:
return np.nonzero(arr)[0][0]
except IndexError:
return -1
return np.apply_along_axis(nonzero_first_1d, axis, arr) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nonzero_indices(a):\n return (np.nonzero(a)[0])",
"def zero_indexed(array):\n if all(dl == 0 for dl in array.datashape.dim_low):\n return array\n if any(dl < 0 for dl in array.datashape.dim_low):\n raise ValueError(\"Cannot zero_index array: one or more \"\n \"d... | [
"0.7046656",
"0.6831373",
"0.6539587",
"0.62987006",
"0.62457144",
"0.61971784",
"0.61363906",
"0.6088739",
"0.6076612",
"0.60524017",
"0.5979014",
"0.5956975",
"0.5942205",
"0.5927515",
"0.5920843",
"0.5846095",
"0.584005",
"0.5835365",
"0.5828217",
"0.5823978",
"0.5822171",... | 0.666242 | 2 |
Gets the quantize representation of a float . The resulting tensor will contain the quantized values and the quantization parameters will be tagged with the tensor as a special tensor. A ValueError will be raised if the given tensor contains NaN or divergent values. | def get_quantized_representation(
tensor: torch.Tensor,
quantize_params: QuantizeAffineParams2,
) -> torch.Tensor:
_validate_tensor(tensor)
scale = quantize_params.scale
zero_point = quantize_params.zero_point
num_bits = quantize_params.num_bits
if scale == 0:
# Special case, all el... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quantize_float(f, q):\n return int(round(f / q) * q)",
"def __float__(self):\n if (self.nvar == 0): return self.t[0]\n else: raise ValueError(\"Factor is not a scalar; scope {}\".format(self.v))",
"def get_quant(q):\n\n try:\n e_q = eval(q)\n except:\n return None\n\n if isi... | [
"0.6258426",
"0.5960607",
"0.5929767",
"0.5888707",
"0.58241445",
"0.58061695",
"0.566255",
"0.5661319",
"0.56245506",
"0.5591386",
"0.55134827",
"0.55102366",
"0.548706",
"0.54651064",
"0.54651064",
"0.5449523",
"0.5448558",
"0.5438672",
"0.5436855",
"0.5434669",
"0.5434669"... | 0.66287214 | 0 |
Get a quantizable approximation of a float tensor given quantize param. This function does not quantize the float tensor , but only adjusts it such that the returned float tensor has an exact quantized representation. This is a function that we want to use at training time to quantize biases and other parameters whose ... | def quantize_affine_given_quant_params(
input: torch.Tensor,
quantize_params: QuantizeAffineParams2,
) -> torch.Tensor:
return QuantizeAffineFunction.apply(input, quantize_params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_quantized_representation(\n tensor: torch.Tensor,\n quantize_params: QuantizeAffineParams2,\n) -> torch.Tensor:\n _validate_tensor(tensor)\n\n scale = quantize_params.scale\n zero_point = quantize_params.zero_point\n num_bits = quantize_params.num_bits\n if scale == 0:\n # Speci... | [
"0.65489894",
"0.6516112",
"0.6375786",
"0.60761523",
"0.5911478",
"0.56965756",
"0.5668826",
"0.55257815",
"0.5515781",
"0.54438496",
"0.5428319",
"0.53939265",
"0.53800285",
"0.5355219",
"0.52439564",
"0.5187641",
"0.51826656",
"0.5180605",
"0.51496965",
"0.5134092",
"0.511... | 0.5843646 | 5 |
Quantize a floating point array with respect to the quantization params. | def quantize(
arr: np.ndarray, quantize_params: QuantizeAffineParams2
) -> np.ndarray:
scale = quantize_params.scale
zero_point = quantize_params.zero_point
num_bits = quantize_params.num_bits
if scale == 0:
# Special case, all elements are zeros.
if zero_point != 0:
rais... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quantifyValues( values, scale):\r\n\r\n\tfor v in range(len(values)):\r\n\t\tvalues[v] = st.quantify( values[v], scale)\r\n\treturn values",
"def quantile(self, q: float) -> np.array:\n assert 0 <= q <= 1\n return np.array(\n list(\n chain.from_iterable(\n ... | [
"0.6101966",
"0.57611966",
"0.574104",
"0.57313967",
"0.5639589",
"0.5639589",
"0.5639589",
"0.5592016",
"0.5435763",
"0.5388507",
"0.5334182",
"0.5311806",
"0.52352774",
"0.5212122",
"0.51914227",
"0.5178122",
"0.5149757",
"0.5144619",
"0.513484",
"0.5121159",
"0.510513",
... | 0.684107 | 0 |
Return a quantizable approximation of a float tensor . This function does not quantize the float tensor , but only adjusts it such that the returned float tensor has an exact quantized representation. This is a function that we want to use at training time to quantize weights and activations. | def quantize_affine(
input: torch.Tensor,
min_value: Optional[numbers.Real] = None,
max_value: Optional[numbers.Real] = None,
num_bits: int = None,
) -> torch.Tensor:
if num_bits is None:
raise ValueError("num_bits must be supplied")
if min_value is None:
# Force include 0 in ou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quantize_float(f, q):\n return int(round(f / q) * q)",
"def get_quantized_representation(\n tensor: torch.Tensor,\n quantize_params: QuantizeAffineParams2,\n) -> torch.Tensor:\n _validate_tensor(tensor)\n\n scale = quantize_params.scale\n zero_point = quantize_params.zero_point\n num_bit... | [
"0.64855516",
"0.63071",
"0.60449255",
"0.58433664",
"0.578491",
"0.57847744",
"0.5718715",
"0.56967795",
"0.56645346",
"0.5644118",
"0.564346",
"0.5634277",
"0.5629931",
"0.5629931",
"0.56082",
"0.56082",
"0.56082",
"0.5605481",
"0.56026214",
"0.55979854",
"0.55944324",
"0... | 0.5344516 | 49 |
Initialises a new 'PowerTransformerInfo' instance. | def __init__(self, TransformerTankInfo=None, *args, **kw_args):
self._TransformerTankInfo = []
self.TransformerTankInfo = [] if TransformerTankInfo is None else TransformerTankInfo
super(PowerTransformerInfo, self).__init__(*args, **kw_args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, transformer):\n self.transformer = transformer",
"def __init__(self, ratedU=0.0, endNumber=0, phaseAngleClock=0, emergencyS=0.0, ratedS=0.0, shortTermS=0.0, r=0.0, insulationU=0.0, connectionKind=\"Z\", TransformerTankInfo=None, TransformerEnd=None, *args, **kw_args):\n #: Rated ... | [
"0.61152256",
"0.5753487",
"0.5752063",
"0.5743845",
"0.5649393",
"0.5563833",
"0.55415523",
"0.54955196",
"0.5468761",
"0.5453124",
"0.5449158",
"0.5448353",
"0.5414072",
"0.53945684",
"0.53827214",
"0.5373926",
"0.5355162",
"0.5336674",
"0.531888",
"0.52983326",
"0.52956676... | 0.7152029 | 0 |
Gets the id of this Historico. | def id(self) -> int:
return self._id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id(self) -> int:\n return pulumi.get(self, \"id\")",
"def id(self):\n return self.get_data(\"id\")",
"def get_id(self) -> int:\n return self.id",
"def get_id(self) -> int:\n return self.id",
"def get_id(self):\n return self._id",
"def get_id(self):\n return s... | [
"0.7482253",
"0.74528015",
"0.74229527",
"0.74229527",
"0.74042994",
"0.74042994",
"0.74042994",
"0.74042994",
"0.74042994",
"0.74042994",
"0.74002326",
"0.74002326",
"0.7397954",
"0.7366292",
"0.7366292",
"0.7366292",
"0.7366292",
"0.7366292",
"0.7366292",
"0.7366292",
"0.73... | 0.7383284 | 26 |
Sets the id of this Historico. | def id(self, id: int):
self._id = id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_id(self, id):\n self.data['id'] = id",
"def set_id(self, id):\n self.__id = id",
"def SetId(self, id):\n self.id = int(id)",
"def set_id(self, id_):\n\n self.id_ = id_",
"def setID(self, id):\n self._id = id\n return self.callRemote('setID', id)",
"def id... | [
"0.797054",
"0.7935904",
"0.78132385",
"0.7734397",
"0.7502023",
"0.7399515",
"0.7399515",
"0.7399515",
"0.7399515",
"0.7399515",
"0.737194",
"0.73489964",
"0.7340685",
"0.7339455",
"0.73324174",
"0.73324174",
"0.73324174",
"0.73324174",
"0.73324174",
"0.73324174",
"0.7332417... | 0.74798155 | 14 |
Gets the tipo of this Historico. | def tipo(self) -> TipoHistorico:
return self._tipo | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tipo(self) -> str:\n return self._tipo",
"def getType(self):\n return self.tipo",
"def getType(self):\n return self.type",
"def getType(self):\n return self.type_",
"def get_type(self):\n return self.type",
"def get_type(self):\n return self.type",
"def Get... | [
"0.7791878",
"0.77823025",
"0.67099935",
"0.6708554",
"0.66869074",
"0.66869074",
"0.6678684",
"0.66733795",
"0.6640555",
"0.6597742",
"0.6591268",
"0.6566212",
"0.6566212",
"0.6556727",
"0.65443474",
"0.6544321",
"0.65400547",
"0.65296185",
"0.652133",
"0.652133",
"0.652133"... | 0.89895624 | 0 |
Sets the tipo of this Historico. | def tipo(self, tipo: TipoHistorico):
self._tipo = tipo | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tipo(self, tipo: str):\n\n self._tipo = tipo",
"def tipo(self) -> TipoHistorico:\n return self._tipo",
"def tipo_fondo(self, tipo_fondo):\n\n self._tipo_fondo = tipo_fondo",
"def set_type(self, type):\n self.type = type",
"def set_type(self, type):\n self.type = type"... | [
"0.7844718",
"0.68275464",
"0.68232894",
"0.675328",
"0.675328",
"0.65762246",
"0.6568494",
"0.65554976",
"0.65554976",
"0.6548873",
"0.6368371",
"0.63416195",
"0.6261391",
"0.61846095",
"0.6021663",
"0.6012074",
"0.59684074",
"0.59649616",
"0.59506476",
"0.59098434",
"0.5869... | 0.86336696 | 0 |
Gets the sistema of this Historico. | def sistema(self) -> Sistema:
return self._sistema | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def system(self):\n return self['system']",
"def system(self):\n try:\n return self._system\n except AttributeError:\n raise AttributeError('You must initialize the system with '\n 'createSystem before accessing the cached '\n ... | [
"0.68398154",
"0.6334563",
"0.5904373",
"0.5898471",
"0.5888476",
"0.58501226",
"0.5827773",
"0.5827773",
"0.5805058",
"0.5789183",
"0.57769316",
"0.5770022",
"0.5768491",
"0.57371324",
"0.5721187",
"0.5702871",
"0.5697606",
"0.5600086",
"0.55993193",
"0.55470234",
"0.5526437... | 0.8499895 | 0 |
Sets the descricao of this Historico. | def descricao(self, descricao: str):
self._descricao = descricao | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def descricao_estagio(self, descricao_estagio):\n self._descricao_estagio = descricao_estagio",
"def descricao_produto(self, descricao_produto):\n self._descricao_produto = descricao_produto",
"def set_desc(self, desc: str):\n self._desc = desc",
"def set_description(self, desc: str) -> ... | [
"0.77797574",
"0.7497721",
"0.7149152",
"0.71451193",
"0.6882043",
"0.6770163",
"0.66562873",
"0.6570389",
"0.65478194",
"0.654751",
"0.65474546",
"0.6543521",
"0.65362424",
"0.6515183",
"0.6512677",
"0.6491567",
"0.6452012",
"0.6451664",
"0.64491385",
"0.6374093",
"0.6303296... | 0.83928335 | 0 |
This function updates an existing environment in the environment list | def update(key, environmentDetails):
app.logger.debug(pformat(environmentDetails))
if environmentDetails["key"] != key:
abort(400, f"Key mismatch in path and body")
# Does the environment exist in environment list?
existing_environment = Environment.query.filter(
Environment.k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, system, environment_input):\n pass",
"def update(self, env):\n del env\n return",
"def update(self, env_obj):\n if env_obj:\n if isinstance(env_obj, EnvValues):\n for package_name, env_vars in env_obj.data.items():\n for name, va... | [
"0.7238445",
"0.72148824",
"0.7120257",
"0.649844",
"0.6268269",
"0.6244135",
"0.6230973",
"0.62302595",
"0.6128082",
"0.61241865",
"0.6074088",
"0.60685635",
"0.60434705",
"0.60298103",
"0.59531087",
"0.58574635",
"0.5804927",
"0.5800053",
"0.57754487",
"0.5769917",
"0.57566... | 0.68545854 | 3 |
Attempts to identify if an organization that matches an abbreviation for an OrgConcept is a subchapter of the OrgConcept | def identify_subchapter_abbreviation(org_concept_abbrev, org):
cleaned_org_name = org_tools.filterdata(org['name'])
s = SequenceMatcher(a=org_concept_abbrev, b=cleaned_org_name)
matches = s.get_matching_blocks()
org_matches = list()
for match in matches[:-1]:
start = match[0]
end... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def identify_subchapter(oc_name, org):\n cleaned_oc_name = org_tools.filterdata(oc_name)\n cleaned_org_name = org_tools.filterdata(org['name'])\n s = SequenceMatcher(a=cleaned_oc_name, b=cleaned_org_name)\n\n matches = s.get_matching_blocks()\n org_matches = list()\n\n for match in matches[:-1]:\... | [
"0.78031397",
"0.61174715",
"0.573218",
"0.55013144",
"0.5267409",
"0.5248337",
"0.5197138",
"0.5186743",
"0.5176284",
"0.5175892",
"0.5138939",
"0.51381475",
"0.5099703",
"0.5072286",
"0.50572854",
"0.5043551",
"0.50432336",
"0.5040826",
"0.5026686",
"0.5008674",
"0.49935865... | 0.8353047 | 0 |
The QID of this entity, of the form Q | def qid(self) -> str:
return self._itempage.title() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_eid(self, qid):\n return self._entity_symbols.get_eid(qid)",
"def __int__(self):\n return int(self.q[0])",
"def qd(self):\n return self._qd",
"def get_q_id_by_rec_idx(self, rec_idx):\n return self._record_idx_to_record[rec_idx]['q_id']",
"def id(self):\n retur... | [
"0.7043349",
"0.68651956",
"0.67976",
"0.6783425",
"0.65099895",
"0.6497932",
"0.6489984",
"0.6479542",
"0.6476392",
"0.6448884",
"0.62321675",
"0.6205935",
"0.6173615",
"0.61558586",
"0.6049857",
"0.6045591",
"0.600434",
"0.59431225",
"0.59063363",
"0.5869523",
"0.58692676",... | 0.77057534 | 0 |
The underlying repo from where data for this item is fetched | def repo(self):
return self._repo | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repo(self):\n if not hasattr(self, '_repo'):\n self._repo = Repo(self.path)\n return self._repo",
"def contents(self):\r\n return repocontents.RepoContents(self)",
"async def fetch_data(self) -> GitHubRepositoryModel:\n result = await self._client.repos.get(self.repos... | [
"0.6901222",
"0.67771506",
"0.6730266",
"0.65392953",
"0.65344816",
"0.64445806",
"0.63316774",
"0.61661494",
"0.6090669",
"0.6055677",
"0.5918449",
"0.5909221",
"0.58707887",
"0.58424115",
"0.5842285",
"0.58357245",
"0.5828835",
"0.58244187",
"0.58021814",
"0.5799606",
"0.57... | 0.7643145 | 0 |
Add headers to both force latest IE rendering engine or Chrome Frame, and also to cache the rendered page for 10 minutes. | def add_header(r):
r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
r.headers["Pragma"] = "no-cache"
r.headers["Expires"] = "0"
r.headers['Cache-Control'] = 'public, max-age=0'
return r | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_header(response):\n response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'\n response.headers['Cache-Control'] = 'public, max-age=60'\n return response",
"def add_header(response):\n response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'\n response.headers['Cache-Control'] = 'public, m... | [
"0.82231",
"0.8222272",
"0.8222272",
"0.8222272",
"0.8222272",
"0.8195367",
"0.81630635",
"0.81630635",
"0.81630635",
"0.81630635",
"0.81630635",
"0.81630635",
"0.81630635",
"0.81630635",
"0.81630635",
"0.81630635",
"0.81630635",
"0.81630635",
"0.81630635",
"0.81630635",
"0.8... | 0.7127428 | 61 |
Returns a randomly selected quote from a character based on user input. | def get_bot_response(response):
# Response set 1 for Aang
aang = [
"\"Harsh words won't solve problems, action will!\"", # S1E11
"\"The past can be a great teacher.\"", # S3E13
"\"It's easy to do nothing, but it's hard to forgive.\"", # S3E16
]
# Response set 2 for Katara
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_quote():\n quotes = [\n \"Growth is never by mere chance; it is the result of forces working together.\\n-James Cash Penney\",\n \"We cannot accomplish all that we need to do without working together\\n-Bill Richardson\",\n \"The power of one, if fearless and focused, is formidab... | [
"0.70577174",
"0.70087826",
"0.66427964",
"0.65939885",
"0.64858484",
"0.64615804",
"0.6230817",
"0.6159821",
"0.6150661",
"0.6049354",
"0.6014567",
"0.6004322",
"0.5996546",
"0.5978011",
"0.59584266",
"0.59291565",
"0.5924497",
"0.5920027",
"0.5880703",
"0.58800995",
"0.5878... | 0.0 | -1 |
Return recorded data as a dictionary containing one numpy array for each neuron, ids as keys. | def recording(self, port_name, t_start=None):
if self.is_dead():
t_stop = self._t_stop
else:
t_stop = self.Simulation.active().t
if t_start is None:
t_start = UnitHandler.to_pq_quantity(self._t_start)
t_start = pq.Quantity(t_start, 'ms')
t_stop... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _store(self):\n store_dict = {}\n for key in self._data:\n val = self._data[key]\n if SparseParameter._is_supported_matrix(val):\n serial_string = SparseParameter._serialize_matrix(val)\n store_dict[\"%s%s\" % (key, SparseParameter.IDENTIFIER)] ... | [
"0.60289586",
"0.60114783",
"0.5860054",
"0.5755884",
"0.5716057",
"0.56748897",
"0.5661681",
"0.5652467",
"0.56406534",
"0.56327915",
"0.56219864",
"0.5618285",
"0.5605621",
"0.5595653",
"0.55680156",
"0.5530636",
"0.5522193",
"0.54922014",
"0.54868627",
"0.5484283",
"0.5480... | 0.0 | -1 |
Return the LaTeX formula for the given quantity code | def latex_formula(qcode):
if (qcode in tex_given_code.keys()):
return tex_given_code[qcode]
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RenderTeX(self, Q, size=None, dpi=50):\n code = Q.code\n name = Q.name\n tex = Q.tex\n if (defaults.use_tex):\n #try:\n if (1):\n # convert width/height in pixels to inches and add some padding\n if (size is None):\n ... | [
"0.68796283",
"0.6666894",
"0.6622539",
"0.65689933",
"0.6524665",
"0.6505683",
"0.65052825",
"0.6416758",
"0.6358784",
"0.6243348",
"0.6215221",
"0.6199913",
"0.61996377",
"0.6135273",
"0.6126471",
"0.6079391",
"0.60782313",
"0.60715973",
"0.60030365",
"0.59566927",
"0.58848... | 0.71861565 | 0 |
Given a list of quantities, return the indices and the names | def parse_quantities(quantities):
codes = []; names = []
for q in quantities:
c, n = parse_quantity(q)
codes.append(c)
names.append(n)
return codes, names | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getQuantitys(self, quantityNames):\n selectedQuantities = []\n for quantityName in quantityNames:\n foundQuantities = [q for q in self.quantityList if q.name == quantityName]\n if len(foundQuantities) > 0:\n selectedQuantities.append(foundQuantities[0])\n ... | [
"0.62808657",
"0.6182884",
"0.57407695",
"0.57221067",
"0.56093055",
"0.5584418",
"0.5544604",
"0.5519576",
"0.5483992",
"0.5475174",
"0.5444968",
"0.54252946",
"0.5388171",
"0.5367279",
"0.53451806",
"0.52989185",
"0.5289751",
"0.5284161",
"0.52632076",
"0.52623105",
"0.5250... | 0.6531379 | 0 |
calculates scaled dot product attention | def sdp_attention(Q, K, V, mask=None):
matmul_qk = tf.matmul(Q, K, transpose_b=True)
scald_qk = tf.cast(tf.shape(K)[-1], tf.float32)
scald_atten = matmul_qk / tf.math.sqrt(scald_qk)
# masked added to tensor
if mask is not None:
scald_attention += (mask * -1e9)
# weights are the attentio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scaled_dot_product_attention(q, k, v, mask):\n matmul_qk = tf.matmul(q, k, transpose_b=True) # [..., q_len, kv_len]\n # scale matmul_qk\n dk = tf.cast(tf.shape(k)[-1], tf.float32)\n scaled_attention_logits = matmul_qk / tf.sqrt(dk)\n # print(\"scaled_attention_logits\", tf.nn.top_k(scaled_atten... | [
"0.6945354",
"0.69214934",
"0.6865867",
"0.67973715",
"0.67973715",
"0.679469",
"0.67915493",
"0.6790422",
"0.6776388",
"0.66549087",
"0.6501813",
"0.6471937",
"0.63436484",
"0.6301064",
"0.6251952",
"0.6214482",
"0.6200138",
"0.6161925",
"0.6084597",
"0.60089314",
"0.5978381... | 0.0 | -1 |
get an attribute from the classad, returning default if not found. if the attribute is an expression, eval() it. | def geteval(self, key, default=None):
r = self.get(key,default)
if isinstance(r, classad.ExprTree):
return r.eval()
return r | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_value(self, attribute_name, default=None):\n return getattr(self, '%s__' % attribute_name, default)",
"def get_value(self, attribute_name, default=None):\n return getattr(self, '%s__' % attribute_name, default)",
"def get_value(self, attribute_name, default=None):\n return getattr(... | [
"0.71773195",
"0.71773195",
"0.71773195",
"0.7080743",
"0.70802265",
"0.68044543",
"0.66852283",
"0.6642145",
"0.6631746",
"0.6616394",
"0.66116357",
"0.6603584",
"0.6583975",
"0.6549568",
"0.65346",
"0.65248406",
"0.64783686",
"0.64783686",
"0.64703363",
"0.6440669",
"0.6433... | 0.63743913 | 25 |
Randomly sample an element of this space. Can be uniform or nonuniform sampling based on boundedness of space. | def sample(self):
sample = np.zeros(self.n, dtype=self.dtype)
sample[self.np_random.choice(self.n, self.np_random.random_integers(low=self.low_limit, high=self.high_limit),
replace=False)] = 1
return sample | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample(self):\n return gc.rand_state.uniform(low=self.bounds[0], high=self.bounds[1])",
"def sample(self):\n sampleIndices = self.random_state.choice(len(self.X), int(len(self.X)*self.sample_ratio), replace=False)\n\n return self.X[sampleIndices]\n pass",
"def sample(self):\n ... | [
"0.7659973",
"0.70673394",
"0.7062092",
"0.70263",
"0.70029527",
"0.6995633",
"0.6967637",
"0.69616705",
"0.6946771",
"0.68925464",
"0.67660946",
"0.676219",
"0.66827625",
"0.66009057",
"0.65529644",
"0.64779615",
"0.64280087",
"0.6408345",
"0.64030814",
"0.63998497",
"0.6392... | 0.68871117 | 10 |
finds extremes of voltage | def find_min_max(data):
v = [i[1] for i in data]
extremes = [min(v), max(v)]
logging.info('Calculated extremes: %s', extremes)
return extremes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_extremes(self, attr='values'):\n # calculate the maximum and minimum for all series\n series_max = [0]\n series_min = [0]\n for s in self:\n if s is not None:\n series_max.append(s.max(attr))\n series_min.append(s.min(attr))\n ret... | [
"0.6563574",
"0.6332295",
"0.62120295",
"0.6158018",
"0.6149009",
"0.6124345",
"0.60902345",
"0.60367835",
"0.59389496",
"0.5917776",
"0.5907427",
"0.58263284",
"0.58249635",
"0.58215797",
"0.5821129",
"0.5806169",
"0.58006585",
"0.57998943",
"0.57896847",
"0.57839006",
"0.57... | 0.67037874 | 0 |
calculate duration of data in seconds | def find_duration(data):
t = [i[0] for i in data]
duration = t[len(t) - 1] - t[0]
logging.info('Calculated duration: %s', duration)
return duration | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_duration(data):\n try:\n start_time = data.Time.min()\n end_time = data.Time.max()\n duration = end_time-start_time\n print(duration)\n return duration\n except AttributeError:\n logging.error(\"The dataframe needs to have a Time header\")\n return",
... | [
"0.75729847",
"0.7434915",
"0.7398723",
"0.7352046",
"0.73077095",
"0.72734934",
"0.7242477",
"0.72206455",
"0.7208781",
"0.7178817",
"0.7178817",
"0.71487856",
"0.7125967",
"0.7125967",
"0.7092624",
"0.7074142",
"0.7065374",
"0.70556056",
"0.70512605",
"0.7041593",
"0.701815... | 0.78165597 | 0 |
Removes legal entity, technical description or firm type from firm name Input | def regex_strip_legalname(raw_names):
pattern = r"(\s|\.|\,|\&)*(\.com|Enterprise|Worldwide|Int\'l|N\.V\.|LLC|Co\b|Inc\b|Corp\w*|Group\sInc|Group|Company|Holdings\sInc|\WCo(\s|\.)|plc|Ltd|Int'l\.|Holdings|\(?Class\s\w+\)?)\.?\W?"
stripped_names = [re.sub(pattern,'', n) for n in raw_names]
return s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_specific_name(x: str) -> str:\n\n # this is a list of terms that are not actual species names or specific names that have never been part of\n # a fiddler genus\n skip_list = (\"sp.\",\n \"spp.\",\n \"var.\",\n \"nov.\",\n \"a\",\n ... | [
"0.59831333",
"0.57845896",
"0.5561985",
"0.5539644",
"0.55168295",
"0.5480294",
"0.54691833",
"0.5467891",
"0.544982",
"0.544306",
"0.53979456",
"0.5360318",
"0.5330073",
"0.5323373",
"0.531204",
"0.53006905",
"0.5261108",
"0.5261108",
"0.5260638",
"0.5248523",
"0.5214366",
... | 0.50785214 | 25 |
Yield successive nsized chunks from list lst | def list_batch(lst, n=5):
for i in range(0, len(lst), n):
yield lst[i:i + n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunks(self, lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]",
"def chunks(lst: list, n: int):\n for i in range(0, len(lst), n):\n yield lst[i : i + n]",
"def chunks(lst, n):\n for i in range(0, len(lst), n):\n yield lst[i : i + n]",
"... | [
"0.84788555",
"0.8475035",
"0.84373796",
"0.84367806",
"0.84367806",
"0.83867484",
"0.8364551",
"0.8356401",
"0.8356401",
"0.83249915",
"0.83249915",
"0.83249915",
"0.83249915",
"0.83249915",
"0.83238053",
"0.83238053",
"0.83238053",
"0.83238053",
"0.83238053",
"0.83238053",
... | 0.0 | -1 |
Constructor that will appropriately initialize a supervised learning object @ In, None @ Out, None | def __init__(self):
super().__init__()
import sklearn
import sklearn.svm
self.model = sklearn.svm.NuSVR | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, learning_rate=0.1):\n self.learning_rate = learning_rate\n self._b = 0.0 # y-intercept\n self._w = None # weights assigned to input features\n # count of errors during each iteration\n self.misclassified_samples = []",
"def __init__(self, initialLearnRate):... | [
"0.7502165",
"0.7372804",
"0.7321381",
"0.72918063",
"0.72507447",
"0.7185129",
"0.71837455",
"0.7158798",
"0.71277905",
"0.71103",
"0.71056765",
"0.7085013",
"0.70614153",
"0.7045403",
"0.7045152",
"0.7023761",
"0.702244",
"0.70184857",
"0.7005048",
"0.6981176",
"0.6962386",... | 0.0 | -1 |
Test sanitized input for filename | def test_sanitized_filename(self):
value = "/absolute/path/to/the/file.txt"
response = clean.filename(value)
assert response == "file.txt"
value = "../relative/path/to/the/file.txt"
response = clean.filename(value)
assert response == "file.txt" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_filename_safe(value):\n return value == str_to_filename(value)",
"def test_sanitize_content_filename(filename, expected):\n assert sanitize_content_filename(filename) == expected",
"def is_filename_safe(filename: str) -> bool:\n allowed_format = \"|\".join(FileStoreManager.ALL_FORMAT) # png... | [
"0.7740316",
"0.7491698",
"0.7317127",
"0.7304518",
"0.719281",
"0.7183117",
"0.71796376",
"0.71707016",
"0.7127195",
"0.7066707",
"0.7056003",
"0.7027526",
"0.70222557",
"0.7010979",
"0.70102715",
"0.70009184",
"0.6993445",
"0.6924603",
"0.6922179",
"0.69212633",
"0.69008577... | 0.7524211 | 1 |
Assert response resource not the same as video_id | def assert_response_resource_not_accessible(self, response):
self.assertEqual(response.status_code, 403)
self.assertEqual(
response.json(),
{"detail": "You do not have permission to perform this action."},
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_single_movie_incorrect_id(client):\n resp = client.get(f\"/api/movies/{30}/\")\n assert resp.status_code == 404",
"def _assert_video_removal(self, url, edx_video_id, deleted_videos):\n response = self.client.get_json(url)\n self.assertEqual(response.status_code, 200)\n res... | [
"0.6865544",
"0.66094905",
"0.6582229",
"0.6546155",
"0.65414405",
"0.65024304",
"0.6414523",
"0.6356673",
"0.633165",
"0.62834114",
"0.6281705",
"0.62774",
"0.6177243",
"0.6176217",
"0.615378",
"0.6153552",
"0.6139468",
"0.6086457",
"0.60766995",
"0.6057668",
"0.6054404",
... | 0.0 | -1 |
Assert a user cannot retrieve with a GET request. | def assert_user_cannot_read(self, user, video):
livesession = LiveSessionFactory(
email=user.email,
is_registered=True,
user=user,
video=video,
)
jwt_token = UserAccessTokenFactory(user=user)
response = self.client.get(
self._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unauthenticated_get(self):\n url = reverse('edit-list')\n\n response = self.client.get(url)\n self.assertEqual(403, response.status_code)\n self.assertEqual('Forbidden', response.status_text)\n self.assertTrue(\n 'credentials were not provided.' in response.da... | [
"0.7621194",
"0.75339085",
"0.75293666",
"0.74902266",
"0.74777055",
"0.7363981",
"0.7324574",
"0.7312986",
"0.7293313",
"0.72749007",
"0.7248937",
"0.7242906",
"0.7242906",
"0.7236196",
"0.72310865",
"0.7211645",
"0.7200218",
"0.71942496",
"0.71869856",
"0.71842724",
"0.7176... | 0.6622758 | 81 |
Assert a user can retrieve with a GET request. | def assert_user_can_read(self, user, video):
livesession = LiveSessionFactory(
email=user.email,
is_registered=True,
user=user,
video=video,
)
jwt_token = UserAccessTokenFactory(user=user)
response = self.client.get(
self._get... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_resource_user_resource_get_user_get(self):\n pass",
"def test_authenticated_get(self):\n url = reverse('edit-list')\n\n # authenticate the user\n self.login_user()\n # attemot the get\n response = self.client.get(url)\n self.assertEqual(200, response.stat... | [
"0.7166883",
"0.7138416",
"0.70784193",
"0.70585805",
"0.6992651",
"0.6986855",
"0.6977386",
"0.6973829",
"0.69427407",
"0.68977714",
"0.6843212",
"0.6823857",
"0.68225884",
"0.68099844",
"0.6809175",
"0.6809175",
"0.6802624",
"0.67927337",
"0.67833954",
"0.6781077",
"0.67585... | 0.0 | -1 |
Organization students cannot fetch a livesession. | def test_read_by_organization_student(self):
organization_access = OrganizationAccessFactory(
role=STUDENT,
organization=self.organization,
)
self.assert_user_cannot_read(organization_access.user, self.live) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_livesession_student_cant_read_attendances(self):\n video = VideoFactory(\n live_state=RUNNING,\n live_info={\n \"started_at\": \"1533686400\",\n },\n live_type=JITSI,\n )\n # livesession with consumer_site\n live_se... | [
"0.69396657",
"0.60998213",
"0.5820081",
"0.580893",
"0.5780033",
"0.5774209",
"0.57409483",
"0.57314104",
"0.5679426",
"0.56671363",
"0.5634951",
"0.5633022",
"0.5632234",
"0.5592719",
"0.5561808",
"0.5554536",
"0.5554224",
"0.5553618",
"0.5545273",
"0.55272835",
"0.5523342"... | 0.54202193 | 39 |
Control we can only read livesession from the same consumer site. The video is portable in another playlist portable from another consumer site, the livesession should not be return, if this one has been added with a token with no consumer_site. | def test_api_livesession_read_token_lti_record_consumer_none(self):
# livesession has no consumer_site
livesession = AnonymousLiveSessionFactory()
# token has context_id so different consumer_site
jwt_token = LTIPlaylistAccessTokenFactory(
playlist=livesession.video.playlist... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_livesession_read_token_public_other_video_context_none_role(self):\n # livesession with no consumer_site\n livesession = AnonymousLiveSessionFactory()\n\n # token with no context_id leading to the same undefined consumer_site\n jwt_token = PlaylistAccessTokenFactory(playlis... | [
"0.74330837",
"0.72926605",
"0.7244288",
"0.72079664",
"0.71049285",
"0.67819166",
"0.66117543",
"0.6597018",
"0.6585724",
"0.6561933",
"0.6497419",
"0.6222364",
"0.62131536",
"0.61634046",
"0.6113718",
"0.6005495",
"0.59983224",
"0.59963846",
"0.5977246",
"0.5946793",
"0.580... | 0.7051434 | 5 |
Control we can only read livesession from the same consumer site. The video is portable in another playlist portable from another consumer site, the livesession should not be return, if this one has been added with a token with a different consumer_site. | def test_api_livesession_read_token_lti_record_consumer_diff(self):
other_consumer = ConsumerSiteFactory()
# livesession has consumer_site
livesession = LiveSessionFactory(
is_from_lti_connection=True,
consumer_site=other_consumer, # enforce other consumer site than vide... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_livesession_read_token_public_other_video_context_none_role(self):\n # livesession with no consumer_site\n livesession = AnonymousLiveSessionFactory()\n\n # token with no context_id leading to the same undefined consumer_site\n jwt_token = PlaylistAccessTokenFactory(playlis... | [
"0.7290013",
"0.7129776",
"0.7070606",
"0.6980318",
"0.6874617",
"0.66768795",
"0.6556682",
"0.6531182",
"0.65159345",
"0.64711285",
"0.64142853",
"0.6243148",
"0.6192172",
"0.60892063",
"0.6077968",
"0.60695493",
"0.60295534",
"0.6023179",
"0.6019862",
"0.5817822",
"0.580035... | 0.716866 | 1 |
Control we can only read livesession from the same course. The video is portable in another playlist portable from another course, the livesession should not be return, if this one has been added with a token from a different course. | def test_api_livesession_read_token_lti_record_course_diff(self):
other_consumer = ConsumerSiteFactory()
# livesession has consumer_site
livesession = LiveSessionFactory(
is_from_lti_connection=True,
consumer_site=other_consumer, # enforce other consumer site than video'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_livesession_read_token_lti_other_video_context_none_role(self):\n # livesession with no consumer_site\n livesession = LiveSessionFactory(is_from_lti_connection=True)\n\n jwt_token = LTIPlaylistAccessTokenFactory(\n playlist=VideoFactory().playlist, # other video\n ... | [
"0.7078306",
"0.7044489",
"0.6915882",
"0.6829117",
"0.6641847",
"0.66337645",
"0.6599042",
"0.65749264",
"0.65549153",
"0.65521795",
"0.65022475",
"0.6365631",
"0.6344898",
"0.628964",
"0.62735015",
"0.6253598",
"0.6229169",
"0.6117276",
"0.61119545",
"0.61066234",
"0.610093... | 0.67971104 | 4 |
Admin/instructor can read all livesession belonging to a video. | def test_api_livesession_read_token_lti_admin_instruct_email_diff(self):
# livesession with no consumer site
livesession = AnonymousLiveSessionFactory(
email="different@aol.com",
)
jwt_token = InstructorOrAdminLtiTokenFactory(
# context_id and consumer_site are n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_video_read_detail_as_instructor_in_read_only(self):\n video = factories.VideoFactory(upload_state=\"ready\")\n\n jwt_token = AccessToken()\n jwt_token.payload[\"resource_id\"] = str(video.id)\n jwt_token.payload[\"roles\"] = [random.choice([\"instructor\", \"administrator\"... | [
"0.70488054",
"0.70428854",
"0.69658476",
"0.6871483",
"0.68701327",
"0.6803738",
"0.66802174",
"0.6667102",
"0.6626952",
"0.657966",
"0.6537486",
"0.6516718",
"0.6514493",
"0.64654905",
"0.64510477",
"0.6438336",
"0.6355492",
"0.6323079",
"0.6300556",
"0.6295852",
"0.6285333... | 0.5587022 | 86 |
Admin/instructor can read all livesession belonging to a video. | def test_api_livesession_read_token_lti_admin_instruct_record_consumer_diff(self):
other_consumer_site = ConsumerSiteFactory()
# livesession with consumer_site
livesession = LiveSessionFactory(
consumer_site=other_consumer_site,
is_from_lti_connection=True,
em... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_video_read_detail_as_instructor_in_read_only(self):\n video = factories.VideoFactory(upload_state=\"ready\")\n\n jwt_token = AccessToken()\n jwt_token.payload[\"resource_id\"] = str(video.id)\n jwt_token.payload[\"roles\"] = [random.choice([\"instructor\", \"administrator\"... | [
"0.7049502",
"0.7044813",
"0.696745",
"0.68729174",
"0.6871903",
"0.68047124",
"0.66808295",
"0.66678184",
"0.6626249",
"0.65800154",
"0.6539541",
"0.6518039",
"0.65153825",
"0.64673316",
"0.64514565",
"0.64385307",
"0.63546854",
"0.63250285",
"0.63016814",
"0.6295473",
"0.62... | 0.5908801 | 48 |
Admin/instructor can read all livesession belonging to a video. | def test_api_livesession_read_token_lti_admin_instruct_record_course_diff(self):
other_consumer_site = ConsumerSiteFactory()
# livesession with consumer_site
livesession = LiveSessionFactory(
consumer_site=other_consumer_site,
email="admin@openfun.fr", # explicit to be f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_video_read_detail_as_instructor_in_read_only(self):\n video = factories.VideoFactory(upload_state=\"ready\")\n\n jwt_token = AccessToken()\n jwt_token.payload[\"resource_id\"] = str(video.id)\n jwt_token.payload[\"roles\"] = [random.choice([\"instructor\", \"administrator\"... | [
"0.7049502",
"0.7044813",
"0.696745",
"0.68729174",
"0.6871903",
"0.68047124",
"0.66808295",
"0.66678184",
"0.6626249",
"0.65800154",
"0.6539541",
"0.6518039",
"0.65153825",
"0.64673316",
"0.64514565",
"0.64385307",
"0.63546854",
"0.63250285",
"0.63016814",
"0.6295473",
"0.62... | 0.6128341 | 28 |
Test that the sync_all_models task starts subtasks to sync all models. | def test_sync_all_models(monkeypatch):
sync_model_mock = Mock()
monkeypatch.setattr('datahub.search.tasks.sync_model', sync_model_mock)
sync_all_models.apply()
tasks_created = {call[1]['args'][0] for call in sync_model_mock.apply_async.call_args_list}
assert tasks_created == {app.name for app in ge... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sync_all_to_sugar(self):\n self.assertEqual(sync_all_to_sugar(sugar=MockSugar()), None)",
"def test_all_tasks_with_dummy_model(tasks):\n model = dummy_model.DummyModel()\n run_tasks(model, get_task_list(tasks))",
"def test_synchronize_all_networks(self):\n\n # Store two tenants in a db... | [
"0.67150646",
"0.6645489",
"0.6408561",
"0.6393947",
"0.63218826",
"0.62428296",
"0.6058084",
"0.5738316",
"0.5727992",
"0.5719004",
"0.5666309",
"0.56628525",
"0.56306374",
"0.56288415",
"0.5621453",
"0.5602244",
"0.55847615",
"0.5561826",
"0.55304426",
"0.55164915",
"0.5514... | 0.7754521 | 0 |
Do not return anything, modify head inplace instead. | def reorderList(self, head: Optional[ListNode]) -> None:
# Find the mid of the list
slow, fast = head, head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
# Reverse second half
prev, curr = None, slow
while curr:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def head(self, head):\n\n self._head = head",
"def move_to_head(self, node):\n if node is self.head:\n return\n value = node.value\n self.delete(node)\n self.add_to_head(value)",
"def _move_to_head(self, node):\n self._remove_node(node)\n self._add_no... | [
"0.7218526",
"0.6802109",
"0.6732775",
"0.6622557",
"0.65217346",
"0.6466963",
"0.64551795",
"0.63585746",
"0.63093",
"0.62923217",
"0.6231313",
"0.622523",
"0.62005043",
"0.62005043",
"0.62005043",
"0.62005043",
"0.6198878",
"0.6193791",
"0.61740905",
"0.6149187",
"0.6120934... | 0.63523316 | 8 |
Renders the index page. | def index(request, err_msg=None):
template = loader.get_template("aimodel/index.html")
context = {}
context["err_msg"] = err_msg
return HttpResponse(template.render(context, request)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(self):\n\t\treturn render_template('index.html')",
"def index():\r\n return render_template('index.html')",
"def index():\n return render_template('index.html')",
"def index():\n return render_template('index.html')",
"def index():\n return render_template('ind... | [
"0.8516521",
"0.84311795",
"0.84310013",
"0.84145755",
"0.84145755",
"0.83851033",
"0.8294009",
"0.8237511",
"0.8237511",
"0.8237109",
"0.81209147",
"0.81209147",
"0.81209147",
"0.8120692",
"0.8102571",
"0.80926615",
"0.8088879",
"0.80883557",
"0.8076846",
"0.80755824",
"0.80... | 0.0 | -1 |
Loads the VoxCeleb Audio data paths into a DataFrame. | def enumerate_vox(directory: pathlib.Path):
if type(directory) is not pathlib.Path:
directory = pathlib.Path(directory)
assert directory.exists(), f"Directory {directory} does not exist."
top = directory / 'aac'
try:
import psutil
import os
filesize = os.path.getsize(top.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_vox(data: pd.DataFrame, in_place: bool = False):\n if not in_place:\n mod = data.copy()\n else:\n mod = data\n clips = []\n channels = []\n samplerates = []\n durations = []\n for i, row in mod.iterrows():\n sys.stdout.write(f\"\\r[-] Reading: {i} of {len(mod)} ({... | [
"0.7015144",
"0.67165434",
"0.620072",
"0.6104628",
"0.6067592",
"0.60180914",
"0.59482944",
"0.59316623",
"0.591221",
"0.5895084",
"0.58752614",
"0.587172",
"0.5849425",
"0.58391815",
"0.5833638",
"0.58336264",
"0.58178675",
"0.5806555",
"0.5796249",
"0.5785747",
"0.5785747"... | 0.5886255 | 10 |
Test negative value to KNX. | def test_to_knx_negative(self):
self.assertEqual(DPTSignedRelativeValue.to_knx(-128), (0x80,))
self.assertEqual(DPTSignedRelativeValue.to_knx(-100), (0x9C,))
self.assertEqual(DPTSignedRelativeValue.to_knx(-2), (0xFE,))
self.assertEqual(DPTSignedRelativeValue.to_knx(-1), (0xFF,)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_to_knx_positive(self):\n self.assertEqual(DPTSignedRelativeValue.to_knx(0), (0x00,))\n self.assertEqual(DPTSignedRelativeValue.to_knx(1), (0x01,))\n self.assertEqual(DPTSignedRelativeValue.to_knx(2), (0x02,))\n self.assertEqual(DPTSignedRelativeValue.to_knx(100), (0x64,))\n ... | [
"0.68053955",
"0.6726487",
"0.6411598",
"0.6345561",
"0.63211316",
"0.62936616",
"0.62058496",
"0.61806506",
"0.61336356",
"0.61026883",
"0.6065826",
"0.605254",
"0.60103256",
"0.59738845",
"0.5934937",
"0.59000635",
"0.58856183",
"0.5862906",
"0.58206373",
"0.58085597",
"0.5... | 0.71781117 | 0 |
If you give an existing Rectangle to init, the current rectangle will be identical to that one. This is useful for subclasses. | def transforminitargs(cls, *args, rectangle=None, **kwargs):
rectanglekwargs = {}
if rectangle is not None:
rectanglekwargs = {
**{
field: getattr(rectangle, field)
for field in dataclassy.fields(type(rectangle))
}
}
return super().transforminitargs(
*ar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, height, width):\n\n\t\t# _width and _height are internal (private) Rectangle Instance's attributes. This is something\n\t\t# We keep to ourselves to make sure the User can't just update these attrs randomly and also\n\t\t# so that the code has backward compatibility.\n\t\tself._width = None\n\t\... | [
"0.75346255",
"0.7432669",
"0.73152894",
"0.6910756",
"0.6867908",
"0.6767048",
"0.67061615",
"0.67058426",
"0.6570992",
"0.6478708",
"0.6457321",
"0.6289654",
"0.62825155",
"0.61844367",
"0.6169897",
"0.61645275",
"0.6157988",
"0.6149874",
"0.6127559",
"0.6094426",
"0.608606... | 0.0 | -1 |
The broadband filter id for this layer | def broadbandfilter(self):
_, = self.broadbandfilters
return _ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traffic_mirror_filter_id(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"traffic_mirror_filter_id\")",
"def traffic_mirror_filter_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"traffic_mirror_filter_id\")",
"def traffic_mirror_filter_id(self) -> Optional[pulumi.Input[str]... | [
"0.6700582",
"0.65268505",
"0.6473297",
"0.63865507",
"0.61556107",
"0.59912837",
"0.5887714",
"0.567973",
"0.5642893",
"0.55304307",
"0.55137503",
"0.54667735",
"0.53500754",
"0.53469115",
"0.53317666",
"0.52922195",
"0.52897483",
"0.5288971",
"0.5288971",
"0.5286894",
"0.52... | 0.67852503 | 0 |
Parses an object out of JSON tokens | def parse_object(tokens: Deque[Token]) -> JSONObject:
obj: JSONObject = {}
# special case:
if tokens[0].type == 'right_brace':
tokens.popleft()
return obj
while tokens:
token = tokens.popleft()
if not token.type == 'string':
raise ParseError(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(json_string: str) -> object:\n tokens = tokenize(json_string)\n\n value = _parse(tokens)\n if len(tokens) != 0:\n raise ParseError(\n f\"Invalid JSON at {tokens[0].value} \"\n f\"(line {tokens[0].line} column {tokens[0].column})\")\n\n return value",
"def parse_... | [
"0.6929329",
"0.67512417",
"0.67396253",
"0.66605514",
"0.6528865",
"0.64857805",
"0.6480562",
"0.6454458",
"0.6298291",
"0.6291987",
"0.6240389",
"0.61767405",
"0.6158705",
"0.6146784",
"0.612444",
"0.6120313",
"0.6110793",
"0.6110244",
"0.60553813",
"0.6031592",
"0.60299087... | 0.6889534 | 1 |
Parses an array out of JSON tokens | def parse_array(tokens: Deque[Token]) -> JSONArray:
array: JSONArray = []
# special case:
if tokens[0].type == 'right_bracket':
tokens.popleft()
return array
while tokens:
value = _parse(tokens)
array.append(value)
token = tokens.popleft()
if token.type... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_value(tokens: deque) -> JSON:\n tk = tokens[0]\n\n if tk == \"[\":\n return parse_list(tokens)\n elif tk.type == \"NUMBER\":\n tokens.popleft() # É necessário consumir o 1o token\n return float(tk)\n \n # Complete com as outras regras de objeto, STRING, BOOL e NULL\n ... | [
"0.66905135",
"0.6423509",
"0.6405529",
"0.62673825",
"0.611627",
"0.6105751",
"0.6104584",
"0.60786897",
"0.6055252",
"0.6027563",
"0.5986071",
"0.5892645",
"0.5833111",
"0.5827836",
"0.58231074",
"0.5797738",
"0.5783564",
"0.57752514",
"0.5770648",
"0.57157",
"0.56917876",
... | 0.66233844 | 1 |
Create a txobject from a JSON string. | def from_json(cls, json):
# sender = serialization.load_pem_public_key(json["sender"].encode())
# receiver = serialization.load_pem_public_key(json["receiver"].encode())
tx_inputs = []
for tx_input in json["tx_inputs"]:
tx_inputs.append(TransactionOutput.from_json(tx_input)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_json(cls, string):\n dct = json.loads(string)\n return cls.from_dict(dct)",
"def from_json_str(cls, json_str):\n return cls.from_json(simplejson.loads(json_str))",
"def from_json_string(cls, json_string: Text, check_params=False):\n lparams = json.loads(json_string)\n if... | [
"0.7425078",
"0.72952354",
"0.6922215",
"0.6905086",
"0.69039243",
"0.68402296",
"0.67729115",
"0.6762669",
"0.6762669",
"0.67548835",
"0.67314345",
"0.66914314",
"0.66605496",
"0.66605496",
"0.66605496",
"0.65641135",
"0.6557495",
"0.6557495",
"0.655633",
"0.6540334",
"0.653... | 0.6356844 | 33 |
Make sure that a repository exists and is empty. Return the name of that repository. | def repo_name(conn):
name = conn.repository.database_name
conn.close()
return name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_empty_repository(self):\n os.environ['REPOSITORY'] = ''\n self.assertEqual(self.env.project_repo_name, '')",
"def repository_name(self) -> Optional[str]:\n return pulumi.get(self, \"repository_name\")",
"def repository_name(self) -> Optional[str]:\n return pulumi.get(self, \"reposi... | [
"0.70834315",
"0.70650095",
"0.70650095",
"0.70650095",
"0.63821137",
"0.6319591",
"0.6287283",
"0.62246084",
"0.61868614",
"0.61172897",
"0.6075467",
"0.607445",
"0.60668606",
"0.60452205",
"0.60342276",
"0.5994722",
"0.598412",
"0.5972325",
"0.5972306",
"0.59658056",
"0.595... | 0.53389955 | 72 |
A fixture that makes sure a repository does not exist before the test and also deletes it after the test. The value returned by this fixture is the name of the store. | def non_existing_repo(server):
catalog = server.openCatalog(CATALOG)
store = 'temp-store'
while store in catalog.listRepositories():
store = 'temp-store-' + ''.join(random.choice('0123456789') for _ in range(16))
yield store
if store in catalog.listRepositories():
catalog.deleteRepos... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_collection_delete(repository_collection, faker):\n x_name = faker.word()\n\n repository_collection.delete(x_name)\n\n repository_collection.client.scripts.create_if_missing.assert_called_once()\n repository_collection.client.scripts.run.assert_called_with(\n 'nexus3-cli-repository-delet... | [
"0.59115535",
"0.5897969",
"0.5728862",
"0.5676878",
"0.559541",
"0.5566109",
"0.5513843",
"0.54906553",
"0.5484805",
"0.54383415",
"0.5427661",
"0.5386395",
"0.53539497",
"0.53537637",
"0.532889",
"0.5322896",
"0.53167385",
"0.53014714",
"0.5296024",
"0.5270413",
"0.52568316... | 0.6255285 | 0 |
A test fixture providing access to an instance of the UserData class. All user data changes are undone during cleanup. | def user_data(server):
with contextlib.closing(UserData(server)) as ud:
yield ud | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUpTestData(cls):\n # volunteer user\n common.initialize_empty_volunteer()",
"def setUpTestData(cls) -> None:\n user = User.objects.create(\n username=\"test\",\n email=\"test@example.com\",\n password=User.objects.make_random_password(),\n i... | [
"0.72083414",
"0.709093",
"0.6878094",
"0.68459624",
"0.68448097",
"0.6776075",
"0.6728844",
"0.6702885",
"0.6675313",
"0.6667297",
"0.6647461",
"0.6620915",
"0.6574533",
"0.6574533",
"0.6574533",
"0.6574533",
"0.65356106",
"0.6517822",
"0.65158415",
"0.65067697",
"0.6504434"... | 0.0 | -1 |
Prepend a slash to a string, unless it starts with one already. | def ensure_slash(text):
if text.startswith('/'):
return text
return '/' + text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def starts_slash(url):\n return url if url.startswith(\"/\") else \"/\" + url",
"def ensureOneSlash(s):\n\treturn s.rstrip(\"/\")+\"/\"",
"def leadingSlash(path):\n if path == None or len(path) == 0 or path == '/':\n return '/'\n if path[0] == '/':\n return path\n ... | [
"0.757769",
"0.74330693",
"0.73252136",
"0.7203637",
"0.67708737",
"0.67386395",
"0.67247385",
"0.6695317",
"0.66316605",
"0.6623768",
"0.65975904",
"0.6513887",
"0.64765024",
"0.64454806",
"0.6437237",
"0.63237524",
"0.629294",
"0.61850864",
"0.61308795",
"0.61248326",
"0.61... | 0.78097475 | 0 |
Divide a vector into pieces and return the average for each. | def piecewise_avg(vec, n_groups):
size = len(vec) / n_groups
ends = []
for i in range(1, n_groups + 1):
ends.append(int(size * i))
ends[-1] = len(vec)
sums = []
start = 0
for end in ends:
sums.append(vec[start:end].sum() / (end - start))
start = end
return numpy... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def avg(vector):\n if len(vector) == 0:\n return 0\n return sum(vector) / len(vector)",
"def compute_average(vec_list):\r\n return np.sum(vec_list, axis = 0)/len(vec_list)",
"def mean(v):\n return sum(v)/len(v)",
"def average(cls, vectors):\n return cls.sum(vectors) / len(vectors)",... | [
"0.72715694",
"0.7017395",
"0.7010137",
"0.69049054",
"0.6544908",
"0.65180355",
"0.6517214",
"0.6480198",
"0.6467507",
"0.6467156",
"0.6467156",
"0.6444702",
"0.63790125",
"0.63537896",
"0.6336954",
"0.6332998",
"0.6311281",
"0.6305369",
"0.6275173",
"0.62744904",
"0.6274490... | 0.73543924 | 0 |
Quickly load embedding fft data, using a cache if nothing about the input arguments has changed. | def load_embedding_fft_array(path, start=0, end=None, reload=False,
htid_test=False, n_docs=None, _cache={}):
reload = (reload or not _cache or _cache['start'] != start or
_cache['end'] != end or htid_test or
_cache['n_docs'] != n_docs)
if reload:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache(self):\r\n data = self.input.data\r\n f, cache = tsa.cache_fft(data,\r\n self.ij,\r\n lb=self.lb,\r\n ub=self.ub,\r\n method=self.method,\r\n pr... | [
"0.6133116",
"0.6092971",
"0.58747214",
"0.5550252",
"0.55302346",
"0.5504378",
"0.54992276",
"0.54626495",
"0.5451506",
"0.54478824",
"0.53455627",
"0.5305693",
"0.5297875",
"0.52947557",
"0.5284468",
"0.52843183",
"0.52705926",
"0.52619064",
"0.5244584",
"0.5239117",
"0.520... | 0.713355 | 0 |
Sample `n` values from a 2d normal distribution and represent the result as a vector of complex numbers. When plotted on the imaginary plane, this looks like a blob; hence the name. | def complex_blob(n, scale=1.0, seed=0):
rng = numpy.random.default_rng(seed)
blob = rng.multivariate_normal(
[0, 0], [[scale ** 2, 0], [0, scale ** 2]], n
)
x, y = blob.T
return x + y * 1j | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample(self, n):\n ret = []\n for i in range(n):\n for j in range(n):\n ret.append(self.a + (((0.5 + i) / n) * self.l1) + (((0.5 + j) / n) * self.l2))\n return ret",
"def generate_basis(n, dim):\n planes = [np.random.randn(dim) for i in range(n)]\n return ... | [
"0.65590626",
"0.65129775",
"0.64647657",
"0.6296552",
"0.6186569",
"0.6164371",
"0.6144881",
"0.61101717",
"0.6097649",
"0.60337555",
"0.5984409",
"0.5982221",
"0.5968421",
"0.59483546",
"0.5944581",
"0.5941932",
"0.5922946",
"0.5862705",
"0.58589125",
"0.58427274",
"0.58387... | 0.73738074 | 0 |
Calculate the mangitude of a real vector. If axis is provided, vec is treated as an array of vectors and reduced along the given axis. This will work on arrays of any dimension. | def vector_magnitude(vec, axis=None):
return (vec * vec).sum(axis=axis) ** 0.5 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vector_normalize(vec, axis=None):\n mag = vector_magnitude(vec, axis=axis)\n mag = mag if mag > 0 else 1\n if axis is None:\n return vec / mag\n else:\n axis_ix = [None] * len(vec.shape)\n axis_ix[axis] = slice(None, None, None)\n return vec / numpy.array([mag])[axis_ix]... | [
"0.6525801",
"0.60582083",
"0.59095025",
"0.5875381",
"0.582459",
"0.5820062",
"0.58052224",
"0.57996756",
"0.5795107",
"0.57933223",
"0.5649669",
"0.56187755",
"0.5613727",
"0.55542815",
"0.5525401",
"0.55145586",
"0.5503436",
"0.54624665",
"0.54379",
"0.5425283",
"0.5395266... | 0.70687664 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.