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 |
|---|---|---|---|---|---|---|
Remaining retention days for soft deleted blob container. | def remaining_retention_days(self) -> int:
return pulumi.get(self, "remaining_retention_days") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def soft_delete_retention_days(self) -> int:\n return pulumi.get(self, \"soft_delete_retention_days\")",
"def retention_days(self) -> Optional[int]:\n return pulumi.get(self, \"retention_days\")",
"def container_delete_retention_policy(self) -> pulumi.Output[Optional['outputs.DeleteRetentionPolic... | [
"0.7603276",
"0.65898246",
"0.6585647",
"0.65824777",
"0.65142",
"0.6479939",
"0.6467616",
"0.6465218",
"0.63896096",
"0.63780963",
"0.6276856",
"0.62488556",
"0.6040693",
"0.57856303",
"0.5741927",
"0.56296825",
"0.5572426",
"0.551001",
"0.54318726",
"0.5428414",
"0.5401405"... | 0.7409727 | 1 |
Sens a UDP message via the socket to the given address with type and data set in JSON. | def send_udp_message(socket, address, type, data=None):
if data:
data = json.dumps({"type": type, "payload": data})
else:
data = json.dumps({"type": type})
socket.sendto(data.encode('utf-8'), address) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_udp_message(message, address, port):\n message = message.replace(\" \", \"\").replace(\"\\n\", \"\")\n server_address = (address, port)\n\n sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n try:\n sock.sendto(binascii.unhexlify(message), server_address)\n while True:\n ... | [
"0.65182334",
"0.640981",
"0.6338695",
"0.63228166",
"0.6134314",
"0.5987276",
"0.5883124",
"0.5879312",
"0.58444864",
"0.57027066",
"0.5695698",
"0.5671299",
"0.5648142",
"0.56114036",
"0.5576119",
"0.5567164",
"0.5557832",
"0.54959226",
"0.5475113",
"0.54397607",
"0.54274",... | 0.78338253 | 0 |
Reads a UDP message from the socket and unpacks it. | def read_udp_message(socket):
data, address = socket.recvfrom(4096)
data = data.decode('utf-8')
return json.loads(data), address | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def receive(ip_addr: str, port: int, verbose: bool):\n # Set the socket up to run across internet and to use UDP\n sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n\n # Bind our socket to the passed in IP and port num\n sock.bind((ip_addr, port))\n\n # Recieve the data as well as the address... | [
"0.67826957",
"0.67741454",
"0.6620306",
"0.65950114",
"0.65682864",
"0.64103115",
"0.6386263",
"0.6375209",
"0.6353924",
"0.62689763",
"0.62628776",
"0.6123567",
"0.60778254",
"0.6071863",
"0.60564744",
"0.60325295",
"0.6018941",
"0.59848607",
"0.59734106",
"0.59629494",
"0.... | 0.7599172 | 0 |
handles input signals and mute/unmute based on track ID | def catchall_handler(*args, **kwargs):
if len(args) < 2 or args[0] != 'org.mpris.MediaPlayer2.Player':
return
song_id = args[1]['Metadata']['mpris:trackid']
if not muted and song_id.startswith(AD_ID):
mute()
elif muted and not song_id.startswith(AD_ID):
time.sleep(1.5) # Adding... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def muteTrack(*args, **kwargs):\n pass",
"def handle_mic_mute(_):\n loop.mute()",
"def mute_track(self, track, muted):\n pass",
"def handle_mic_unmute(_):\n loop.unmute()",
"def set_mute(self, track, xclip, ident, value = None):\n if track in self.song().tracks + self.song().return_t... | [
"0.65304595",
"0.6339425",
"0.6325003",
"0.6031489",
"0.5687142",
"0.5567052",
"0.5485761",
"0.5447387",
"0.5431867",
"0.53983545",
"0.5398304",
"0.5394474",
"0.5392154",
"0.5367019",
"0.5357461",
"0.5290992",
"0.52583945",
"0.5227433",
"0.52081877",
"0.5205605",
"0.5202482",... | 0.6683075 | 0 |
Set up signal receiver and start spotify | def main():
global loop
DBusGMainLoop(set_as_default=True)
loop = gobject.MainLoop()
bus = dbus.SessionBus()
bus.add_signal_receiver(catchall_handler,
dbus_interface="org.freedesktop.DBus.Properties")
threading.Thread(target=run_spotify).start()
loop.run() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_start(self):\n pass",
"def on_start(self):\n pass",
"def on_start(self):\n pass",
"def on_start(self):\n pass",
"def on_start(self):\n pass",
"def on_start(self):\n pass",
"def on_start(self):\n pass",
"def on_start(self):\n pass",
"def... | [
"0.6382936",
"0.6382936",
"0.6382936",
"0.6382936",
"0.6382936",
"0.6382936",
"0.6382936",
"0.6382936",
"0.63633436",
"0.63633436",
"0.6271748",
"0.61065465",
"0.6099642",
"0.6099289",
"0.6014195",
"0.6002303",
"0.5966543",
"0.59562826",
"0.59325296",
"0.59325296",
"0.5928347... | 0.6614646 | 0 |
helper function to read a single line from a file | def read_line(filename):
line = "Unknown"
try:
with open(filename) as f:
line = f.readline().strip()
finally:
return line | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_line(f):\n line = f.readline()\n if len(line) == 0:\n raise EOFError\n return line.rstrip()",
"def _read_one_line_file(name):\n with open(name, \"rb\") as file:\n data = file.read()\n return data.decode('utf-8').strip()",
"def next_line(the_file):\n line... | [
"0.7692665",
"0.75832075",
"0.7388899",
"0.7388899",
"0.73823714",
"0.7378581",
"0.7341703",
"0.72553897",
"0.7247761",
"0.72475743",
"0.70941657",
"0.7032835",
"0.7032835",
"0.69336134",
"0.6877057",
"0.68571943",
"0.6774676",
"0.67604446",
"0.6748443",
"0.66357327",
"0.6625... | 0.79594934 | 0 |
given a path to a usb device in sysfs, return a string describing it | def usb_sysfs_hw_string(sysfs_path):
snr = read_line(sysfs_path + '/serial')
if snr:
snr_txt = '%s' % (snr,)
else:
snr_txt = ''
if doPrintVendorID:
return 'USB VID:PID=%s:%s SNR=%s' % (
read_line(sysfs_path + '/idVendor'),
read_line(sysfs_path + '/... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def describe(device):\n base = os.path.basename(device)\n # USB-Serial devices\n sys_dev_path = '/sys/class/tty/%s/device/driver/%s' % (base, base)\n if os.path.exists(sys_dev_path):\n sys_usb = os.path.dirname(os.path.dirname(os.path.realpath(sys_dev_path)))\n return usb_string(sys_usb)\... | [
"0.7606253",
"0.70159906",
"0.65955526",
"0.65890044",
"0.6562016",
"0.6427426",
"0.624008",
"0.6222067",
"0.61899215",
"0.61851984",
"0.614794",
"0.6138752",
"0.61170495",
"0.60925347",
"0.60876894",
"0.6081939",
"0.60774773",
"0.6035167",
"0.6034503",
"0.6031892",
"0.602000... | 0.7734423 | 0 |
Get a human readable description. For USBSerial devices try to run lsusb to get a human readable description. For USBCDC devices read the description from sysfs. | def describe(device):
base = os.path.basename(device)
# USB-Serial devices
sys_dev_path = '/sys/class/tty/%s/device/driver/%s' % (base, base)
if os.path.exists(sys_dev_path):
sys_usb = os.path.dirname(os.path.dirname(os.path.realpath(sys_dev_path)))
return usb_string(sys_usb)
# Ardu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_description(self):\n\t\treturn call_sdk_function('PrlVmDev_GetDescription', self.handle)",
"def desc(name):\n\n # This includes several different methods to try and get the desc. If\n # one fails, try the next.\n try:\n with open(os.path.join('/sys/class/input', name, 'de... | [
"0.7142649",
"0.7044011",
"0.6878384",
"0.67932856",
"0.67932856",
"0.6790387",
"0.6764138",
"0.67578316",
"0.67369276",
"0.6701573",
"0.66901016",
"0.66879094",
"0.6687814",
"0.6669273",
"0.6669273",
"0.66512156",
"0.66052914",
"0.66052914",
"0.65827566",
"0.65756655",
"0.65... | 0.7570059 | 0 |
Try to get a HW identification using sysfs | def hwinfo(device):
base = os.path.basename(device)
if os.path.exists('/sys/class/tty/%s/device' % (base,)):
# PCI based devices
sys_id_path = '/sys/class/tty/%s/device/id' % (base,)
if os.path.exists(sys_id_path):
return read_line(sys_id_path)
# USB-Serial devices
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_hardware_id():\r\n try:\r\n return utils.run('crossystem hwid').stdout.strip()\r\n except:\r\n logging.info(\"Not Found\")\r\n return -1",
"def _get_system_hardware(self):\n return self._get_system_status()[\"hardware\"]",
"def usb_sysfs_hw_string(sysfs_path):\n snr = r... | [
"0.74944115",
"0.71442604",
"0.71081996",
"0.68066007",
"0.67603415",
"0.6648561",
"0.6489683",
"0.64582026",
"0.6290594",
"0.6254846",
"0.62130994",
"0.619794",
"0.6190729",
"0.6129336",
"0.6081687",
"0.60806364",
"0.60647136",
"0.60367924",
"0.6014794",
"0.60136855",
"0.600... | 0.7575497 | 0 |
Create new record or replace existing record if it has the same holder barcode as the most recent record. Save to backing store. | def merge_record(self, holder_barcode, plate, holder_img, pins_img):
if self.records and self.records[0].holder_barcode == holder_barcode:
self.delete_records([self.records[0]])
self._add_record(holder_barcode, plate, holder_img, pins_img) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_record(self, holder_barcode, plate, holder_img, pins_img):\n guid = str(uuid.uuid4())\n self._store_writer.to_image(pins_img, holder_img, guid)\n img_path = self._store_writer.get_img_path()\n holder_image_path = self._store_writer.get_holder_img_path()\n record = Record... | [
"0.6826699",
"0.6639652",
"0.59140694",
"0.5705957",
"0.56990135",
"0.56887066",
"0.5672744",
"0.55546737",
"0.55532664",
"0.548633",
"0.5449741",
"0.54300094",
"0.5424234",
"0.54038393",
"0.537593",
"0.5366054",
"0.53530633",
"0.53473806",
"0.53452706",
"0.53235084",
"0.5318... | 0.7069348 | 0 |
Sort the records and save to file. | def _process_change(self):
self._sort_records()
self._store_writer.to_file(self.records)
self._store_writer.to_csv_file(self.records) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sort_records(self):\n self.records.sort(reverse=True, key=lambda record: record.timestamp)",
"def sorting_and_save(self, content):\n if content is None:\n logging.warn(\"Content is null\")\n return\n try:\n arr = content.split()\n with open(se... | [
"0.6630066",
"0.6510317",
"0.6134179",
"0.6009877",
"0.5982607",
"0.5953085",
"0.5943169",
"0.59402925",
"0.59370655",
"0.5929697",
"0.58718467",
"0.579221",
"0.57310385",
"0.57219607",
"0.5708639",
"0.56859297",
"0.5652638",
"0.5637352",
"0.5590723",
"0.5583001",
"0.5577339"... | 0.6992248 | 0 |
Sort the records in descending date order (most recent first). | def _sort_records(self):
self.records.sort(reverse=True, key=lambda record: record.timestamp) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_records(records):\n return sorted(records, key=lambda r: r.value.event.datetime, reverse=True)",
"def sort_time(self):\n self.entries.sort(key=lambda x: x.date_stamp_utc)",
"def sort_records_by_dob(records):\n return sorted(records, key=lambda x: x.dob)",
"def sort_and_reduce(self):\n ... | [
"0.7662122",
"0.6944911",
"0.67218864",
"0.6682471",
"0.6621681",
"0.6610427",
"0.6584499",
"0.6513622",
"0.6381109",
"0.6349682",
"0.63240045",
"0.63010275",
"0.6152952",
"0.61023664",
"0.60990214",
"0.6057141",
"0.60555905",
"0.60545504",
"0.6040389",
"0.60319525",
"0.60306... | 0.82427233 | 0 |
Create a Digest from content (in a given namespace) for preupload. | def generate_digest(namespace, content):
return handlers_endpoints_v1.Digest(
digest=hash_content(namespace, content), size=len(content)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def digest_begin(self): # real signature unknown; restored from __doc__\n pass",
"def get_content_sha1(self):",
"def digest(self, *args, **kwargs): # real signature unknown\n pass",
"def digest(self, *args, **kwargs): # real signature unknown\n pass",
"def digest(self, *args, **kwargs)... | [
"0.5254694",
"0.52127886",
"0.514883",
"0.514883",
"0.514883",
"0.514883",
"0.514883",
"0.514883",
"0.5093403",
"0.5093403",
"0.5093403",
"0.50524306",
"0.5039486",
"0.49740633",
"0.48718596",
"0.4848608",
"0.48375",
"0.48369282",
"0.48308003",
"0.47762486",
"0.47327024",
"... | 0.63486344 | 1 |
Create a Storage/FinalizeRequest corresponding to a PreuploadStatus. | def preupload_status_to_request(preupload_status, content):
ticket = preupload_status.get('upload_ticket')
url = preupload_status.get('gs_upload_url', None)
if url is not None:
return handlers_endpoints_v1.FinalizeRequest(upload_ticket=ticket)
return handlers_endpoints_v1.StorageRequest(
upload_ticket... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_request(self, namespace, content):\n collection = generate_collection(namespace, [content])\n response = self.call_api('preupload', message_to_dict(collection), 200)\n message = response.json.get(u'items', [{}])[0]\n return preupload_status_to_request(message, content)",
"def store_request(... | [
"0.5977701",
"0.59610534",
"0.5534168",
"0.5142167",
"0.5142167",
"0.5142167",
"0.5142167",
"0.5142167",
"0.49813625",
"0.4981096",
"0.4981096",
"0.4979155",
"0.4956969",
"0.49372947",
"0.48857424",
"0.48589066",
"0.48586586",
"0.48257098",
"0.48228",
"0.48042032",
"0.4790732... | 0.8152911 | 1 |
Cache the value of a function until the desired file changes. | def file_memoize(fname):
def wrapper(fn):
# Store these in lists so inner can access them
last_update = {}
cached_values = {}
@functools.wraps(fn)
def inner(*args):
file_mtime = os.path.getmtime(fname)
if args not in cached_values or file_mtime > last... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_function(self, func):\n\n @wraps(func)\n def wrapper(*args):\n if self.__log:\n self.__logger.info(f\"Called {func.__name__} with {args}\")\n fileName = self.__build_file_name(func, args)\n\n if os.path.isfile(fileName):\n # Res... | [
"0.720604",
"0.67948097",
"0.66382027",
"0.6582363",
"0.6535072",
"0.6453462",
"0.64014256",
"0.63990355",
"0.6389076",
"0.63873917",
"0.6344661",
"0.63035446",
"0.62770283",
"0.62614775",
"0.62434876",
"0.6241331",
"0.62016994",
"0.6199149",
"0.61901593",
"0.61833733",
"0.61... | 0.6807073 | 1 |
Yield each of the lab openclose ranges as start and stop datetimes. | def iter_ranges(logfile):
current_start = None
for line in logfile:
date = datetime.strptime(line[:19], '%Y/%m/%d %H:%M:%S')
if line[20:] == 'Received request: open\n':
if current_start is None:
current_start = date
elif line[20:] == 'Received request: close\n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_range(start, stop):\n for n in range(int((stop - start).days)):\n yield start + timedelta(n)",
"def _drange(start: Date, end: Date) -> Iterator[Date]:\n while start <= end:\n yield start\n start = start + TimeDelta(days=1)",
"def date_range(start, stop, step=date... | [
"0.60931253",
"0.6043652",
"0.59107965",
"0.586885",
"0.58392316",
"0.57898676",
"0.57893485",
"0.5785012",
"0.5764881",
"0.56708515",
"0.5667553",
"0.5639976",
"0.56248677",
"0.56022716",
"0.5601227",
"0.5587146",
"0.5572767",
"0.5556205",
"0.5519697",
"0.5514681",
"0.549542... | 0.6058507 | 1 |
If obj contains key and its value is a valid date, return the date. Otherwise, return None. | def get_date_or_none(obj, key):
try:
return datetime.strptime(obj[key], '%Y-%m-%d')
except (KeyError, ValueError):
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_date(filing: Dict, path: str) -> date:\n try:\n raw = dpath.util.get(filing, path)\n return date.fromisoformat(raw)\n except (IndexError, KeyError, TypeError, ValueError):\n return None",
"def autocast(o_key, value):\n if not isinstance(o_key, (str, unicode)):\n ret... | [
"0.6251335",
"0.61490345",
"0.60113055",
"0.5877569",
"0.5866413",
"0.5852391",
"0.58249456",
"0.5803112",
"0.5802971",
"0.5770974",
"0.5739042",
"0.57100016",
"0.5707882",
"0.5703599",
"0.5634237",
"0.5633141",
"0.5575378",
"0.5513639",
"0.5437365",
"0.5424837",
"0.5424686",... | 0.86701906 | 0 |
Dilation e.g. for cloud and cloud/terrain shadow | def dilate(array):
# kernel = [[1] * 7] * 7 # blocky 3-pixel dilation
y, x = np.ogrid[-3:4, -3:4]
kernel = ((x * x) + (y * y) <= 3.5**2) # disk-like 3-pixel radial dilation
return scipy.ndimage.binary_dilation(array, structure=kernel) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dilate(img, kernel = (5,5), iterations = 1):\n\ttmp = grayscale(img)\n\tk = np.ones(kernel, np.uint8)\n\tdilation = cv2.dilate(tmp, k, iterations = iterations)\n\treturn dilation",
"def grass_drass():",
"def dilating_image(image, kn, i):\n\n kernel_dlt = np.ones((kn, kn), np.uint8)\n\n dilation = cv2... | [
"0.60380554",
"0.59759533",
"0.5890122",
"0.58306825",
"0.5816742",
"0.57814837",
"0.57552636",
"0.57525986",
"0.5750691",
"0.56951356",
"0.56864643",
"0.56534505",
"0.56488657",
"0.564674",
"0.5578061",
"0.5468445",
"0.54215384",
"0.54208046",
"0.53777474",
"0.535536",
"0.53... | 0.6221012 | 0 |
nms_pos, nms_prob, and gt_pos are lists of numpy arrays specifying detection position, detection probability and GT position. Each list entry is a different file. Each entry in nms_pos is an array of length num_entries. For nms_prob and gt_pos its an array of size (num_entries, 1). durations is a array of the length of... | def prec_recall_1d(nms_pos_o, nms_prob_o, gt_pos_o, durations, detection_overlap, win_size, remove_eof=True):
if remove_eof:
# filter out the detections in both ground truth and predictions that are too
# close to the end of the file - dont count them during eval
nms_pos, nms_prob, gt_pos =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_detections(ground_truth, predictions, class_name, overlap_threshold=0.5,\n allow_multiple_matches_per_ignored=True,\n verbose=True):\n\n Detection = namedtuple('Detection', ['image', 'bbox', 'score', 'gt_match'])\n GT = namedtuple('GroundTruth', ['bb... | [
"0.5781365",
"0.5635635",
"0.55106544",
"0.55041724",
"0.5294834",
"0.5286687",
"0.5204303",
"0.52004194",
"0.514912",
"0.5121422",
"0.5106426",
"0.5091037",
"0.50691056",
"0.5037461",
"0.50349545",
"0.5033584",
"0.5007368",
"0.5005097",
"0.49918944",
"0.4976583",
"0.49547723... | 0.74757457 | 0 |
Vocabulary factory for talk track options | def trackVocabulary(context):
ct = getToolByName(context,'portal_catalog')
tracks = ct.searchResults(portal_type='apyb.papers.track', sort_on='getObjPositionInParent')
items = [SimpleTerm(b.UID,b.UID,b.Title) for b in tracks]
return SimpleVocabulary(items) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vocab():\n symbols = DEFAULT_SPECIAL_SYMBOLS + [\"mouse\", \"dog\", \"tree\"]\n return Vocabulary(symbols)",
"def getVocabulary(self): # real signature unknown; restored from __doc__\n pass",
"def speakersVocabulary(context):\n ct = getToolByName(context,'portal_catalog')\n dictSearch = ... | [
"0.6435355",
"0.6372042",
"0.60669035",
"0.5965872",
"0.58536285",
"0.5845328",
"0.5772159",
"0.5734506",
"0.5650804",
"0.5592767",
"0.5447777",
"0.54062873",
"0.53616786",
"0.5274424",
"0.5269094",
"0.5249436",
"0.52348447",
"0.52293754",
"0.52257395",
"0.5206178",
"0.517921... | 0.69906795 | 0 |
Vocabulary factory for speakers | def speakersVocabulary(context):
ct = getToolByName(context,'portal_catalog')
dictSearch = {'portal_type':'apyb.papers.speaker','sort_on':'sortable_title'}
speakers = ct.searchResults(**dictSearch)
speakers = [SimpleTerm(b.UID,b.UID,b.Title) for b in speakers]
return SimpleVocabulary(speakers) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vocab():\n symbols = DEFAULT_SPECIAL_SYMBOLS + [\"mouse\", \"dog\", \"tree\"]\n return Vocabulary(symbols)",
"def getVocabulary(self): # real signature unknown; restored from __doc__\n pass",
"def vocabulary(self, config=Config()):\n raise NotImplementedError(\"Class %s doesn't implemen... | [
"0.7067296",
"0.69267315",
"0.6728168",
"0.6483753",
"0.6334042",
"0.61614317",
"0.5988837",
"0.5967823",
"0.5956461",
"0.59522575",
"0.59491456",
"0.590299",
"0.5891059",
"0.5870922",
"0.58575344",
"0.5845206",
"0.578708",
"0.5779765",
"0.57536083",
"0.5741004",
"0.5696296",... | 0.74610883 | 0 |
Player has spun "nun"; this is a noop. | def do_nothing(self, player):
return '%s spins \'nun\' and does nothing.' % (player,) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_not_unopposed(self):\n s1 = self.battle.create_skirmish(self.alice, 2) # Attack 2\n s1.react(self.bob, 1) # --Attack 1\n s1.resolve()\n self.assertFalse(s1.unopposed)",
"def process(self, player):\n if player.has_sword():\n retu... | [
"0.5981257",
"0.5823792",
"0.57996505",
"0.57667667",
"0.57367903",
"0.5706391",
"0.5693054",
"0.56522876",
"0.5648075",
"0.5566805",
"0.55660844",
"0.55660594",
"0.5562009",
"0.5561571",
"0.5554415",
"0.5479602",
"0.5469468",
"0.5461365",
"0.54535997",
"0.5450532",
"0.544060... | 0.7388114 | 0 |
Player has spun "gimel" and gets everything in the pot. | def give_all(self, player):
self.transfer(self, player, self.account.balance)
return '%s spins \'gimel\' and gets everything.' % (player,) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zapisi_pot(pot):",
"def zapisi_pot(pot):",
"def zapisi_pot(pot):",
"def zapisi_pot(pot):",
"def zapisi_pot(pot):",
"def zapisi_pot(pot):",
"async def play_gun(game_state) -> None:\n play_weapon(game_state, Supply.GUN)",
"async def get_pots(self):\n return await self.get_states_by_tag_pr... | [
"0.6314113",
"0.6314113",
"0.6314113",
"0.6314113",
"0.6314113",
"0.6314113",
"0.5898333",
"0.5802323",
"0.5621155",
"0.55983734",
"0.5502525",
"0.54629385",
"0.54629385",
"0.54629385",
"0.54629385",
"0.54629385",
"0.5406731",
"0.5322075",
"0.5306998",
"0.53033155",
"0.530310... | 0.6338415 | 0 |
Player has spun "hey" and gets half of the pot, rounded up. | def give_half(self, player):
self.transfer(
self,
player,
int(ceil(self.account.balance/2.0))
)
return '%s spins \'hey\' and gets half.' % (player,) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def punch(self):\n # you are not working, futher investagtion needed...\n if self.weight < 5:\n return \"That tickles.\"\n elif self.weight < 15:\n return \"Hey that hurt!\"\n else:\n return \"OUCH!\"",
"def punch(self):\n if self.weight < 5.0:\... | [
"0.6459758",
"0.64262986",
"0.64061284",
"0.6385781",
"0.62437606",
"0.5964058",
"0.58923566",
"0.5855951",
"0.5799146",
"0.5718551",
"0.56614166",
"0.5649295",
"0.5621195",
"0.56117743",
"0.55970484",
"0.5595939",
"0.55939186",
"0.5567364",
"0.55237484",
"0.5508335",
"0.5494... | 0.7100421 | 0 |
Player has spun "shin" and has to put in a certain amount. | def take(self, player):
self.transfer(player, self, self.shin_amount)
return '%s spins \'shin\' and puts in %d.' % (player,
self.shin_amount) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def giveSmoke(self, amount):\n self.sg = amount\n if amount > 0:\n es.give(self.userid, \"weapon_smokegrenade\")",
"def __init__(self, players, initial_amount=10, shin_amount=1):\n \n # validate the numeric arguments:\n # initial amount has to be at least 2,\n ... | [
"0.64244854",
"0.63369477",
"0.6165752",
"0.6135867",
"0.6106612",
"0.60930175",
"0.6077653",
"0.6045193",
"0.6035751",
"0.5996051",
"0.59521586",
"0.5916642",
"0.5915506",
"0.5896164",
"0.5849925",
"0.5849198",
"0.58461815",
"0.58388364",
"0.582254",
"0.5771939",
"0.57620144... | 0.7585761 | 0 |
Sets the recipient_email of this GiftDetails. | def recipient_email(self, recipient_email):
self._recipient_email = recipient_email | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recipient(self, recipient):\n\n self._recipient = recipient",
"def email(self, email):\n\n self._email = email",
"def email(self, email):\n\n self._email = email",
"def email(self, email):\n\n self._email = email",
"def email(self, email):\n\n self._email = email",
... | [
"0.7003676",
"0.655063",
"0.655063",
"0.655063",
"0.655063",
"0.655063",
"0.655063",
"0.655063",
"0.655063",
"0.655063",
"0.655063",
"0.6463328",
"0.6463328",
"0.6395344",
"0.6375733",
"0.6240201",
"0.6240201",
"0.6240201",
"0.62081444",
"0.6160627",
"0.61436236",
"0.605806... | 0.824746 | 0 |
Sets the sender_name of this GiftDetails. | def sender_name(self, sender_name):
self._sender_name = sender_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sender(self, sender: str):\n if sender is None:\n raise ValueError(\"Invalid value for `sender`, must not be `None`\") # noqa: E501\n\n self._sender = sender",
"def sender(self, sender: Address) -> None:\n enforce(\n isinstance(sender, str), f\"Sender must be strin... | [
"0.71977746",
"0.7106946",
"0.65814424",
"0.62214434",
"0.62214434",
"0.61114466",
"0.61114466",
"0.61114466",
"0.61114466",
"0.61114466",
"0.60985005",
"0.60284305",
"0.60284305",
"0.5976745",
"0.5976745",
"0.59699434",
"0.5942325",
"0.59321296",
"0.59235996",
"0.5812395",
"... | 0.8307557 | 0 |
make a single deletion request per bunch of datasets Filtering only the INVALID or DEPRECATED ones | def makeDeletionRequests(url, allDatasets, verbose=False, test=False):
#delete duplicates
datasets = list(set(allDatasets))
#group datasets by sites
requests = {}
for ds in datasets:
try:
t = dbs.getDatasetStatus(ds)
if verbose:
print ds, 'is... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def purge_dataset(request):\n data = json.loads(request.body.decode('utf-8'))\n if not request.user.is_staff:\n return JsonResponse({'error': 'Only admin can purge dataset'}, status=403)\n try:\n dset = models.Dataset.objects.get(pk=data['item_id'])\n except models.Dataset.DoesNotExist:\n... | [
"0.64524555",
"0.64497876",
"0.6245465",
"0.62270623",
"0.6146194",
"0.6072038",
"0.606238",
"0.5993247",
"0.5993221",
"0.5946118",
"0.5907852",
"0.58622974",
"0.58615917",
"0.58615917",
"0.58615917",
"0.58615917",
"0.58414334",
"0.5839086",
"0.580446",
"0.5765579",
"0.575155... | 0.6861733 | 0 |
This function makes sure the link is an amazon.com link. | def urlValidator(url):
if 'amazon.com/' not in url:
print('ERROR: Please enter a valid amazon.com URL. (ERROR 1)')
else:
validURL = url
if 'Amazon.com/' not in url:
print('ERROR: Please enter a valid amazon.com URL. (ERROR 2)')
else:
validURL = url
return validURL | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_amazon() -> bool:\n if amazon_public_address():\n return True\n else:\n return False",
"def isValidURL(self, url):\n if \"imdb.com\" in url:\n return True\n else:\n return False",
"def is_href_valid(self, link):\n url = str(link['href'])\n ... | [
"0.6950918",
"0.5862666",
"0.5835146",
"0.56849533",
"0.5627608",
"0.5601782",
"0.55941004",
"0.5575757",
"0.5573196",
"0.55288863",
"0.5517786",
"0.54667896",
"0.5390702",
"0.5375992",
"0.53514016",
"0.533296",
"0.530206",
"0.5270406",
"0.5261524",
"0.52614176",
"0.525825",
... | 0.61025023 | 1 |
Auxiliary price extraction function. Gets price of 'Deal of the Day'. | def priceGetDeal(soup):
price = soup.find('td', id='priceblock_dealprice', class_='a-color-price a-size-medium')
price = price.text
priceList = price.split()
price = priceList[0]
price = price.strip()
price = price.lstrip('$')
price = float(price)
return price | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_price(self, soup):\n\n try:\n # try to locate the price tag \n price_tag = soup.find('div', class_='listing-detail-header-row md:ml-auto -ml-1')\\\n .find('h4', class_='h3')\n # remove punctuation marks \n price_text = price_tag... | [
"0.7028774",
"0.6929832",
"0.6806725",
"0.6527963",
"0.64799756",
"0.6477542",
"0.6458842",
"0.64488053",
"0.63198704",
"0.62966806",
"0.6224046",
"0.62180793",
"0.62034667",
"0.6200526",
"0.6185642",
"0.6183655",
"0.6171727",
"0.6158887",
"0.6158649",
"0.61567354",
"0.615621... | 0.7494976 | 0 |
This function writes the ASIN of the product in a .txt file | def asinTracker(asin):
with open('ASINs.txt', 'a') as f:
f.write(asin + '\n') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_quantities(quant_filename, products):\n\n with open(quant_filename, \"w\") as quant_file:\n quant_file.write(\"Quantity,SKU,Description(ignored)\\n\")\n for product in products:\n sku = product[\"SKU\"]\n description = \"{}: {}\".format(\n product[\"P... | [
"0.6129043",
"0.60017425",
"0.5965282",
"0.59514904",
"0.59017813",
"0.5860878",
"0.5812091",
"0.5785695",
"0.5750532",
"0.5748894",
"0.5742919",
"0.57049847",
"0.56986105",
"0.5658765",
"0.565127",
"0.5642307",
"0.56132483",
"0.5611988",
"0.5602596",
"0.5598513",
"0.5586851"... | 0.70680535 | 0 |
Produces consolidated arrays containing all SpherePiece vertices and edges. | def compile_points_edges(sphere_pieces):
def build_edge_list(tris, points):
v_adj = np.zeros(2*[points.shape[0]], dtype=np.int32)
v_adj[tris[:,0], tris[:,1]] = v_adj[tris[:,1], tris[:,0]] = 1
v_adj[tris[:,1], tris[:,2]] = v_adj[tris[:,2], tris[:,1]] = 1
v_adj[tris... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_boundary_PSLGs(domain, sphere_pieces, ds):\n # TODO : Break up this function a bit.\n\n def compile_points_edges(sphere_pieces):\n \"\"\"Produces consolidated arrays containing all SpherePiece vertices and\n edges.\n :param sphere_pieces list: list of SpherePiece objects.\n ... | [
"0.62588775",
"0.6085644",
"0.5982536",
"0.59402066",
"0.5756347",
"0.57024664",
"0.56980264",
"0.5678307",
"0.5608608",
"0.5601576",
"0.5596907",
"0.5539166",
"0.5521828",
"0.5492065",
"0.5491973",
"0.5491089",
"0.5481343",
"0.54743445",
"0.54713684",
"0.5462053",
"0.5449676... | 0.61926186 | 1 |
Reindexes edges along a given axis. | def reindex_edges(points, points_ax, edges_ax):
points_segment = points[points_ax]
reindex = {old: new for new, old in enumerate(np.where(points_ax)[0])}
for i, (v0, v1) in enumerate(edges_ax):
edges_ax[i] = np.array([reindex[v0], reindex[v1]])
return points_segment, edges_ax | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addEdgeToIndex(self, edge):\n self.idx.add(self.edgecounter, (edge.getMinX(), edge.getMinY(), edge.getMaxX(), edge.getMaxY()),obj=edge)\n # print \"%d/%d -> %d/%d\" % (edge.getMinX(), edge.getMinY(), edge.getMaxX(), edge.getMaxY())\n self.edgeindex_edge[self.edgecounter] = edge\n se... | [
"0.5696842",
"0.5624301",
"0.53624904",
"0.52496225",
"0.5230937",
"0.5169553",
"0.51400083",
"0.5127258",
"0.50954074",
"0.50954074",
"0.50850433",
"0.50818866",
"0.508047",
"0.5077113",
"0.5074856",
"0.50497717",
"0.5049294",
"0.50486386",
"0.5043889",
"0.5029128",
"0.50143... | 0.64712906 | 0 |
Construct list of perimeter edges for boundary. | def build_perim_edge_list(points_pieces, perim_refined):
# Need to adjust edge indices for perimeter segments
v_count = len(points_pieces)
perim_edges = 4 * [None]
for j in range(4):
v_count_perim = len(perim_refined[j])
perim_vidx = np.empty(v_count_perim, dtype=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetBoundaryEdgesPent(self):\n\n p = self.InferPolynomialDegree()\n\n # DO NOT COMPUTE IF ALREADY COMPUTED\n if isinstance(self.edges,np.ndarray):\n if self.edges.shape[0] > 1:\n # IF LINEAR VERSION IS COMPUTED, DO COMPUTE HIGHER VERSION\n if self.ed... | [
"0.62316316",
"0.61059797",
"0.6039545",
"0.60376734",
"0.5987016",
"0.59125966",
"0.5897252",
"0.58805734",
"0.58559597",
"0.5844207",
"0.5831732",
"0.5779419",
"0.57632965",
"0.5756053",
"0.5738258",
"0.5738258",
"0.5738258",
"0.57317734",
"0.57285696",
"0.5715138",
"0.5713... | 0.65824497 | 0 |
data is a deserialized list containing ad objects, ostensibly from the JSON.parsed payload of Twitter's adimpressions.js file | def extract_ad_impressions(data):
_a = namedtuple("AdImpressionPayload", "impressions, targeting")
_a.impressions = []
_a.targeting = []
for d in data:
impressions = d['ad']['adsUserData']['adImpressions']['impressions']
for i in impressions:
try:
_a.impressio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_from_json_ld(self, data, url):\n\n scripts = data.xpath(\"//script[@type='application/ld+json']\")\n records = [ ]\n\n for scr in scripts:\n\n try:\n data = json.loads(scr.text)\n except:\n continue\n\n if not isinstanc... | [
"0.58622235",
"0.5823169",
"0.5642594",
"0.5607261",
"0.55972517",
"0.55578536",
"0.55514205",
"0.5481259",
"0.5444888",
"0.54164225",
"0.54035854",
"0.53956926",
"0.5368816",
"0.5364882",
"0.5363454",
"0.5358585",
"0.5357465",
"0.53338826",
"0.52928287",
"0.52914554",
"0.528... | 0.69800425 | 0 |
Modify `obj` by replacing `dict`s with `tfu.Struct`s. | def make(obj):
if isinstance(obj, dict):
if isinstance(obj, Struct):
ObjType = type(obj)
else:
ObjType = Struct
return ObjType(**{k: Struct.make(v) for k, v in obj.items()})
elif isinstance(obj, list):
return [Struct.make(v) for v in obj]
return obj | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dataclassUpdate(obj, *srcObjs, **kwargs) -> object:\n if not is_dataclass(obj):\n raise TypeError(f'Object {obj} is not a dataclass')\n for srcObj in srcObjs:\n obj.__dict__.update(dataclassAsDict(srcObj))\n obj.__dict__.update(**kwargs)\n return obj",
"def hook(obj: Dict) -> Dict:\... | [
"0.5693876",
"0.5658637",
"0.56568277",
"0.56523484",
"0.5641577",
"0.5623007",
"0.5591107",
"0.5528825",
"0.55023587",
"0.54896265",
"0.5447281",
"0.5427962",
"0.5377632",
"0.5358284",
"0.53528625",
"0.53206605",
"0.53200567",
"0.5294163",
"0.52630264",
"0.522704",
"0.521179... | 0.62042284 | 0 |
in pfPaperID ci sono record IDpapIDautIDaff, carico gli IDpap nel set in pfPapAutAffRAW ci sono record IDpapIDautIDaff, se IDaut e' nel set allora in pfPapAutAff salvo i record | def estraiPapAutAffPerPaper(pfPaperID, pfPapAutAffRAW, pfPapAutAff):
# print 'pfPapAutAff:{}\tpfPapAutAffRAW:{}\tpfPaperID:{}'.format(pfPapAutAff, pfPapAutAffRAW, pfPaperID)
# proceso scrittore con coda dei risultati scitti subito ???
sIDpap = set()
with open(pfPaperID, 'rb') as fPaperID:
for line in fPaper... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setpmidInfo():\n DB = PT.DB\n for p in PT.proteins:\n f = DB[p]['PMID_link']\n #print f\n try:\n auth, tit = t.fetchPMIDSummary(f['text'])\n #print 'got info', tit\n except:\n print 'no pmid'\n try:\n f['authors'] = auth\n ... | [
"0.5436813",
"0.5312703",
"0.5203853",
"0.5188142",
"0.51306105",
"0.5056955",
"0.5024764",
"0.49724486",
"0.49668655",
"0.49494895",
"0.49372512",
"0.49151874",
"0.48789692",
"0.48615327",
"0.48583245",
"0.48397592",
"0.48345232",
"0.4825301",
"0.47939983",
"0.47921956",
"0.... | 0.64699167 | 0 |
Method sets the prompt embedding weights to 0.0 | def clear_prompt_embedding_weights(self,):
self.prompt_embeddings.weight.fill_(0.0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(self):\n self.embedding.weight.data.uniform_(-0.1, 0.1)\n self.word.bias.data.fill_(0)\n self.word.weight.data.uniform_(-0.1, 0.1)",
"def init_weights(self):\r\n self.embedding.weight.data.uniform_(-0.1, 0.1)\r\n self.fc.bias.data.fill_(0)\r\n self.fc.we... | [
"0.7463873",
"0.7199745",
"0.71822166",
"0.71816295",
"0.7171803",
"0.7171803",
"0.7171803",
"0.709266",
"0.7066728",
"0.7066646",
"0.6958817",
"0.690859",
"0.68791986",
"0.672614",
"0.67151546",
"0.6635397",
"0.65766937",
"0.65614665",
"0.6556054",
"0.653788",
"0.65227437",
... | 0.8714095 | 0 |
Method sets the prompt embedding weights with a new weight w | def set_prompt_embedding_weights(self, weight: torch.Tensor):
self.prompt_embeddings.weight.data = weight.type_as(self.prompt_embeddings.weight.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_prompt_embedding_weights(self,):\n self.prompt_embeddings.weight.fill_(0.0)",
"def init_weights(self):\n self.embedding.weight.data.uniform_(-0.1, 0.1)\n self.word.bias.data.fill_(0)\n self.word.weight.data.uniform_(-0.1, 0.1)",
"def setWeights(self, w):\n raise Not... | [
"0.73268247",
"0.72788864",
"0.7256226",
"0.7252996",
"0.701445",
"0.6961656",
"0.6961656",
"0.6951745",
"0.6946087",
"0.6880116",
"0.68501544",
"0.6839706",
"0.68244517",
"0.68196607",
"0.68133944",
"0.681045",
"0.678291",
"0.67816025",
"0.67816025",
"0.67816025",
"0.6776748... | 0.7940417 | 0 |
Method sets the prompt embedding inside self.prompt_table[taskname] with new weights | def set_prompt_table(self, prompt_representation: torch.Tensor):
self.prompt_table[self.taskname].set_prompt_embedding_weights(prompt_representation)
self.is_inference_ready = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_prompt_embedding_weights(self, weight: torch.Tensor):\n self.prompt_embeddings.weight.data = weight.type_as(self.prompt_embeddings.weight.data)",
"def clear_prompt_table(self,):\n self.prompt_table[self.taskname].clear_prompt_embedding_weights()\n self.is_inference_ready = False",
... | [
"0.6723237",
"0.62406766",
"0.567763",
"0.567732",
"0.5614703",
"0.56041825",
"0.55482334",
"0.55092585",
"0.54146916",
"0.53373724",
"0.5330053",
"0.5323259",
"0.5310719",
"0.5308155",
"0.5282654",
"0.52624685",
"0.5236947",
"0.5232898",
"0.52073205",
"0.5205094",
"0.5189278... | 0.7479566 | 0 |
Returns the prompt representation cached in the prompt table | def get_prompt_table(self,):
return self.prompt_table[self.taskname].forward() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPrompt(self):\n return str(self.prompt)",
"def _getPrompt(self):\n return Prompt(\n task=AnsibleTask(),\n connection=None,\n play_context=AnsiblePlayContext(),\n loader=None,\n templar=None,\n shared_loader_obj=None\n )... | [
"0.7051371",
"0.655758",
"0.647599",
"0.6389225",
"0.62960994",
"0.62469625",
"0.62408257",
"0.6204379",
"0.6159991",
"0.6153383",
"0.6132691",
"0.60949546",
"0.6062579",
"0.6005795",
"0.59915847",
"0.5972832",
"0.5939374",
"0.593828",
"0.5930662",
"0.5929807",
"0.59027886",
... | 0.68141127 | 1 |
Method "clears" the prompt embedding inside self.prompt_table[taskname] by setting it to zero. | def clear_prompt_table(self,):
self.prompt_table[self.taskname].clear_prompt_embedding_weights()
self.is_inference_ready = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Reset(self):\n self.prompt_str = self.prompt_ev.FirstPromptEvaluator()",
"def clear_screen(self):\n self.ClearAll()\n self.new_prompt(self.input_prompt_template.substitute(\n number=(self.last_result['number'] + 1)))",
"def clear(self):\n self.entry_gu... | [
"0.71894723",
"0.7172326",
"0.6529257",
"0.6470064",
"0.6387349",
"0.634283",
"0.6335559",
"0.61485064",
"0.61439395",
"0.6078703",
"0.6058917",
"0.59830153",
"0.5967517",
"0.595206",
"0.59446496",
"0.59407115",
"0.59316623",
"0.5923165",
"0.5906737",
"0.5895128",
"0.5873446"... | 0.79912794 | 0 |
Return the integer index into self.voltages corresponding to the given key, computing the values if necessary | def gt_voltages(self, key):
# If we already have the (model, G, T) key, we're done
if key in self.cell_keys:
return self.cell_keys[key]
model, insolation, temperature = key # unpack the key
index = len(self.cell_voltages)
self.cell_keys[key] = index
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def str_voltages(self, key, bypass_voltage):\r\n # If we already have the key, we're done\r\n if key in self.string_keys:\r\n return self.string_keys[key]\r\n model = key[0] # unpack the key\r\n pattern = key[1:]\r\n index = len(self.string_voltages)\r\n self.s... | [
"0.66611093",
"0.64660835",
"0.6437124",
"0.6412482",
"0.6389903",
"0.6278537",
"0.62480706",
"0.6233651",
"0.6208461",
"0.61683357",
"0.6160918",
"0.614379",
"0.61322546",
"0.611922",
"0.6093328",
"0.6086808",
"0.6039528",
"0.60380924",
"0.60224545",
"0.60191905",
"0.5994054... | 0.7571906 | 0 |
Return the integer index into self.voltages corresponding to the given key, computing the values if necessary | def str_voltages(self, key, bypass_voltage):
# If we already have the key, we're done
if key in self.string_keys:
return self.string_keys[key]
model = key[0] # unpack the key
pattern = key[1:]
index = len(self.string_voltages)
self.string_keys[key] = i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gt_voltages(self, key):\r\n # If we already have the (model, G, T) key, we're done\r\n if key in self.cell_keys:\r\n return self.cell_keys[key]\r\n model, insolation, temperature = key # unpack the key\r\n index = len(self.cell_voltages)\r\n self.cell_keys[key] = ... | [
"0.7571906",
"0.64660835",
"0.6437124",
"0.6412482",
"0.6389903",
"0.6278537",
"0.62480706",
"0.6233651",
"0.6208461",
"0.61683357",
"0.6160918",
"0.614379",
"0.61322546",
"0.611922",
"0.6093328",
"0.6086808",
"0.6039528",
"0.60380924",
"0.60224545",
"0.60191905",
"0.5994054"... | 0.66611093 | 1 |
Make a plot of the IV curve for a stored curve n. Raises an exception for invalid index. | def plot_cell_iv(self, n, show=True):
from solar_plots import ivplot
# Figure out the key
for k, v in self.cell_keys.items():
if v == n:
(model, g, t) = k
title = f'{model.name} {g:.1f} W/m$^2$ {t:.1f}$^{{\circ}}$C'
title = ti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Draw(Uk): \n vecx = np.zeros([n,1])\n for i in range(n):\n vecx[i][0] =(float(2*i-n+1)/(n-1))*L\n plt.plot(vecx, Uk, linewidth=1.0)\n plt.show()",
"def setCurve(self, index, curve) -> None:\n ...",
"def plot_inverse(self,show=True,nx=129):\n xs = np.linspace(0.0,1.0,nx)\... | [
"0.6334967",
"0.6032911",
"0.5882786",
"0.579593",
"0.57481384",
"0.5723888",
"0.5668775",
"0.564979",
"0.56415886",
"0.5622665",
"0.55573416",
"0.5548427",
"0.5535385",
"0.5527291",
"0.55126876",
"0.5508224",
"0.5503563",
"0.54931617",
"0.54859847",
"0.54827553",
"0.5476824"... | 0.65777373 | 0 |
Computes approximate value of the Bessel function I_0 according to formulas in Praat source code, file | def bessel_i0_approximation(x):
if x < 0:
return bessel_i0_approximation(-x)
# Argument is in [0, 3.75), using formula 9.8.1.
elif x < 3.75:
t = x / 3.75
t2 = t * t
return 1.0 + t * (3.5156229 + t * (3.0899424 +
t * (1.2067492 + t * (0.2659732 + t * (0.036076... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def i0(x):\n return tt.switch(tt.lt(x, 5), 1 + x**2 / 4 + x**4 / 64 + x**6 / 2304 + x**8 / 147456\n + x**10 / 14745600 + x**12 / 2123366400,\n np.e**x / (2 * np.pi * x)**0.5 * (1 + 1 / (8 * x) + 9 / (128 * x**2) + 225 / (3072 * x**3)\n ... | [
"0.63962996",
"0.6169751",
"0.5996741",
"0.59689647",
"0.5863775",
"0.5856659",
"0.5820521",
"0.57904685",
"0.5765348",
"0.57574636",
"0.5744184",
"0.5739884",
"0.57355976",
"0.5732318",
"0.5712163",
"0.5707551",
"0.56916195",
"0.5670462",
"0.5655714",
"0.56469965",
"0.564636... | 0.6743058 | 0 |
Computes Linear Prediction coefficients via Burg method from a list of samples. | def burg(sample_list, coefficient_number):
p = sum(sample ** 2 for sample in sample_list)
a0 = p / len(sample_list)
b1 = sample_list[:len(sample_list) - 1]
b2 = sample_list[1:]
aa = [0.0 for i in range(coefficient_number)]
coefficient_list = [0.0 for i in range(coefficient_number)]
for i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def b_coefficients(x1,x2,x3,y1,y2,y3,CCoefficients,DCoefficients):\n\tBCoefficients = np.array([\t((y2-y1)/(x2-x1)-CCoefficients[0]*(x2-x1) - DCoefficients[0]*((x2-x1)**2)), \\\n\t\t\t\t\t\t\t\t((y3-y2)/(x3-x2)-CCoefficients[1]*(x3-x2) - DCoefficients[1]*((x3-x2)**2)) \t]).astype(float)\n\treturn(BCoefficients)",... | [
"0.588556",
"0.58450377",
"0.56125486",
"0.5588281",
"0.5565084",
"0.55091435",
"0.5476168",
"0.54556483",
"0.5409804",
"0.5363739",
"0.5347172",
"0.5325818",
"0.5317474",
"0.53165877",
"0.5301712",
"0.5300622",
"0.52828956",
"0.5275676",
"0.5262064",
"0.52465135",
"0.5235341... | 0.6491661 | 0 |
Computes intensity at the point specified by intensity time step index. | def get_intensity(self, step_index):
if step_index < 4 or step_index >= self.intensity_step_count - 4:
raise ValueError('step index {0} is out of bounds [4, {1})'.format(
step_index, self.intensity_step_count - 4))
# Checking if we already computed required intensity value.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intensity(self, value: int, /) -> None:",
"def intensity(self) -> int:",
"def _ith_point(self, i):\n if self.start is S.NegativeInfinity:\n initial = self.stop\n else:\n initial = self.start\n\n if self.start is S.NegativeInfinity:\n step = -1\n ... | [
"0.64101243",
"0.617516",
"0.59392095",
"0.5813477",
"0.5625089",
"0.55660486",
"0.5486099",
"0.543807",
"0.54261965",
"0.5382803",
"0.53800386",
"0.5366848",
"0.53468555",
"0.5343197",
"0.53428704",
"0.5321194",
"0.5290446",
"0.5197066",
"0.518417",
"0.51560026",
"0.50724673... | 0.69535184 | 0 |
Computes point formant values at the point specified by formant time step index. | def get_formants(self, step_index):
if step_index < 4 or step_index >= self.formant_step_count - 4:
raise ValueError('step index {0} is out of bounds [4, {1})'.format(
step_index, self.formant_step_count - 4))
# Checking if we already computed required formant point value.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_interval_formants(self, begin, end):\n\n # Initializing formant computation data, if required.\n\n if self.formant_sound == None:\n\n self.formant_sound = self.intensity_sound.set_frame_rate(self.formant_frame_rate)\n\n self.formant_step_count = int(\n mat... | [
"0.5583921",
"0.5249184",
"0.5203325",
"0.51509523",
"0.5082131",
"0.5079269",
"0.5038989",
"0.50300026",
"0.4964435",
"0.49531314",
"0.4926366",
"0.4918329",
"0.48595932",
"0.48520714",
"0.48278973",
"0.47974613",
"0.47897872",
"0.47831386",
"0.47750327",
"0.4758332",
"0.475... | 0.64310485 | 0 |
Given a sound recording and a list of intervals specified by boundaries in seconds, returns index of the interval with the highest sound intensity, intensity of this interval, index of the longest interval and the length of the longest interval. Intensity is computed as closely as possible to the intensity computed by ... | def find_max_interval_praat(sound, interval_list):
max_intensity = None
max_intensity_index = None
max_length = None
max_length_index = None
# Finding interval with highest intensity and the longest interval.
for index, (begin_sec, end_sec, _) in enumerate(interval_list):
intensity ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_max_power(data, interval_power, interval_duration, search_range):\n max_power = 0\n index = None\n for i in range(min(len(data), search_range)):\n power = get_row_power(data, i)\n if power > max_power:\n index, max_power = i, power\n logging.debug(\"peak index = %u, ma... | [
"0.6358573",
"0.6134721",
"0.5717627",
"0.56928444",
"0.5607882",
"0.56057876",
"0.5593326",
"0.55912477",
"0.5544572",
"0.55422294",
"0.55079436",
"0.5487213",
"0.5458871",
"0.5458349",
"0.5453618",
"0.54222214",
"0.5415315",
"0.54060084",
"0.53813905",
"0.5372076",
"0.53462... | 0.80858994 | 0 |
Computes phonology of a specified perspective. Perspective is specified by request parameters 'perspective_client_id' and 'perspective_object_id', | def phonology(request):
perspective_cid = request.params.get('perspective_client_id')
perspective_oid = request.params.get('perspective_object_id')
# Checking if we have limits on number of computed results.
limit = (None if 'limit' not in request.params else
int(request.params.get('limit')))... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def determinePoses(self, object_pose, object_type):\n self.publishPose(object_pose.pose, self.objectPosePublisher)\n \n quaternion_object = Quaternion(\n object_pose.pose.orientation.w,\n object_pose.pose.orientation.x,\n object_pose.pose.orientation.y,\n ... | [
"0.5101633",
"0.5025305",
"0.4937565",
"0.49290425",
"0.4918552",
"0.48812005",
"0.48696923",
"0.48425367",
"0.47113043",
"0.46992862",
"0.46580386",
"0.4655105",
"0.46248472",
"0.46148935",
"0.45794016",
"0.45139703",
"0.45135105",
"0.45099118",
"0.44662756",
"0.44629663",
"... | 0.7144419 | 0 |
Recurses over a Skywriting data structure (containing lists, dicts and primitive leaves) in a deterministic order, and updates the given hash with all values contained therein. | def hash_update_with_structure(hash, value):
if isinstance(value, list):
hash.update('[')
for element in value:
hash_update_with_structure(hash, element)
hash.update(',')
hash.update(']')
elif isinstance(value, dict):
hash.update('{')
for (dict_key... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_hash(self, h):\n # Generate a sequence of fragments that add up to the canonical\n # version of the expression.\n fragments = []\n self.collect_str_fragments(fragments)\n # Update the hash. Wrapping with 'node<...>' prevents the hash\n # from being extended in ... | [
"0.6283258",
"0.62538487",
"0.5987227",
"0.5949011",
"0.58771133",
"0.586068",
"0.57835984",
"0.57812417",
"0.57483125",
"0.57483125",
"0.57331014",
"0.5612424",
"0.5606768",
"0.5602949",
"0.55961907",
"0.5593356",
"0.5572666",
"0.55617875",
"0.55617875",
"0.55611175",
"0.553... | 0.66173977 | 0 |
Fetches a reference if it is available, and returns a filename for reading it. Options to do with eagerness, streaming, etc. If reference is unavailable, raises a ReferenceUnavailableException. | def open_ref(self, ref):
ref = self.task_record.retrieve_ref(ref)
return self.block_store.retrieve_filename_for_ref(ref) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_reference_file(dataset, reference_file_type, observatory=None, asn_exptypes=None):\n if isinstance(dataset, str):\n from jwst import datamodels\n with datamodels.open(dataset, asn_exptypes=asn_exptypes) as model:\n return get_multiple_reference_paths(\n model, [re... | [
"0.62668496",
"0.6265027",
"0.6206624",
"0.58024764",
"0.57741493",
"0.5729092",
"0.5602254",
"0.5539818",
"0.548042",
"0.5473275",
"0.54689324",
"0.54222244",
"0.53188396",
"0.5299525",
"0.5278652",
"0.52682966",
"0.5256566",
"0.52051485",
"0.5200777",
"0.5194874",
"0.518543... | 0.64354956 | 0 |
Creates a new reference, and returns a filename for writing it. Also, can supply a string and create the new reference inline. Also, can specify what output is being created. Returns the created reference to the object, and (if necessary) filename. | def create_ref_file(self):
id = self.task_record.create_published_output_name()
ctx = self.block_store.make_local_output(id)
self.open_ref_contexts[ctx.get_filename()] = ctx
return ctx.get_filename() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_reference(\n self, response_checker=default_checker.default_journey_checker\n ):\n # Check that the file doesn't already exist\n filename = self.get_file_name()\n filepath = os.path.join(config[\"REFERENCE_FILE_PATH\"], filename)\n\n if os.path.isfile(filepath):\n ... | [
"0.6061138",
"0.57434314",
"0.5675039",
"0.5661924",
"0.5659864",
"0.56557876",
"0.5611315",
"0.56035614",
"0.5594945",
"0.5592123",
"0.5564332",
"0.5540029",
"0.5473499",
"0.54609543",
"0.54573286",
"0.5450987",
"0.5427525",
"0.5420739",
"0.5381908",
"0.53653884",
"0.5352038... | 0.71080023 | 0 |
Creates a file for the output with the given index, and returns the filename. | def write_output_file(self, index):
ctx = self.block_store.make_local_output(self.expected_outputs[index])
self.open_output_contexts[index] = ctx
return ctx.get_filename() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _out_fn(self, split_index):\n if split_index > 999:\n raise ValueError(\"Too many splitted files to generate: number \" +\n \"of splitted files exceed 1000.\")\n name = self.out_format.format(split_index)\n return op.join(self.out_dir, name)",
"def ... | [
"0.7043272",
"0.6833462",
"0.678748",
"0.676521",
"0.6710912",
"0.63163453",
"0.6271672",
"0.6258734",
"0.6254915",
"0.6213093",
"0.6163952",
"0.61557615",
"0.614629",
"0.6146222",
"0.6125935",
"0.6121711",
"0.60860264",
"0.60827655",
"0.60735834",
"0.6060932",
"0.60248595",
... | 0.78400207 | 0 |
Closes the open file for a constructed reference. | def close_ref(self, filename):
ctx = self.open_ref_contexts.pop(filename)
ctx.close()
ref = ctx.get_completed_ref()
self.task_record.publish_ref(ref)
return ref | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close(self, close_file=True):\n if self.__ref is not None:\n self.__lib.flush()\n if close_file == True:\n self.__ref.close()\n self.__ref = None\n self.__lib = None",
"def close(self):\n self.__file_object.close()",
"def close_file(s... | [
"0.7742864",
"0.7563475",
"0.7489155",
"0.7480569",
"0.74259466",
"0.738527",
"0.738527",
"0.733487",
"0.73153365",
"0.73153365",
"0.73047477",
"0.72957414",
"0.7287493",
"0.72814417",
"0.7279619",
"0.7278698",
"0.7278698",
"0.72182274",
"0.7207381",
"0.719627",
"0.719627",
... | 0.75949395 | 1 |
Creates a continuation task for blocking on the given references. | def block_on_refs(self, refs):
task_descriptor = {"handler" : "proc"}
spawn_task_helper(self.task_record, "proc", False, process_record_id=self.process_record.id, blocking_refs=refs, current_outputs=self.expected_outputs, output_mask=self.expected_output_mask) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancel_tasks(tasks: Iterable[asyncio.Future]) -> asyncio.Future:\n\n future = asyncio.get_event_loop().create_future()\n future.set_result(None)\n\n if not tasks:\n return future\n\n cancelled_tasks = []\n exc = asyncio.CancelledError()\n\n for task in tasks:\n if task.done():\n... | [
"0.5502701",
"0.5406121",
"0.5249749",
"0.50498354",
"0.5006657",
"0.5000263",
"0.49913812",
"0.4972244",
"0.49477524",
"0.49443525",
"0.49277103",
"0.4914492",
"0.48593238",
"0.48480922",
"0.4844165",
"0.4762097",
"0.4750882",
"0.47031823",
"0.46794972",
"0.46610945",
"0.464... | 0.57081866 | 0 |
Get the progress of how many files have already been processed by OpenIE | def openie_get_progress(out_fn):
if not os.path.exists(out_fn):
return 0
else:
with open(out_fn) as f:
doc_names = []
for line in f:
d = line.split('\t', 1)[0]
doc_names.append(d)
return len(set(doc_names)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getProgress(self):",
"def progress(self):\n return self.runProgress",
"def progress(self):\n return self.runProgress",
"def get_progress(self):\n\t\treturn call_sdk_function('PrlJob_GetProgress', self.handle)",
"def GetProgress(self):\n return self.objects_finished",
"def GetProgress... | [
"0.7094764",
"0.6578887",
"0.6578887",
"0.6565225",
"0.6553384",
"0.6488721",
"0.6480194",
"0.6458993",
"0.64584625",
"0.64049935",
"0.63742083",
"0.63592714",
"0.6340405",
"0.63334024",
"0.632225",
"0.6305707",
"0.6293516",
"0.62709427",
"0.62264454",
"0.6203152",
"0.6189957... | 0.7541667 | 0 |
matches the predicate tokens in the sentence and extracts the correct pos tags | def openie_match_pred_tokens(pred, pos_tags, pred_start, pred_end, sent):
# the format seems to be strange some times
if pred_end < pred_start:
temp = pred_start
pred_start = pred_end
pred_end = temp
if pred_start == pred_end:
return pos_tags[pred_start]
else:
to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pos_tag(self, sentence):\n tags = []\n tokens = sentence.split(\" \")\n for i in range(len(tokens)):\n tags.append('')\n for i in range (len(tokens)):\n feat = []\n feat.append(self.features(tokens,tags,i))\n tag_predicted = self.postagge... | [
"0.68537337",
"0.6575514",
"0.6402165",
"0.6340297",
"0.62640506",
"0.62438756",
"0.62354314",
"0.6200754",
"0.6149336",
"0.61342067",
"0.6077075",
"0.6060228",
"0.60253185",
"0.6023351",
"0.5995335",
"0.5962352",
"0.59592444",
"0.5954324",
"0.5948058",
"0.5940367",
"0.592849... | 0.6906623 | 0 |
Transforms the CoreNLP OpenIE Output format to an internal format | def openie_process_output(openie_out: str, outfile: str):
tuples = 0
with open(openie_out, 'r') as f_out, open(outfile, 'w') as f_conv:
writer = csv.writer(f_conv, delimiter='\t')
writer.writerow(['document id',
'subject',
'predicate',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_corenlp_openie(input_file, output, config=NLP_CONFIG, no_entity_filter=False, consider_sections=False):\n # Read config\n with open(config) as f:\n conf = json.load(f)\n core_nlp_dir = conf[\"corenlp\"]\n\n # Prepare files\n filelist_fn, out_fn, amount_files = openie_prepare_files... | [
"0.55576575",
"0.5345858",
"0.5222792",
"0.51759994",
"0.51739126",
"0.50711215",
"0.5053358",
"0.5038428",
"0.49775144",
"0.49672452",
"0.49663988",
"0.49509645",
"0.49292606",
"0.49291357",
"0.48953876",
"0.48768157",
"0.48675898",
"0.4859114",
"0.48588386",
"0.48430315",
"... | 0.6126473 | 0 |
Executes the Stanford CoreNLP OpenIE extraction | def run_corenlp_openie(input_file, output, config=NLP_CONFIG, no_entity_filter=False, consider_sections=False):
# Read config
with open(config) as f:
conf = json.load(f)
core_nlp_dir = conf["corenlp"]
# Prepare files
filelist_fn, out_fn, amount_files = openie_prepare_files(input_file, n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def openie_run(core_nlp_dir: str, out_fn: str, filelist_fn: str):\n start = datetime.now()\n with open(filelist_fn) as f:\n num_files = len(f.read().split(\"\\n\"))\n\n run_script = os.path.join(os.path.dirname(os.path.abspath(__file__)), \"run.sh\")\n out_fn = os.path.join(os.path.dirname(os.pa... | [
"0.6620474",
"0.5656396",
"0.5556522",
"0.52192885",
"0.5152066",
"0.51240176",
"0.5022306",
"0.5003122",
"0.49662173",
"0.49480104",
"0.49453816",
"0.4944723",
"0.49391413",
"0.49352282",
"0.4892565",
"0.48839137",
"0.4877507",
"0.48755205",
"0.4861758",
"0.48573345",
"0.483... | 0.65011543 | 1 |
Mouse click on element matching given locator. Exception ``ActionNotPossible`` is raised if element does not allow Click action. | def click(
self,
locator: Locator,
wait_time: Optional[float] = None,
timeout: Optional[float] = None,
) -> WindowsElement:
return self._mouse_click(locator, "Click", wait_time, timeout) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def click(self, element=None):\n\t\tif element is not None:\n\t\t\ttry:\n\t\t\t\tassert(type(element)) == webdriver.firefox.webelement.FirefoxWebElement\n\t\t\t\telement.click()\n\t\t\t\treturn\n\t\t\texcept Exception as e:\n\t\t\t\tprint(\"Unable to click element\\n{}\".format(e))\n\t\t\t\treturn -1\n\t\ttry:\n\t... | [
"0.69686425",
"0.6952208",
"0.6908809",
"0.6865455",
"0.67595595",
"0.6758704",
"0.65802515",
"0.65654767",
"0.65379477",
"0.65366226",
"0.65140927",
"0.65006226",
"0.64890856",
"0.64590824",
"0.64528096",
"0.63889796",
"0.63794476",
"0.6371438",
"0.6307859",
"0.6248868",
"0.... | 0.73438823 | 0 |
Double mouse click on element matching given locator. Exception ``ActionNotPossible`` is raised if element does not allow Click action. | def double_click(
self,
locator: Locator,
wait_time: Optional[float] = None,
timeout: Optional[float] = None,
) -> WindowsElement:
return self._mouse_click(locator, "DoubleClick", wait_time, timeout) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def double_click(dsk_session: WebDriver, element: WebElement):\n actions = ActionChains(dsk_session)\n actions.move_to_element(element)\n actions.double_click(element).perform()",
"def double_click(self):\n self.scroll_to()\n ActionChains(self.driver).double_click(self._element).perform()"... | [
"0.7294949",
"0.69400907",
"0.679815",
"0.65080285",
"0.64902407",
"0.64665383",
"0.6445964",
"0.635055",
"0.6278408",
"0.6185829",
"0.60788864",
"0.6029002",
"0.6010307",
"0.5995132",
"0.5907198",
"0.5853656",
"0.5826893",
"0.58023447",
"0.5772024",
"0.57648253",
"0.5757234"... | 0.78112084 | 0 |
Right mouse click on element matching given locator. Exception ``ActionNotPossible`` is raised if element does not allow Click action. | def right_click(
self,
locator: Locator,
wait_time: Optional[float] = None,
timeout: Optional[float] = None,
) -> WindowsElement:
return self._mouse_click(locator, "RightClick", wait_time, timeout) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def right_click(self, selector):\n el = self.locate_element(selector)\n ActionChains(self.base_driver).context_click(el).perform()",
"def right_click(self):\n self.scroll_to()\n ActionChains(self.driver).context_click(self._element).perform()",
"def right_click(coords=(0, 0)):\n ... | [
"0.76646465",
"0.6871791",
"0.6594901",
"0.65575135",
"0.65395576",
"0.63958615",
"0.6393752",
"0.6166534",
"0.60028625",
"0.5893509",
"0.58544904",
"0.5785418",
"0.57662475",
"0.57640254",
"0.5751519",
"0.56125504",
"0.5587439",
"0.5547663",
"0.5542235",
"0.55280495",
"0.550... | 0.80277693 | 0 |
Select a value on the passed element if such action is supported. The ``ActionNotPossible`` exception is raised when the element does not allow the `Select` action. This is usually used with combo box elements. | def select(self, locator: Locator, value: str) -> WindowsElement:
element = self.ctx.get_element(locator)
if hasattr(element.item, "Select"):
# NOTE(cmin764): This is not supposed to work on `*Pattern` or `TextRange`
# objects. (works with `Control`s and its derived flavors only... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform_as(self, the_actor: Actor) -> None:\n if self.target is None:\n raise UnableToAct(\n \"Target was not provided for SelectByValue. Provide a target using the \"\n \".from_() or .from_the() methods.\"\n )\n\n element = self.target.found_by... | [
"0.62238955",
"0.5973726",
"0.5947558",
"0.5833145",
"0.57968736",
"0.57692224",
"0.57590413",
"0.573912",
"0.56351537",
"0.5604959",
"0.55624765",
"0.55609965",
"0.5503806",
"0.5492601",
"0.5466104",
"0.5436489",
"0.53234076",
"0.5322582",
"0.5311624",
"0.52998",
"0.529459",... | 0.61820287 | 1 |
Send keys to desktop, current window or to Control element defined by given locator. If ``locator`` is `None` then keys are sent to desktop. Exception ``ActionNotPossible`` is raised if element does not allow SendKeys action. | def send_keys(
self,
locator: Optional[Locator] = None,
keys: Optional[str] = None,
interval: float = 0.01,
wait_time: Optional[float] = None,
send_enter: bool = False,
):
if locator:
element = self.ctx.get_element(locator).item
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sendKeys(self,data, locator=\"\", locatorType='id', element=None):\n try:\n\n if locator:\n element=self.getElement(locator,locatorType)\n element.send_keys(data)\n self.logger.info(\"Sent data on element with locator\"+locator+\" locatorType: \"+locatorType)\... | [
"0.66883934",
"0.5958949",
"0.5916988",
"0.56418866",
"0.5483339",
"0.53321874",
"0.52912056",
"0.5278712",
"0.51724446",
"0.51691645",
"0.51664644",
"0.5067585",
"0.4988945",
"0.4944113",
"0.4897145",
"0.48759228",
"0.48653334",
"0.47926876",
"0.47265878",
"0.47235355",
"0.4... | 0.7373044 | 0 |
Get text from Control element defined by the locator. Exception ``ActionNotPossible`` is raised if element does not allow GetWindowText action. | def get_text(self, locator: Locator) -> str:
element = self.ctx.get_element(locator)
if hasattr(element.item, "GetWindowText"):
return element.item.GetWindowText()
raise ActionNotPossible(
f"Element found with {locator!r} does not have 'GetWindowText' attribute"
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_text(locator, timeout=default_timeout, type = By.XPATH):\n logger.debug(\"Entered _get_text() method\")\n button = _find_element(locator, type = type, timeout = timeout)\n if button:\n return button.text\n return None",
"def get_text(self,locator):\r\n t1 = time.time()\r\n ... | [
"0.7472512",
"0.7053349",
"0.6659012",
"0.6648674",
"0.6632658",
"0.66203004",
"0.65963334",
"0.65955853",
"0.6298224",
"0.62838197",
"0.6257135",
"0.6246154",
"0.61976665",
"0.617704",
"0.6072492",
"0.6058471",
"0.5894503",
"0.5884582",
"0.5873599",
"0.58704597",
"0.58467174... | 0.8045525 | 0 |
Get the value of the element defined by the provided `locator`. The ``ActionNotPossible`` exception is raised if the identified element doesn't support value retrieval. | def get_value(self, locator: Locator) -> Optional[str]:
element = self.ctx.get_element(locator)
get_value_pattern = self.get_value_pattern(element)
if get_value_pattern:
func_name = get_value_pattern.__name__
self.logger.info(
"Retrieving the element valu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_element_value(self, locator):\n return self.get_element(locator).get_attribute('value')",
"def __get__(self, obj, owner):\n # def get_value(self, obj, owner):\n driver = obj.driver\n if self.locator[0] != 'css selector':\n raise 'Using a locator other than css'\n ... | [
"0.74683064",
"0.6511875",
"0.63174784",
"0.6295683",
"0.59136415",
"0.57749736",
"0.5608894",
"0.5485995",
"0.5461312",
"0.5461312",
"0.5435183",
"0.54296726",
"0.5423922",
"0.53713876",
"0.53586686",
"0.53550994",
"0.5319171",
"0.5314429",
"0.5314429",
"0.5314429",
"0.52863... | 0.8586263 | 0 |
Set global timeout for element search. Applies also to ``Control Window`` keyword. By default, the library has a timeout of 10 seconds. | def set_global_timeout(self, timeout: float) -> float:
previous_timeout = self.ctx.global_timeout
self.ctx.global_timeout = timeout
auto.SetGlobalSearchTimeout(self.ctx.global_timeout)
return previous_timeout | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setdefaulttimeout(timeout):\r\n global _TIMEOUT\r\n _TIMEOUT = timeout",
"def set_timeout(self, timeout):\n self.timeout = timeout",
"def setdefaulttimeout(timeout):\r\n global default_timeout\r\n default_timeout = timeout",
"def set_timeout(self, timeout):\n pass",
"def setTimeOu... | [
"0.7021249",
"0.69126594",
"0.69018596",
"0.6887196",
"0.68613315",
"0.6781983",
"0.66552067",
"0.6621496",
"0.65661573",
"0.6554327",
"0.63645965",
"0.6347939",
"0.6335188",
"0.62914443",
"0.62847984",
"0.6279671",
"0.6217797",
"0.62087256",
"0.62070656",
"0.6195933",
"0.615... | 0.72433466 | 0 |
Set view focus to the element defined by the locator. | def set_focus(self, locator: Locator) -> None:
element = self.ctx.get_element(locator)
if not hasattr(element.item, "SetFocus"):
raise ActionNotPossible(
f"Element found with {locator!r} does not have 'SetFocus' attribute"
)
element.item.SetFocus() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _focus(self, element):\n actions = ActionChains(self.selenium.driver)\n actions.move_to_element(element).click().perform()\n self.selenium.set_focus_to_element(element)",
"def setFocus(*args, **kwargs)->None:\n pass",
"def SetFocus(self):\r\n \r\n self._main_win.SetFoc... | [
"0.75795484",
"0.67102313",
"0.6517049",
"0.6505347",
"0.6505347",
"0.6505347",
"0.6505347",
"0.645401",
"0.63585174",
"0.6268996",
"0.6228265",
"0.6193915",
"0.61304414",
"0.61304414",
"0.61304414",
"0.61304414",
"0.6074505",
"0.6068601",
"0.60382974",
"0.6022987",
"0.601745... | 0.8290157 | 0 |
Drag and drop the source element into target element. | def drag_and_drop(
self,
source_element: Locator,
target_element: Locator,
speed: Optional[float] = 1.0,
copy: Optional[bool] = False,
wait_time: Optional[float] = 1.0,
): # noqa: E501
source = self.ctx.get_element(source_element)
target = self.ctx.ge... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drag_and_drop(self, source_selector, target_selector):\n self._wait_element_localed(self.driver, source_selector)\n source = self.get_element(source_selector)\n self._wait_element_localed(self.driver, target_selector)\n target = self.get_element(target_selector)\n ActionChain... | [
"0.78213465",
"0.7129433",
"0.70079046",
"0.69661415",
"0.6848806",
"0.6613128",
"0.6395738",
"0.5926413",
"0.5638813",
"0.5633318",
"0.5624476",
"0.55691123",
"0.5548099",
"0.5541817",
"0.5535741",
"0.5513431",
"0.5493148",
"0.54817766",
"0.54353875",
"0.5410005",
"0.5406284... | 0.72368634 | 1 |
Enable or disable mouse movement simulation during clicks and other actions. Returns the previous set value as `True`/`False`. | def set_mouse_movement(self, simulate: bool) -> bool:
to_str = lambda state: "ON" if state else "OFF" # noqa: E731
previous = self.ctx.simulate_move
self.logger.info("Previous mouse movement simulation: %s", to_str(previous))
self.ctx.simulate_move = simulate
self.logger.info(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setEnabled(self, boo):\n if boo:\n self.mousePressEvent = self.mousePressEventEnabled\n self.mouseMoveEvent = self.mouseMoveEventEnabled\n self.mouseReleaseEvent = self.mouseReleaseEventEnabled\n else:\n self.mousePressEvent = self.notEnabledDummy\n ... | [
"0.68261725",
"0.6411389",
"0.6155258",
"0.6104473",
"0.60621965",
"0.59738624",
"0.59355164",
"0.5780015",
"0.57259977",
"0.56874037",
"0.5685383",
"0.56765544",
"0.56746906",
"0.56661415",
"0.56610805",
"0.56389785",
"0.56150156",
"0.56149876",
"0.5612128",
"0.5589586",
"0.... | 0.7039132 | 0 |
Given a flow name within this Storage object, load and return the Flow. | def get_flow(self, flow_name: str) -> "Flow":
if flow_name not in self.flows:
raise ValueError("Flow is not contained in this Storage")
req_function = self._method_to_function[self.get_flow_request_http_method]
get_flow_request_kwargs = _render_dict(self.get_flow_request_kwargs)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def read_flow_by_name(\n self,\n flow_name: str,\n ) -> Flow:\n response = await self._client.get(f\"/flows/name/{flow_name}\")\n return Flow.parse_obj(response.json())",
"async def read_flow(self, flow_id: UUID) -> Flow:\n response = await self._client.get(f\"/flows/{... | [
"0.7934159",
"0.646134",
"0.63433677",
"0.6178463",
"0.6128208",
"0.5960097",
"0.5926186",
"0.58671963",
"0.5768048",
"0.56477654",
"0.5555112",
"0.5476098",
"0.53369844",
"0.5315714",
"0.5313755",
"0.5297373",
"0.51395684",
"0.51168096",
"0.510803",
"0.5079798",
"0.50309175"... | 0.81868434 | 0 |
Build the Webhook storage object by issuing an HTTP request to store the flow. If `self.stored_as_script` is `True`, this method will read in the contents of `self.flow_script_path`, convert it to byes, and attach it to the request as `data`. The response from this request is stored in `._build_responses`, a dictionary... | def build(self) -> "Webhook":
self.run_basic_healthchecks()
self._build_responses = {}
for flow_name, flow in self._flows.items():
self.logger.info("Uploading flow '{}'".format(flow_name))
data = flow_to_bytes_pickle(flow)
if self.stored_as_script:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_flow(self, flow_name: str) -> \"Flow\":\n if flow_name not in self.flows:\n raise ValueError(\"Flow is not contained in this Storage\")\n\n req_function = self._method_to_function[self.get_flow_request_http_method]\n\n get_flow_request_kwargs = _render_dict(self.get_flow_req... | [
"0.61519736",
"0.5087138",
"0.5030603",
"0.50136465",
"0.49839678",
"0.4889457",
"0.486859",
"0.48568365",
"0.48356435",
"0.48273116",
"0.4803845",
"0.47970167",
"0.47970167",
"0.47666833",
"0.4761016",
"0.47355944",
"0.47221723",
"0.4658424",
"0.4647923",
"0.4638675",
"0.461... | 0.75592494 | 0 |
Returns question for box specified by id. | def get(self, box_id):
box_id = int(box_id)
res = yield self.db_conn.places.find_one({"id": box_id,
"box": {"$exists": True}},
{"_id": 0, "id": 1, "box.question": 1})
raise gen.Return(res) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_question(self, id):\n\t\tif id < len(self.questions) and id >= 0:\n\t\t\treturn self.questions[id]\n\t\telse:\n\t\t\treturn None",
"def get_single_question(self, id):\n query = (\"SELECT * FROM tbl_questions WHERE question_id = %s;\")\n inputs = id\n user_requests = get_query(query, ... | [
"0.67667735",
"0.6427109",
"0.61088526",
"0.5987204",
"0.59413373",
"0.58789515",
"0.58658487",
"0.58460283",
"0.5844125",
"0.58158547",
"0.5786309",
"0.5746276",
"0.5706206",
"0.56378007",
"0.56141144",
"0.55670446",
"0.5565941",
"0.55076766",
"0.5457137",
"0.53220147",
"0.5... | 0.7585053 | 0 |
Download avalanche (git clone). | def _Download( self ):
self._DownloadPipe += PackageUtil.ExecuteSimpleCommand( "git", ["clone", "git@github.com:mastbaum/avalanche.git", self.GetInstallPath()], None, os.getcwd() )
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _download(self):\n self._system.download(\"http://geant4.web.cern.ch/geant4/support/source/\" + self._tar_name)",
"def __download(self):\n\n # Use the default repository if set to True\n if self.repository is True:\n self.repository = self.__default_repository\n\n if no... | [
"0.6597199",
"0.6479433",
"0.61543876",
"0.6149253",
"0.6069035",
"0.6040472",
"0.6028526",
"0.60164666",
"0.60066116",
"0.5996922",
"0.5990685",
"0.59512675",
"0.59271777",
"0.5907757",
"0.58497226",
"0.58003294",
"0.5779044",
"0.5779044",
"0.57782733",
"0.5770083",
"0.57321... | 0.80656594 | 0 |
Visualize future population density estimates for 20202024 | def pop_dens_tse_viz(city_id: int):
df = pd.read_csv(DATA_FILEPATH3, encoding='utf-8')
df2 = pd.read_csv(DATA_FILEPATH1, encoding='utf-8')
df = df.loc[df['city_id'] == city_id]
df2 = df2.loc[df2['city_id'] == city_id]
x = df['year'].tolist()
y = df2['pop_density'].tolist()
y_hat = df[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visualize(houses:pd.DataFrame) -> None:\n #price_distribution(houses)\n #prop_types(houses)\n #zip_code(houses)\n #year_built(houses)\n #bed_bath(houses)\n return",
"def info_density(self):\n tot_fields = self.tot_col * self.tot_rows # Total number of fields\n pop_fields = 10... | [
"0.5936084",
"0.59231454",
"0.58783734",
"0.58430874",
"0.57707477",
"0.57654625",
"0.5718483",
"0.5718483",
"0.5718483",
"0.56936246",
"0.5689151",
"0.56748796",
"0.56670994",
"0.56580925",
"0.5621095",
"0.56174976",
"0.56142414",
"0.5609334",
"0.55967164",
"0.55960447",
"0.... | 0.61336243 | 0 |
Create list of bigrams from the tweets in the corpus. | def make_bigrams(texts,bigram_mod):
return [bigram_mod[doc] for doc in texts] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_bigrams(bigram_mod, texts):\n return [bigram_mod[doc] for doc in texts]",
"def list_bigrams(sentence_list):\n assert nltk_enabled\n return bigrams(sentence_list)",
"def get_bigrams(self, tokens):\n return [a + \" \" + b for a, b in zip(tokens, tokens[1:])]",
"def _generateBigrams(sel... | [
"0.7402998",
"0.7327968",
"0.7226348",
"0.70147127",
"0.6941188",
"0.68485177",
"0.67478436",
"0.6733484",
"0.6681483",
"0.6675648",
"0.6675056",
"0.66608196",
"0.66165566",
"0.638539",
"0.6374289",
"0.6310031",
"0.6274061",
"0.61876446",
"0.61874664",
"0.6078481",
"0.6074752... | 0.7377119 | 1 |
Graph a list of coherence values to determine the optimal number of topics to model. | def graph_coherence(coherence_values):
limit=50; start=5; step=5;
x = range(start, limit, step)
plt.plot(x, coherence_values)
plt.xlabel("Num Topics")
plt.ylabel("Coherence score")
plt.legend(("coherence_values"), loc='best')
plt.show()
# Print the coherence scores
for m, cv in ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_graph(dictionary, corpus, texts, limit):\n c_v = []\n lm_list = []\n for num_topics in range(1, limit):\n lm = LdaModel(corpus=corpus, num_topics=num_topics, id2word=dictionary)\n lm_list.append(lm)\n cm = CoherenceModel(model=lm, texts=texts, dictionary=dictionary, coher... | [
"0.6930295",
"0.63584644",
"0.61313343",
"0.6051337",
"0.604479",
"0.6038947",
"0.5999525",
"0.5987457",
"0.5987457",
"0.59873605",
"0.5962324",
"0.5821641",
"0.580799",
"0.57936347",
"0.57869893",
"0.57646865",
"0.5700302",
"0.56867707",
"0.56204665",
"0.5589136",
"0.5557433... | 0.76849127 | 0 |
Compute aggregations and statistics on the topics modeled in a corpus, code sourced from the excellent tutorial at Machine Learning Plus found at the link below. | def topic_stats(df_topic_sents_keywords):
# Number of Documents for Each Topic
topic_counts = df_topic_sents_keywords['Dominant_Topic'].value_counts()
# Percentage of Documents for Each Topic
topic_contribution = round(topic_counts/topic_counts.sum(), 4)
# Topic Number and Keywords
topic_num_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def summarize_corpus():\n\t\n\t# get metadata\n\t#get_metadata.from_TEIP5(wdir, corpus_inpath, \"metadata\", md_mode)\n\t\n\t# visualize some metadata\n\t#visualize_metadata.describe_corpus(wdir, md_csv, \"author-continent\")\n\tvisualize_metadata.describe_corpus(wdir, md_csv, \"author-country\")\n\t#visualize_met... | [
"0.70244294",
"0.68748534",
"0.6591268",
"0.6581112",
"0.65675104",
"0.6498032",
"0.643722",
"0.6387676",
"0.6356621",
"0.6299352",
"0.6263404",
"0.6244149",
"0.6227684",
"0.6212978",
"0.6196245",
"0.6191798",
"0.61890405",
"0.61863583",
"0.6175882",
"0.6173014",
"0.6144387",... | 0.6979981 | 1 |
Produce a wordcloud for each topic in the model. | def topic_wordcloud(top_model):
cols = [color for name, color in mcolors.TABLEAU_COLORS.items()] # more colors: 'mcolors.XKCD_COLORS'
cloud = WordCloud(stopwords=stop_words,
background_color='white',
width=2500,
height=1800,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_wordcloud():\r\n # \"\"\"Join list into one string\"\"\"\r\n # unique_string = (\" \").join(prioritized)\r\n # wc = WordCloud(background_color=\"black\", width=2000, height=2000,contour_color=\"black\", max_words=30, relative_scaling=0.5, normalize_plurals=False).gener... | [
"0.6780629",
"0.6701198",
"0.6542724",
"0.63414407",
"0.6313984",
"0.6294399",
"0.62759715",
"0.6208082",
"0.62076896",
"0.61579335",
"0.61363643",
"0.60813165",
"0.59867287",
"0.5982095",
"0.5903823",
"0.5860784",
"0.58562374",
"0.58351845",
"0.58272153",
"0.58073676",
"0.58... | 0.7072422 | 0 |
Integration test to ensure that the API requests are rate limited | def test_api_requests_limited(self):
did_reach_rate_limit = False
for _ in range(110):
response = self.send_get('Participant', expected_status=None)
if response.status_code == TooManyRequests.code:
did_reach_rate_limit = True
break
self.a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_rate_limited(self):\n response = self._mock_utility(get_kwargs=self._data(),\n error=fitbit_exceptions.HTTPConflict)\n self._check_response(response, 105)",
"def test_requests_are_throttled(self):\n request = self.factory.get('/')\n for du... | [
"0.7972853",
"0.7692225",
"0.7422559",
"0.7316215",
"0.7265686",
"0.7235707",
"0.71683854",
"0.7100706",
"0.70878667",
"0.7071839",
"0.7004152",
"0.6937514",
"0.69061965",
"0.68870467",
"0.68552417",
"0.68479383",
"0.6826209",
"0.6771384",
"0.6626057",
"0.66125566",
"0.660881... | 0.7899416 | 1 |
Make sure that when a limit is reached on one endpoint, another is still available | def test_distinct_endpoint_limits(self):
# Hit the rate limit for the Participant endpoint
self._reach_rate_limit(url='Participant')
# Expect a request on another endpoint to succeed
self.send_post('Participant/P123123123/Observation', expected_status=200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_requests_limited(self):\n\n did_reach_rate_limit = False\n for _ in range(110):\n response = self.send_get('Participant', expected_status=None)\n if response.status_code == TooManyRequests.code:\n did_reach_rate_limit = True\n break\n\n... | [
"0.6913083",
"0.64372456",
"0.6194626",
"0.61393696",
"0.61300164",
"0.60951686",
"0.6094754",
"0.60827464",
"0.60371524",
"0.5984565",
"0.59638983",
"0.5903768",
"0.589939",
"0.588165",
"0.5875936",
"0.5867579",
"0.5845911",
"0.5837239",
"0.57767206",
"0.57161754",
"0.571454... | 0.6499776 | 1 |
return a list of all models containing the case insensitive 'grep' string which defaults to 'trail' for this exercise, sort the resulting sequence alphabetically | def get_all_matching_models(cars=cars, grep='trail'):
matched = []
for v in cars.values():
for i in v:
if grep.lower() in i.lower():
matched.append(i)
return sorted(matched) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_matching_models(grep='trail'):\n lst = []\n for make, model in cars.items():\n for version in model:\n if grep.upper() in version.upper():\n lst.append(version)\n return sorted(lst)",
"def get_all_matching_models(cars=cars, grep=\"trail\"):\r\n search_trai... | [
"0.7598126",
"0.73557544",
"0.6286624",
"0.6246177",
"0.58713245",
"0.55417883",
"0.5457469",
"0.5410914",
"0.53014374",
"0.52890766",
"0.5284026",
"0.5279538",
"0.52334017",
"0.523238",
"0.52085274",
"0.51918423",
"0.51666814",
"0.51105857",
"0.51055306",
"0.5099197",
"0.507... | 0.7375759 | 1 |
return a copy of the cars dict with the car models (values) sorted alphabetically | def sort_car_models(cars=cars):
return {k:sorted(cars[k]) for k in cars.keys()} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_car_models():\n for make, model in cars.items():\n cars[make] = sorted(model)\n return cars",
"def sort_car_models(cars=cars):\r\n for model in cars:\r\n cars[model].sort()\r\n return cars",
"def load_car_models(self):\n car_models_all = OrderedDict([])\n loggin... | [
"0.8386408",
"0.78856957",
"0.6111236",
"0.5691202",
"0.56717473",
"0.5667032",
"0.5664055",
"0.5633449",
"0.55873",
"0.5546567",
"0.5545345",
"0.5537814",
"0.5529127",
"0.5487243",
"0.54769766",
"0.5475808",
"0.54684997",
"0.54667825",
"0.5397825",
"0.538667",
"0.5378415",
... | 0.8272651 | 1 |
Allocates regs to the intra bbl live ranges Note, this runs after global register allocation has occurred | def _BblRegAllocOrSpill(bbl: ir.Bbl, fun: ir.Fun) -> int:
VERBOSE = False
if VERBOSE:
_DumpBblWithLineNumbers(bbl)
live_ranges = liveness.BblGetLiveRanges(bbl, fun, bbl.live_out)
live_ranges.sort()
for lr in live_ranges:
assert liveness.LiveRangeFlag.IGNORE not in lr.flags
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def PhaseGlobalRegAlloc(fun: ir.Fun, _opt_stats: Dict[str, int], fout):\n debug = None\n if fout:\n print(\"#\" * 60, file=fout)\n print(f\"# GlobalRegAlloc {fun.name}\", file=fout)\n print(\"#\" * 60, file=fout)\n\n # print (\"@@@@@@\\n\", \"\\n\".join(serialize.FunRenderToAsm(fun)))... | [
"0.64274806",
"0.575689",
"0.5651436",
"0.55086535",
"0.54175746",
"0.5359126",
"0.52838314",
"0.5279008",
"0.52514446",
"0.524858",
"0.5248286",
"0.51806515",
"0.51806515",
"0.51746655",
"0.51346993",
"0.5124681",
"0.5122819",
"0.5097571",
"0.5084451",
"0.5065766",
"0.505006... | 0.64295065 | 0 |
Removes all fields instead the whitelisted fields from the form. | def whitelist_form_fields(form, whitlisted_fields):
for schema in getAdditionalSchemata(form):
behavior_interface_name = schema.__name__
for fieldname in schema:
full_name = '{}.{}'.format(behavior_interface_name, fieldname)
if full_name in whitlisted_fields:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_all_fields(self):\n self.fields = None",
"def filter_allowed_fields(self):\n allowed_fields = super().filter_allowed_fields\n # Remove assignment_id\n allowed_fields.remove('assignment_id')\n return allowed_fields",
"def strip_unwanted_fields(self, data, many, **kw... | [
"0.79055166",
"0.6998252",
"0.66042054",
"0.63483155",
"0.63071465",
"0.62416124",
"0.62240094",
"0.6199403",
"0.61980444",
"0.61398077",
"0.60742",
"0.60416746",
"0.60010546",
"0.5952623",
"0.59316224",
"0.59096444",
"0.5899072",
"0.5849075",
"0.5842647",
"0.5833446",
"0.583... | 0.7426219 | 1 |
Returns the dossier's comment truncated to characters defined in `threshold` and transformed as web intelligent text. | def get_formatted_comments(self, threshold=400):
comments = IDossier(self).comments
if comments:
if threshold:
comments = truncate_ellipsis(comments, threshold)
return api.portal.get_tool(name='portal_transforms').convertTo(
'text/html', comments, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shortened_text(self, max_chars=50):\n if len(self.comment) > max_chars:\n return self.comment[:max_chars] + \"...\"\n else:\n return self.comment",
"def short_comment(self):\n return self.comment if len(self.comment) <= 500 else self.comment[:497] + '...'",
"def c... | [
"0.64614934",
"0.6283325",
"0.58088666",
"0.56076866",
"0.5597876",
"0.5530404",
"0.5395029",
"0.53850037",
"0.5335696",
"0.5300687",
"0.5252912",
"0.5242726",
"0.5216234",
"0.5207592",
"0.51818043",
"0.5179468",
"0.5174526",
"0.516574",
"0.5146242",
"0.51450276",
"0.5144813"... | 0.7867259 | 0 |
Check if the theme is a legit name. | def check_theme(theme: str) -> bool:
themes = ["dark", "light"]
return theme in themes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def theme_named(self, name):\n for theme in self.themes:\n if theme.get('name', 'Error') == name:\n return theme",
"def _check_name(self):\n\t\tpass",
"def validate_theme(theme):\n try:\n get_theme(theme)\n except KeyError:\n raise FlaskBBCLIError(\"Theme {}... | [
"0.6778209",
"0.6598484",
"0.65919214",
"0.6457272",
"0.64410216",
"0.6383648",
"0.63204575",
"0.62847066",
"0.6187711",
"0.61557186",
"0.61436516",
"0.61436516",
"0.61221594",
"0.6107752",
"0.60583967",
"0.6036885",
"0.60194457",
"0.60114294",
"0.5958369",
"0.5951348",
"0.59... | 0.68623817 | 0 |
Generate a mixin for a file based data source allowing for custom storage and file path. storage A django FileStorage implementation upload_to the default path for an uploaded file | def make_file_data_source_mixin(storage, upload_to):
class FileDataSourceMixin(TransformMixin, models.Model):
file = models.FileField(
storage=storage,
upload_to=upload_to,
max_length=255)
class Meta:
abstract = True
def get_trans... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_file_storage(source='local', **kwargs):\n pass",
"def __init__(self, path, storage=None):\n self.path = path\n storage = storage or default_storage\n file = storage.open(path)\n folder, name = os.path.split(path)\n super(OnStoragePlaceholderImage, self).__init__(file... | [
"0.5999614",
"0.57056445",
"0.5692524",
"0.5664402",
"0.54976845",
"0.5455176",
"0.5389421",
"0.53479695",
"0.5321149",
"0.52183753",
"0.51447207",
"0.51183665",
"0.51019454",
"0.50965655",
"0.5039249",
"0.5037354",
"0.5000094",
"0.49935773",
"0.49740922",
"0.49714348",
"0.49... | 0.82667536 | 0 |
Copy compiled libraries to the destination directory. | def copy_compiled_libs(libs, dest_dir):
for lib in libs:
try:
shutil.copy2(lib, dest_dir)
except shutil.SameFileError:
# In case the file is the same do nothing
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_files():\n os.makedirs('build/usr/lib/python3/dist-packages', exist_ok=True)\n os.makedirs('build/usr/share/doc', exist_ok=True)\n\n shutil.copytree('applications', 'build/usr/share/applications')\n shutil.copytree('doc', 'build/usr/share/doc/qastetray')\n shutil.copytree('icons', 'build/us... | [
"0.66713417",
"0.66010416",
"0.6322739",
"0.62808627",
"0.62084883",
"0.6112713",
"0.60485387",
"0.60182065",
"0.6004007",
"0.59704936",
"0.5963938",
"0.5953608",
"0.59527844",
"0.59078825",
"0.5838055",
"0.58280647",
"0.5826412",
"0.57765",
"0.57580847",
"0.5748392",
"0.5702... | 0.7685799 | 0 |
Copy fonts to the destination directory. | def copy_fonts(dest_dir):
dst_fonts = os.path.join(dest_dir, "fonts")
if not os.path.exists(dst_fonts):
shutil.copytree("third_party/fonts", dst_fonts) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_fonts():\n fonts_path = os.path.join(settings.BASE_DIR, 'themes/CMESH/assets/fonts/')\n static_fonts = os.path.join(settings.BASE_DIR, 'static/CMESH/fonts/')\n\n copy_files(fonts_path, static_fonts)",
"def copyFiles(self, package):\n styleFiles = [self.stylesDir/'..'/'base.css']\n\ts... | [
"0.7423674",
"0.6394532",
"0.5915496",
"0.57542723",
"0.56963205",
"0.5688823",
"0.5684097",
"0.54807836",
"0.5476413",
"0.5423028",
"0.52957565",
"0.5285343",
"0.5275628",
"0.5275146",
"0.5246063",
"0.5246063",
"0.5233216",
"0.51839244",
"0.51810575",
"0.5159028",
"0.5126567... | 0.8532442 | 0 |
Clean up (if necessary) some directories before or after running setup in development (a.k.a. editable) mode (`pip install e .`). | def process_develop_setup():
if 'develop' in sys.argv and os.path.exists('build'):
# Remove `build` directory created by a regular installation
shutil.rmtree('build')
elif 'develop' not in sys.argv and os.path.exists('gfootball_engine'):
# If `pip install .` is called after development mode,
# remov... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_extra_package_managment_files():\n use_pipenv = '{{cookiecutter.use_pipenv}}'\n to_delete = []\n\n if use_pipenv == 'yes':\n to_delete = to_delete + ['requirements.txt', 'requirements']\n else:\n to_delete.append('Pipfile')\n\n try:\n for file_or_dir in to_delete:\n ... | [
"0.71108127",
"0.68683255",
"0.67774886",
"0.6693352",
"0.6641649",
"0.6542424",
"0.65015703",
"0.6454592",
"0.6448003",
"0.642705",
"0.64063084",
"0.6391795",
"0.63572025",
"0.6351599",
"0.6341543",
"0.6330253",
"0.63125664",
"0.6296481",
"0.6277156",
"0.625509",
"0.62381727... | 0.72018105 | 0 |
Parse a date string in ISO format to date. | def parse_iso_date(date_string):
try:
return date.fromisoformat(date_string)
except ValueError:
raise DomainError("Incorrect date format!", "D0001") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_date(str_date):\n return ciso8601.parse_datetime(str_date)",
"def parse_isodate(iso_date):\n date = None\n\n try:\n date = isodate.parse_date(iso_date)\n except Exception, e:\n log.msg(e.message, level=log.WARNING)\n\n return date",
"def parse_iso_date(value):\n tr... | [
"0.81124496",
"0.784937",
"0.7772179",
"0.7659335",
"0.756239",
"0.7560333",
"0.7529543",
"0.7510865",
"0.73808056",
"0.73538923",
"0.7336985",
"0.72911686",
"0.71597624",
"0.7120003",
"0.70880926",
"0.7080191",
"0.7057957",
"0.7048546",
"0.70407164",
"0.7012259",
"0.69873905... | 0.8319153 | 0 |
Initialise database with default admin and user(s) | def initDB():
global DATABASE
uid0 = generate_resource_uid('Admin1', 0)
DATABASE["users"] = {
"Admin1": {
"Type": "admin",
"Password": "AdminPass",
"Quota": int(sys.maxsize),
"Resources": {uid0},
"Created": 1,
},
"User1": ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initDb():\n createDb()\n admin = User(\n name=\"faby\",\n lastname=\"star\",\n username=\"faby\",\n email=\"star._faby@hotmail.com\",\n isAdmin=True,\n cellphone=\"0983856136\",\n )\n admin.onSetPassord(\"faby123\")\n db.session.add(admin)\n db.sessio... | [
"0.8030841",
"0.79336005",
"0.7773083",
"0.7749264",
"0.7702155",
"0.75949013",
"0.7499129",
"0.7461483",
"0.7333598",
"0.72975147",
"0.7280645",
"0.7246277",
"0.72303087",
"0.71908814",
"0.71737117",
"0.7151373",
"0.7068662",
"0.6995089",
"0.69748044",
"0.6951029",
"0.690964... | 0.7942322 | 1 |
Calculates soiling ratio given particulate and rain data using the model from Humboldt State University [1]_. | def soiling_hsu(rainfall, cleaning_threshold, tilt, pm2_5, pm10,
depo_veloc={'2_5': 0.004, '10': 0.0009},
rain_accum_period=pd.Timedelta('1h')):
try:
from scipy.special import erf
except ImportError:
raise ImportError("The soiling_hsu function requires scipy.")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculateR(sapienses: list) -> float:\n r = 0\n for i in sapienses:\n r = r + i.numberInfected\n r=r/I0\n r = r*S/(S+R+D)\n return r",
"def model_prem(r):\n\n\t#- normalised radius\n\tx = r / 6371000.0\n\n\t#- march through the various depth levels --------------------------------------... | [
"0.64087194",
"0.5757915",
"0.572986",
"0.57080287",
"0.5643513",
"0.558052",
"0.5507402",
"0.54924387",
"0.548126",
"0.54473543",
"0.54449123",
"0.54353803",
"0.54346627",
"0.5412862",
"0.53879434",
"0.5387771",
"0.5387159",
"0.53812027",
"0.53757817",
"0.5369851",
"0.535662... | 0.6184165 | 1 |
r"""Preprocess `news_collection.csv` and convert into `lmp.dataset.LanguageModelDataset`. | def _preprocess_news_collection(
column: str
) -> lmp.dataset.LanguageModelDataset:
if not isinstance(column, str):
raise TypeError('`column` must be an instance of `str`.')
file_path = os.path.join(f'{lmp.path.DATA_PATH}', 'news_collection.csv')
if not os.path.exists(file_path):
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess(self):\n\n self._build_labels_dict(['one', 'two', 'three', 'four', 'five'])\n\n with open(self.data_path + self.file_name, 'rb') as csvfile:\n\n reader = csv.reader(csvfile, delimiter=\",\")\n for row in reader:\n self.texts.append(row[1])\n ... | [
"0.6370065",
"0.6219334",
"0.6200984",
"0.6183939",
"0.6136471",
"0.61227214",
"0.60809225",
"0.59827965",
"0.5978353",
"0.5963629",
"0.5912398",
"0.5890645",
"0.5890645",
"0.5890645",
"0.5887151",
"0.58484054",
"0.5817602",
"0.5811613",
"0.5810188",
"0.5794005",
"0.5792081",... | 0.7806552 | 0 |
r"""Preprocess `wiki..tokens` and convert into `lmp.dataset.LanguageModelDataset`. | def _preprocess_wiki_tokens(split: str) -> lmp.dataset.LanguageModelDataset:
if not isinstance(split, str):
raise TypeError('`split` must be an instance of `str`.')
file_path = os.path.join(f'{lmp.path.DATA_PATH}', f'wiki.{split}.tokens')
if not os.path.exists(file_path):
raise FileNotFoun... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_wiki_tokenized() -> pd.DataFrame:\n text_ids = []\n text_string = []\n articles = []\n text_ids_intro = []\n\n with open(WIKI_ARTICLES_TOKENIZED_PATH, \"r\") as json_file:\n json_list = list(json_file)\n\n for json_str in tqdm(json_list):\n result = json.loads(json_str)\... | [
"0.66479766",
"0.6226101",
"0.61701614",
"0.6134741",
"0.60984904",
"0.6041527",
"0.6009486",
"0.59737575",
"0.59614587",
"0.5945968",
"0.591458",
"0.5903691",
"0.59022385",
"0.58789974",
"0.58743083",
"0.5867766",
"0.585464",
"0.58138835",
"0.58111805",
"0.5810568",
"0.58034... | 0.8668603 | 0 |
r"""Preprocess `wordtest.v1.txt` and convert into `lmp.dataset.AnalogyDataset`. | def _preprocess_word_test_v1() -> lmp.dataset.AnalogyDataset:
file_path = os.path.join(f'{lmp.path.DATA_PATH}', 'word-test.v1.txt')
if not os.path.exists(file_path):
raise FileNotFoundError(f'file {file_path} does not exist.')
with open(file_path, 'r', encoding='utf8') as input_file:
# Rem... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_preprocessing():\n lineid_content = get_lineid_content()\n print('Read movie_lines.txt file complete...')\n convos = get_convos()\n print('Read movie_conversations.txt file complete...')\n print('Building dataset')\n get_data(lineid_content, convos)",
"def _init_dataset(self):\n ... | [
"0.61875474",
"0.60985136",
"0.5962654",
"0.59296596",
"0.5919968",
"0.58807945",
"0.5878281",
"0.58674693",
"0.5854215",
"0.5844582",
"0.58382046",
"0.5831682",
"0.58153903",
"0.5806589",
"0.5797713",
"0.5790728",
"0.57761437",
"0.5760811",
"0.57218736",
"0.5715228",
"0.5712... | 0.89427596 | 0 |
Base function for registering a customized module to a module dictionary | def register(key, module, module_dict):
if key in module_dict:
raise KeyError('Key {} is already pre-defined.'.format(key))
else:
module_dict[key] = module | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register(self, module):\n tagvalues = \"\\n\".join([\"%s: %s\" % (attr, str(getattr(module, attr))) for attr in dir(module) if attr in ['create', 'menu', 'name', 'label'] ])\n # tagvalues = \"\\n\".join([\"%s\" % (attr) for attr in dir(module) if attr not in ['urls'] ])\n logger.debug(\"mo... | [
"0.7250419",
"0.710624",
"0.7084187",
"0.70116746",
"0.68409985",
"0.68305075",
"0.665472",
"0.660029",
"0.6517815",
"0.6354334",
"0.6334482",
"0.6305535",
"0.6279934",
"0.6278782",
"0.62353134",
"0.6227171",
"0.6219403",
"0.6196198",
"0.6188337",
"0.6188337",
"0.6188337",
... | 0.73679656 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.