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 |
|---|---|---|---|---|---|---|
Get hosted zone by looking up account name and using that to tell which zone to return. | def get_hosted_zone(session):
account = get_account_id_from_session(session)
if account == hosts.PROD_ACCOUNT:
return hosts.PROD_DOMAIN
elif account == hosts.DEV_ACCOUNT:
return hosts.DEV_DOMAIN
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_zone(cls, name):\n\n def get_closest(n):\n \"\"\"\n Return closest matching zone\n \"\"\"\n while n:\n try:\n return DNSZone.objects.get(name=n)\n except DNSZone.DoesNotExist:\n pass\n ... | [
"0.7249278",
"0.70573413",
"0.6600804",
"0.6556853",
"0.65454966",
"0.6509461",
"0.6491115",
"0.64886916",
"0.64364696",
"0.6349082",
"0.6179819",
"0.61753106",
"0.61310756",
"0.61241627",
"0.6072795",
"0.59662193",
"0.5963174",
"0.5910606",
"0.58478206",
"0.58478206",
"0.584... | 0.7208443 | 1 |
Updates or Creates a domain name with FQDN resource. | def set_domain_to_dns_name(session, domain_name, dns_resource, hosted_zone):
if session is None:
return None
client = session.client('route53')
hosted_zone_id = get_hosted_zone_id(session, hosted_zone)
if hosted_zone_id is None:
print("Error: Unable to find Route 53 Hosted Zone, " + ho... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_dns(self):\n if self.ptr:\n which_zone = None\n zones = dns.models.Zone.objects.all()\n for zone in zones:\n if self.ptr.endswith(zone.name) or self.ptr.endswith(zone.name + '.'):\n which_zone = zone\n break\n\n... | [
"0.61005515",
"0.5949715",
"0.58637345",
"0.58026123",
"0.57765675",
"0.57385725",
"0.56413877",
"0.5568498",
"0.55607516",
"0.5557578",
"0.55217475",
"0.55150574",
"0.55067784",
"0.5486445",
"0.5471696",
"0.5465719",
"0.546032",
"0.5456307",
"0.54177785",
"0.5328181",
"0.532... | 0.62173575 | 0 |
Delete all of the matching CNAME records from a DNS Zone | def route53_delete_records(session, hosted_zone, cname):
if session is None:
return None
client = session.client('route53')
hosted_zone_id = get_hosted_zone_id(session, hosted_zone)
if hosted_zone_id is None:
print("Could not locate Route53 Hosted Zone '{}'".format(hosted_zone))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_deletednsrecord(kasserver, kasapi):\n kasserver.delete_dns_record(\"test.example.com\", \"CNAME\")\n assert kasapi.requests_contains(\"delete_dns_settings\")",
"def delete_container_links(container):\n container_uri = container.cdn_uri.replace(\"http://\", \"\")\n domain = get_domain... | [
"0.68798274",
"0.6212371",
"0.6047711",
"0.60346884",
"0.5980792",
"0.58506405",
"0.5818954",
"0.57226974",
"0.5720566",
"0.57001406",
"0.56724554",
"0.56326467",
"0.56292945",
"0.56163657",
"0.5554157",
"0.554218",
"0.55259824",
"0.5514953",
"0.5445766",
"0.5426144",
"0.5409... | 0.70036846 | 0 |
Unsubscribe all subscriptions for the given SNS topic | def sns_unsubscribe_all(session, topic, region="us-east-1", account=None):
if session is None:
return None
if account is None:
account = get_account_id_from_session(session)
topic = "arn:aws:sns:{}:{}:{}".format(region, account, topic.replace(".", "-"))
client = session.client('sns')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def unsubscribe(self, topic: str, subscription_id: int = None) -> None:\n ...",
"async def unsubscribe_topics(self) -> None:\n self._sub_state = await self._mqtt_client.unsubscribe(self._sub_state)",
"def unsubscribe(self, topic):\n request = protos.RequestUnsubscribe(topic=topic)\n ... | [
"0.78564173",
"0.7503416",
"0.7494931",
"0.7264927",
"0.7082679",
"0.6934921",
"0.6786763",
"0.6547516",
"0.6486138",
"0.6444043",
"0.64201444",
"0.6402963",
"0.63842636",
"0.63343644",
"0.6314208",
"0.63087684",
"0.62940603",
"0.6240863",
"0.6240863",
"0.62375754",
"0.623116... | 0.811901 | 0 |
Delete all of the IAM policies that start with the given domain name | def policy_delete_all(session, domain, path="/"):
client = session.client('iam')
resp = client.list_policies(Scope='Local', PathPrefix=path)
prefix = domain.replace('.', '-')
for policy in resp.get('Policies', []):
if policy['PolicyName'].startswith(prefix):
ARN = policy['Arn']
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy_all(self):\n for name in self.app.config['SIMPLE_DOMAINS']:\n self.connection.delete_domain(name)",
"def delete_policies():\n if PoliciesOutput.POLICIES_EVENT not in ctx.instance.runtime_properties:\n return\n\n service_component_name = ctx.instance.runtime_... | [
"0.6473392",
"0.6243997",
"0.5969745",
"0.5849608",
"0.57430595",
"0.57022417",
"0.5679662",
"0.56782377",
"0.5672439",
"0.56152827",
"0.55565584",
"0.54859465",
"0.5423485",
"0.5404208",
"0.5362759",
"0.53223443",
"0.5299086",
"0.5266806",
"0.5250096",
"0.52498037",
"0.52363... | 0.71195954 | 0 |
gets the account id from the session using the iam client. This method will work even if you have assumed a role in another account. | def get_account_id_from_session(session):
if session is None:
return None
return session.client('iam').list_users(MaxItems=1)["Users"][0]["Arn"].split(':')[4] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def account_id():\n return client.get_caller_identity()['Account']",
"def id(self) -> str:\n account_id = self.__session.client(\"sts\").get_caller_identity().get(\"Account\")\n if account_id:\n return account_id\n raise ValueError(\"get_caller_identity did not return Account\"... | [
"0.716123",
"0.69258696",
"0.6868835",
"0.6868835",
"0.6868835",
"0.6868835",
"0.6868835",
"0.6868835",
"0.6868835",
"0.6868835",
"0.6804414",
"0.67929757",
"0.67919576",
"0.6678467",
"0.6673702",
"0.661376",
"0.6577138",
"0.6577138",
"0.6577138",
"0.6577138",
"0.6577138",
... | 0.797403 | 0 |
Returns the arn for a lambda given a lambda function name. | def lambda_arn_lookup(session, lambda_name):
if session is None:
return None
client = session.client("lambda")
response = client.get_function(FunctionName=lambda_name)
if response is None:
return None
else:
return response['Configuration']['FunctionArn'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lambda_arn(region: str, first_part: str, second_part: str=None) -> str:\n client = boto3.client('lambda', region_name=region)\n response = client.list_functions()\n for x in response['Functions']:\n if second_part:\n if first_part in x['FunctionArn'] and second_part in x['Functio... | [
"0.62491465",
"0.6024986",
"0.59035015",
"0.5837769",
"0.5678364",
"0.56479216",
"0.55890566",
"0.54492086",
"0.5431791",
"0.5426185",
"0.53477263",
"0.52988434",
"0.52703404",
"0.5237456",
"0.5228843",
"0.5223322",
"0.52192754",
"0.52119076",
"0.5209872",
"0.52070284",
"0.51... | 0.7466593 | 0 |
Use SHA1 hash to hash a string, convert it to integer and shift right (160 m) places | def chord_hash(input_string):
h = hashlib.sha1() # 160 bit string
encoded_data = input_string.encode('utf-8')
h.update(encoded_data)
hex_string = h.hexdigest()
hex_value = int(hex_string, 16)
hash_integer_value = hex_value >> (160 - m)
return hash_integer_value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sha1(self, s):\n\t\tself.sha1_calls += 1\n\t\treturn int(hashlib.sha1(s).hexdigest(), 16)",
"def computeHash(string):\n\tif isBytes(string):\n\t\tstring = string.decode(\"latin-1\")\n\thash_ = 63689\n\tfor char in string:\n\t\thash_ = hash_ * 378551 + ord(char)\n\treturn hash_ % 65536",
"def strhash(s: str... | [
"0.7196707",
"0.71366036",
"0.69533736",
"0.6906234",
"0.6869732",
"0.6842359",
"0.68278766",
"0.6794289",
"0.6765675",
"0.6747291",
"0.6716161",
"0.65964735",
"0.6587518",
"0.6550875",
"0.65399194",
"0.6535304",
"0.6471856",
"0.6450568",
"0.6412695",
"0.6410531",
"0.6410033"... | 0.7221014 | 0 |
Checks if a given value is in the range start to end while considering given options, i.e., including/excluding start and/or end of the range. | def is_between(value, start, end, including_start=False, including_end=False):
if not including_start and not including_end: # not include both start and end
if (start < value < end):
return True
elif (start > end) and (start < value <= (2**m - 1) or 0 <= value < end):
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_range(start, end, x):\n if start <= end:\n return start <= x <= end\n else:\n return start <= x or x <= end",
"def check_ranges(ranges, value):\n for fromto in ranges:\n start, end = fromto.split('-')\n if int(value) in range(int(start), int(end) + 1):\n return True\n ... | [
"0.747743",
"0.7280649",
"0.70743567",
"0.69564146",
"0.6774148",
"0.6771647",
"0.6761343",
"0.67048234",
"0.66715246",
"0.6633946",
"0.65986615",
"0.6595173",
"0.6571696",
"0.6535455",
"0.6530302",
"0.6497032",
"0.6490265",
"0.64786255",
"0.64565444",
"0.6445503",
"0.6378988... | 0.7582872 | 0 |
remove a connection from a node, by the id of the other node in the connection | def remove_connection_by_id(self, node_id: int):
for conn in self.get_connections():
if conn.other.node_id == node_id:
self.remove_connection(conn)
break | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_connection(self, conn: Connection):\n self.__connections.remove(conn)\n # now from other:\n other = conn.other\n for others_conn in other.get_connections():\n if others_conn.other.node_id == self.node_id:\n other.__connections.remove(others_conn)\n ... | [
"0.75725925",
"0.7457941",
"0.7354663",
"0.7288606",
"0.72552603",
"0.70799124",
"0.70066655",
"0.6946529",
"0.69460434",
"0.6903269",
"0.68844795",
"0.68477476",
"0.6784337",
"0.6707545",
"0.668367",
"0.66627955",
"0.6633565",
"0.65117043",
"0.649248",
"0.64896923",
"0.64595... | 0.8295772 | 0 |
Generate key using random bytes with specified size. | def generate_key(self, size):
key = bytearray()
for i in range(0,size):
random_byte = ord(os.urandom(1))
key.append(random_byte)
return key | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_key():\n return get_random_bytes(KEY_SIZE)",
"def random_key(size):\n return ''.join(random.choice(string.letters) for _ in range(size))",
"def get_random_secret_key(cls, size=None):\n if not size:\n size = cls.default_secret_key_size\n return os.urandom(size)",
"d... | [
"0.86057556",
"0.80857086",
"0.8032245",
"0.8031311",
"0.8002937",
"0.79636395",
"0.7943351",
"0.790454",
"0.7867546",
"0.7851878",
"0.77818877",
"0.7591018",
"0.7578894",
"0.75569624",
"0.7556202",
"0.74411345",
"0.74128795",
"0.73925257",
"0.7379331",
"0.72996837",
"0.72394... | 0.8874437 | 0 |
'Encrypt' the password with the key. Reverse key bytes and XOR with password bytes. Very low security but a bit obfuscated. | def mix_keys(self, password, key):
rev_key = list(reversed(key)) # Reverse bytes
result = bytearray()
for i in range(0, len(password)):
xored = password[i] ^ rev_key[i] # Mix each byte
result.append(xored)
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xor_encode(data, key):\n if not data:\n return \"\"\n if not key:\n raise exceptions.EncryptError\n return binascii.hexlify(\n ''.join(chr(ord(a) ^ ord(b)) for a, b in zip(data, key)).encode(\"utf-8\")).decode(\"utf-8\")",
"def encrypt_password(pass_to_encrypt):\n\n temp_key ... | [
"0.71066976",
"0.70337445",
"0.70089537",
"0.6976745",
"0.69720566",
"0.68509895",
"0.6773852",
"0.6713531",
"0.669853",
"0.6677601",
"0.66625684",
"0.6630633",
"0.66287386",
"0.6601027",
"0.6546598",
"0.65335375",
"0.6481441",
"0.64804226",
"0.646954",
"0.6465444",
"0.643424... | 0.70879525 | 1 |
Finds the peak in the specified time range. Finds the peak in the data in the specified time range. You must pass it pretrigger and timebase as well as the time and data series. timebase is an integer equal to (1 us)/(delta t of the digitizer). For example, if capturing data at 10 MHz, timebase = (1e6/1e7) = 10. For da... | def polyPeak_noPlot(time, data, timerange = [40,80],axis = 'x'):
# Find the indices corresponding to the ends of the time range
t1 = mj.tindex(time,timerange[0])#+pretrigger)
t2 = mj.tindex(time,timerange[1])#+pretrigger)
# print 't1=', t1
# print 't2=', t2
# generate an array of indices spanni... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def peak(data, fft_data=None):\n return np.max(np.abs(data))",
"def find_peak(mhw, mhw_relSeas, ev, tt_start):\n tt_peak = np.argmax(mhw_relSeas)\n mhw[\"time_peak\"].append(mhw[\"time_start\"][ev] + tt_peak)\n mhw[\"date_peak\"].append(date.fromordinal(mhw[\"time_start\"][ev] + tt_peak))\n mhw[\"... | [
"0.6256507",
"0.62215835",
"0.61286575",
"0.59447867",
"0.5906512",
"0.5898816",
"0.58075976",
"0.5780191",
"0.57295424",
"0.5648836",
"0.5639455",
"0.5607322",
"0.5568726",
"0.55157095",
"0.551521",
"0.5498673",
"0.54892355",
"0.54749453",
"0.5392688",
"0.53639615",
"0.53472... | 0.6415059 | 0 |
Provides positions in meters along probe stalks for 4x4 array of probes built by M. Kaur. | def get_probeLocs_calib_setup(dir, num_probes = 16):
position_vectors = [[0] * 3 for i in range(num_probes)]
#every x postion
# Convert to meters
x_pos = [-4.25*1e-3*25.4, -4.25*1e-3*25.4, 4.24*1e-3*25.4, 4.24*1e-3*25.4]
y_pos = [-4.25*1e-3*25.4, 4.24*1e-3*25.4, 4.24*1e-3*25.4, -4.25*1e-3*25.4]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_probeLocs_calib_setup_cm(dir, num_probes = 16):\n position_vectors = [[0] * 3 for i in range(num_probes)]\n\n #every x postion\n\n # Convert to meters\n x_pos = [-4.25*2.54, -4.25*2.54, 4.24*2.54, 4.24*2.54]\n y_pos = [-4.25*2.54, 4.24*2.54, 4.24*2.54, -4.25*2.54]\n z_pos = [-2.25*2.54, -... | [
"0.68602735",
"0.635877",
"0.622993",
"0.62070554",
"0.57699996",
"0.5661007",
"0.5541144",
"0.54987085",
"0.54753906",
"0.54418695",
"0.5396649",
"0.5383856",
"0.53815603",
"0.5378696",
"0.53735656",
"0.534419",
"0.53433716",
"0.5325735",
"0.53203666",
"0.52891964",
"0.52763... | 0.68148327 | 1 |
Provides positions in meters along probe stalks for 4x4 array of probes built by M. Kaur. | def get_probeLocs_calib_setup_cm(dir, num_probes = 16):
position_vectors = [[0] * 3 for i in range(num_probes)]
#every x postion
# Convert to meters
x_pos = [-4.25*2.54, -4.25*2.54, 4.24*2.54, 4.24*2.54]
y_pos = [-4.25*2.54, 4.24*2.54, 4.24*2.54, -4.25*2.54]
z_pos = [-2.25*2.54, -0.75*2.54, 0.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_probeLocs_calib_setup(dir, num_probes = 16):\n position_vectors = [[0] * 3 for i in range(num_probes)]\n\n #every x postion\n\n # Convert to meters\n x_pos = [-4.25*1e-3*25.4, -4.25*1e-3*25.4, 4.24*1e-3*25.4, 4.24*1e-3*25.4]\n y_pos = [-4.25*1e-3*25.4, 4.24*1e-3*25.4, 4.24*1e-3*25.4, -4.25*1... | [
"0.6814141",
"0.6357938",
"0.6228107",
"0.62063867",
"0.576915",
"0.56598634",
"0.5540284",
"0.5499135",
"0.5474505",
"0.54411244",
"0.5393473",
"0.5382529",
"0.5381584",
"0.53801537",
"0.5371877",
"0.53437704",
"0.53433514",
"0.5324205",
"0.5318798",
"0.5288676",
"0.5275662"... | 0.68606234 | 0 |
This finds the ratio between the idealized helmholtz field and the actual recoreded signal This also corrects for inverted signals... however due to what I'm assuming is noise, finding the inverted ones are a bit tricky feel free to uncomment the plotting lines and see if it needs adjusments, though I did get it workin... | def ratio_4_doc(shot, dir, num_probes = 16):
# data = [[0] *3 for i in range(num_probes)]
# magdata = hdr.getMagData(shot)
probe_locs = get_probeLocs_calib_setup(shot)
data=hdr.getquikData(shot)
time,eastcurrent,westcurrent = loadcurrent(shot)#using eastcurrent
ratios = [[0]*3 for i in range(num... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _calculate_measurement_error(self): \n \n # Calculate Hartmann Spot\n # FIXME what are factor_1, factor_2 ???\n factor_1, factor_2 = 206265*5.89e-7, 206265*6.5e-7\n term1, term2 = factor_1/self.actuator_spacing, factor_2/self.r0\n hartmann_spot = np.max([term1, term... | [
"0.62044317",
"0.59503055",
"0.5934977",
"0.58116406",
"0.5744772",
"0.5688612",
"0.5682206",
"0.5657256",
"0.5637151",
"0.56292534",
"0.562283",
"0.56201357",
"0.5602905",
"0.5597058",
"0.55753255",
"0.55715555",
"0.55521727",
"0.5543683",
"0.55348676",
"0.5511092",
"0.55000... | 0.6009351 | 1 |
Retrieve the .mat filenames for the troika dataset. Review the README in ./datasets/troika/ to understand the organization of the .mat files. | def LoadTroikaDataset():
data_dir = "./datasets/troika/training_data"
data_fls = sorted(glob.glob(data_dir + "/DATA_*.mat"))
ref_fls = sorted(glob.glob(data_dir + "/REF_*.mat"))
return data_fls, ref_fls | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matrices_names(self, folder=None):\n if folder is None:\n abs_path = os.path.abspath(os.path.dirname(sys.argv[0]))\n folder = os.path.join(abs_path, 'matrix')\n\n matrix_name_x = \"%s_%s_%s_%s_x.txt\" % (\n self.D, self.Rs, self.axe_X, self.FOV_img)\n matri... | [
"0.62999743",
"0.5992772",
"0.5919344",
"0.58812904",
"0.5764292",
"0.57600445",
"0.5720086",
"0.56433666",
"0.5607395",
"0.5561246",
"0.55274653",
"0.55114895",
"0.5472151",
"0.54595053",
"0.54580384",
"0.5449727",
"0.54414546",
"0.54392225",
"0.54072315",
"0.5384773",
"0.53... | 0.73199314 | 0 |
Toplevel function evaluation function. Runs the pulse rate algorithm on the Troika dataset and returns an aggregate error metric. | def Evaluate():
global reg
reg = ModelRegression()
# Retrieve dataset files
data_fls, ref_fls = LoadTroikaDataset()
errs, confs = [], []
for data_fl, ref_fl in zip(data_fls, ref_fls):
# Run the pulse rate algorithm on each trial in the dataset
errors, confidence = RunPulseRa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_aggregated_error_rate(self):\n estimates = np.mat([0.8, 0.4, 0.8, 0.4])\n m = np.shape(self.data_matrix)[0]\n returned = ada_boost.aggregated_error_rate(estimates, self.labels, m)\n self.assertEqual(returned, 2.0)",
"def run(self):\n self.evaluate()\n self.accum... | [
"0.5552829",
"0.54419374",
"0.5426438",
"0.53882104",
"0.53734046",
"0.52837074",
"0.5248022",
"0.5202013",
"0.5199766",
"0.51779705",
"0.51705366",
"0.51694053",
"0.5148345",
"0.514448",
"0.51326084",
"0.5094116",
"0.5040183",
"0.50327647",
"0.5014488",
"0.5009077",
"0.50053... | 0.7705827 | 0 |
Given the string representation of a tagged token, return the corresponding tuple representation. The rightmost occurence of C{sep} in C{s} will be used to divide C{s} into a word string and a tag string. If C{sep} does not occur in C{s}, return C{(s, None)}. | def str2tuple(s, sep='/'):
loc = s.rfind(sep)
if loc >= 0:
return (s[:loc], s[loc+1:].upper())
else:
return (s, None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tuple2str(tagged_token, sep='/'):\n word, tag = tagged_token\n if tag is None:\n return word\n else:\n assert sep not in tag, 'tag may not contain sep!'\n return '%s%s%s' % (word, sep, tag)",
"def split(value: str, sep: str = \":\") -> Tuple:\n left, _, right = value.partitio... | [
"0.6646102",
"0.612387",
"0.60105777",
"0.5899971",
"0.56244576",
"0.5581877",
"0.556164",
"0.54761165",
"0.5448013",
"0.5431246",
"0.54079366",
"0.5345186",
"0.5311481",
"0.52914494",
"0.5287557",
"0.5282446",
"0.5266853",
"0.52644396",
"0.52302814",
"0.52152735",
"0.5200624... | 0.682012 | 0 |
Given the tuple representation of a tagged token, return the corresponding string representation. This representation is formed by concatenating the token's word string, followed by the separator, followed by the token's tag. (If the tag is None, then just return the bare word string.) | def tuple2str(tagged_token, sep='/'):
word, tag = tagged_token
if tag is None:
return word
else:
assert sep not in tag, 'tag may not contain sep!'
return '%s%s%s' % (word, sep, tag) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tagify(parsedtag):\n tag = \"\"\n for t in parsedtag:\n if t == '':\n t = '_'\n tag = tag+t\n return tag",
"def tuple_to_string(letter_word_pair):\n letter, word = letter_word_pair\n return '{letter}: {word}'.format(letter=letter, word=word)",
"def _preproces... | [
"0.65129",
"0.6197551",
"0.6189595",
"0.603213",
"0.59723246",
"0.5791183",
"0.56370145",
"0.56172186",
"0.5614327",
"0.55962265",
"0.5587963",
"0.55618066",
"0.5522836",
"0.5503617",
"0.5499369",
"0.5470717",
"0.5397113",
"0.5374059",
"0.5342552",
"0.5339643",
"0.53354275",
... | 0.8627057 | 0 |
Given a tagged sentence, return an untagged version of that sentence. I.e., return a list containing the first element of each tuple in C{tagged_sentence}. >>> untag([('John', 'NNP'), ('saw', 'VBD'), ('Mary', 'NNP')] ['John', 'saw', 'mary'] | def untag(tagged_sentence):
return [w for (w, t) in tagged_sentence] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def untag(tagged_sentence):\n return [w for w, _ in tagged_sentence]",
"def untag(self, tagged_sent, strict=True, verbose=False):\n word = \"\"\n for char, tag in tagged_sent:\n if verbose:\n print char, tag\n if tag in self.itags:\n if word:\n... | [
"0.8872581",
"0.688079",
"0.6484743",
"0.5917314",
"0.58630955",
"0.5849702",
"0.5814519",
"0.57450205",
"0.565951",
"0.5595256",
"0.55470544",
"0.55409217",
"0.5509677",
"0.54981333",
"0.5497102",
"0.54217565",
"0.5420616",
"0.5420616",
"0.5396361",
"0.5392199",
"0.53684276"... | 0.8875718 | 0 |
Select only rows representing extended sources from a catalog table | def select_extended(cat_table):
try:
l = [len(row.strip()) > 0 for row in cat_table['Extended_Source_Name'].data]
return np.array(l, bool)
except KeyError:
return cat_table['Extended'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_sources(cat_table, cuts):\n nsrc = len(cat_table)\n full_mask = np.ones((nsrc), bool)\n for cut in cuts:\n if cut == 'mask_extended':\n full_mask *= mask_extended(cat_table)\n elif cut == 'select_extended':\n full_mask *= select_extended(cat_table)\n e... | [
"0.60211074",
"0.5248736",
"0.5232373",
"0.5228239",
"0.5216698",
"0.514871",
"0.51264745",
"0.5091105",
"0.50576377",
"0.50509965",
"0.500945",
"0.50049895",
"0.49812737",
"0.49577492",
"0.4953649",
"0.49411482",
"0.49411097",
"0.49344343",
"0.4923671",
"0.4913756",
"0.49132... | 0.67723024 | 0 |
Select only rows passing a set of cuts from catalog table | def select_sources(cat_table, cuts):
nsrc = len(cat_table)
full_mask = np.ones((nsrc), bool)
for cut in cuts:
if cut == 'mask_extended':
full_mask *= mask_extended(cat_table)
elif cut == 'select_extended':
full_mask *= select_extended(cat_table)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_subset(df, constraints):\n for constraint in constraints:\n subset = df.loc[df[constraint[0]].isin(constraint[1])]\n df = subset\n return subset",
"def get_table_subset(table, batches):\n idxs = np.array([])\n for batch in batches:\n idxs = np.append(idxs, np.where(table[... | [
"0.5679256",
"0.54460526",
"0.5423245",
"0.54030055",
"0.5230312",
"0.5216821",
"0.5212075",
"0.5188647",
"0.51706034",
"0.5072302",
"0.5045124",
"0.5038879",
"0.5030005",
"0.50211084",
"0.50056404",
"0.49777895",
"0.49624884",
"0.4951754",
"0.4933273",
"0.4932415",
"0.490916... | 0.6428772 | 0 |
Read the yaml file for a particular split key | def read_catalog_info_yaml(self, splitkey):
catalog_info_yaml = self._name_factory.catalog_split_yaml(sourcekey=splitkey,
fullpath=True)
yaml_dict = yaml.safe_load(open(catalog_info_yaml))
# resolve env vars
yaml_dict['cat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getitem__(self, item):\n try:\n if \".\" in item:\n keys = item.split(\".\")\n else:\n return self.data[item]\n element = self.data[keys[0]]\n for key in keys[1:]:\n element = element[key]\n except KeyError... | [
"0.59335405",
"0.5843199",
"0.5721483",
"0.56454915",
"0.5619514",
"0.56168664",
"0.5573831",
"0.55296016",
"0.5514136",
"0.54911107",
"0.54887116",
"0.5482527",
"0.5466847",
"0.54572874",
"0.5439963",
"0.54187524",
"0.5408526",
"0.540396",
"0.5391459",
"0.53888166",
"0.53775... | 0.6570766 | 0 |
Build a CatalogInfo object | def build_catalog_info(self, catalog_info):
cat = SourceFactory.build_catalog(**catalog_info)
catalog_info['catalog'] = cat
# catalog_info['catalog_table'] =
# Table.read(catalog_info['catalog_file'])
catalog_info['catalog_table'] = cat.table
catalog_info['roi_model'] ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_catalog_comp_info(self, full_cat_info, split_key, rule_key, rule_val, sources):\n merge = rule_val.get('merge', True)\n sourcekey = \"%s_%s_%s\" % (\n full_cat_info.catalog_name, split_key, rule_key)\n srcmdl_name = self._name_factory.srcmdl_xml(sourcekey=sourcekey)\n ... | [
"0.6588303",
"0.61483276",
"0.5996167",
"0.5996167",
"0.5996167",
"0.59377766",
"0.5853027",
"0.58457947",
"0.5777897",
"0.57669896",
"0.5660952",
"0.56151086",
"0.5586599",
"0.5576048",
"0.55725324",
"0.55642617",
"0.5543427",
"0.5534594",
"0.55312943",
"0.5503297",
"0.54956... | 0.8214636 | 0 |
Return the list of full catalogs used | def catalogs(self):
return sorted(self._catalog_comp_info_dicts.keys()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCatalogs():",
"def get(self):\n return GenericGet().get_catalogs()",
"def get_catalogs(self):\n # Implemented from kitosid template for -\n # osid.resource.BinLookupSession.get_bins_template\n catalogs = self._get_provider_session('catalog_lookup_session').get_catalogs()\n ... | [
"0.8308617",
"0.7364706",
"0.7295699",
"0.7183018",
"0.7094484",
"0.7065019",
"0.68383414",
"0.66891736",
"0.65169674",
"0.6516233",
"0.6503805",
"0.64863735",
"0.64859456",
"0.6473658",
"0.6427194",
"0.64163595",
"0.6385455",
"0.63072556",
"0.6240876",
"0.623814",
"0.6236926... | 0.79021573 | 1 |
Return the list of catalog split keys used | def splitkeys(self):
return sorted(self._split_comp_info_dicts.keys()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def keys(self) -> List[str]:\n raise NotImplementedError",
"def catalog_components(self, catalog_name, split_ver):\n return sorted(self._split_comp_info_dicts[\"%s_%s\" % (catalog_name, split_ver)].keys())",
"def keys(self) -> List:\n pass",
"def get_keys(self):\r\n\r\n #using databas... | [
"0.6911",
"0.69100714",
"0.6819517",
"0.68116844",
"0.67278045",
"0.6701149",
"0.6674959",
"0.6631823",
"0.6594297",
"0.65199286",
"0.651894",
"0.65150744",
"0.65001196",
"0.65000886",
"0.6440549",
"0.64391464",
"0.6426035",
"0.6371353",
"0.6365058",
"0.6354946",
"0.6335533",... | 0.7640336 | 0 |
Return the info for a particular split key | def split_comp_info(self, catalog_name, split_ver, split_key):
return self._split_comp_info_dicts["%s_%s" % (catalog_name, split_ver)][split_key] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getsplitinfo():\n \n splitvarlist = spss.GetSplitVariableNames()\n if len(splitvarlist) == 0:\n return [], None\n else:\n splittype = spssaux.getShow(\"split\", olang=\"english\")\n if splittype.lower().startswith(\"layer\"):\n splittype=\"layered\"\n else:\n ... | [
"0.6543608",
"0.6113423",
"0.5998565",
"0.5991682",
"0.5982638",
"0.59728223",
"0.59677356",
"0.58936083",
"0.5857385",
"0.576732",
"0.57553214",
"0.5689077",
"0.56885535",
"0.5674944",
"0.5661469",
"0.56329924",
"0.5598245",
"0.55969393",
"0.5588592",
"0.5572412",
"0.5545308... | 0.73933583 | 0 |
Stores the given model. | def store_model(self, user_name, model_name, model):
print(f"sto {user_name}\n{model_name}\n{serialize(model)}")
return self.dao.store_serialized_model(user_name, model_name, serialize(model)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_model(self):\n pass",
"def save_model(self, *args, **kwargs):\n raise NotImplementedError",
"def save_model(self):\n if self.model:\n self.model.save(self.config[\"model_path\"])",
"def _save_model(self):\n save_generic(self.model, self.model_pkl_fname)",
"de... | [
"0.77885836",
"0.7711191",
"0.755239",
"0.75421274",
"0.7444351",
"0.7415339",
"0.7415298",
"0.7396812",
"0.73743224",
"0.7329616",
"0.72817063",
"0.71172756",
"0.7011479",
"0.6994045",
"0.6933486",
"0.68591076",
"0.6839708",
"0.68030614",
"0.6796083",
"0.67817974",
"0.676047... | 0.84057695 | 0 |
Stores the given model in redis. | def store_serialized_model(self, user_name, model_name, serialized_model):
try:
self.rconn.set(redis_keys.for_model(user_name, model_name), json.dumps(serialized_model))
return True
except redis.RedisError as e:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_model(self, user_name, model_name, model):\n print(f\"sto {user_name}\\n{model_name}\\n{serialize(model)}\")\n return self.dao.store_serialized_model(user_name, model_name, serialize(model))",
"def redis_save(key: object, value: object) -> object:\n if key is not None and value is not ... | [
"0.6808482",
"0.6612063",
"0.6367931",
"0.60557693",
"0.5940292",
"0.5915331",
"0.58338416",
"0.58175427",
"0.580114",
"0.5768876",
"0.57467467",
"0.57321674",
"0.5718583",
"0.5714915",
"0.5696914",
"0.5685338",
"0.56384814",
"0.5590227",
"0.5558572",
"0.5553382",
"0.55394566... | 0.75235426 | 0 |
Read the timestamps and sort them to permit simple concurrency tests. | def read_timestamps(self, tasks):
from reframe.core.deferrable import evaluate
self.begin_stamps = []
self.end_stamps = []
for t in tasks:
with open(evaluate(t.check.stdout), 'r') as f:
self.begin_stamps.append(float(f.readline().strip()))
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sort_data_by_time():\n data = race.read_file_to_list()\n sorted_data = race.sort_data_by_time(data)\n assert data != sorted_data\n assert len(data) == len(sorted_data)\n assert type(sorted_data) == list\n for lines in sorted_data:\n assert type(lines) == dict",
"def batch_uses_p... | [
"0.70775634",
"0.7044557",
"0.6865213",
"0.6789583",
"0.6551319",
"0.65016",
"0.64157754",
"0.63982505",
"0.6367806",
"0.6276606",
"0.6226092",
"0.619473",
"0.6178502",
"0.60988915",
"0.60325676",
"0.6003747",
"0.59616065",
"0.5910013",
"0.5909187",
"0.581583",
"0.58126765",
... | 0.73157066 | 0 |
creates a vao if the instance has a shape where we did not create an vao yet | def update_shape_vaos(self, instance, show):
shape = self._shape(instance)
shape_object_id = id(shape)
if not shape_object_id in self._shape_vaos:
self._shape_vaos[shape_object_id] = VertexArray({
'vertex_position': VertexBuffer.from_numpy(shape.verticies),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def agregar_arista(self, v, w, peso=1):\n if not v in self.vertices or not w in self.vertices:\n return False\n self.vertices[v][w]= peso\n if not self.dirigido: self.vertices[w][v] = peso",
"def test_creation(self):\n\n assert self.test_shape.solid is not None\n ass... | [
"0.5730283",
"0.5638069",
"0.5638069",
"0.56318754",
"0.56318754",
"0.5603204",
"0.5560593",
"0.54646444",
"0.5322073",
"0.5228889",
"0.5199293",
"0.5199293",
"0.5173173",
"0.516719",
"0.51552814",
"0.5147659",
"0.51269144",
"0.5120981",
"0.5112034",
"0.5101421",
"0.51001644"... | 0.6779693 | 0 |
renders a texture containing the borders of all shapes. | def _render_borders(self):
# XXX
# - read the old glBlendFunc value and restore it if neccessary.
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
self.border_program.use()
for shape_object_id, instances in self._instances.items():
self._shape_vaos[shape_object_id]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tile_border(draw, r_s, r_e, c_s, c_e, color, border_size=TILE_BORDER_SIZE):\n for x in range(0, border_size):\n draw.rectangle([(c_s + x, r_s + x), (c_e - 1 - x, r_e - 1 - x)], outline=color)",
"def borders(self):\n border_left = pm.Segment(self.space.static_body, (-5, 0), (-5, self.screen_height)... | [
"0.61772597",
"0.604624",
"0.5954987",
"0.59350353",
"0.58965117",
"0.58747965",
"0.5859048",
"0.58586574",
"0.5853385",
"0.5800375",
"0.5792888",
"0.5761924",
"0.5725997",
"0.5725489",
"0.5707735",
"0.56973356",
"0.56697094",
"0.56612206",
"0.5657879",
"0.56512725",
"0.55952... | 0.6801152 | 0 |
Copy the score to the NN after each tick. | def update(self, game):
super().update(game)
self.nn_def.set_score(self.score) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateScore(self, score):\n self.__score += score",
"def update_score():\n pass",
"def update_score(self):\n self.score = TurboMQ.calculate_fitness(self.result, self.graph)",
"def update_score(self, board):\n self._score += 1",
"def update_score(self):\n td = self.cre... | [
"0.64578915",
"0.6423904",
"0.6408726",
"0.62740093",
"0.61973757",
"0.6169047",
"0.6169047",
"0.6169047",
"0.60679024",
"0.60264367",
"0.6015221",
"0.59940284",
"0.5993987",
"0.5973198",
"0.59721255",
"0.5949299",
"0.5942236",
"0.5902771",
"0.58866864",
"0.5841765",
"0.58369... | 0.7277563 | 0 |
Set suffixes if they begin with a + | def set_suffixes(args):
return [arg[1:] for arg in args if arg[0] == '+'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removesuffix(self, x) -> String:\n pass",
"def suffix_replace(original, old, new):\n ...",
"def add_suffix(word, suffix):\n suffix, sep, rest = suffix.partition(' ')\n expanded = _add_suffix(word, suffix)\n return expanded + sep + rest",
"def setSuffixes(self, s):\n return self._set... | [
"0.6363864",
"0.6346127",
"0.6332669",
"0.61678916",
"0.6081603",
"0.59654105",
"0.59258044",
"0.5911821",
"0.586002",
"0.585793",
"0.58109426",
"0.57019335",
"0.56996137",
"0.5689837",
"0.5645532",
"0.5638323",
"0.56038296",
"0.5587256",
"0.5583112",
"0.5580947",
"0.5578123"... | 0.75712377 | 0 |
Takes a bounding box in the form [x1,y1,x2,y2] and returns z in the form [x,y,s,r] where x,y is the centre of the box and s is the scale/area and r is the aspect ratio | def convert_bbox_to_z(bbox):
w = bbox[2] - bbox[0]
h = bbox[3] - bbox[1]
x = bbox[0] + w / 2.
y = bbox[1] + h / 2.
s = w * h # scale is just area
r = w / float(h)
return np.array([x, y, s, r]).reshape((4, 1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_bbox_to_z(bbox):\n w = bbox[2] - bbox[0]\n h = bbox[3] - bbox[1]\n x = bbox[0] + w/2.\n y = bbox[1] + h/2.\n s = w * h #scale is just area\n r = w / float(h)\n return np.array([x, y, s, r]).reshape((4, 1))",
"def convert_bbox_to_z(bbox):\n w = bbox[2] - bbox[0]\n h = bbox[3] - bbox[1]... | [
"0.70684916",
"0.6832517",
"0.67437243",
"0.67029804",
"0.667289",
"0.65944505",
"0.6579306",
"0.63725936",
"0.63596195",
"0.63322043",
"0.6323071",
"0.62650836",
"0.6200155",
"0.6196621",
"0.6168873",
"0.6150329",
"0.6144695",
"0.6138646",
"0.61194324",
"0.61101246",
"0.6088... | 0.6905524 | 1 |
Decorator for exposing a method as an RPC call with the given signature. | def expose_rpc(permission, return_type, *arg_types):
def decorator(func):
if not hasattr(func, '_xmlrpc_signatures'):
func._xmlrpc_signatures = []
func._xml_rpc_permission = permission
func._xmlrpc_signatures.append((return_type,) + tuple(arg_types))
return func
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rpc_call(func):\n @wraps(func)\n def decorator(*args, **kwargs):\n return func(*args, **kwargs)\n decorator.rpc_call = True\n return decorator",
"def rpc_method(func):\n func.rpc_callable = True\n return func",
"def rpcmethod(func):\n func.rpcmethod = True\n return fu... | [
"0.72693485",
"0.7231531",
"0.6921579",
"0.6753611",
"0.6449031",
"0.6424492",
"0.6306513",
"0.614029",
"0.6127533",
"0.598983",
"0.5951367",
"0.5933623",
"0.58960724",
"0.58644986",
"0.581652",
"0.5811746",
"0.58007073",
"0.5770051",
"0.57460624",
"0.57426834",
"0.5732241",
... | 0.7436393 | 0 |
Serialize the result of the RPC call and send it back to the client. | def send_rpc_result(req, result): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def send_result(\n self,\n rpc_message: RpcMessage,\n result_message: ResultMessage,\n return_path: str,\n bus_client: \"BusClient\",\n ):\n raise NotImplementedError()",
"def _success(self, result_ser, request):\n result = json.dumps(result_ser)\n ... | [
"0.66543037",
"0.6296766",
"0.6142886",
"0.6120978",
"0.61099845",
"0.60895675",
"0.5985333",
"0.59626645",
"0.59577644",
"0.59334546",
"0.5809743",
"0.5802393",
"0.5798993",
"0.5763221",
"0.57578456",
"0.57577705",
"0.57374424",
"0.5700236",
"0.56850314",
"0.56526905",
"0.56... | 0.7619752 | 0 |
Provide the namespace in which a set of methods lives. This can be overridden if the 'name' element is provided by xmlrpc_methods(). | def xmlrpc_namespace(): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xmlrpc_methods():",
"def namespace(self):\n raise exceptions.NotImplementedError()",
"def namespaces(self):\n return ()",
"def _ns(self, *args):\n return \"%s.%s\" % (self.namespace, \".\".join([str(arg) for arg in args]))",
"def createNamespace(self):\r\n raise NotImplement... | [
"0.67840374",
"0.6330559",
"0.60799056",
"0.6017906",
"0.58106625",
"0.57945573",
"0.5761432",
"0.57473826",
"0.5687743",
"0.56653756",
"0.5655525",
"0.560176",
"0.55967504",
"0.54732215",
"0.546771",
"0.54126364",
"0.5406012",
"0.54021627",
"0.53649825",
"0.5364481",
"0.5357... | 0.7973318 | 0 |
This method takes one parameter, the name of a method implemented by the RPC server. It returns a documentation string describing the use of that method. If no such string is available, an empty string is returned. The documentation string may contain HTML markup. | def methodHelp(self, req, method):
p = self.get_method(method)
return '\n'.join((p.signature, '', p.description)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def methodHelp(self, name):\r\n methods = self._listMethods()\r\n for methodname in methods.keys():\r\n if methodname == name:\r\n return methods[methodname]\r\n raise RPCError(Faults.SIGNATURE_UNSUPPORTED)",
"def method(name, doc):\n import html\n\n params = ... | [
"0.7297669",
"0.694731",
"0.68896276",
"0.6688466",
"0.6388553",
"0.6385201",
"0.63499844",
"0.6292997",
"0.6292498",
"0.62701833",
"0.6107226",
"0.60769576",
"0.60552335",
"0.60015124",
"0.59173465",
"0.58777815",
"0.58560765",
"0.58364666",
"0.5824243",
"0.5823201",
"0.5823... | 0.71314836 | 1 |
Extract all phrases from word alignment. | def extract_phrase(self, src_text, tgt_text, alignment, max_phrase_len=0):
def extract_from_range(tgt_start, tgt_end, src_start, src_end, max_phrase_len):
"""Extract a set of possible phrase given the source, language ranges.
"""
# print("rages", tgt_start, tgt_end, src_star... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_phrases(data,model):\n phrases = []\n alignment = model.alignment_idx\n for i in range(len(data)):\n sent_phrases = phrase_extraction(data[i][\"fr\"],data[i][\"en\"],alignment[i])\n phrases.append(sent_phrases)\n return phrases",
"def lemmatized_phrases(self):\n phras... | [
"0.7157194",
"0.6438471",
"0.61811405",
"0.6119933",
"0.6069589",
"0.60057",
"0.59385145",
"0.58645695",
"0.5848218",
"0.58418983",
"0.58405614",
"0.58251745",
"0.57417756",
"0.57353705",
"0.57185733",
"0.57103014",
"0.5676527",
"0.56694734",
"0.56662035",
"0.5655986",
"0.563... | 0.6709278 | 1 |
Extract a set of possible phrase given the source, language ranges. | def extract_from_range(tgt_start, tgt_end, src_start, src_end, max_phrase_len):
# print("rages", tgt_start, tgt_end, src_start, src_end)
if tgt_end < 0:
return
# If `src_align_idx` out of the `src_start` and `src_target`.
for src_align_idx, tgt_align_idx ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_phrase(self, src_text, tgt_text, alignment, max_phrase_len=0):\n def extract_from_range(tgt_start, tgt_end, src_start, src_end, max_phrase_len):\n \"\"\"Extract a set of possible phrase given the source, language ranges.\n\n \"\"\"\n # print(\"rages\", tgt_start,... | [
"0.6873448",
"0.5602197",
"0.5513425",
"0.55112517",
"0.5479709",
"0.54267764",
"0.5333438",
"0.52627516",
"0.5251202",
"0.5215412",
"0.52010435",
"0.5196199",
"0.5195391",
"0.51823145",
"0.5178213",
"0.51594794",
"0.51498526",
"0.5126929",
"0.50857365",
"0.50619686",
"0.5037... | 0.70351136 | 0 |
Extract phrase from list of the parallel sentences. | def extract_phrase_from_parallel_sentences(self, src_lst,
tgt_lst,
word_alignment,
max_phrase_len=0,
save_phrase_table=None):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_phrases(data,model):\n phrases = []\n alignment = model.alignment_idx\n for i in range(len(data)):\n sent_phrases = phrase_extraction(data[i][\"fr\"],data[i][\"en\"],alignment[i])\n phrases.append(sent_phrases)\n return phrases",
"def sentence_parse(list_of_posts): \n fo... | [
"0.6296526",
"0.6136638",
"0.5852756",
"0.5819079",
"0.57264394",
"0.5696509",
"0.5664151",
"0.559129",
"0.55865973",
"0.55777866",
"0.5577783",
"0.5568261",
"0.553962",
"0.54893243",
"0.5487933",
"0.54764163",
"0.5456427",
"0.5454422",
"0.543709",
"0.5425575",
"0.5423253",
... | 0.6505854 | 0 |
Compute log probability of sorucetarget phrase pairs. Note that we compute log p(f|e) due to the noise channel assumption. | def compute_log_probs(self, phrases, save_to_file=None):
# Co-ocurrence for source and target phrase
tgt_src_cnt = defaultdict(lambda: defaultdict(int))
# ocurrence for target (English)
tgt_cnt = defaultdict(int)
# Compute frequency and co-occurence
for phrase_p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sentence_logprob(self, sentence):\n line = get_ngrams(sentence,3)\n log_por = 0.0\n for item in line:\n raw_por = self.smoothed_trigram_probability(item)\n log_por = log_por+math.log2(raw_por)\n\n return float(log_por)",
"def sentence_logprob(self, sentence):... | [
"0.74536216",
"0.72376466",
"0.6940813",
"0.69313174",
"0.6906261",
"0.6710182",
"0.6671943",
"0.66348374",
"0.66269255",
"0.66226804",
"0.658965",
"0.6519465",
"0.6512543",
"0.6429427",
"0.6417837",
"0.6415285",
"0.63980013",
"0.63869506",
"0.6386877",
"0.63799185",
"0.63781... | 0.7457257 | 0 |
Flatten nested list into a list of sorucetarget phrase pairs. | def flatten_phrase_collect(phrase_collect):
flatten_phrse_collect = list()
for phrase_lst in phrase_collect:
pass
return flatten_phrse_collect | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flatten(nested_list):\r\n return list(chain.from_iterable(nested_list))",
"def _flatten(phrases):\n return [' '.join(phrase) for phrase in phrases]",
"def flatten(nested_list):\n for elt in nested_list:\n if isinstance(elt, collections.Iterable) and not isinstance(elt, six.string_types)... | [
"0.68353754",
"0.6703909",
"0.6512857",
"0.65088475",
"0.64734936",
"0.640399",
"0.618579",
"0.6086874",
"0.6073905",
"0.60664827",
"0.60623664",
"0.604358",
"0.60098505",
"0.5991506",
"0.5989105",
"0.5989105",
"0.5974142",
"0.5966722",
"0.5949544",
"0.5914635",
"0.59093",
... | 0.69660723 | 0 |
Summary Split data into nq blocks. | def split_data(data, nq, flag=1):
if flag == 1:
quantiles = np.linspace(data.min(), data.max(), nq + 1)
elif flag == 2:
segs = np.linspace(0, 100, nq + 1)
quantiles = np.percentile(data, segs)
quantiles[0] = quantiles[0] - 1e-15
quantiles[-1] = quantiles[-1] + 1e-15
grp_names... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_chunk_size_priority_over_n_splits(self):\n with self.subTest(input='list', chunk_size=1, n_splits=6):\n self.assertEqual(get_n_chunks(self.test_data, iterable_len=None, chunk_size=1, n_splits=6, n_jobs=None), 13)\n with self.subTest(input='numpy', chunk_size=1, n_splits=6):\n ... | [
"0.57900053",
"0.5749784",
"0.55733985",
"0.55712456",
"0.55246603",
"0.55168134",
"0.5494334",
"0.5402945",
"0.5363317",
"0.5348577",
"0.532229",
"0.52557427",
"0.5247931",
"0.5193257",
"0.5171128",
"0.51542133",
"0.5153879",
"0.51524353",
"0.5149456",
"0.51452446",
"0.51341... | 0.5802561 | 0 |
online maxminscale normalization using key basic statistics. | def update_maxminscale(stats_on_target, lastest_minmax):
target_xss, target_xs, target_xct = stats_on_target
xmn, xmx = lastest_minmax
zss = (target_xss - 2 * xmn * target_xs + target_xct * xmn**2) / (xmx - xmn)**2
zs = (target_xs - target_xct * xmn) / (xmx - xmn)
zct = target_xct
return zss, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _normalize(self, dataset):\n if self.max is None: # if we are normalizing the training set\n self.max, self.min = dataset.max(), dataset.min() # find max, min value for each columns\n for row in dataset.index: # for each row in dataset\n for c... | [
"0.63708794",
"0.62702864",
"0.61845",
"0.61675406",
"0.6165542",
"0.61498797",
"0.61322546",
"0.6095306",
"0.60869277",
"0.6003787",
"0.6002606",
"0.60010904",
"0.5944249",
"0.59147775",
"0.5865857",
"0.58601046",
"0.58502215",
"0.5845374",
"0.58325875",
"0.5817523",
"0.5789... | 0.6510492 | 0 |
Construct the flow graph by connecting this node to another node or a command. The predicate is a function that tells the flow executor if the flow can enter the step without the user intervention (automatically). | def connect(self, node_or_command: Union['FlowNode', str], predicate: Predicate = lambda _: False,
hints: bool = True):
node_to_connect_to = node_or_command if isinstance(node_or_command, FlowNode) else FlowNode(node_or_command,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_new_flow(flow_root, requestor: Identifier, initial_command) \\\n -> Tuple[Optional[Flow], Optional[FlowNode]]:\n empty_context = {}\n flow = Flow(flow_root, requestor, empty_context)\n for possible_next_step in flow.next_steps():\n if possible_next_step.comman... | [
"0.6413768",
"0.5331428",
"0.52776724",
"0.5124311",
"0.51223505",
"0.5108684",
"0.50600624",
"0.5043233",
"0.5042275",
"0.4964955",
"0.49122655",
"0.48988894",
"0.48981482",
"0.48565575",
"0.484811",
"0.4824072",
"0.48154116",
"0.4813976",
"0.4800156",
"0.4783596",
"0.478087... | 0.65801656 | 0 |
gets the predicate function for the specified child node. | def predicate_for_node(self, node: 'FlowNode'):
for predicate, possible_node in self.children:
if node == possible_node:
return predicate
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_predicate(self):\n return self._predicate",
"def predicate(f):\n wrapper = Predicate(f)\n update_wrapper(wrapper, f)\n return wrapper",
"def predicate (self) :\n\n return self.__predicate__",
"def to_predicate(self, node, f='predicate', map=None):\n\n if 'AK{}' == node.n... | [
"0.60676956",
"0.59117705",
"0.5859783",
"0.5716894",
"0.5592004",
"0.54098916",
"0.5391563",
"0.5362847",
"0.52606004",
"0.52374494",
"0.51913834",
"0.50643146",
"0.5036615",
"0.49944842",
"0.4963765",
"0.49336788",
"0.4933024",
"0.49324915",
"0.49315336",
"0.49314764",
"0.4... | 0.69061804 | 0 |
Get all the possible next steps after this one (predicates statisfied or not). | def next_steps(self) -> List[FlowNode]:
return [node for predicate, node in self._current_step.children] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSteps():",
"def get_next_steps(self, steps):\n step_list = []\n\n steps_remaining = set(steps.keys())\n counter = 0\n max_counter = 10000\n next_steps = set()\n\n for step in steps_remaining:\n dependencies = steps[step]\n if len(dependencies... | [
"0.6234041",
"0.58860874",
"0.58491534",
"0.5800428",
"0.5592601",
"0.5583821",
"0.5574898",
"0.5521146",
"0.5507032",
"0.5441927",
"0.5365685",
"0.5339986",
"0.5337542",
"0.5333407",
"0.5318446",
"0.53063506",
"0.5300591",
"0.5297238",
"0.5295074",
"0.5279935",
"0.5268858",
... | 0.6419919 | 0 |
The original flowroot of this flow. | def root(self) -> FlowRoot:
return self._root | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root_orig(self):\n if hasattr(self, \"orig\"):\n return self.orig.root_orig\n return self",
"def original(self):\n return self._original",
"def original(self):\n return self._original",
"def getOriginal(self,):\n\t\treturn self.original;",
"def root(self):\n\t\tre... | [
"0.73445743",
"0.6893548",
"0.6893548",
"0.6484647",
"0.63805735",
"0.63805735",
"0.6353325",
"0.6331243",
"0.6286299",
"0.62303126",
"0.62067777",
"0.62067777",
"0.62067777",
"0.6187001",
"0.6182318",
"0.6174468",
"0.6174468",
"0.6173917",
"0.6116025",
"0.60984105",
"0.60967... | 0.6993407 | 1 |
Register a flow with this executor. | def add_flow(self, flow: FlowRoot):
with self._lock:
self.flow_roots[flow.name] = flow | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_flow(self, state, flow_id):\n self._flows[state] = flow_id\n _LOGGER.debug(\"Register state %s for flow_id %s\", state, flow_id)",
"def flow(self, flow):\n\n self._flow = flow",
"def add_flow_controller(cls, name, controller):\n cls.registered_controllers[name] = contro... | [
"0.69882387",
"0.67626894",
"0.6249088",
"0.61617434",
"0.6143314",
"0.5989838",
"0.58785754",
"0.5878573",
"0.58688176",
"0.5865792",
"0.5640574",
"0.56151783",
"0.5605409",
"0.56050324",
"0.553389",
"0.5516025",
"0.5483355",
"0.5407733",
"0.53915477",
"0.53600454",
"0.53564... | 0.6806603 | 1 |
Trigger workflows that may have command cmd as a auto_trigger or an in flight flow waiting for command. This assume cmd has been correctly executed. | def trigger(self, cmd: str, requestor: Identifier, extra_context=None) -> Optional[Flow]:
flow, next_step = self.check_inflight_flow_triggered(cmd, requestor)
if not flow:
flow, next_step = self._check_if_new_flow_is_triggered(cmd, requestor)
if not flow:
return None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_if_new_flow_is_triggered(self, cmd: str, user: Identifier) -> Tuple[Optional[Flow], Optional[FlowNode]]:\n log.debug(\"Test if the command %s is an auto-trigger for any flow ...\", cmd)\n with self._lock:\n for name, flow_root in self.flow_roots.items():\n if cmd ... | [
"0.715326",
"0.6214702",
"0.5785957",
"0.5547166",
"0.54532874",
"0.545297",
"0.5442159",
"0.5426565",
"0.54126877",
"0.54040956",
"0.5393063",
"0.5381227",
"0.53534704",
"0.5316226",
"0.5302364",
"0.5268394",
"0.5265039",
"0.5208793",
"0.5185608",
"0.51715356",
"0.5159973",
... | 0.6354978 | 1 |
Check if user is already running a flow. | def check_inflight_already_running(self, user: Identifier) -> bool:
with self._lock:
for flow in self.in_flight:
if flow.requestor == user:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def IsRunning(self):\n current_urn = self.Get(self.Schema.CURRENT_FLOW_URN)\n if current_urn:\n current_flow = aff4.FACTORY.Open(urn=current_urn,\n token=self.token, mode=\"r\")\n runner = current_flow.GetRunner()\n return runner.context.state == rdfvalue.... | [
"0.69948125",
"0.6222682",
"0.61390924",
"0.60672396",
"0.6056235",
"0.5998055",
"0.59039176",
"0.5898025",
"0.58831185",
"0.5882401",
"0.58729315",
"0.58365375",
"0.58026636",
"0.5799237",
"0.5794511",
"0.57941985",
"0.57290274",
"0.57271695",
"0.5711765",
"0.57040274",
"0.5... | 0.7122003 | 0 |
Trigger workflows that may have command cmd as a auto_trigger.. This assume cmd has been correctly executed. | def _check_if_new_flow_is_triggered(self, cmd: str, user: Identifier) -> Tuple[Optional[Flow], Optional[FlowNode]]:
log.debug("Test if the command %s is an auto-trigger for any flow ...", cmd)
with self._lock:
for name, flow_root in self.flow_roots.items():
if cmd in flow_roo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trigger(self, cmd: str, requestor: Identifier, extra_context=None) -> Optional[Flow]:\n flow, next_step = self.check_inflight_flow_triggered(cmd, requestor)\n if not flow:\n flow, next_step = self._check_if_new_flow_is_triggered(cmd, requestor)\n if not flow:\n return... | [
"0.5883584",
"0.58415097",
"0.5791433",
"0.5771063",
"0.5762324",
"0.576105",
"0.5728582",
"0.567646",
"0.5645227",
"0.5643713",
"0.556337",
"0.5523932",
"0.54966164",
"0.5453627",
"0.54442376",
"0.54439944",
"0.5407391",
"0.5404491",
"0.53985775",
"0.53704196",
"0.53561866",... | 0.7032899 | 0 |
Stops a specific flow. It is a no op if the flow doesn't exist. Returns the stopped flow if found. | def stop_flow(self, name: str, requestor: Identifier) -> Optional[Flow]:
with self._lock:
for flow in self.in_flight:
if flow.name == name and flow.check_identifier(requestor):
log.debug(f'Removing flow {str(flow)}.')
self.in_flight.remove(flow... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop(self, **kwargs):\n return self.client.api.stop(self.id, **kwargs)",
"def del_flow(self, flow_name):\n\n try:\n of_response = requests.delete(self.url + \"restconf/config/opendaylight-inventory:nodes/node/\" + self.id +\n \"/table/0/flow/\... | [
"0.5746109",
"0.5730475",
"0.56689626",
"0.5514384",
"0.5421373",
"0.5382266",
"0.5365279",
"0.5311939",
"0.53013855",
"0.5270593",
"0.5240544",
"0.5230865",
"0.5225166",
"0.52059144",
"0.5201256",
"0.5201256",
"0.51601064",
"0.51247495",
"0.5124382",
"0.511578",
"0.5107241",... | 0.72481436 | 0 |
Convert byte data for a Point to a GeoJSON `dict`. | def __load_point(big_endian, type_bytes, data_bytes):
endian_token = '>' if big_endian else '<'
if type_bytes == WKB_2D['Point']:
coords = struct.unpack('%sdd' % endian_token, data_bytes)
elif type_bytes == WKB_Z['Point']:
coords = struct.unpack('%sddd' % endian_token, data_bytes)
elif ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_geom(data: dict) -> dict:\n geom = geom_from_geojson(data)\n validate_geom(geom)\n return geom",
"def parse_point(line):\n return json.loads(line)",
"def to_data(self):\n point = {\n 'point': [self.pt[0], self.pt[1], self.pt[2]],\n 'layer_height': self.layer_heig... | [
"0.61113554",
"0.60749865",
"0.59794545",
"0.58607936",
"0.58315086",
"0.57933426",
"0.5684637",
"0.5668959",
"0.56447315",
"0.55123854",
"0.5489289",
"0.54598",
"0.5451788",
"0.54298854",
"0.54289055",
"0.5410997",
"0.5388101",
"0.5378883",
"0.5308924",
"0.5280801",
"0.52757... | 0.6990642 | 0 |
Cluster prey sequences according to mapped RefSeq | def refseq_based_clustering(self):
self.refseq_based = NonRedSetDict()
for prey in self.ivv_info.Prey_info().preys():
refseqid = self.get_refseq(prey)
if refseqid:
self.refseq_based.append_Dict(refseqid, prey) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refseq_based_clustering(self):\n self.refseq_based = Usefuls.NonRedSet.NonRedSetDict()\n for prey in self.ivv_info.Prey_info().preys():\n refseqid = self.get_refseq(prey)\n if refseqid:\n self.refseq_based.append_Dict(refseqid, prey)",
"def test_first_sequen... | [
"0.70106786",
"0.6068481",
"0.5995936",
"0.5906224",
"0.58543235",
"0.58283967",
"0.57719815",
"0.5765596",
"0.5720791",
"0.56829274",
"0.5669235",
"0.5604671",
"0.55728793",
"0.5560698",
"0.5556891",
"0.5496786",
"0.547497",
"0.540696",
"0.5392086",
"0.537271",
"0.5355906",
... | 0.70810395 | 0 |
Returns all RefSeqs. refseq_based_clustering() must be precalled. | def get_all_refseq(self):
return self.refseq_based.keys() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def references(self) -> \"IterableList[Reference]\":\n return Reference.list_items(self)",
"def get_all_refobjs(self, ):\n return cmds.ls(type=\"jb_reftrack\")",
"def references(self):\n ref_nodes = self.root.xpath(\".//bib-reference\")\n return list(\n itertools.chain.fr... | [
"0.67854905",
"0.64765537",
"0.6383024",
"0.6376954",
"0.6328095",
"0.61806107",
"0.61366177",
"0.61037624",
"0.60236764",
"0.60163116",
"0.59973496",
"0.599216",
"0.59824604",
"0.59700936",
"0.59552693",
"0.59420055",
"0.5773383",
"0.57720006",
"0.5713108",
"0.5703122",
"0.5... | 0.77024484 | 1 |
This creates the symbols out of a stylegallery | def create_symbols(self, style_gallery, style_gallery_name, class_to_export):
try:
symbols_element = self.xml_document.getElementsByTagName("symbols")[0]
except IndexError:
symbols_element = self.xml_document.createElement("symbols")
root_element = self.xml_document.getE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_image_caption_pairs(self):",
"def singleglyph(x):\n return [glyph(x)]",
"def build_schematic(self, bg=None):",
"def get_stylesheet():\n\n #ss_dict\n ss_dict = {'header_image' : HEADER_IMAGE,\n 'icon_true' : ICON_TRUE,\n 'icon_false' : ICON_FALSE,\n ... | [
"0.5846963",
"0.5831491",
"0.57929367",
"0.5631854",
"0.56144685",
"0.55986845",
"0.5543508",
"0.55282354",
"0.54610837",
"0.5445795",
"0.544179",
"0.5433599",
"0.54209745",
"0.54185355",
"0.53752816",
"0.5288781",
"0.5242281",
"0.52400696",
"0.5225346",
"0.51927286",
"0.5187... | 0.69908535 | 0 |
check if given args are new | def __is_args_new(self, *args, **kwargs):
# if input size is different
if len(args) != len(self.__cached_args) or len(kwargs) != len(self.__cached_kwargs):
return True
# check args and kwargs
for a, ca in zip(args, self.__cached_args):
if a != (ca() if isinstance(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_args(self, args_):\n\n pass",
"def _check_args(self, args):\n if len(args) == 0:\n print(\"No parameters provided.\")\n return False\n else:\n return True",
"def __check_args(self):\n self.__check_args_type()\n self.__check_args_val... | [
"0.7180964",
"0.67476994",
"0.6550825",
"0.64482",
"0.61821944",
"0.6121256",
"0.6078874",
"0.60775244",
"0.5957351",
"0.59326947",
"0.59292126",
"0.585978",
"0.5825051",
"0.57995284",
"0.57905746",
"0.5777149",
"0.57604843",
"0.5759606",
"0.5752128",
"0.5742403",
"0.5735094"... | 0.76295835 | 0 |
Return the two base images needed to create a lighthouse animation. base_img is either A full/relative path from the run context The name of a directory under lighthouses here | def load_base_images(base_img):
if base_img is not None:
if not os.path.exists(base_img):
base_img = os.path.join(LIGHTHOUSES_DIR, base_img)
return (
Image.open(os.path.join(base_img, 'on.gif')).convert('RGBA'),
Image.open(os.path.join(base_img, 'off.gif'))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_imagebase(self):\n pass",
"def get_random_base():\n\n n_base = count_raw_img('base')\n img = \"{}.jpg\".format(random.randint(1, n_base + 1))\n return Image.open(RAW_DIR_PATH['base'] + img)",
"def propose_image_path():\n image_name = \"image_{}.png\".format(''.join(random.choice('abc... | [
"0.62116516",
"0.6163408",
"0.5916963",
"0.57784426",
"0.5775673",
"0.5691343",
"0.5683936",
"0.5591003",
"0.5576489",
"0.55682087",
"0.5541228",
"0.548597",
"0.5453294",
"0.54221994",
"0.54105973",
"0.5399216",
"0.535957",
"0.5359305",
"0.5342906",
"0.531411",
"0.52954346",
... | 0.7206143 | 0 |
Given a light characteristic, return a list of 2tuples representing the state of light at any given time. A fixed light is the given colour, permanently >>> characteristic_to_light_states('F. R') [('R', 1)] | def characteristic_to_light_states(description):
fragments = description.split()
pattern_type, groups = parse_pattern(fragments.pop(0))
colour, fragments = get_colour_code(fragments)
try:
period = parse_period(fragments)
except IndexError:
if must_have_period(pattern_type, groups):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_states(crime):\n statelist = []\n for i in range(len(crime)-1):\n statelist.append(crime[i][0])\n return statelist",
"def get_rgb_light():\n return list(light.rgb())",
"def lights(self):\n return list(self.GetLights())",
"def lights_on(self) -> list:\n return [\n ... | [
"0.5880032",
"0.5774206",
"0.5655911",
"0.55833024",
"0.5447408",
"0.5406236",
"0.54036015",
"0.537056",
"0.53520906",
"0.5329592",
"0.5319485",
"0.5250559",
"0.5245645",
"0.5213831",
"0.51771307",
"0.51550233",
"0.50853217",
"0.507346",
"0.50687844",
"0.50391555",
"0.5013721... | 0.6722805 | 0 |
Given the split up characteristic, return the period in milliseconds The period is specified in seconds >>> parse_period(['2']) 2000 The letter 's' to mark the units may be present >>> parse_period(['3s']) 3000 It may be separated from the number by a space >>> parse_period(['4','s']) 4000 A Quick flash can only have a... | def parse_period(fragments):
period_spec = fragments[-1]
# The last term is the cycle period,
# it may or may not have 's' for seconds
# The 's' may or may not be attached to the number
if period_spec == 's':
period_spec = fragments[-2]
if period_spec[-1] == 's':
period_spec = pe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def period(self):\n period_ns = int(utils.readstr_all(os.path.join(_CHANNEL_PATH(self._chip,\n self._channel),\n 'period')))\n return int(period_ns / 1000)",
"def get_period_sec... | [
"0.6479936",
"0.644268",
"0.6255988",
"0.6126181",
"0.59293336",
"0.5887166",
"0.5848696",
"0.581168",
"0.5801859",
"0.57852525",
"0.57155305",
"0.57155305",
"0.56989634",
"0.5696296",
"0.55982697",
"0.55982697",
"0.5581507",
"0.55336004",
"0.5522052",
"0.55193275",
"0.551443... | 0.75614196 | 0 |
Crack a pattern definition into its type and any grouping. A pattern consists of the pattern type (e.g. flashing, occulting) and optionally a group designation in parentheses. The pattern definition could just be the type >>> parse_pattern('Fl') ('fl', [1]) It could have optional dots marking the abbreviation, these ca... | def parse_pattern(pattern):
pattern_type, _, group_spec = pattern.partition('(')
# Groups are separated by '+' in a composite pattern.
groups = [
int(group) for group in group_spec[:-1].split('+')
] if group_spec else [1]
# Some light lists use dots, some don't, just throw them away
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_pattern(pattern: NumberPattern | str) -> NumberPattern:\n if isinstance(pattern, NumberPattern):\n return pattern\n\n def _match_number(pattern):\n rv = number_re.search(pattern)\n if rv is None:\n raise ValueError(f\"Invalid number pattern {pattern!r}\")\n re... | [
"0.6776147",
"0.61842924",
"0.6145672",
"0.60469675",
"0.582925",
"0.576661",
"0.5751908",
"0.5672661",
"0.564937",
"0.55928665",
"0.5582709",
"0.54133475",
"0.5398375",
"0.53610086",
"0.5338687",
"0.5337617",
"0.53008944",
"0.5261952",
"0.5254372",
"0.52399373",
"0.5239051",... | 0.7442205 | 0 |
Given a list of light states, collapse any adjacent entries that have the same state. If there are no adjacent matching states, there is no change to the output >>> collapse_states([('R',1), ('Y', 1), ('R', 1)]) [('R', 1), ('Y', 1), ('R', 1)] Adjacent states are collapsed, summing their durations >>> collapse_states([(... | def collapse_states(states):
new_states = states[:1]
for state in states[1:]:
last_state = new_states[-1]
if state[0] == last_state[0]:
new_states[-1] = (state[0], last_state[1] + state[1])
else:
new_states.append(state)
return new_states | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def states_filter(state):\n if state.count(0) < state.count(1) or state.count(1) < state.count(0) - 1:\n return False\n\n rows = [[i, i+1, i+2] for i in [0, 3, 6]]\n cols = [[i, i+3, i+6] for i in [0, 1, 2]]\n\n winners = set()\n\n for row_indexes in rows:\n row = [state[ind] for ind i... | [
"0.52173054",
"0.5162994",
"0.50791174",
"0.50559324",
"0.4989781",
"0.4952426",
"0.4899571",
"0.48871356",
"0.48810527",
"0.48748165",
"0.48466158",
"0.47453317",
"0.47329503",
"0.47069013",
"0.46448886",
"0.46182868",
"0.4606048",
"0.4591518",
"0.45846918",
"0.45573312",
"0... | 0.7746325 | 0 |
The Fixed pattern is simply an alwayson light in the given colour. groups and period are irrelevant. | def fixed(_groups, colour, _period):
return [(colour, 1)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pattern(colors=('green', 'blue', 'red')): # (10)\n for i in range(0, int(ceil(float(NUM_LEDS)/float(len(colors))))):\n for color in colors:\n push_color(color)",
"def fill(self, color):",
"def fill(self, colour: int, /) -> None:",
"def occult... | [
"0.57946724",
"0.57644004",
"0.5761895",
"0.5750514",
"0.5239501",
"0.52209616",
"0.5144774",
"0.51025516",
"0.5077008",
"0.50707483",
"0.50707483",
"0.5058601",
"0.5058601",
"0.5058601",
"0.50353426",
"0.5011609",
"0.50076145",
"0.50035447",
"0.49892506",
"0.49738902",
"0.49... | 0.72213733 | 0 |
A flash is a single colour displayed for a short period, followed by a longer period of darkness A single flash of a given colour is a 1 second flash >>> flash([1], 'R', 5000) [('R', 1000), ('Off', 4000)] Grouped flashes have a shorter duration >>> flash([3], 'R', 10000) [('R', 500), ('Off', 1000), ('R', 500), ('Off', ... | def flash(groups, colour, period):
if groups == [1]:
if period <= 2000:
raise ValueError(
"The cycle period for a flash must be longer than 2 seconds"
)
return [
(colour, 1000),
('Off', period-1000)
]
return light_sequenc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def long_flash(groups, colour, period):\n if groups == [1]:\n return [\n (colour, 2000),\n ('Off', period - 2000)\n ]\n return light_sequence(groups, colour, 'Off', period, 2000, 3000)",
"def quick(groups, colour, period):\n # The cycle period cannot be longer than 1.... | [
"0.6906268",
"0.63640183",
"0.53384686",
"0.5311426",
"0.52867997",
"0.5262986",
"0.5233251",
"0.52132744",
"0.5064614",
"0.50232327",
"0.4976142",
"0.49747515",
"0.49659762",
"0.49345678",
"0.4889537",
"0.4873445",
"0.4861576",
"0.48529956",
"0.48520216",
"0.48484832",
"0.48... | 0.730446 | 0 |
isophase is a pattern with equal dark and light. There are no groups. | def isophase(_groups, colour, period):
# Whole numbers are required, so odd numbers are dealt with by loading
# the spare into the off period.
# As this is in milliseconds, this will be imperceptible.
# It is also unlikely, as the top-level input is in seconds
# and has been multiplied up to millise... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_monochromatic(self):\n return equal(s.color for s in self.iter_states())",
"def keep_measures(mosaiced_img, pattern):\n h, w = mosaiced_img.shape\n imout = np.zeros((h, w, 3))\n mask = np.zeros((h, w, 3))\n for i in range(2):\n for j in range(2):\n imout[i::2, j::2, pa... | [
"0.54219186",
"0.52342373",
"0.51545143",
"0.5147554",
"0.512688",
"0.493742",
"0.49075535",
"0.48455277",
"0.48435876",
"0.48435876",
"0.48414382",
"0.48366624",
"0.48366624",
"0.48366624",
"0.48335874",
"0.4826204",
"0.4740178",
"0.47373027",
"0.47355133",
"0.4724675",
"0.4... | 0.5926785 | 0 |
A Quick flash is more than 50 per minute. | def quick(groups, colour, period):
# The cycle period cannot be longer than 1.2s (60/50)
# or shorter than 0.5s
if groups == [1]:
if period is not None:
raise ValueError(
"Quick Flash cycle periods must be longer than 0.5 seconds"
)
return [
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_flash_timer(self):\r\n self.flashMillisecs = 1000\r\n self.flashTimer.start(50)",
"def giveFlash(self, amount):\n self.fb = amount\n if amount > 0:\n es.give(self.userid, \"weapon_flashbang\")",
"def brief_led_flash(self):\n self._ubx.send('CFG-TP5', puls... | [
"0.7274421",
"0.6186878",
"0.6086867",
"0.59733325",
"0.58153445",
"0.58117354",
"0.5774111",
"0.57247484",
"0.5715428",
"0.569542",
"0.5694873",
"0.5687403",
"0.56838447",
"0.5658738",
"0.56574625",
"0.5635628",
"0.5612565",
"0.5605468",
"0.5590237",
"0.55884016",
"0.5575568... | 0.61882275 | 1 |
Write out binary VTK file with a single vector field. Can specify time index or output time. | def writeVTK(self,fname,itime=None,output_time=None):
if output_time:
itime = int(output_time / self.dt)
if not itime:
print 'Need to specify itime or output_time'
return
print 'Writing out time step',itime,': t=',self.t[itime]
u = np.zeros((self.NY,1,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saveVelocityAndPressureVTK_binary(pressure,u,v,w,x,y,z,filename,dims):\n numEl_size = u.size; numEl = np.prod(numEl_size);\n # open the file and write the ASCII header:\n file = open(filename,'w')\n file.write('# vtk DataFile Version 3.0\\n')\n file.write('VTK file for data post-processed with P... | [
"0.6757693",
"0.66369015",
"0.6426294",
"0.63140506",
"0.626889",
"0.6226187",
"0.607385",
"0.604287",
"0.6018301",
"0.6018301",
"0.5969815",
"0.5968377",
"0.594419",
"0.5942577",
"0.58605295",
"0.5848289",
"0.5788712",
"0.5758208",
"0.5744678",
"0.5741473",
"0.5739878",
"0... | 0.7530258 | 0 |
Call writeVTK for a range of times | def writeVTKSeries(self,prefix=None,step=1):
if not prefix: prefix = self.prefix
for i in range(0,self.N,step):
fname = prefix + '_' + str(i) + '.vtk'
self.writeVTK(fname,itime=i) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writeVTK(self,fname,itime=None,output_time=None):\n if output_time:\n itime = int(output_time / self.dt)\n if not itime:\n print 'Need to specify itime or output_time'\n return\n print 'Writing out time step',itime,': t=',self.t[itime]\n u = np.zeros... | [
"0.67234313",
"0.65439826",
"0.61956275",
"0.6171551",
"0.584729",
"0.58062536",
"0.5772773",
"0.5763361",
"0.5762426",
"0.56863654",
"0.5424772",
"0.5380682",
"0.5364221",
"0.53386146",
"0.53386146",
"0.5328883",
"0.5259615",
"0.5244934",
"0.52399683",
"0.5105576",
"0.507751... | 0.6567778 | 1 |
Creates a minimal configuration for the user. | def create_default_user_config(server, port, user, api_key, whitelist_tags=[], ignore_proxy=True, verify_ssl=False):
config = {}
config_path = DEFAULT_CONFIG_PATH
config['default'] = {'server': server,
'port': port,
'user': user,
'ap... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_config(self) -> None:\n pass",
"def create_config(self) -> None:\n pass",
"def create_empty_config_file():\n config = {\n \"config\": [\n {\n \"site\": {\n \"username\": \"\",\n \"name\": ... | [
"0.6830326",
"0.6830326",
"0.68101245",
"0.67205757",
"0.66883713",
"0.6676231",
"0.6484155",
"0.6468319",
"0.64551955",
"0.63014174",
"0.626041",
"0.6171588",
"0.61103344",
"0.60650027",
"0.6061568",
"0.6031424",
"0.5996078",
"0.592579",
"0.59251434",
"0.59190315",
"0.590579... | 0.68759596 | 0 |
rebuilds elements of flat_li to match list structure of original_li (or tuple if given as args) | def deflatten(flat_li, *original_li):
if len(original_li) == 1:
original_li = original_li[0]
deflatten_li = []
i = 0
for el in original_li:
if isinstance(el, Sequence):
deflatten_li.append(flat_li[i:i+len(el)])
i += len(el)
else:
deflatten_li.a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flatten(self, l, ltypes=(list, tuple)):\n i = 0\n while i < len(l):\n while isinstance(l[i], ltypes):\n if not l[i]:\n l.pop(i)\n if not len(l):\n break\n else:\n l[i:i + 1] = ... | [
"0.6270293",
"0.6178351",
"0.61386776",
"0.60761553",
"0.58953786",
"0.5860441",
"0.5845089",
"0.57745105",
"0.5755302",
"0.5732161",
"0.56978935",
"0.566958",
"0.566346",
"0.56503826",
"0.5627321",
"0.5624456",
"0.5575356",
"0.5567329",
"0.5556008",
"0.5543179",
"0.55420625"... | 0.7833961 | 0 |
find all indices from list ``l`` where entries match specific object ``o`` | def findall(l, o):
return [i for i, u in enumerate(l) if u==o] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAllIndex(ldata, fldata):\n\treturn list(map(lambda e : fldata.index(e), ldata))",
"def matchloc(alist,val): \n return [ilc for ilc,jlc in enumerate(alist) if jlc==val]",
"def get_indexes(from_list, find_list):\n\n df_find = pd.DataFrame(find_list, columns=['value'])\n df_from = pd.DataFrame(li... | [
"0.63037544",
"0.6193546",
"0.6087121",
"0.6016721",
"0.59283173",
"0.5781884",
"0.57606155",
"0.5718999",
"0.5709015",
"0.56931007",
"0.5680674",
"0.5623687",
"0.5537491",
"0.551839",
"0.5506623",
"0.5459669",
"0.5450619",
"0.54497373",
"0.53892154",
"0.53692645",
"0.5348893... | 0.7872293 | 0 |
get all entries of list ``l`` at positions ``idx`` | def getall(l, idx):
return [l[i] for i in idx] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multiListSlice(lol, index):\n divisor = 1\n values = []\n for i in range(0, len(lol)):\n index = (index / divisor) % len(lol[i])\n values[i] = lol[i][index]\n divisor *= len(lol[i])\n return values",
"def extract_sub_list(mylist, indices):\n return [mylist[ii] for ii in in... | [
"0.6098279",
"0.59349114",
"0.58925664",
"0.58031976",
"0.5779936",
"0.5718426",
"0.56653845",
"0.56569105",
"0.5654663",
"0.5648731",
"0.5606806",
"0.55991054",
"0.55896133",
"0.550258",
"0.5500482",
"0.54870623",
"0.54548275",
"0.54517424",
"0.5408129",
"0.54024506",
"0.529... | 0.82942766 | 0 |
Model function for CIFAR10. | def cifar10_model_fn(features, labels, mode, params):
features = tf.reshape(features, [-1, _IMAGE_SIZE, _IMAGE_SIZE, _NUM_CHANNELS])
learning_rate_fn = resnet_run_loop.learning_rate_with_decay(
batch_size=params['batch_size'], batch_denom=128,
num_images=_NUM_IMAGES['train'], boundary_epochs=[10, 20, 3... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cifar10(self):\n\t\t# Get the data.\n\t\tself.x_train = self.x_train.reshape(self.nb_train, self.input_dim)\n\t\tself.x_test = self.x_test.reshape(self.nb_test, self.input_dim)\n\t\tself.x_train = self.x_train.astype('float32')\n\t\tself.x_test = self.x_test.astype('float32')\n\t\tself.x_train /= 255\n\t\t... | [
"0.6843386",
"0.650111",
"0.609306",
"0.60163224",
"0.5996454",
"0.59331244",
"0.588775",
"0.58561015",
"0.5830527",
"0.57808924",
"0.57354146",
"0.5720595",
"0.5690742",
"0.56661737",
"0.5664544",
"0.5653322",
"0.56082076",
"0.55979353",
"0.5551245",
"0.5541251",
"0.5541251"... | 0.6535784 | 1 |
This is the main prediction adding function. It starts by grabbing a file to open from standard in, which contains one message board page. It processes each message contained in the page. | def main():
# db_user = raw_input('DB username: ')
db_user = 'oraclech'
pw = getpass.getpass()
odb = oracle_db.OracleDb(db_user, pw, database='oraclech_new')
contest_id = raw_input('Current Contest ID? ')
round_num = raw_input('Current Round Number? ')
round_nums = round_num.split(',')
topic_num = ra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_poems(self):\n file = open(self.name, \"r\")\n content = file.readlines()\n for i in content:\n self.add_msg_and_index(i.strip())",
"def process_input_file(sess, char_dict, model_settings, model_vars, input_file):\n \n with open(input_file, 'r') as f:\n for s... | [
"0.5945443",
"0.5409753",
"0.5362085",
"0.5329677",
"0.52767473",
"0.5266814",
"0.5265608",
"0.52539533",
"0.5241925",
"0.5217411",
"0.5205404",
"0.51909417",
"0.5187099",
"0.51860255",
"0.5160676",
"0.5133867",
"0.5133248",
"0.51240563",
"0.5112366",
"0.51108074",
"0.5107463... | 0.6416924 | 0 |
This function parses the predictions in one individual message. If the message contains predictions, they will be inserted into the oracle database. | def ParsePredictions(odb, message, contest, round_nums):
duel = 0
if contest['CompetitorsPerMatch'] == 2:
duel = 1
user_id = odb.GetUserId(message['User'])
if user_id is None:
user_id = GetUserId(odb, message['User'], add_alt=1)
# This enables admins to enter predictions for other users.
# TODO: M... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_raw_predictions(self, raw_predictions):\n result = []\n for line in raw_predictions.split(\"\\n\"):\n line_parts = line.split(\"|\")\n type = line_parts[0]\n assert type.lstrip(\"*\") in (\n \"FP\", \"TP\", \"TN\", \"FN\"), 'Expected {} to be... | [
"0.61501306",
"0.6139516",
"0.60400605",
"0.5975302",
"0.5914858",
"0.5826979",
"0.582425",
"0.57627505",
"0.5746949",
"0.5707061",
"0.56706715",
"0.5667077",
"0.5660581",
"0.5609151",
"0.56070286",
"0.5595583",
"0.55625534",
"0.5559505",
"0.5535425",
"0.55325687",
"0.5504344... | 0.6788969 | 0 |
Prompt for user input to figure out who predictions are for. This function is written so that the Oracle host can post predictions in the topic for other users. | def PromptForId(odb, message, orig_id=1):
print 'Is this prediction for someone other than the poster?\n\n%s\n\n' % \
(message['Text'])
diff_user = raw_input('(y/n): ')
if diff_user == 'n':
return orig_id
user_name = raw_input('Username this prediction is for? ')
user_id = odb.GetUserId(user_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_prompt(self):\n # we need _something_ in the dictionary even if the user decides to use all defaults\n # otherwise for some unknown reason it won't work\n user_in = {'__meta__': '__user_input__'}\n\n print('Please enter the information asked for in the following prompts in order ... | [
"0.64296",
"0.6354998",
"0.63514704",
"0.6275108",
"0.6199466",
"0.6192252",
"0.6019146",
"0.59782445",
"0.5917745",
"0.590989",
"0.584681",
"0.58215415",
"0.5810385",
"0.579001",
"0.5771973",
"0.576907",
"0.5767045",
"0.5765213",
"0.5736743",
"0.5734095",
"0.57227224",
"0.... | 0.67718136 | 0 |
tokenized_sentence = ["tu", "que", "tal"] all_words = ["tu", "yo", "soy", "que", "tal"] bag = [ 1, 0, 0, 1, 1] | def bag_of_words(tokenized_sentence, all_words):
tokenized_sentence = [stem(w) for w in tokenized_sentence]
#print(tokenized_sentence)
bag = np.zeros_like(all_words, dtype=np.float32)
for idx, w in enumerate(all_words):
if w in tokenized_sentence:
bag[idx] = 1.0
return bag | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bag_of_words(batch, TEXT):\n V = len(TEXT.vocab)\n X = torch.zeros(batch.text.size(0), V)\n ones = torch.ones(batch.text.size(1))\n for b in range(batch.text.size(0)):\n X[b].index_add_(0, batch.text.data[b], ones)\n X[b][TEXT.vocab.stoi['<pad>']] = 0\n X = Variable(X, requires_gra... | [
"0.7064958",
"0.6989011",
"0.6753921",
"0.66266555",
"0.6409904",
"0.63231957",
"0.6267341",
"0.62106866",
"0.6205491",
"0.6204041",
"0.6201656",
"0.61629564",
"0.61408895",
"0.60988027",
"0.6071161",
"0.60488117",
"0.60472023",
"0.59949446",
"0.59798604",
"0.5959912",
"0.595... | 0.8335468 | 0 |
A decorator that registers a coroutine as a preinvoke hook. A preinvoke hook is called directly before the command is called. This makes it a useful function to set up database connections or any type of set up required. | def before_invoke(self, coro):
if not asyncio.iscoroutinefunction(coro):
raise TypeError('The pre-invoke hook must be a coroutine.')
self._before_invoke = coro
return coro | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_invoke(coro) -> Callable[[T], T]:\n def decorator(func: Union[Command, CoroFunc]) -> Union[Command, CoroFunc]:\n if isinstance(func, Command):\n func.before_invoke(coro)\n else:\n func.__before_invoke__ = coro\n return func\n return decorator # type: ign... | [
"0.711384",
"0.59254164",
"0.59139216",
"0.57862735",
"0.57862735",
"0.57862735",
"0.57862735",
"0.5783765",
"0.56661844",
"0.55336636",
"0.54575396",
"0.5412497",
"0.535912",
"0.5343143",
"0.5328596",
"0.5258286",
"0.5252766",
"0.5236413",
"0.5234541",
"0.5177922",
"0.516268... | 0.7430255 | 0 |
A decorator that registers a coroutine as a postinvoke hook. A postinvoke hook is called directly after the command is called. This makes it a useful function to cleanup database connections or any type of clean up required. | def after_invoke(self, coro):
if not asyncio.iscoroutinefunction(coro):
raise TypeError('The post-invoke hook must be a coroutine.')
self._after_invoke = coro
return coro | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_invoke(coro) -> Callable[[T], T]:\n def decorator(func: Union[Command, CoroFunc]) -> Union[Command, CoroFunc]:\n if isinstance(func, Command):\n func.after_invoke(coro)\n else:\n func.__after_invoke__ = coro\n return func\n return decorator # type: ignore... | [
"0.7060543",
"0.59133196",
"0.5863492",
"0.57352626",
"0.56779206",
"0.563653",
"0.55416155",
"0.5520004",
"0.5520004",
"0.5520004",
"0.5520004",
"0.5489191",
"0.5475493",
"0.54560333",
"0.54542017",
"0.5424057",
"0.5418961",
"0.5323915",
"0.5317458",
"0.5298286",
"0.5239417"... | 0.7256072 | 0 |
An iterator that recursively walks through all commands and subcommands. Yields | def walk_commands(self) -> typing.Generator[Command, None, None]:
for command in self.commands:
yield command
if isinstance(command, Group):
yield from command.walk_commands() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n for node in self.grammar.walk():\n yield node",
"def HierarchyIterator(obj):\n while obj:\n yield obj\n for opChild in SplineInputGeneratorHelper.HierarchyIterator(obj.GetDown()):\n yield opChild\n obj = obj.GetNext()"... | [
"0.69049597",
"0.6855705",
"0.67742354",
"0.67373574",
"0.6698454",
"0.6655534",
"0.6623079",
"0.65826356",
"0.65400165",
"0.650673",
"0.63782173",
"0.63522226",
"0.63168263",
"0.63032573",
"0.63010323",
"0.62850904",
"0.62850904",
"0.626276",
"0.6249921",
"0.62281144",
"0.61... | 0.75511664 | 0 |
A decorator that registers a coroutine as a preinvoke hook. This allows you to refer to one before invoke hook for several commands that do not have to be within the same cog. Example | def before_invoke(coro) -> Callable[[T], T]:
def decorator(func: Union[Command, CoroFunc]) -> Union[Command, CoroFunc]:
if isinstance(func, Command):
func.before_invoke(coro)
else:
func.__before_invoke__ = coro
return func
return decorator # type: ignore | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_invoke(self, coro):\n if not asyncio.iscoroutinefunction(coro):\n raise TypeError('The pre-invoke hook must be a coroutine.')\n\n self._before_invoke = coro\n return coro",
"def wrap_before(before, condition=lambda *args, **kwargs: True):\n def decorator(func):\n ... | [
"0.7762231",
"0.61355424",
"0.6063686",
"0.5962607",
"0.58490914",
"0.5809584",
"0.5795975",
"0.5628273",
"0.55104494",
"0.55104494",
"0.55104494",
"0.55104494",
"0.54770267",
"0.5420125",
"0.53899693",
"0.53138167",
"0.53052264",
"0.52775484",
"0.52747756",
"0.5244982",
"0.5... | 0.7769411 | 0 |
A decorator that registers a coroutine as a postinvoke hook. This allows you to refer to one after invoke hook for several commands that do not have to be within the same cog. | def after_invoke(coro) -> Callable[[T], T]:
def decorator(func: Union[Command, CoroFunc]) -> Union[Command, CoroFunc]:
if isinstance(func, Command):
func.after_invoke(coro)
else:
func.__after_invoke__ = coro
return func
return decorator # type: ignore | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_invoke(self, coro):\n if not asyncio.iscoroutinefunction(coro):\n raise TypeError('The post-invoke hook must be a coroutine.')\n\n self._after_invoke = coro\n return coro",
"def Postcall(function_to_call_later): \n def postcall_inside(fun): \n @functo... | [
"0.7621359",
"0.6003703",
"0.590855",
"0.580963",
"0.56406933",
"0.5633439",
"0.5529226",
"0.551219",
"0.5412582",
"0.53565824",
"0.5354295",
"0.5315982",
"0.53044456",
"0.5290917",
"0.52646506",
"0.5262968",
"0.5256531",
"0.52481365",
"0.52188635",
"0.5216198",
"0.5194705",
... | 0.77887046 | 0 |
Initializes a storage merge reader. | def __init__(self, session, storage_writer, task_storage_reader):
super(StorageMergeReader, self).__init__()
self._active_container_type = None
self._active_generator = None
self._container_types = []
self._event_data_identifier_mappings = {}
self._event_data_parser_mappings = {}
self._event... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n\n self.reader = reader.Reader()",
"def __init__(self, storage_writer, task, redis_client=None):\n super(RedisMergeReader, self).__init__(storage_writer)\n self._active_container_type = None\n self._container_types = []\n self._active_cursor = 0\n self._add_active_conta... | [
"0.62885654",
"0.58362806",
"0.57856005",
"0.5741826",
"0.5728234",
"0.5686032",
"0.5671583",
"0.55968064",
"0.55951667",
"0.55562574",
"0.5551261",
"0.5526546",
"0.5510841",
"0.54997456",
"0.54607743",
"0.54495597",
"0.54392564",
"0.54389495",
"0.5437427",
"0.5426284",
"0.53... | 0.70713705 | 0 |
Handle page head and create dict with different content | def handle_page_head(self, head_content):
return_dict = {}
return_dict['title'] = self.find_in_content(r'title:.+', head_content)
return_dict['permalink'] = self.find_in_content(r'permalink:.+',
head_content)
return return_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ParsePageHead(read):\n page_head = {}\n result = struct.unpack_from(PageHeadFormat, read, 0)\n for i in xrange(len(PageHeadProperties)):\n page_head[PageHeadProperties[i]] = result[i]\n return page_head",
"def handle_page_body(self, body_content):\n return_dict = {}\n return_... | [
"0.65806377",
"0.6083205",
"0.59432834",
"0.59213173",
"0.5893205",
"0.58655334",
"0.5822796",
"0.5818106",
"0.58166486",
"0.57890755",
"0.57307625",
"0.5705943",
"0.5701683",
"0.5639737",
"0.5633458",
"0.56205946",
"0.557755",
"0.5573049",
"0.5549238",
"0.5528069",
"0.552551... | 0.8366756 | 0 |
Handle page body and create page dict | def handle_page_body(self, body_content):
return_dict = {}
return_dict['content'] = self.markdown_to_html(body_content)
return return_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_mapping_page(self, id, body):\n info = {}\n info['original'] = self.__re_search(body, *self.regx['original'])\n info['save'] = self.__re_search(body, *self.regx['save'])\n info['price'] = self.__re_search(body, *self.regx['price'])\n info['rebate'] = self.__re_search(bo... | [
"0.64590585",
"0.6278418",
"0.6139448",
"0.5948847",
"0.5872562",
"0.5811106",
"0.57711333",
"0.57591534",
"0.5752565",
"0.57495147",
"0.5747665",
"0.5722854",
"0.5712628",
"0.571118",
"0.5696923",
"0.5694322",
"0.5614354",
"0.56108755",
"0.56095475",
"0.5606405",
"0.5568982"... | 0.7880545 | 0 |
Read pages and save the instance into database | def read_pages(self):
for file in os.listdir(self.repo_path):
if file.endswith('.md'):
if str(file) is not ('README.md' or '404.md'):
with open(self.repo_path + file, 'r') as page_file:
file_data = page_file.read()
c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self, *args, **kwargs):\n created = False\n if self.pk is None:\n created = True\n super(Base, self).save(*args, **kwargs)\n if created is True:\n for i in range(self.page_count):\n page = Page(work=self, number=i+1)\n page.sa... | [
"0.6114496",
"0.60416394",
"0.59844977",
"0.59610665",
"0.5876366",
"0.5847255",
"0.57638466",
"0.5758273",
"0.57403046",
"0.57091016",
"0.5637539",
"0.5621401",
"0.55633825",
"0.5521344",
"0.5509448",
"0.55065763",
"0.5492751",
"0.54720575",
"0.5468598",
"0.54553676",
"0.540... | 0.6453269 | 0 |
read all files that we want at any time. we have to pass the extension and exception_list. exception_list will contain the list of all the files that should'nt be scanned. repo is the Repo db instance | def read_pages(self, repo, extension, exception_list):
for file in os.listdir(self.repo_path):
if file.endswith('.'.join(['', extension])):
if file not in exception_list:
file_handler = FileHandler(self.repo_path, file)
content = file_handler.r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_files_with_extension(self, extension=sys.argv[1]) -> list:\n if extension == \"\":\n raise EnvironmentError(\"No extension provided!\")\n\n result = []\n for idx, file in enumerate(self.file_list):\n if re.search(extension + \"$\", file):\n result.a... | [
"0.6206179",
"0.6107929",
"0.6043444",
"0.593927",
"0.58915067",
"0.58556247",
"0.57860583",
"0.57807255",
"0.5777453",
"0.5773534",
"0.5771638",
"0.57592523",
"0.57556206",
"0.5750356",
"0.5739557",
"0.57273585",
"0.57255244",
"0.57110775",
"0.5685773",
"0.56543374",
"0.5647... | 0.72571635 | 0 |
Update status to database | def _update_status(self):
self._db_update({'status': self.status}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateStatus(self, status):\n pass",
"def UpdateStatus(self, status):\r\n self.status.update(status)",
"def updatestatus(self):\n self.status = self.query()\n if self.status['success']:\n return True\n else:\n return False",
"def update_status(request_... | [
"0.8104977",
"0.7823668",
"0.7671553",
"0.74507135",
"0.7403075",
"0.73636246",
"0.72525454",
"0.725253",
"0.72357446",
"0.7171517",
"0.7166486",
"0.70517457",
"0.7043152",
"0.7029378",
"0.7019931",
"0.6978809",
"0.69682807",
"0.6892425",
"0.68785965",
"0.6876388",
"0.6852951... | 0.90569335 | 0 |
Function to generate distributed training scripts. | def generate_disttrain_scipts(self):
train_py = "/home/haihuam/Projects/RepPoints/mmdetection/tools/train.py"
py = self.global_setting.get('python', sys.executable)
ex_options = self.global_setting.get('train_options', str())
if not os.access(py, os.X_OK):
py = "/home/haihua... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def script_generator(self):\n\n self._get_free_tcp_port()\n\n train_py = \"/home/haihuam/Projects/RepPoints/mmdetection/tools/train.py\"\n py = self.global_setting.get('python', sys.executable)\n ex_options = self.global_setting.get('train_options', str())\n\n if not os.access(py... | [
"0.7570193",
"0.724141",
"0.7049878",
"0.6241078",
"0.6189553",
"0.6151004",
"0.6111944",
"0.6034311",
"0.60096145",
"0.59790266",
"0.59271824",
"0.58651984",
"0.5852421",
"0.5842843",
"0.58210456",
"0.58143574",
"0.5811275",
"0.58090484",
"0.5808338",
"0.58027387",
"0.580093... | 0.7527086 | 1 |
Function to generate the scripts to analyze the log. | def script_generator(self):
analyze_tool = "/home/haihuam/Projects/RepPoints/mmdetection/tools/analyze_logs.py"
ex_options = self.global_setting.get('analyze_options', str())
py = self.global_setting.get('python', sys.executable)
if os.access(py, os.X_OK):
content = "set -e \... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def script_generator(self):\n py = self.global_setting.get('python', sys.executable)\n ex_options = self.global_setting.get('evaluate_options', str())\n train_py = \"/home/haihuam/Projects/RepPoints/mmdetection/tools/train.py\"\n if os.access(py, os.X_OK):\n content = \"set -... | [
"0.6372324",
"0.6196502",
"0.58817005",
"0.5872832",
"0.5843183",
"0.57949096",
"0.5750669",
"0.5748845",
"0.57101727",
"0.56722856",
"0.5642168",
"0.56294507",
"0.5594446",
"0.55805284",
"0.552635",
"0.55260634",
"0.5525768",
"0.5515622",
"0.5510869",
"0.5489981",
"0.5473564... | 0.81086046 | 0 |
Function to generate distributed training scripts. | def script_generator(self):
self._get_free_tcp_port()
train_py = "/home/haihuam/Projects/RepPoints/mmdetection/tools/train.py"
py = self.global_setting.get('python', sys.executable)
ex_options = self.global_setting.get('train_options', str())
if not os.access(py, os.X_OK):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_disttrain_scipts(self):\n train_py = \"/home/haihuam/Projects/RepPoints/mmdetection/tools/train.py\"\n py = self.global_setting.get('python', sys.executable)\n ex_options = self.global_setting.get('train_options', str())\n\n if not os.access(py, os.X_OK):\n py = ... | [
"0.7527086",
"0.724141",
"0.7049878",
"0.6241078",
"0.6189553",
"0.6151004",
"0.6111944",
"0.6034311",
"0.60096145",
"0.59790266",
"0.59271824",
"0.58651984",
"0.5852421",
"0.5842843",
"0.58210456",
"0.58143574",
"0.5811275",
"0.58090484",
"0.5808338",
"0.58027387",
"0.580093... | 0.7570193 | 0 |
Validates and modifies the dictionary Checks tube number against given radii, max tube lengths, and given q_dof. Checks that the lengths are all divisible by delta_x and raises an error if not. | def config_validation(configuration):
tube_num = configuration.get('tube_number')
q_dof = configuration.get('q_dof')
radius = configuration.get('tube_radius')
delta_x = configuration.get('delta_x')
tube_lengths = configuration.get('tube_lengths')
if isinstance(q_dof, int):
configuration... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check(self):\n # check for nonsense or missing mandatory parameters\n mdp = self.parameters.get( \"md\", [] )\n fp = self.parameters.get( \"files\", [] )\n ip = self.parameters.get( \"intervals\", [] )\n\n for keyword in (\"temperature\", \"steps\", \"stepsize\"):\n ... | [
"0.52189726",
"0.5177317",
"0.5169023",
"0.51312196",
"0.5052218",
"0.50168866",
"0.4954876",
"0.48952448",
"0.4873793",
"0.4869507",
"0.48316526",
"0.48261344",
"0.4816464",
"0.47993284",
"0.4798235",
"0.47845814",
"0.47829345",
"0.47609234",
"0.47100845",
"0.46791354",
"0.4... | 0.6384456 | 0 |
Takes an object and returns a list of names of all the methods in that class | def classmethods(class_object):
fn_tuple_list = inspect.getmembers(class_object, predicate=inspect.ismethod)
fn_names = [
f_name for (f_name, method) in fn_tuple_list if not f_name.startswith("_")
]
return fn_names | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def methods_of(obj):\r\n result = []\r\n for i in dir(obj):\r\n if callable(getattr(obj, i)) and not i.startswith('_'):\r\n result.append((i, getattr(obj, i)))\r\n return result",
"def lookup(obj):\n objList = [method_name for method_name in dir(obj)\n if callable(geta... | [
"0.81180924",
"0.77584505",
"0.7427535",
"0.7369807",
"0.7367492",
"0.7268082",
"0.7225354",
"0.70353705",
"0.70313483",
"0.70313483",
"0.7011768",
"0.6934401",
"0.6904447",
"0.68782264",
"0.68726104",
"0.6863157",
"0.6825215",
"0.6760233",
"0.67479444",
"0.67468894",
"0.6688... | 0.8122183 | 0 |
The Akaike information criterion (AIC) is a measure of the relative goodness of fit of a statistical model. Akaike, Hirotugu (1974). "A new look at the statistical model | def calculate_AIC(self):
hmm_ll_calculator = LikelihoodInfEngineHMM(
dbn=self.model.dbn, hidden_node_index=0, check_dbn=False)
ll_full = hmm_ll_calculator.calc_ll(self.seq_list, self.mismask_list)
return 2 * ll_full - 2 * self._get_parameter_count() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_aic_ms(distribution):\n print(\"TESTING: AIC model selection for %s distribution\" % distribution.upper())\n params = dist.DISTRIBUTIONS[distribution][dist.KEY_TEST_PARAMS]\n print(\" creating sample\")\n test_sample = dist.samples(distribution, params)\n print(\" calculating AIC for all ... | [
"0.7080638",
"0.67313176",
"0.66234607",
"0.6486055",
"0.61601174",
"0.6079734",
"0.6033591",
"0.57279545",
"0.57276684",
"0.563323",
"0.56095815",
"0.555238",
"0.5534736",
"0.5459357",
"0.5456556",
"0.54511565",
"0.5418131",
"0.5415451",
"0.5370663",
"0.5346118",
"0.5329103"... | 0.6961269 | 1 |
The Bayesian information criterion (BIC) is a criterion for model selection among a finite set of models. Schwarz, Gideon E. (1978). "Estimating the dimension of a model". Annals | def calculate_BIC(self):
hmm_ll_calculator = LikelihoodInfEngineHMM(
dbn=self.model.dbn, hidden_node_index=0, check_dbn=False)
ll_full = hmm_ll_calculator.calc_ll(self.seq_list, self.mismask_list)
return 2 * ll_full - self._get_parameter_count() * math.log(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bic_ms(distribution):\n print(\"TESTING: BIC model selection for %s distribution\" % distribution.upper())\n params = dist.DISTRIBUTIONS[distribution][dist.KEY_TEST_PARAMS]\n print(\" creating sample\")\n test_sample = dist.samples(distribution, params)\n print(\" calculating BIC for all ... | [
"0.6738231",
"0.6541316",
"0.6489599",
"0.63965064",
"0.6255589",
"0.61559856",
"0.6112755",
"0.6090768",
"0.59615993",
"0.59547305",
"0.59203905",
"0.59203905",
"0.58714235",
"0.5793341",
"0.5740092",
"0.57190186",
"0.56444794",
"0.5625056",
"0.5620049",
"0.5608862",
"0.5584... | 0.68793404 | 0 |
Create sequence and mismask (mask that identifies values as hidden, observed or missing) from a training set. | def _create_sequence_and_mismask(self, training_set, missing_residues):
seq_list = []
mismask_list = []
if not self.show_warnings:
warning_list = warnings.filters[:]
warnings.filterwarnings('ignore', category=TorusDBNWarning)
training_set_cou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_masked_targets(self, item_ids: tf.Tensor, training: bool = False) -> MaskingInfo:\n\n labels = tf.cast(tf.fill(item_ids.shape, self.padding_idx), dtype=item_ids.dtype)\n non_padded_mask = tf.cast(item_ids != self.padding_idx, labels.dtype)\n rows_ids = tf.range(labels.shape[0], dt... | [
"0.62820804",
"0.60834235",
"0.5759483",
"0.57154673",
"0.56921595",
"0.5655835",
"0.56276035",
"0.5595453",
"0.55943155",
"0.55873364",
"0.55382186",
"0.5523225",
"0.54959726",
"0.5485287",
"0.54780704",
"0.54613227",
"0.5454266",
"0.5439734",
"0.5433462",
"0.5433462",
"0.54... | 0.6283801 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.