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 |
|---|---|---|---|---|---|---|
My delimited list. Allows for length zero list and uses no delimiter by default. | def List(expr, delim=""):
if not delim:
return Group(ZeroOrMore(expr))
else:
return Group(Optional(expr + ZeroOrMore( Suppress(delim) + expr))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenlist(sep, item):\n return item + ZeroOrMore(sep + item) + Optional(sep)",
"def listify(item, delimiter=\",\"):\n if not item:\n return []\n if type(item) is str:\n item = item.split(delimiter)\n if type(item) is not list:\n raise TypeError(\"'listify' must take None, str... | [
"0.7051483",
"0.6357497",
"0.6287068",
"0.62133163",
"0.6168434",
"0.61420405",
"0.6067352",
"0.5842047",
"0.57866776",
"0.5777707",
"0.5761801",
"0.57346326",
"0.5694061",
"0.56513804",
"0.5629008",
"0.56282747",
"0.5587309",
"0.55792344",
"0.5534608",
"0.5531955",
"0.551274... | 0.6472422 | 1 |
Returns True if the user has the specified permission. This method queries all available auth backends, but returns immediately if any backend returns True. Thus, a user who has permission from a single auth backend is assumed to have permission in general. If an object is provided, permissions for this specific object... | def has_perm(self, user, perm, obj=None):
# Active superusers have all permissions.
if user.is_active and user.is_superuser:
return True
# Otherwise we need to check the backends.
return _user_has_perm(user, perm, obj) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_perm(self, perm, obj=None):\n\n # Active superusers have all permissions.\n if self.is_active and self.is_superuser:\n return True\n\n # Otherwise we need to check the backends.\n return _user_has_perm(self, perm, obj)",
"def has_perm(self, perm, obj=None):\n\n ... | [
"0.7863119",
"0.7828964",
"0.7681567",
"0.7681567",
"0.7347684",
"0.730742",
"0.7284849",
"0.72575694",
"0.72098434",
"0.7167823",
"0.7167823",
"0.71654195",
"0.7089648",
"0.70708424",
"0.70448405",
"0.7043486",
"0.69482195",
"0.6947326",
"0.69120204",
"0.69032484",
"0.684018... | 0.7860136 | 1 |
Test scenario where branch is deleted by someone. | def test_branch_deleted(local):
pytest.run(local, ['git', 'checkout', 'feature'])
pytest.run(local, ['git', 'push', 'origin', '--delete', 'feature'])
local.join('README').write('Changed by local.')
# Run.
actual = commit_and_push(str(local), 'origin', Versions(REMOTES))
assert actual is True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def branch_delete(request, branch_id):\n branch = models.Branch.get_by_id(int(branch_id))\n if branch.owner != request.user:\n return HttpTextResponse('You do not own this branch', status=403)\n\n repo_key = branch.repo_key\n branch.key.delete()\n num_branches = models.Branch.query(models.Branch.repo_key =... | [
"0.70407706",
"0.6978257",
"0.6950403",
"0.69398266",
"0.69226867",
"0.6910521",
"0.68338317",
"0.6806933",
"0.67489284",
"0.6737305",
"0.67202115",
"0.6653965",
"0.65832716",
"0.65230274",
"0.65227497",
"0.6496914",
"0.64698577",
"0.6468279",
"0.6465555",
"0.64556766",
"0.64... | 0.7768845 | 0 |
Get and validate user input for a bounded number. Loops until true. Uses GLOBAL BOUNDS | def get_number():
valid_input = False
while not valid_input:
try:
user_num = int(input("Enter a number between {} and {}: ".format(LOWER_BOUND, UPPER_BOUND)))
if LOWER_BOUND <= user_num <= UPPER_BOUND:
return user_num
except ValueError:
pass
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def boundary(quantity, lower, upper):\r\n in_range = False\r\n while not in_range:\r\n if quantity < lower or quantity > upper:\r\n quantity = int(input(\"That is out of range, please try a number between \" + \\\r\n str(lower) + \" and \" + str(upper) + \": ... | [
"0.7017077",
"0.6891233",
"0.6279303",
"0.6265519",
"0.6217458",
"0.6194167",
"0.6188855",
"0.6186043",
"0.6179174",
"0.61711013",
"0.6162517",
"0.6142887",
"0.6130406",
"0.61281335",
"0.6114784",
"0.60892946",
"0.60543203",
"0.6048339",
"0.6033415",
"0.6026771",
"0.5994991",... | 0.70898324 | 0 |
Bind to the ``IID_str`` with the given ``version`` | def bind(self, IID_str, version=(1,0)):
IID = windows.com.IID.from_string(IID_str)
request = self._forge_bind_request(IID, version, self.number_of_bind_if)
response = self._send_request(request)
# Parse reponse
request_type = self._get_request_type(response)
if request_ty... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_server_ident(name, version=None):\n global server_ident\n \n server_ident[\"server_name\"] = name\n \n if version != None and len(version) > 0:\n server_ident[\"server_version\"] = str(version)\n version_text = \"/%s\" % server_ident[\"server_version\"]\n else:\n v... | [
"0.5488293",
"0.5464984",
"0.5414237",
"0.5216008",
"0.5216008",
"0.5132779",
"0.5110682",
"0.50267404",
"0.49960196",
"0.49960196",
"0.49735996",
"0.49455595",
"0.4940661",
"0.49362436",
"0.49324334",
"0.49238288",
"0.48973906",
"0.48956478",
"0.48696187",
"0.48696187",
"0.4... | 0.7529546 | 0 |
Craft an ALPC message containing an RPC request to call ``method_offset`` of interface ``IID` with ``params``. Can be used to craft request without directly sending it | def forge_alpc_request(self, IID, method_offset, params, ipid=None):
iid_hash = hash(buffer(IID)[:])
interface_nb = self.if_bind_number[iid_hash] # TODO: add __hash__ to IID
if len(params) > 0x900: # 0x1000 - size of meta-data
request = self._forge_call_request_in_view(interface_nb, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call(self, IID, method_offset, params, ipid=None):\n request = self.forge_alpc_request(IID, method_offset, params, ipid=ipid)\n response = self._send_request(request)\n # Parse reponse\n request_type = self._get_request_type(response)\n if request_type != gdef.RPC_RESPONSE_TY... | [
"0.7709393",
"0.6050143",
"0.5798952",
"0.5638268",
"0.5624949",
"0.55940336",
"0.5567791",
"0.5512863",
"0.5477219",
"0.537469",
"0.5337115",
"0.53062266",
"0.52889895",
"0.5286633",
"0.52851754",
"0.5255648",
"0.5251362",
"0.52488613",
"0.52292114",
"0.5226254",
"0.51244795... | 0.7918275 | 0 |
Call method number ``method_offset`` of interface ``IID`` with mashalled ``params`` | def call(self, IID, method_offset, params, ipid=None):
request = self.forge_alpc_request(IID, method_offset, params, ipid=ipid)
response = self._send_request(request)
# Parse reponse
request_type = self._get_request_type(response)
if request_type != gdef.RPC_RESPONSE_TYPE_SUCCESS... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call(self, method, params, callback=None):\n cur_id = self._next_id()\n if callback:\n self._callbacks[cur_id] = callback\n self.send({'msg': 'method', 'id': cur_id, 'method': method, 'params': params})",
"def call(self, method, params, callback=None):\n cur_id = self._... | [
"0.6457688",
"0.6457688",
"0.63944983",
"0.60446113",
"0.60007215",
"0.5442638",
"0.5425219",
"0.5395106",
"0.53930616",
"0.5373983",
"0.5315418",
"0.5293637",
"0.52931386",
"0.5262458",
"0.5239935",
"0.5228087",
"0.520957",
"0.5179884",
"0.5162715",
"0.5161636",
"0.5153802",... | 0.6616697 | 0 |
return a 2tuple list (idx, run) filter out not incrementables | def compress_runs(runs, incrementable):
return [(i, r) for i, r in enumerate(runs) if r.analysis_type in incrementable] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_idxs(self):\n return list(range(len(self._h5[RUNS])))",
"def runs(lst):\n for j, two in enumerate(lst):\n if j == 0:\n one, i = two, 0\n if one != two:\n yield j - i, one\n i = j\n one = two\n yield j - i + 1, two",
"def run_traj_idxs(s... | [
"0.61934006",
"0.59456134",
"0.5884365",
"0.58346885",
"0.57831305",
"0.57831305",
"0.5749621",
"0.57459706",
"0.568972",
"0.5641108",
"0.56102896",
"0.560884",
"0.5552723",
"0.55208975",
"0.54915106",
"0.54656136",
"0.5431433",
"0.5424431",
"0.54129857",
"0.5407284",
"0.5405... | 0.6838056 | 0 |
Implemented label methods should place labels within a LETTER_HEIGHT x len(label) LETTER_WIDTH region centered at label_x, label_y | def _draw_label(label, label_x, label_y):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_label(self, contig_name, width, height, font, title_width, upper_left, vertical_label,\n strand, canvas, horizontal_centering=False, center_vertical=False, chop_text=True,\n label_color=(50, 50, 50, 255)):\n upper_left = list(upper_left) # to make it mutable\... | [
"0.71363807",
"0.68898165",
"0.6765323",
"0.6661851",
"0.65560156",
"0.6492479",
"0.6486989",
"0.64741296",
"0.644576",
"0.6443592",
"0.6416232",
"0.63992846",
"0.63034606",
"0.62848526",
"0.62837756",
"0.6281372",
"0.6280866",
"0.62708366",
"0.62629914",
"0.6259574",
"0.6256... | 0.7144518 | 0 |
Get the ElasticSearch index or indices to query. By default, we obtain the index from the foreign table options. However, this method can be overridden to derive the index from the query quals. For example, the `timestamp` qual could be used to select one or more timebased indices. | def get_index(self, _quals):
return self._options['index'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_index(self, *args, **dargs):\n pass",
"def get_index(\n self,\n ) -> Callable[[datastore_admin.GetIndexRequest], Awaitable[index.Index]]:\n # Generate a \"stub function\" on-the-fly which will actually make\n # the request.\n # gRPC handles serialization and deserial... | [
"0.62230533",
"0.6008187",
"0.58028996",
"0.57998234",
"0.57949215",
"0.57949215",
"0.57921827",
"0.56789416",
"0.5601105",
"0.5534349",
"0.552037",
"0.5520204",
"0.5516885",
"0.55096304",
"0.55079347",
"0.54522127",
"0.5441961",
"0.5438087",
"0.54296577",
"0.53880614",
"0.53... | 0.68531275 | 0 |
Converts a CoreBluetooth UUID to a Python string. If ``_uuid`` is a 16bit UUID, it is assumed to be a Bluetooth GATT UUID (``0000xxxx00001000800000805f9b34fb``). Args | def cb_uuid_to_str(_uuid: CBUUID) -> str:
_uuid = _uuid.UUIDString()
if len(_uuid) == 4:
return "0000{0}-0000-1000-8000-00805f9b34fb".format(_uuid.lower())
# TODO: Evaluate if this is a necessary method...
# elif _is_uuid_16bit_compatible(_uuid):
# return _uuid[4:8].lower()
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uuid(_uuid=uuid4):\n return str(_uuid())",
"def _format_uuid(self, uuid):\n uuid_format = self.uuid_format\n uuid_list=uuid_format.split(\"-\")\n pad=len(uuid_list[-1])\n last_element=uuid.zfill(pad)\n formatted_uuid=uuid_format.replace(uuid_list[-1], last_element)\n ... | [
"0.67531985",
"0.6394974",
"0.6309436",
"0.6288315",
"0.6235836",
"0.6185628",
"0.61492383",
"0.61275625",
"0.6092875",
"0.60705936",
"0.6040981",
"0.595578",
"0.59540427",
"0.5948298",
"0.59475523",
"0.58622694",
"0.5757375",
"0.575162",
"0.575162",
"0.57498914",
"0.5726065"... | 0.83089083 | 0 |
Instruct the light to turn on. You can skip the brightness part if your light does not support brightness control. | def turn_on(self, **kwargs):
self._brightness = 100
self._state = 'on'
#self._light.brightness = kwargs.get(ATTR_BRIGHTNESS, 255)
#self._light.turn_on()
_LOGGER.info("turn_on() is called") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_on(self, **kwargs: Any) -> None:\n self._light.brightness = kwargs.get(ATTR_BRIGHTNESS, 255)\n self._light.turn_on()",
"def set_light_on(self):\r\n self._light = \"ON\"",
"async def async_turn_on(self, **kwargs: Any) -> None:\n if (brightness := kwargs.get(ATTR_BRIGHTNESS))... | [
"0.876063",
"0.86473703",
"0.86437523",
"0.86226034",
"0.86144036",
"0.83741844",
"0.8299596",
"0.8281327",
"0.82521445",
"0.8087994",
"0.8022874",
"0.80080384",
"0.78507304",
"0.7818195",
"0.77767706",
"0.7775988",
"0.7701322",
"0.7684567",
"0.767373",
"0.761866",
"0.7589698... | 0.8921207 | 0 |
Predicts whether the faces belong to a trained class. | def face_prediction(self, frame, faces):
predictions = FaceModel.model.predict_proba(FaceModel.emb_array)
best_class_indices = np.argmax(predictions, axis=1)
best_class_probabilities = predictions[
np.arange(len(best_class_indices)),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_trained(self) -> bool:\r\n return not getattr(self._lda, \"classes_\", None) is None",
"def apply_classifier(self):\n for detected_object in self.detected_objects:\n detected_object.predict_class(self.original_image)",
"def is_trained(self) -> bool:",
"def classification(self)... | [
"0.6539211",
"0.64435315",
"0.642666",
"0.64105463",
"0.6291514",
"0.62014234",
"0.6199739",
"0.61470646",
"0.60917354",
"0.60511786",
"0.6036084",
"0.6013855",
"0.6013855",
"0.6013855",
"0.6013592",
"0.6008291",
"0.5985599",
"0.59688056",
"0.5966839",
"0.5940728",
"0.5940728... | 0.70823354 | 0 |
Performs all necessary work to do face classification. Returns | def classification(self):
if self.video_in != None:
ret, frame = self.video_in.get_a_frame()
elif self.camera_in != None:
ret, frame = self.camera_in.get_a_frame()
if ret == True:
# detect face
faces = FaceModel.detect_face(self, frame)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classify_face(im):\r\n faces = get_encoded_faces()\r\n faces_encoded = list(faces.values())\r\n known_face_names = list(faces.keys())\r\n\r\n img = cv2.imread(im, 1)\r\n \"\"\"\r\n Resize optinal \r\n \"\"\"\r\n #img = cv2.resize(img, (0, 0), fx=0.5, fy=0.5)\r\n #img = img[:,:,::-1]\... | [
"0.72616476",
"0.70782316",
"0.6882108",
"0.6881206",
"0.6809572",
"0.6784606",
"0.67753196",
"0.66968185",
"0.6624295",
"0.65775526",
"0.6573839",
"0.6529528",
"0.65139365",
"0.6483432",
"0.6458223",
"0.6457295",
"0.6426916",
"0.6408628",
"0.6396731",
"0.6369119",
"0.6361105... | 0.71059865 | 1 |
Build an expression equivalent to a lookup table | def build_lookup(mapping, var='ptype', default='ptype'):
if len(mapping) > 0:
return 'where(%s==%s, %s, %s)' % (var, mapping[0][0], mapping[0][1], build_lookup(mapping[1:], var, default))
else:
return str(default) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_lookup(mapping, var='ptype', default=0.):\n # force mapping to be a list if it wasn't already\n mapping=list(mapping)\n if len(mapping) > 0:\n return 'where(%s==%s, %s, %s)' % (var, mapping[0][0], mapping[0][1], build_lookup(mapping[1:], var, default))\n else:\n ... | [
"0.6523732",
"0.61150914",
"0.5955717",
"0.570927",
"0.56178665",
"0.5579834",
"0.5579453",
"0.54781777",
"0.5457547",
"0.5432533",
"0.5425061",
"0.5388716",
"0.5387384",
"0.5381003",
"0.5378903",
"0.53568715",
"0.5315897",
"0.52996916",
"0.5293774",
"0.528251",
"0.5204979",
... | 0.64584607 | 1 |
Build an expression equivalent to a lookup table | def build_lookup(mapping, var='ptype', default=0.):
# force mapping to be a list if it wasn't already
mapping=list(mapping)
if len(mapping) > 0:
return 'where(%s==%s, %s, %s)' % (var, mapping[0][0], mapping[0][1], build_lookup(mapping[1:], var, default))
else:
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_lookup(mapping, var='ptype', default='ptype'):\n if len(mapping) > 0:\n return 'where(%s==%s, %s, %s)' % (var, mapping[0][0], mapping[0][1], build_lookup(mapping[1:], var, default))\n else:\n return str(default)",
"def __getitem__(self, key: str) -> ir.TableExpr:\n return sel... | [
"0.64584607",
"0.61150914",
"0.5955717",
"0.570927",
"0.56178665",
"0.5579834",
"0.5579453",
"0.54781777",
"0.5457547",
"0.5432533",
"0.5425061",
"0.5388716",
"0.5387384",
"0.5381003",
"0.5378903",
"0.53568715",
"0.5315897",
"0.52996916",
"0.5293774",
"0.528251",
"0.5204979",... | 0.6523732 | 0 |
Returns defaultdict with script type / paths mapping, excluding given patterns and python packages. | def walkdirs(root):
scriptype_paths = collections.defaultdict(set)
for root, subdirs, files in os.walk(root):
# Filter subdirs
tmpdir = []
for i in subdirs:
if i.startswith(EXCLUDE_PATTERNS):
continue
if '__init__.py' in os.listdir(os.pat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_extension_to_type_map(file_types):\n extension_to_type = dict()\n for file_type in file_types:\n for file_ext in file_type['extensions']:\n if file_ext not in extension_to_type:\n extension_to_type[file_ext] = file_type\n return extension_to_type",
"def run_mapp... | [
"0.5768541",
"0.569013",
"0.5677841",
"0.55597234",
"0.55592877",
"0.55176985",
"0.5469804",
"0.5445721",
"0.53891",
"0.53409356",
"0.527778",
"0.5227336",
"0.5217691",
"0.5178613",
"0.5168109",
"0.5162053",
"0.5146098",
"0.5145351",
"0.5128747",
"0.51221925",
"0.5121463",
... | 0.6402314 | 0 |
Return valid paths from __file__ dir, PYENV and MELENV. | def get_source_paths():
script_paths = set()
try:
script_paths.update(filter(None, os.environ.get(PYENV).split(os.pathsep)))
script_paths.update(filter(None, os.environ.get(MELENV).split(os.pathsep)))
except AttributeError:
logger.debug('No custom environ variables set.')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_environment_paths(basedir=None):\n basedir = (\n get_default_secrets_basedir() if basedir is None\n else Path(basedir)\n )\n results = list()\n for item in sorted(basedir.iterdir()):\n if is_valid_environment(item):\n results.append(item)\n return results",
... | [
"0.7171722",
"0.6597074",
"0.6507689",
"0.6315025",
"0.6311144",
"0.6296824",
"0.62492156",
"0.6234693",
"0.62341654",
"0.61818033",
"0.61814684",
"0.6162761",
"0.6095949",
"0.60329336",
"0.6010903",
"0.59968036",
"0.5987034",
"0.59694135",
"0.59489715",
"0.5938563",
"0.59279... | 0.7076356 | 1 |
Returns the best camera zoom given the atlas resolution | def zoom(self):
res = np.max(self.metadata["resolution"])
if self.atlas_name == "allen_human_500um":
logger.debug(
"ATLAS: setting zoom manually for human atlas, atlas needs fixing"
)
return 350
else:
return 40 / res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_zoom(input_box, z=18):\n box_tile = smopy.get_tile_box(input_box, z)\n box = smopy.correct_box(box_tile, z)\n sx, sy = smopy.get_box_size(box)\n if sx * sy >= MAXTILES:\n z = get_zoom(input_box, z - 1)\n return z",
"def compute_resolution(zoom, size_px):\n # Calibration data:\n ... | [
"0.6454999",
"0.64292175",
"0.6390678",
"0.62350464",
"0.622483",
"0.6209762",
"0.61986816",
"0.6183604",
"0.6173395",
"0.61674184",
"0.60466546",
"0.5988281",
"0.5962575",
"0.57636255",
"0.5750779",
"0.56561506",
"0.56086415",
"0.55965966",
"0.55922043",
"0.5578516",
"0.5558... | 0.7805432 | 0 |
Gets the rgb color of a region in the atlas | def _get_region_color(self, region):
return [
x / 255 for x in self._get_from_structure(region, "rgb_triplet")
] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_color_in_region(self, start, end):\n # Input format: (start_x, start_y), (end_x, end_y)\n start_x, start_y = start\n end_x, end_y = end\n\n # x and y are flipped\n crop_img = self.img[start_x:(end_x + 1), start_y:(end_y + 1)]\n channels = cv2.mean(crop_img)\n\n ... | [
"0.69011796",
"0.6625769",
"0.65982455",
"0.65948516",
"0.6562015",
"0.6556168",
"0.6497549",
"0.63513184",
"0.6319954",
"0.63109565",
"0.6263722",
"0.6247156",
"0.6227768",
"0.6227081",
"0.61992794",
"0.6185941",
"0.61626786",
"0.6158018",
"0.6136658",
"0.6122602",
"0.607359... | 0.77586186 | 0 |
Returns a plane going through a point at pos, oriented orthogonally to the vector norm and of width and height sx, sy. | def get_plane(
self,
pos=None,
norm=None,
plane=None,
sx=None,
sy=None,
color="lightgray",
alpha=0.25,
**kwargs,
):
axes_pairs = dict(sagittal=(0, 1), horizontal=(2, 0), frontal=(2, 1))
if pos is None:
pos = self.ro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def proj_to_plane(norm, d, pts):\n a = norm[0]\n b = norm[1]\n c = norm[2]\n\n p = []\n\n for i in range(len(pts)):\n x_p = pts[i][0]\n y_p = pts[i][1]\n z_p = pts[i][2]\n\n if a != 0:\n x_0 = (b * b + c * c) * x_p - a * b * y_p - a * c * z_p - a * d\n ... | [
"0.6396546",
"0.6396546",
"0.6183506",
"0.6174271",
"0.6145053",
"0.61160415",
"0.6035465",
"0.5979914",
"0.59591293",
"0.5913918",
"0.59053445",
"0.5904647",
"0.5876737",
"0.58654743",
"0.58250505",
"0.58204174",
"0.57940704",
"0.5756824",
"0.57409114",
"0.57186556",
"0.5703... | 0.68663776 | 0 |
compute z_n at previous time, i.e. z_n(t), z_n(t1) | def compute_z_prev(n, Z_opt, device):
nzx, nzy = Z_opt.shape[2], Z_opt.shape[3]
# no. of channel for noise input
nc_z = 3
if n == 0:
# z_rand is gaussian noise
z_rand = functions.generate_noise([1, nzx, nzy], device= device)
z_rand = z_rand.expand(1, 3, Z_opt.shape[2], Z... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_z_curr(Z_opt, z_prev1, z_diff, alpha):\r\n z_curr = alpha * Z_opt + (1 - alpha) * (z_prev1 + z_diff)\r\n return z_curr",
"def lookback_time(self, z, z0 = 0.0):\n lt_func = np.vectorize(lambda z, z0: \n si.quad(self._lookback_integrand, z0, z, limit=1000)\n ... | [
"0.6359763",
"0.6280652",
"0.5986535",
"0.59398437",
"0.58886546",
"0.5796982",
"0.57787",
"0.57448745",
"0.5621632",
"0.55678546",
"0.5563106",
"0.55606556",
"0.55116934",
"0.54717535",
"0.54433835",
"0.544052",
"0.54086614",
"0.538945",
"0.53769845",
"0.53676015",
"0.536680... | 0.6960639 | 0 |
Usage Compute all the free space on the boundary of cells in the diagram for polygonal chains P and Q and the given eps LF[(i,j)] is the free space of segment [Pi,Pi+1] from point Qj BF[(i,j)] is the free space of segment [Qj,Qj+1] from point Pj | def LF_BF(P, Q, p, q, eps, mdist, P_dist, Q_dist):
LF = {}
for j in range(q):
for i in range(p - 1):
LF.update({(i, j): free_line(Q[j], eps, P[i:i + 2], mdist[i, j], mdist[i + 1, j], P_dist[i])})
BF = {}
for j in range(q - 1):
for i in range(p):
BF.update({(i, j):... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def LR_BR(LF, BF, p, q):\n if not (LF[(0, 0)][0] <= 0 and BF[(0, 0)][0] <= 0 and LF[(p - 2, q - 1)][1] >= 1 and BF[(p - 1, q - 2)][1] >= 1):\n rep = False\n BR = {}\n LR = {}\n else:\n LR = {(0, 0): True}\n BR = {(0, 0): True}\n for i in range(1, p - 1):\n ... | [
"0.5799362",
"0.56557685",
"0.56553715",
"0.55753076",
"0.5484209",
"0.5474942",
"0.541693",
"0.53881",
"0.5384835",
"0.5301325",
"0.52949774",
"0.5292436",
"0.528571",
"0.5250551",
"0.52481675",
"0.519482",
"0.5136062",
"0.5130518",
"0.51211125",
"0.51081985",
"0.5103744",
... | 0.6871466 | 0 |
Usage Compute all the free space,that are reachable from the origin (P[0,0],Q[0,0]) on the boundary of cells in the diagram for polygonal chains P and Q and the given free spaces LR and BR LR[(i,j)] is the free space, reachable from the origin, of segment [Pi,Pi+1] from point Qj BR[(i,j)] is the free space, reachable f... | def LR_BR(LF, BF, p, q):
if not (LF[(0, 0)][0] <= 0 and BF[(0, 0)][0] <= 0 and LF[(p - 2, q - 1)][1] >= 1 and BF[(p - 1, q - 2)][1] >= 1):
rep = False
BR = {}
LR = {}
else:
LR = {(0, 0): True}
BR = {(0, 0): True}
for i in range(1, p - 1):
if LF[(i, 0)]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dbgain_free_space(self, pt_1, pt_2):\n if (pt_1.ndim > 1) or (pt_2.ndim > 1):\n raise NotImplementedError\n dist = np.linalg.norm(pt_1 - pt_2)\n\n return self.dist_to_dbgain_free_space(\n dist,\n wavelength=self.wavelength,\n antenna_dbgain_tx=se... | [
"0.5692554",
"0.5665216",
"0.5620372",
"0.5388032",
"0.5333929",
"0.53203285",
"0.5296268",
"0.5269298",
"0.5259146",
"0.5242636",
"0.5239064",
"0.52265537",
"0.52158135",
"0.51837415",
"0.51299995",
"0.5123705",
"0.5116886",
"0.51046026",
"0.50999355",
"0.50996166",
"0.50863... | 0.57159686 | 0 |
Usage Compute all the critical values between trajectories P and Q | def compute_critical_values(P, Q, p, q, mdist, P_dist, Q_dist):
origin = eucl_dist(P[0], Q[0])
end = eucl_dist(P[-1], Q[-1])
end_point = max(origin, end)
cc = set([end_point])
for i in range(p - 1):
for j in range(q - 1):
Lij = point_to_seg(Q[j], P[i], P[i + 1], mdist[i, j], mdis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cost(P, Q):\n Q = np.where(Q != 0, Q, 1e-12)\n P = np.where(P != 0, P, 1e-12)\n Div = P / Q\n C = np.sum(P * np.log(Div))\n return C",
"def frechet(P, Q):\n p = len(P)\n q = len(Q)\n\n mdist = eucl_dist_traj(P, Q)\n P_dist = [eucl_dist(P[ip], P[ip + 1]) for ip in range(p - 1)]\n ... | [
"0.59205824",
"0.58363307",
"0.57980275",
"0.5699093",
"0.5682799",
"0.5677158",
"0.5676779",
"0.5636182",
"0.56267333",
"0.5624366",
"0.5620646",
"0.5620646",
"0.5620646",
"0.5620646",
"0.5620646",
"0.5599994",
"0.5571987",
"0.55696845",
"0.5563916",
"0.55605155",
"0.5541283... | 0.67792004 | 0 |
Usage Compute the frechet distance between trajectories P and Q | def frechet(P, Q):
p = len(P)
q = len(Q)
mdist = eucl_dist_traj(P, Q)
P_dist = [eucl_dist(P[ip], P[ip + 1]) for ip in range(p - 1)]
Q_dist = [eucl_dist(Q[iq], Q[iq + 1]) for iq in range(q - 1)]
cc = compute_critical_values(P, Q, p, q, mdist, P_dist, Q_dist)
eps = cc[0]
while (len(cc) !... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dist(p, q):\n return ((p[0] - q[0])**2 + (p[1] - q[1])**2 + (p[2] - q[2])**2)**0.5",
"def dist(p,q):\n return math.sqrt((p[0] - q[0]) ** 2+(p[1] - q[1]) ** 2)",
"def distance(M, p, q):\n\n return (math.sqrt(math.pow(M[p, 0] - M[q, 0],2) + math.pow(M[p, 1] - M[q, 1],2))) # obliczanie dystansu mie... | [
"0.7173551",
"0.69895643",
"0.6843418",
"0.6539303",
"0.65212935",
"0.650371",
"0.63225406",
"0.62851346",
"0.6272369",
"0.6259774",
"0.62053066",
"0.62031424",
"0.6179285",
"0.6176652",
"0.6154126",
"0.6151824",
"0.6131871",
"0.6069721",
"0.60457736",
"0.6016533",
"0.5989678... | 0.7064292 | 1 |
Append size with the specified number of entities | def appendsize(self, numents):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def appendsize(self, numents):\n self._numents += numents",
"def inc_size(self):\r\n self.__length += 1",
"def batch_size(self) -> int:\n ...",
"def appenddictitemsize(self, key, numents):\n self._dentsvertsdata[key].appendsize(numents * self._multFactor)",
"def _assign_sizes(se... | [
"0.71058905",
"0.62483996",
"0.60852516",
"0.60310906",
"0.6018139",
"0.5965686",
"0.588384",
"0.5873902",
"0.5820619",
"0.5802095",
"0.57661766",
"0.57575065",
"0.57453406",
"0.5733978",
"0.5712476",
"0.57062435",
"0.5704675",
"0.56961715",
"0.56593245",
"0.56401414",
"0.563... | 0.7674417 | 0 |
Append size with the specified number of entities | def appendsize(self, numents):
self._numents += numents | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def appendsize(self, numents):\n pass",
"def inc_size(self):\r\n self.__length += 1",
"def batch_size(self) -> int:\n ...",
"def appenddictitemsize(self, key, numents):\n self._dentsvertsdata[key].appendsize(numents * self._multFactor)",
"def _assign_sizes(self):",
"def setDat... | [
"0.7674417",
"0.62483996",
"0.60852516",
"0.60310906",
"0.6018139",
"0.5965686",
"0.588384",
"0.5873902",
"0.5820619",
"0.5802095",
"0.57661766",
"0.57575065",
"0.57453406",
"0.5733978",
"0.5712476",
"0.57062435",
"0.5704675",
"0.56961715",
"0.56593245",
"0.56401414",
"0.5638... | 0.71058905 | 1 |
! Allocate memory for the vertex data channels Allocation size is based on the information collected by client calls to appendsize() | def allocatememory(self):
self._numvertstotal = self._numents * self._nvet
self._cords = VertDataSingleChannel(GLDataType.FLOAT, 3, self._numvertstotal)
self._colors = VertDataSingleChannel(GLDataType.UBYTE, 4, self._numvertstotal) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _allocate_buffer_memory(self):\n for channel in self._channels_dict.values():\n if channel.enabled:\n channel.allocate(self._num_captures, self._num_samples)",
"def allocatememory(self):\n\n for key, value in self._dentsvertsdata.items():\n value.allocatemem... | [
"0.6268719",
"0.61186135",
"0.57991874",
"0.560458",
"0.5575091",
"0.55208147",
"0.54995835",
"0.5477305",
"0.54349387",
"0.54285145",
"0.5426824",
"0.54087883",
"0.5403441",
"0.5387381",
"0.5375428",
"0.5373897",
"0.53613126",
"0.5357203",
"0.5356363",
"0.53444767",
"0.53117... | 0.76169854 | 0 |
! Clone the instance of VertDataCollectorCoord3fColor4ub class Overrides the base class abstract method | def clone(self):
vdc = VertDataCollectorCoord3fColor4ub(self._enttype)
return vdc | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self):\n return vertex(self.x, self.y, self.z)",
"def clone(self, *args):\n return _osgAnimation.VertexInfluenceMap_clone(self, *args)",
"def Clone(self) -> \"itkBinaryContourImageFilterIUS3IUS3_Pointer\":\n return _itkBinaryContourImageFilterPython.itkBinaryContourImageFilterIUS3... | [
"0.56691396",
"0.56231135",
"0.5584617",
"0.5574439",
"0.55721986",
"0.5510009",
"0.5508986",
"0.5500849",
"0.5500065",
"0.54964495",
"0.5489479",
"0.5352548",
"0.53463817",
"0.53232324",
"0.53192043",
"0.5311618",
"0.53026754",
"0.52971894",
"0.5295959",
"0.5295959",
"0.5279... | 0.7961676 | 0 |
Generate test image with random pixels and save as an image file. | def test_image(filename, x_size=350, y_size=350):
# Create image and loop over all pixels
im = Image.new("RGB", (x_size, y_size))
pixels = im.load()
for i in range(x_size):
for j in range(y_size):
x = remap(i, 0, x_size, -1, 1)
y = remap(j, 0, y_size, -1, 1)
p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_image(filename, x_size=350, y_size=350):\n # Create image and loop over all pixels\n im = Image.new(\"RGB\", (x_size, y_size))\n pixels = im.load()\n for i in range(x_size):\n for j in range(y_size):\n pixels[i, j] = (random.randint(0, 255), # Red channel\n ... | [
"0.7916328",
"0.7276964",
"0.72279763",
"0.7180069",
"0.7180069",
"0.7180069",
"0.6833925",
"0.67390573",
"0.6636539",
"0.6577365",
"0.6552666",
"0.654833",
"0.6493901",
"0.64547956",
"0.6446572",
"0.6445794",
"0.6444757",
"0.6440958",
"0.6415097",
"0.6344109",
"0.63346565",
... | 0.73138684 | 1 |
Generates computational art and save as an image file. All args optional complexity base complexity (depth of recursion) for image creation num_frames determines how many frames will be drawn | def gen_art(complexity=7, num_frames=1, x_size=350, y_size=350):
# Functions for red, green, and blue channels - where the magic happens!
red_function = bld_func(complexity, complexity+2)
green_function = bld_func(complexity, complexity+2)
blue_function = bld_func(complexity, complexity+2)
# Crea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def genFrameImages((widthPixels, heightPixels), flashColourGen, flashColourGenPipTrain, numFrames, FPS, superSamplingScale=8, BG_COLOUR=(0,0,0), TEXT_COLOUR=(255,255,255), GFX_COLOUR=(255,255,255), title=\"\", TITLE_COLOUR=(255,255,255), FRAMES_AS_FIELDS=False, frameSkipChecker=None, segments=[]):\n\n # we're g... | [
"0.6099129",
"0.60725677",
"0.59570324",
"0.57942635",
"0.5732733",
"0.5721138",
"0.5702478",
"0.5699087",
"0.56475115",
"0.56121796",
"0.5609035",
"0.56052744",
"0.5589004",
"0.5555326",
"0.5541834",
"0.5528516",
"0.5511197",
"0.55007917",
"0.5499388",
"0.54913527",
"0.54791... | 0.76743954 | 0 |
Calculates and returns Y position to draw the graph or the border lines on canvas. Correct calculation is based on given sensor. | def calculate_y_pos(value, sensor):
if GraphModel.check_value(value, sensor):
return ((32 - int(value)) * 12.5) + 50 if sensor == 't' else 450 - (int(value) / 10 * 40)
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_y_position(self):\n return self.actual_coordinates[1]",
"def _get_y(self):\n return self.position.y",
"def get_y_position(self): \n return self.rect.y",
"def _get_y(self):\n enabled = self.num_enabled\n\n if self.heart_enabled:\n self._heart_y = 45... | [
"0.66574275",
"0.6487656",
"0.6412374",
"0.6384742",
"0.63770056",
"0.63079816",
"0.63051313",
"0.62791324",
"0.6248244",
"0.6188574",
"0.61683464",
"0.61539483",
"0.6150818",
"0.6133438",
"0.61187756",
"0.6089482",
"0.6060128",
"0.605848",
"0.60405856",
"0.60292876",
"0.6007... | 0.78490245 | 0 |
Returns mean value for values in mean_t or mean_l list based on sensor. | def calculate_mean(cls, sensor):
try:
if sensor == 't':
return cls.calculate_y_pos(sum(cls.mean_t) / len(cls.mean_t), sensor)
if sensor == 'l':
return cls.calculate_y_pos(sum(cls.mean_l) / len(cls.mean_l), sensor)
except ZeroDivisionError:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_t_mean_value(self, value_list):\n if not len(value_list):\n return None\n else:\n return round(statistics.mean(value_list), 1)",
"def add_value_mean(cls, sensor, values, device_id):\n if values[device_id] is not None:\n if sensor == 't':\n ... | [
"0.72287035",
"0.7126963",
"0.69162667",
"0.6880043",
"0.68731856",
"0.6742288",
"0.6600956",
"0.6521696",
"0.6425413",
"0.64079094",
"0.6404101",
"0.6390297",
"0.63823843",
"0.6371286",
"0.6350793",
"0.630408",
"0.63019705",
"0.62969667",
"0.6281619",
"0.62799853",
"0.621725... | 0.74634945 | 0 |
This method is used internally to check if the current animation needs to be skipped or not. It also checks if the number of animations that were played correspond to the number of animations that need to be played, and raises an EndSceneEarlyException if they don't correspond. | def update_skipping_status(self):
# there is always at least one section -> no out of bounds here
if self.file_writer.sections[-1].skip_animations:
self.skip_animations = True
if (
config["from_animation_number"]
and self.num_plays < config["from_animation_num... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def skip_next_animation(self):\n current_num_animations = len(self.queued_animations)\n while len(self.queued_animations) >= current_num_animations and len(self.queued_animations) > 0:\n self.update(100)",
"def verify_ending(self):\n self._fast_forward_to_penultimate_play()\n ... | [
"0.5900172",
"0.55246276",
"0.5460398",
"0.5384421",
"0.53802437",
"0.5294638",
"0.5283734",
"0.52820474",
"0.52820474",
"0.5280884",
"0.5170907",
"0.5156991",
"0.5137927",
"0.5131808",
"0.5128726",
"0.50902385",
"0.50789577",
"0.5078137",
"0.50726855",
"0.50664717",
"0.50526... | 0.746912 | 0 |
Returns an image from the current frame. The first argument passed to image represents the mode RGB with the alpha channel A. The data we read is from the currently bound frame buffer. We pass in 'raw' as the name of the decoder, 0 and 1 args are specifically used for the decoder tand represent the stride and orientati... | def get_image(self) -> Image.Image:
raw_buffer_data = self.get_raw_frame_buffer_object_data()
image = Image.frombytes(
"RGBA",
self.get_pixel_shape(),
raw_buffer_data,
"raw",
"RGBA",
0,
-1,
)
return image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grabFrame(self):\r\n \r\n data, w, h, orientation = self.grabRawFrame()\r\n return Image.fromstring(\"RGB\", (w, h), data, \"raw\", \"BGR\", 0, orientation)",
"def grabRawFrame(self):\r\n \r\n self.surface = self.capture.get_image(self.surface)\r\n width, height = se... | [
"0.6702811",
"0.6255629",
"0.62121195",
"0.5816756",
"0.5771386",
"0.57592493",
"0.56033903",
"0.5568716",
"0.55405825",
"0.5520708",
"0.54805356",
"0.54444456",
"0.54290974",
"0.5426007",
"0.5381863",
"0.5361281",
"0.5349747",
"0.5332689",
"0.5305605",
"0.53024167",
"0.52890... | 0.6270685 | 1 |
Set the commitment to sha256(serialization of public key P2) Return in hex to calling function | def get_commitment(self):
if not self.P2:
raise PoDLEError("Cannot construct commitment, no P2 available")
if not isinstance(self.P2, secp256k1.PublicKey):
raise PoDLEError("Cannot construct commitment, P2 is not a pubkey")
self.commitment = hashlib.sha256(self.P2.seriali... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sha256(self):\n return self._sha256",
"def hash(self) -> bytes:",
"def printsha(self):\n print(self.sha256.hex())",
"def RSA_SIGNATURE_HASH() :\n return \"SHA-256\"",
"def SHA256(self) -> _n_0_t_3[_n_0_t_9]:",
"def hash(self) -> str:\r\n ...",
"def sha256(self) -> Optional[p... | [
"0.6685336",
"0.6628729",
"0.65991706",
"0.6530299",
"0.64776933",
"0.6459898",
"0.6440979",
"0.6411019",
"0.6385267",
"0.62253946",
"0.6224505",
"0.6205821",
"0.61614484",
"0.6151875",
"0.61337245",
"0.6097328",
"0.60924083",
"0.60726136",
"0.60650444",
"0.6061097",
"0.60603... | 0.70035625 | 0 |
Encapsulate all the data representing the proof in a dict for client functions. Data output in hex. | def reveal(self):
if not all([self.u, self.P, self.P2, self.s, self.e]):
raise PoDLEError("Cannot generate proof, data is missing")
if not self.commitment:
self.get_commitment()
Phex, P2hex, shex, ehex, commit = [
safe_hexlify(x) for x in [self.P.serialize(),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json_data(self):\n self.check_proof()\n return {\n \"vars\": [{'name': v.name, 'T': str(v.T)} for v in self.vars],\n \"proof\": sum([printer.export_proof_item(self.thy, item, unicode=True, highlight=True)\n for item in self.prf.items], []),\n ... | [
"0.60062224",
"0.59404445",
"0.58804053",
"0.585302",
"0.5616752",
"0.5561285",
"0.55145526",
"0.5495601",
"0.5492765",
"0.54911596",
"0.5489464",
"0.54656714",
"0.5438447",
"0.5421299",
"0.5415515",
"0.54064167",
"0.5376681",
"0.53762263",
"0.53696877",
"0.5365422",
"0.53627... | 0.6377318 | 0 |
For an object created without a private key, check that the opened commitment verifies for at least one NUMS point as defined by the range in index_range | def verify(self, commitment, index_range):
if not all([self.P, self.P2, self.s, self.e]):
raise PoDLE("Verify called without sufficient data")
if not self.get_commitment() == commitment:
return False
for J in [getNUMS(i) for i in index_range]:
sig_priv = secp2... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_validity(self):\n cnt = np.array([len(v) for v in self.t_signatures.values()])\n cnt_n = len(cnt) - self.min_bins\n idx = None\n if cnt_n < 0:\n self.valid = False\n else:\n y = [np.all(cnt[i:(i + self.min_bins)] >= self.min_neigh) for i in range(... | [
"0.60313314",
"0.57843703",
"0.5700702",
"0.5683255",
"0.5668263",
"0.5665159",
"0.56576747",
"0.56090784",
"0.5576112",
"0.55565137",
"0.54981154",
"0.5470356",
"0.54564524",
"0.5453247",
"0.5430382",
"0.53956276",
"0.5395109",
"0.5362661",
"0.5359905",
"0.53594095",
"0.5355... | 0.66429484 | 0 |
Returns the public key binary representation of secp256k1 G | def getG(compressed=True):
priv = "\x00"*31 + "\x01"
G = secp256k1.PrivateKey(priv, ctx=ctx).pubkey.serialize(compressed)
return G | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def derive_public_key(private_key):\r\n\r\n Q = int.from_bytes(private_key, byteorder='big') * BIP32_CURVE.generator\r\n xstr = Q.x().to_bytes(32, byteorder='big')\r\n parity = Q.y() & 1\r\n return (2 + parity).to_bytes(1, byteorder='big') + xstr",
"def generate_ecc_public_key(private_key: EllipticCu... | [
"0.6999427",
"0.69973236",
"0.69607085",
"0.6955401",
"0.6817513",
"0.6802411",
"0.6732746",
"0.6685661",
"0.6667977",
"0.654074",
"0.6512128",
"0.64995784",
"0.6488834",
"0.6488834",
"0.6424222",
"0.6328244",
"0.6264105",
"0.6260353",
"0.6245178",
"0.6235156",
"0.61760545",
... | 0.7992583 | 0 |
Taking secp256k1's G as a seed, either in compressed or uncompressed form, append "index" as a byte, and append a second byte "counter" try to create a new NUMS base point from the sha256 of that bytestring. Loop counter and alternate compressed/uncompressed until finding a valid curve point. The first such point is co... | def getNUMS(index=0):
assert index in range(256)
nums_point = None
for G in [getG(True), getG(False)]:
seed = G + chr(index)
for counter in range(256):
seed_c = seed + chr(counter)
hashed_seed = hashlib.sha256(seed_c).digest()
#Every x-coord on the curve ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_podle(self, index=0):\n #TODO nonce could be rfc6979?\n k = os.urandom(32)\n J = getNUMS(index)\n KG = secp256k1.PrivateKey(k, ctx=ctx).pubkey\n KJ = J.tweak_mul(k)\n self.P2 = getP2(self.priv, J)\n self.get_commitment()\n self.e = hashlib.sha256... | [
"0.588711",
"0.55167645",
"0.5486731",
"0.5389965",
"0.5368635",
"0.5368635",
"0.5340812",
"0.5231569",
"0.5220929",
"0.5193509",
"0.51206154",
"0.5085955",
"0.5046237",
"0.5041022",
"0.502793",
"0.5023869",
"0.50096273",
"0.49974316",
"0.49673843",
"0.49673653",
"0.49479038"... | 0.78247774 | 0 |
Check that the algorithm produces the expected NUMS values; more a sanity check than anything since if the file is modified, all of it could be; this function is mostly for testing, but runs fast with precomputed context so can be run in user code too. | def verify_all_NUMS(write=False):
nums_points = {}
for i in range(256):
nums_points[i] = safe_hexlify(getNUMS(i).serialize())
if write:
with open("nums_basepoints.txt", "wb") as f:
from pprint import pformat
f.write(pformat(nums_points))
assert nums_points == prec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_converges_to_accurate_values(fake_args):\n with tempfile.TemporaryDirectory() as tmp_dir:\n fake_args.return_value = FakeArguments('orvara/tests/diagnostic_config.ini', tmp_dir)\n tt = run()[1].data\n # check params\n i = -1 # walker index.\n burn = 250 # number of ... | [
"0.6062466",
"0.6013086",
"0.58547235",
"0.5534653",
"0.5532871",
"0.5531744",
"0.55294245",
"0.5479131",
"0.54670936",
"0.54526573",
"0.543836",
"0.5416768",
"0.53805554",
"0.53707004",
"0.5367765",
"0.53630483",
"0.53561896",
"0.533691",
"0.533691",
"0.53347796",
"0.5329929... | 0.63798946 | 0 |
Given a secp256k1.PrivateKey priv and a secp256k1.PublicKey nums_pt, an alternate | def getP2(priv, nums_pt):
priv_raw = priv.private_key
return nums_pt.tweak_mul(priv_raw) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def derive_public_key(private_key):\r\n\r\n Q = int.from_bytes(private_key, byteorder='big') * BIP32_CURVE.generator\r\n xstr = Q.x().to_bytes(32, byteorder='big')\r\n parity = Q.y() & 1\r\n return (2 + parity).to_bytes(1, byteorder='big') + xstr",
"def check_equal_rsa_pub_key(sk2_, sk_):\n ... | [
"0.59067875",
"0.5829378",
"0.5765356",
"0.5526576",
"0.5433772",
"0.54143405",
"0.5405053",
"0.53853583",
"0.53798145",
"0.53798145",
"0.5323323",
"0.53160423",
"0.528461",
"0.5262551",
"0.5256528",
"0.5253128",
"0.5232929",
"0.5206507",
"0.52053124",
"0.51826376",
"0.517654... | 0.64084935 | 0 |
To allow external functions to add PoDLE commitments that were calculated elsewhere; | def add_external_commitments(ecs):
update_commitments(external_to_add=ecs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_commitments(commitment=None, external_to_remove=None,\n external_to_add=None):\n c = {}\n if os.path.isfile(PODLE_COMMIT_FILE):\n with open(PODLE_COMMIT_FILE, \"rb\") as f:\n try:\n c = json.loads(f.read())\n except ValueError:\n ... | [
"0.6084426",
"0.6054412",
"0.5841496",
"0.5841496",
"0.5827327",
"0.5769322",
"0.5695153",
"0.5672127",
"0.55997235",
"0.5597223",
"0.55949086",
"0.5594832",
"0.5516829",
"0.54900813",
"0.54555416",
"0.53672564",
"0.53643566",
"0.53592396",
"0.535497",
"0.535497",
"0.535497",... | 0.6456808 | 0 |
Optionally add the commitment commitment to the list of 'used', and optionally remove the available external commitment whose key value is the utxo in external_to_remove, persist updated entries to disk. | def update_commitments(commitment=None, external_to_remove=None,
external_to_add=None):
c = {}
if os.path.isfile(PODLE_COMMIT_FILE):
with open(PODLE_COMMIT_FILE, "rb") as f:
try:
c = json.loads(f.read())
except ValueError:
pr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_external_commitments(ecs):\n update_commitments(external_to_add=ecs)",
"def commit(self):\n\t\t## Loops through ALL items\n\t\tfor k in self.data.keys():\n\t\t\tfor item in self[k]:\n\n\t\t\t\t## If the object needs committing, commit it!\n\t\t\t\tif item['meta']['needs_commit']:\n\t\t\t\t\t## Create ... | [
"0.58187145",
"0.5580867",
"0.50022554",
"0.4993998",
"0.4935813",
"0.49136874",
"0.4909131",
"0.49072638",
"0.4864383",
"0.48420364",
"0.48227012",
"0.4786407",
"0.47639194",
"0.4718446",
"0.46703878",
"0.46602783",
"0.46588057",
"0.465066",
"0.46503636",
"0.46418327",
"0.46... | 0.7458837 | 0 |
Given a list of privkeys, try to generate a PoDLE which is not yet used more than tries times. | def generate_podle(priv_utxo_pairs, tries=1, allow_external=None):
used_commitments, external_commitments = get_podle_commitments()
for priv, utxo in priv_utxo_pairs:
for i in range(tries):
#Note that we will return the *lowest* index
#which is still available.
p = Po... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_keys(g, o):\n priv = o.random()\n pub = priv * g\n\n return (priv, pub)",
"def calc_pool(players):\n players = [str(x) for x in players]\n n = len(players)\n for player in players:\n nopool = payoff_nopool(p=percentages[player])\n print(nopool)\n p = {i: percen... | [
"0.5407278",
"0.53765005",
"0.5358425",
"0.5299596",
"0.52687997",
"0.5203861",
"0.5168442",
"0.5158879",
"0.50972825",
"0.5045369",
"0.50346786",
"0.50105166",
"0.4999906",
"0.49660498",
"0.49414423",
"0.49236983",
"0.4902794",
"0.48773238",
"0.48708338",
"0.48589072",
"0.48... | 0.6327766 | 0 |
This function counts how many words are the same between the cuisine file and menu list. | def count_same_words(cuisine_file, menu):
cuisine_list = separate_words(cuisine_file)
same_word_count = 0
for i in cuisine_list:
for j in menu:
if i == j:
same_word_count += 1
return same_word_count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_words(filename):",
"def count_words_and_dublicates(novel):",
"def word_count(self):\n print(self.words())\n return len(self.words())\n #count = 0\n #for lines in self.lines:\n # line = lines.strip(os.linesep)\n # wordslst = line.split()\n # co... | [
"0.690674",
"0.68663776",
"0.68278384",
"0.6711609",
"0.66950136",
"0.659886",
"0.6540741",
"0.651223",
"0.6462825",
"0.63756806",
"0.62130094",
"0.6198834",
"0.61832255",
"0.6172285",
"0.61688614",
"0.6166723",
"0.615954",
"0.61456776",
"0.6139662",
"0.61389077",
"0.6133218"... | 0.8976418 | 0 |
Writes a dictionary of cuisines, scores per dining hall menu to a JSON file | def to_JSON(meal, list_of_cuisines, list_of_menus):
data = {}
for cuisine in list_of_cuisines:
cuisine_list = separate_words(cuisines[cuisine])
scores = {}
for i in range(len(list_of_menus)):
scores[menus[i]] = get_score(cuisines[cuisine], list_of_menus[i])
data[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_json(toWrite):\n with open('clubs.json', 'w+') as outfile:\n json.dump(toWrite, outfile)",
"def write_to_json(dictData, fileout):\n\t# Prepare the output file\n\tfout = codecs.open(fileout, 'w', 'utf-8')\n\thwDict = prepare_hw_dict(dictData)\n\tjson.dump(hwDict, fout)\n\t# Give some summary t... | [
"0.63122237",
"0.612619",
"0.5950973",
"0.57618344",
"0.5728447",
"0.5712075",
"0.5669831",
"0.5658273",
"0.56450564",
"0.56368273",
"0.5627659",
"0.56155825",
"0.5583689",
"0.5558727",
"0.55583084",
"0.5555163",
"0.55480874",
"0.5523268",
"0.55128515",
"0.55048144",
"0.54915... | 0.75506806 | 0 |
get shape key local co | def get_shapekeys_co(ob_name):
obj = bpy.data.objects[ob_name] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_key_id(self):",
"def loc_key(self):\r\n key = tuple(self.loc.coord)\r\n return (key)",
"def key():",
"def grid_shape(self, key):\n return self.execute(b\"GRID.SHAPE\", key)",
"def GetRootKey(self):",
"def locate_shape(shape):",
"def shape_id(self):\n return self._sha... | [
"0.62794775",
"0.627112",
"0.6183166",
"0.61344665",
"0.5998332",
"0.5967131",
"0.5965354",
"0.59295803",
"0.5864717",
"0.5857207",
"0.5822323",
"0.57988447",
"0.5792031",
"0.5763907",
"0.57507324",
"0.5741417",
"0.5723869",
"0.5723869",
"0.57104725",
"0.5698671",
"0.5692661"... | 0.7656703 | 0 |
Gets all users having a specific treatment. Return a list of unique ids. | def get_userids(cursor, having_treatment=None):
cursor.execute('SELECT id FROM users WHERE treatment=?', (having_treatment,))
return cursor.fetchall() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_id_users(self):\n return self.execute(TABELLE['id_users']['select']['all'])",
"def _get_user_ids(model):\n return model.objects.values_list(\"user\", flat=True).distinct(\"user\")",
"def user_ids(self):\n return list(self.get_users())",
"def get_users_and_id(self):\n return se... | [
"0.6486269",
"0.6268288",
"0.6096328",
"0.5965909",
"0.5874028",
"0.5859561",
"0.58230615",
"0.58035034",
"0.5749481",
"0.5737924",
"0.57142645",
"0.5705991",
"0.57020724",
"0.5667985",
"0.5667205",
"0.5649348",
"0.5617039",
"0.5612184",
"0.55673",
"0.5501717",
"0.54955304",
... | 0.75097686 | 0 |
Inject a new user if it is not already existent. | def inject_user(dbConn, uid, username):
try:
with dbConn:
pars = (uid, username)
print "pars: ", pars
dbConn.execute(
"""INSERT OR IGNORE INTO users(uid, username) VALUES(?, ?)""", pars)
except sqlite3.IntegrityError as e:
log.error("Error in ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_append_existing_user(self):\n print('(' + self.test_append_existing_user.__name__+')',\n self.test_append_existing_user.__doc__)\n self.assertIsNone(self.connection.append_user(\n PATIENT_USERNAME, NEW_PATIENT))",
"def add_user_to_g():\n \n if CURRENT_USER in ... | [
"0.6981035",
"0.6747009",
"0.6734936",
"0.67245996",
"0.671906",
"0.671906",
"0.671906",
"0.6718293",
"0.66659963",
"0.6617214",
"0.6604228",
"0.6601467",
"0.6455636",
"0.6441589",
"0.6425503",
"0.63296014",
"0.63053393",
"0.629712",
"0.6287836",
"0.6258661",
"0.6240081",
"... | 0.68272775 | 1 |
Make an update for entry in 'notifications' DB table for a notification message. When a notification arrives. | def make_notification_update(dbConn, obj):
try:
with dbConn:
dbConn.execute("update notifications set rcv_ts=? where msg_id=?",
(obj['dt'], obj['msg_id']))
except sqlite3.IntegrityError as e:
log.error("Error in DB transaction when updating notification fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def update_notification_status(db_session: Session, notification: NotificationUpdate):\n notification_exists = await NotificaitonCRUD.find_notification_by_id(db_session, notification.id)\n if notification_exists:\n notification_exists.sent_date = notification.sent_date\n n... | [
"0.68454736",
"0.6658394",
"0.6574994",
"0.6457614",
"0.63482887",
"0.62627167",
"0.6245886",
"0.62132937",
"0.6201244",
"0.61510915",
"0.6078458",
"0.60640794",
"0.60503453",
"0.6039418",
"0.59960485",
"0.59960234",
"0.59941435",
"0.5983427",
"0.59663224",
"0.5915447",
"0.58... | 0.7377954 | 0 |
Get the last used uid. Corresponds to the number of current rows in users table. | def get_last_uid(cursor):
cursor.execute('SELECT count(uid) FROM users')
return int(cursor.fetchall()[0][0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_last_id(cls):\n db = database.db_connection()\n cursor = db.cursor()\n sql_query = \"SELECT max(id_user) FROM user\"\n cursor.execute(sql_query)\n row = cursor.fetchone()\n cursor.close()\n return int(row[0])",
"def findLastUserID():\n conn = engine.c... | [
"0.71453404",
"0.69029254",
"0.68670946",
"0.6793728",
"0.67858857",
"0.65834606",
"0.65095794",
"0.6316191",
"0.6264117",
"0.6212843",
"0.6200426",
"0.6200426",
"0.6200426",
"0.6198154",
"0.61980546",
"0.6170376",
"0.61453146",
"0.60790145",
"0.6074715",
"0.6057952",
"0.5975... | 0.8011418 | 0 |
Get the last sessios id. Corresponds to the number of current rows in sessions table. | def get_last_sid(cursor):
cursor.execute('SELECT count(sid) FROM sessions')
return int(cursor.fetchall()[0][0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_last_id(cls):\n db = database.db_connection()\n cursor = db.cursor()\n sql_query = \"SELECT max(id_user) FROM user\"\n cursor.execute(sql_query)\n row = cursor.fetchone()\n cursor.close()\n return int(row[0])",
"def last(self):\n return int(self.r... | [
"0.71088165",
"0.7083588",
"0.7010163",
"0.6716816",
"0.66496617",
"0.66146433",
"0.65737474",
"0.65153116",
"0.6488121",
"0.6480088",
"0.64697057",
"0.6468558",
"0.6450978",
"0.6436075",
"0.62589836",
"0.6256979",
"0.6219457",
"0.62008554",
"0.61697483",
"0.61649126",
"0.615... | 0.77453893 | 0 |
Method to scroll down and up the page | def scroll_page(self):
scroll_down = self.driver.find_element_by_tag_name("html")
scroll_down.send_keys(Keys.END)
sleep(TestData.DELAY)
scroll_down.send_keys(Keys.CONTROL + Keys.HOME)
sleep(TestData.DELAY)
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scroll_down(self):\r\n self.driver.execute_script('window.scrollTo(0, document.body.scrollHeight);')\r\n sleep(self.wait)",
"def scroll_half_page_up(event):\n scroll_backward(event, half=True)",
"def scrollTop(self):\n\t\tself.driver.execute_script(\"window.scrollTop(0)\")",
"def scroll_... | [
"0.74910605",
"0.6924257",
"0.68156487",
"0.681399",
"0.67801416",
"0.66706586",
"0.66691154",
"0.66658944",
"0.6662427",
"0.66357076",
"0.660041",
"0.65823764",
"0.6574611",
"0.6517441",
"0.643081",
"0.6410477",
"0.6406138",
"0.6405084",
"0.63762605",
"0.63598233",
"0.634576... | 0.71633923 | 1 |
Method to locate the bot image in the login page | def bot_image(self):
return self.bot_image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def locateImageOnScreen(ImageName):\n location = pyautogui.locateOnScreen(ImageName) \n try: \n for x in location:\n return location\n except:\n sys.exit('The image could not be found in the active screen. \\n'+'Stopping program.')",
"def get_bot_icon(self):\n return s... | [
"0.61848575",
"0.6016288",
"0.5862747",
"0.5774769",
"0.5676973",
"0.565614",
"0.56560594",
"0.561276",
"0.556046",
"0.556046",
"0.5436463",
"0.54205257",
"0.54033643",
"0.5379427",
"0.5356934",
"0.5349648",
"0.53474325",
"0.5340549",
"0.5332325",
"0.5332325",
"0.5332325",
... | 0.70394737 | 0 |
Write into the corpus file. | def corpusWriter(self):
with open('corpus.txt', 'w') as file:
for quote in self.quotes:
file.write(quote + '\n') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_corpus_to_file(output_file, corpus): \n \n file = open(output_file, 'w')\n for line in corpus: \n file.write(line)\n print ('Corpus has been writted in file')\n file.close()",
"def save(file, corpus):\n with open(file, 'w') as f_out:\n f_out.write(corpus)",
"def sav... | [
"0.8130881",
"0.7788724",
"0.71461576",
"0.70922303",
"0.6882938",
"0.6699375",
"0.6698951",
"0.65648764",
"0.63408846",
"0.63222456",
"0.6238415",
"0.6161453",
"0.6103348",
"0.6076733",
"0.6034292",
"0.6018647",
"0.5968113",
"0.5964516",
"0.59475064",
"0.5937549",
"0.5929299... | 0.80795825 | 1 |
Sets/gets homogeneous external field and does not update vector potential. | def homogeneous_external_field(self):
return self._H | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def external_field(self):\n # TODO: return curl(A) for non-homogeneous external_field\n A = self.external_vector_potential\n if A is not None:\n Ax, Ay = A\n # TODO: check expression below\n return (- np.diff(Ax, axis=1) * cfg.idy\n + np.diff... | [
"0.6045435",
"0.6040067",
"0.58883786",
"0.5711208",
"0.55493957",
"0.5493443",
"0.54701155",
"0.53724504",
"0.5348009",
"0.5171922",
"0.5158918",
"0.5158763",
"0.51249254",
"0.5080409",
"0.50776005",
"0.5062098",
"0.5047997",
"0.5029041",
"0.50261176",
"0.5023545",
"0.498671... | 0.61421114 | 0 |
Sets self.gvpei = (self.ae, self.be) + (ai, bi). To be executed in self.external_vector_potential and self.fixed_vortices setters. | def _update_gvpei(self):
assert (self.ae is None) == (self.be is None)
ai, bi = None, None
if self.fixed_vortices is not None and self.fixed_vortices._vpi is not None:
ai, bi = self.fixed_vortices._vpi.get_vec_h()
assert (ai is None) == (bi is None)
vpe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_global_problem_vf_3_gr1_bif(self):\n #0\n std_map = Epetra.Map(len(self.all_fine_vols_ic),0,self.comm)\n self.trans_fine = Epetra.CrsMatrix(Epetra.Copy, std_map, 7)\n self.b = Epetra.Vector(std_map)\n for volume in self.all_fine_vols_ic - set(self.neigh_wells_d):\n ... | [
"0.56007665",
"0.5436167",
"0.53549033",
"0.5279826",
"0.52668923",
"0.5232523",
"0.5191996",
"0.5186861",
"0.5171484",
"0.5170207",
"0.5155571",
"0.5155571",
"0.51301646",
"0.50711966",
"0.50634015",
"0.5041026",
"0.5024466",
"0.50092936",
"0.5004564",
"0.49962527",
"0.49778... | 0.8162519 | 0 |
Sets/gets external vector potential. | def external_vector_potential(self):
assert (self.ae is None) == (self.be is None)
if self.ae is not None:
return self.ae, self.be
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def external_irregular_vector_potential(self):\n if self._vpei is not None:\n return self._vpei.get_vec_h()\n\n return None",
"def potential(self) -> np.ndarray:\n if self._V is None:\n potential = -self._gp.reshape(-1, 1) * self._gp # pylint: disable=E1101\n ... | [
"0.6709609",
"0.6408864",
"0.63957906",
"0.6121401",
"0.6120507",
"0.6060116",
"0.6041537",
"0.5978795",
"0.5968136",
"0.59421694",
"0.5931237",
"0.5890419",
"0.5791883",
"0.5742687",
"0.57241136",
"0.57071424",
"0.5693986",
"0.56902176",
"0.5679575",
"0.56609213",
"0.5643648... | 0.67878634 | 0 |
Sets/gets external irregular vector potential | def external_irregular_vector_potential(self):
if self._vpei is not None:
return self._vpei.get_vec_h()
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def potential(self) -> np.ndarray:\n if self._V is None:\n potential = -self._gp.reshape(-1, 1) * self._gp # pylint: disable=E1101\n object.__setattr__(self, \"_V\", potential)\n return self._V",
"def external_vector_potential(self):\n assert (self.ae is None) == (self... | [
"0.6777151",
"0.6714715",
"0.6365124",
"0.62756366",
"0.62136114",
"0.615632",
"0.6140968",
"0.6131208",
"0.61214024",
"0.6068877",
"0.6030403",
"0.5973165",
"0.596924",
"0.59545225",
"0.5888215",
"0.5796419",
"0.5769236",
"0.57671154",
"0.5765479",
"0.57427657",
"0.57207257"... | 0.711595 | 0 |
Check usage of default credentials on master node | def test_001_check_default_master_node_credential_usage(self):
ip = self.config.nailgun_host
ssh_client = ssh.Client(ip,
self.config.master.master_node_ssh_user,
self.config.master.master_node_ssh_password,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_003_check_default_keystone_credential_usage(self):\n\n usr = self.config.master.keystone_user\n pwd = self.config.master.keystone_password\n url = 'http://{0}:5000/v2.0'.format(self.config.nailgun_host)\n\n try:\n keystone = keystoneclient(usernam... | [
"0.8095686",
"0.73973477",
"0.68096805",
"0.6725103",
"0.6619466",
"0.6389539",
"0.6344078",
"0.6290091",
"0.6246063",
"0.6232161",
"0.61840326",
"0.6176696",
"0.6170216",
"0.6159659",
"0.611495",
"0.6110858",
"0.60856205",
"0.6053819",
"0.60522896",
"0.604298",
"0.6013833",
... | 0.7976447 | 1 |
Check if default credentials for OpenStack cluster have changed | def test_002_check_default_openstack_credential_usage(self):
cluster_data = {
'password': self.config.identity.admin_password,
'username': self.config.identity.admin_username}
default_data = {
'password': 'admin',
'username': 'admin'}
self.verify... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_003_check_default_keystone_credential_usage(self):\n\n usr = self.config.master.keystone_user\n pwd = self.config.master.keystone_password\n url = 'http://{0}:5000/v2.0'.format(self.config.nailgun_host)\n\n try:\n keystone = keystoneclient(usernam... | [
"0.7338063",
"0.65568185",
"0.6468364",
"0.62571883",
"0.59062266",
"0.5873348",
"0.585109",
"0.5782438",
"0.57635754",
"0.57020897",
"0.5653839",
"0.563108",
"0.5605719",
"0.55638623",
"0.5553499",
"0.5546776",
"0.5503604",
"0.5487107",
"0.5486545",
"0.5467942",
"0.5448755",... | 0.7722615 | 0 |
Check usage of default credentials for keystone on master node | def test_003_check_default_keystone_credential_usage(self):
usr = self.config.master.keystone_user
pwd = self.config.master.keystone_password
url = 'http://{0}:5000/v2.0'.format(self.config.nailgun_host)
try:
keystone = keystoneclient(username=usr,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_002_check_default_openstack_credential_usage(self):\n cluster_data = {\n 'password': self.config.identity.admin_password,\n 'username': self.config.identity.admin_username}\n\n default_data = {\n 'password': 'admin',\n 'username': 'admin'}\n\n ... | [
"0.7416696",
"0.73040277",
"0.66775703",
"0.64706546",
"0.63807833",
"0.63734967",
"0.6169981",
"0.6136318",
"0.6118",
"0.6086049",
"0.607734",
"0.60373425",
"0.60364085",
"0.6034082",
"0.59883475",
"0.5980997",
"0.5974277",
"0.59671694",
"0.59401226",
"0.5902685",
"0.5882367... | 0.8827416 | 0 |
helper funtion to get user.id using email | def getUserID(email):
try:
user = session.query(User_info).filter_by(email=email).one()
return user.id
except Exception as e:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_id(self, email):\n\n query = self._db.User.select(self._db.User.c.email == email)\n query = query.with_only_columns([self._db.User.c.id_, ])\n\n record = query.execute().fetchone()\n return record[0]",
"def find_user_id(email: str):\n user_id = sdk.search_users(email=email)\n... | [
"0.80991805",
"0.80331326",
"0.79804707",
"0.7974303",
"0.7971684",
"0.7953753",
"0.7935821",
"0.7935821",
"0.78868335",
"0.78705585",
"0.77772075",
"0.7756721",
"0.7755162",
"0.77276444",
"0.75779545",
"0.7553001",
"0.7553001",
"0.75268793",
"0.74339384",
"0.73698187",
"0.73... | 0.80812913 | 1 |
Launch the instance of tensorboard given the directory and port | def launch_tb(logdir: str = None, port: str = '7900'):
tb = program.TensorBoard()
tb.configure(argv=[None, '--logdir', logdir, '--port', port])
url = tb.launch()
print(f'======\nLaunching tensorboard,\nDirectory: {logdir}\nPort: {port}\n======\n')
return url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_tensorboard(self):\n python_path = sys.executable\n option = '--logdir=' + self.instance.instance_summary_folder_path\n args_ = [python_path, tensorboard_dir(), option]\n self.open_subprocess(args_=args_, subprocess_key=\"tensorboard\")",
"def run_simple_server(tb_app):\n # ... | [
"0.73095095",
"0.6589419",
"0.6576443",
"0.64658266",
"0.6464839",
"0.6164005",
"0.613992",
"0.58848023",
"0.58216435",
"0.57985985",
"0.5750669",
"0.5724207",
"0.5703905",
"0.56819606",
"0.567644",
"0.5631442",
"0.5608709",
"0.56047523",
"0.55997616",
"0.55934083",
"0.554290... | 0.8142196 | 0 |
Random display of 25 fonts | def lf():
return random.sample(font_list, 25) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drawtext(self, drawer):\n rand_chars = self.randchars()\n font = ImageFont.truetype(self._font_face, self._font_size)\n font_width, font_height = font.getsize(rand_chars)\n drawer.text(\n ((self._width - font_width) / 2,\n (self._height - font_height) / 2),\n ... | [
"0.6392809",
"0.6286903",
"0.62738657",
"0.6246008",
"0.6230189",
"0.62171894",
"0.616977",
"0.61241275",
"0.609214",
"0.59919924",
"0.59631574",
"0.59398395",
"0.59008574",
"0.58772904",
"0.5865573",
"0.58576256",
"0.5825984",
"0.5825982",
"0.58239526",
"0.58212125",
"0.5809... | 0.8467218 | 0 |
An art font that generates random fonts and random colors. | def rd(text, on_color=None, attr=None,
width=80, justify="center"):
rand_int = random.randint(1, len(font_list)+1)
rand_color = color_dict.get(random.randint(30, 38))
rand_font = font_list[rand_int]
print(f"Random font: {format(rand_font)}")
f = Figlet(
font=rand_font, width=width,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lf():\n return random.sample(font_list, 25)",
"def test_generate_mine_text(self):\n pg.font.init()\n font_surface = utils.generate_mine_text(1)\n self.assertIsInstance(font_surface, pg.Surface)",
"def create(font_name, point):\n return pygame.font.SysFont(font_name, int(point... | [
"0.72884387",
"0.64297265",
"0.64126635",
"0.62243783",
"0.6147591",
"0.61150885",
"0.60803175",
"0.60634375",
"0.60376585",
"0.6032824",
"0.60188615",
"0.5972626",
"0.59216464",
"0.59104794",
"0.5828189",
"0.5799208",
"0.57634753",
"0.5763224",
"0.57085055",
"0.565248",
"0.5... | 0.7143183 | 1 |
Gets the ith bit (zeroindexed). | def get_bit(num, i):
return 1 if num & 1 << i else 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bit(num, i):\n return num & (1 << i) != 0",
"def __getitem__(self, index):\n nth_int, nth_bit = divmod(index, BitArray._UNSIGNED_INT)\n return self.bits[nth_int] & (1 << nth_bit)",
"def _get_bit(byte, ii):\n return (byte >> (7 - ii)) & 1",
"def bit_get(val, idx):\n return (... | [
"0.7826954",
"0.7410046",
"0.7386657",
"0.73263216",
"0.7222269",
"0.7176076",
"0.7137559",
"0.71253127",
"0.6973061",
"0.6967496",
"0.6958228",
"0.69483864",
"0.694268",
"0.68543786",
"0.6816369",
"0.6688558",
"0.66808105",
"0.6567417",
"0.6564154",
"0.6555715",
"0.653013",
... | 0.81653005 | 0 |
set kromosom dengan cara mencari biner dari solusi untuk dijadikan 8 kromosom | def setKromosom(self,x,y):
binx = bin(x)[2:].zfill(4)
biny = bin(y)[2:].zfill(4)
self.kromosom = list(binx+biny) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getKromosom(self):\n intx = int(\"\".join(self.kromosom[:4]),2)\n inty = int(\"\".join(self.kromosom[4:]),2)\n return [intx,inty]",
"def generateKromosom(self):\n result = []\n # looping sebanyak panjangKromosom\n for _ in range(self.panjangKromosom):\n # ... | [
"0.5587814",
"0.55320877",
"0.55121857",
"0.55119824",
"0.5262004",
"0.5262004",
"0.5262004",
"0.5262004",
"0.5262004",
"0.5259152",
"0.5237551",
"0.5234786",
"0.50942725",
"0.5071469",
"0.5066532",
"0.5040176",
"0.5033861",
"0.50290656",
"0.49992993",
"0.49971503",
"0.499188... | 0.7294824 | 0 |
return all the URIs that directly or indirectly share keys with the given URI | def traverse_uris(uri):
seen = set()
uris_to_check = [uri]
while len(uris_to_check) > 0:
uri = uris_to_check.pop()
if uri not in seen:
seen.add(uri)
for key in keys_for_uri[uri]:
for uri2 in uris_for_key[key]:
if uri2 not in seen:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_signed_urls(urls, rse, operation='read'):\n result = {}\n for url in urls:\n try:\n endpoint, bucket_name, key_name = _get_endpoint_bucket_key(url)\n\n signed_url = None\n if operation == 'read':\n # signed_url = conn.generate_url(3600, 'GET', bu... | [
"0.5448103",
"0.5409984",
"0.5319906",
"0.5254115",
"0.519453",
"0.5190271",
"0.5170817",
"0.5147005",
"0.5144864",
"0.5075499",
"0.50541604",
"0.5042928",
"0.50086915",
"0.50086915",
"0.50020605",
"0.49731576",
"0.49711323",
"0.49554473",
"0.49431983",
"0.49355274",
"0.49327... | 0.7433617 | 0 |
return a sort key for the given URI, based on whether it represents the primary work in the record | def uri_sort_key(uri):
if uri.startswith('http://urn.fi/URN:NBN:fi:bib:me:'):
priority = int(uri[-2:]) # last two digits are 00 for the primary work, 01+ for other works mentioned
else:
priority = -1 # higher priority for e.g. authorized agents
return (priority, uri) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _wiki_sort_key(doc):\n url = doc['url']\n return 1 if url.startswith('https://en.wikipedia') else -1",
"def get_row_list_sorting_key(x):\n name, count = x\n if '_' not in name:\n return name\n s = name.split('_')\n e... | [
"0.6385338",
"0.6095066",
"0.6061569",
"0.5977724",
"0.5976031",
"0.5923008",
"0.5896237",
"0.58184385",
"0.5716709",
"0.5716709",
"0.5691437",
"0.56786144",
"0.55717903",
"0.5541411",
"0.55260164",
"0.54876274",
"0.54588896",
"0.544542",
"0.5411701",
"0.5399729",
"0.5323552"... | 0.7179098 | 0 |
return the most appropriate URI from the given set of URIs | def select_uri(uris):
return sorted(uris, key=uri_sort_key)[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_best(a_list, base_url, keyword=TERMS_KEYWORD):\n if not a_list:\n return None\n\n if len(a_list) == 1:\n return get_absolute_url(a_list[0], base_url)\n\n for a in a_list:\n full_url_str = get_absolute_url(a, base_url)\n full_url = URL(full_url_str)\n\n if full... | [
"0.5774539",
"0.5353114",
"0.5214836",
"0.5105618",
"0.5089583",
"0.5086685",
"0.5053703",
"0.50328743",
"0.50301826",
"0.502398",
"0.50229007",
"0.50123894",
"0.5010701",
"0.49976727",
"0.4970601",
"0.4955148",
"0.4953455",
"0.49447128",
"0.49424458",
"0.49263084",
"0.490907... | 0.7494441 | 0 |
Return user details from Kakao account | def get_user_details(self, response):
kaccount_email = ""
kakao_account = response.get("kakao_account", "")
if kakao_account:
kaccount_email = kakao_account.get("email", "")
properties = response.get("properties", "")
nickname = properties.get("nickname") if properti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_data(self, access_token, *args, **kwargs):\n return self.get_json(\n \"https://kapi.kakao.com/v2/user/me\",\n headers={\n \"Authorization\": f\"Bearer {access_token}\",\n \"Content_Type\": \"application/x-www-form-urlencoded;charset=utf-8\",\n ... | [
"0.74495924",
"0.7401827",
"0.7308182",
"0.7220801",
"0.7169196",
"0.7113641",
"0.7105932",
"0.70832413",
"0.69508857",
"0.6946847",
"0.69346327",
"0.6913946",
"0.6912289",
"0.6847098",
"0.6845799",
"0.68399817",
"0.6829566",
"0.6815086",
"0.6811426",
"0.6808608",
"0.6788369"... | 0.77409214 | 0 |
Publishes freespace (as measured by e.g. sonar). | def send_free_space(self, distance):
self.client.publish('free_space', str(distance)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def usedspace(self):\n self.log.info(\"freespace\")\n nbytes = 0\n keys = list(self.downloads.keys())\n keys.sort()\n for key in keys:\n download = self.downloads[key]\n nbytes += download['size']\n self.log.info(\"returning:\" + str(nbytes))\n ... | [
"0.61439735",
"0.611649",
"0.59722584",
"0.59080696",
"0.5887496",
"0.5801403",
"0.57203335",
"0.55763495",
"0.5572963",
"0.55633366",
"0.55046725",
"0.54344904",
"0.5423423",
"0.5421534",
"0.5417115",
"0.5363897",
"0.53438485",
"0.53435826",
"0.5342639",
"0.5336582",
"0.5308... | 0.68613786 | 0 |
Fetch data from RRD archive for given period of time. | def _fetch_data(self, rrdObject, startTime, endTime):
#print rrdObject
if not path.exists(rrdObject):
raise Exception("File not exists: %s" % rrdObject)
#print "%s - %s" % (startTime, endTime)
rrd_data = None
try:
rrd_data = rrdtool.fetch(str(rrdObjec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetchOHLC(ticker,interval = \"minute\",duration=4):\r\n data = pd.DataFrame(kite.historical_data(ticker,dt.date.today()-dt.timedelta(duration), dt.date.today(),interval))\r\n data.date =data.date.map(lambda t: t.strftime('%Y-%m-%d %H:%M'))\r\n return data",
"def fetch_data(self, from_date: float, to... | [
"0.59084827",
"0.5897862",
"0.58881354",
"0.5841368",
"0.5826922",
"0.58209974",
"0.5776042",
"0.5727331",
"0.56761867",
"0.56529486",
"0.56008005",
"0.5581093",
"0.5486558",
"0.54823905",
"0.54436505",
"0.5440745",
"0.5436888",
"0.5407445",
"0.53838426",
"0.5374633",
"0.5373... | 0.6730135 | 0 |
Download genotype data the save the out put in .data dir | def download_genotype_data():
print("downloading genotype data")
download_from_url(PSAM_PATH, dst=f"{GENOTYPE_DATA_PATH}/{MERGED_GENOTYPE_FILE}.psam", desc="downloading psam")
download_from_url(PVAR_PATH, dst=f"{GENOTYPE_DATA_PATH}/{MERGED_GENOTYPE_FILE}.pvar.zst",
desc="downloading pv... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_data(self):\n # Command to get the download data\n pass",
"def download_proteome(proteome_id, data_dir, domain=\"Eukaryota\"):\n base = (\"ftp://ftp.uniprot.org/pub/databases/uniprot/current_release/\"\n \"knowledgebase/reference_proteomes\")\n\n url = [base, domain, prote... | [
"0.67733765",
"0.6754389",
"0.65670013",
"0.6480931",
"0.64402175",
"0.64136404",
"0.61601907",
"0.6154601",
"0.6146112",
"0.6115417",
"0.60394645",
"0.60286486",
"0.60172874",
"0.59958476",
"0.59882545",
"0.5964745",
"0.59604585",
"0.5958659",
"0.59532046",
"0.5930072",
"0.5... | 0.87439203 | 0 |
create merged genotype file from psam pvar and pgen | def create_merged_genotype_file(snps_file_path):
print("creating merged genotype file")
plink_runner = Plink2DockerRunner()
shutil.copyfile(snps_file_path, f"{GENOTYPE_DATA_PATH}/{SNP_LIST_FILE_NAME}")
plink_runner(f"./plink2 --pfile {IMAGE_SHARE_FOLDER_PATH}/{GENOTYPE_DATA_FOLDER}/{MERGED_GENOTYPE_FILE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_gmpe_data_file(indata_dir, tmpdir,\n gmpe_file, gmpe_label_file,\n gmpe_group_name):\n # Find SRC file\n basedir = os.path.join(indata_dir, os.listdir(indata_dir)[0])\n src_file = glob.glob(\"%s%s*.src\" % (basedir, os.sep))\n if not len(src_... | [
"0.5435754",
"0.52857256",
"0.52641356",
"0.5249349",
"0.5163392",
"0.5138307",
"0.5133329",
"0.5126286",
"0.51097524",
"0.51070285",
"0.5083355",
"0.50709164",
"0.50644994",
"0.50576615",
"0.5056252",
"0.5051618",
"0.50503314",
"0.50489813",
"0.5036032",
"0.5025411",
"0.5020... | 0.72425526 | 0 |
to initialise vectors, its size and randomly allocated centroids | def initialize(self):
self.SIZE = self.vectors.shape[0]
# todo can use max distance to allocation farthest apart points
self.centroids = self.vectors[[random.randint(1, self.SIZE) for x in range(self.K)], :] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_init(self, train_data):\n\n centroids=np.zeros((self.n_clusters_, train_data.shape[1]))\n for c in range(self.n_clusters_):\n for f in range(train_data.shape[1]):\n centroids[c,f]=random.uniform(min(train_data[:,f]), max(train_data[:,f]))\n\n return centroi... | [
"0.7167922",
"0.70244765",
"0.6918472",
"0.6858616",
"0.68306804",
"0.67281",
"0.6684833",
"0.65676075",
"0.6543686",
"0.64338136",
"0.6385544",
"0.6385496",
"0.6346486",
"0.63083196",
"0.6302265",
"0.62757456",
"0.618771",
"0.6186494",
"0.6182182",
"0.6167982",
"0.6166685",
... | 0.83943045 | 0 |
The action controls the robot using mocaps. Specifically, bodies on the robot (for example the gripper wrist) is controlled with mocap bodies. In this case the action is the desired difference in position and orientation (quaternion), in world coordinates, of the of the target body. The mocap is positioned relative to ... | def mocap_set_action(self, action):
# @Melissa: Action = 3DOF Cartesian Position Delta + Quaternion
if self.sim.model.nmocap > 0:
action, _ = np.split(action, (self.sim.model.nmocap * 7, ))
action = action.reshape(self.sim.model.nmocap, 7)
pos_delta = action[:, :3]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mocap_set_action(sim, action, mocap_low, mocap_high, ee_name): \n if sim.model.nmocap > 0:\n action, _ = np.split(action, (sim.model.nmocap * 7, ))\n action = action.reshape(sim.model.nmocap, 7)\n\n pos_delta = action[:, :3]\n quat_delta = action[:, 3:]\n\n if np.count_non... | [
"0.6857181",
"0.6473455",
"0.6208231",
"0.61743957",
"0.6151875",
"0.6096956",
"0.58196455",
"0.58098626",
"0.57758635",
"0.57689625",
"0.5463688",
"0.5459588",
"0.542433",
"0.5395272",
"0.52858716",
"0.526483",
"0.5258025",
"0.525683",
"0.52174217",
"0.52063286",
"0.5194508"... | 0.7424087 | 0 |
Resets the mocap welds that we use for actuation. | def reset_mocap_welds(self):
if self.sim.model.nmocap > 0 and self.sim.model.eq_data is not None:
for i in range(self.sim.model.eq_data.shape[0]):
if self.sim.model.eq_type[i] == mujoco_py.const.EQ_WELD:
self.sim.model.eq_data[i, :] = np.array(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_mocap_welds(sim):\n if sim.model.nmocap > 0 and sim.model.eq_data is not None:\n for i in range(sim.model.eq_data.shape[0]):\n if sim.model.eq_type[i] == mujoco_py.const.EQ_WELD:\n sim.model.eq_data[i, :] = np.array(\n [0., 0., 0., 1., 0., 0., 0.])\n... | [
"0.72712475",
"0.6722829",
"0.6504008",
"0.6271008",
"0.62297726",
"0.6208428",
"0.6196257",
"0.6191569",
"0.61721665",
"0.6122709",
"0.607302",
"0.60728467",
"0.606244",
"0.6059849",
"0.6052459",
"0.60498244",
"0.60480326",
"0.6044585",
"0.6020971",
"0.6006914",
"0.6000386",... | 0.7608869 | 0 |
Resets the position and orientation of the mocap bodies to the same values as the bodies they're welded to. | def reset_mocap2body_xpos(self):
if (self.sim.model.eq_type is None or
self.sim.model.eq_obj1id is None or
self.sim.model.eq_obj2id is None):
return
for eq_type, obj1_id, obj2_id in zip(self.sim.model.eq_type,
self.sim.mode... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_mocap2body_xpos(sim):\n\n if (sim.model.eq_type is None or\n sim.model.eq_obj1id is None or\n sim.model.eq_obj2id is None):\n return\n for eq_type, obj1_id, obj2_id in zip(sim.model.eq_type,\n sim.model.eq_obj1id,\n ... | [
"0.6893635",
"0.6499374",
"0.6466375",
"0.63432604",
"0.63174415",
"0.6309813",
"0.6250218",
"0.6250218",
"0.6250218",
"0.6227424",
"0.5993534",
"0.59932613",
"0.5980894",
"0.5974436",
"0.5955571",
"0.59437466",
"0.59390795",
"0.5894605",
"0.58935535",
"0.5870204",
"0.5842682... | 0.7228065 | 0 |
Initializes territory selection phase runs until all of the territories in the game world are selected | def init_territory_selection_phase(self):
phase_name = "Territory Selection Phase!\n\n"
selected_territories = 0
while selected_territories < len(self.world.territories):
for i, player in enumerate(self.players):
complain = ""
selected_territory = None... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_initial_state(self):\n # collect the ids of vehicles in the network\n self.ids = self.vehicles.get_ids()\n self.controlled_ids = self.vehicles.get_controlled_ids()\n self.sumo_ids = self.vehicles.get_sumo_ids()\n self.rl_ids = self.vehicles.get_rl_ids()\n\n # dic... | [
"0.54485637",
"0.5442429",
"0.54404324",
"0.53849924",
"0.5252147",
"0.52514434",
"0.5197759",
"0.5194349",
"0.5169358",
"0.51636755",
"0.5162915",
"0.51623625",
"0.5112647",
"0.5089078",
"0.50820476",
"0.50782955",
"0.50541395",
"0.50344735",
"0.5020178",
"0.5017316",
"0.499... | 0.7551169 | 0 |
finds the epipolar lines in two images given a set of pointcorrespondences | def find_epilines(imgLeft, imgRight, ptsLeft, ptsRight, F):
color = []
for i in range(ptsLeft.shape[0]):
color.append(tuple(np.random.randint(0, 255, 3).tolist()))
print(color)
# Find epilines corresponding to points in right image (right image)
linesLeft = cv2.computeCorrespondEpilines(pts... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visualize_epipolar_lines(self, img1, img2, p1, p2, E, save_path):\n # get fundamental matrix\n F, mask_fdm = cv2.findFundamentalMat(p1, p2, cv2.RANSAC)\n p1_selected = p1[mask_fdm.ravel() == 1]\n p2_selected = p2[mask_fdm.ravel() == 1]\n\n # draw lines\n lines1 = cv2.c... | [
"0.70122874",
"0.64854825",
"0.6441403",
"0.63546497",
"0.6317812",
"0.6274026",
"0.6253232",
"0.6238574",
"0.61882734",
"0.6186069",
"0.6170266",
"0.61325264",
"0.6126266",
"0.610908",
"0.6090316",
"0.6057525",
"0.60160977",
"0.6001683",
"0.6000284",
"0.5994642",
"0.5993322"... | 0.7567746 | 0 |
Estimate the p_observations_given_state matrix for a set of observations. If observations is a list/array of length N, returns an array of shape (N, S), where element [t, s] is the probability of the observation at time t assuming the system was in fact in state s. | def __call__(self, observations):
observations = numpy.asarray(observations)
if self.continuous:
state_probabilities = [kde(observations) for kde in self.state_distributions]
else:
state_probabilities = [hist[observations] for hist in self.state_distributions]
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def observation_from_state(self, state):\n state_index = self.latent_variable_markov_chain.index_dict[state]\n return np.random.choice(self.observation_states,\n p=self.emission_probabilities[state_index, :])",
"def viterbi(p_observations_given_state, p_transition, p_initial):... | [
"0.6838239",
"0.58764845",
"0.5864366",
"0.5794693",
"0.57128555",
"0.57071984",
"0.5683988",
"0.55933166",
"0.55871",
"0.5572618",
"0.552575",
"0.55044127",
"0.5496997",
"0.5407656",
"0.53901947",
"0.5342929",
"0.5342017",
"0.52807003",
"0.52772355",
"0.5257948",
"0.5251679"... | 0.6578636 | 1 |
Given a set of state sequences, estimate the initial and transition probabilities for each state (i.e. the p_initial and p_transition matrices needed for HMM inference). | def estimate_hmm_params(state_sequences, pseudocount=1, moving=True, time_sigma=1):
state_sequences = numpy.asarray(state_sequences)
n, t = state_sequences.shape
s = state_sequences.max() + 1 # number of states
initial_counts = numpy.bincount(state_sequences[:,0], minlength=s) + pseudocount
p_initia... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initial_probabilities_from_trajectories(n_states, trajectories):\n p = np.zeros(n_states)\n\n for t in trajectories:\n p[t.transitions()[0][0]] += 1.0\n\n return p / len(trajectories)",
"def init_start_prob(n_states):\n start_prob_est = np.random.rand(n_states, 1)\n start_prob_est /= np... | [
"0.6737312",
"0.6540201",
"0.643304",
"0.64260924",
"0.6414045",
"0.6372045",
"0.6327534",
"0.63086444",
"0.62992555",
"0.62833136",
"0.6242119",
"0.61996263",
"0.61793613",
"0.6153507",
"0.6136968",
"0.6071576",
"0.6045001",
"0.6036908",
"0.6011966",
"0.5985723",
"0.5974724"... | 0.7366758 | 0 |
The bit position getter. | def bit_pos(self):
return self.byte_ptr * 8 + self.bit_ptr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_position(self):\n\n return (self._fileobj.tell() - self._pos) * 8 - self._bits",
"def get_position(self) -> Tuple[int]:\n return self.position.copy()",
"def __getpos__(self, num):\n return self.num_to_pos[num]",
"def get_bit(num, position):\n\treturn (num >> position) & 0b1",
"... | [
"0.70577097",
"0.68061477",
"0.67975134",
"0.6695327",
"0.66924286",
"0.6679596",
"0.66726327",
"0.6656201",
"0.661305",
"0.6570994",
"0.65080434",
"0.64964867",
"0.64851624",
"0.6482087",
"0.6471589",
"0.64665365",
"0.646452",
"0.6454277",
"0.6441795",
"0.64201766",
"0.64042... | 0.8436633 | 0 |
The bit position setter. | def bit_pos(self, bits):
if bits > len(self):
raise BitReaderError('bit_pos(%s) is out of boundary', bits)
self.byte_ptr, self.bit_ptr = divmod(bits, 8) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bit_pos(self):\n\n return self.byte_ptr * 8 + self.bit_ptr",
"def initializeOffsets(self, bitPosition: int, _value: int) -> int:\n\n return bitPosition + self.bitSizeOf()",
"def initializeOffsets(self, bitPosition: int, _value: int) -> int:\n\n return bitPosition + self.bitSizeOf()",
... | [
"0.6843015",
"0.6645116",
"0.6645116",
"0.6591307",
"0.65042365",
"0.6372688",
"0.6217314",
"0.62171125",
"0.61885184",
"0.61506695",
"0.6108199",
"0.6107682",
"0.60736126",
"0.6068757",
"0.6064724",
"0.60437346",
"0.60085493",
"0.6003586",
"0.59972906",
"0.5992333",
"0.59916... | 0.70632917 | 0 |
Read bit_length bits as an integer. | def read(self, bit_length):
ret = self.peek(bit_length)
self.bit_pos += bit_length
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_integer(self, number_of_bits):\n\n value = 0\n\n for _ in range(number_of_bits):\n value <<= 1\n value |= self.read_bit()\n\n return value",
"def extract_bits(data, bit, length=1):\n bits = bitarray(data, endian='big')\n if length > 1:\n out = bits... | [
"0.75628495",
"0.7081306",
"0.6991238",
"0.69427687",
"0.67833155",
"0.677061",
"0.6710745",
"0.65669936",
"0.65387785",
"0.65387785",
"0.65387785",
"0.65387785",
"0.65387785",
"0.65387785",
"0.65387785",
"0.65387785",
"0.65387785",
"0.65387785",
"0.65387785",
"0.65387785",
"... | 0.72332305 | 1 |
Add image to a webfacet. | def upload_webfacet_image(request):
if request.method == 'POST':
imageform=ImageAssetForm(request.POST, request.FILES)
if imageform.is_valid():
webimage = imageform.save(commit=False)
# retrieve the webfacet the image should be associated with
webfacet_id ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_webfacet_image(request):\r\n\r\n if request.method == \"POST\":\r\n add_image_form = AddImageForm(request.POST, request=request)\r\n if add_image_form.is_valid():\r\n webfacet_id = request.POST.get('webfacet')\r\n print \"WEBFACETid: \", webfacet_id\r\n web... | [
"0.6959996",
"0.6487224",
"0.6455513",
"0.62596583",
"0.6204542",
"0.6056155",
"0.6029566",
"0.59842545",
"0.5923838",
"0.5902165",
"0.5883469",
"0.5882552",
"0.5859965",
"0.5838259",
"0.5744651",
"0.57241696",
"0.57239974",
"0.5716125",
"0.5703071",
"0.56786585",
"0.5642951"... | 0.6796275 | 1 |
Add image to a audiofacet. | def upload_audiofacet_image(request):
if request.method == 'POST':
imageform=ImageAssetForm(request.POST, request.FILES)
if imageform.is_valid():
audioimage = imageform.save(commit=False)
# retrieve the audiofacet the image should be associated with
audiof... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_audiofacet_image(request):\r\n\r\n if request.method == \"POST\":\r\n add_image_form = AddImageForm(request.POST, request=request)\r\n if add_image_form.is_valid():\r\n audiofacet_id = request.POST.get('audiofacet')\r\n print \"audioFACETid: \", audiofacet_id\r\n ... | [
"0.66578627",
"0.64728636",
"0.61345947",
"0.60722554",
"0.60476905",
"0.60405284",
"0.59467155",
"0.59415364",
"0.5939142",
"0.5883977",
"0.5809388",
"0.5729445",
"0.56972593",
"0.56908375",
"0.5679853",
"0.56495744",
"0.5649321",
"0.564413",
"0.5638859",
"0.56222016",
"0.56... | 0.66707206 | 0 |
Add image to a videofacet. | def upload_videofacet_image(request):
if request.method == 'POST':
imageform=ImageAssetForm(request.POST, request.FILES)
if imageform.is_valid():
videoimage = imageform.save(commit=False)
# retrieve the videofacet the image should be associated with
videof... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_videofacet_image(request):\r\n\r\n if request.method == \"POST\":\r\n add_image_form = AddImageForm(request.POST, request=request)\r\n if add_image_form.is_valid():\r\n videofacet_id = request.POST.get('videofacet')\r\n print \"videoFACETid: \", videofacet_id\r\n ... | [
"0.6674277",
"0.62054956",
"0.61609864",
"0.6160968",
"0.6141157",
"0.60072285",
"0.598328",
"0.5955084",
"0.591528",
"0.57893074",
"0.57588404",
"0.5740034",
"0.5733411",
"0.57132757",
"0.56607807",
"0.5579022",
"0.55734813",
"0.5563795",
"0.55606425",
"0.5558055",
"0.555533... | 0.65812075 | 1 |
Add existing image(s) in the library to another webfacet. | def add_webfacet_image(request):
if request.method == "POST":
add_image_form = AddImageForm(request.POST, request=request)
if add_image_form.is_valid():
webfacet_id = request.POST.get('webfacet')
print "WEBFACETid: ", webfacet_id
webfacet = get_object_or_4... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_printfacet_image(request):\r\n\r\n if request.method == \"POST\":\r\n add_image_form = AddImageForm(request.POST, request=request)\r\n if add_image_form.is_valid():\r\n printfacet_id = request.POST.get('printfacet')\r\n print \"printFACETid: \", printfacet_id\r\n ... | [
"0.62151027",
"0.59925026",
"0.58333486",
"0.583099",
"0.5817499",
"0.57698077",
"0.5705304",
"0.56660897",
"0.56204855",
"0.56093407",
"0.54203415",
"0.54093826",
"0.5408779",
"0.5378336",
"0.53766954",
"0.5346963",
"0.5326423",
"0.53248286",
"0.530735",
"0.5260022",
"0.5252... | 0.676759 | 0 |
Add existing image(s) in the library to another printfacet. | def add_printfacet_image(request):
if request.method == "POST":
add_image_form = AddImageForm(request.POST, request=request)
if add_image_form.is_valid():
printfacet_id = request.POST.get('printfacet')
print "printFACETid: ", printfacet_id
printfacet = get... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append_component_images(pldm_fw_up_pkg, image_files):\n for image in image_files:\n with open(image, \"rb\") as file:\n for line in file:\n pldm_fw_up_pkg.write(line)",
"def addTextureToOcc(self):\n\t\tshas = self._getShapes()\n\t\tfname, _ = QtGui.QFileDialog.getOpenFileN... | [
"0.57439345",
"0.5572703",
"0.55238974",
"0.5361123",
"0.53004485",
"0.52716833",
"0.52288663",
"0.51478827",
"0.514103",
"0.51245344",
"0.5079901",
"0.5075902",
"0.5065897",
"0.50491333",
"0.5048254",
"0.50375414",
"0.50358367",
"0.50343746",
"0.50187576",
"0.5002619",
"0.49... | 0.63303715 | 0 |
Add existing image(s) in the library to another audiofacet. | def add_audiofacet_image(request):
if request.method == "POST":
add_image_form = AddImageForm(request.POST, request=request)
if add_image_form.is_valid():
audiofacet_id = request.POST.get('audiofacet')
print "audioFACETid: ", audiofacet_id
audiofacet = get... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_image(self, other):\n newcls = self.__class__(None)\n newcls.polygon = self.union(other)\n\n newcls._members = []\n for v in self.members:\n newcls._members.append(v)\n for v in other.members:\n if v not in newcls._members:\n newcls._m... | [
"0.60004723",
"0.58277434",
"0.5797199",
"0.5697797",
"0.5677714",
"0.5672392",
"0.56353205",
"0.5634928",
"0.5560553",
"0.5501598",
"0.5486434",
"0.54514974",
"0.53752357",
"0.5367797",
"0.53480774",
"0.5342311",
"0.53182214",
"0.5294023",
"0.5289791",
"0.528354",
"0.5255328... | 0.63307816 | 0 |
Given list of ``Tag`` instances, creates a string representation of the list suitable for editing by the user, such that submitting the given string representation back without changing it will give the same list of tags. Tag names which contain DELIMITER will be double quoted. Adapted from Taggit's _edit_string_for_ta... | def join_tags(tags):
names = []
delimiter = settings.TAGGIT_SELECTIZE['DELIMITER']
for tag in tags:
name = tag.name
if delimiter in name or ' ' in name:
names.append('"%s"' % name)
else:
names.append(name)
return delimiter.join(sorted(names)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_string_for_tags(tags):\r\n names = []\r\n use_commas = False\r\n for tag in tags:\r\n name = tag.name\r\n if u',' in name:\r\n names.append('\"%s\"' % name)\r\n continue\r\n elif u' ' in name:\r\n if not use_commas:\r\n use_comm... | [
"0.74842143",
"0.61348253",
"0.60322964",
"0.60187674",
"0.5813906",
"0.5634633",
"0.5617626",
"0.55532956",
"0.55511045",
"0.5493373",
"0.54873353",
"0.5473861",
"0.5438646",
"0.54261506",
"0.54241925",
"0.53745574",
"0.53239423",
"0.52918303",
"0.52737874",
"0.5259001",
"0.... | 0.64570826 | 1 |
Goes to form with AMOUNT_OF_COURSES text boxes to input courses to schedule, form action=/schedules, method=POST | def how_many_post():
default_courses = ['CS 442', 'CS 392', 'CS 519', 'MA 331']
resp = make_response(render_template(
"sched_entry.html",
quantity=AMOUNT_OF_COURSES,
title='Scheduler',
default_vals=default_courses))
resp.set_cookie('course_combos', '', expires=0)
return r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_form_post():\n text_list = []\n #make list of form inputs\n for i in range(1, AMOUNT_OF_COURSES + 1):\n form_num = 'text' + str(i)\n text_list.append(request.form[form_num])\n #remove items with no input, generate string of courses\n final_list = []\n for text in text_list:\n... | [
"0.7359131",
"0.5738121",
"0.56755453",
"0.56118274",
"0.5451969",
"0.5445266",
"0.5368269",
"0.5310079",
"0.5273463",
"0.5239701",
"0.52320564",
"0.5225265",
"0.52122545",
"0.5199207",
"0.5196593",
"0.5195842",
"0.5134032",
"0.51298195",
"0.5128839",
"0.5125523",
"0.5111229"... | 0.6717341 | 1 |
Gets input from form, puts it in a list, gets the schedules, send JSON of course combinations and send then to /sched as a cookie | def my_form_post():
text_list = []
#make list of form inputs
for i in range(1, AMOUNT_OF_COURSES + 1):
form_num = 'text' + str(i)
text_list.append(request.form[form_num])
#remove items with no input, generate string of courses
final_list = []
for text in text_list:
if not... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scheduleMe(page):\n querystring_combos = request.cookies.get('course_combos')\n if not querystring_combos:\n return render_template('404.html'), 404\n combos = json.loads(querystring_combos)\n #print querystring_combos\n\n count = len(combos)\n pagination_needed = count > PER_PAGE\n ... | [
"0.65634745",
"0.64576983",
"0.62224543",
"0.6023303",
"0.5766378",
"0.5760955",
"0.5739446",
"0.5460604",
"0.5388673",
"0.5352139",
"0.5332513",
"0.53309214",
"0.5291213",
"0.5275477",
"0.524384",
"0.524187",
"0.52391493",
"0.52390355",
"0.5194757",
"0.51929027",
"0.5184178"... | 0.81814945 | 0 |
Upon a GET request containing csv course names in a query string... Find the combos and send them as JSON | def getCombosAPI():
all_args = request.args.lists()
course_list = all_args[0][1][0].split(",")
u_COURSE_LIST = map((lambda x: x.upper()), course_list)#make all caps just in case
COURSE_LIST = map( str, u_COURSE_LIST)#unicode list -> list of python strs
combos = scheduler.schedule(COURSE_LIST)
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_courses(self):\n\n self.search([]).unlink()\n token = self.env['odoo.moodle'].search([('create_uid', '=', self.env.user.id)]).token\n domain = \"http://localhost:8888\"\n webservice_url = \"/webservice/rest/server.php?\"\n parameters = {\n \"wstoken\":token,\n ... | [
"0.6156919",
"0.6040665",
"0.60034776",
"0.5928247",
"0.5916178",
"0.5860666",
"0.58110094",
"0.57956994",
"0.5633802",
"0.5619331",
"0.5583209",
"0.5545663",
"0.5522311",
"0.5501062",
"0.54804116",
"0.5449549",
"0.54390436",
"0.5390255",
"0.53620845",
"0.53605145",
"0.534555... | 0.68711597 | 0 |
Returns the set of combos for the current page | def getCombosForPage(page_num, per_page, count_of_combos, combos):
combos_start = (per_page * (page_num - 1)) + 1
combos_end = combos_start + per_page
these_combos = {}
for key in range(combos_start, combos_end):
try:
# if new dict is not an int schedules are not sorted on the page
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combos():\n print 'Loading combo info page'\n\n test_data_folder = os.path.join('data', 'testdata')\n base_file_name = 'CU-PENN.dvw'\n base_file_key = os.path.join(test_data_folder, base_file_name)\n\n parser = Parser(base_file_key)\n combo_list = parser.read_combos()\n\n combo_dicts = [{'... | [
"0.66509014",
"0.61322004",
"0.5766209",
"0.56483555",
"0.5634054",
"0.56314075",
"0.5607587",
"0.55948377",
"0.55948377",
"0.55948377",
"0.55948377",
"0.55781025",
"0.55628926",
"0.5496233",
"0.54629517",
"0.54608715",
"0.5457087",
"0.54336566",
"0.54232746",
"0.54089713",
"... | 0.6515991 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.