query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Shutdown and remove all endpoints in use. | def shutdown_all_endpoints(self):
logger.debug('Removing all endpoints')
endpoints = []
with self._endpoint_lock:
endpoints = list(self._endpoints)
# be sure we're not holding the lock when shutdown calls
# _remove_endpoint.
for e in endpoints:
e.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanUp(self):\r\n for endpoint in self._endpoints.keys():\r\n endpoint.destroy()\r\n\r\n assert len(self._endpoints) == 0",
"def stop(self):\n for c in self.openstack_endpoints.values():\n c.stop()\n #for c in self.openstack_endpoints.values():\n # ... | [
"0.7638886",
"0.7031735",
"0.7007295",
"0.6990433",
"0.6923845",
"0.6923845",
"0.68971926",
"0.6882468",
"0.68696773",
"0.68651676",
"0.6857834",
"0.6821186",
"0.6821186",
"0.6821186",
"0.6813516",
"0.68123233",
"0.6797806",
"0.6760887",
"0.67333436",
"0.67297524",
"0.6722941... | 0.79324275 | 0 |
Add a MessageChain to the internal list for the given request ID. | def add_message_chain(self, request_id, message_chain):
logger.debug('request_id = %s' % request_id)
with self._message_chains_lock:
self._message_chains[request_id] = message_chain | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append_message(self, message):\n if message['message_id'] in self.message_ids:\n return\n self.message_ids.append(message['message_id'])\n self.messages.append(message)",
"def add_message(self, message):\n self.message_list.append(message)",
"def remove_message_chain(... | [
"0.5982852",
"0.5875561",
"0.56743115",
"0.55958617",
"0.55825657",
"0.5526259",
"0.55260205",
"0.5498304",
"0.54431385",
"0.5434903",
"0.5410539",
"0.5391618",
"0.5315123",
"0.5288119",
"0.5248552",
"0.5224282",
"0.52231395",
"0.52214056",
"0.52062374",
"0.5164818",
"0.51402... | 0.8448856 | 0 |
Remove a particular MessageChain from the internal list. | def remove_message_chain(self, request_id):
logger.debug('request_id = %s' % request_id)
with self._message_chains_lock:
del self._message_chains[request_id] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_chain(self, chain):\n assert isinstance(chain, Chain)\n self.chain_list.remove(chain)\n del self.chain_dict[chain.chain_id]\n chain.model = None",
"def removeChain(self, mychain):\n\n\t\tichain = self.getChain(mychain)\t\n\t\tif ichain == None:\n\t\t\treturn\n\n\t\tself.cha... | [
"0.707457",
"0.6997403",
"0.6952389",
"0.60951513",
"0.5924398",
"0.5919615",
"0.59025043",
"0.58603734",
"0.5835594",
"0.5799319",
"0.57425165",
"0.5730201",
"0.57281935",
"0.5715879",
"0.5715307",
"0.56899655",
"0.5671005",
"0.5666363",
"0.56640697",
"0.5659076",
"0.5613275... | 0.7244194 | 0 |
Return the MessageChain for the given request ID. | def get_message_chain(self, request_id):
logger.debug('request_id = %s' % request_id)
with self._message_chains_lock:
if request_id in self._message_chains:
return self._message_chains[request_id]
else:
#logger.debug('no message chain found for req... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_request(self, request_id):\r\n if request_id not in self.__requests:\r\n self.__requests[request_id] = Request(request_id)\r\n return self.__requests[request_id]",
"def __get_request(self, request_id):\r\n if request_id not in self.__requests:\r\n self.__reque... | [
"0.60119104",
"0.60119104",
"0.5812235",
"0.5750902",
"0.5716137",
"0.56717724",
"0.565159",
"0.56510836",
"0.5594178",
"0.55415475",
"0.5292603",
"0.52618223",
"0.5172036",
"0.51201814",
"0.5104106",
"0.5099639",
"0.50938606",
"0.5042277",
"0.5042277",
"0.49994317",
"0.49958... | 0.8318861 | 0 |
Add the handling to all available MessageChains. | def add_orphaned_handling(self, handling):
logger.debug('Adding orphaned handling')
with self._message_chains_lock:
for mc in self._message_chains.itervalues():
mc.add_orphaned_handling(handling) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _register_handlers(self):\n import handlers as th\n import inspect\n for name, class_type in inspect.getmembers(th, predicate=inspect.isclass):\n if class_type is th.ZMQTopicHandlerBase:\n continue\n handler = class_type()\n topic = handler.g... | [
"0.5882938",
"0.5742624",
"0.5681602",
"0.56333554",
"0.5612072",
"0.5575544",
"0.5575388",
"0.54889035",
"0.54680467",
"0.5444565",
"0.54261345",
"0.5404349",
"0.5386052",
"0.5371324",
"0.53703123",
"0.5308286",
"0.5211676",
"0.51994216",
"0.5199076",
"0.5187632",
"0.5157146... | 0.6574009 | 0 |
Create sequences that are the input values and the next characters that are the labels. Attributes | def create_sequences(text, sequence_length, step):
sequences = []
labels = []
for i in range(0, len(text) - sequence_length, step):
sequences.append(text[i: i + sequence_length])
labels.append(text[i + sequence_length])
return sequences, labels | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen(length):\n return itertools.product(LABELS,repeat=length)",
"def make_labels(self, ilines):\n\n llist = []\n for lind, lstr in enumerate(ilines):\n # get label and value list\n rv, label, vals = self.get_label_vals(lstr)\n if rv < 1: continue\n\n nvals = len(v... | [
"0.6470457",
"0.64123285",
"0.6164413",
"0.61386436",
"0.6104493",
"0.6063354",
"0.5965397",
"0.59203815",
"0.59138167",
"0.589114",
"0.58406407",
"0.58016074",
"0.5751395",
"0.57289296",
"0.57238644",
"0.5703187",
"0.5700745",
"0.56986874",
"0.5698294",
"0.56899434",
"0.5685... | 0.66256857 | 0 |
Get text unique characters. Attributes | def get_unique_characters(text):
return sorted(list(set(text))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_unique_chars(self, data_string):\n unique_chars = list(set(data_string))\n return unique_chars",
"def getText():",
"def getText():",
"def getText():",
"def getText():",
"def getText():",
"def randchars(self):\n samples = random.sample(self._charset, self._text_length)\n ... | [
"0.6572222",
"0.63200176",
"0.63200176",
"0.63200176",
"0.63200176",
"0.63200176",
"0.6247901",
"0.6204976",
"0.6159503",
"0.6158642",
"0.61425966",
"0.60354614",
"0.60235137",
"0.5985139",
"0.5966651",
"0.59415984",
"0.59232706",
"0.5916645",
"0.5864096",
"0.5852108",
"0.576... | 0.6793441 | 0 |
Convert sequences and labels to one hot arrays. Attributes | def convert_to_one_hot(sequences, sequence_length, chars_length, char_to_index, labels):
x = np.zeros((len(sequences), sequence_length, chars_length), dtype=np.bool)
y = np.zeros((len(sequences), chars_length), dtype=np.bool)
for i, sentence in enumerate(sequences):
for t, char in enumerate(sentence... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_labels(state_mapping, sequences):\n encoded_labels = [[state_mapping[state] for state in label] for label in sequences]\n \n depth = len(state_mapping)\n one_hot_labels = [[one_hot_encode(label, depth) for label in sequence] for sequence in encoded_labels]\n one_hot_labels = [np.asarray(... | [
"0.80264527",
"0.7792371",
"0.75988716",
"0.7422211",
"0.73779625",
"0.7244488",
"0.7208552",
"0.7159937",
"0.7146789",
"0.71388704",
"0.7112212",
"0.7097633",
"0.7083599",
"0.708275",
"0.7065401",
"0.7037123",
"0.70215356",
"0.7021148",
"0.7021148",
"0.7008587",
"0.6982315",... | 0.7869032 | 1 |
Creates two numpy array with all computed patient exercises and patient group as indicator. | def generate_exercises(patient_combinations):
np_patient_reshaped = np.empty((0, 5 *
len(Worker.columns) *
Worker.frames_per_excersise))
indicator = None
for combination in patient_combinations:
exercise... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reshape_exercises(args):\n # Create dataframe object here\n # args contain alpha, bravo, charlie, delta, echo\n\n # exercise_array = np.empty(\n # [0, len(Worker.columns) *\n # len(args) *\n # Worker.frames_per_excersise])\n\n exercise_array ... | [
"0.60978377",
"0.52030385",
"0.5166391",
"0.5144017",
"0.49654016",
"0.49457532",
"0.4915989",
"0.48005804",
"0.47985417",
"0.47319722",
"0.47287726",
"0.47279516",
"0.47057968",
"0.46736777",
"0.46558046",
"0.46520984",
"0.46463436",
"0.46018022",
"0.45909542",
"0.45903024",
... | 0.73087025 | 0 |
User can get a comment | def test_user_can_get_a_comment(self):
token1 = self.create_user(VALID_USER_DATA)
response = self.create_article(VALID_ARTICLE, token1)
response = self.create_comment(
token=token1,
parentId=0,
slug=response.data['article']['slug']
)
get_comme... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_func(self):\r\n\r\n comment = self.get_object()\r\n return self.request.user == comment.name",
"def test_func(self):\r\n \r\n comment = self.get_object()\r\n return self.request.user == comment.name",
"def test_retrieve_comment_by_post(self):\n\n self.factory.... | [
"0.7038644",
"0.70376927",
"0.67370343",
"0.67120206",
"0.66021633",
"0.65627986",
"0.6511986",
"0.6497923",
"0.640186",
"0.6339536",
"0.6310061",
"0.6306427",
"0.62967557",
"0.62699234",
"0.6268474",
"0.62412363",
"0.62237895",
"0.62186027",
"0.6194395",
"0.61843294",
"0.617... | 0.7290576 | 0 |
User can reply to a comment | def test_user_can_reply_to_comment(self):
token1 = self.create_user(VALID_USER_DATA)
response = self.create_article(VALID_ARTICLE, token1)
response = self.create_comment(
token=token1,
parentId=0,
slug=response.data['article']['slug']
)
respon... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_reply(self, comment):\n\t\tpass",
"def reply(cls, user, context, message, reply_message):\r\n pass",
"def answerComment(r, comment, answeredDB, helper):\n\n cards, answer = helper.parseText(comment.body)\n\n if cards and answer and not answeredDB.exists(comment.parent_id, cards):\n ... | [
"0.74846804",
"0.70101684",
"0.68703973",
"0.6867254",
"0.67366505",
"0.6692145",
"0.6664973",
"0.65788364",
"0.647903",
"0.6440472",
"0.6382182",
"0.6355708",
"0.6302688",
"0.6282473",
"0.6247909",
"0.6207214",
"0.61699224",
"0.6164209",
"0.6159504",
"0.61511284",
"0.6134993... | 0.76388335 | 0 |
user can get comments for an article | def test_user_can_get_comments_for_an_article(self):
token1 = self.create_user(VALID_USER_DATA)
response = self.create_article(VALID_ARTICLE, token1)
response = self.create_comment(
token=token1,
parentId=0,
slug=response.data['article']['slug']
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_object(self, article_id):\n try:\n comments = Comment.objects.all()\n #filter to only contain comments for specified article (article_id)\n comments = list(filter(lambda x: x.article_id == article_id , comments))\n return comments\n except Comment.D... | [
"0.7051459",
"0.7011194",
"0.6828945",
"0.67730135",
"0.67639273",
"0.647759",
"0.6316718",
"0.6151316",
"0.6119812",
"0.6088404",
"0.60635614",
"0.5980794",
"0.59584194",
"0.5949022",
"0.5934125",
"0.5932308",
"0.5923707",
"0.5905992",
"0.5903777",
"0.58925235",
"0.58722794"... | 0.78564686 | 0 |
user can delete comments for an article | def test_user_can_delete_their_comment(self):
token = self.create_user(VALID_USER_DATA)
response = self.create_article(VALID_ARTICLE, token)
response = self.create_comment(
token=token,
parentId=0,
slug=response.data['article']['slug']
)
get_co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_comments(self, pk):\n try:\n comments = Comment.objects.all()\n # filter to only contain comments for specified article (article_id)\n comments = list(filter(lambda x: x.article_id == pk, comments))\n\n #loop through and delete all comments\n ... | [
"0.724776",
"0.71893334",
"0.7097344",
"0.69964445",
"0.6952778",
"0.6936803",
"0.68999505",
"0.6801651",
"0.67899805",
"0.6717094",
"0.6655033",
"0.6592393",
"0.6590674",
"0.65445375",
"0.6513937",
"0.64832425",
"0.64586824",
"0.6398616",
"0.63897127",
"0.638828",
"0.6374779... | 0.7676523 | 0 |
user can update their comments for an article | def test_user_can_update_their_comment(self):
token = self.create_user(VALID_USER_DATA)
response = self.create_article(VALID_ARTICLE, token)
response = self.create_comment(
token=token,
parentId=0,
slug=response.data['article']['slug']
)
get_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_update_comments(self):\n # Implemented from template for\n # osid.resource.ResourceAdminSession.can_update_resources\n # NOTE: It is expected that real authentication hints will be\n # handled in a service adapter above the pay grade of this impl.\n return True",
"def t... | [
"0.6694878",
"0.6580968",
"0.6578074",
"0.65608335",
"0.65161645",
"0.642181",
"0.638465",
"0.6338328",
"0.6323572",
"0.6308092",
"0.62434256",
"0.6221932",
"0.6188669",
"0.6147377",
"0.6136802",
"0.60883176",
"0.6087288",
"0.6085069",
"0.6055377",
"0.6050128",
"0.60483855",
... | 0.70312065 | 0 |
User can view the edit history from a comment | def test_users_can_track_edit_history(self):
token = self.create_user(VALID_USER_DATA)
response = self.create_article(VALID_ARTICLE, token)
response = self.create_comment(
token=token,
parentId=0,
slug=response.data['article']['slug']
)
update... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_can_edit_comment(user, comment: DocumentComment):\n current_status = comment.document.status.id\n\n if user.id == comment.create_user_id and \\\n current_status == \\\n DocumentStatus.objects.get_by_natural_key('Draft').id:\n return True\n\n re... | [
"0.6276179",
"0.6129255",
"0.6072952",
"0.6031221",
"0.5972467",
"0.5945878",
"0.58512664",
"0.5815655",
"0.57384324",
"0.5737346",
"0.5734554",
"0.57197136",
"0.5719074",
"0.57138777",
"0.5686815",
"0.5665731",
"0.5661041",
"0.5657937",
"0.56377286",
"0.56316584",
"0.5626735... | 0.70912933 | 0 |
User can retrieve comments of invalid article | def test_user_can_get_comments_of_invalid_article(self):
token = self.create_user(VALID_USER_DATA)
response = self.create_article(VALID_ARTICLE, token)
response = self.create_comment(
token=token,
parentId=0,
slug=response.data['article']['slug']
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_can_get_comments_for_an_article(self):\n token1 = self.create_user(VALID_USER_DATA)\n response = self.create_article(VALID_ARTICLE, token1)\n response = self.create_comment(\n token=token1, \n parentId=0,\n slug=response.data['article']['slug']\n ... | [
"0.72780085",
"0.6803199",
"0.67557496",
"0.65182453",
"0.64307",
"0.64246607",
"0.6372403",
"0.6340008",
"0.6311736",
"0.62324345",
"0.6209545",
"0.61896634",
"0.61834466",
"0.6164329",
"0.6134414",
"0.60954946",
"0.60302156",
"0.6023688",
"0.5990243",
"0.5972506",
"0.594815... | 0.8203984 | 0 |
Calls the gpg command line utility to sign the passed content with the key identified by the passed keyid from the gpg keyring at the passed homedir. The executed base command is defined in securesystemslib.gpg.constants.gpg_sign_command. | def create_signature(content, keyid=None, homedir=None, timeout=GPG_TIMEOUT):
if not have_gpg(): # pragma: no cover
raise exceptions.UnsupportedLibraryError(NO_GPG_MSG)
if not CRYPTO: # pragma: no cover
raise exceptions.UnsupportedLibraryError(NO_CRYPTO_MSG)
keyarg = ""
if keyid:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gpg_sign(configs, artifact_folder):\n print(\"GPG sign all files in artifact folder...\")\n for file_to_sign in os.listdir(artifact_folder):\n gpg_str = 'gpg --batch --passphrase {0} -ab {1}'.format(\n configs[\"passwords\"][\"gpg\"], os.path.join(artifact_folder, file_to_sign))\n ... | [
"0.68507767",
"0.68322337",
"0.6398521",
"0.56058276",
"0.55639625",
"0.55280185",
"0.55247456",
"0.54288834",
"0.5412411",
"0.5399767",
"0.5361631",
"0.53325844",
"0.531024",
"0.53027576",
"0.5211971",
"0.5197494",
"0.5166297",
"0.5154255",
"0.5153762",
"0.5149427",
"0.51449... | 0.73907304 | 0 |
Verifies the passed signature against the passed content using the passed public key, or one of its subkeys, associated by the signature's keyid. The function selects the appropriate verification algorithm (rsa or dsa) based on the "type" field in the passed public key object. | def verify_signature(signature_object, pubkey_info, content):
if not CRYPTO: # pragma: no cover
raise exceptions.UnsupportedLibraryError(NO_CRYPTO_MSG)
formats.GPG_PUBKEY_SCHEMA.check_match(pubkey_info)
formats.GPG_SIGNATURE_SCHEMA.check_match(signature_object)
handler = SIGNATURE_HANDLERS[pu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _verify(pubkey: SupportedKeyTypes, sig: bytes, filehash: bytes, hashfunc: hashes.HashAlgorithm) -> None:\n if isinstance(pubkey, RSAPublicKey):\n pubkey.verify(sig, filehash, padding.PKCS1v15(), Prehashed(hashfunc))\n elif isinstance(pubkey, EllipticCurvePublicKey):\n pubkey... | [
"0.64094335",
"0.609544",
"0.57538563",
"0.5712986",
"0.56911343",
"0.56681806",
"0.56622565",
"0.5661895",
"0.5622748",
"0.5621221",
"0.5613082",
"0.55626976",
"0.55405384",
"0.5533384",
"0.5465545",
"0.5407589",
"0.5261456",
"0.525556",
"0.5251413",
"0.52476776",
"0.5198009... | 0.64093834 | 1 |
Exports multiple public keys from a GnuPG keyring. | def export_pubkeys(keyids, homedir=None, timeout=GPG_TIMEOUT):
public_key_dict = {}
for gpg_keyid in keyids:
public_key = export_pubkey(gpg_keyid, homedir=homedir, timeout=timeout)
keyid = public_key["keyid"]
public_key_dict[keyid] = public_key
return public_key_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _gpg_keys(self) -> ListKeys:\n return self.gpg.list_keys()",
"def gen_keys(lname,dsa=False):\n d = 'keys'\n if not os.path.isdir(d):\n os.mkdir(d)\n for n in lname:\n if not os.path.isfile('%s/%s.pem'%(d,n)):\n key = Crypto.PublicKey.DSA.generate(512, os.urandom) if d... | [
"0.6020826",
"0.59996045",
"0.5764085",
"0.56361765",
"0.5631428",
"0.56166446",
"0.5558561",
"0.55409014",
"0.552927",
"0.5520167",
"0.5482177",
"0.545604",
"0.5420718",
"0.54171395",
"0.54019034",
"0.53583276",
"0.53478974",
"0.5266232",
"0.5228462",
"0.52197886",
"0.520650... | 0.72244596 | 0 |
vec = logspace_quadrature(start, stop, num) Return the `num' equispace interger in log scale between `start' and `stop' with the constraint that they be divisible by 4. | def logspace_quadrature(start: float, stop: float, num: int) -> NDArray:
return 4 * rint(geomspace(start / 4, stop / 4, num=num)).astype(int) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logspace(start, stop, num=50, include_endpoint=True, base=10, dtype=None, constant=False):\n return Tensor(np.logspace(start, stop, num, include_endpoint, base, dtype), constant=constant)",
"def logspace(start,stop,num=50,endpoint=True,base=10.0):\n y = linspace(start,stop,num=num,endpoint=endpoint)\n ... | [
"0.71089005",
"0.7080484",
"0.7028581",
"0.6967482",
"0.6916623",
"0.6861421",
"0.6407103",
"0.63515925",
"0.6351078",
"0.62723017",
"0.6160656",
"0.61063635",
"0.60615623",
"0.5996366",
"0.59277433",
"0.59029776",
"0.5839394",
"0.58349806",
"0.5800873",
"0.5738171",
"0.56610... | 0.84608686 | 0 |
vec = logspace_epsilon(start, stop, num) Return the `num' equispace float in log scale between `start' and `stop'. | def logspace_epsilon(start: float, stop: float, num: int) -> NDArray:
return array([float(f"{x:.1e}") for x in geomspace(start, stop, num=num)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logspace_from_lin(start, stop, num=50):\n unit = unit_of(start)\n start_ = np.log2(to_unitless(start, unit))\n stop_ = np.log2(to_unitless(stop, unit))\n return np.exp2(np.linspace(start_, stop_, num)) * unit",
"def logspace(start, stop, num=50, include_endpoint=True, base=10, dtype=None, constan... | [
"0.75122464",
"0.7085507",
"0.6986215",
"0.6889644",
"0.6872215",
"0.6597869",
"0.6567027",
"0.6442175",
"0.6292748",
"0.62571156",
"0.60829014",
"0.6042655",
"0.60155225",
"0.5985579",
"0.593522",
"0.59056914",
"0.5905396",
"0.5873115",
"0.5857406",
"0.5847692",
"0.58172786"... | 0.8521804 | 0 |
Generate precipitation rasters for low and highprecip scenarios. | def generate_scenario_precip_inputs():
def multiply_precip(precip_raster, multiply_factor):
valid_mask = (precip_raster != precip_raster_nodata)
result = numpy.empty(precip_raster.shape, dtype=numpy.float32)
result[:] = _TARGET_NODATA
result[valid_mask] = precip_raster[valid_mask] * ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def workflow(save_dir):\n year = 2016\n month_series = range(1, 13)\n total_potential_biomass_multiplier = 48.8\n total_standing_biomass_multiplier = 45.25\n biomass_jitter = 3.\n diet_sufficiency_multiplier = 0.28\n diet_sufficiency_jitter = 0.01\n avg_animal_density = 0.0175\n animal_d... | [
"0.6527915",
"0.58097965",
"0.57598424",
"0.549908",
"0.543252",
"0.5431733",
"0.5426188",
"0.54042876",
"0.5392365",
"0.5392087",
"0.53920585",
"0.5366366",
"0.53536344",
"0.5327072",
"0.5309186",
"0.53031427",
"0.52818346",
"0.52812237",
"0.52715135",
"0.5270121",
"0.525383... | 0.6585323 | 0 |
Calculate the pixellevel difference in L_sum_avail between pre and postdecline landscapes, for each precip scenario. | def diff_l_sum_avail():
def subtract(raster1, raster2):
"""Subtract raster2 from raster1."""
valid_mask = (
(raster1 != nodata) &
(raster2 != nodata))
result = numpy.empty(raster1.shape, dtype=numpy.float32)
result[:] = nodata
result[valid_mask] = rast... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_total_risk_level(self) -> int:\n origin = Point(0, 0)\n bounded_points = self.grid.get_bounded_points(origin, self.target)\n return sum(self.get_region(point) for point, _ in bounded_points)",
"def get_threshold_bypl(scenario, row):\n fn = \"/i/0/sol/%s/%s/%s_%s.sol\" % (\n ... | [
"0.56551874",
"0.5233327",
"0.5082341",
"0.50011104",
"0.49651894",
"0.4928351",
"0.49194488",
"0.49171555",
"0.48630777",
"0.48488337",
"0.48428175",
"0.4842482",
"0.48370627",
"0.47904214",
"0.4780358",
"0.47743925",
"0.47738755",
"0.47570777",
"0.47366795",
"0.4721045",
"0... | 0.6240719 | 0 |
Subtract raster2 from raster1. | def subtract(raster1, raster2):
valid_mask = (
(raster1 != nodata) &
(raster2 != nodata))
result = numpy.empty(raster1.shape, dtype=numpy.float32)
result[:] = nodata
result[valid_mask] = raster1[valid_mask] - raster2[valid_mask]
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subtract_2_rasters(\r\n raster_path_a, raster_path_b, target_path):\r\n a_nodata = pygeoprocessing.get_raster_info(raster_path_a)['nodata'][0]\r\n b_nodata = pygeoprocessing.get_raster_info(raster_path_b)['nodata'][0]\r\n target_nodata = -9999\r\n\r\n def sub_op(a_array, b_array):\r\n ... | [
"0.7581937",
"0.6882157",
"0.65314496",
"0.62197345",
"0.61709106",
"0.61709106",
"0.61709106",
"0.6079049",
"0.6026854",
"0.60247636",
"0.6019486",
"0.59994996",
"0.5998246",
"0.59929824",
"0.59929824",
"0.5965789",
"0.5936023",
"0.5930357",
"0.5924577",
"0.5920633",
"0.5914... | 0.8415499 | 0 |
Trim trailing whitespace from the plain text file, updating it in place. | def trim_trailing_whitespace(path: Path) -> None:
content = path.read_text()
formatted_lines = [line.rstrip() for line in content.splitlines()]
new_content = "\n".join(formatted_lines) + "\n"
path.write_text(new_content) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_file(in_file, out_file):\n with open(in_file, \"r\") as book, open(out_file, \"w\") as out:\n for line in book:\n if line.strip() == \"\":\n continue\n\n line = normalize_text(line)\n\n out.write(line.lstrip())",
"def remove_empty_lines(file... | [
"0.68959224",
"0.6438378",
"0.605931",
"0.5986773",
"0.5979213",
"0.5861789",
"0.58034337",
"0.5790748",
"0.5610792",
"0.5541701",
"0.55375266",
"0.5525325",
"0.5481809",
"0.54726416",
"0.5431509",
"0.54275763",
"0.5426124",
"0.54154515",
"0.5401054",
"0.5397843",
"0.53946936... | 0.68411356 | 1 |
Run evaluator This function update predictions from context, evaluate them and update result file and result plot. | def run(self, context):
self.start()
while not context.is_finished():
self.update_predictions(context)
new_results, instances = self.evaluate()
if new_results:
self.write_results(new_results, instances)
self.update_plot(new_results, ins... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(parser):\n required_args = (\n 'train_tfrecord',\n 'valid_tfrecord',\n 'predicted_data',\n 'actual_data',\n )\n cli_args = add_all_args(parser, EVALUATION, *required_args)\n evaluator = Evaluator(\n input_shape=cli_args.input_shape,\n model_configu... | [
"0.68675935",
"0.68628967",
"0.6772609",
"0.67330617",
"0.6618416",
"0.6556874",
"0.6554007",
"0.6548344",
"0.6542789",
"0.65314573",
"0.65025735",
"0.6490764",
"0.6482366",
"0.64536554",
"0.6440243",
"0.64204234",
"0.64162874",
"0.641036",
"0.6386629",
"0.6354457",
"0.635429... | 0.75775164 | 0 |
Gets all the model instances. | def all_model_instances(self) -> Iterator['panda_core_data.model.Model']:
for current_type in self.all_models:
for current_instance in current_type.all_instances:
yield current_instance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_all_records(self) -> List[DBModelInstance]:\n return self.model.query.all()",
"def get_all(cls):\n return DataStore.get_all_instance(cls)",
"def iter_models(self):\n return iter(self.model_list)",
"def get_models(self):\n self.load()\n return self._models",
"def ... | [
"0.7698019",
"0.7503729",
"0.7334518",
"0.7277576",
"0.7223713",
"0.72139347",
"0.7193906",
"0.7129815",
"0.7070198",
"0.7070198",
"0.7070198",
"0.7070198",
"0.7070198",
"0.7070198",
"0.70472",
"0.7039465",
"0.7001101",
"0.6997673",
"0.6991649",
"0.68915975",
"0.6820305",
"... | 0.801359 | 0 |
compares an input string to the dictionary. Returns 0 if it doesn't match the first letters of any word, 1 if it does, 2 if it matches a word exactly | def compare(theInput,dictionary):
n=len(theInput)
ret=0
for word in dictionary:
if theInput==word: return 2
if theInput==word[:n]: ret=1
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isWord(word, dictionary):\n return word in dictionary",
"def isPrefix(string, dictionary):\n strLen = len(string)\n for word in dictionary:\n if word[:strLen] == string:\n return True\n return False",
"def property_2(string):\n for letter in al:\n pair = letter + let... | [
"0.6364099",
"0.6339004",
"0.6161465",
"0.61469054",
"0.61344486",
"0.613364",
"0.61099565",
"0.60987484",
"0.6097887",
"0.6091052",
"0.60874915",
"0.6049932",
"0.6044812",
"0.60355",
"0.602227",
"0.6019349",
"0.6019027",
"0.60125643",
"0.6011144",
"0.59723926",
"0.5962059",
... | 0.7055396 | 0 |
Add rules to Firewall. | def add_rules(self, rules):
self.name.append(rules) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_rules(self, rules: List[Rule]):\n self.rules.extend(rules)",
"def add_rules(self, rules: List[validation.rule.Rule]):\n for rule in rules:\n self.add_rule(rule)\n\n return self",
"def create_firewall_rule(self, body=None):\r\n return self.post(self.firewall_rules_... | [
"0.7520936",
"0.6762879",
"0.67130226",
"0.6688658",
"0.6618677",
"0.6593269",
"0.64975655",
"0.6359648",
"0.6357155",
"0.63370395",
"0.63134074",
"0.62356436",
"0.6231376",
"0.62186724",
"0.6169606",
"0.6080061",
"0.6075759",
"0.60745746",
"0.5991942",
"0.5985725",
"0.596699... | 0.7026838 | 1 |
Add source address to Rule. If the packet matches this then the action is taken. | def add_source_address(self, srcAddr):
self.source.address = srcAddr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_source(self, source: _Source) -> None:\n\n self._sources.append(source)",
"def _add_source_net_filter(self, rule_list, source_net):\n for rule in rule_list:\n if (\"source\" in rule.keys()):\n if (\"nets\" in rule[\"source\"].keys()):\n rule[\"s... | [
"0.6147156",
"0.6041207",
"0.600631",
"0.59983796",
"0.59466434",
"0.5875135",
"0.582798",
"0.5818522",
"0.5730725",
"0.57222754",
"0.5713313",
"0.57097584",
"0.569038",
"0.5674645",
"0.5668545",
"0.56297374",
"0.55851746",
"0.5569822",
"0.5554489",
"0.5545913",
"0.5456151",
... | 0.7249079 | 1 |
Add typename for ICMP to Rule. If the packet matches this then the action is taken. | def add_icmp_typename(self, typeName):
self.protocol = "icmp"
self.icmp.typename = typeName | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_icmp(pkt, packets, i, start_point):\r\n icmp_type = int(pkt[start_point:start_point+2], 16)\r\n start_point = start_point + 2\r\n icmp_code = int(pkt[start_point:start_point+2], 16)\r\n start_point = start_point + 2\r\n icmp_checksum = pkt[start_point:start_point+4]\r\n packets[i][2].a... | [
"0.57339853",
"0.55959594",
"0.5581209",
"0.550038",
"0.5402495",
"0.53664416",
"0.5311878",
"0.51565474",
"0.5117618",
"0.51003325",
"0.5003094",
"0.4985352",
"0.49788257",
"0.4964143",
"0.49132615",
"0.48973534",
"0.48141655",
"0.47941944",
"0.4757915",
"0.47573274",
"0.473... | 0.7089012 | 1 |
Test a default `Pw2gwCalculation`. | def test_pw2gw_default(fixture_sandbox, generate_calc_job, file_regression, remote, inputs, with_symlink):
entry_point_name = 'quantumespresso.pw2gw'
calc_info = generate_calc_job(fixture_sandbox, entry_point_name, inputs)
retrieve_list = ['aiida.out', 'epsX.dat', 'epsY.dat', 'epsZ.dat', 'epsTOT.dat']
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_init_default_scoring():\n\n tpot_obj = TPOTRegressor()\n assert tpot_obj.scoring_function == 'neg_mean_squared_error'",
"def test_custom_works_fine(self):\n\t\thsaba_custom = self.algo(NP=10, Limit=2, seed=self.seed)\n\t\thsaba_customc = self.algo(NP=10, Limit=2, seed=self.seed)\n\t\tAlgorithmTest... | [
"0.54319876",
"0.53312033",
"0.52903694",
"0.5287584",
"0.52864814",
"0.52822727",
"0.5277",
"0.5277",
"0.5252502",
"0.52179444",
"0.5187263",
"0.51575553",
"0.51491416",
"0.5145803",
"0.513132",
"0.51312876",
"0.5108078",
"0.5090236",
"0.5080785",
"0.50785524",
"0.5066683",
... | 0.6165722 | 0 |
Compute a string key for a given field/format/conversion. | def flatKey(
self, fieldName: str, formatSpec: Optional[str], conversion: Optional[str]
) -> str:
if formatSpec is None:
formatSpec = ""
if conversion is None:
conversion = ""
result = "{fieldName}!{conversion}:{formatSpec}".format(
fieldName=fie... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cache_key_from_field_object(self, scope, field_object):\r\n if scope == Scope.user_state:\r\n return (scope, field_object.module_state_key.map_into_course(self.course_id))\r\n elif scope == Scope.user_state_summary:\r\n return (scope, field_object.usage_id.map_into_course(s... | [
"0.638103",
"0.63024837",
"0.61655",
"0.6129932",
"0.6068213",
"0.6046238",
"0.59965515",
"0.5986165",
"0.5982876",
"0.5909534",
"0.59017485",
"0.5895281",
"0.58876413",
"0.5869471",
"0.58367276",
"0.5827761",
"0.580957",
"0.57902354",
"0.57848155",
"0.57621527",
"0.5746614",... | 0.73828506 | 0 |
Flatten the given event by preassociating format fields with specific objects and callable results in a L{dict} put into the C{"log_flattened"} key in the event. | def flattenEvent(event: LogEvent) -> None:
if event.get("log_format", None) is None:
return
if "log_flattened" in event:
fields = event["log_flattened"]
else:
fields = {}
keyFlattener = KeyFlattener()
for (literalText, fieldName, formatSpec, conversion) in aFormatter.parse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flatFormat(event: LogEvent) -> str:\n fieldValues = event[\"log_flattened\"]\n keyFlattener = KeyFlattener()\n s = []\n\n for literalText, fieldName, formatSpec, conversion in aFormatter.parse(\n event[\"log_format\"]\n ):\n s.append(literalText)\n\n if fieldName is not None... | [
"0.6760659",
"0.65010715",
"0.5891237",
"0.58312917",
"0.57149434",
"0.5618122",
"0.55652946",
"0.5552419",
"0.55145985",
"0.5493505",
"0.54799795",
"0.52787995",
"0.5243208",
"0.5241175",
"0.51138145",
"0.5099614",
"0.5053237",
"0.49583116",
"0.4888975",
"0.48837164",
"0.483... | 0.7920332 | 0 |
Extract a given format field from the given event. | def extractField(field: str, event: LogEvent) -> Any:
keyFlattener = KeyFlattener()
[[literalText, fieldName, formatSpec, conversion]] = aFormatter.parse(
"{" + field + "}"
)
assert fieldName is not None
key = keyFlattener.flatKey(fieldName, formatSpec, conversion)
if "log_flattened"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_format_event(file_events):\n file_format_event = file_events.filter(event_type=\"format identification\").first()\n if file_format_event:\n return file_format_event",
"def get_field(self, bib_entry, field):\n output = bib_entry.fields[field] if field in bib_entry.fields else \"\"... | [
"0.62060285",
"0.56357586",
"0.5468803",
"0.54453415",
"0.54446566",
"0.5433722",
"0.5357515",
"0.5338236",
"0.53367466",
"0.5330088",
"0.5312251",
"0.52503425",
"0.521106",
"0.51955575",
"0.5138566",
"0.51353544",
"0.5133794",
"0.5117337",
"0.5115096",
"0.5113306",
"0.509367... | 0.7677983 | 0 |
Format an event which has been flattened with L{flattenEvent}. | def flatFormat(event: LogEvent) -> str:
fieldValues = event["log_flattened"]
keyFlattener = KeyFlattener()
s = []
for literalText, fieldName, formatSpec, conversion in aFormatter.parse(
event["log_format"]
):
s.append(literalText)
if fieldName is not None:
key =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flattenEvent(event: LogEvent) -> None:\n if event.get(\"log_format\", None) is None:\n return\n\n if \"log_flattened\" in event:\n fields = event[\"log_flattened\"]\n else:\n fields = {}\n\n keyFlattener = KeyFlattener()\n\n for (literalText, fieldName, formatSpec, conversio... | [
"0.68550235",
"0.61438745",
"0.61311406",
"0.55230755",
"0.5460096",
"0.53753906",
"0.53002834",
"0.5203177",
"0.520288",
"0.5122038",
"0.5082791",
"0.506107",
"0.50313926",
"0.495877",
"0.49565652",
"0.49548748",
"0.4943327",
"0.49426275",
"0.48641995",
"0.4741003",
"0.47187... | 0.6792072 | 1 |
Public method to show a message in the bottom part of the splashscreen. msg message to be shown (string) | def showMessage(self, msg):
super(SplashScreen, self).showMessage(
msg, self.labelAlignment, QColor(_QtCore.Qt.white))
QApplication.processEvents() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_message(window, msg):\n v = create_output_panel(window, '')\n _append(v, msg)",
"def showMessage(self):",
"def display_message():",
"def _flash(self,id,msg,duration=30.0):\n if duration>0:\n pass #gtk.timeout_add(duration,'')\n return self.statusbar.push(id,msg)",
... | [
"0.6831969",
"0.6766163",
"0.6757307",
"0.6628959",
"0.6532629",
"0.648848",
"0.6473647",
"0.6443324",
"0.6439594",
"0.6422004",
"0.63924766",
"0.6330386",
"0.6285463",
"0.62818736",
"0.6280677",
"0.62405944",
"0.62403274",
"0.62266165",
"0.61867714",
"0.6167764",
"0.61663175... | 0.82565975 | 0 |
Wait until the specified EC2 resource (instance, image, volume, ...) transitions from any of the given 'from' states to the specified 'to' state. If the instance is found in a state other that the to state or any of the from states, an exception will be thrown. | def wait_transition(resource, from_states, to_state,
state_getter=attrgetter('state')):
state = state_getter(resource)
while state in from_states:
time.sleep(a_short_time)
for attempt in retry_ec2():
with attempt:
resource.update(validate=True)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def until_instances_in_state(self, **states):\n timeout = self.timeout()\n while not timeout:\n counts = self.instance_states()\n if counts == states:\n return\n\n time.sleep(2)",
"def validate_valid_transition(enum, from_value, to_value):\n valida... | [
"0.5824875",
"0.5623646",
"0.56056595",
"0.54760593",
"0.53725404",
"0.53470594",
"0.52862585",
"0.5239472",
"0.52138066",
"0.51882076",
"0.5107701",
"0.510443",
"0.50948304",
"0.50338316",
"0.50102705",
"0.49956095",
"0.49890852",
"0.49851823",
"0.49591202",
"0.48840776",
"0... | 0.8329309 | 1 |
Wait until no spot request in the given iterator is in the 'open' state or, optionally, a timeout occurs. Yield spot requests as soon as they leave the 'open' state. | def wait_spot_requests_active(ec2, requests: Iterable[SpotInstanceRequest], timeout: float = None, tentative: bool = False) -> Iterable[List[SpotInstanceRequest]]:
if timeout is not None:
timeout = time.time() + timeout
active_ids = set()
other_ids = set()
open_ids = None
def cancel():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_spot_requests_active(ec2, requests, timeout=None, tentative=False):\n\n if timeout is not None:\n timeout = time.time() + timeout\n active_ids = set()\n other_ids = set()\n open_ids = None\n\n def cancel():\n log.warning('Cancelling remaining %i spot requests.', len(open_ids))... | [
"0.64133847",
"0.54700196",
"0.53930193",
"0.53253734",
"0.522287",
"0.52173835",
"0.5123776",
"0.5107116",
"0.5091519",
"0.50446767",
"0.5001658",
"0.49590588",
"0.49590588",
"0.49590588",
"0.49398538",
"0.49208733",
"0.48923516",
"0.4862277",
"0.48590606",
"0.48429903",
"0.... | 0.6397087 | 1 |
Creates a launch template with the given name for launching instances with the given parameters. We only ever use the default version of any launch template. | def create_launch_template(ec2_client: BaseClient,
template_name: str,
image_id: str,
key_name: str,
instance_type: str,
security_group_ids: Optional[List] = None,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_launch_template(self, name: str, description: str, data: Dict) -> Dict:\n kwargs = {'LaunchTemplateName': name,\n 'VersionDescription': description,\n 'LaunchTemplateData': data}\n return self.client.create_launch_template(**kwargs)",
"def create_launch_... | [
"0.72641915",
"0.6778969",
"0.63940763",
"0.61855185",
"0.61780214",
"0.6137633",
"0.60221386",
"0.596194",
"0.5960937",
"0.5890139",
"0.58353853",
"0.58023816",
"0.5800883",
"0.5780713",
"0.57555413",
"0.5618659",
"0.5616187",
"0.55308425",
"0.5498409",
"0.54877406",
"0.5451... | 0.7075948 | 1 |
Get a LaunchTemplateSpecification for the given instance type. | def get_launch_template_spec(instance_type):
return {'LaunchTemplateId': launch_template_ids[instance_type], 'Version': '$Default'} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_launch_template(lt_name):\n logger.info(f'Describing launch template for {lt_name}...')\n response = ec2_client.describe_launch_templates(LaunchTemplateNames=[lt_name])\n return response['LaunchTemplates'][0]",
"def template(self) -> Optional[pulumi.Input['InstanceTemplateSpecArgs']]:\n r... | [
"0.6161785",
"0.6109164",
"0.5901771",
"0.5547203",
"0.5516086",
"0.53271073",
"0.5300028",
"0.5290134",
"0.5290134",
"0.52424955",
"0.5200714",
"0.5172569",
"0.5155719",
"0.5111424",
"0.5040829",
"0.501867",
"0.4991858",
"0.4991858",
"0.49644318",
"0.49612013",
"0.49473852",... | 0.7545968 | 0 |
Grab all data within the time range in the ObserverStats object. This gives us two views of the data by observer type and by nameserver. | def fetch_propagation_data(observer_stats):
columns = [
Observer.TABLE.c.start_time,
Observer.TABLE.c.duration,
Observer.TABLE.c.type,
Observer.TABLE.c.status,
Observer.TABLE.c.nameserver,
]
query = select(columns).where(
and_(Observer.TABLE.c.start_time >= ob... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_dns_query_data(observer_stats, threshold=None):\n columns = [\n DnsQuery.TABLE.c.nameserver,\n DnsQuery.TABLE.c.status,\n DnsQuery.TABLE.c.timestamp,\n DnsQuery.TABLE.c.duration,\n ]\n\n if threshold is None:\n query = select(columns).where(\n and_(\... | [
"0.6322721",
"0.59190804",
"0.55406624",
"0.5499491",
"0.53490144",
"0.5338446",
"0.5327392",
"0.5269172",
"0.5253611",
"0.5251995",
"0.523506",
"0.52192783",
"0.5166268",
"0.5163687",
"0.5158407",
"0.515774",
"0.5150035",
"0.51449233",
"0.51405334",
"0.5119434",
"0.51181614"... | 0.62536335 | 1 |
Search for a webelement, get its text, compare with expected_text | def verify_text(self, expected_text: str, *locator):
e = self.driver.find_element(*locator)
actual_text = e.text
assert expected_text == actual_text, f"Expected {expected_text} does not match actual {actual_text}" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_text_in_element():\n nonlocal text_\n if text_ is None:\n text_ = element.text\n element_text = element.text\n if element_text == text:\n return element\n if text.lower() == element_text.lower():\n return el... | [
"0.75028706",
"0.68471503",
"0.6784768",
"0.66558605",
"0.6586245",
"0.65446293",
"0.6540035",
"0.6536432",
"0.64735866",
"0.6412034",
"0.6392269",
"0.63771224",
"0.63462776",
"0.6344391",
"0.6303919",
"0.62900984",
"0.62873024",
"0.6238481",
"0.6172193",
"0.6143173",
"0.6115... | 0.7155954 | 1 |
Display the input history | def show_input_history(self):
# copy with user multifilter
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def history():",
"def show_history_log(self):\n self.visual.print_enum(self.visual.history_log)",
"def print_history(self):\n self.game_started = False\n for state in self.history:\n self.__draw_board(state)",
"def showSearchHistory(self):\n field = self.txtSearchHistory\n ... | [
"0.7834511",
"0.7569966",
"0.71997684",
"0.7151319",
"0.68784857",
"0.6833684",
"0.6816879",
"0.67939866",
"0.67820376",
"0.6735712",
"0.6731279",
"0.6593247",
"0.6559692",
"0.6559692",
"0.6559692",
"0.65540755",
"0.65540755",
"0.65523255",
"0.6543018",
"0.65201294",
"0.64824... | 0.78117853 | 1 |
Display raw bibtex of the selection | def show_raw_bibtex(self, entry_idx=None):
if entry_idx is None:
entry_idx = self.selector.get_selection()
else:
entry_idx = self.selector.select_by_index(entry_idx)
if not entry_idx:
self.visual.error("Need a selection to show raw bibtex of")
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bibtex(self) -> str:\n a = BibDatabase()\n a.entries = [self.bib]\n return bibtexparser.dumps(a)",
"def copy_raw_bibtex(self, entry_idx=None):\n if entry_idx is None:\n entry_idx = self.selector.get_selection()\n else:\n entry_idx = self.selector.selec... | [
"0.68152225",
"0.675579",
"0.6602158",
"0.6285689",
"0.5774236",
"0.57184494",
"0.5599995",
"0.55009043",
"0.5491813",
"0.5483719",
"0.54388016",
"0.5421458",
"0.54180384",
"0.5347414",
"0.53143513",
"0.5313949",
"0.5307857",
"0.53024274",
"0.52850306",
"0.5266816",
"0.526535... | 0.7959872 | 0 |
Copy the raw bibtex of the selection | def copy_raw_bibtex(self, entry_idx=None):
if entry_idx is None:
entry_idx = self.selector.get_selection()
else:
entry_idx = self.selector.select_by_index(entry_idx)
if not entry_idx:
self.visual.error("Need a selection to show raw bibtex of")
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_selection( self, ):\n try:\n data = self.msg_text.get( \"sel.first\", \"sel.last\" )\n pyperclip.copy( data )\n except Exception as exception: # if no selection\n pass",
"def bibtex(self) -> str:\n a = BibDatabase()\n a.entries = [self.bib]\... | [
"0.61058193",
"0.60512817",
"0.59239763",
"0.58814573",
"0.5879674",
"0.5807684",
"0.5780087",
"0.5697196",
"0.5688134",
"0.5563128",
"0.5486109",
"0.54836905",
"0.5456211",
"0.5332448",
"0.53201324",
"0.52739567",
"0.526546",
"0.52503425",
"0.52167636",
"0.5201794",
"0.51969... | 0.77476096 | 0 |
Open the pdf of an entry | def pdf_open(self, arg=None):
nums = self.selector.select_by_index(arg)
if not nums or nums is None:
self.visual.print("Need a selection to open.")
# arg has to be a single string
if utils.has_none(nums):
self.visual.print("Need a valid entry index.")
for ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open(pdf=None, key=None, bibcode=None, pdf_file=None):\n if pdf is None and key is None and bibcode is None and pdf_file is None:\n raise ValueError(\"At least one of the arguments must be not None\")\n\n # Set pdf_file:\n if pdf_file is not None:\n pass\n elif pdf is not None:\n ... | [
"0.71574897",
"0.69651294",
"0.6672312",
"0.6605501",
"0.64958584",
"0.6466954",
"0.609538",
"0.6081259",
"0.6059829",
"0.604097",
"0.6026577",
"0.60037476",
"0.5994538",
"0.59375995",
"0.5924511",
"0.5920576",
"0.5846454",
"0.5843259",
"0.57760054",
"0.57647496",
"0.5679288"... | 0.78840697 | 0 |
Jump to a specific history step | def jump_history(self, index):
if type(index) is str:
index = utils.str_to_int(index)
if self.reference_history_index == index:
self.visual.error("Already on starting history.")
return
if index >= 0 and index < len(self.reference_history):
self.ste... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def history_go(self, relative):\n self.thistab.history_go(int(relative))",
"def step():\n \n step = models.Step(action=u\"goto\", target=u\"http://www.joesfunerals.com\")",
"def _historyForwardClickedSlot(self):\r\n\r\n steps, success = self._controller.forwardAction.data().toInt()\r\n ... | [
"0.705413",
"0.68320966",
"0.6704773",
"0.64074683",
"0.63368887",
"0.6282589",
"0.62462467",
"0.6196051",
"0.61694306",
"0.6150364",
"0.6136726",
"0.6126961",
"0.6078458",
"0.6047492",
"0.60266054",
"0.597202",
"0.5902899",
"0.58969504",
"0.5884526",
"0.5877796",
"0.58666795... | 0.76633203 | 0 |
Function to step +/ n steps to history | def step_history(self, n_steps=-1):
n_steps = utils.get_single_index(n_steps)
self.visual.debug("Stepping through a {}-long history, current index: {}, current length: {}, step is {}".format(len(self.reference_history), self.reference_history_index, len(self.reference_entry_id_list), n_steps))
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def increment_steps(self):\n self.num_steps += 1",
"def increment_step(self, n_steps: int) -> None:\n self.step = self.policy.increment_step(n_steps)",
"def increment_step(self, n_steps: int) -> None:\n self.step = self.policy.increment_step(n_steps)",
"def backtrack_steps():\n\n # In... | [
"0.6772057",
"0.67315614",
"0.67315614",
"0.65895635",
"0.65459734",
"0.65257627",
"0.63886577",
"0.6339741",
"0.6237703",
"0.6207665",
"0.6206845",
"0.61948144",
"0.61285514",
"0.6119168",
"0.6104943",
"0.6104015",
"0.6096012",
"0.6045004",
"0.5994955",
"0.5975936",
"0.59531... | 0.70220196 | 0 |
Display the history of past logs | def show_history_log(self):
self.visual.print_enum(self.visual.history_log) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def history():",
"def history():\n \n user_id = session[\"user_id\"]\n history_list = hist(user_id, db)\n return render_template('history.html', history=history_list)",
"def history():\n query = Records.query.filter_by(user_id=session.get(\"user_id\")).all()\n return render_template(\"history... | [
"0.81908417",
"0.73947614",
"0.73736984",
"0.7260729",
"0.72394687",
"0.72394687",
"0.72394687",
"0.71871954",
"0.7104882",
"0.7076923",
"0.70666885",
"0.70300686",
"0.6997992",
"0.697799",
"0.69611007",
"0.69512576",
"0.6927413",
"0.6924873",
"0.69063616",
"0.68983793",
"0.6... | 0.7877134 | 1 |
Change the reference list to its latest modificdation Calling the function after a search will set the reference list to the resulting entry set. | def change_history(self, new_reflist, modification_msg):
self.visual.log("New reference list wrt: [{}], yielded {} items.".format(modification_msg, len(new_reflist)))
self.push_reference_list(new_reflist, modification_msg)
# unselect stuff -- it's meaningless now
self.unselect() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateScptRefs(self):\n for scpt in self.refs_scpt.keys():\n self.refs_scpt[scpt] = scpt.getRef()\n self.scptRefs = set(self.refs_scpt.values())",
"def resetConflictList(self):\n return\n #self.conflict_list = PersistentMapping()",
"def latest_ref(self):",
"def update(self)... | [
"0.5823228",
"0.5696979",
"0.5693149",
"0.5477903",
"0.54641354",
"0.54172283",
"0.5395508",
"0.5359608",
"0.53491706",
"0.5348922",
"0.5333087",
"0.53047913",
"0.527268",
"0.5261751",
"0.5248508",
"0.52465993",
"0.5226675",
"0.52057576",
"0.52036506",
"0.51973283",
"0.519499... | 0.64127845 | 0 |
Function to attach a local pdf path to an entry | def set_local_pdf_path(self, str_selection=None):
nums = self.selector.select_by_index(str_selection)
if nums is None or not nums or len(nums) > 1:
self.visual.error("Need a single selection to set pdf to.")
return
entry = self.entry_collection.entries[self.reference_entr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put_attach_document(filename: str, entry_hash: str) -> str:\n g.ledger.file.insert_metadata(entry_hash, \"document\", filename)\n return f\"Attached '{filename}' to entry.\"",
"def open_file(entry):\n entry.delete(0, 'end')\n file = askopenfile(mode ='r', filetypes =[('PDF Files', '*.pdf')])\n ... | [
"0.6260518",
"0.62164277",
"0.6133685",
"0.61190873",
"0.601275",
"0.5898673",
"0.58965534",
"0.5853636",
"0.583997",
"0.5785303",
"0.57108134",
"0.5683029",
"0.56511647",
"0.5613092",
"0.55610275",
"0.5553567",
"0.55016506",
"0.54960257",
"0.5474063",
"0.544802",
"0.54317564... | 0.709661 | 0 |
Function to cite an entry | def cite(self, arg=None):
nums = self.selector.select_by_index(arg)
if nums is None or not nums:
self.visual.error("Need a selection to cite.")
return
citation_id = ", ".join([self.reference_entry_id_list[n] for n in nums])
citation = "\\cite{{{}}}".format(citatio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cite(silent=False):\n if silent is False:\n print(__cite__)\n else:\n return __bibtex__",
"def make_citation(meta):\n pass",
"def citeproc(style, reference_list):\n pass",
"def to_citation(self, type):\n acs_authors = \"; \".join(self.format_authors(\"acs\"))\n # Som... | [
"0.68519396",
"0.66513044",
"0.6269391",
"0.6148226",
"0.5920095",
"0.5774845",
"0.57598853",
"0.56668186",
"0.5585785",
"0.55778253",
"0.5571776",
"0.55563915",
"0.553391",
"0.55278593",
"0.55174685",
"0.5463496",
"0.544523",
"0.5427308",
"0.54020184",
"0.53890437",
"0.53564... | 0.6908319 | 0 |
Search the web for a pdf pertaining to the current entry selection | def search_web_pdf(self, str_selection=None):
nums = self.selector.select_by_index(str_selection)
if nums is None or not nums or len(nums) > 1:
self.visual.error("Need a single selection to download pdf to.")
return
entry_id = self.reference_entry_id_list[nums[0]]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pdf_open(self, arg=None):\n nums = self.selector.select_by_index(arg)\n if not nums or nums is None:\n self.visual.print(\"Need a selection to open.\")\n # arg has to be a single string\n if utils.has_none(nums):\n self.visual.print(\"Need a valid entry index.\... | [
"0.7713435",
"0.68374825",
"0.66385597",
"0.62042266",
"0.61473495",
"0.60966283",
"0.5858778",
"0.58104765",
"0.5777446",
"0.57145166",
"0.5699604",
"0.56666553",
"0.55972296",
"0.5586182",
"0.55621207",
"0.5522652",
"0.5515224",
"0.5498697",
"0.5466489",
"0.54585826",
"0.54... | 0.7948106 | 0 |
Parse the command line arguments and write the corresponding XDMF file. | def main():
parser = ArgumentParser(
description="Write an XDMF file for post-processing results in HDF5.")
parser.add_argument(dest="file_name", metavar="<filename>",
help="path to an HDF5 file for which XDMF metadata should be written")
parser.add_argument("-t", "--type", d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n parsed_args = parse_args()\n dfg = DummyFileGenerator(parsed_args[0], **parsed_args[1])\n dfg.write_output_file(**parsed_args[2])",
"def exportBulletFile(*argv):",
"def main(args):\n # Results: print to console and also write to output file\n pass",
"def __main__():\n parser =... | [
"0.62449414",
"0.6101182",
"0.60397434",
"0.58313733",
"0.5817086",
"0.5783014",
"0.57435566",
"0.56002647",
"0.5445973",
"0.54362404",
"0.54019433",
"0.540165",
"0.53999245",
"0.53663015",
"0.5336973",
"0.53198874",
"0.52856547",
"0.5267965",
"0.5257674",
"0.5251052",
"0.523... | 0.7708665 | 0 |
In this function, we read a csv file to separate the dataset into two parts called "nudity" and "normal". We, then, copy the nude images into the "nudity" folder and the other into the "normal" folder. | def process_raw_dataset(path_csv, processed_data):
labels = defaultdict(list)
with open(path_csv, 'rb') as csvfile:
stream_data = csv.DictReader(csvfile, delimiter=',')
for row in stream_data:
for (k, v) in row.items():
labels[k].append(v)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data():\n # Dictionary mapping image names to labels\n image_name_to_label = dict()\n\n # Store labels associated with image names\n notifier.send(\" Reading metadata...\")\n with open(\"data/metadata.csv\") as file: # Original dataset\n # Use images for normal, virus (unknown ty... | [
"0.6221404",
"0.6066151",
"0.5918556",
"0.58840704",
"0.5861433",
"0.5836633",
"0.5814959",
"0.5814711",
"0.57464224",
"0.5727429",
"0.5669105",
"0.5636576",
"0.5585446",
"0.55809695",
"0.55803156",
"0.5564481",
"0.5549987",
"0.55359995",
"0.5535824",
"0.55266327",
"0.5511501... | 0.7450069 | 0 |
Convert vector to one hot form. | def to_one_hot(v):
n = len(v)
m = max(v) + 1
out = np.zeros((n, m))
out[np.arange(n), v] = 1
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_to_onehot(vector, num_classes=None):\n assert isinstance(vector, np.ndarray)\n assert len(vector) > 0\n\n if num_classes is None:\n num_classes = np.max(vector)+1\n else:\n assert num_classes > 0\n assert num_classes >= np.max(vector)\n\n result = np.zeros(shape=(len... | [
"0.8490456",
"0.8103757",
"0.79804724",
"0.7954823",
"0.78555137",
"0.7808817",
"0.7680536",
"0.7607491",
"0.75317764",
"0.7527006",
"0.75106126",
"0.75083894",
"0.74944246",
"0.74725986",
"0.7460844",
"0.7426176",
"0.741461",
"0.7379436",
"0.7379436",
"0.7379436",
"0.7368112... | 0.86740214 | 0 |
Return best saved model from basename. | def best_model_from_dir(basename):
models = glob.glob(basename + '*.index')
best_model = None
# get best model, if exists
models_out = []
for m in models:
match = re.match(re.escape(basename) + '(1?[0-9]{4}).index', m)
if match:
models_out.append(int(match.groups()[0]))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_latest_saved_model(model_dir):\n saved_models = os.path.join(model_dir, 'best_models')\n saved_chkp = sorted([int(mdl) for mdl in os.listdir(saved_models)])\n latest = saved_chkp[-1]\n path = os.path.join(saved_models, '%d' % latest)\n\n # Next, find the full path to the saved model\n mdl... | [
"0.72615594",
"0.7203072",
"0.6981535",
"0.69693244",
"0.6907213",
"0.68909866",
"0.6813552",
"0.67604953",
"0.675071",
"0.6747153",
"0.67380697",
"0.6728239",
"0.669167",
"0.66892385",
"0.66410077",
"0.6632338",
"0.65335447",
"0.65113086",
"0.65043974",
"0.64896995",
"0.6379... | 0.784153 | 0 |
Run predictions w/ test time rotation augmentation by angs | def predict_testaug(model, X, batchsize=None, angs=None):
preds = []
for a in angs:
print('rotating test set by angle: {:.2f}...'.format(a))
rotX = np.stack(Parallel(n_jobs=-1)(delayed(rotate)
(im, a, preserve_range=True)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_experiments() :\n #%%\n target_size=(32,32)\n g_specs = {\n \"batch_size\" : [ 30 , 60, 100 ],\n \"learning_rate\" : [ 0.0002, 0.0003, 0.0005 ],\n \"drop_out_rate\" : [ 0.2, 0.25, 0.3 ],\n \"rescale_mode\" : [ \"max_q\" , \"max\", \"\" ]\n }\n\n model_traits = M... | [
"0.6183047",
"0.61516017",
"0.6134961",
"0.61310446",
"0.60742813",
"0.6060462",
"0.6060413",
"0.5913337",
"0.5902078",
"0.58697194",
"0.5860837",
"0.5851886",
"0.5822639",
"0.58169556",
"0.57997453",
"0.579611",
"0.57574785",
"0.57425636",
"0.569915",
"0.56784314",
"0.567378... | 0.7156704 | 0 |
Calculate a mass using the Torres calibration | def massTorres(teff, erteff, logg, erlogg, feh, erfeh):
ntrials = 100
randomteff = teff + erteff * np.random.randn(ntrials)
randomlogg = logg + erlogg * np.random.randn(ntrials)
randomfeh = feh + erfeh * np.random.randn(ntrials)
# Parameters for the Torres calibration:
a1, a2, a3 = 1.5689, 1.37... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cal_mass(self):\n\n if not self.check_def(['E','px','py','pz']):\n sys.exit('Particle error: Quadri impulsion not define (error for mass routine)')\n\n\n \n if self.E**2-self.px**2-self.py**2-self.pz**2>1e-7: #precision problem\n self.mass=math.sqrt(self.E**2-... | [
"0.6704896",
"0.66077316",
"0.6563508",
"0.64171964",
"0.64057356",
"0.628466",
"0.6214704",
"0.62146425",
"0.6186859",
"0.6169552",
"0.6161276",
"0.6155291",
"0.609218",
"0.6083895",
"0.6079843",
"0.60665077",
"0.6064035",
"0.6064035",
"0.6000756",
"0.59707755",
"0.59568936"... | 0.67022866 | 1 |
This function finds the best for both the target object and the robot. Here, we assign 4 different type of costs. (1) cost of changing legs if needed. (2) cost of robot motion to the starting state of the planned path. (3) cost of object manipulation, which is based on object's path. (4) cost of predicted repositioning... | def Optimizer(r_grasp,PAM_r, PAM_s, object_s, object_f, object_params, phi, r_max, walls, obstacles, obstacles_PAM, current_leg, n, n_p, v_max, force_max, legs, dt):
global action_push_pull, PAM_goal, grasping_goal, object_path_planned, PAM_path_planned
# assigning cost of changing from one leg to another based... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_best_goal_node(self):\n\n dist_to_goal_list = [self.calc_dist_to_goal(n.x, n.y) for n in self.node_list]\n goal_indexes = [\n dist_to_goal_list.index(i)\n for i in dist_to_goal_list\n if i <= self.expand_dis\n ]\n\n safe_goal_indexes = []\n ... | [
"0.65465975",
"0.6469724",
"0.6405786",
"0.6401081",
"0.6316471",
"0.6307774",
"0.6241775",
"0.6239213",
"0.62384593",
"0.6211875",
"0.6193676",
"0.60697377",
"0.6068892",
"0.60370046",
"0.6031944",
"0.60016024",
"0.59971553",
"0.59770614",
"0.59660935",
"0.5960024",
"0.59586... | 0.6471031 | 1 |
Perform the add ToDo request and return the data in case of success | def post_add_todo_request(self):
response = requests.post(
url=self.url,
headers=self.default_headers,
json=self.habitica_todo.to_json_dict()
)
return get_data_or_exit(response) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_todo():\n task = flask.request.form[\"task\"]\n todos.append(ToDo(task))\n return \"success\"",
"def add(request):\n\tif request.method == 'GET':\n\t\tID = request.GET.get('id',False)\n\t\tstatus = request.GET.get('status',False)\n\t\ttaskname = request.GET.get('taskname',False)\n\t\tdescription... | [
"0.7596594",
"0.7439005",
"0.7321323",
"0.6966536",
"0.680227",
"0.6778358",
"0.66524065",
"0.66510046",
"0.65505797",
"0.64994675",
"0.6434419",
"0.64133227",
"0.6331727",
"0.6325294",
"0.63199586",
"0.6279663",
"0.62545174",
"0.6237472",
"0.6219414",
"0.6143676",
"0.6111249... | 0.79520947 | 0 |
Function used to get collection names of the current dataset | def get_current_collection_names(account, dataset):
token = get_access_token()
selected_dataset_id = get_dataset_id(token, dataset)
r = requests.get(f"{PENNSIEVE_URL}/datasets/{selected_dataset_id}/collections", headers=create_request_headers(token))
r.raise_for_status()
return r.json() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collections(self):\r\n\t\tself.fetch_collections()\r\n\t\treturn self._collection_names",
"def get_collection_names(res_id):\n one = get_db()[CLIENTS_COLLECTION].find_one(\n {'res_id': res_id}, {'collections': 1, '_id': 0}\n )\n return one['collections']",
"def get_all_collection_names(self... | [
"0.7708619",
"0.73003423",
"0.6968342",
"0.6792319",
"0.6791377",
"0.67810154",
"0.6711488",
"0.6682415",
"0.6503992",
"0.6489309",
"0.6436213",
"0.6428013",
"0.63834316",
"0.6365121",
"0.63554806",
"0.6211192",
"0.61984485",
"0.61952776",
"0.61127555",
"0.60709864",
"0.60323... | 0.8088284 | 0 |
Function used to upload the collection tags of a dataset to Pennsieve | def upload_collection_names(account, dataset, tags):
token = get_access_token()
selected_dataset_id = get_dataset_id(token, dataset)
if not has_edit_permissions(token, selected_dataset_id):
abort(403, "You do not have permission to edit this dataset.")
store = []
for tag in tags:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload2notion(page, name, tags):\n row = page.collection.add_row()\n row.name = str(name.stem)\n row.Tags = tags\n for image_path in image_dir.iterdir():\n image = row.children.add_new(ImageBlock)\n image.upload_file(str(image_path))\n pdf = row.children.add_new(FileBlock)\n pdf... | [
"0.6116331",
"0.58188635",
"0.5790391",
"0.57721794",
"0.57665956",
"0.5733764",
"0.5722805",
"0.56501263",
"0.5572317",
"0.55265164",
"0.54406065",
"0.5418415",
"0.5416835",
"0.540117",
"0.5386757",
"0.53538316",
"0.5353162",
"0.5342134",
"0.5325164",
"0.53233975",
"0.529759... | 0.7389916 | 0 |
Function used to reserve a DOI after dataset has been published | def reserve_dataset_doi(dataset): # sourcery skip: extract-method
token = get_access_token()
dataset_id = get_dataset_id(token, dataset)
try:
doi_request = requests.post(f"{PENNSIEVE_URL}/datasets/{dataset_id}/doi", headers=create_request_headers(token))
doi_request.raise_for_status()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reserve(data, username=None, password=None):\n if ('title' not in data):\n data['title'] = \"Placeholder Dataset Title\"\n \n data['set_reserved'] = \"true\"\n\n return post(data, username, password);",
"def validate_reserve_request(self, doi: Doi):\n # For reserve requests, need to... | [
"0.59242475",
"0.5578877",
"0.5491279",
"0.524461",
"0.52130175",
"0.51404834",
"0.51114863",
"0.50984216",
"0.4974547",
"0.4921261",
"0.49002188",
"0.48252124",
"0.47844732",
"0.46826923",
"0.46466",
"0.46241626",
"0.4610343",
"0.45774886",
"0.45592102",
"0.4557711",
"0.4520... | 0.7368957 | 0 |
Function used to get the DOI of a dataset | def get_dataset_doi(dataset):
token = get_access_token()
dataset_id = get_dataset_id(token, dataset)
try:
doi_request = requests.get(f"{PENNSIEVE_URL}/datasets/{dataset_id}/doi", headers=create_request_headers(token))
if doi_request.status_code == 404:
return {"doi": "No DOI fou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doi(self):\n return LiteratureReader(self.record).doi",
"def get_doi(self):\n\n return self._dois",
"def reserve_dataset_doi(dataset): # sourcery skip: extract-method\n token = get_access_token()\n\n dataset_id = get_dataset_id(token, dataset)\n\n try:\n doi_request = request... | [
"0.73552567",
"0.69396996",
"0.6604417",
"0.6594884",
"0.65387887",
"0.6488872",
"0.61606026",
"0.6082726",
"0.6056956",
"0.60264283",
"0.6021914",
"0.5995704",
"0.59292525",
"0.58887255",
"0.5885538",
"0.588378",
"0.58447045",
"0.5810868",
"0.5791774",
"0.5773025",
"0.574856... | 0.7856116 | 0 |
Function used to get the package type counts of a dataset (package type counts are the amount of files in a dataset) | def get_package_type_counts(dataset_name):
token = get_access_token()
dataset_id = get_dataset_id(token, dataset_name)
r = requests.get(f"https://api.pennsieve.io/datasets/{dataset_id}/packageTypeCounts", headers=create_request_headers(token))
r.raise_for_status()
return r.json() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type_count():\n types = []\n for typ in Statistics.all_type():\n types.append({'label': typ.lower(), 'y': Statistics.type_count(typ)})\n fix_types = []\n for i in sorted(types, key=lambda k: k['y']):\n if i['y'] != 0:\n fix_types.append(i)\n return jsonify(result=fix_typ... | [
"0.6786938",
"0.65611976",
"0.6389435",
"0.6316701",
"0.6281419",
"0.61885256",
"0.61607045",
"0.6066565",
"0.5876612",
"0.5859251",
"0.58299094",
"0.5825858",
"0.5816752",
"0.5814178",
"0.5801793",
"0.5720606",
"0.5711719",
"0.57059246",
"0.5703063",
"0.5701574",
"0.5687642"... | 0.8252644 | 0 |
Function used to get the total amount of items in a local dataset | def get_total_items_in_local_dataset(dataset_path):
# count the amount of items in folder
create_soda_json_total_items = 0
for _, dirs, filenames in walk(dataset_path):
# walk through all folders and it's subfolders
for Dir in dirs:
if Dir[:1] != ".":
create_soda_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_total_item_size(dataset):\n total_items = 0\n for element in dataset:\n total_items += 1\n return total_items",
"def num_items(self):\n num_items = 0\n for line in self.lines.all():\n num_items += line.quantity\n return num_items",
"def get_amount_of_data... | [
"0.82085365",
"0.7008908",
"0.692242",
"0.6887295",
"0.683338",
"0.682697",
"0.6759568",
"0.6724773",
"0.66621304",
"0.66553134",
"0.6585481",
"0.6580973",
"0.6579759",
"0.65685064",
"0.6559302",
"0.6551821",
"0.6536312",
"0.65262175",
"0.64940095",
"0.6489141",
"0.6472651",
... | 0.76697767 | 1 |
This function plots the average pdr for all links that have been made between mprs and their selectors in comparison to the average mpr achieved by all links. | def plot_mpr_pdr(options, tags=None, cursor=None):
options['prefix'] = "mpr"
if options['grayscale']:
colors = options['graycm'](range(1, 10, 1))
else:
colors = options['color'](range(1, 10, 1))
fig_1 = MyFig(options, xlabel='MPR vs NOMPR',
ylabel='Fraction of MPRs', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_alleles(folder):\n\n abs_alt,perc_alt = parse_geno_file(folder,False)\n\n strain_matcher = re.compile('(.*) \\(.*\\)') ## regex to get strain name from radio button click\n strain_matcher2 = re.compile('(.*)-(.*)')\n \n fig, ax = plt.subplots()\n l, = plt.plot(perc_alt['MC'],perc_alt[S]... | [
"0.5947055",
"0.565502",
"0.5634731",
"0.5589524",
"0.5552843",
"0.5448533",
"0.5419134",
"0.5415741",
"0.5377791",
"0.537186",
"0.5365952",
"0.53624487",
"0.5358062",
"0.53406537",
"0.5335902",
"0.53238994",
"0.5316676",
"0.527764",
"0.5254815",
"0.5252962",
"0.5220736",
"... | 0.64014286 | 0 |
Compare games using condorcet method with an IRV tiebreaker as described in | def main():
# Ask for games to compare.
games = {}
more_games = True
while more_games:
search = input("Enter board game to search (leave empty if finished):")
if search:
matches = bgg_compare.find_game(search)
print("Games found:")
for game_id, nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_game_diff(self):\n pass",
"def run_game(self, p1, p2):\n could_win = [True, True] # can each player win?\n data = {k:[0.0] for k in self.col_names}\n for rnd in range(self.num_rounds):\n before = data.copy()\n p1_row = Game.timeout(p1.take_turn, (da... | [
"0.6005742",
"0.59954774",
"0.59342337",
"0.587341",
"0.58180124",
"0.578757",
"0.5772562",
"0.5770795",
"0.5739876",
"0.5734094",
"0.570773",
"0.56915385",
"0.5675364",
"0.56607246",
"0.564684",
"0.56458324",
"0.56356925",
"0.56085837",
"0.56085837",
"0.56085837",
"0.5608086... | 0.6258148 | 0 |
Test attitude number of terms. | def test_do_check_number_of_terms(self):
self.assertTrue(self.a.do_check_number_of_terms(self.b))
self.assertFalse(self.a.do_check_number_of_terms(self.c)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_accept_all_terms_required(api, account, given_terms):\n api.terms.get_required_terms.return_value = given_terms\n api.terms.accept_terms.reset_mock()\n account.accept_all_terms()\n api.terms.get_required_terms.assert_called()\n api.terms.get_all_terms.assert_not_called()\n\n call_count =... | [
"0.6470264",
"0.6318675",
"0.63101614",
"0.6190968",
"0.61544645",
"0.6016552",
"0.6015099",
"0.59678173",
"0.5954766",
"0.59345716",
"0.5920591",
"0.5908663",
"0.583445",
"0.5823644",
"0.5756424",
"0.5756301",
"0.57550937",
"0.57524925",
"0.57524925",
"0.5738494",
"0.5693518... | 0.6436111 | 1 |
kafka_setup func to setup up message broker for receives data | def kafka_setup(self):
# To consume latest messages and auto-commit offsets
consumer = KafkaConsumer('test-topic',
group_id='test-consumer',
bootstrap_servers=['kafka:9092'])
filename = "/home/debianml/idsFinal/modelo_ultimo_newf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _setup_consumer(self):\n # <WTF> https://github.com/dpkp/kafka-python/issues/601\n self.available_topics = self.client.topics()\n # </WTF>\n\n # might as well use it\n assert self.topic in self.available_topics\n\n if (self.start_params is None) != (self.end_params is ... | [
"0.6801679",
"0.6592574",
"0.65399915",
"0.65337545",
"0.6365531",
"0.63224477",
"0.62041605",
"0.61487556",
"0.61458737",
"0.6136074",
"0.6121307",
"0.6083639",
"0.6043062",
"0.59761024",
"0.59408796",
"0.5938708",
"0.59242535",
"0.58910453",
"0.5855709",
"0.58185035",
"0.58... | 0.7172763 | 0 |
to get disabled layers | def disabled(self):
return QgsProject.instance().readListEntry("Identify", "disabledLayers", "None")[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disableWithLayer( self ):\n return self._disableWithLayer",
"def _get_layers(self) :\n \n return self._layers",
"def select_layers(m, enable, disable):\n for l in m.layers:\n if l.name in enable:\n l.active = True\n if l.name in disable:\n l.activ... | [
"0.7022948",
"0.6894045",
"0.6790678",
"0.66564274",
"0.65293574",
"0.63721687",
"0.6371687",
"0.6341439",
"0.6318801",
"0.6304207",
"0.62541646",
"0.6240074",
"0.62274855",
"0.60787314",
"0.6040702",
"0.6021405",
"0.6005849",
"0.5998175",
"0.59930855",
"0.59706104",
"0.59512... | 0.7499197 | 0 |
To select objects in multiples layers inside a selection rectangle | def __select(self):
searchRect = QgsRectangle(self.first, self.last)
for layer in self.canvas().layers():
if not self.identified or layer.id() not in self.disabled():
if layer.type() == QgsMapLayer.VectorLayer and layer.geometryType() in self.types:
render... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_selection():\n\n selected = Gui.Selection.getSelectionEx()[0].SubObjects\n sel_len = len(selected)\n result = SelectionContainer()\n\n for _x in range(0, sel_len):\n\n shape_type = selected[_x].ShapeType\n\n if shape_type == 'Vertex':\n result.vertices.append(selected[_... | [
"0.6547677",
"0.6489428",
"0.64489985",
"0.64326656",
"0.61144257",
"0.6088905",
"0.6056797",
"0.59542894",
"0.58783185",
"0.5870195",
"0.58497286",
"0.58141154",
"0.58024627",
"0.57950264",
"0.5791926",
"0.57665914",
"0.5747095",
"0.574411",
"0.5722913",
"0.5712149",
"0.5685... | 0.7188011 | 0 |
PAM pulse p(t) = p(nTB/sps) generation >>>>> pt = pampt(sps, ptype, pparms) <<<<< | def pampt(sps, ptype, pparms=[], plot='', duty=1):
if ptype is 'rect':
pt = np.ones(sps)
elif ptype is 'tri':
triarray = np.arange(0,1,(1/float(sps)))[1:]
pt = np.concatenate([triarray,[1],triarray[::-1]])
elif ptype is 'sinc':
k = pparms[0]
beta = pparms[1]
n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pamhRt(sps, ptype, pparms=[]):\n pt = pampt(int(sps), ptype, pparms)\n hrt = multiply(pt,1/float(np.sum(np.power(pt,2))))\n hrt = hrt[::-1]\n return hrt",
"def mm_to_ps(delays_in_mm, stage_passes):\n ps_delays = (delays_in_mm * stage_passes)/0.2998 \n return ps_delays",
"def visit_pulseex... | [
"0.760947",
"0.58867526",
"0.5878893",
"0.5691023",
"0.5643341",
"0.55759794",
"0.55489904",
"0.5497658",
"0.54927593",
"0.5408664",
"0.5408037",
"0.53972983",
"0.5372686",
"0.5352186",
"0.53408444",
"0.53182334",
"0.5312574",
"0.53088474",
"0.52938807",
"0.52895635",
"0.5289... | 0.7628801 | 0 |
PAM normalized matched filter (MF) receiver filter h_R(t) = h_R(nTB/sps) generation >>>>> hRt = pamhRt(sps, ptype, pparms) <<<<< | def pamhRt(sps, ptype, pparms=[]):
pt = pampt(int(sps), ptype, pparms)
hrt = multiply(pt,1/float(np.sum(np.power(pt,2))))
hrt = hrt[::-1]
return hrt | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prep(self):\n print\n print 'Filtering rawdata to data as masked array...'\n# using 0 as flag\n# self.data = n.ma.masked_array(self.rawdata[:self.nints,:, self.chans,:], self.rawdata[:self.nints,:, self.chans,:] == 0j)\n# using standard flags\n self.data = n.ma.masked_array(self.raw... | [
"0.54264504",
"0.5125475",
"0.50817657",
"0.50474656",
"0.5031233",
"0.5001261",
"0.49961358",
"0.49815556",
"0.49378115",
"0.4911355",
"0.48580718",
"0.48568124",
"0.48549768",
"0.48305887",
"0.48229444",
"0.4798316",
"0.4784546",
"0.4771352",
"0.47691798",
"0.47686964",
"0.... | 0.71751475 | 0 |
Review the state of the current main spreadsheet, create it if required (by merging the previous main + checklist) or by copying the previous main spreadsheet if the previous checklist is missing. This will determine which initial window will be shown | def spreadsheet_file_setup(self, current_date: MyDate, previous_date: MyDate) -> Tuple[str, str, str]:
if not os.path.exists(self.spreadsheet_directory):
os.makedirs(self.spreadsheet_directory)
current_date_str = current_date.strdate
previous_date_str = previous_date.strdate
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync_spreadsheet(self):\n\n\t\t# Open up the main sheet\n\n\t\t# Glob in columns to let us figure out which row each parent is in\n\n\t\t# For each parent\n\n\t\t\t# If any of the 'I fill out' entries are None (besides 'notes')\n\n\t\t\t\t# Get the row values and see if I updated any of them\n\n\t\t\t\t# If I ... | [
"0.5732371",
"0.53364146",
"0.53332794",
"0.5322917",
"0.51630425",
"0.5141455",
"0.5138451",
"0.51265264",
"0.5100866",
"0.50261587",
"0.5012249",
"0.5010007",
"0.49848384",
"0.49694338",
"0.4965991",
"0.496513",
"0.4948898",
"0.4944994",
"0.4921458",
"0.49152672",
"0.491382... | 0.5897153 | 0 |
Solve the people selection for every natural budget B in the range [Bmin, Bmax] Gather a solution to each such B under self.solution_dictionary[B]. | def solve(self, Bmin=2, Bmax=6, integer_programming=False,
normalized_coverage=True, secondary_objective_coefficient=0.01, risk_manager=None) -> Tuple[bool, str]:
if self.state == "Initial_main_spreadsheet_loaded":
self.solutions_dictionary = {}
self.fig_output_dir = os.pat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_choose_candidate_solve (x_v, C, A, S, budgets, start_time, verbose=True):\n A = A.copy()\n edges_removed = []\n budget = np.max(budgets)\n results_info = []\n for i in range(budget):\n if (len(C) == 0):\n # Maximum balance achieved -> budget high.\n results_in... | [
"0.6185025",
"0.59405524",
"0.5894277",
"0.5769825",
"0.57343185",
"0.57234454",
"0.5569516",
"0.55680245",
"0.5528746",
"0.5513123",
"0.55121934",
"0.5510101",
"0.55031",
"0.5490586",
"0.54869777",
"0.54784375",
"0.54608595",
"0.54383326",
"0.54235995",
"0.5405957",
"0.53893... | 0.7298354 | 0 |
Analyse the AST built from `str_definition`. | def _analyse_ast(str_code: str) -> Tuple[bool, Set[str]]:
node = ast.parse(str_code)
visitor = VarCounterVisitor()
visitor.visit(node)
return visitor.has_return, visitor.get_vars() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(self, definition):\n comment_re = re.compile(r\"(#.*)\")\n state_re = re.compile(r\"^([a-zA-Z_][a-zA-Z0-9_]*)([.*])?$\")\n transition_re = re.compile(\n r\"^'(.)'\\s+'(.)'\\s+([<>])\\s+([a-zA-Z_][a-zA-Z0-9_]*)$\"\n )\n\n lines = list(\n filter(\n ... | [
"0.5804697",
"0.54685974",
"0.54609656",
"0.5377099",
"0.5368216",
"0.53238297",
"0.52445525",
"0.52434343",
"0.52340716",
"0.5203703",
"0.51806396",
"0.5177865",
"0.51605487",
"0.51293385",
"0.51269925",
"0.5102782",
"0.50988954",
"0.50564325",
"0.5037128",
"0.50355864",
"0.... | 0.55397505 | 1 |
Method for distinguishing among statements and executing appropriate compilation methods | def compile_statements(self):
if self.tokenizer.get_token() == 'do':
self.compile_do()
elif self.tokenizer.get_token() == 'let':
self.compile_let()
elif self.tokenizer.get_token() == 'while':
self.compile_while()
elif self.tokenizer.get_token() == 'return':
self.compile_return()
elif self.tokeni... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile_statements(self):\r\n while self.__tokenizer.token_type() == TYPES_DIC[\"KEYWORD\"]:\r\n if self.__tokenizer.keyword() == TYPES_DIC[\"LET\"]:\r\n self.compile_let()\r\n elif self.__tokenizer.keyword() == TYPES_DIC[\"DO\"]:\r\n self.compile_do()... | [
"0.6922679",
"0.68892235",
"0.6818094",
"0.65094197",
"0.63267976",
"0.61395943",
"0.5988998",
"0.5987703",
"0.59598833",
"0.5933996",
"0.5909652",
"0.5894095",
"0.5861663",
"0.579982",
"0.57987",
"0.57934976",
"0.57888937",
"0.57770365",
"0.57601076",
"0.57009965",
"0.569212... | 0.7621141 | 0 |
Method for compiling return statements | def compile_return(self):
xml = '<returnStatement>\n' + self.tokenizer.keyword()
self.outfile.write(xml)
if self.tokenizer.get_token() != ';':
self.compile_expression()
xml = self.tokenizer.symbol() + '</returnStatement>\n'
self.outfile.write(xml) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile_return(self) -> None:\n self._consume('return')\n if self._get_current_token() != ';':\n self.compile_expression()\n else:\n self.writer.write_push('CONST', 0)\n self.writer.write_return()\n self._consume(';')",
"def compile_return(self):\r\n ... | [
"0.77394056",
"0.74051446",
"0.7263994",
"0.6973101",
"0.69503146",
"0.66593987",
"0.6618876",
"0.64668745",
"0.63659763",
"0.63589627",
"0.6339866",
"0.630496",
"0.62770593",
"0.61640376",
"0.60698193",
"0.6051587",
"0.6013866",
"0.5988043",
"0.59227455",
"0.58733314",
"0.58... | 0.7865864 | 0 |
Method for compiling terms. | def compile_term(self):
self.outfile.write('<term>\n')
count = 0
while(self.tokenizer.get_token() not in [')',']',';',',', '/', '|', '<', '>', '=', '*', '+', '&']):
if self.tokenizer.get_token().isdigit():
self.outfile.write(self.tokenizer.int_value())
elif '"' in self.tokenizer.get_token():
self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile_term(self) -> None:\n token_type = self.tokenizer.token_type()\n\n if token_type == TokenTypes.IDENTIFIER:\n curr_token = self._get_current_token()\n self.tokenizer.advance()\n if self._get_current_token() in ('(', '.'):\n self.compile_subro... | [
"0.6797548",
"0.6408566",
"0.6043867",
"0.58825356",
"0.58099383",
"0.580154",
"0.5744342",
"0.5740527",
"0.5670405",
"0.5630286",
"0.56288904",
"0.56277066",
"0.56176656",
"0.5616536",
"0.55326056",
"0.551408",
"0.55036604",
"0.5495442",
"0.5486665",
"0.5447361",
"0.5447361"... | 0.65248525 | 1 |
Method for compiling expression list | def compile_expression_list(self):
self.compile_expression()
while(self.tokenizer.get_token() == ','):
self.outfile.write(self.tokenizer.symbol())
self.compile_expression() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile(expression):",
"def compile_expressions(self):\n if getattr(self, \"_attrs\", None):\n for k, v in self._attrs.items():\n try:\n Expression.compile_cache(v)\n except:\n pass\n if \"${\" in v and \"}\"... | [
"0.7303742",
"0.6899812",
"0.676477",
"0.6764549",
"0.6595679",
"0.6594294",
"0.6505174",
"0.6433924",
"0.6407704",
"0.63050604",
"0.62129176",
"0.61291176",
"0.6054552",
"0.6029492",
"0.5955361",
"0.59018266",
"0.58894014",
"0.5862463",
"0.5834631",
"0.58301324",
"0.5783622"... | 0.77256614 | 0 |
Get ref_dict and original xml. Return modified xml. | def changeXML(request):
if request.is_ajax():
mod_xml = change_XML(request.POST.get("origXML", None), request.POST.get("refDict", None))
return HttpResponse(mod_xml) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def translate_xml(self):\n self._from_origin_to_dict()\n self._from_dict_to_destination()\n return self",
"def get_prep_tags(src_xml, d1):\n root, tree = gen_tree(src_xml)\n d2 = OrderedDict()\n # list of old rIds\n rId_lis = [i for i in d1.keys()]\n nmsps = root.nsmap['r']\n... | [
"0.5992099",
"0.59686065",
"0.5740401",
"0.5733478",
"0.5554997",
"0.5549551",
"0.53976065",
"0.53976065",
"0.5374542",
"0.5363357",
"0.5337076",
"0.53112733",
"0.5307064",
"0.52926534",
"0.5246573",
"0.52317154",
"0.5196472",
"0.51863503",
"0.51779026",
"0.51708364",
"0.5138... | 0.6100053 | 0 |
Plot the boundary of the decision function of a classifier. | def plot_decision_function(fitted_classifier, range_features, ax=None):
from sklearn.preprocessing import LabelEncoder
feature_names = list(range_features.keys())
# create a grid to evaluate all possible samples
plot_step = 0.02
xx, yy = np.meshgrid(
np.arange(*range_features[feature_names[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_decision_boundary(pred_func):\n # Set min and max values\n x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5\n y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5\n h = 0.01\n # Generate a grid of points\n xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))... | [
"0.78084874",
"0.7255437",
"0.71386033",
"0.7092351",
"0.7068796",
"0.70634454",
"0.69989425",
"0.6928147",
"0.69253993",
"0.6838848",
"0.67972547",
"0.67400056",
"0.67281514",
"0.6592813",
"0.6581072",
"0.649618",
"0.64668304",
"0.6430339",
"0.6427567",
"0.6402144",
"0.63229... | 0.7528398 | 1 |
No args, returns public IP as string. | def get_public_ip():
public_ip = get('https://api.ipify.org').text
return public_ip | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obtain_public_ip():\n from urllib2 import urlopen\n my_ip = urlopen('http://ip.42.pl/raw').read()\n logger.debug('The public ip is: %s' % my_ip)\n return str(my_ip)",
"def public_ip_address(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"public_ip_address\")",
"def __lookup_publ... | [
"0.83127135",
"0.80796",
"0.7783871",
"0.76831925",
"0.7600024",
"0.75949574",
"0.75438094",
"0.75281465",
"0.7523305",
"0.7467583",
"0.74656445",
"0.74131584",
"0.73996073",
"0.73036295",
"0.72666174",
"0.7263097",
"0.7261891",
"0.7193733",
"0.71464616",
"0.7134698",
"0.7117... | 0.8456587 | 0 |
Given an Observable, return the hexdigest of the MD5 computation used for hal9000. | def _compute_hal9000_md5(observable: Observable) -> str:
md5_hasher = md5()
md5_hasher.update(observable.type.encode('utf-8', errors='ignore'))
md5_hasher.update(observable.value.encode('utf-8', errors='ignore'))
return md5_hasher.hexdigest() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MD5(self) -> _n_0_t_3[_n_0_t_9]:",
"def md5hash(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"md5hash\")",
"def hex_digest(x):\r\n\r\n global hashlib\r\n if hashlib is None:\r\n try:\r\n import hashlib\r\n except ImportError:\r\n raise RuntimeErro... | [
"0.7017166",
"0.68753433",
"0.6857451",
"0.6643236",
"0.6606516",
"0.65155923",
"0.65101314",
"0.6490241",
"0.6467206",
"0.64201826",
"0.6401238",
"0.6400731",
"0.632309",
"0.6251294",
"0.6243819",
"0.6233169",
"0.62189025",
"0.62096703",
"0.6203974",
"0.61911243",
"0.617401"... | 0.82838666 | 0 |
Returns an observable sequence that stays connected to the source indefinitely to the observable sequence. Providing a subscriber_count will cause it to connect() after that many subscriptions occur. A subscriber_count of 0 will result in emissions firing immediately without waiting for subscribers. | def auto_connect(self, subscriber_count: int = 1) -> Observable[_T]:
connectable_subscription: List[Optional[abc.DisposableBase]] = [None]
count = [0]
source = self
is_connected = [False]
if subscriber_count == 0:
connectable_subscription[0] = source.connect()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rx_publish(\n an_observable: Observable,\n subject_handler: Optional[SubjectHandler] = None,\n connection_handler: Optional[ConnectableObservableHandler] = None,\n subject_factory: SubjectFactory = rx_subject,\n) -> ConnectableObservable:\n _ref_count_activated = False # Flag to enable auto-con... | [
"0.5828235",
"0.56218654",
"0.54947263",
"0.53222233",
"0.5296239",
"0.52916276",
"0.524747",
"0.52000093",
"0.51686496",
"0.51450634",
"0.5046524",
"0.4932304",
"0.48687896",
"0.47747943",
"0.47149625",
"0.46692255",
"0.4658458",
"0.45011935",
"0.44860765",
"0.44434935",
"0.... | 0.78981453 | 0 |
Return page title and description from the global variable pages if a match with current node page.src_pathname is found. | def get_page_contents(node):
try:
return (SITE_NAME + ' | ' + PAGES[node.page.src_pathname][0], \
PAGES[node.page.src_pathname][1])
except KeyError:
return ('%%%TITLE%%%', '') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_page_name(self,en_code):\n files_and_names = {}\n for files_named in self.find_enc(en_code):\n search_in_file = open(self.file_location+\"/\"+files_named)\n for line in search_in_file:\n if '# LINKNAME:' in line:\n #print(line)\n ... | [
"0.5581692",
"0.5453277",
"0.5358435",
"0.5314624",
"0.5253254",
"0.52273643",
"0.51900214",
"0.51895034",
"0.5117078",
"0.5105263",
"0.5065553",
"0.49728322",
"0.4916901",
"0.49029452",
"0.48753327",
"0.4870343",
"0.48675117",
"0.4849708",
"0.4846126",
"0.48419836",
"0.48398... | 0.637792 | 0 |
Check if `df` is already loaded in, if not, load from file. | def _check_df_load(df):
if isinstance(df, str):
if df.lower().endswith('json'):
return _check_gdf_load(df)
else:
return pd.read_csv(df)
elif isinstance(df, pd.DataFrame):
return df
else:
raise ValueError(f"{df} is not an accepted DataFrame format.") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(self, filename: str) -> None:\n if os.path.exists(filename):\n self.df = pd.read_csv(filename)\n logging.info(f\"Data loaded from {filename}\")\n else:\n raise FileNotFoundError(f\"{filename} does not exist.\")",
"async def reload():\n global DF\n ... | [
"0.6277648",
"0.6191782",
"0.61039275",
"0.6056933",
"0.6031007",
"0.5953166",
"0.59385717",
"0.59070724",
"0.58768165",
"0.5739335",
"0.5734155",
"0.57321936",
"0.5702543",
"0.5688365",
"0.5682212",
"0.5661225",
"0.5649886",
"0.56405413",
"0.563232",
"0.56136",
"0.5611218",
... | 0.71676666 | 0 |
Check whether or not a transformation should be performed. | def _check_do_transform(df, reference_im, affine_obj):
try:
crs = getattr(df, 'crs')
except AttributeError:
return False # if it doesn't have a CRS attribute
if not crs:
return False # return False for do_transform if crs is falsey
elif crs and (reference_im is not None or aff... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_retransform(self):\r\n return self._can_retransform",
"def _is_transformable(self):\n if not self._app.get_paths():\n raise NotTransformable(\"No image to\")\n elif not edit_supported(self._app.get_path()):\n raise NotTransformable(\"Filetype not supported for\")\n ... | [
"0.7249936",
"0.6998299",
"0.66887665",
"0.66887116",
"0.66887116",
"0.63980013",
"0.63311636",
"0.63046885",
"0.6275514",
"0.6219605",
"0.6021119",
"0.59835887",
"0.596009",
"0.59206647",
"0.591317",
"0.5904577",
"0.58614516",
"0.5852779",
"0.57798934",
"0.5726429",
"0.57246... | 0.73821825 | 1 |
Check if a geometry is loaded in. Returns the geometry if it's a shapely geometry object. If it's a wkt string or a list of coordinates, convert to a shapely geometry. | def _check_geom(geom):
if isinstance(geom, BaseGeometry):
return geom
elif isinstance(geom, str): # assume it's a wkt
return loads(geom)
elif isinstance(geom, list) and len(geom) == 2: # coordinates
return Point(geom) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getGeometry(self, geom):\n if \"POLYGON\" in self.geometryType:\n rings = geom['rings']\n polygon = getMultiGeometry(rings)\n polyGeom = arcpy.Polygon(polygon, self.sr)\n return polyGeom\n elif \"POLYLINE\" in self.geometryType:\n paths = g... | [
"0.6801356",
"0.65980977",
"0.6589894",
"0.63210255",
"0.61391467",
"0.60185724",
"0.58834255",
"0.58313197",
"0.58018106",
"0.5799447",
"0.5770487",
"0.57421964",
"0.57199174",
"0.5673253",
"0.56658554",
"0.5628066",
"0.55974066",
"0.5594967",
"0.5591497",
"0.55895776",
"0.5... | 0.7502172 | 0 |
Check if `im` is already loaded in; if not, load it in. | def _check_skimage_im_load(im):
if isinstance(im, str):
return skimage.io.imread(im)
elif isinstance(im, np.ndarray):
return im
else:
raise ValueError(
"{} is not an accepted image format for scikit-image.".format(im)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_from_images(self):\n logging.debug(\"load_from_images called\")\n return True",
"def checkForImage(self, PATH=\"./Input/\"):\n files = [ _ for _ in sorted(os.listdir(PATH)) if \".png\" in _ and \"Image\" in _ ]\n if len(files) > 0:\n f = files[0]\n im = ... | [
"0.6499908",
"0.6096371",
"0.6067545",
"0.6033128",
"0.5957636",
"0.5905161",
"0.5901737",
"0.58247775",
"0.58093244",
"0.5752622",
"0.5741115",
"0.5704073",
"0.5698754",
"0.56524754",
"0.56310904",
"0.5626889",
"0.55896306",
"0.5551396",
"0.55398846",
"0.5534099",
"0.5515276... | 0.62191695 | 1 |
Converts data to a numpy array of dtype ``theano.config.floatX``. | def floatX(arr):
return np.asarray(arr, dtype=theano.config.floatX) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_data(self, data):\n return array(data, dtype=float32)",
"def _to_numpy_ndarray(cls, data):\n if isinstance(data, np.ndarray):\n return data\n arr = np.array(data, dtype=np.float)\n if len(arr.shape) == 1:\n arr = np.reshape(arr, newshape=(1, arr.shape[0]... | [
"0.6914697",
"0.66941285",
"0.6257841",
"0.6220697",
"0.6082377",
"0.6058563",
"0.60510707",
"0.59450364",
"0.59197205",
"0.5905",
"0.59049326",
"0.58883035",
"0.58737826",
"0.586",
"0.5842861",
"0.58201295",
"0.58104676",
"0.58054763",
"0.56974417",
"0.5684491",
"0.56502676"... | 0.7794205 | 0 |
This tries to complete lcdict column keys. | def completer_func_cols(text, state):
return [x for x in lc_keys if x.startswith(text)][state] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def customize_dict_keys(x, col, keys):\n new_keys = [key + '_' + col for key in keys]\n new_dict = dict(zip(new_keys, list(x.values())))\n return new_dict",
"def initalise_column_lengths(coldata):\n for key, _ in coldata.items():\n coldata[key]['collen'] = len(coldata[key]['head'])\n return... | [
"0.58676094",
"0.58175683",
"0.5693576",
"0.56674314",
"0.5646315",
"0.5580921",
"0.5565844",
"0.5544771",
"0.55172974",
"0.55011266",
"0.5470133",
"0.5437494",
"0.542268",
"0.5406469",
"0.5328236",
"0.5306072",
"0.53009397",
"0.5254619",
"0.52482355",
"0.52427024",
"0.522550... | 0.6004714 | 0 |
Run the 'exp_by_states' function | def test_exp_by_states(self):
api = my_mock.api_mock({"items": [{'state': 'Waiting', 'id': 10134},
{'state': 'Waiting', 'id': 10135},
{'state': 'Running', 'id': 10130}]})
states_d = helpers.exps_by_states_dict(api, helpe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eval_exp_table(self):\n\n maximum = max(self.exp_states, key=self.exp_states.get)\n minimum = min(self.exp_states, key=self.exp_states.get)\n print(maximum, self.exp_states[maximum])\n print(minimum, self.exp_states[minimum])",
"def explore_act(self, states_ns):\n raise Not... | [
"0.63333124",
"0.6201458",
"0.598863",
"0.5944459",
"0.5876799",
"0.5797775",
"0.5792334",
"0.57780284",
"0.56897247",
"0.5675811",
"0.56502956",
"0.5636345",
"0.56308776",
"0.5617289",
"0.55571985",
"0.5549741",
"0.5549618",
"0.5546261",
"0.5511726",
"0.55096716",
"0.5502994... | 0.69073737 | 0 |
Returns a response with a template depending if the request is ajax or not and it renders with the given context. | def render_to_response(self, context, **response_kwargs):
if self.request.is_ajax():
template = self.page_template
else:
template = self.get_template_names()
return self.response_class(
request=self.request,
template=template,
context=c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_to_response(self, context, **response_kwargs):\n if self.request.is_ajax():\n data = {\n \"content\": render_to_string(\n self.get_template_names(), context, request=self.request)\n }\n return JsonResponse(data)\n if settin... | [
"0.7809597",
"0.7377398",
"0.7010131",
"0.6987082",
"0.69166535",
"0.68252474",
"0.6771008",
"0.65937597",
"0.6588166",
"0.65728974",
"0.6566237",
"0.64738065",
"0.63902193",
"0.63787663",
"0.6283311",
"0.6262474",
"0.61762077",
"0.61464626",
"0.61354387",
"0.6133349",
"0.613... | 0.7889873 | 0 |
Runs an ASA calculation. This function takes a selection of atoms (in the most common case all atoms in a structure) and lattice coordinates (in the most common a 3x3 box of unitcells). This function should be considered lowlevel and not part of the interface. | def _run_asa(atoms, lattice_coords, spoints, probe=1.4, bucket_size=5, \
MAXSYM=200000):
# get array of radii inflated by probe size of the selection of atoms.
atom_radii = array(atoms.getData('radius', forgiving=False)) + probe
# get array of coordinates
atom_coords = array(atoms.getData('... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calcASA(atoms, probe=1.4, n_sphere_point=960):\r\n atoms.setRadii(getAtomRadii(atoms))\r\n\r\n sphere_points = generate_sphere_points(n_sphere_point)\r\n const = 4.0 * math.pi / len(sphere_points)\r\n\r\n test_point = [0.0, 0.0, 0.0]\r\n areas = []\r\n\r\n coords_all = atoms.getCoords()\r\n\r... | [
"0.6583111",
"0.5863668",
"0.5665775",
"0.5556178",
"0.55475384",
"0.5533965",
"0.546892",
"0.542892",
"0.533817",
"0.5314313",
"0.5283346",
"0.5239428",
"0.52058405",
"0.52058256",
"0.5139876",
"0.5137725",
"0.510819",
"0.50953245",
"0.50585145",
"0.4984134",
"0.49810362",
... | 0.76762646 | 0 |
Prepares input entities for ASA calculation, which includes masking water molecules and water chains. | def _prepare_entities(entities):
# First we mask all water residues and chains with all residues masked
# (water chains).
lattice_residues = einput(entities, 'R')
lattice_residues.maskChildren('H_HOH', 'eq', 'name')
lattice_chains = einput(entities, 'C')
lattice_chains.maskChildren([], 'eq', 'v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _prepare_asa(entities, symmetry_mode=None, crystal_mode=None, points=960, \\\n **kwargs):\n # generate uniform points on the unit-sphere\n spoints = sphere_points(points)\n # prepare entities for asa calculation\n # free-floating area mode\n result = {}\n atoms = einput(entitie... | [
"0.6200153",
"0.57410395",
"0.5616965",
"0.555657",
"0.55119246",
"0.54899794",
"0.54524016",
"0.5420377",
"0.54129404",
"0.5361355",
"0.5250238",
"0.521313",
"0.5201811",
"0.51699144",
"0.51465464",
"0.51431507",
"0.5114623",
"0.5108252",
"0.5087482",
"0.5057189",
"0.505701"... | 0.6730421 | 0 |
Escapes all the elements of the array | def escaped(array):
return list(map(re.escape, array)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _escape(strings):\n ret = []\n for string in strings:\n if string == '[' or string == ']' or string == \"\\\"\":\n string = '\\\\' + string\n ret.append(string)\n return \"\".join(ret)",
"def escape(text):\n if isinstance(text, list):\n for i, t in enumerate(text):... | [
"0.61737067",
"0.60916007",
"0.5786192",
"0.57429165",
"0.56900054",
"0.5645866",
"0.5611427",
"0.55317134",
"0.55243725",
"0.5488824",
"0.547087",
"0.54102594",
"0.5405861",
"0.5405861",
"0.5405861",
"0.5397523",
"0.53616697",
"0.5339624",
"0.5324862",
"0.52107453",
"0.52002... | 0.8006267 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.