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 |
|---|---|---|---|---|---|---|
Sets the provider of this GroupModel. | def provider(self, provider):
allowed_values = ["github"] # noqa: E501
if provider not in allowed_values:
raise ValueError(
"Invalid value for `provider` ({0}), must be one of {1}" # noqa: E501
.format(provider, allowed_values)
)
self._p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def provider(self, provider):\n\n self._provider = provider",
"def provider(self, provider: Provider) -> None:\n self._provider = provider",
"def set_provider(self, provider):\n \n check = self.check_provider(provider)\n if check is not None:\n self.default_provide... | [
"0.7498156",
"0.72607905",
"0.70867676",
"0.7079431",
"0.68937176",
"0.65203404",
"0.6137128",
"0.5863652",
"0.57979643",
"0.5794294",
"0.5770369",
"0.5765517",
"0.56933933",
"0.5667428",
"0.5606175",
"0.5587098",
"0.5583761",
"0.55306125",
"0.5419826",
"0.5410462",
"0.536335... | 0.6897319 | 4 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, GroupModel):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.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):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
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.76047015",
"0.74474794",
"0.74041575",
"0.7280166",
"0.7208148",
"0.716517",
"0.7156958",
"0.7131029",
"0.710041",
"0.7096404",
"0.7096404",
"0.7096404",
"0.7096404",
"0.7096404",
"0.7096404",
"0.7096404",
"0.7096404",
"0.7096404",
"0.7096404",
"0.7096404",
"0.7096404",
... | 0.7144544 | 10 |
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.7489789",
"0.7288577",
"0.7160126",
"0.71535283",
"0.7066027",
"0.69853693",
"0.6965701",
"0.69550425",
"0.69127744",
"0.6834017",
"0.68179363",
"0.6809387",
"0.6785694",
"0.67576426",
"0.67576426",
"0.67576426",
"0.67576426",
"0.67576426",
"0.67576426",
"0.67576426",
"0.6... | 0.68049496 | 15 |
Clear all extra quantities from field_mappings and config | def clear_quantities(shared):
del_list = [i for i, fm in enumerate(shared.field_mappings)
if fm.extra is not None]
for index in reversed(del_list):
del shared.field_mappings[index]
shared.config.remove_section('extra')
shared.config.add_section('extra') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_up_map(self):\n self.items = [i for i in self.items if i.quantity != 0]",
"def reset_fields(fc):\n\n # Delete classification fields if they already exist in the dataset\n inc_fields = [f.name for f in arcpy.ListFields(fc)]\n\n delete_fields = []\n\n for field in[z_value_field]: # inc... | [
"0.6364374",
"0.6217193",
"0.61390203",
"0.58981806",
"0.5832346",
"0.5819015",
"0.5765438",
"0.575776",
"0.5698789",
"0.56783336",
"0.56783336",
"0.5676035",
"0.56716084",
"0.565995",
"0.56246436",
"0.56174904",
"0.5584232",
"0.557563",
"0.5575127",
"0.55516434",
"0.55498743... | 0.8384985 | 0 |
Yield successive nsized chunks from lst. | def chunks(lst, n, seed = 2020, is_shuffle=True):
random.seed(seed)
if is_shuffle:
shuffle(lst)
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]",
"de... | [
"0.83071756",
"0.81939614",
"0.81910837",
"0.81910837",
"0.8190213",
"0.81267184",
"0.81218547",
"0.81218547",
"0.80773693",
"0.80533457",
"0.80533457",
"0.80533457",
"0.80533457",
"0.80533457",
"0.80533457",
"0.80533457",
"0.80533457",
"0.80533457",
"0.80533457",
"0.80533457",... | 0.0 | -1 |
Convert a scipy sparse matrix to a torch sparse tensor. | def sparse_mx_to_torch_sparse_tensor(sparse_mx):
sparse_mx = sparse_mx.tocoo().astype(np.float32)
indices = torch.from_numpy(
np.vstack((sparse_mx.row, sparse_mx.col)).astype(np.int64))
values = torch.from_numpy(sparse_mx.data)
shape = torch.Size(sparse_mx.shape)
return torch.sparse.FloatTen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def csr2tensor(self, matrix: sp.csr_matrix):\n matrix = matrix.tocoo()\n x = torch.sparse.FloatTensor(\n torch.LongTensor(np.array([matrix.row, matrix.col])),\n torch.FloatTensor(matrix.data.astype(np.float32)),\n matrix.shape,\n ).to(self.device)\n retu... | [
"0.8299787",
"0.8148542",
"0.8045949",
"0.80325705",
"0.80134654",
"0.79973555",
"0.79973555",
"0.7985302",
"0.7985302",
"0.7985302",
"0.7977018",
"0.79650825",
"0.7754673",
"0.7713117",
"0.7429514",
"0.7429514",
"0.735423",
"0.71969247",
"0.7156927",
"0.69882196",
"0.6969645... | 0.80300856 | 14 |
GET all uses QuestionSerializer by default. | def get_serializer_class(self):
if self.request.method in ['GET', ]:
return QuestionSerializer
return QuestionGroupQuestionSerializer | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def questions(self, request, pk):\n tag = self.get_object()\n questions = tag.questions.all()\n serializer = QuestionSerializer(questions, many=True, context={'request': request})\n return Response(serializer.data)",
"def get_questions(self):\n self.post_question()\n ret... | [
"0.715349",
"0.71304595",
"0.7106909",
"0.699531",
"0.6976396",
"0.68824595",
"0.6618705",
"0.6617095",
"0.66126454",
"0.6561686",
"0.6535101",
"0.6515255",
"0.65042275",
"0.6500901",
"0.6410488",
"0.63707465",
"0.63475215",
"0.62995416",
"0.62141913",
"0.6164105",
"0.6110911... | 0.6322442 | 17 |
Return True if path is considered insignificant. | def insignificant(path):
# This part is simply an implementation detail for the code base that the
# script was developed against. Ideally this would be moved out to a config
# file.
return path.endswith('Dll.H') or path.endswith('Forward.H') or \
path.endswith('templates.H') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __nonzero__(self):\n return any(self.path)",
"def _isInterestingPath(self, path: str) -> bool:\n for suffix in self.extensions:\n if path.endswith(suffix):\n return True\n return False",
"def path_is_hidden(path):\n for p in path.parts:\n if p != '..' and p[0] == '.':\n ... | [
"0.6101551",
"0.584425",
"0.5729731",
"0.5727862",
"0.5617974",
"0.5543468",
"0.5515001",
"0.54883116",
"0.5476804",
"0.53790396",
"0.5359712",
"0.535412",
"0.5349357",
"0.53488845",
"0.53102577",
"0.5299268",
"0.5297762",
"0.5286957",
"0.52745855",
"0.52585727",
"0.525564",
... | 0.6165975 | 0 |
Saves added lines into png chart file and prepares plot for new line addition. | def draw_plot(self, plot_name, file_name, num_of_tests):
plt.axis([0, num_of_tests, 0, 100])
plt.title(plot_name)
plt.xlabel("Číslo testu")
plt.ylabel("Přesnost (%)")
plt.legend()
path = os.getcwd()+file_name+".png"
os.makedirs(os.path.dirname(path), exist_ok=True... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linePlot(self):\n clf()\n plot(self.x,self.averages)\n xlabel('X Label (units)')\n ylabel('Y Label (units)')\n savefig('line.png')",
"def updatePlot(self):\n self.axes.clear()\n self.axes.plot(self.data[0], self.data[1], linestyle='-', color='gray')\n s... | [
"0.6540506",
"0.639254",
"0.6388968",
"0.6376275",
"0.6376275",
"0.6376275",
"0.6376275",
"0.6376275",
"0.6359943",
"0.6343007",
"0.63404036",
"0.623976",
"0.61792195",
"0.6118465",
"0.6105118",
"0.6087279",
"0.60757846",
"0.6045443",
"0.6002285",
"0.60008794",
"0.59727067",
... | 0.5570887 | 61 |
Test attributes of Class City | def test_city(self):
my_city = City()
self.assertTrue(hasattr(mycity, "name"))
self.assertEqual(my_city.name, "")
self.assertTrue(hasattr(mycity, "state_id"))
self.assertEqual(my_city.state_id, "") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_attributes(self):\n self.assertTrue(hasattr(self.city, 'name'))\n self.assertTrue(hasattr(self.city, 'state_id'))",
"def test_type_of_attributes(self):\n self.assertIsInstance(self.city.name, str)\n self.assertIsInstance(self.city.state_id, str)",
"def test_attr_type(self):... | [
"0.83744025",
"0.78133166",
"0.78127617",
"0.77511907",
"0.7716359",
"0.76952344",
"0.76537216",
"0.7441304",
"0.7264715",
"0.72645366",
"0.7225852",
"0.7212472",
"0.71441114",
"0.7045063",
"0.7019905",
"0.7000363",
"0.68795675",
"0.6858797",
"0.6812267",
"0.6739816",
"0.6724... | 0.8167105 | 1 |
Return ``True`` if the Pixel Data should to be converted from YCbCr to RGB. This affects JPEG transfer syntaxes. | def needs_to_convert_to_RGB(ds: "Dataset") -> bool:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def should_change_PhotometricInterpretation_to_RGB(ds: \"Dataset\") -> bool:\n return False",
"def rgb(self) -> bool:\n return self.image_shape[2] == 3",
"def check_rgb(image):\n im_yiq = []\n rgb = False\n y = image\n if len(image.shape) > 2 and image.shape[-1] == 3: # The image is RGB\... | [
"0.6485655",
"0.64236915",
"0.6371506",
"0.62484235",
"0.61199087",
"0.6013372",
"0.59540033",
"0.59540033",
"0.58759546",
"0.5786272",
"0.577233",
"0.5736785",
"0.5708002",
"0.5661065",
"0.5609152",
"0.5582685",
"0.5565979",
"0.54774755",
"0.5469251",
"0.5442214",
"0.5399911... | 0.6915101 | 0 |
Insert data to linked list | def insert(self, data):
new_node = Item(data)
new_node.next = self.head
self.head = new_node | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(self, data):\n if self.head == None:\n self.head = Node(data)\n else:\n curr = self.head\n while curr.link != None:\n curr = curr.link\n curr.link = Node(data)",
"def insert_append(self, data):\n node = Node(data)\n ... | [
"0.8260955",
"0.7895376",
"0.76737785",
"0.7642676",
"0.75568575",
"0.75288785",
"0.7469132",
"0.746608",
"0.74265593",
"0.7340274",
"0.7216372",
"0.7203431",
"0.7202156",
"0.7043071",
"0.7041471",
"0.7020388",
"0.701305",
"0.6979278",
"0.69715863",
"0.6943156",
"0.6935461",
... | 0.8271023 | 0 |
check all files have valid names | def all_valid(self):
return all([is_valid_name(_) for _ in self.files]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_file_valid(name: str) -> bool:\n return not name.startswith(\".\")",
"def check_file_name():\n script_name = os.path.basename(__file__)\n import re\n matches = re.findall(r\"(\\d{4}_){,2}lab2\\.py\", script_name)\n if not matches:\n print(f\"[WARN] File name is invalid [{script_name... | [
"0.7428497",
"0.7131344",
"0.7125528",
"0.7104261",
"0.70894283",
"0.70567876",
"0.69553095",
"0.6882373",
"0.68369853",
"0.6784915",
"0.67623967",
"0.67501706",
"0.671571",
"0.6659447",
"0.66479474",
"0.6642254",
"0.66380155",
"0.66296196",
"0.66209155",
"0.66201484",
"0.661... | 0.76052696 | 0 |
replace quats in sequence with interpolated version | def slerp_quats( Q, bad_idxs, allow_roll = True ):
for cur_idx in bad_idxs:
pre_idx = cur_idx-1
preQ = None
while preQ is None:
if pre_idx < 0:
raise IndexError
preQ = Q[pre_idx]
if len(getnan(nx.array((preQ.w,preQ.x,preQ.y,preQ.z)))[0]):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interpolate_replacements(text, expr_replacements):\n if not expr_replacements:\n return [text]\n\n replacement_strings = list(expr_replacements.keys())\n splitter = re.compile(\n \"({0})\".format(\"|\".join(re.escape(r) for r in replacement_strings))\n )\n split_text = [p for p in ... | [
"0.5678295",
"0.5618973",
"0.55559313",
"0.5549054",
"0.5512322",
"0.5482311",
"0.5475914",
"0.5473719",
"0.5446365",
"0.5380866",
"0.5368384",
"0.5351873",
"0.5340748",
"0.531281",
"0.53018826",
"0.52768886",
"0.52396077",
"0.52250856",
"0.52189857",
"0.5204761",
"0.51168203... | 0.54443306 | 9 |
Returns an int64_list from a bool / enum / int / uint. | def _int64_feature(value):
return tf.train.Feature(int64_list=tf.train.Int64List(value=value)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _BoolsToInts(arg_list):\n result = []\n for arg in arg_list:\n if isinstance(arg, (list, tuple)):\n result.append(_BoolsToInts(arg))\n elif arg is True:\n result.append(1)\n elif arg is False:\n result.append(0)\n else:\n result.append(arg)\n\n return result",
"def convertT... | [
"0.68822104",
"0.6595804",
"0.6461252",
"0.6448161",
"0.6367609",
"0.62926817",
"0.6269916",
"0.621823",
"0.6104528",
"0.59533274",
"0.5947467",
"0.5901199",
"0.5863832",
"0.5863832",
"0.58563983",
"0.5844792",
"0.58434534",
"0.5829844",
"0.5801042",
"0.5793561",
"0.5793561",... | 0.55319947 | 45 |
Waters a zone Returns True if able to water, returns False if unable (last water time is too recent) | def water(self):
now = time.time()
if self.state['last_water_time'] is None:
self.state['last_water_time'] = now
if (now == self.state['last_water_time']) or (now - self.state['last_water_time'] > self.min_seconds_between_waterings):
if DEBUG:
print("Debug... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_water(self):\n return False",
"def is_water(self):\n return False",
"def CanBalanceWithWater(self):\n try:\n extra_waters = self._ExtraWaters()\n except ReactantFormulaMissingError:\n return True\n \n return extra_waters is not None",
"de... | [
"0.7053808",
"0.7053808",
"0.6517015",
"0.6466305",
"0.63491946",
"0.62562984",
"0.5901666",
"0.58074063",
"0.5720216",
"0.57053214",
"0.5696398",
"0.5664168",
"0.56331986",
"0.56069124",
"0.5570686",
"0.5555971",
"0.55518997",
"0.5546786",
"0.553766",
"0.54935676",
"0.542973... | 0.67219234 | 2 |
Returns the root node of a tree. This operation assumes that a complete product partition tree is provided for one ad group. The node that has null ParentCriterionId is the root node. | def get_node_by_client_id(product_partitions, client_id=None):
client_node=None
for product_partition in product_partitions:
if product_partition.client_id == client_id:
client_node=product_partition
break
return client_node | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_root_node(self):\n return self.root",
"def root_node(self):\n return self.process_tree",
"def getRoot(self):\n n = self\n while n.parent is not None:\n n = n.parent\n return n",
"def root(self):\n if self.has_multiple_roots:\n raise Valu... | [
"0.66813284",
"0.64856464",
"0.6300651",
"0.6199316",
"0.61867476",
"0.60778415",
"0.5972168",
"0.5925751",
"0.59185165",
"0.591336",
"0.59102345",
"0.58695936",
"0.58393633",
"0.5828653",
"0.5828653",
"0.5783646",
"0.5760971",
"0.57168645",
"0.5663603",
"0.5623278",
"0.56172... | 0.0 | -1 |
Name of the current Juju application. | def _app(self) -> str:
return self.charm.app.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_name():\n return config.APP_NAME",
"def app_name(self):\n return self._app_name",
"def app_name(self) -> str:\n return self._app_name",
"def app_name(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"app_name\")",
"def application_name(self) -> pulumi.Output... | [
"0.81471616",
"0.79351443",
"0.7909901",
"0.79004765",
"0.7808416",
"0.7808416",
"0.78007734",
"0.7581811",
"0.7579881",
"0.7555855",
"0.75472385",
"0.7538527",
"0.75067365",
"0.73825717",
"0.73619986",
"0.73619986",
"0.73619986",
"0.73619986",
"0.73231775",
"0.7181963",
"0.7... | 0.7549485 | 10 |
The Kubernetes namespace we're running in. | def _namespace(self) -> str:
with open("/var/run/secrets/kubernetes.io/serviceaccount/namespace", "r") as f:
return f.read().strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def namespace(self) -> str:\n return pulumi.get(self, \"namespace\")",
"def namespace(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"namespace\")",
"def namespace(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"namespace\")",
"def namespace(self) ->... | [
"0.80273694",
"0.78911114",
"0.78911114",
"0.78911114",
"0.78911114",
"0.78911114",
"0.7827665",
"0.7827665",
"0.7827665",
"0.76884794",
"0.7625922",
"0.75682366",
"0.7510255",
"0.7485709",
"0.74465775",
"0.7446415",
"0.7446415",
"0.7446415",
"0.7446415",
"0.7446415",
"0.7446... | 0.7842258 | 6 |
Tests functionality of 'dummy_authenticated_endpoint' in handler. | def test_dummy_authenticated_endpoint(self):
# For all users created in setUp...
for user in self.users:
# Invokes login
event = {
"username": user['username'],
"pwd": user['pwd']
}
response = handler.user_login(event=even... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_authenticated_uri(self):\n request = self.factory.get(self.uri)\n force_authenticate(request, self.user)\n response = self.view(request)\n response.render()\n self.assertEqual(response.status_code, 200,\n 'Expected Response Code 200, received {0} instead.'\n ... | [
"0.6669248",
"0.66452277",
"0.66452277",
"0.642556",
"0.64208937",
"0.63333386",
"0.62716067",
"0.62524265",
"0.62477714",
"0.61482084",
"0.614508",
"0.6134452",
"0.61091673",
"0.610051",
"0.6095598",
"0.60682094",
"0.60650885",
"0.60413325",
"0.6023572",
"0.6020357",
"0.6003... | 0.8188941 | 0 |
Convert an integer date to a string date. YYYYMMDD > YYYYMMMDD | def format_date(int_date):
if int_date == 0:
return 'today'
tmp_date = int_date
day = tmp_date % 100
tmp_date = tmp_date / 100
month = tmp_date % 100
year = tmp_date / 100
month_str = MONTHS[month]
date_str = '%d-%s-%d' % (year, month_str, day)
return date_str | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_datetime_to_string(dt):\n\treturn '{0}-{1}-{2}'.format(dt.year, dt.month, dt.day)",
"def convert_datetime_to_string(dt):\n\treturn '{0}-{1}-{2}'.format(dt.year, dt.month, dt.day)",
"def int_to_date(date):\n\n year = date / 10**4\n month = date % 10**4 / 10**2\n day = date % 10**2\n\n re... | [
"0.73250073",
"0.73250073",
"0.7205232",
"0.7134138",
"0.70699203",
"0.7065101",
"0.7046285",
"0.70349044",
"0.7026851",
"0.6993089",
"0.6948385",
"0.69187695",
"0.6913919",
"0.690657",
"0.68742037",
"0.68742037",
"0.68742037",
"0.6871451",
"0.67320544",
"0.67129385",
"0.6699... | 0.78848255 | 0 |
Returns project's root working directory (entire path). Returns string Path to project's root directory. | def get_project_root():
# Get current working directory
cwd = os.getcwd()
# Remove all children directories
rd = os.path.join(cwd.split('stochastic-travel-demand-modelling/', 1)[0])
# Make sure directory ends with project's name
if not rd.endswith('stochastic-travel-demand-modelling'):
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project_root() -> Path:\n return PROJECT_ROOT",
"def getProjectRootDir():\n return ROOT_DIR",
"def get_project_root() -> Path:\n return Path(__file__).parent.parent",
"def get_project_root() -> Path:\n return Path(__file__).parent.parent",
"def get_project_root() -> Path:\n return Pa... | [
"0.85936373",
"0.83282125",
"0.8312298",
"0.8312298",
"0.8312298",
"0.8312298",
"0.8278842",
"0.8177462",
"0.81329143",
"0.80996335",
"0.8093347",
"0.8082763",
"0.8082763",
"0.7993069",
"0.7930441",
"0.78737926",
"0.78507364",
"0.77732915",
"0.7752615",
"0.7744949",
"0.771998... | 0.771375 | 21 |
Sessionwide test `Flask` application. | def app(request):
settings_override = {
'TESTING': True,
}
yield settings_override | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app():\n os.environ[\"FLASK_ENV\"] = \"test\"\n return create_app()",
"def app() -> flask.Flask:\n test_app: flask.Flask = create_app(\"tests.conftest.TestConfig\")\n test_app.logger.setLevel(\"CRITICAL\")\n test_context = test_app.test_request_context()\n test_context.push()\n\n yield t... | [
"0.8047767",
"0.75766337",
"0.7453325",
"0.7448997",
"0.7378813",
"0.7361134",
"0.7335257",
"0.7256735",
"0.7174306",
"0.7166491",
"0.714767",
"0.714767",
"0.714767",
"0.7147354",
"0.7145838",
"0.7138676",
"0.71294713",
"0.71052396",
"0.70688695",
"0.7067603",
"0.7002536",
... | 0.0 | -1 |
Compute Area Under the Uplift Curve from prediction scores. | def uplift_auc_score(y_true, uplift, treatment):
# ToDO: Add normalization
# ToDO: Add baseline
return auc(*uplift_curve(y_true, uplift, treatment)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auc(self,predictions,labels):\n\n # sort the array by predictions in descending order in case it has not been done\n order = np.flipud(predictions.argsort())\n labels = labels[order]\n\n # clean labels, calculate the number of positive labels\n labeled_true = (np.asarray(labe... | [
"0.66294956",
"0.65651476",
"0.6456004",
"0.64363694",
"0.63966006",
"0.6256422",
"0.6182779",
"0.61570245",
"0.60881525",
"0.6074789",
"0.60486394",
"0.60328346",
"0.6003431",
"0.5973575",
"0.594633",
"0.5941757",
"0.5935597",
"0.5931766",
"0.59089917",
"0.59020466",
"0.5897... | 0.61500573 | 8 |
Compute Area Under the Uplift Curve from prediction scores. | def auuc(y_true, uplift, treatment):
warnings.warn(
'Metric `auuc` was renamed to `uplift_auc_score`'
'in version 0.1.0 and will be removed in 0.2.0',
FutureWarning
)
return uplift_auc_score(y_true, uplift, treatment) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auc(self,predictions,labels):\n\n # sort the array by predictions in descending order in case it has not been done\n order = np.flipud(predictions.argsort())\n labels = labels[order]\n\n # clean labels, calculate the number of positive labels\n labeled_true = (np.asarray(labe... | [
"0.6630244",
"0.65645206",
"0.64559364",
"0.64355165",
"0.6397641",
"0.6257192",
"0.6180602",
"0.6155692",
"0.61506444",
"0.60884345",
"0.60743606",
"0.6048635",
"0.60312843",
"0.600411",
"0.5945924",
"0.5943082",
"0.59351397",
"0.5931023",
"0.59104717",
"0.5904262",
"0.58968... | 0.59735817 | 14 |
Compute Area Under the Qini Curve (aka Qini coefficient) from prediction scores. | def qini_auc_score(y_true, uplift, treatment):
# ToDO: Add normalization
# ToDO: Add baseline
return auc(*qini_curve(y_true, uplift, treatment)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_ap(recall: np.array, precision: np.array) -> np.array:\n # Append sentinel values to beginning and end\n mrec = np.concatenate(([0.], recall, [min(recall[-1] + 1E-3, 1.)]))\n mpre = np.concatenate(([0.], precision, [0.]))\n\n # Compute the precision envelope\n mpre = np.flip(np.maximum.a... | [
"0.59268594",
"0.5907993",
"0.5871902",
"0.57250816",
"0.5681551",
"0.5668508",
"0.56565577",
"0.5642054",
"0.5627936",
"0.56171614",
"0.5587005",
"0.55849063",
"0.55826133",
"0.55822843",
"0.5552341",
"0.5542468",
"0.5535257",
"0.5529099",
"0.5526554",
"0.5526554",
"0.552286... | 0.62072194 | 0 |
Compute Area Under the Qini Curve (aka Qini coefficient) from prediction scores. | def auqc(y_true, uplift, treatment):
warnings.warn(
'Metric `auqc` was renamed to `qini_auc_score`'
'in version 0.1.0 and will be removed in 0.2.0',
FutureWarning
)
return qini_auc_score(y_true, uplift, treatment) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def qini_auc_score(y_true, uplift, treatment):\n # ToDO: Add normalization\n # ToDO: Add baseline\n return auc(*qini_curve(y_true, uplift, treatment))",
"def compute_ap(recall: np.array, precision: np.array) -> np.array:\n # Append sentinel values to beginning and end\n mrec = np.concatenate(([0.]... | [
"0.62072194",
"0.59268594",
"0.5907993",
"0.5871902",
"0.5681551",
"0.5668508",
"0.56565577",
"0.5642054",
"0.5627936",
"0.56171614",
"0.5587005",
"0.55849063",
"0.55826133",
"0.55822843",
"0.5552341",
"0.5542468",
"0.5535257",
"0.5529099",
"0.5526554",
"0.5526554",
"0.552286... | 0.57250816 | 4 |
Closes this database connection. | def close(self):
if getattr(self, "_db", None) is not None:
if not self._db_args['autocommit']:
self._db.commit()
self._db.close()
self._db = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_database(self):\n if self._conn is not None:\n self._conn.close()\n self._conn = None",
"def close_db_connection(cls):\n db.close()",
"def close(self):\n Log.debug('DB -> close')\n # 关闭数据库连接\n self.conn.close()",
"def close(self):\n if... | [
"0.8292057",
"0.8254112",
"0.82229376",
"0.8203255",
"0.818026",
"0.8166083",
"0.81160486",
"0.7871417",
"0.7857391",
"0.7857391",
"0.7857391",
"0.78436184",
"0.784009",
"0.77772814",
"0.7746946",
"0.7742204",
"0.7729554",
"0.77030843",
"0.76807404",
"0.76142853",
"0.7602529"... | 0.7549437 | 25 |
Deletes all seasons of a show | def delete(self, show_id, session):
try:
show = db.show_by_id(show_id, session=session)
except NoResultFound:
raise NotFoundError('show with ID %s not found' % show_id)
args = delete_parser.parse_args()
forget = args.get('forget')
for season in show.season... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self, show_id, season_id, session):\n try:\n show = db.show_by_id(show_id, session=session)\n except NoResultFound:\n raise NotFoundError('show with ID %s not found' % show_id)\n try:\n season = db.season_by_id(season_id, session)\n except NoR... | [
"0.6906248",
"0.67241365",
"0.66384214",
"0.61112946",
"0.6071612",
"0.60186964",
"0.5902297",
"0.5852594",
"0.57554513",
"0.56138754",
"0.54666793",
"0.546592",
"0.5436233",
"0.5413299",
"0.5395587",
"0.53826797",
"0.5351108",
"0.5265867",
"0.5265457",
"0.52568823",
"0.52548... | 0.7964258 | 0 |
Get episodes by show ID | def get(self, show_id, session):
args = entity_parser.parse_args()
# Pagination and sorting params
page = args['page']
per_page = args['per_page']
sort_order = args['order']
# Handle max size limit
if per_page > 100:
per_page = 100
descendin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_episodes(self, show_id):\n if not self.logged_:\n self.do_login()\n if show_id not in self.episodes_data:\n logging.debug(\n 'Load episodes: %s%s',\n self.api_url, self.config['url']['list_episodes'].format(show_id)\n )\n ... | [
"0.77689534",
"0.7684578",
"0.74420786",
"0.7310166",
"0.71478194",
"0.7101126",
"0.69356114",
"0.68908906",
"0.67861664",
"0.6693501",
"0.66874284",
"0.66603124",
"0.6619614",
"0.6617498",
"0.64613616",
"0.6328124",
"0.63167775",
"0.6259481",
"0.6249959",
"0.61752915",
"0.61... | 0.74491817 | 2 |
Get episode by show ID and episode ID | def get(self, show_id, ep_id, session):
try:
db.show_by_id(show_id, session=session)
except NoResultFound:
raise NotFoundError('show with ID %s not found' % show_id)
try:
episode = db.episode_by_id(ep_id, session)
except NoResultFound:
rais... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_episode(self, object_id):\n return self.get_object(\"episode\", object_id)",
"def get_episodes(token, show_id):\n page = 1\n url = 'https://api.thetvdb.com/series/' + str(show_id) + '/episodes?page=' + str(page)\n headers = {'Accept': 'application/json', 'Authorization': token}\n r = r... | [
"0.74157596",
"0.73477",
"0.70848554",
"0.6940887",
"0.67649305",
"0.67379266",
"0.6731169",
"0.6625166",
"0.65566087",
"0.65210557",
"0.65181494",
"0.6486066",
"0.6434558",
"0.638522",
"0.6291047",
"0.6269022",
"0.62437284",
"0.61427504",
"0.6103673",
"0.6090743",
"0.6090551... | 0.7700012 | 0 |
Get all episodes releases by show ID and episode ID | def get(self, show_id, ep_id, session):
try:
db.show_by_id(show_id, session=session)
except NoResultFound:
raise NotFoundError('show with ID %s not found' % show_id)
try:
episode = db.episode_by_id(ep_id, session)
except NoResultFound:
rais... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_episodes(token, show_id):\n page = 1\n url = 'https://api.thetvdb.com/series/' + str(show_id) + '/episodes?page=' + str(page)\n headers = {'Accept': 'application/json', 'Authorization': token}\n r = requests.get(url, headers=headers)\n json_data = json.loads(r.text).get('links')\n first =... | [
"0.76515687",
"0.71136093",
"0.7091169",
"0.68839353",
"0.6878058",
"0.684974",
"0.68375057",
"0.68256164",
"0.68142265",
"0.67627174",
"0.66499025",
"0.650809",
"0.6442885",
"0.6414857",
"0.62919414",
"0.6215414",
"0.61869454",
"0.61320925",
"0.6114624",
"0.6085876",
"0.6073... | 0.80251133 | 0 |
hashes paassword and salt for user and assings to user.hash_password | def set_password(self, password):
self.password_hash = generate_password_hash(f"{password}{self.user_salt}") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _hash_password(self, password):\n passwordhash = bcrypt.hashpw(password.encode('utf8'), bcrypt.gensalt())\n return passwordhash",
"def hash_password(self):\n self.__password = self.str_to_hash(self.__password)",
"def set_password(self, user, password):\n hashed_password = self.h... | [
"0.7511003",
"0.7447282",
"0.7444837",
"0.74161136",
"0.7400125",
"0.7336776",
"0.7300477",
"0.72378194",
"0.7234351",
"0.7233301",
"0.7218163",
"0.7213832",
"0.7158332",
"0.7059815",
"0.7056021",
"0.7030563",
"0.69882905",
"0.69837415",
"0.696973",
"0.6951395",
"0.6903566",
... | 0.692591 | 20 |
verifies current hash_password against new password + salt hash | def check_password(self, password):
return check_password_hash(self.password_hash, f"{password}{self.user_salt}") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __is_correct_password(salt: bytes, pw_hash: bytes, password: str) -> bool:\n return hmac.compare_digest(\n pw_hash, hashlib.pbkdf2_hmac(\"sha256\", password.encode(), salt, 100000)\n )",
"def hash_password(self, original_password):\n self.password = generate_password_hash(original_passwor... | [
"0.723675",
"0.71713704",
"0.7011375",
"0.7002979",
"0.69631004",
"0.69578964",
"0.6936367",
"0.69329584",
"0.68901545",
"0.6888035",
"0.6886871",
"0.6882606",
"0.68739986",
"0.6854401",
"0.6805608",
"0.67832744",
"0.6771275",
"0.6761262",
"0.67524254",
"0.67417544",
"0.67326... | 0.655716 | 48 |
This function takes an (x,y) coordinate and a triangle radius to ouput the coordinates of the triangle as a list. | def get_triangle(radius, xcenter, ycenter, numberOfVertices):
angles = [0.0, (2. / 3.0) * math.pi, (4.0 / 3.0) * math.pi]
vertices = []
for angle in range(0, len(angles)):
x = radius * math.cos(angles[angle]) + xcenter
y = radius * math.sin(angles[angle]) + ycenter
vertices.appen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def triPoints(rect, orientation): \r\n p1 = (rect.center[0]+orientation[0]*rect.size[0]/3.,\r\n rect.center[1]+orientation[1]*rect.size[1]/3.)\r\n p2 = (rect.center[0]-orientation[0]*rect.size[0]/4.,\r\n rect.center[1]-orientation[1]*rect.size[1]/4.)\r\n orthdir = (orientation[1], -or... | [
"0.6264579",
"0.6153603",
"0.60403895",
"0.6035337",
"0.6033001",
"0.6011119",
"0.5974378",
"0.5936714",
"0.5893815",
"0.58567154",
"0.5844231",
"0.5832336",
"0.58251595",
"0.5798073",
"0.57965285",
"0.5794668",
"0.5774607",
"0.5770411",
"0.5761321",
"0.57583463",
"0.57505256... | 0.7523382 | 0 |
Deep merge two dictionaries. The two dictionaries are merged recursively so that values that are themselves dictionaries are merged as well. Entries in dict b override values in dict a. | def merge_dicts(a, b, path=None):
if path is None:
path = []
for key in b:
if key in a:
if isinstance(a[key], dict) and isinstance(b[key], dict):
merge_dicts(a[key], b[key], path + [str(key)])
elif type(a) is type(b):
a[key] = b[key]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_dicts(a, b):\n if not isinstance(b, dict):\n return b\n\n result = a\n for k, v in b.items():\n if k in result and isinstance(result[k], dict):\n result[k] = merge_dicts(result[k], v)\n else:\n result[k] = v\n return result",
"def deep_merge(a,... | [
"0.85159343",
"0.84749436",
"0.82162994",
"0.81826884",
"0.8135638",
"0.8115771",
"0.8100251",
"0.8092431",
"0.80858684",
"0.8057501",
"0.7992476",
"0.79525334",
"0.79335916",
"0.785625",
"0.7836039",
"0.7794589",
"0.77833587",
"0.7739384",
"0.7694073",
"0.76902056",
"0.76676... | 0.77732533 | 17 |
Returns density of Air in g/cc. This is from Table A.4 in Fundamentals of Heat and Mass Transfer Incropera, DeWitt | def pseudoDensity(
self,
Tk=None,
Tc=None,
):
Tk = getTk(Tc, Tk)
self.checkPropertyTempRange("pseudoDensity", Tk)
inv_Tk = 1.0 / getTk(Tc, Tk)
rho_kgPerM3 = 1.15675e03 * inv_Tk**2 + 3.43413e02 * inv_Tk + 2.99731e-03
return rho_kgPerM3 / G_PER_CM3_TO_KG... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def density_of_air(self) -> float:\n\n return self.pressure / (SPECIFIC_GAS_CONSTANT_OF_AIR * self.ambient_temperature)",
"def air_density(self):\n return self.flow_field.air_density",
"def air_density(altitude):\n p = pressure(altitude) # psf\n t = temperature(altitude) # R\n rho = p/... | [
"0.78822154",
"0.7829083",
"0.71805054",
"0.70106447",
"0.6976494",
"0.677124",
"0.6640587",
"0.64853156",
"0.6360587",
"0.63253057",
"0.62796634",
"0.62600636",
"0.6194468",
"0.6137655",
"0.6106348",
"0.60996294",
"0.6099618",
"0.60994434",
"0.6096661",
"0.6038131",
"0.60381... | 0.0 | -1 |
Get name of the class. | def _get_classname(cls):
return cls.__name__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self) -> str:\n return self.class_names[self.class_num]",
"def className(self):\n namevalue = self.__class__.__name__\n return str(namevalue)",
"def f_get_class_name(self):\n return self.__class__.__name__",
"def getClassName(self):\n n = type(self).__name__\n ... | [
"0.8880071",
"0.8774532",
"0.876987",
"0.87567806",
"0.86787975",
"0.865417",
"0.865417",
"0.86346865",
"0.85787356",
"0.8554913",
"0.84429896",
"0.84077644",
"0.8387701",
"0.8312019",
"0.82716143",
"0.8188753",
"0.8188753",
"0.8177206",
"0.8177206",
"0.8177206",
"0.8177206",... | 0.84871656 | 10 |
Get all used annotations. | def _used_annotations(cls) -> set:
return set(field.type for field in dataclasses.fields(cls)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def annotations(self):\n return self._annotations",
"def annotations(self):\n\n return self._annotations",
"def get_annotations(graph):\n return set(_annotation_iter_helper(graph))",
"def annotations(self) -> Iterator['Annotation']:\n return itertools.chain(self.footnotecitations.all(... | [
"0.7582189",
"0.7567262",
"0.69919133",
"0.6862719",
"0.67887175",
"0.6688718",
"0.6658135",
"0.6632644",
"0.6632644",
"0.6505323",
"0.6483809",
"0.64677966",
"0.63713366",
"0.6345742",
"0.626946",
"0.61599547",
"0.61599547",
"0.6152513",
"0.61038715",
"0.60283387",
"0.600438... | 0.6433511 | 12 |
Test that we can manage a `VolttronCentralPlatform`. This test is concerned with managing a `VolttronCentralPlatform` from the same platform. Though in principal that should not matter. We do this from a secondary platform in a diffferent integration test. | def test_manage_agent(pa_instance):
wrapper, agent_uuid = pa_instance
publickey, secretkey = get_new_keypair()
agent = wrapper.build_agent(
serverkey=wrapper.publickey, publickey=publickey, secretkey=secretkey)
peers = agent.vip.peerlist().get(timeout=2)
assert VOLTTRON_CENTRAL_PLATFORM in ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_setup_platform(self, store_mock):\n config = {\n ip.DOMAIN: {\n \"platform\": \"microsoft_face_identify\",\n \"source\": {\"entity_id\": \"camera.demo_camera\"},\n \"group\": \"Test Group1\",\n },\n \"camera\": {\"platfor... | [
"0.64706796",
"0.6285142",
"0.6192805",
"0.61129165",
"0.6098421",
"0.6065588",
"0.60330874",
"0.58783174",
"0.5855061",
"0.5819832",
"0.5795899",
"0.57855546",
"0.5756603",
"0.5746232",
"0.5742218",
"0.5717158",
"0.5687915",
"0.5677127",
"0.56752694",
"0.56602716",
"0.564065... | 0.5556825 | 28 |
Save JSON representation of package container to file file_path. | def toFile(self, file_path) -> None:
json_repr = self.toJSON()
with open(file_path, "w") as f:
f.write(json_repr) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_json(self, json_file):\n try:\n json.dump(self.container, open(json_file, 'w'), indent=4)\n except (FileNotFoundError, IOError) as err:\n print(err)",
"def write_package_json(self) -> None:\n # make sure folder exists\n if not self.package_path.exists():\n... | [
"0.72861004",
"0.7266841",
"0.72017175",
"0.7165451",
"0.70882344",
"0.7080005",
"0.6984982",
"0.6977844",
"0.6972104",
"0.6954177",
"0.6953304",
"0.6953304",
"0.6953304",
"0.69014984",
"0.68612075",
"0.6798283",
"0.67972976",
"0.6796042",
"0.6789203",
"0.678339",
"0.6752863"... | 0.6637014 | 25 |
Create YOLO_V3 model CNN body in Keras. | def yolo_body(inputs, num_anchors, num_classes, architecture="yolov4", base_ops=DarknetConv2D_BN_Leaky):
if architecture == "yolov4":
config = get_yolo_config("yolov4", num_anchors, num_classes, base_ops=base_ops)
outputs = spatial_pyramid_block(cspdarknet_body(inputs), base_ops=base_ops) if config.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_model(new_shape):\n model = Sequential()\n\n\n model.add(Convolution3D(\n input_shape = new_shape[1:],\n filters=64,\n kernel_size=6,\n data_format='channels_first',\n ))\n\n\n model.add(Dropout(0.2))\n\n model.add(Convolution3D(\n filters=64,\n k... | [
"0.69994485",
"0.6812483",
"0.6802783",
"0.6799505",
"0.6775794",
"0.67447317",
"0.6713567",
"0.66745013",
"0.6637123",
"0.661646",
"0.6587527",
"0.6576134",
"0.6569317",
"0.6552251",
"0.65454865",
"0.65211767",
"0.6498319",
"0.64820737",
"0.64793897",
"0.64768475",
"0.642461... | 0.588181 | 80 |
Process Conv layer output | def yolo_boxes_and_scores_lite(feats, anchors, num_classes, input_shape, image_shape):
# 获取输出,即相对整图的长宽以及置信度与概率值
box_xy, box_wh, box_confidence, box_class_probs = yolo_head_lite(feats,
anchors, num_classes, input_shape)
boxes = yolo_correct... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conv_output(model, layer_name, img):\n # this is the placeholder for the input images\n input_img = model.input\n\n try:\n # this is the placeholder for the conv output\n out_conv = model.get_layer(layer_name).output\n except:\n raise Exception('Not layer named {}!'.format(laye... | [
"0.6720857",
"0.6501934",
"0.62365854",
"0.6127954",
"0.6121829",
"0.61155516",
"0.6094045",
"0.6084792",
"0.6082905",
"0.6001638",
"0.6001638",
"0.6001638",
"0.5916043",
"0.5909601",
"0.5895201",
"0.5861889",
"0.5859919",
"0.5859317",
"0.5855007",
"0.5852903",
"0.584325",
... | 0.0 | -1 |
Validates an handler implementation against the IOutput interface. | def output_validator(klass, obj):
members = [
'_setup',
'render',
]
interface.validate(IOutput, obj, members) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate(cls, output_destination):\n # nothing to check :)\n pass",
"def validate(cls, output_destination):\n # nothing to check :)\n pass",
"def _valid_output_type(self, output_type):\n # pylint: disable=W0613, R0201\n return True",
"def output_invalid(self, out... | [
"0.60533357",
"0.60533357",
"0.5886572",
"0.5737378",
"0.56766737",
"0.5650158",
"0.5608917",
"0.55891466",
"0.552297",
"0.5451484",
"0.5414647",
"0.54119366",
"0.54032594",
"0.5399969",
"0.52919513",
"0.52711755",
"0.5225708",
"0.51780194",
"0.50767076",
"0.5066225",
"0.5063... | 0.6808796 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, CloudEvents):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.80886984",
"0.80886984",
"0.8055307",
"0.7983415",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.84560555",
"0.83913696",
"0.8143685",
"0.81403786",
"0.8131871",
"0.8093231",
"0.80915105",
"0.80915105",
"0.80915105",
"0.8084564",
"0.8084564",
"0.8075547",
"0.8075547",
"0.8065006"
] | 0.0 | -1 |
Returns a dict from features to counts Usually, the count will just be 1.0 for indicator functions. | def getFeatures(self, state, action):
util.raiseNotDefined() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_counts(self, X: np.ndarray) -> Dict[int, np.ndarray]:\n return {f: np.bincount(X[:, f].astype(int), minlength=n_cat) for f, n_cat in\n self.categories_per_feature.items()}",
"def count_label_feature_frequency(self):\n label_feature_frequency = {}\n for label in self.l... | [
"0.7821883",
"0.764447",
"0.74018896",
"0.72689825",
"0.7187044",
"0.7147565",
"0.69336647",
"0.6877193",
"0.6863449",
"0.68268955",
"0.6785782",
"0.6725169",
"0.6722362",
"0.6716919",
"0.6654024",
"0.66194445",
"0.6572489",
"0.6565492",
"0.65483856",
"0.6508336",
"0.64834917... | 0.0 | -1 |
Validate password and password2 fields match. | def validate(self, validated_data):
if validated_data['password'] != validated_data['password2']:
raise serializers.ValidationError(
{"error": "Password fields didn't match."})
return validated_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_password2(self):\n if 'password1' in self.cleaned_data and 'password2' in self.cleaned_data:\n if self.cleaned_data['password1'] != self.cleaned_data['password2']:\n raise forms.ValidationError(_(\"The two password fields didn't match.\"))\n return self.cleaned_dat... | [
"0.818635",
"0.81538403",
"0.81434983",
"0.80553186",
"0.8023498",
"0.8023498",
"0.79872715",
"0.79796684",
"0.79789793",
"0.7978222",
"0.79739666",
"0.784966",
"0.7833754",
"0.77879775",
"0.77755076",
"0.77158356",
"0.7711837",
"0.7702989",
"0.7702989",
"0.7604853",
"0.76016... | 0.68367505 | 39 |
Search for the nearest neighbors from the reference set for each element of the query set. The query SFrame must include columns with the same names as the row_label and feature columns used to create the SimilaritySearchModel. | def search(self, data, row_label=None, k=5):
_raise_error_if_not_of_type(row_label, [str, type(None)])
feature = self._state['features']
_raise_error_if_column_exists(data, feature)
if (data[feature].dtype() != self._feature_type):
raise ValueError('Feature columns must hav... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nearest_neighbors(self):\n neighbor_distances_and_indices = []\n for idx, data_point in enumerate(self.data):\n distance = self.euclidean_dis(data_point[:-1], self.query) # Calculate the distance between the query\n # example and the current example from the data.\n\n ... | [
"0.68114066",
"0.6346849",
"0.5588211",
"0.55786014",
"0.55373144",
"0.55322295",
"0.54620737",
"0.54458565",
"0.5420241",
"0.5411248",
"0.5364573",
"0.5329649",
"0.532108",
"0.53099453",
"0.5299332",
"0.52908224",
"0.52700794",
"0.52463645",
"0.52344084",
"0.5212405",
"0.520... | 0.646696 | 1 |
Get absolute path to resource, works for dev and for PyInstaller | def resource_path(relative_path):
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS # pylint: disable=no-member
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_resource_path():\n return os.path.join(os.path.dirname(__file__), \"resources\") + os.path.sep",
"def resourcePath(relative):\r\n try:\r\n # PyInstaller creates a temp folder and stores path in _MEIPASS\r\n base_path = sys._MEIPASS\r\n except Exception:\r\n base_path = os.pa... | [
"0.8369028",
"0.82811016",
"0.82484996",
"0.81395954",
"0.81144196",
"0.8099082",
"0.8094557",
"0.8080269",
"0.8068243",
"0.8067889",
"0.80630267",
"0.80630267",
"0.80630267",
"0.80630267",
"0.80630267",
"0.80630267",
"0.80630267",
"0.805744",
"0.8045351",
"0.8045351",
"0.804... | 0.80550295 | 18 |
Checks if the input data shape is valid | def check_data_shape(self, data_shape):
if not len(data_shape) == 2:
raise ValueError('data_shape should have length 2')
if not data_shape[0] == 1:
raise ValueError('This iterator expects inputs to have 1 channels.') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_shape(placeholder_shape, data_shape):\n\n return True",
"def _isvalid(self, data):\n if data is None:\n return False\n elif isinstance(data, (list,tuple)):\n if len(data) <= 0:\n return False\n else:\n return True\n ... | [
"0.8319323",
"0.7820716",
"0.7808032",
"0.7708385",
"0.765418",
"0.7619648",
"0.75292563",
"0.7452693",
"0.73863083",
"0.7378265",
"0.7335014",
"0.7321489",
"0.7296737",
"0.7134457",
"0.7116714",
"0.7112497",
"0.70817435",
"0.7067729",
"0.70649505",
"0.7062013",
"0.7036901",
... | 0.78938377 | 1 |
Create a fake PPD file (if needed), then mock the getPPD3 method return value to give that file | def mock_cups_ppd(self, cups, file_name=None, input_slots=None):
if file_name is None:
fd, file_name = tempfile.mkstemp()
if file_name:
ppd_contents = self.build_ppd(input_slots=input_slots)
with open(file_name, 'w') as fp:
fp.write(ppd_contents)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_file_by_filename(self, mock_move):\n\n # Mock the move function so we don't actually end up filing\n p = P.PyPDFOCR()\n cwd = os.getcwd()\n filename = os.path.join(\"pdfs\", \"test_super_long_keyword.pdf\")\n out_filename = filename.replace(\".pdf\", \"_ocr.pdf\")\n\n ... | [
"0.5625471",
"0.5596651",
"0.5585879",
"0.5450779",
"0.5437726",
"0.5404796",
"0.5329626",
"0.53271425",
"0.53110844",
"0.53055936",
"0.52987975",
"0.5297079",
"0.5286609",
"0.52834433",
"0.52830815",
"0.5260701",
"0.5256966",
"0.52222717",
"0.52061504",
"0.51922643",
"0.5182... | 0.7241103 | 0 |
Check that the tray_ids field has no value when no PPD is available | def test_prepare_update_from_cups_no_ppd(self, cups):
self.mock_cups_ppd(cups, file_name=False)
connection = cups.Connection()
cups_printer = connection.getPrinters()
vals = self.printer._prepare_update_from_cups(connection, cups_printer)
self.assertFalse('tray_ids' in vals) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_no_cable_errors(self):\n i = 0\n for dpid in self.dpids:\n i += 1\n labels = {'dp_id': '0x%x' % int(dpid), 'dp_name': 'faucet-%u' % i}\n self.assertEqual(\n 0, self.scrape_prometheus_var(\n var='stack_cabling_errors_total',... | [
"0.6117772",
"0.5590091",
"0.5560799",
"0.5536237",
"0.55004615",
"0.5480353",
"0.5480115",
"0.5357441",
"0.53198266",
"0.5290409",
"0.5273166",
"0.52508104",
"0.5212732",
"0.51968944",
"0.51832634",
"0.51618934",
"0.50983936",
"0.5076811",
"0.50579077",
"0.50480217",
"0.5043... | 0.5456704 | 7 |
Return a friendly HTTP greeting. | def index():
return render_template('index.html') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_greeting(name):\n\n greeting = (f\"Hello, {name.title()}. It's nice to meet you!\")\n return greeting",
"def welcome():\n return 'Welcome to Flask!'",
"def greeting_message(name):\n print('My name is ' + name)",
"def Welcome():\n return (\n f\"Welcome to the Surf's Up API!\... | [
"0.6785658",
"0.6718835",
"0.67086893",
"0.66817635",
"0.6662773",
"0.6637097",
"0.6633533",
"0.66266304",
"0.6556931",
"0.65360993",
"0.64784324",
"0.64777356",
"0.64686126",
"0.64640325",
"0.6443602",
"0.6435352",
"0.640118",
"0.64006835",
"0.6374869",
"0.6374869",
"0.63681... | 0.0 | -1 |
Return a custom 404 error. | def page_not_found(e):
return 'Sorry, nothing at this URL.', 404 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def not_found():\n return HttpError(404)",
"def error_404(error):\n return '404 Error'",
"def error_404(error):\n return 'Bummer, there is nothing at this URL.'",
"def error_not_found(error):\n return 'No page here, dood. 404!', 404",
"def not_found(self, error):\n return jsonify({'error': 'NO... | [
"0.81159586",
"0.80410045",
"0.7738874",
"0.77369535",
"0.77182025",
"0.7689595",
"0.7670471",
"0.76112473",
"0.7602477",
"0.7570698",
"0.75528365",
"0.7545827",
"0.751882",
"0.74745256",
"0.7458403",
"0.7455682",
"0.74548143",
"0.74505144",
"0.7442062",
"0.7428278",
"0.74065... | 0.72672606 | 33 |
Sets the error_group_id of this AlertErrorGroupSummary. | def error_group_id(self, error_group_id):
self._error_group_id = error_group_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_group_name(self, error_group_name):\n\n self._error_group_name = error_group_name",
"def group_id(self, group_id):\n\n self._group_id = group_id",
"def group_id(self, group_id):\n\n self._group_id = group_id",
"def group_id(self, group_id):\n\n self._group_id = group_id"... | [
"0.75870997",
"0.71503705",
"0.71503705",
"0.71503705",
"0.71503705",
"0.71503705",
"0.71503705",
"0.6729585",
"0.6506523",
"0.64266306",
"0.63897884",
"0.6187408",
"0.6174485",
"0.6127527",
"0.6076385",
"0.59774184",
"0.59774184",
"0.59774184",
"0.59561014",
"0.58860123",
"0... | 0.8830125 | 0 |
Sets the error_group_name of this AlertErrorGroupSummary. | def error_group_name(self, error_group_name):
self._error_group_name = error_group_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_group_id(self, error_group_id):\n\n self._error_group_id = error_group_id",
"def set_group_name(self, name):\n self.groupname = name",
"def set_group_name(self, name):\n params = [('groupname', name, 'cdata')]\n\n self.get(COMMAND_UIC, 'SetGroupName', params)",
"def set_... | [
"0.7515292",
"0.6842258",
"0.64834154",
"0.63355285",
"0.62777054",
"0.62164974",
"0.62007964",
"0.60143673",
"0.58007485",
"0.57979673",
"0.5767984",
"0.5714703",
"0.5697868",
"0.5680305",
"0.5674288",
"0.565811",
"0.565811",
"0.5651028",
"0.5651028",
"0.5651028",
"0.5635324... | 0.8925021 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, AlertErrorGroupSummary):
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.80886984",
"0.80886984",
"0.8055307",
"0.7983415",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
if not isinstance(other, AlertErrorGroupSummary):
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.84560555",
"0.83913696",
"0.8143685",
"0.81403786",
"0.8131871",
"0.8093231",
"0.80915105",
"0.80915105",
"0.80915105",
"0.8084564",
"0.8084564",
"0.8075547",
"0.8075547",
"0.8065006",
"0.80417657",
"0.80417657",
"0.80417657",
"0.80417657",
"0.80417657",
"0.80417657",
"0.8... | 0.0 | -1 |
Apply symmetry constraints to a crystal model. Returns the crystal model (with symmetry constraints applied) in the same setting as provided as input. The cb_op returned by the method is that necessary to transform that model to the userprovided target symmetry. | def apply_symmetry(self, crystal_model):
if not (
self.target_symmetry_primitive
and self.target_symmetry_primitive.space_group()
):
return crystal, sgtbx.change_of_basis_op()
target_space_group = self.target_symmetry_primitive.space_group()
A = crys... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _apply_symmetry(self):\r\n self.command_stack.do(model.structure.ApplySymmetry(self._structure))",
"def get_symbolic_model(self):\n return self.sym_func",
"def get_symbolic_model(self):\n return self.sym_func",
"def determine_symmetry(self):\n if self.optical_isomers is None a... | [
"0.6082653",
"0.54509735",
"0.54509735",
"0.5258745",
"0.5226781",
"0.5098142",
"0.50905246",
"0.50784826",
"0.49611276",
"0.49035504",
"0.4883844",
"0.48831636",
"0.48306364",
"0.48049894",
"0.4781762",
"0.4737869",
"0.47336996",
"0.47273827",
"0.46800214",
"0.46159214",
"0.... | 0.76728874 | 0 |
Transition model. From a state and an action, return all of (state , probability) pairs. | def T(self, state, action):
_tr = self.transitions[state,action]
return izip(_tr.indices, _tr.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prob(self, state, action):\n if state + action == 100:\n reward = 1\n else:\n reward = 0\n\n return [(state + action, self._p_head, reward), (state - action, 1 - self._p_head, 0)]",
"def get_action_probability_dict(self, state):\n pass",
"def get_transition... | [
"0.785698",
"0.76274514",
"0.76059943",
"0.745071",
"0.74223214",
"0.7374063",
"0.7319806",
"0.706995",
"0.6966696",
"0.6966106",
"0.69556844",
"0.69443387",
"0.6943371",
"0.6932903",
"0.692419",
"0.6830901",
"0.68259865",
"0.6811094",
"0.67231303",
"0.6709734",
"0.6709532",
... | 0.60745966 | 93 |
Return unread message count. | def count(request):
n = request.user.profile.unread_message_count()
data = {
'count': n,
}
return HttpResponse(json.dumps(data), mimetype='application/json') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_unread_count(imap):\n status, messages = imap.select('Inbox')\n status, response = imap.uid('search', None, 'UNSEEN')\n unread_msg_nums = response[0].split()\n return len(unread_msg_nums)",
"def inbox_count_for(user):\n return Message.inbox.for_user(user).unread().count()",
"def get_unre... | [
"0.8327228",
"0.81447077",
"0.8140668",
"0.80129915",
"0.75354356",
"0.74578863",
"0.72802866",
"0.7245566",
"0.72252",
"0.70243347",
"0.7017666",
"0.69837636",
"0.6836136",
"0.67517996",
"0.6688123",
"0.6685107",
"0.6684228",
"0.66449547",
"0.65997607",
"0.6567238",
"0.65449... | 0.7119284 | 9 |
If the issuer responds with something that isn't JSON then the response is logged and the ``Deferred`` fires with a ``Failure`` wrapping ``UnexpectedResponse``. | def test_non_json_response(
self, voucher: Voucher, counter: int, num_tokens: int
) -> None:
issuer = UnexpectedResponseRedemption()
treq = treq_for_loopback_ristretto(issuer)
redeemer = RistrettoRedeemer(treq, NOWHERE)
random_tokens = redeemer.random_tokens_for_voucher(vouch... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _handle_response(self, response):\n self.client.status = response.code\n self.response_headers = headers = response.headers\n # XXX This workaround (which needs to be improved at that) for possible\n # bug in Twisted with new client:\n # http://twistedmatrix.com/trac/ticket/5... | [
"0.60140187",
"0.5851042",
"0.5821027",
"0.5701688",
"0.5695022",
"0.5668842",
"0.56205535",
"0.55588645",
"0.5556857",
"0.5555747",
"0.55480087",
"0.5538086",
"0.5514122",
"0.5507056",
"0.5483513",
"0.5472109",
"0.54697776",
"0.5466882",
"0.54661775",
"0.54571754",
"0.544789... | 0.53936374 | 26 |
If the issuer returns a failure without a recognizable reason then ``RistrettoRedeemer.redeemWithCounter`` returns a ``Deferred`` that fails with ``UnrecognizedFailureReason``. | def test_redemption_unknown_response(
self, voucher: Voucher, counter: int, extra_tokens: int
) -> None:
details = "mysterious"
num_tokens = counter + extra_tokens
issuer = UnsuccessfulRedemption(details)
treq = treq_for_loopback_ristretto(issuer)
redeemer = Ristretto... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_redemption_denied_unpaid(\n self, voucher: Voucher, counter: int, extra_tokens: int\n ) -> None:\n num_tokens = counter + extra_tokens\n issuer = unpaid_redemption()\n treq = treq_for_loopback_ristretto(issuer)\n redeemer = RistrettoRedeemer(treq, NOWHERE)\n ra... | [
"0.6063742",
"0.5815506",
"0.5583691",
"0.5562042",
"0.55192876",
"0.5296941",
"0.5169151",
"0.5110404",
"0.5060233",
"0.5046953",
"0.50379896",
"0.50059146",
"0.49959433",
"0.49628198",
"0.49373996",
"0.48936027",
"0.48814422",
"0.48798427",
"0.4873036",
"0.48370895",
"0.482... | 0.65321463 | 0 |
If the issuer returns a successful result with an invalid proof then ``RistrettoRedeemer.redeem`` returns a ``Deferred`` that fires with a ``Failure`` wrapping ``SecurityException``. | def test_bad_ristretto_redemption(
self, voucher: Voucher, counter: int, extra_tokens: int
) -> None:
num_tokens = counter + extra_tokens
signing_key = random_signing_key()
issuer = RistrettoRedemption(signing_key)
# Make it lie about the public key it is using. This causes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def already_spent_redemption() -> UnsuccessfulRedemption:\n return UnsuccessfulRedemption(\"double-spend\")",
"def test_fail(self) -> defer.Deferred[None]:\n return deferLater(reactor, 0, self.fail, \"I fail later\") # type: ignore[arg-type]",
"def test_redemption_denied_unpaid(\n self, vouch... | [
"0.5071755",
"0.49494836",
"0.49428242",
"0.4875747",
"0.48644093",
"0.48567504",
"0.48172936",
"0.4784264",
"0.47808266",
"0.47609627",
"0.4747154",
"0.46995032",
"0.46988824",
"0.4698413",
"0.46893993",
"0.46759978",
"0.4657636",
"0.46513",
"0.46436906",
"0.4641246",
"0.463... | 0.5684516 | 0 |
If the request contenttype is not application/json, the response is Unsupported Media Type. | def test_content_type(self) -> None:
issuer = unpaid_redemption()
treq = treq_for_loopback_ristretto(issuer)
d = treq.post(
NOWHERE.child("v1", "redeem").to_text().encode("ascii"),
b"{}",
)
self.assertThat(
d,
succeeded(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_content_type():\n return request.content_type == \"application/json\"",
"def _create_unsupported_media_type(self):\n body = self.server.create_error(\n 415,\n 'Not Acceptable', 'Invalid Accept header.',\n bad=True)\n self._write_response(415, body, cont... | [
"0.7720528",
"0.7250566",
"0.7062126",
"0.7045966",
"0.7028753",
"0.7001248",
"0.6943853",
"0.69326663",
"0.6910364",
"0.6720082",
"0.6654788",
"0.66005754",
"0.6582554",
"0.6553169",
"0.6542169",
"0.65123034",
"0.64150596",
"0.6404158",
"0.6377746",
"0.637424",
"0.63573647",... | 0.60286516 | 27 |
Hash a plaintext password. | def encrypt_password(cls, password):
return generate_password_hash(password) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash_password(self, password):\n self.password = pwd_context.encrypt(password)",
"def hash_password(self):\n self.__password = self.str_to_hash(self.__password)",
"def hash_password(self, password):\n\n # Use passlib's CryptContext to hash a password\n password_hash = self.passw... | [
"0.80052966",
"0.7932388",
"0.7795498",
"0.77503675",
"0.76861316",
"0.76543856",
"0.7624532",
"0.7603017",
"0.75838363",
"0.75794697",
"0.75714666",
"0.7541523",
"0.74899554",
"0.7447514",
"0.74341726",
"0.74300414",
"0.7366932",
"0.7337264",
"0.73348254",
"0.73213273",
"0.7... | 0.7046166 | 42 |
Authenticate plaintext password against hashed password saved in the db. | def authenticated(self, password):
return check_password_hash(self.password, password) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _authenticate_password(user_input: str, hash_: str) -> bool:\n return pbkdf2_sha256.verify(user_input, hash_)",
"def authenticate(cls, username, password):\n\n user = User.query.filter_by(username=username).first()\n\n if user and bcrypt.check_password_hash(user.password, password):\n ... | [
"0.7271155",
"0.71837604",
"0.717026",
"0.71700066",
"0.7146838",
"0.7112472",
"0.7091199",
"0.70465124",
"0.69927704",
"0.697564",
"0.69674677",
"0.6952829",
"0.6939267",
"0.69385016",
"0.6933561",
"0.693248",
"0.69228786",
"0.69134134",
"0.68841755",
"0.68832016",
"0.688055... | 0.6999178 | 8 |
Daylight savings time offset. | def dst(self, dt): # pylint: disable=unused-argument
return self._dst | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _local_time_offset():\n if time.localtime().tm_isdst and time.daylight:\n return -time.altzone\n else:\n return -time.timezone",
"def tzoffset(self):\n return _tzoffset(self._tz, self._t)",
"def get_tz_offset(self) -> float:\n return self.AD.tz.utcoffset(self.datetime()).t... | [
"0.8040169",
"0.70686764",
"0.678663",
"0.6753827",
"0.67073375",
"0.65406525",
"0.6350034",
"0.6230661",
"0.6217669",
"0.62040377",
"0.618155",
"0.6148078",
"0.61476386",
"0.6106361",
"0.60876715",
"0.60599285",
"0.59431314",
"0.59243816",
"0.5891895",
"0.5883789",
"0.583433... | 0.0 | -1 |
Convert a timestamp from (naive) UTC to this timezone. | def fromutc(self, dt):
if dt.tzinfo is None:
return dt.replace(tzinfo=self)
return super(UTC, self).fromutc(dt) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aware_utc_from_timestamp(timestamp):\n return datetime.utcfromtimestamp(timestamp).replace(tzinfo=pytz.utc)",
"def convertToUsersTimeZone(self, timestamp):\n user = self.zport.dmd.ZenUsers.getUserSettings()\n if user.timezone:\n utc_dt = pytz.utc.localize(datetime.utcfromtimes... | [
"0.7341733",
"0.7125917",
"0.70582074",
"0.6867549",
"0.6782569",
"0.6772863",
"0.67713416",
"0.66262937",
"0.6610231",
"0.6577075",
"0.65343285",
"0.64954835",
"0.64426804",
"0.64002496",
"0.63064134",
"0.6251915",
"0.6210545",
"0.6192532",
"0.6180376",
"0.61644584",
"0.6147... | 0.64996207 | 11 |
Get the name of this timezone. | def tzname(self, dt): # pylint: disable=unused-argument
return self._tzname | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tzname (self, dt):\n return self.__tzName",
"def tzname(self):\n if self._tzinfo is None:\n return None\n name = self._tzinfo.tzname(None)\n _check_tzname(name)\n return name",
"def tzname(self):\n if self._tzinfo is None:\n return None\n ... | [
"0.82758176",
"0.8122792",
"0.8106306",
"0.7950379",
"0.7919405",
"0.77748585",
"0.7613045",
"0.7551512",
"0.7524089",
"0.7447023",
"0.7374887",
"0.71320647",
"0.7088229",
"0.70807546",
"0.70807546",
"0.70807546",
"0.70807546",
"0.70807546",
"0.70807546",
"0.70807546",
"0.708... | 0.79848903 | 3 |
UTC offset of this timezone. | def utcoffset(self, dt): # pylint: disable=unused-argument
return self._utcoffset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tzoffset(self):\n return _tzoffset(self._tz, self._t)",
"def get_tz_offset(self) -> float:\n return self.AD.tz.utcoffset(self.datetime()).total_seconds() / 60",
"def get_utc_offset():\n timedelta = datetime.datetime.now() - datetime.datetime.utcnow()\n # XXX: `return -time.timezone`?\n ... | [
"0.8024776",
"0.76653856",
"0.7297475",
"0.725709",
"0.70740867",
"0.70577747",
"0.7054859",
"0.6801528",
"0.67610323",
"0.6697359",
"0.6626605",
"0.65941584",
"0.65941584",
"0.65941584",
"0.6554219",
"0.65410274",
"0.65166026",
"0.6487153",
"0.6475814",
"0.6374597",
"0.63740... | 0.5839888 | 57 |
Convert a Timestamp protobuf to a datetime object. | def pb_timestamp_to_datetime(timestamp_pb):
return (
_EPOCH +
datetime.timedelta(
seconds=timestamp_pb.seconds,
microseconds=(timestamp_pb.nanos / 1000.0),
)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _timestamp_to_datetime(timestamp):\n return datetime.fromtimestamp(timestamp * 0.001, tz=timezone.utc)",
"def _pd_datetime_to_timestamp_proto(dtype, value) -> Timestamp:\n\n if type(value) in [np.float64, np.float32, np.int32, np.int64]:\n return Timestamp(seconds=int(value))\n if dtype._... | [
"0.71154785",
"0.7087566",
"0.6903503",
"0.68818754",
"0.67507106",
"0.6714833",
"0.6709062",
"0.6582832",
"0.65689814",
"0.651013",
"0.6498681",
"0.645619",
"0.64456236",
"0.64142627",
"0.63764757",
"0.6324647",
"0.62838596",
"0.6237046",
"0.6228158",
"0.6159523",
"0.6128871... | 0.79439294 | 0 |
Given a protobuf for a Value, get the correct value. The Cloud Datastore Protobuf API returns a Property Protobuf which has one value set and the rest blank. This function retrieves the the one value provided. Some work is done to coerce the return value into a more useful type (particularly in the case of a timestamp ... | def _get_value_from_value_pb(value_pb):
value_type = value_pb.WhichOneof('value_type')
if value_type == 'timestamp_value':
result = pb_timestamp_to_datetime(value_pb.timestamp_value)
elif value_type == 'key_value':
result = CustomIterator.key_from_protobuf(value_pb.key_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _to_google_protobuf_value(value):\n lv = struct_pb2.ListValue()\n lv.append(value)\n return lv.values[0]",
"def proto_value(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]:\n return pulumi.get(self, \"proto_value\")",
"def _get_val(json_value):\n val = gnmi_pb2.TypedValue()\n i... | [
"0.6948249",
"0.66075104",
"0.6601361",
"0.63059145",
"0.6284209",
"0.6166976",
"0.6055706",
"0.60522616",
"0.6005781",
"0.5992529",
"0.5974919",
"0.59671247",
"0.5951767",
"0.5946457",
"0.59311265",
"0.5897246",
"0.58605814",
"0.5853358",
"0.58343697",
"0.5833488",
"0.583339... | 0.7410404 | 0 |
Convert a dictionary that was created with dottify() back into a standard BaseModel object >>> dict_ = { | def _dotted_dict_to_object(cls, dict_: dict, key: Key = None):
dotted_pairs = {}
for k, val in dict_.copy().items():
if '.' in k:
dotted_pairs[k] = val
del dict_[k]
class_dict = {}
for k, val in dotted_pairs.items():
class_, prop_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_basedict(self):\n tester = BaseModel()\n self.assertTrue(dict, type(tester.to_dict()))",
"def from_dict(cls, dikt):\n return util.deserialize_model(dikt, cls)",
"def from_dict(cls, dikt):\n return util.deserialize_model(dikt, cls)",
"def from_dict(cls, dikt):\n ret... | [
"0.69167453",
"0.6653887",
"0.6653887",
"0.6653887",
"0.6653887",
"0.6653887",
"0.6653887",
"0.65368706",
"0.6517929",
"0.65144557",
"0.6438958",
"0.6396974",
"0.6396974",
"0.636275",
"0.63137764",
"0.63030833",
"0.6239215",
"0.6221077",
"0.6183743",
"0.6170875",
"0.6167124",... | 0.66716444 | 1 |
Get the policy name Returns str The name of the partition policy. | def policy_str(self): # -> str:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def policy_name(self):\n return self._policy_name",
"def policy_name(self) -> Optional[str]:\n return pulumi.get(self, \"policy_name\")",
"def policy_name(self) -> Optional[str]:\n return pulumi.get(self, \"policy_name\")",
"def get_policyname(self):\n return self.options[\"policy... | [
"0.8429353",
"0.8285578",
"0.8285578",
"0.8196362",
"0.8186843",
"0.8124292",
"0.8124292",
"0.8124292",
"0.8124292",
"0.8124292",
"0.8124292",
"0.8124292",
"0.75938505",
"0.73334664",
"0.7174909",
"0.7174909",
"0.7174909",
"0.7090308",
"0.7090308",
"0.6963581",
"0.69412655",
... | 0.61776847 | 48 |
Get data size of current partition. Returns int data size | def get_part_size(self): # -> int:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data_size(self):\n if self._policy_str == EDGE_PART_POLICY:\n return len(self._partition_book.partid2eids(self._part_id))\n elif self._policy_str == NODE_PART_POLICY:\n return len(self._partition_book.partid2nids(self._part_id))\n else:\n raise RuntimeE... | [
"0.78575176",
"0.78404653",
"0.77894115",
"0.7320275",
"0.72090286",
"0.71066797",
"0.7029484",
"0.6978457",
"0.6955772",
"0.6954159",
"0.6953559",
"0.6936392",
"0.69342345",
"0.6925633",
"0.6919111",
"0.69150144",
"0.6909606",
"0.688219",
"0.68817353",
"0.68604344",
"0.68600... | 0.73075014 | 4 |
Get the full size of the data. Returns int data size | def get_size(self):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_size(self):\n return self._data_size",
"def size(self):\n return self.data.size",
"def size(self):\n size = 0\n size += self.data.size * sys.getsizeof(self.data)\n return size / 1024.0 / 1024.0 / 1024.0",
"def data_length(self):\n size = self.unpack_dword(0x4... | [
"0.86101663",
"0.8294422",
"0.82466274",
"0.82067496",
"0.81668735",
"0.81668735",
"0.81668735",
"0.81668735",
"0.81668735",
"0.8111365",
"0.8044784",
"0.803414",
"0.7929649",
"0.79210514",
"0.7916815",
"0.7854782",
"0.7819682",
"0.7771386",
"0.77202106",
"0.7709685",
"0.7709... | 0.0 | -1 |
Get Mock that emulate standard input. You won't use this function directly. | def get_input_mock(inputs=None): # Use this mock if a contest requires interactive input.
stdin_mock = MagicMock()
stdin_mock.side_effect = inputs # You can emulate standard input lines by using this list.
return stdin_mock | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mockRawInput(mock):\n original_raw_input = __builtin__.raw_input\n __builtin__.raw_input = lambda _: mock\n yield\n __builtin__.raw_input = original_raw_input",
"def test_raw_input_ex(input_output):\n with mock.patch.object(builtins, 'input', lambda _: input_output):\n assert GC.raw_inp... | [
"0.80178136",
"0.7564353",
"0.73974955",
"0.7157679",
"0.708158",
"0.70150906",
"0.6580765",
"0.65448713",
"0.65438503",
"0.65295905",
"0.65035164",
"0.64731824",
"0.64452386",
"0.6420596",
"0.6400902",
"0.63983184",
"0.6369561",
"0.6343025",
"0.6329749",
"0.6312141",
"0.6286... | 0.812207 | 0 |
Load pickle files and transform to dataframe. | def load_stats_dataframe(files, aggregated_results=None):
if os.path.exists(aggregated_results) and all(
[os.path.getmtime(f) < os.path.getmtime(aggregated_results) for f in files]):
return pd.read_pickle(aggregated_results)
df = pd.DataFrame()
for f in files:
tmp_dict = pd.read... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_pickle(args):\n with open(args.pickle_name, 'rb') as fh:\n datum = pickle.load(fh)\n\n df = pd.DataFrame.from_dict(datum['labels'])\n\n return df",
"def read_data(dump_dir):\n \n os.chdir(dump_dir)\n file_list = os.listdir()\n file_list = [i for i in file_list if 'threadtemp'... | [
"0.7422415",
"0.6805238",
"0.6784351",
"0.67746395",
"0.67718774",
"0.6754657",
"0.6754657",
"0.66959864",
"0.66895443",
"0.66309613",
"0.6513934",
"0.63346434",
"0.6331759",
"0.62952536",
"0.61987084",
"0.61912286",
"0.6182703",
"0.6135205",
"0.6120971",
"0.6087721",
"0.6086... | 0.6337251 | 11 |
Returns which custom emoji to use to mark card. | def marker(cardsize: int, row: int, column: int) -> str:
# if card size = 2, only use the one marker: cringo_36
if cardsize == 2:
return raw_cringo_emojis[row + 1][column + 1]
elif cardsize == 4:
return raw_cringo_emojis[row][column]
elif cardsize == 6:
return raw_cringo_emojis[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emoji(self):\n return self._manager.get_emoji(self.name)",
"def is_custom_emoji(self):\n ...",
"def get_emoji(self, icon):\n emojis = self.config['emojis']\n emoji = emojis.get(icon, '')\n return emoji",
"def what_means_emoji(emoji):\r\n try:\r\n return unicod... | [
"0.7407292",
"0.7155207",
"0.7065894",
"0.7024489",
"0.6823812",
"0.6674126",
"0.6374117",
"0.62680894",
"0.62680894",
"0.6249325",
"0.624096",
"0.6145197",
"0.6045673",
"0.604056",
"0.60399055",
"0.60325086",
"0.58630025",
"0.5825695",
"0.5774706",
"0.5751671",
"0.57499135",... | 0.66423154 | 6 |
Get directory of spike prediction based on the directory structure of neuRoi | def get_spike_dir(root_dir, exp_name, plane_num):
exp_dir = os.path.join(root_dir, exp_name)
spike_root_dir = os.path.join(exp_dir, 'deconvolution')
plane_string = 'plane{0:02d}'.format(plane_num+1)
spike_dir = os.path.join(spike_root_dir, plane_string)
return spike_dir | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict_image_path(self) -> str:\n return join(self.directory_path, 'predict-images')",
"def getFilePaths():\n \n image_dir = r'/hpc/wfok007/mpi_heart/Training Set'\n mask_paths = []\n image_paths = []\n for root, dirs, files in os.walk(image_dir, topdown=False):\n for name in fi... | [
"0.6572198",
"0.6549571",
"0.6375013",
"0.63687235",
"0.6329466",
"0.63069224",
"0.62881684",
"0.62731874",
"0.61978513",
"0.60777366",
"0.6069529",
"0.6025704",
"0.5989499",
"0.59715873",
"0.59533614",
"0.5947444",
"0.5945113",
"0.59172994",
"0.59134376",
"0.59132606",
"0.59... | 0.57934594 | 30 |
Returns true if both objects are equal | def __eq__(self, other):
# type: (object) -> bool
if not isinstance(other, ComponentVisibleOnScreenTags):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.80886984",
"0.80886984",
"0.8055307",
"0.7983415",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
# type: (object) -> bool
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.84560555",
"0.83913696",
"0.8143685",
"0.81403786",
"0.8131871",
"0.8093231",
"0.8084564",
"0.8084564",
"0.8075547",
"0.8075547",
"0.8065006",
"0.80417657",
"0.80417657",
"0.80417657",
"0.80417657",
"0.80417657",
"0.80417657",
"0.80417657",
"0.80417657",
"0.80417657",
"0.8... | 0.80915105 | 8 |
Note that the table logic is hardcoded in this function. Ideally, there should be one table per class. if output_file is not None, will write out each dictionary as a json We invent our own property names by using the correct name from Offer, and appending a '1' to it. Since this is only a prototype, we use some of the... | def buildOfferTableFromScratch(output_file = None):
offer_table = []
our_properties = ['itemOffered.name', 'itemOffered.age','itemOffered.ethnicity', 'mainEntityOfPage.description']
for property in our_properties:
dict = {}
dict['onto_prop'] = property+'1'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output(self):\n # store tables\n # protocol PK keys table for measurements under a protocol\n # 'line' keys table for line-only section (if enabled)\n # 'all' keys table including everything.\n tables = OrderedDict()\n if self.options.line_section:\n tables[... | [
"0.6040826",
"0.5976885",
"0.59153336",
"0.5884464",
"0.5855467",
"0.5668098",
"0.563533",
"0.5621095",
"0.55886185",
"0.5573978",
"0.55739594",
"0.54910606",
"0.54705036",
"0.54650444",
"0.54310745",
"0.5424976",
"0.5421673",
"0.5413054",
"0.5402804",
"0.53977406",
"0.533486... | 0.7793784 | 0 |
Check if version string is either "current" or the form vX.Y.Z | def check_version_str(version):
if not version.startswith('v') and version != 'current':
version = 'v%s' % version
return version | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_python_version(match, current=None):\n if current is None:\n current = list(sys.version_info[:3])\n if not isinstance(match, list):\n match = [match]\n for m in match:\n minimal = False\n if isinstance(m, float):\n m = str(m)\n if m.endswith(\"+\"):\... | [
"0.70857155",
"0.6846582",
"0.67956823",
"0.67766833",
"0.6734291",
"0.67158955",
"0.66501665",
"0.660779",
"0.65944666",
"0.65841395",
"0.6541539",
"0.65331215",
"0.6513458",
"0.6486654",
"0.64820844",
"0.6402213",
"0.6373061",
"0.63678175",
"0.6351145",
"0.63207865",
"0.630... | 0.8133405 | 0 |
Get full path for given file, relative to parent directory. | def path(self, f):
return os.path.join(self.directory, f) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_relative_path(self, file_path):\n file_path = os.path.abspath(file_path)\n if self.base_dir is not None:\n file_path = file_path.replace(os.path.abspath(self.base_dir), \"\")\n assert file_path[0] == \"/\"\n file_path = file_path[1:]\n return file_path",
"def... | [
"0.7958778",
"0.75750756",
"0.7491911",
"0.7430754",
"0.74245965",
"0.7410865",
"0.74025464",
"0.73988426",
"0.7392543",
"0.73701304",
"0.7349241",
"0.7318822",
"0.7276252",
"0.7269386",
"0.72491455",
"0.72130626",
"0.72034967",
"0.7197673",
"0.7177205",
"0.71565944",
"0.7136... | 0.684048 | 46 |
Compute Xb with column standardized X | def compute_Xb(X_t, b_t, cm_t, csd_t):
# scale Xb
scaled_Xb_t = torch.mm(X_t, (b_t/csd_t).reshape(-1,1)).squeeze()
# center Xb
Xb_t = scaled_Xb_t - (cm_t*b_t/csd_t).sum()
return Xb_t | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def standardize(X):\n X_std = X\n mean = X.mean(axis=0)\n std = X.std(axis=0)\n for col in range(np.shape(X)[1]):\n if std[col]:\n X_std[:, col] = (X_std[:, col] - mean[col]) / std[col]\n # X_std = (X - X.mean(axis=0)) / X.std(axis=0)\n return X_std",
"def standardise(x):\n ... | [
"0.6356758",
"0.6342893",
"0.6204855",
"0.61218274",
"0.61043584",
"0.6082749",
"0.59972167",
"0.5957963",
"0.59430116",
"0.5929519",
"0.5892421",
"0.5858894",
"0.5854356",
"0.585426",
"0.58424574",
"0.5812357",
"0.58061165",
"0.5788898",
"0.5786278",
"0.5779717",
"0.5779717"... | 0.65355724 | 0 |
Compute posterior inclusion probability (PIP) for all variables | def susie_get_pip(res, prune_by_cs=False, prior_tol=1e-9):
# drop null weight columns
if res['null_index'] > 0:
res['alpha'] = res['alpha'][:, -res['null_index']]
# drop the single effect with estimated prior zero
include_idx = torch.where(res['V'] > 1e-9)[0]
# only consider variables in r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perplexity(self):\n raise NotImplementedError(\"To be implemented\")",
"def prob4():\n#raise NotImplementedError(\"Problem 4 Incomplete\")\n h = lambda x : x[0] < -1 and x[1] > 1\n f = lambda x : stats.multivariate_normal.pdf(x,mean=np.array([0,0]),cov=np.eye(2))\n g = lambda x : stats.multiv... | [
"0.6601619",
"0.6589225",
"0.6471362",
"0.6404401",
"0.6398576",
"0.62561375",
"0.625596",
"0.6254964",
"0.62503153",
"0.6239866",
"0.6237026",
"0.62114197",
"0.6199829",
"0.61776745",
"0.6157536",
"0.61511046",
"0.6130461",
"0.6112303",
"0.60781276",
"0.60747606",
"0.6066003... | 0.0 | -1 |
Converts one of the relationstrings defined on Relation as enumlike values to a lambda that implements the relation that the relationstring signifies. | def as_function(relation, opposite=False):
greater_than = lambda x, y: x > y
less_than = lambda x, y: x < y
equal = lambda x, y: x == y
not_equal = lambda x, y: not equal(x, y)
if relation == Relation.greater_than:
if not opposite:
return greater_than... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link_value_func(value):\r\n return lambda course, reverse_url_func: value",
"def str2enum(enum: type) -> Callable[[str], Any]:\n\n def _parse(string: str) -> Any:\n try:\n return enum[string.lower()] # type: ignore\n except BaseException:\n raise argparse.ArgumentTy... | [
"0.49566957",
"0.4944811",
"0.4859224",
"0.48215905",
"0.4818728",
"0.4799329",
"0.467955",
"0.45894128",
"0.4584948",
"0.45734772",
"0.4566678",
"0.45462155",
"0.4533016",
"0.44997674",
"0.44845584",
"0.44420934",
"0.443044",
"0.4410531",
"0.43898413",
"0.43863988",
"0.43810... | 0.5718791 | 0 |
Returns True if the variable has a unary constraint, False otherwise. | def has_unary_constraint(self, var):
return var in self.__constraints | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_bounded_continuous_variable(self):\n for rv in self.unique_variables:\n if not is_bounded_continuous_variable(rv):\n return False\n return True",
"def remove_unary_constraint(self, var):\n\n del self.__constraints[var]",
"def _is_unary_op(op):\n if o... | [
"0.62324053",
"0.6138888",
"0.5928244",
"0.5903357",
"0.5898959",
"0.5898959",
"0.5875363",
"0.5740035",
"0.573903",
"0.5700841",
"0.566433",
"0.566216",
"0.5660113",
"0.5653952",
"0.56507754",
"0.56166464",
"0.5615793",
"0.5598134",
"0.5595502",
"0.5583389",
"0.55792826",
... | 0.8697148 | 0 |
(str, str) > bool Return True if and only if DNA sequence dna2 occurs in the DNA sequence dna1. >>> contains_sequence('ATCGGC', 'GG') True >>> contains_sequence('ATCGGC', 'GT') False | def contains_sequence(dna1, dna2):
if dna1.find(dna2):
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contains_sequence(dna1, dna2):\r\n if dna2 in dna1:\r\n return True\r\n else:\r\n return False",
"def contains_sequence(dna1, dna2):\n return dna2 in dna1",
"def __contains__(self, seq):\n return bool(libhts.faidx_has_seq(self._fai, seq))",
"def is_legit_DNA_sequence(record_... | [
"0.86137754",
"0.8488343",
"0.6487442",
"0.6075849",
"0.6047391",
"0.58996",
"0.58396256",
"0.5788455",
"0.57447463",
"0.57391495",
"0.5694425",
"0.5689869",
"0.5666709",
"0.56612825",
"0.56292063",
"0.5626966",
"0.55898666",
"0.5579443",
"0.5527616",
"0.55027074",
"0.5494569... | 0.83295405 | 2 |
Return whether an object belongs to a member. | def belongs_to_member(self, obj, member_id,
ignore_members=None, replicas=1):
return member_id in self.members_for_object(
obj, ignore_members=ignore_members, replicas=replicas) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_member(self, node):\n return node in self._members",
"def is_member(self) -> bool:\n if self._is_member is _missing:\n return False\n return self._is_member",
"def is_member(user: User) -> bool:\n if not user:\n raise TypeError('user should not be None')\n return... | [
"0.81116414",
"0.79815453",
"0.7579076",
"0.75440353",
"0.74206465",
"0.73116136",
"0.72415864",
"0.7098172",
"0.69540393",
"0.6951602",
"0.6896566",
"0.67631966",
"0.67536247",
"0.6743148",
"0.67023665",
"0.6693831",
"0.6686203",
"0.66634285",
"0.6663066",
"0.66514945",
"0.6... | 0.7858317 | 2 |
Return whether an object belongs to this coordinator. | def belongs_to_self(self, obj, ignore_members=None, replicas=1):
return self.belongs_to_member(obj, self._coord._member_id,
ignore_members=ignore_members,
replicas=replicas) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exists(self):\n return self.obj is not None",
"def has_object_permission(self, request, view, obj):\n if request.user.is_manager or request.user == obj.child.family:\n return True\n return False",
"def has_object_permission(self, request, view, obj):\n if request.user... | [
"0.7039352",
"0.6984215",
"0.6929683",
"0.6922257",
"0.69048166",
"0.6888037",
"0.6883356",
"0.6850917",
"0.679859",
"0.6779464",
"0.6754767",
"0.66810346",
"0.6677259",
"0.6612626",
"0.65795845",
"0.6544606",
"0.65375394",
"0.6536038",
"0.6523502",
"0.65155494",
"0.6496675",... | 0.0 | -1 |
Draw a horizontal line in the image buffer. | def hline(self, xi: int, yi: int, length: int, color: int):
for x in range(length):
self.pixel(xi + x, yi, color) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hline(self, x, y, width, color):\n self.rect(x, y, width, 1, color, fill=True)",
"def _plot_line(self, image, x1, y1, x2, y2, width, color):\n\n draw = ImageDraw.Draw(image, \"RGBA\")\n draw.line([x1, y1, x2, y2], fill=color, width=width)\n del draw\n\n return image",
"de... | [
"0.7343851",
"0.72636026",
"0.6926238",
"0.689498",
"0.68844485",
"0.6877569",
"0.6846872",
"0.67588174",
"0.67320454",
"0.67187965",
"0.66324776",
"0.6596149",
"0.65555984",
"0.6538864",
"0.64836067",
"0.6471436",
"0.64581096",
"0.644349",
"0.64254797",
"0.641323",
"0.640539... | 0.6679107 | 10 |
Draw a vertical line in the image buffer. | def vline(self, xi: int, yi: int, length: int, color: int):
for y in range(length):
self.pixel(xi, yi + y, color) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vline(self, x, y, height, color):\n self.rect(x, y, 1, height, color, fill=True)",
"def draw_blue_vertical_line(img, pos):\n img_rgb = np.tile(img, (3, 1, 1))\n img_rgb = np.moveaxis(img_rgb, 0, -1)\n rg = np.zeros((img.shape[0]))\n b = np.ones((img.shape[0]))\n blue_line = np.stack([rg... | [
"0.7205712",
"0.69971025",
"0.690392",
"0.6853191",
"0.6852523",
"0.6835999",
"0.6817275",
"0.681231",
"0.6777608",
"0.67288655",
"0.6677273",
"0.6570685",
"0.65632504",
"0.64924175",
"0.64449805",
"0.6443226",
"0.6419069",
"0.6394806",
"0.6384978",
"0.63711435",
"0.62859756"... | 0.6660656 | 11 |
Sets the instrumentToken of this Todays. | def instrumentToken(self, instrumentToken):
self._instrumentToken = instrumentToken | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instrument(self, instrument):\n\n self._instrument = instrument",
"def instrument(self, instrument):\n\n self._instrument = instrument",
"def instrument(self, instrument):\n\n self._instrument = instrument",
"def instrument(self, instrument):\n\n self._instrument = instrument"... | [
"0.59376115",
"0.59376115",
"0.59376115",
"0.59376115",
"0.5914821",
"0.5774514",
"0.5774514",
"0.5693026",
"0.5538383",
"0.5521752",
"0.55142695",
"0.53797996",
"0.51793224",
"0.5176991",
"0.5096867",
"0.5068754",
"0.50679696",
"0.505422",
"0.5038145",
"0.5025074",
"0.500453... | 0.7723014 | 0 |
Sets the actualNetTrdValue of this Todays. | def actualNetTrdValue(self, actualNetTrdValue):
self._actualNetTrdValue = actualNetTrdValue | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def netTrdValue(self, netTrdValue):\n\n self._netTrdValue = netTrdValue",
"def net_amount(self, net_amount):\n\n self._net_amount = net_amount",
"def actual(self, actual):\n\n self._actual = actual",
"def actual(self, actual):\n\n self._actual = actual",
"def SetTrSet(self,value... | [
"0.7913668",
"0.5616521",
"0.54992557",
"0.54992557",
"0.54202294",
"0.52773374",
"0.52240705",
"0.51183426",
"0.5089935",
"0.50599754",
"0.49885562",
"0.48998088",
"0.48989636",
"0.48755258",
"0.4846786",
"0.48100752",
"0.48038182",
"0.4795886",
"0.47838572",
"0.47440583",
"... | 0.8420904 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.