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 |
|---|---|---|---|---|---|---|
Creating fake profiles for given number of people using namedtuples | def init_profiles_using_namedtuple(no_profiles: int):
profiles = []
Profile = namedtuple('Profile', fake.profile().keys())
for _ in range(no_profiles):
profiles.append(Profile(**fake.profile()))
return profiles | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enumerate_person(hf=0.5, age=(18, 60), n=100):\n for i in range(n):\n hfi = random.random() <= hf\n agei = random.randint(*age)\n namei = first_names[hfi]\n yield dict(gender=(1 if hfi else 0), age=agei, name=namei, idc=uuid.uuid4())",
"def create_members(N):\n for _ in rang... | [
"0.6443193",
"0.63009214",
"0.6153241",
"0.6137819",
"0.6063342",
"0.6063036",
"0.60477436",
"0.60470337",
"0.60437965",
"0.60285556",
"0.6014141",
"0.59978324",
"0.5987455",
"0.5987455",
"0.59811175",
"0.593664",
"0.593664",
"0.5933317",
"0.59086925",
"0.59086925",
"0.590869... | 0.7333659 | 0 |
This function finds the oldest person from the slot, calculates the \ duration. The minimum birthdate and time is returned. | def oldest_person_nt(all_profile_nt: namedtuple) -> float:
"""Param: all_profile_nt: Named tuple containing all profiles"""
value = min(all_profile_nt, key=lambda v: v[-1])
date_today = datetime.date.today()
age = (date_today - value.birthdate).days
return int(age/365) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def oldest():\n def get_age(person_list):\n return person_list['age']\n return sorted(PEOPLE_LIST, key = get_age, reverse=True)",
"def take_min(self):\n return self.get_first()",
"def min(self):\n\n return time_stat(self, stat=\"min\")",
"def oldest():\n # fill it out\n newlist =... | [
"0.6221359",
"0.5758762",
"0.57277995",
"0.57165074",
"0.57137835",
"0.5579486",
"0.5531427",
"0.5531427",
"0.5455574",
"0.5450134",
"0.5420511",
"0.5401952",
"0.5370815",
"0.5282806",
"0.51883173",
"0.5179302",
"0.5165424",
"0.5159719",
"0.5157662",
"0.515641",
"0.5151814",
... | 0.6448769 | 0 |
This function uses the mode function defined in statisics library to find \ the most occured blood group from the list. The list is generated \ using the lambda function and returned to the mode function as a \ parameters. The code is then timed and the result and time is \ sent back. | def max_bloodgroup_nt(all_profile_nt: namedtuple) -> tuple:
"""Param:all_profile_nt: Named tuple containing all profiles"""
blood_group = mode(list(map(lambda v: v[5], all_profile_nt)))
return blood_group | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findMode(list):\n # Use Python's Counter function on the list\n values = Counter(list)\n # Returns the highest occurring item\n return values.most_common(1)[0][0]",
"def mode(lst):\n cnt = Counter(lst)\n return cnt.most_common(1)[0][0]",
"def lmode(inlist):\r\n\r\n scores = pstats.uniq... | [
"0.6360939",
"0.57988197",
"0.5796576",
"0.5660203",
"0.5659024",
"0.56108975",
"0.5607258",
"0.5543546",
"0.5522401",
"0.54757273",
"0.5412688",
"0.5288786",
"0.52810484",
"0.5259109",
"0.52543527",
"0.51720995",
"0.507658",
"0.50760496",
"0.5062678",
"0.50548244",
"0.505374... | 0.6243897 | 1 |
To create a fake stock data set for imaginary stock exchange for \ top 100 companies (name, symbol, open, high, close). \ | def stock_market(no_profiles: int) -> tuple:
all_companies = []
Stocks = namedtuple("Stocks", 'name symbol open high close company_weight')
MkValue_ = random.uniform(1000, 50000, 100)
wts_ = random.uniform(0, 1, 100)
wts_ = wts_/sum(wts_)
for _ in range(100):
name = fake.company()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_52_week_high_low_for_stocks(stocks):\n print(\"Fetching stock quotes.\")\n # Build a full list of symbols\n symbols = []\n for key in stocks.keys():\n symbols.append(key)\n\n num_of_batches = int(len(symbols)/BATCH_SIZE) + 1\n\n all_stocks_df = pandas.DataFrame()\n\n #all_stocks... | [
"0.6489456",
"0.6323425",
"0.63060725",
"0.62956864",
"0.6255761",
"0.62412673",
"0.6200349",
"0.6188368",
"0.61862606",
"0.61424375",
"0.61337084",
"0.6123032",
"0.61126554",
"0.6108505",
"0.61013997",
"0.6084537",
"0.6067216",
"0.6050892",
"0.6036497",
"0.60350937",
"0.6013... | 0.7113026 | 0 |
Explains the model with LimeExplainer | def explain_model_with_lime(
model,
data_to_explain=None,
train_data=None,
total_data=None,
examples_to_explain: Union[int, float, list] = 0,
) -> "LimeExplainer":
if total_data is None:
train_x = train_data
test_x = data_to_explain
test_y = None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def explainer(model, text):\r\n from lime.lime_text import LimeTextExplainer\r\n\r\n model = Explainer(model)\r\n\r\n explainer = LimeTextExplainer(\r\n split_expression=lambda x: x.split(),\r\n bow=False,\r\n class_names=[\"positive probability\"]\r\n )\r\n\r\n exp = explainer.... | [
"0.7617358",
"0.6783141",
"0.66918886",
"0.66185474",
"0.6507089",
"0.6430941",
"0.6364863",
"0.62004024",
"0.61559814",
"0.5953485",
"0.5935031",
"0.5910146",
"0.585681",
"0.5826685",
"0.5823301",
"0.581807",
"0.5754989",
"0.5713097",
"0.5707046",
"0.57027256",
"0.5647099",
... | 0.69931304 | 1 |
Does Non Max Suppression given bboxes | def non_max_suppression(bboxes, iou_threshold, threshold, box_format="corners"):
# 49 x 6
assert type(bboxes) == list
# print(bboxes)
bboxes = [box for box in bboxes if box[1] > threshold]
bboxes = sorted(bboxes, key=lambda x: x[1], reverse=True)
bboxes_after_nms = []
# print(bboxes)
w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iou_suppression(cnt_box, yolo_box, max_threshold, min_threshold):\n all_boxes = []\n pre_bboxes = yolo_box\n bboxes = cnt_box\n for i in range(len(pre_bboxes)):\n max_flag = 0\n min_flag = 0\n for j in range(len(bboxes)):\n\n (pre_x1, pre_y1) = (pre_bboxes[i][0], pre... | [
"0.7150832",
"0.7069101",
"0.68712294",
"0.6653853",
"0.65888387",
"0.65339005",
"0.64546716",
"0.6423793",
"0.6404525",
"0.63950497",
"0.6346387",
"0.6314987",
"0.63059807",
"0.62732834",
"0.62166923",
"0.61743283",
"0.607827",
"0.60195446",
"0.5984185",
"0.5977257",
"0.5976... | 0.7529759 | 0 |
out product of state1 and state2 | def ketbra(state1, state2):
state1 = normalize(state1)
state2 = normalize(state2)
return np.outer(state1.conj(), state2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inner_product(state_1, state_2):\n return numpy.dot(state_1.conjugate(), state_2)",
"def braket(state1, state2):\n state1 = normalize(state1)\n state2 = normalize(state2)\n return np.dot(state1.conj(), state2)",
"def product(self, x, y):\n return self( x.lift() * y.lift() )",
"def ... | [
"0.75618",
"0.6473393",
"0.6389227",
"0.61178523",
"0.6102681",
"0.6095291",
"0.6018713",
"0.601494",
"0.5975703",
"0.59749955",
"0.59558004",
"0.59287375",
"0.5914068",
"0.5913484",
"0.5894375",
"0.5887508",
"0.5875724",
"0.5860244",
"0.5821667",
"0.58075386",
"0.57790744",
... | 0.6515105 | 1 |
density matrix of a ensemble of quantum states | def density(ensembles):
if len(ensembles.shape) < 2:
return ketbra(ensembles)
else:
den_mat = ketbra(ensembles[0])
for i in range(1, len(ensembles)):
den_mat += ketbra(ensembles[i])
den_mat /= len(ensembles)
return den_mat | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_density_matrix(states=None, dimensions=None):\n if states is None:\n tdim = np.prod(dimensions)\n dmtotal0 = np.eye(tdim) / tdim\n\n return dmtotal0\n\n dmtotal0 = np.eye(1, dtype=np.complex128)\n\n for i, s in enumerate(states):\n\n if not hasattr(s, \"__len__\"):\n ... | [
"0.7259972",
"0.6602903",
"0.65992695",
"0.6588799",
"0.642848",
"0.6414085",
"0.6389149",
"0.62670654",
"0.6260562",
"0.6256143",
"0.62500995",
"0.6240718",
"0.6226135",
"0.61993104",
"0.61880094",
"0.61302406",
"0.6075312",
"0.60418975",
"0.6032779",
"0.6008144",
"0.5978373... | 0.6821482 | 1 |
fidelity between state1 and state2, only valid for pure state1 | def fidelity(state1, state2):
if len(state1.shape) > 1:
print("error: state1 must be a pure state.")
state1 = normalize(state1)
fid = 0
if len(state2.shape)<2:
state2 = normalize(state2)
fid = np.abs(
braket(state1, state2)
)**2
else:
for i in rang... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_state2(self):\n pass",
"def test_update_state1(self):\n pass",
"def test_eq_not_two_states(self):\n assert not State(substance=\"water\") == 3\n assert not 3 == State(substance=\"water\")",
"def check_state(self):\n pass",
"async def test_multiple_same_sta... | [
"0.631732",
"0.6272566",
"0.62698925",
"0.6217125",
"0.6172236",
"0.6096079",
"0.6023768",
"0.5982629",
"0.59668",
"0.5952515",
"0.5916351",
"0.5878813",
"0.58518475",
"0.5844466",
"0.583131",
"0.5803019",
"0.58011234",
"0.5720957",
"0.57201564",
"0.5688706",
"0.56737256",
... | 0.6372287 | 0 |
NXDOMAIN records to Redis. Scheduled with RedisHandler.submit(). | def nx_to_redis(self, backlog_timer, client_address, name):
if self.stop:
return
if PRINT_COROUTINE_ENTRY_EXIT:
PRINT_COROUTINE_ENTRY_EXIT("START nx_to_redis")
if DNS_STATS:
timer = self.answer_to_redis_stats.start_timer()
self.redis_executor(self.nx... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(host):\n redis.setex('dispatcher',host,60)\n timer = threading.Timer(20.0, post, args=[host])\n timer.daemon = True\n timer.start()",
"def main():\n start = time.time()\n store = redis_stats_store.RedisStatsStore()\n\n delta_domains = get_delta_domains()\n for domain in delta_dom... | [
"0.62073916",
"0.56420434",
"0.5620912",
"0.55742466",
"0.552533",
"0.55196965",
"0.54764575",
"0.5447752",
"0.54184425",
"0.5291048",
"0.5289621",
"0.5279754",
"0.52736604",
"0.5273331",
"0.52584916",
"0.5249248",
"0.5233644",
"0.5203347",
"0.51823413",
"0.51620185",
"0.5121... | 0.568186 | 1 |
Analyze and post to the ShoDoHFlo redis database. | def post_to_redis(self, message):
if self.message_type and message.field('type')[1] != self.message_type:
if self.performance_hint:
logging.warn('PERFORMANCE HINT: Change your Dnstap config to restrict it to client response only.')
self.performance_hint = Fal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(host):\n redis.setex('dispatcher',host,60)\n timer = threading.Timer(20.0, post, args=[host])\n timer.daemon = True\n timer.start()",
"def knock_sev_post(self,host):\n url = \"http://{}:{}/knock\".format(host, self.port)\n method = \"POST\"\n data = {\n \"Comm... | [
"0.5725667",
"0.56653404",
"0.5566156",
"0.5477563",
"0.5476219",
"0.53017694",
"0.5296024",
"0.5260438",
"0.5248785",
"0.52383286",
"0.5230912",
"0.52285486",
"0.5227938",
"0.5227938",
"0.5227938",
"0.5227938",
"0.5227938",
"0.5227938",
"0.5227938",
"0.5227938",
"0.5227938",... | 0.5848072 | 0 |
u"""setParameters(IZParameters) > void Sets the IZParameters normally during creation of menu items. | def setParameters(self, izParameters): #$NON-NLS-1$
| {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_parameters(self, parameters):\n self.parameters = parameters\n self._set_points_and_weights()",
"def updateParameters(self, parameters):",
"def updateParameters(self, parameters):\r\n return",
"def updateParameters(self, parameters):\r\n return",
"def updateParameters(s... | [
"0.6724673",
"0.6470492",
"0.6398909",
"0.6398909",
"0.6398909",
"0.6398909",
"0.6398909",
"0.6398909",
"0.6398909",
"0.6398909",
"0.63371325",
"0.6329999",
"0.6298071",
"0.62955827",
"0.62955827",
"0.62955827",
"0.6238463",
"0.6228565",
"0.6209343",
"0.619296",
"0.619296",
... | 0.8441474 | 0 |
NDVI with wrong bands | def _test_ndvi_incorrect_bands(self):
scene = Landsat8Scene(self.filenames)
self.assertEquals(scene.band_numbers, 8)
try:
scene2.ndvi()
except SatProcessError as e:
self.assertEquals(e.message, 'nir band is not provided')
scene2 = scene.select(['nir', 'b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ndvi(in_nir_band, in_colour_band, in_rows, in_cols, in_geotransform, out_tiff, data_type=gdal.GDT_Float32):\r\n\r\n # Read the input bands as numpy arrays.\r\n np_nir = in_nir_band.ReadAsArray(0, 0, in_cols, in_rows)\r\n np_colour = in_colour_band.ReadAsArray(0, 0, in_cols, in_rows)\r\n\r\n # Conve... | [
"0.71685034",
"0.71119153",
"0.6962683",
"0.6600374",
"0.6548575",
"0.648904",
"0.63722575",
"0.63132954",
"0.61180866",
"0.6112589",
"0.6094235",
"0.6086239",
"0.59720784",
"0.5760393",
"0.5739196",
"0.5679314",
"0.5637874",
"0.561567",
"0.55735964",
"0.55613995",
"0.5546381... | 0.7226453 | 0 |
Get the patients that are currently in the Intensive Care. | def get_patients_in_ic(self):
query = "SELECT * FROM patients WHERE datetime_discharge IS NULL"
return self.mysql_obj.fetch_rows(query) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_patients(self):\n return",
"def get_all_incidents():\n allIncidents = Incident.get_all()\n #allCops = get_all_cops()\n incidents = []\n for i in allIncidents:\n if(\n (i['operations_center']['id'] in allCops) and\n (inicioAmostragem <= i.reporting_date and ... | [
"0.6540609",
"0.6131111",
"0.6062366",
"0.59744585",
"0.59557164",
"0.5854854",
"0.58444697",
"0.5811601",
"0.58045304",
"0.57877827",
"0.56264734",
"0.555936",
"0.55263805",
"0.551021",
"0.550255",
"0.55022293",
"0.5453711",
"0.5433522",
"0.5396434",
"0.53827906",
"0.5377944... | 0.6811366 | 0 |
Get all signal values for patient. | def get_signal_values_for_patient(self, patient_id):
query = \
"""
SELECT s.name, psv.value, psv.time
FROM patient_signal_values psv
INNER JOIN signals s
ON psv.signal_id = s.id
WHERE patient_id = %(patient_id)s
"""
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_raw_signals(self):\n signals, fields = wfdb.rdsamp(self.patient_number, pb_dir='mitdb', warn_empty=True)\n logging.info(\"Patient {} additional info: {}\".format(self.patient_number, fields))\n return signals, fields",
"def return_values(self):\r\n\r\n values = list(self.piDD.... | [
"0.6766118",
"0.6505692",
"0.6368694",
"0.63396835",
"0.60953635",
"0.60298645",
"0.58378303",
"0.58372927",
"0.58189297",
"0.57914597",
"0.57846195",
"0.5775973",
"0.5775973",
"0.577389",
"0.57266253",
"0.57230437",
"0.5665654",
"0.5658327",
"0.5649866",
"0.5648695",
"0.5645... | 0.77991635 | 0 |
computes diag(v1) dot M dot diag(v2). returns np.ndarray with same dimensions as M | def v1Mv2(v1, M, v2):
return v1[:, None] * M * v2[None, :] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vec_dot(v1,v2):\r\n \r\n return np.dot(v1,v2)",
"def diag(v, k=0):\n\n if not use_origin_backend(v):\n if not isinstance(v, dparray):\n pass\n else:\n return dpnp_diag(v, k)\n\n return call_origin(numpy.diag, v, k)",
"def vdot(a, b):\n return np.vdot(a.rav... | [
"0.6502854",
"0.6264067",
"0.6235242",
"0.6111132",
"0.60820174",
"0.6053548",
"0.6019043",
"0.60024",
"0.59885395",
"0.59714615",
"0.5968381",
"0.596071",
"0.5959117",
"0.59306157",
"0.5902412",
"0.5900423",
"0.58945966",
"0.58917797",
"0.58533454",
"0.58418703",
"0.58413756... | 0.64991665 | 1 |
Return windows of indices into the flattened data. data[index_matrix[i]] returns the flattened window around the ith element. | def create_index_matrix(data_shape, window_shape):
n_data = np.prod(data_shape)
n_window = np.prod(window_shape)
box = np.indices(window_shape)
index_matrix = np.zeros((n_data, n_window), dtype=np.int32)
shifts = np.unravel_index(np.arange(n_data), data_shape)
offset = (np.array(window_shape)-1)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_flatten_indices(actual_index, num_samples, skip_coef=1, window_size=5):\n n_pre_zeros = 0\n window_indices = []\n n_post_zeros = 0\n for i in range(window_size * 2 + 1):\n if (actual_index - window_size*skip_coef) + i*skip_coef >= 0 and (actual_index - window_size*ski... | [
"0.6340699",
"0.5813027",
"0.5748229",
"0.56743836",
"0.55570626",
"0.55411845",
"0.5432381",
"0.5309236",
"0.5209544",
"0.52076346",
"0.52067953",
"0.52067953",
"0.51609695",
"0.51609695",
"0.5154295",
"0.5130914",
"0.5128103",
"0.50972",
"0.5071069",
"0.49966234",
"0.499414... | 0.6024071 | 1 |
Decorate tensorflow op graph building function with name_scope. Name defaults to function name. | def scope_op(name=None):
def decorator(function):
@functools.wraps(function)
def wrapper(*args, **kwargs):
with tf.name_scope(name or function.__name__):
return function(*args, **kwargs)
return wrapper
return decorator | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def function_name_scope(function):\n @wraps(function)\n def wrapper(*args, **kwargs):\n with tf.name_scope(function.__name__):\n return function(*args, **kwargs)\n return wrapper",
"def build(self, **kwargs):\n if not self.built:\n with tf.name_scope(self.name):\n ... | [
"0.6776843",
"0.6052667",
"0.6024638",
"0.6017519",
"0.5850662",
"0.582437",
"0.578642",
"0.57745945",
"0.5770974",
"0.57384944",
"0.57371694",
"0.57050693",
"0.56976104",
"0.5680395",
"0.5660873",
"0.56570977",
"0.5645926",
"0.56300974",
"0.55482644",
"0.55344635",
"0.551495... | 0.78752005 | 0 |
Gather windows of tensor around centers. Uses wrapped padding. | def gather_windows(x, centers, system_shape, window_shape):
window_size = np.prod(window_shape)
batch_size = tf.shape(x)[0]
index_matrix = tf.constant(create_index_matrix(system_shape, window_shape))
window_range = tf.range(batch_size, dtype=tf.int32)[:, None] * \
tf.ones(window_size, dtype=tf.i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_windows(x, centers, updates, mask, system_shape, window_shape):\n window_size = np.prod(window_shape)\n batch_size = tf.shape(x)[0]\n index_matrix = tf.constant(create_index_matrix(system_shape, window_shape))\n window_range = tf.range(batch_size, dtype=tf.int32)[:, None] * \\\n tf.on... | [
"0.62628543",
"0.6066326",
"0.58352035",
"0.56969947",
"0.5685777",
"0.5637248",
"0.55407983",
"0.553049",
"0.54852927",
"0.54782593",
"0.5473007",
"0.5462575",
"0.5458505",
"0.5457785",
"0.5445776",
"0.5361355",
"0.5351152",
"0.5341841",
"0.53008586",
"0.5300423",
"0.5274436... | 0.670488 | 0 |
Update windows around centers with updates at rows where mask is True. | def update_windows(x, centers, updates, mask, system_shape, window_shape):
window_size = np.prod(window_shape)
batch_size = tf.shape(x)[0]
index_matrix = tf.constant(create_index_matrix(system_shape, window_shape))
window_range = tf.range(batch_size, dtype=tf.int32)[:, None] * \
tf.ones(window_s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_mask(self, indices):\n\n indices = indices.view(self.batch_size, -1)\n updated_mask = torch.zeros_like(self.mask.squeeze(-1)).scatter_(1, indices, 1)\n\n return updated_mask.unsqueeze(-1)",
"def _modify_updates(self, updates):\n wxf = self.wxf\n wyf = self.wyf\n ... | [
"0.65512353",
"0.63234437",
"0.62542087",
"0.6015804",
"0.5854032",
"0.5760298",
"0.5750986",
"0.57493496",
"0.56922036",
"0.56810457",
"0.5634808",
"0.5616217",
"0.5529044",
"0.5510181",
"0.5471018",
"0.5466577",
"0.5422766",
"0.54003185",
"0.53856635",
"0.5350144",
"0.53002... | 0.7305941 | 0 |
Gather all windows of tensor. | def all_windows(x, system_shape, window_shape):
index_matrix = tf.constant(create_index_matrix(system_shape, window_shape))
return tf.transpose(
tf.gather_nd(tf.transpose(x),
tf.expand_dims(index_matrix, 2)),
[2, 0, 1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gather_windows(x, centers, system_shape, window_shape):\n window_size = np.prod(window_shape)\n batch_size = tf.shape(x)[0]\n index_matrix = tf.constant(create_index_matrix(system_shape, window_shape))\n window_range = tf.range(batch_size, dtype=tf.int32)[:, None] * \\\n tf.ones(window_size,... | [
"0.67346734",
"0.61865276",
"0.6179608",
"0.60237753",
"0.59480226",
"0.5931195",
"0.5915982",
"0.58032703",
"0.5747572",
"0.5730282",
"0.57175064",
"0.5670163",
"0.5625128",
"0.5528307",
"0.5527471",
"0.5497974",
"0.54943347",
"0.5490933",
"0.54879826",
"0.5485261",
"0.54693... | 0.7017742 | 0 |
Initialize public and private key variables. | def __init__(self):
self.public_key = None
self._private_key = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self._keypair = RSA.generate(2048)\n self.public_key = self._keypair.publickey().exportKey()",
"def __init__(self):\n publicKeyFileName = \"serverPublicKey\"\n privateKeyFileName = \"serverPrivateKey.pem\"\n try:\n f = open(privateKeyFileName, '... | [
"0.78923047",
"0.7381298",
"0.736876",
"0.7335485",
"0.7318558",
"0.7158979",
"0.7150423",
"0.6961174",
"0.68982685",
"0.68939155",
"0.6887066",
"0.68617594",
"0.6817887",
"0.68071634",
"0.6774524",
"0.6687083",
"0.6653473",
"0.66499335",
"0.6604744",
"0.65936434",
"0.6576135... | 0.79213834 | 0 |
Encrypt 'message' with a public key and return its encryption as a list of integers. If no key is provided, use the 'public_key' attribute to encrypt the message. | def encrypt(self, message, key=None):
#Check validity of public key
if self.public_key is None:
raise Exception("invalid public key!")
elif pub_key is None:
e = self.public_key[0]
n = self.public_key[1]
else:
e = pub_key[0]
n ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encrypt(self, message, key=None):\n if key is None:\n key = self.public_key\n encrypter = RSA.importKey(key)\n return encrypter.encrypt(message, 2048)",
"def rsa_encrypt(message, publickey):\r\n \r\n # A key object is created to interact with the PyCrypto\r\n # encryption s... | [
"0.7807903",
"0.759414",
"0.7560335",
"0.7453449",
"0.7370985",
"0.70735997",
"0.7071769",
"0.7071769",
"0.7052295",
"0.68057853",
"0.67484885",
"0.6708029",
"0.66434103",
"0.664233",
"0.6539715",
"0.6480346",
"0.64450645",
"0.63244545",
"0.62741244",
"0.6272498",
"0.62405026... | 0.84980357 | 0 |
Decrypt 'message' with the private key and return its decryption as a single string. You may assume that the format of 'message' is the same as the output of the encrypt() function. | def decrypt(self, message):
#check validity of _private_key
if self._private_key is None:
raise Exception("invalid private key")
output = ""
d = self._private_key[0]
n = self._private_key[1]
for i in xrange(len(ciphertext)):
m = pow(ciphertext[i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decrypt(self, message):\n return self._keypair.decrypt(message)",
"def decrypt_message(self, message):\n\t\tf = Fernet(self.key)\n\t\treturn f.decrypt(message)",
"def decrypt_message(encrypted_message):",
"def decrypt_using_private_key(message):\n public_key_path = os.path.join('keys', 'pri... | [
"0.8332212",
"0.82969767",
"0.81545275",
"0.80835545",
"0.7953939",
"0.7846777",
"0.78017974",
"0.77947813",
"0.7641488",
"0.7457096",
"0.7444166",
"0.74372023",
"0.7364984",
"0.7335487",
"0.72907263",
"0.724854",
"0.71047544",
"0.70548815",
"0.7027532",
"0.6998797",
"0.69971... | 0.84557134 | 0 |
Use Fermat's test for primality to see if 'n' is probably prime. Run the test at most five times, using integers randomly chosen from [2, n1] as possible witnesses. If a witness number is found, return the number of tries it took to find the witness. If no witness number is found after five tries, return 0. | def is_prime(n, number_of_tests=5):
passes = 0
prime = True #assume prime
for i in xrange(number_of_tests):
passes += 1
random_int = random.randint(2, n-1)
test = pow(random_int, n-1, n)
if test != 1:
prime = False
break
if prime:
return 0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Ballie_PSW_test(n, max_trivial_trials=100):\n for i in range(max_trivial_trials):\n if primes[i] == n:\n return True\n if n % primes[i] == 0:\n return False\n if primes[i] ** 2 >= n:\n return True\n if not fermat_strong_test(n, 2):\n return Fal... | [
"0.65775406",
"0.6563441",
"0.64641523",
"0.6411732",
"0.6402925",
"0.6373394",
"0.63652146",
"0.62972295",
"0.62671983",
"0.62667334",
"0.626641",
"0.62386185",
"0.62371504",
"0.62341464",
"0.61839336",
"0.6167961",
"0.6142165",
"0.6119516",
"0.6093374",
"0.60730374",
"0.605... | 0.6907187 | 0 |
Initialize the _keypair and public_key attributes. | def __init__(self):
self._keypair = RSA.generate(2048)
self.public_key = self._keypair.publickey().exportKey() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.public_key = None\n self._private_key = None",
"def initialize(self):\n super(self.__class__, self).initialize()\n\n try:\n self.__keypair = nova_utils.get_keypair_by_name(\n self._nova, self.keypair_settings.name)\n retu... | [
"0.77278996",
"0.73476756",
"0.72197735",
"0.71278316",
"0.7043952",
"0.6906836",
"0.6847678",
"0.6793105",
"0.6780805",
"0.6697357",
"0.6651101",
"0.6648877",
"0.6648221",
"0.66463923",
"0.6603375",
"0.65970063",
"0.65599597",
"0.64603907",
"0.63687944",
"0.6349367",
"0.6348... | 0.75195104 | 1 |
Encrypt 'message' with a public key and return its encryption. If no key is provided, use the '_keypair' attribute to encrypt 'message'. | def encrypt(self, message, key=None):
if key is None:
key = self.public_key
encrypter = RSA.importKey(key)
return encrypter.encrypt(message, 2048) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encrypt(message, pub_key):\n\n if not isinstance(pub_key, key.PublicKey):\n raise TypeError(\"You must use the public key with encrypt\")\n\n return chopstring(message, pub_key.e, pub_key.n, encrypt_int)",
"def encrypt(self, message, key):\n return self.translateMessage(message, key, \"en... | [
"0.7848979",
"0.77931744",
"0.7753139",
"0.7636173",
"0.7587493",
"0.7331755",
"0.7327657",
"0.7158712",
"0.7151961",
"0.709577",
"0.709577",
"0.70698965",
"0.6942818",
"0.6929247",
"0.68518966",
"0.68266696",
"0.66923577",
"0.66752476",
"0.66741943",
"0.6659982",
"0.6638486"... | 0.81159896 | 0 |
Sends an XGRequest to the host and parses output into a XGResponse object. | def send_request(self, request, strip=None, retry=True):
data = request.to_xml()
if self.debug:
self.log('sending:\n{0}'.format(data))
try:
resp = self._handle.open(self.request_url, data)
resp_str = resp.read()
if self.debug:
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _xml_command(self, request):\n response = self._send(request)\n self._check_response(response)\n return response",
"def do_external_request(self, cmd, extra_payload):\r\n xmlstr = etree.tostring(self.xml, pretty_print=True)\r\n payload = {\r\n 'xml': xmlstr,\r\n ... | [
"0.6229007",
"0.57445365",
"0.5311812",
"0.53040063",
"0.5297168",
"0.52688396",
"0.5243111",
"0.52420366",
"0.5171214",
"0.51392835",
"0.51179385",
"0.5113762",
"0.5070183",
"0.50646555",
"0.5036037",
"0.5022937",
"0.50217754",
"0.50087965",
"0.5005785",
"0.49964833",
"0.497... | 0.57920414 | 1 |
Retrieve a "flat" list of XGNode objects based on node_names. If you wish to perform some iteration over a representational hierarchy, use get_node_tree() instead. This takes similar arguments to get_node_values() but returns all the node infomation received from the gateway in terms of XGNode objects. | def get_nodes(self, node_names, nostate=False, noconfig=False):
return self._get_nodes(node_names, nostate, noconfig, flat=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_nodes(self, names):\n nodes = []\n for name in names:\n node = self.get_node(name, prevent_error=True)\n if node == None:\n if verbose:\n print('Warning: could not find a TreeNode named {}.'.format(name))\n else:\n ... | [
"0.70559436",
"0.6798552",
"0.67908376",
"0.6708074",
"0.6707484",
"0.6662926",
"0.6562542",
"0.6462647",
"0.6462647",
"0.6373096",
"0.63702697",
"0.63507134",
"0.6265725",
"0.6254135",
"0.6243567",
"0.6224585",
"0.6222014",
"0.6214804",
"0.62056595",
"0.6203174",
"0.6191699"... | 0.69900393 | 1 |
Performs a 'set' using the nodes specified and returns the result. | def perform_set(self, nodes=[]):
# Input validation
try:
# Works for XGNodeDict input
set_nodes = nodes.get_updates()
except (AttributeError, TypeError):
# Assume list instead
set_nodes = nodes
if not isinstance(set_nodes, list):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_set(node):\n node.parent = node\n node.rank = 0",
"def visit_Set(self, node):\n self.generic_visit(node)\n return to_call(to_attribute(self.operator, '__set__'), node.elts)",
"def test_set_passed_as_iterable():\n tree = Tree([10, 5, 100])\n assert tree.root.value == 10\n a... | [
"0.69223654",
"0.6857986",
"0.657144",
"0.64777136",
"0.6360099",
"0.6342601",
"0.6235472",
"0.6176727",
"0.616161",
"0.6120538",
"0.5858361",
"0.58278024",
"0.58103836",
"0.58078146",
"0.5798671",
"0.574837",
"0.5694906",
"0.5672775",
"0.5651913",
"0.56457376",
"0.56296605",... | 0.76450825 | 0 |
Sets nodes per dict with node name > value mappings. | def set_nodes_values(self, node_dict):
# Requires nodes to have type defined in lookup array
raise Exception("Not yet implemented.") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_nodes(self, ndict):\n self.inode_ref = ndict[self.inode]\n self.jnode_ref = ndict[self.jnode]",
"def set_values(self, new_values):\n for name, value in new_values.items():\n self.nodes_db.loc[name][\"node\"].set_value(value)",
"def _init_nodes(self, nodes):\n attr... | [
"0.74113405",
"0.67245656",
"0.6602044",
"0.6529335",
"0.643137",
"0.61999345",
"0.6081437",
"0.6069941",
"0.6063902",
"0.6053018",
"0.6053018",
"0.6028629",
"0.6014309",
"0.5999404",
"0.5981748",
"0.597711",
"0.59712344",
"0.595847",
"0.59258413",
"0.589504",
"0.58826923",
... | 0.747575 | 0 |
returns relative frequency of a category, and words linked to categories | def getAll(text):
URIs = getURIs(text)
categories=getCategories(URIs[0], URIs[1] )
return categoryFrequency(categories[0]),categories[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def categoryFrequency(categoryList): #TODO delete units\n n=len(categoryList)\n freq = dict()\n for i in categoryList:\n if i in freq.keys():\n freq[i]=freq[i]+1/float(n)\n else:\n freq[i]=1/float(n)\n sortedFreq=sorted([(v,k) for (k,v) in freq.items()], reverse = ... | [
"0.66775525",
"0.64714974",
"0.6468304",
"0.6424987",
"0.6397465",
"0.63883096",
"0.6299494",
"0.62394077",
"0.6195926",
"0.6182201",
"0.6174687",
"0.6160413",
"0.6156063",
"0.6153839",
"0.612197",
"0.6117892",
"0.60976714",
"0.609022",
"0.6082632",
"0.6076902",
"0.6010695",
... | 0.70378643 | 0 |
Returns searcher with boosts applied | def apply_boosts(searcher):
return searcher.boost(
question_title=4.0,
question_content=3.0,
question_answer_content=3.0,
post_title=2.0,
post_content=1.0,
document_title=6.0,
document_content=1.0,
document_keywords=8.0,
document_summary=2.0,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_boost(self, search_boost):\n\n self._search_boost = search_boost",
"def search(self, query, maxhits=100):",
"def _add_better_search_words(self):\n for kw in self.better_search_kw:\n self.search_query += kw",
"def search(self, text, scope=None, limit=20):\n\t\tix = self.get... | [
"0.60998726",
"0.59151304",
"0.574534",
"0.57388705",
"0.56903166",
"0.5567034",
"0.55486757",
"0.55217326",
"0.54974544",
"0.54808474",
"0.5383242",
"0.53806686",
"0.5372127",
"0.5334215",
"0.5333432",
"0.53207475",
"0.53197944",
"0.5305514",
"0.5304185",
"0.5290752",
"0.528... | 0.7754596 | 0 |
Write given timeseries to Cloud Monitoring. | def write_time_series(host_project_id, series):
client = monitoring_v3.MetricServiceClient()
project_id = 'projects/%s' % host_project_id
try:
client.create_time_series(request={
'name': project_id,
'time_series': [series]
})
return True
except exceptions.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_time_series(temperature, time_series_collector, file_name):\n with open(\"./Results/\" + file_name + \"-T{:.4f}.csv\".format(temperature), 'w') as f:\n for i, line in enumerate(zip(*time_series_collector)):\n if i < len(time_series_collector[0]) - 1:\n f.write(\"%s\\n\... | [
"0.66388404",
"0.6581932",
"0.6308372",
"0.6216045",
"0.6097348",
"0.6085458",
"0.59469795",
"0.57111454",
"0.5689555",
"0.5682473",
"0.5670478",
"0.5664158",
"0.5662826",
"0.5619124",
"0.55925524",
"0.5572947",
"0.554315",
"0.5539387",
"0.55369955",
"0.5442291",
"0.54096097"... | 0.76035273 | 0 |
Extract timeseries data from MQL query response. | def _extract_mql_timeseries_data(response):
lkeys = response['timeSeriesDescriptor'].get('labelDescriptors', [])
# (fixme): Is there a better way to fetch and extract this data?
for result in response.get('timeSeriesData', []):
data = {}
lvalues = result.get('labelValues', [])
data =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_timeseries_mql(project_id, mql):\n project_name = _PROJECTS % project_id\n client = gcp.monitoring_service()\n # pylint:disable=no-member\n request = client.projects().timeSeries().query(name=project_name,\n body={'query': mql})\n # pylint:... | [
"0.6610051",
"0.627801",
"0.6274864",
"0.61707604",
"0.6128382",
"0.6069567",
"0.5944313",
"0.58993965",
"0.5889491",
"0.58621395",
"0.58621395",
"0.5862082",
"0.5802309",
"0.57957715",
"0.5789012",
"0.57394266",
"0.5738667",
"0.5714318",
"0.5689396",
"0.5662071",
"0.5643546"... | 0.84172064 | 0 |
Query timeseries for a project using mql. | def query_timeseries_mql(project_id, mql):
project_name = _PROJECTS % project_id
client = gcp.monitoring_service()
# pylint:disable=no-member
request = client.projects().timeSeries().query(name=project_name,
body={'query': mql})
# pylint:enable=no-m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self, query, project=\"odyssey-193217\"):\n\t\tfrom google.cloud import bigquery\n\t\tjob_config = bigquery.QueryJobConfig()\n\t\tclient = bigquery.Client(project=project)\n\t\tresult = client.query(query,job_config=job_config)\n\t\tjob_config.allowLargeResults = True\n\t\tresult.__done_timeout = 99999999\... | [
"0.65136653",
"0.63618124",
"0.62450224",
"0.62362874",
"0.6012494",
"0.59513414",
"0.5846183",
"0.55958813",
"0.55835605",
"0.5576945",
"0.55751055",
"0.55694366",
"0.55660886",
"0.55609494",
"0.55261236",
"0.54521173",
"0.54411834",
"0.54324687",
"0.5397769",
"0.53974396",
... | 0.802371 | 0 |
For an incoming transaction from a given origin, check if we have already responded to it. If so, return the response code and response body (as a dict). | def get_received_txn_response(self, transaction_id, origin):
return self.db.runInteraction(
"get_received_txn_response",
self._get_received_txn_response,
transaction_id,
origin,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_received_txn_response(self, transaction_id, origin, code, response_dict):\n\n return self.db.simple_insert(\n table=\"received_transactions\",\n values={\n \"transaction_id\": transaction_id,\n \"origin\": origin,\n \"response_code\"... | [
"0.603699",
"0.56335163",
"0.5395163",
"0.526941",
"0.5254303",
"0.52452505",
"0.52179694",
"0.5169635",
"0.5075448",
"0.504402",
"0.50247324",
"0.5017175",
"0.49992537",
"0.49695182",
"0.4865666",
"0.48077887",
"0.47865376",
"0.47796166",
"0.4770173",
"0.4770173",
"0.4770173... | 0.6981153 | 0 |
Persist the response we returened for an incoming transaction, and should return for subsequent transactions with the same transaction_id and origin. | def set_received_txn_response(self, transaction_id, origin, code, response_dict):
return self.db.simple_insert(
table="received_transactions",
values={
"transaction_id": transaction_id,
"origin": origin,
"response_code": code,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_response(self, request, response):\r\n if transaction.is_managed():\r\n if transaction.is_dirty():\r\n transaction.commit()\r\n transaction.leave_transaction_management()\r\n return response",
"def store_response(resp, response_dict):\n if respons... | [
"0.6364257",
"0.6238919",
"0.61123395",
"0.6015873",
"0.5987165",
"0.5851384",
"0.5706261",
"0.5692146",
"0.5657159",
"0.56424594",
"0.56416804",
"0.54970986",
"0.5437243",
"0.5410561",
"0.53601235",
"0.53576314",
"0.53576314",
"0.5333208",
"0.5309181",
"0.5278578",
"0.525649... | 0.6618684 | 0 |
Gets the current retry timings (if any) for a given destination. | def get_destination_retry_timings(self, destination):
result = self._destination_retry_cache.get(destination, SENTINEL)
if result is not SENTINEL:
return result
result = yield self.db.runInteraction(
"get_destination_retry_timings",
self._get_destination_ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_destination_retry_timings(\n self, destination, failure_ts, retry_last_ts, retry_interval\n ):\n\n self._destination_retry_cache.pop(destination, None)\n return self.db.runInteraction(\n \"set_destination_retry_timings\",\n self._set_destination_retry_timings,\... | [
"0.67022175",
"0.58530706",
"0.5591563",
"0.546668",
"0.5392975",
"0.52803975",
"0.52738106",
"0.5146915",
"0.51433176",
"0.5128729",
"0.5097669",
"0.50913644",
"0.5060083",
"0.5018542",
"0.5013286",
"0.49948463",
"0.49795264",
"0.49795264",
"0.49795264",
"0.4966824",
"0.4957... | 0.8384712 | 0 |
Sets the current retry timings for a given destination. Both timings should be zero if retrying is no longer occuring. | def set_destination_retry_timings(
self, destination, failure_ts, retry_last_ts, retry_interval
):
self._destination_retry_cache.pop(destination, None)
return self.db.runInteraction(
"set_destination_retry_timings",
self._set_destination_retry_timings,
de... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_destination_retry_timings(self, destination):\n\n result = self._destination_retry_cache.get(destination, SENTINEL)\n if result is not SENTINEL:\n return result\n\n result = yield self.db.runInteraction(\n \"get_destination_retry_timings\",\n self._get_... | [
"0.64224875",
"0.62720156",
"0.56372",
"0.555946",
"0.5518571",
"0.53955126",
"0.53396565",
"0.531217",
"0.52713865",
"0.52484846",
"0.5234268",
"0.5068851",
"0.50572044",
"0.5030623",
"0.50164175",
"0.49849373",
"0.49810487",
"0.48878133",
"0.4884664",
"0.48801792",
"0.48715... | 0.7926547 | 0 |
Returns the smallest string up to max_len characters accepted by this NFA greater than sequence. | def next_accepted(self, sequence: Sequence[Text], max_len: int) -> Optional[Text]:
max_hi = num_seqs_with_max_len(len(self.alphabet), max_len)
desired_num_accepted = self.num_accepts_ge(max_len, sequence) - self.accepts(sequence)
lo = seq_to_num(sequence, self.inverse_alphabet, max_len) + 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _model_string_maxlen():\n # hardcoded for convenience. Could be dynamically set in future.\n # the current longest is: BLOSUM62+I+G+X, i.e. 14 chars.\n # so we just over double it, for safety\n\n return 30",
"def filter_max_length(self, string):\n newstring = string\n length = len(n... | [
"0.68739814",
"0.670806",
"0.6582716",
"0.6533468",
"0.64901865",
"0.6415257",
"0.635727",
"0.6322649",
"0.6315081",
"0.62874407",
"0.62872374",
"0.6286444",
"0.6286076",
"0.62738734",
"0.6236837",
"0.62363255",
"0.61767066",
"0.61482036",
"0.61432",
"0.61285764",
"0.60883576... | 0.67607486 | 1 |
Returns the number of sequences accepted by this NFA. Return the number of sequences with length less than or equal to max_len that are lexicographically greater than or equal to bound. | def num_accepts(self, max_len: int, bound: Sequence[Text] = ()) -> Tuple[int, int, int]:
lt1: Dict[FrozenSet[int], int] = collections.defaultdict(int)
lt2: Dict[FrozenSet[int], int] = collections.defaultdict(int)
eq1: Dict[FrozenSet[int], int] = collections.defaultdict(int)
eq2: Dict[Fro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_accepts_ge(self, max_len: int, bound: Sequence[Text] = ()) -> int:\n _, num_accepted_eq, num_accepted_gt = self.num_accepts(max_len, bound)\n return num_accepted_eq + num_accepted_gt",
"def length_of_sequences(self):\n return self._seq_length",
"def max_sequence_length(self) -> int... | [
"0.7504999",
"0.65972674",
"0.6497466",
"0.6494008",
"0.6415731",
"0.63933873",
"0.6205498",
"0.6124807",
"0.59868175",
"0.5957853",
"0.5955138",
"0.5945578",
"0.59398663",
"0.59378064",
"0.5933087",
"0.59312755",
"0.59160244",
"0.59088737",
"0.59002274",
"0.5860422",
"0.5850... | 0.7307848 | 1 |
Returns the number of sequences >= bound with len() <= max_len accepted by this NFA. | def num_accepts_ge(self, max_len: int, bound: Sequence[Text] = ()) -> int:
_, num_accepted_eq, num_accepted_gt = self.num_accepts(max_len, bound)
return num_accepted_eq + num_accepted_gt | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_accepts(self, max_len: int, bound: Sequence[Text] = ()) -> Tuple[int, int, int]:\n lt1: Dict[FrozenSet[int], int] = collections.defaultdict(int)\n lt2: Dict[FrozenSet[int], int] = collections.defaultdict(int)\n eq1: Dict[FrozenSet[int], int] = collections.defaultdict(int)\n eq2:... | [
"0.71217704",
"0.6733206",
"0.67215616",
"0.66500634",
"0.6458716",
"0.64107955",
"0.6339628",
"0.63114727",
"0.6308476",
"0.6282204",
"0.6279598",
"0.62426364",
"0.62255585",
"0.6195235",
"0.6125995",
"0.6120646",
"0.6120646",
"0.61179775",
"0.6109793",
"0.6084972",
"0.60760... | 0.74793345 | 0 |
Returns a string representation of this NFA as a GraphViz .dot file. | def build_dot_str(self) -> Text:
s = []
s.append("digraph {")
for node in self.nodes:
label = str(node)
if node in self.start_nodes:
label += "S"
if node in self.accept_nodes:
label += "A"
s.append(f' "{node}" [labe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dump_graph(self) -> str:\n graph_dot_file = f'{self._name}.dot'\n graph_diagram_file = f'{self._name}.svg'\n write_dot(self._graph, graph_dot_file)\n subprocess.check_output(\n shlex.split(f'dot -Tsvg {graph_dot_file} -o {graph_diagram_file}')\n )\n return g... | [
"0.75486964",
"0.7548447",
"0.7353784",
"0.7292023",
"0.7183512",
"0.7085536",
"0.70306456",
"0.70009273",
"0.70009273",
"0.70002353",
"0.70002353",
"0.69679123",
"0.6958223",
"0.6934876",
"0.6925822",
"0.6865341",
"0.6827346",
"0.6814584",
"0.6760694",
"0.66928124",
"0.66715... | 0.7643195 | 0 |
Return a sequence that partitions the space of accepted strings. Returns a sequence, results, that is not necessarily accepted by nfa that partitions the space of all sequences lexicographically between lo and hi that nfa accepts of length max_len or less such target_ratio + tolerance_ratio of the sequences are lexicog... | def find_partition_seq(
nfa: NFA,
max_len: int,
target_ratio=fractions.Fraction(1, 2),
low: Iterable[Text] = (),
high: Optional[Iterable[Text]] = None,
tolerance_ratio: float = 0.0,
) -> Tuple[Text, ...]:
max_letter = max(nfa.alphabet)
lo: int = seq_to_num(low, nfa.inverse_alphabet, max... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_accepted(self, sequence: Sequence[Text], max_len: int) -> Optional[Text]:\n max_hi = num_seqs_with_max_len(len(self.alphabet), max_len)\n desired_num_accepted = self.num_accepts_ge(max_len, sequence) - self.accepts(sequence)\n lo = seq_to_num(sequence, self.inverse_alphabet, max_len) ... | [
"0.5758776",
"0.54950756",
"0.5426463",
"0.53324264",
"0.5252544",
"0.51077604",
"0.5059399",
"0.5043758",
"0.5004417",
"0.4975387",
"0.49677187",
"0.49565747",
"0.49563187",
"0.49299663",
"0.48925182",
"0.4888343",
"0.48725554",
"0.48663878",
"0.48532745",
"0.48340026",
"0.4... | 0.79418826 | 0 |
Create should fail with a StratisCliNameConflictError trying to create new pool with the same devices and the same name as previous. | def test_create_same_devices(self):
command_line = self._MENU + [self._POOLNAME] + self.devices
self.check_error(StratisCliNameConflictError, command_line, _ERROR) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_different_devices(self):\n command_line = self._MENU + [self._POOLNAME] + _DEVICE_STRATEGY()\n self.check_error(StratisCliNameConflictError, command_line, _ERROR)",
"def test_create_same_devices(self):\n command_line = self._MENU + [self._POOLNAME_2] + self._DEVICES\n ... | [
"0.6936273",
"0.668377",
"0.65317404",
"0.6379177",
"0.6103705",
"0.6079796",
"0.60304755",
"0.6021698",
"0.60045826",
"0.59128916",
"0.59012294",
"0.58715385",
"0.57743937",
"0.5755864",
"0.57389754",
"0.57138234",
"0.57114106",
"0.57097745",
"0.5707323",
"0.5629869",
"0.558... | 0.7493981 | 0 |
Create should fail with a StratisCliNameConflictError trying to create new pool with different devices and the same name as previous. | def test_create_different_devices(self):
command_line = self._MENU + [self._POOLNAME] + _DEVICE_STRATEGY()
self.check_error(StratisCliNameConflictError, command_line, _ERROR) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_same_devices(self):\n command_line = self._MENU + [self._POOLNAME] + self.devices\n self.check_error(StratisCliNameConflictError, command_line, _ERROR)",
"def test_create_same_devices(self):\n command_line = self._MENU + [self._POOLNAME_2] + self._DEVICES\n self.check_... | [
"0.7578934",
"0.6852764",
"0.6572364",
"0.649063",
"0.6186363",
"0.61459994",
"0.6054562",
"0.60405385",
"0.60289097",
"0.6028448",
"0.5937939",
"0.5918405",
"0.58632976",
"0.5842114",
"0.58106863",
"0.57899123",
"0.5784483",
"0.5784168",
"0.57270914",
"0.56444716",
"0.563977... | 0.71884704 | 1 |
Test that creating two pools with different names and the same devices raises a StratisCliInUseSameTierError exception. | def test_create_same_devices(self):
command_line = self._MENU + [self._POOLNAME_2] + self._DEVICES
self.check_error(StratisCliInUseSameTierError, command_line, _ERROR) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_same_devices(self):\n command_line = self._MENU + [self._POOLNAME] + self.devices\n self.check_error(StratisCliNameConflictError, command_line, _ERROR)",
"def test_create_different_devices(self):\n command_line = self._MENU + [self._POOLNAME] + _DEVICE_STRATEGY()\n sel... | [
"0.69769305",
"0.685628",
"0.6208406",
"0.6059924",
"0.60429776",
"0.5966177",
"0.59638995",
"0.59604377",
"0.5955759",
"0.5941339",
"0.59009176",
"0.5895814",
"0.5869945",
"0.58545804",
"0.58469856",
"0.5839096",
"0.582636",
"0.58109653",
"0.5797299",
"0.57923716",
"0.576472... | 0.78499734 | 0 |
Test that creating with tpm2 does something reasonable. | def test_create_tpm(self):
command_line = self._MENU + [self._POOLNAME] + self._DEVICES + ["--clevis=tpm2"]
TEST_RUNNER(command_line) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_system_entire(self):\n pass",
"def test_create_tang_1(self):\n command_line = (\n self._MENU\n + [self._POOLNAME]\n + self._DEVICES\n + [\"--clevis=tang\", \"--trust-url\", \"--tang-url=http\"]\n )\n TEST_RUNNER(command_line)... | [
"0.6962036",
"0.67384905",
"0.66820294",
"0.6649081",
"0.6562297",
"0.6489998",
"0.6451913",
"0.6450422",
"0.644342",
"0.6434589",
"0.64143276",
"0.63866884",
"0.6297511",
"0.6297511",
"0.6280332",
"0.6280332",
"0.6259234",
"0.6234679",
"0.61640173",
"0.61496794",
"0.6148087"... | 0.79857373 | 0 |
Tests whether an exception is raised when a mandatory attribute does not belong to the product model definition. | def test_missing_mandatory_attributes():
model_definition = {'source': {'type': 'list',
'required': True,
'persisted': True},
'resources.title': {'type': 'text',
'required': True... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _clean_standalone(self):\n if not self.title:\n raise ValidationError(_(\"Your product must have a title.\"))\n if not self.product_class:\n raise ValidationError(_(\"Your product must have a product class.\"))\n if self.parent_id:\n raise ValidationError(_... | [
"0.66832054",
"0.6592669",
"0.6539923",
"0.65391064",
"0.6538347",
"0.6508393",
"0.6435435",
"0.6404906",
"0.6383828",
"0.6370085",
"0.6338571",
"0.6333693",
"0.6308506",
"0.6305229",
"0.62869805",
"0.62426364",
"0.6228736",
"0.6196969",
"0.61729705",
"0.6161835",
"0.6150827"... | 0.69952655 | 0 |
Tests whether the factory successfully validates a model when a nonrequired attribute is missing from the product model. | def test_alright_when_non_required_field_is_missing():
model_definition = {'language': {'type': 'fixed',
'required': True,
'persisted': True},
'source': {'type': 'list',
'required': ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_missing_mandatory_attributes():\n model_definition = {'source': {'type': 'list',\n 'required': True,\n 'persisted': True},\n 'resources.title': {'type': 'text',\n 'requi... | [
"0.7707438",
"0.702368",
"0.7003859",
"0.68904054",
"0.6742272",
"0.6715958",
"0.6712021",
"0.668092",
"0.662",
"0.65714717",
"0.6567007",
"0.6544035",
"0.6535288",
"0.6520894",
"0.65018946",
"0.64207494",
"0.6395853",
"0.6385905",
"0.6313941",
"0.6300126",
"0.6299455",
"0.... | 0.76279354 | 1 |
Tests whether the factory successfully validates a model when a required attribute is missing from the product model, but a default value is given. | def test_alright_when_required_field_is_missing_but_default_is_given():
model_definition = {'language': {'type': 'fixed',
'required': True,
'persisted': True,
'default': 'portuguese'},
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_missing_mandatory_attributes():\n model_definition = {'source': {'type': 'list',\n 'required': True,\n 'persisted': True},\n 'resources.title': {'type': 'text',\n 'requi... | [
"0.7500169",
"0.74960834",
"0.7320718",
"0.6709409",
"0.64118165",
"0.6393792",
"0.63357896",
"0.63171214",
"0.62877655",
"0.62474984",
"0.62145287",
"0.6192724",
"0.61926067",
"0.61849076",
"0.6179737",
"0.61769146",
"0.6107873",
"0.61037236",
"0.60997593",
"0.6051574",
"0.6... | 0.7979957 | 0 |
Tests the calculation of the similarity of two products based on a 'numeric' attribute. | def test_similarity_numeric():
similarity = pm.compute_similarity_for_numeric(900, 800)
nose.tools.ok_(abs(similarity - 8/9) < tests.FLOAT_DELTA, "Wrong numeric similarity") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_similarity(self):\n self.assertTrue(np.allclose(self.vectors.similarity('dog.n.01', 'dog.n.01'), 1))\n self.assertTrue(np.allclose(self.vectors.similarity('dog.n.01', 'mammal.n.01'), 0.180901358))",
"def similarity(self, e1, e2):\n\t\tpass",
"def similarity_function_old(feature1, feature... | [
"0.67872584",
"0.67387223",
"0.65631735",
"0.63529235",
"0.63501847",
"0.6342312",
"0.6342312",
"0.63209295",
"0.623091",
"0.62212586",
"0.6199165",
"0.61860114",
"0.61807173",
"0.6159763",
"0.6153235",
"0.61523235",
"0.61315036",
"0.60996103",
"0.60927147",
"0.60767853",
"0.... | 0.72086656 | 0 |
Tests the calculation of the similarity of two products based on a 'date' attribute. | def test_similarity_date():
date1 = dt.datetime(2000, 11, 24, 10, 0)
date2 = dt.datetime(2000, 11, 26, 10, 0)
similarity = pm.compute_similarity_for_date(date1, date2, halflife=2)
nose.tools.ok_(abs(similarity - 0.5) < tests.FLOAT_DELTA, "Wrong date similarity") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def similarity(self, e1, e2):\n\t\tpass",
"def test_similarity(self):\n self.assertTrue(np.allclose(self.vectors.similarity('dog.n.01', 'dog.n.01'), 1))\n self.assertTrue(np.allclose(self.vectors.similarity('dog.n.01', 'mammal.n.01'), 0.180901358))",
"def compare_state_demand(\n a: pd.DataFram... | [
"0.6140461",
"0.58180696",
"0.5778696",
"0.57648724",
"0.56924784",
"0.56461555",
"0.559752",
"0.55854833",
"0.55672175",
"0.55280447",
"0.55000603",
"0.54928476",
"0.54652286",
"0.5449586",
"0.5445474",
"0.5440284",
"0.5421769",
"0.54209423",
"0.54195374",
"0.54045564",
"0.5... | 0.77693075 | 0 |
Tests the calculation of the similarity of two products based on a 'fixed' attribute. | def test_similarity_fixed():
similarity = pm.compute_similarity_for_fixed("Rio de Janeiro", "São Paulo")
nose.tools.eq_(similarity, 0, "Wrong fixed similarity")
similarity = pm.compute_similarity_for_fixed("Rio de Janeiro", "Rio de Janeiro")
nose.tools.eq_(similarity, 1, "Wrong fixed similarity") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_similarity(self):\n self.assertTrue(np.allclose(self.vectors.similarity('dog.n.01', 'dog.n.01'), 1))\n self.assertTrue(np.allclose(self.vectors.similarity('dog.n.01', 'mammal.n.01'), 0.180901358))",
"def similarity(pair: Tuple[Text, Text]) -> float:\n (a, b) = pair\n missing ... | [
"0.66236335",
"0.6590189",
"0.6483876",
"0.6461456",
"0.6403854",
"0.62277865",
"0.6196094",
"0.6050941",
"0.6039867",
"0.6006546",
"0.5983247",
"0.59342825",
"0.5914346",
"0.5914346",
"0.5882225",
"0.5880784",
"0.58777213",
"0.5872836",
"0.58536917",
"0.5853683",
"0.5847085"... | 0.6943262 | 0 |
Tests the calculation of the similarity of two products based on a 'list' attribute. | def test_similarity_list():
list1 = ["a", "b", "c"]
list2 = ["b", "c", "d", "e"]
similarity = pm.compute_similarity_for_list(list1, list2)
nose.tools.ok_(abs(similarity - 2/3) < tests.FLOAT_DELTA, "Wrong list similarity")
similarity = pm.compute_similarity_for_list(list2, list1) # intentionally as... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_similarity(self):\n self.assertTrue(np.allclose(self.vectors.similarity('dog.n.01', 'dog.n.01'), 1))\n self.assertTrue(np.allclose(self.vectors.similarity('dog.n.01', 'mammal.n.01'), 0.180901358))",
"def get_similar_products(list):\n #initialize cart with random ASIN\n params = {\"It... | [
"0.6316317",
"0.63050604",
"0.6177503",
"0.61020786",
"0.6076241",
"0.60168993",
"0.5944124",
"0.5928959",
"0.59269273",
"0.5791538",
"0.57839596",
"0.5783629",
"0.578113",
"0.57527703",
"0.5746568",
"0.5746568",
"0.5725273",
"0.57178694",
"0.57150406",
"0.56814325",
"0.56440... | 0.7762865 | 0 |
Tests conversion from a dict to a ProductModel instance. | def test_conversion_from_dict():
model_definition = {
'language': {'type': 'fixed', 'default': 'english'},
'a': {'type': 'fixed', 'persisted': True},
'b.c': {'type': 'fixed', 'persisted': True},
'b.d.e': {'type': 'text', 'persisted': True},
'b.d.f': {'type': 'numeric', 'persi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_from_dict(self):\n b1 = BaseModel()\n b1.name = \"Holberton\"\n b1.my_number = 89\n my_model_json = b1.to_dict()\n b2 = BaseModel(**my_model_json)\n self.assertEqual(b1.my_number, b2.my_number)\n self.assertEqual(b1.id, b2.id)\n self.assertEqu... | [
"0.6527579",
"0.64977103",
"0.62672186",
"0.610359",
"0.60274994",
"0.6020002",
"0.5937814",
"0.59310555",
"0.5926014",
"0.5909174",
"0.5909174",
"0.5909174",
"0.5909174",
"0.5909174",
"0.5909174",
"0.59031826",
"0.5890253",
"0.58854175",
"0.58797616",
"0.5858172",
"0.5854472... | 0.6796946 | 0 |
Return category details url | def category_details_url(id):
return reverse('category:category-detail', args=[id]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_absolute_url(self):\n return reverse('market:category-detail', args=[str(self.id)])",
"def get_absolute_url(self):\n return reverse('category-detail', args=[str(self.categoryId)])",
"def _get_url(self, category):\n query = []\n for key,value in self._params.iteritems():\n ... | [
"0.76737565",
"0.7562042",
"0.6749167",
"0.65350366",
"0.6471964",
"0.6314211",
"0.6271113",
"0.625414",
"0.6219947",
"0.62155586",
"0.6212428",
"0.6178922",
"0.61175007",
"0.6104493",
"0.60992265",
"0.60960597",
"0.60801506",
"0.6054124",
"0.6013464",
"0.5993353",
"0.5972542... | 0.8083309 | 0 |
Create and return a sample category | def sample_category(name='place'):
return Category.objects.create(name=name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_category():\n category = Category(name='testcategory', description=\"\", fee=DEFAULT_FEE)\n category.save()\n return category",
"def test_create_category(self):\n pass",
"def test_0005_create_categories(self):\n self.create_category(name='Test 0060 Workflow Features', descript... | [
"0.7426105",
"0.73442113",
"0.7260034",
"0.706049",
"0.68367004",
"0.68239397",
"0.6787772",
"0.67004144",
"0.6686712",
"0.6656232",
"0.6518061",
"0.64919376",
"0.6432085",
"0.6426642",
"0.64018744",
"0.63784826",
"0.63733375",
"0.6366401",
"0.63178706",
"0.63171357",
"0.6289... | 0.8123947 | 0 |
test viewing category details | def test_get_category_details(self):
category = sample_category()
url = category_details_url(category.id)
res = self.client.get(url)
serializer = CategorySerializer(category)
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertEqual(res.data, serializer.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_view_categories(self):\n res = self.client().post('/categories/', data=self.category)\n self.assertEqual(res.status_code, 201)\n res = self.client().get('/categories/')\n self.assertEqual(res.status_code, 200)\n self.assertIn('Stews', str(res.data))",
"def test_get_cat... | [
"0.7814517",
"0.75773275",
"0.75567085",
"0.7504459",
"0.7501404",
"0.7409347",
"0.7393505",
"0.7224864",
"0.7210572",
"0.72028196",
"0.7201158",
"0.71600854",
"0.7142944",
"0.7045864",
"0.69958264",
"0.695585",
"0.69526976",
"0.692939",
"0.6918037",
"0.6918037",
"0.6916416",... | 0.76808107 | 1 |
Test creating a category with invalid details | def test_create_category_with_invalid_details_fails(self):
res = self.client.post(CATEGORY_URL, {})
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(
res.data['errors']['name'][0],
'This field is required.') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_category(self):\n pass",
"def test_cannot_create_with_invalid_category(self):\n serializer = ServiceSerializer(\n data = dict(name = \"service1\", category = 10),\n context = dict(project = self.project)\n )\n self.assertFalse(serializer.is_valid(... | [
"0.82101303",
"0.8041852",
"0.791494",
"0.78192854",
"0.7700955",
"0.76209366",
"0.7575074",
"0.7443271",
"0.74368286",
"0.7422457",
"0.7414787",
"0.74138415",
"0.73887557",
"0.73368895",
"0.7318645",
"0.7282309",
"0.72419256",
"0.722112",
"0.71900594",
"0.71621287",
"0.71399... | 0.87169325 | 0 |
Test create category with existing same name fails | def test_create_category_with_existing_name(self):
sample_category()
res = self.client.post(CATEGORY_URL, {"name": "place"})
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(
res.data['errors']['name'][0],
'This field must be unique.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_category(self):\n pass",
"def test_add_same_category(self):\n response = self.client.post('/api/v1/categories',\n data=json.dumps(category[0]),\n content_type='application/json',\n ... | [
"0.86326134",
"0.81314254",
"0.79928046",
"0.785919",
"0.78289926",
"0.77278626",
"0.7714236",
"0.7689189",
"0.76465833",
"0.7560281",
"0.7554323",
"0.7551021",
"0.7518037",
"0.74838006",
"0.7428445",
"0.7390729",
"0.73875856",
"0.73158264",
"0.7306888",
"0.72817504",
"0.7277... | 0.83984613 | 1 |
Test updating a category to existing name fails | def test_update_category_to_existing_name(self):
sample_category()
category = sample_category(name='House')
url = category_details_url(category.id)
res = self.client.put(url, {"name": "place"})
category.refresh_from_db()
self.assertEqual(res.status_code, status.HTTP_400_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_category(self):\n pass",
"def test_update(self, init_db, category):\n category_name = fake.alphanumeric()\n category.update(name=category_name)\n assert category.name == category_name",
"def test_update_category(self):\n category = sample_category()\n u... | [
"0.8705725",
"0.86055994",
"0.8067761",
"0.79751843",
"0.7777514",
"0.7758227",
"0.7564963",
"0.7562341",
"0.7552205",
"0.7283096",
"0.72652644",
"0.72646534",
"0.7263289",
"0.72263676",
"0.7210747",
"0.7179932",
"0.7075194",
"0.7023446",
"0.7023264",
"0.69821405",
"0.6903937... | 0.86579794 | 1 |
Extract the images into a numpy array. | def _extract_images(image_paths):
num_images = len(image_paths)
data = np.zeros((num_images, _IMAGE_SIZE, _IMAGE_SIZE, _NUM_CHANNELS))
for i in range(num_images):
image_path = image_paths[i]
print('Extracting images from: ', image_path)
image = imageio.imread(image_path)
dat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _extract_images(self, filename):\n log.info('Extracting', filename)\n with gzip.open(filename) as bytestream:\n magic = self._read32(bytestream)\n if magic != 2051:\n raise ValueError(\n 'Invalid magic number %d in MNIST image file: %s' %\n ... | [
"0.72095007",
"0.7152573",
"0.70705694",
"0.7013361",
"0.6969041",
"0.6916433",
"0.68338263",
"0.683087",
"0.67723185",
"0.67375094",
"0.67287177",
"0.67180645",
"0.67137927",
"0.6679731",
"0.6623957",
"0.6600087",
"0.658568",
"0.6582823",
"0.6553165",
"0.65411156",
"0.653439... | 0.77781427 | 0 |
Aggregate metric value across towers. | def _aggregate_across_towers(metrics_collections, metric_value_fn, *args):
def fn(distribution, *a):
"""Call `metric_value_fn` in the correct control flow context."""
if hasattr(distribution, '_outer_control_flow_context'):
# If there was an outer context captured before this method was called,
# ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _aggregate_across_towers(metrics_collections, metric_value_fn, *args):\n def fn(distribution, *a):\n \"\"\"Call `metric_value_fn` in the correct control flow context.\"\"\"\n if hasattr(distribution, '_outer_control_flow_context'):\n # If there was an outer context captured before t... | [
"0.6526208",
"0.61006385",
"0.60297525",
"0.59245074",
"0.584058",
"0.5800489",
"0.56997293",
"0.56921005",
"0.56350535",
"0.5630873",
"0.56030244",
"0.5590685",
"0.5583606",
"0.55782723",
"0.5570165",
"0.5558878",
"0.55482966",
"0.5541951",
"0.5541951",
"0.55373263",
"0.5535... | 0.6474678 | 1 |
Call `metric_value_fn` in the correct control flow context. | def fn(distribution, *a):
if hasattr(distribution, '_outer_control_flow_context'):
# If there was an outer context captured before this method was called,
# then we enter that context to create the metric value op. If the
# caputred context is `None`, ops.control_dependencies(None) gives the
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fn(distribution, *a):\n if hasattr(distribution, '_outer_control_flow_context'):\n # If there was an outer context captured before this method was called,\n # then we enter that context to create the metric value op. If the\n # caputred context is `None`, ops.control_dep... | [
"0.6583132",
"0.58839256",
"0.5767293",
"0.574908",
"0.55788815",
"0.5566902",
"0.548517",
"0.5422161",
"0.537603",
"0.5365945",
"0.52946395",
"0.52842236",
"0.51841676",
"0.5158378",
"0.515165",
"0.51359975",
"0.51274526",
"0.5114945",
"0.5100913",
"0.50856",
"0.5031937",
... | 0.6464017 | 1 |
Initializes to count the number of null lists in a specific feature path. When required_paths is also passed, rows which are null for all of the required paths will not be counted as missing. | def __init__(self,
path: types.FeaturePath,
required_paths: Optional[Iterable[types.FeaturePath]] = None):
self._path = path
if required_paths:
self._required_paths = tuple(sorted(required_paths))
else:
self._required_paths = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_null(self):\n null = 0\n for x in range(0, self.tot_col):\n for y in range(1, self.tot_rows + 1):\n if self.file_list[y][x].lower() == 'null':\n null += 1\n print('Total number of null fields: ' + str(null))\n results.append('Total n... | [
"0.57643074",
"0.5636303",
"0.56160426",
"0.5423167",
"0.53524774",
"0.5331745",
"0.5315419",
"0.5221362",
"0.5192976",
"0.5125796",
"0.5100069",
"0.5041495",
"0.5023727",
"0.49956",
"0.49956",
"0.49719247",
"0.49719247",
"0.49719247",
"0.49719247",
"0.49430317",
"0.4916951",... | 0.57114744 | 1 |
r""" Calculates the sum over all dimensions, except the first (batch dimension), and excluding the last n_dims. This function will ignore the first dimension and it will not aggregate over the last n_dims dimensions. | def sum_over_all_but_batch_and_last_n(
tensor: torch.Tensor, n_dims: int
) -> torch.Tensor:
if tensor.dim() == n_dims + 1:
return tensor
else:
dims = list(range(1, tensor.dim() - n_dims))
return tensor.sum(dim=dims) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_except_batch(x, num_dims=1):\n return x.reshape(*x.shape[:num_dims], -1).sum(-1)",
"def dim_zero_sum(x: Tensor) ->Tensor:\n return torch.sum(x, dim=0)",
"def sum(self, axis=None, keepdims=False):\n return F.Sum.apply(self, axis, keepdims)",
"def sum_to_0d(x):\n assert_equal(x.... | [
"0.7724387",
"0.63933766",
"0.623022",
"0.617324",
"0.6025804",
"0.59841615",
"0.5975488",
"0.59079736",
"0.58502185",
"0.58405554",
"0.5831169",
"0.5810228",
"0.5778869",
"0.5778869",
"0.5761769",
"0.57385844",
"0.57123697",
"0.57123697",
"0.56297374",
"0.561928",
"0.5616455... | 0.798387 | 0 |
Returns an ndb.Model entity that the urlsafe key points to. Checks that the type of entity returned is of the correct kind. Raises an error if the key String is malformed or the entity is of the incorrect kind | def get_by_urlsafe(urlsafe, model):
try:
key = ndb.Key(urlsafe=urlsafe)
except TypeError:
raise endpoints.BadRequestException('Invalid Key')
except Exception as e:
if e.__class__.__name__ == 'ProtocolBufferDecodeError':
raise endpoints.BadRequestException('Invalid Key')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _getEntityByWebsafeKey(websafeKey, kind):\n # Ensure that the websafe key is valid\n key = _raiseIfWebsafeKeyNotValid(websafeKey, kind)\n # Get the entity\n entity = key.get()\n if not entity:\n raise endpoints.NotFoundException(\n \"No '%s' entity found using websafe key: %s\"... | [
"0.73048353",
"0.65032816",
"0.64167804",
"0.6294501",
"0.62330955",
"0.5972219",
"0.59239554",
"0.5729749",
"0.5718736",
"0.5496142",
"0.54275656",
"0.54200107",
"0.5398956",
"0.5366968",
"0.53621364",
"0.5358711",
"0.5357161",
"0.53120214",
"0.53034353",
"0.53009325",
"0.52... | 0.8238842 | 0 |
Returns an Player (ndb.Model) entity for a given username and game. First verify username and game entity are valid, raises error if not. Then returns the Player entity for the given user in the game. Raises an error if a Player is not found. | def get_player_by_game(username, game):
# check to make sure User exists
if not check_user_exists(username):
raise endpoints.NotFoundException(
'{} does not exist!'.format(username))
# check to see if game is a valid Game entity
if not isinstance(game, Game):
raise endpoint... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_game(username):\n user = User.objects.get(username=username)\n if user.two_player_game_id != None:\n return TwoPlayerGame.objects.get(\n game_id=user.two_player_game_id), \"two\"\n if user.four_player_game_id != None:\n return FourPlayerGame.objects.get(\n game_... | [
"0.65232056",
"0.63248277",
"0.6170685",
"0.60794777",
"0.59741324",
"0.59616375",
"0.5943671",
"0.5908297",
"0.5905852",
"0.5870364",
"0.5857468",
"0.5836295",
"0.5746015",
"0.5728419",
"0.57253647",
"0.5602715",
"0.55801475",
"0.5562985",
"0.55489415",
"0.55399925",
"0.5517... | 0.8235693 | 0 |
if there are a start position, then add defaulttag item till that start position and add foundtag item form start with length n | def add_item(items, coder, tag, start, n):
if start is not None:
# close opened items
add_zero_item(items, coder, tag, start) # default tag
items[tag][coder].append(item(b=start, l=n-start, v=1)) # found tag | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extend_pos(self, start: int, end: int) -> None:",
"def __init__(self, start_index: int, tag: str):\n self.start_index = start_index\n self.limit = 10\n self.tag = tag.lower()",
"def handle_starttag(self, tag, attrs):\n if tag == \"a\":\n curr_tag = Tag(tag)\n ... | [
"0.57692724",
"0.57584",
"0.5506527",
"0.54777753",
"0.5397803",
"0.5319494",
"0.5314077",
"0.5247034",
"0.52080256",
"0.5207023",
"0.5185454",
"0.5167013",
"0.5088132",
"0.5079091",
"0.5039901",
"0.5026523",
"0.5013085",
"0.50089514",
"0.5003757",
"0.50031894",
"0.4975165",
... | 0.6109693 | 0 |
Create the sign evaluation message. | def to_msg(self):
return SignEvaluationMsg(
self.position.to_geometry_msg(), self.desc, *self.evaluate()
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign(self,msg,s):\n # $y_s = E_k^{-1} \\left( y_{s+1} \\oplus \\dots E_k^{-1} \\left( y_n \\oplus E_k^{-1} \\left(z\\right)\\right)\\dots\\right) \\oplus E_k \\left( y_{s-1} \\oplus \\dots E_k \\left( y_1 \\oplus v \\right)\\dots\\right)$\n self.permut(msg)\n x,y = [],[]\n for i in ... | [
"0.64031225",
"0.6378018",
"0.61032414",
"0.6040611",
"0.5963941",
"0.59369916",
"0.5801996",
"0.5800221",
"0.57777756",
"0.5704505",
"0.56650835",
"0.56564415",
"0.5642582",
"0.56367344",
"0.56246454",
"0.5612385",
"0.5597548",
"0.55866754",
"0.5567704",
"0.5535878",
"0.5520... | 0.73843765 | 0 |
Sum over the evaluations. | def sum_evaluations(evaluations):
def add_evaluations(e1, e2):
"""Add two evaluations.
If Signs do not have detections the distance is -1, therefore the distance needs
to be handled separately.
"""
true_positive = e1[0] + e2[0]
false_posi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum(self):\n return sum(self.values)",
"def evaluate(self, solution, total = 0):\n for objective in self.objectives:\n total = total + objective(solution)\n return total",
"def sum(self) -> float:\n return sum(self.values)",
"def evaluate(self,**d):\r\n\t\t\r\n\t\t#... | [
"0.6946212",
"0.68665934",
"0.6806886",
"0.6783867",
"0.676219",
"0.6713398",
"0.6688774",
"0.66768426",
"0.6672747",
"0.6663228",
"0.66507614",
"0.6645578",
"0.66443914",
"0.66443914",
"0.66300213",
"0.6587658",
"0.6506838",
"0.6465377",
"0.6465377",
"0.6465377",
"0.64633495... | 0.70826775 | 0 |
Add two evaluations. If Signs do not have detections the distance is 1, therefore the distance needs to be handled separately. | def add_evaluations(e1, e2):
true_positive = e1[0] + e2[0]
false_positive = e1[1] + e2[1]
distance = e1[2] + e2[2]
if e1[2] < 0 and e2[2] < 0:
distance = -1
elif e1[2] < 0:
distance = e2[2]
elif e2[2] < 0:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_evaluations(evaluations):\n\n def add_evaluations(e1, e2):\n \"\"\"Add two evaluations.\n\n If Signs do not have detections the distance is -1, therefore the distance needs\n to be handled separately.\n \"\"\"\n true_positive = e1[0] + e2[0]\n ... | [
"0.75192755",
"0.5600311",
"0.5589506",
"0.5509544",
"0.5471695",
"0.54424715",
"0.5433446",
"0.5314487",
"0.5303053",
"0.5303053",
"0.52639925",
"0.5242543",
"0.52394116",
"0.5227583",
"0.52234477",
"0.52131516",
"0.52124393",
"0.52061206",
"0.5189503",
"0.51505655",
"0.5142... | 0.7382814 | 1 |
Calculate the evaluation for the given ids. | def get_evaluations(self, ids):
evaluations = [(self.signs[i].evaluate(), self.signs[i].desc) for i in ids]
descriptions = list({self.signs[i].desc for i in ids})
evaluations_per_sign = [
([e for e, desc in evaluations if desc == description], description)
for description... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(self) -> Dict[str, Any]:\n kwargs = {\"ids\": self._ids}\n return {\n metric.value: self._metric_funcs[metric](\n self._targets, self._preds, **kwargs\n )\n for metric in self._metrics\n }",
"def compute(self, *args, **kwargs):\n ... | [
"0.6405527",
"0.626387",
"0.614188",
"0.60892797",
"0.5997984",
"0.59179175",
"0.58075917",
"0.5800151",
"0.5796685",
"0.57785195",
"0.5775786",
"0.5748048",
"0.5720896",
"0.5712271",
"0.5695938",
"0.567937",
"0.5655204",
"0.5627428",
"0.56098115",
"0.55980873",
"0.5597552",
... | 0.7392089 | 0 |
Create the plots from the detected signs. | def create_plots(self):
shutil.rmtree(self.param.path, ignore_errors=True)
os.makedirs(self.param.path)
ids = list(range(len(self.signs)))
"""True positives"""
values, kinds = self.get_evaluations(ids)
plots.create_plot(
kinds,
[e[0] for e in val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_asimov_significance_plots(self):\n import matplotlib.pyplot as plt\n plt.rcParams['text.usetex'] = True\n outdir = os.path.join(self.outdir, 'Significances')\n mkdir(outdir)\n maintitle = self.make_main_title(\n end='Asimov Analysis Significances',\n ... | [
"0.6569927",
"0.61876655",
"0.6008588",
"0.5985453",
"0.594897",
"0.5938306",
"0.5926033",
"0.590905",
"0.590554",
"0.59010196",
"0.5889001",
"0.58831525",
"0.58794993",
"0.5871761",
"0.58256704",
"0.5796685",
"0.57645845",
"0.57590383",
"0.57559466",
"0.5752957",
"0.57412344... | 0.72643757 | 0 |
Publish an RVIZ marker on the publisher's topic. | def _publish_point_marker(
self,
point: Point,
id: int,
ns="simulation/sign_evaluation",
):
rospy.logdebug(f"display point {point}")
marker = visualization.get_marker(
frame_id="sim_world",
rgba=[255, 0, 255, 255],
id=id,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def publish(self, message: str) -> None:",
"def on_publish( client, userdata, mid ):\n logging.info( \"Data published successfully.\" )",
"def on_publish(client, userdata, mid):\n print(\"Message Published.\")",
"def on_publish(mqttc, obj, mid):\n logger.debug(\"MQTT PUBLISH: mid: \" + str(mid))",
... | [
"0.6357063",
"0.62376064",
"0.6155916",
"0.61463344",
"0.6132296",
"0.61243963",
"0.6114466",
"0.6062014",
"0.6028903",
"0.58927435",
"0.58779794",
"0.5839856",
"0.5829416",
"0.5820119",
"0.58172786",
"0.58139145",
"0.57845473",
"0.57736254",
"0.57331103",
"0.57204676",
"0.56... | 0.6295984 | 1 |
Add the detection to the closest sign. | def add_detection(self, point: Point, desc: str):
closest_sign = Sign.closest(self.signs, point)
if closest_sign.position.distance(point) < self.param.distance_threshold:
closest_sign.detections.append((point, desc))
self.evaluation_publisher.publish(closest_sign.to_msg()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detect_traffic_sign(image, mask, THRESHOLD = 100):\n \n\n contours = findContour(mask)\n sign, coordinate = findLargestSign(image, contours, 0.55, 10) #0.55 10\n k = cv2.waitKey(1)\n if k == ord(' '): \n x = np.random.randint(0,100)\n y = np.random.randint(0,100)\n z = np.r... | [
"0.5513667",
"0.5390601",
"0.5299022",
"0.52472854",
"0.5236474",
"0.5220663",
"0.5186746",
"0.5184309",
"0.5168466",
"0.5166982",
"0.5121159",
"0.50838625",
"0.50461096",
"0.5044699",
"0.50344473",
"0.5026088",
"0.501678",
"0.501594",
"0.50108033",
"0.5007771",
"0.49960783",... | 0.60529 | 0 |
(DEPRECATED) Generate an HTML5 appcache. Should be run after wq optimize, as some of the manifest entries will be inferred from the build log. Note that browser vendors are deprecating support for Application Cache in favor of Service Workers. The `wq appcache` command will be removed in wq.app 2.0. Use the `wq service... | def appcache(config, version):
click.echo("Warning: Application Cache is deprecated by browser vendors.")
time.sleep(10)
if 'appcache' not in config:
raise click.UsageError(
"appcache section not found in %s" % config.filename
)
if 'optimize' not in config:
raise cl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def offline_command(args):\n\n list_local_files()\n\n if os.path.exists(MANIFEST_FILENAME) and not options.force:\n print \"%s already exists (use -f to overwrite).\" % MANIFEST_FILENAME\n\n if not os.path.exists(MANIFEST_FILENAME) or options.force:\n print \"Creating file %s.\" % MANIFEST_F... | [
"0.6182627",
"0.6134158",
"0.60425276",
"0.5894826",
"0.5606136",
"0.5565214",
"0.552516",
"0.5501652",
"0.54487354",
"0.538457",
"0.5367333",
"0.5328549",
"0.5269285",
"0.5257637",
"0.51493615",
"0.51167154",
"0.5082973",
"0.50464684",
"0.5039921",
"0.4998034",
"0.49817517",... | 0.7762304 | 0 |
Generate a dataframe containing the covariate X, and observations Y The X's are generated uniformly over each of the supplied segments. | def generate_data(func, points, seed=0):
np.random.seed(seed)
data = []
for segment in points:
x = np.linspace(*segment["xlim"], num=segment["n_points"])
distribution = func(x)
# Generate observations
y = distribution.rvs()
df = pd.DataFrame({"x": x, "y": y})
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_training_data_2D():\n c11 = np.random.uniform(0.05, 1.50, 100)\n c12 = np.random.uniform(-1.50, 1.50, 100)\n c21 = np.random.uniform(-1.50, -0.05, 100)\n c22 = np.random.uniform(-1.50, 1.50, 100)\n c1 = np.array([[i, j] for i, j in zip(c11, c12)])\n c2 = np.array([[i, j] for i, j in ... | [
"0.5358331",
"0.53441787",
"0.51789",
"0.5127328",
"0.5110928",
"0.5071385",
"0.5048293",
"0.50151145",
"0.50039065",
"0.49815464",
"0.49476844",
"0.4927507",
"0.49263746",
"0.4925004",
"0.49133477",
"0.49133477",
"0.49133477",
"0.49133477",
"0.48974207",
"0.48693144",
"0.486... | 0.6094589 | 0 |
Like scandir, but recursively. Will skip everything in the skip array, but only at the top level directory. Returns SEntry objects. If in_restricted is true, all returned entries will be marked as restricted even if their permissions are not restricted. | def recursedir(path='.', skip=[], alwaysskip=['.~tmp~'], in_restricted=False):
for dentry in scandir(path):
if dentry.name in skip:
continue
if dentry.name in alwaysskip:
continue
if dentry.name.startswith('.nfs'):
continue
# Skip things which are... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def walker(path: str, skip_on_eacces: bool) -> List[str]:\n entries = []\n\n # TODO: Would moving walker to a generator yield a performance increase, or lead to\n # higher disk contention due to the hasher running at the same time?\n try:\n with os.scandir(path) as scan:\n for h... | [
"0.58776116",
"0.54903525",
"0.51267457",
"0.51127154",
"0.49117744",
"0.49114066",
"0.48921844",
"0.48819953",
"0.48574495",
"0.48382702",
"0.48305023",
"0.48272744",
"0.47720328",
"0.47461796",
"0.46840212",
"0.46832395",
"0.46400335",
"0.46174994",
"0.460325",
"0.45985925",
... | 0.7487002 | 0 |
Split data into train and test set. Train set is split with stratify label ratio between label_ratio_low and label_ratio_high. | def split_stratify_train(data: pd.DataFrame, label_ratio_low: float, label_ratio_high: float, test_size=0.2):
while True:
X_train, X_test, y_train, y_test = train_test_split(data.drop(columns=['LABEL']), data['LABEL'],
test_size=test_size)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_split(data, labels, train_ratio=0.5, rand_seed=42):\n\n assert 0 <= train_ratio <= 1, \"Error: training set ratio must be between 0 and 1\"\n\n x_train, x_temp, y_train, y_temp = train_test_split(data,\n labels,\n ... | [
"0.8258039",
"0.7710548",
"0.7688627",
"0.75904655",
"0.75765723",
"0.7543811",
"0.75388366",
"0.7477704",
"0.7435805",
"0.7415709",
"0.7415688",
"0.74026334",
"0.7371344",
"0.7349963",
"0.73185074",
"0.7288917",
"0.72865677",
"0.7271239",
"0.7267007",
"0.7255961",
"0.7241415... | 0.8792884 | 0 |
Train XGBoost model using scikitlearn RandomizedSearchCV, and output report. Train set is split into train and validation set. The validation set is used for early stopping. | def xgb_scikit_random_train(train_X, train_Y, test_X, test_Y):
x_train, x_val, y_train, y_val = train_test_split(train_X, train_Y, test_size=0.1)
logger.info(f"Train set size: {len(x_train)}, validation set(for early stopping) size: {len(x_val)}")
objective = 'binary:logistic'
eval_metric = 'logloss'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_xgb(params, X_train, y_train, cv, scorer='neg_mean_squared_error', seed=42):\n\n n_estimators = int(params[\"n_estimators\"])\n max_depth= int(params[\"max_depth\"])\n\n try:\n model = xgb.XGBRegressor(n_estimators=n_estimators,\n max_depth=max_depth,\n ... | [
"0.7190715",
"0.7094397",
"0.70745474",
"0.6775865",
"0.6753152",
"0.66384083",
"0.65544754",
"0.65499026",
"0.6505415",
"0.649495",
"0.6494385",
"0.6487969",
"0.6479537",
"0.645025",
"0.6406553",
"0.6400581",
"0.63784343",
"0.63220215",
"0.63135535",
"0.62865824",
"0.6284737... | 0.7714557 | 0 |
Leverage IGDB's API to search for game information. | async def gamelookup(self, ctx, *, game_name = None):
if not game_name: return await ctx.send("Usage: `{}gamelookup [game_name]`".format(ctx.prefix))
if not self.access_token or time.time() >= self.expire_time:
if not await self._update_token():
return await ctx.send("I... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_games_from_database (self):\n r = requests.get (self.url_endpoint)\n if (r.status_code != 200):\n print (\"Failed to get games:\\n\", r.text)\n return r\n \n games = json.loads (r.text)['games']\n return_list = []\n for game in games:\n ... | [
"0.60661846",
"0.6001404",
"0.59874094",
"0.59113",
"0.59061587",
"0.5824826",
"0.577423",
"0.5772616",
"0.57339895",
"0.57207435",
"0.5694939",
"0.5686116",
"0.56730014",
"0.56721807",
"0.5669932",
"0.56376046",
"0.5632637",
"0.56092167",
"0.56059164",
"0.55752486",
"0.55350... | 0.7406503 | 0 |
Function Takes login as string Returns result of compliance validation as array of strings, void array means pass | def login_validation(login):
# Argument must be a string
if not isinstance(login, str):
raise TypeError("Argument must be a string")
result = []
# Check for length
if len(login) < 1 or len(login) > 20:
result.append("Login length must be between 1 and 20 symbols")
# Check if ha... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate(self) -> typing.List[str]:\n return jsii.invoke(self, \"validate\", [])",
"def valid_logins():\n login_data = json.load(open('data/login_data.json', 'r', encoding=\"utf8\"))\n return (random.choice(login_data['name']),\n random.choice(login_data['email']),\n rando... | [
"0.61099607",
"0.59491867",
"0.59310037",
"0.57885253",
"0.5766248",
"0.5730974",
"0.561032",
"0.5571905",
"0.5527034",
"0.55210996",
"0.54881525",
"0.5455377",
"0.5399907",
"0.536307",
"0.53402466",
"0.53250456",
"0.5280993",
"0.5265969",
"0.52527785",
"0.52511543",
"0.52349... | 0.66098934 | 0 |
Read and process data stored in input excel file then inject entry in DB | def importXlsxIntoDb(input):
#import global variable
global UPLOAD_ID
global PATIENT_NUM
global DATABASE
connection = db.create_connection(DATABASE)
xlsx = pd.read_excel(input)
#looping on each row
print(" - Importing data in DB", end = '')
for index, row in xlsx.iterrows():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Excel_Load_Data( self, ExcelFilename ):\n pass",
"def import_excel(self):\n self.ensure_one()\n if self.file_import:\n filecontent = base64.b64decode(self.file_import)\n try:\n # Todo: import excel\n input = cStringIO.StringIO()\n ... | [
"0.6571204",
"0.6529585",
"0.647885",
"0.63984954",
"0.638115",
"0.6332327",
"0.6286695",
"0.61833394",
"0.6131002",
"0.6119043",
"0.6111723",
"0.61092854",
"0.6051651",
"0.59979343",
"0.58864397",
"0.58640933",
"0.58146226",
"0.58035517",
"0.5800213",
"0.5788585",
"0.5772386... | 0.6835037 | 0 |
Read and process all pdf file situated in "./fichiers source/" then inject it in the document table | def pdfProcessing():
global DATABASE
conn = db.create_connection(DATABASE)
DOCUMENT_ORIGIN_CODE = "DOSSIER_PATIENT"
pathFolder = "fichiers source/"
extension = ".pdf"
pdfFileArrayPath = glob.glob(pathFolder + "*" + extension)
print(" - Processing pdf", end="")
for file in pdfFileArrayPa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n mip = parametros()\n mir = Reporte(CURRENT_PATH, mip.debug, mip.overwrite)\n pdfs = mir.obtener()\n if pdfs:\n print(\"Obteniendo nuevos pdf:\")\n for pdf in pdfs:\n print(f\"* {pdf}\")\n\n for file in glob.glob(f\"{CURRENT_PATH}/resources/pdf/*.pdf\"):\n ... | [
"0.65797544",
"0.65296715",
"0.6453306",
"0.6322549",
"0.6238333",
"0.6149662",
"0.60941696",
"0.60810435",
"0.6048382",
"0.5938034",
"0.59144366",
"0.5892034",
"0.58687395",
"0.58637136",
"0.58473825",
"0.57955265",
"0.57600033",
"0.57588214",
"0.56795657",
"0.56698626",
"0.... | 0.76072 | 0 |
Read and process all docx file situated in "./fichiers source/" then inject it in the document table | def docxProcessing():
DOCUMENT_ORIGIN_CODE = "RADIOLOGIE_SOFTWARE"
global DATABASE
conn = db.create_connection(DATABASE)
pathFolder = "fichiers source/"
extension = ".docx"
docxFileArrayPath = glob.glob(pathFolder + "*" + extension)
print(" - Processing docx", end="")
for file in docxFi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pdfProcessing():\n global DATABASE\n conn = db.create_connection(DATABASE)\n DOCUMENT_ORIGIN_CODE = \"DOSSIER_PATIENT\"\n\n pathFolder = \"fichiers source/\"\n extension = \".pdf\"\n pdfFileArrayPath = glob.glob(pathFolder + \"*\" + extension)\n print(\" - Processing pdf\", end=\"\")\n ... | [
"0.64515847",
"0.630049",
"0.627368",
"0.62275624",
"0.6038094",
"0.59903705",
"0.5970335",
"0.5945489",
"0.59367883",
"0.59338593",
"0.58784306",
"0.5854394",
"0.5817054",
"0.57945406",
"0.57783514",
"0.5768201",
"0.57398105",
"0.57188696",
"0.5715797",
"0.56921357",
"0.5682... | 0.73857903 | 0 |
Test filtering hits and miss datasets. | def test_filter_exists(self):
datasets = [{"exists": True, "name": "DATASET1"}, {"exists": False, "name": "DATASET2"}]
hits = filter_exists("HIT", datasets)
misses = filter_exists("MISS", datasets)
all = filter_exists("ALL", datasets)
nothing = filter_exists("NONE", datasets)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_fetch_filtered_dataset_call_misses(self):\n pool = asynctest.CoroutineMock()\n pool.acquire().__aenter__.return_value = Connection() # db_response is []\n assembly_id = 'GRCh38'\n position = (10, 20, None, None, None, None)\n chromosome = 1\n reference = 'A... | [
"0.6526705",
"0.63991475",
"0.6067365",
"0.60468185",
"0.5980538",
"0.59720397",
"0.59475845",
"0.589787",
"0.5843083",
"0.58304274",
"0.5800998",
"0.57543606",
"0.573433",
"0.57284266",
"0.5726334",
"0.5716319",
"0.5710886",
"0.57061344",
"0.57022065",
"0.56984323",
"0.56940... | 0.730566 | 0 |
Test transform DB record. | def test_transform_record(self):
response = {"frequency": 0.009112876, "info": {"accessType": "PUBLIC"},
"referenceBases": "CT", "alternateBases": "AT",
"start": 10, "end": 12,
"variantCount": 3, "variantType": "MNP"}
record = Record("PUBLIC", ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Transform(self, record):\n pass",
"def test_get_record(self):\n pass",
"def test_patch_record(self):\n pass",
"def test_create_record(self):\n pass",
"def test_update_record(self):\n pass",
"def test_transform_data(self):\n # assemble\n input_data = (\n ... | [
"0.7146753",
"0.65239096",
"0.6425714",
"0.6382288",
"0.63361186",
"0.63342535",
"0.6245365",
"0.6213984",
"0.6181023",
"0.61414087",
"0.6087115",
"0.6081557",
"0.59832424",
"0.59551847",
"0.5924976",
"0.5916013",
"0.5908581",
"0.5900851",
"0.59001505",
"0.5843761",
"0.582942... | 0.7696168 | 0 |
Test transform misses record. | def test_transform_misses(self):
response = {"referenceBases": '', "alternateBases": '', "variantType": "",
"frequency": 0, "callCount": 0, "sampleCount": 0, "variantCount": 0,
"start": 0, "end": 0, "info": {"accessType": "PUBLIC"}}
record = Record("PUBLIC")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_transforms_match(self, transform: Mapping) -> None:\n xform_id = transform.get(TraceKeys.ID, \"\")\n if xform_id == id(self):\n return\n # TraceKeys.NONE to skip the id check\n if xform_id == TraceKeys.NONE:\n return\n xform_name = transform.get(Tr... | [
"0.6604709",
"0.6437916",
"0.6375894",
"0.6232821",
"0.5919303",
"0.590823",
"0.58788997",
"0.58498996",
"0.58181363",
"0.57857037",
"0.57830256",
"0.57796776",
"0.57594526",
"0.5697106",
"0.56866306",
"0.5685778",
"0.56558555",
"0.5641226",
"0.56247234",
"0.5612856",
"0.5603... | 0.6836742 | 0 |
Test that add handover. | def test_add_handover(self):
# Test that the handover actually is added
handovers = [{"handover1": "info"}, {"handover2": "url"}]
record = {"datasetId": "test", "referenceName": "22", "referenceBases": "A",
"alternateBases": "C", "start": 10, "end": 11, "variantType": "SNP"}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_02_add_move(self):\n # Create/validate PO\n order = self.create_and_validate_po()\n\n # Add new move in picking\n picking = order.picking_ids[0]\n self.add_move(picking)\n\n # Try to validate picking\n self.assertEqual(picking.state, 'draft')\n with ... | [
"0.6259538",
"0.62197006",
"0.6193764",
"0.6161933",
"0.6152835",
"0.61155427",
"0.61128086",
"0.61108625",
"0.61099696",
"0.6078901",
"0.6065535",
"0.6053951",
"0.60404694",
"0.60404694",
"0.60404694",
"0.60404694",
"0.60404694",
"0.60337585",
"0.60318476",
"0.6021554",
"0.6... | 0.7491612 | 0 |
Test db call of getting public datasets access. | async def test_datasets_access_call_public(self):
pool = asynctest.CoroutineMock()
pool.acquire().__aenter__.return_value = Connection(accessData=[{'accesstype': 'PUBLIC', 'datasetid': 'mock:public:id'}])
result = await fetch_datasets_access(pool, None)
# for now it can return a tuple of... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dataset_for_personal_accounts(self):\n pass",
"async def test_datasets_access_call_multiple(self):\n pool = asynctest.CoroutineMock()\n pool.acquire().__aenter__.return_value = Connection(accessData=[{'accesstype': 'CONTROLLED', 'datasetid': 'mock:controlled:id'},\n ... | [
"0.69238675",
"0.69035935",
"0.67359",
"0.6674255",
"0.66601235",
"0.6349921",
"0.6299647",
"0.62559557",
"0.6216987",
"0.61688465",
"0.60637873",
"0.59757394",
"0.59607965",
"0.5922106",
"0.5850786",
"0.58391786",
"0.5838317",
"0.58256304",
"0.5823583",
"0.58134",
"0.5811772... | 0.79184955 | 0 |
Test db call of getting registered datasets access. | async def test_datasets_access_call_registered(self):
pool = asynctest.CoroutineMock()
pool.acquire().__aenter__.return_value = Connection(accessData=[{'accesstype': 'REGISTERED', 'datasetid': 'mock:registered:id'}])
result = await fetch_datasets_access(pool, None)
# for now it can retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_finding_datasets_doesnt_query_database_excessively(\n access_type, client, django_assert_num_queries\n):\n expected_num_queries = 13\n source_tags = [factories.SourceTagFactory() for _ in range(10)]\n topic_tags = [factories.TopicTagFactory() for _ in range(10)]\n\n masters = [\n fac... | [
"0.692886",
"0.66641706",
"0.6565195",
"0.65563977",
"0.65087014",
"0.6503476",
"0.6399934",
"0.6390301",
"0.63635707",
"0.63535875",
"0.63359255",
"0.6288772",
"0.6233373",
"0.6157593",
"0.6155992",
"0.61443067",
"0.6102189",
"0.6071379",
"0.6071379",
"0.60491437",
"0.604104... | 0.7375869 | 0 |
Test db call of getting controlled datasets access. | async def test_datasets_access_call_controlled(self):
pool = asynctest.CoroutineMock()
pool.acquire().__aenter__.return_value = Connection(accessData=[{'accesstype': 'CONTROLLED', 'datasetid': 'mock:controlled:id'}])
result = await fetch_datasets_access(pool, None)
# for now it can retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_datasets_access_call_multiple(self):\n pool = asynctest.CoroutineMock()\n pool.acquire().__aenter__.return_value = Connection(accessData=[{'accesstype': 'CONTROLLED', 'datasetid': 'mock:controlled:id'},\n {'accessty... | [
"0.71085185",
"0.69189525",
"0.68948346",
"0.66749257",
"0.66024005",
"0.6447773",
"0.6408226",
"0.64078",
"0.63756603",
"0.63122475",
"0.61679447",
"0.6157619",
"0.60740554",
"0.6063692",
"0.6012641",
"0.59584606",
"0.5945216",
"0.59411925",
"0.5923041",
"0.59035486",
"0.588... | 0.7419891 | 0 |
Test db call of getting controlled and public datasets access. | async def test_datasets_access_call_multiple(self):
pool = asynctest.CoroutineMock()
pool.acquire().__aenter__.return_value = Connection(accessData=[{'accesstype': 'CONTROLLED', 'datasetid': 'mock:controlled:id'},
{'accesstype': 'PU... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_datasets_access_call_public(self):\n pool = asynctest.CoroutineMock()\n pool.acquire().__aenter__.return_value = Connection(accessData=[{'accesstype': 'PUBLIC', 'datasetid': 'mock:public:id'}])\n result = await fetch_datasets_access(pool, None)\n # for now it can return a... | [
"0.747451",
"0.71193075",
"0.683675",
"0.67620665",
"0.67434555",
"0.644622",
"0.6355829",
"0.6252154",
"0.624759",
"0.62461096",
"0.6196234",
"0.6161387",
"0.61113137",
"0.59870577",
"0.59677655",
"0.5960365",
"0.59477",
"0.59436566",
"0.59349966",
"0.59032625",
"0.58963615"... | 0.71368766 | 1 |
Test db call of getting datasets metadata. | async def test_fetch_dataset_metadata_call(self):
pool = asynctest.CoroutineMock()
pool.acquire().__aenter__.return_value = Connection()
result = await fetch_dataset_metadata(pool, None, None)
# for now it can return empty dataset
# in order to get a response we will have to mock... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dataset_details():\n with new_test_dataset(2) as test_ds:\n args = build_register_args(test_ds.copy_to_s3())\n ds_name = args['name']\n URLs.run(url_info=URLs.register_url(), json_body=args)\n\n ds_parts = URLs.run(url_info=URLs.dataset_parts_url(ds_name)).json\n asse... | [
"0.7350097",
"0.67755806",
"0.66323686",
"0.66123265",
"0.64851105",
"0.6451084",
"0.63992196",
"0.6393353",
"0.63796693",
"0.63779145",
"0.63269633",
"0.6278049",
"0.6246102",
"0.62334937",
"0.617247",
"0.61681867",
"0.61557543",
"0.61213416",
"0.61100024",
"0.61076134",
"0.... | 0.7253901 | 1 |
Test PostgreSQL wildcard handling. | def test_handle_wildcard(self):
sequence1 = 'ATCG'
sequence2 = 'ATNG'
sequence3 = 'NNCN'
self.assertEqual(handle_wildcard(sequence1), ['ATCG'])
self.assertEqual(handle_wildcard(sequence2), ["%AT_G%"])
self.assertEqual(handle_wildcard(sequence3), ["%__C_%"]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_match_any_wildcard_in_literal(self):\n qs = '\"Foo t*\"'\n qs_escaped, wildcard = wildcard_escape(qs)\n\n self.assertEqual(\n qs_escaped, r'\"Foo t\\*\"', \"Wildcard should be escaped\"\n )\n self.assertFalse(wildcard, \"Wildcard should not be detected\")\n ... | [
"0.7469122",
"0.738512",
"0.71618766",
"0.71604025",
"0.7111361",
"0.7002698",
"0.69867164",
"0.6560411",
"0.6547104",
"0.6484008",
"0.638041",
"0.630823",
"0.616465",
"0.6079208",
"0.59992486",
"0.599845",
"0.5911614",
"0.58510184",
"0.58022",
"0.57422745",
"0.5732638",
"0... | 0.74337596 | 1 |
Built the error Message from a key with specific params | def built_error_message(self, key: str, params: List[str]) -> str:
if key in self.errors:
error_msg = self.errors[key]
error_msg = re.sub("{..}", "", error_msg)
return error_msg.format(*params)
else:
return "" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_error(self, key: str, **kwargs) -> ValidationError:\n try:\n msg = self.error_messages[key]\n except KeyError as error:\n class_name = self.__class__.__name__\n message = (\n \"ValidationError raised by `{class_name}`, but error key `{key}` doe... | [
"0.6951925",
"0.672945",
"0.6627752",
"0.65712",
"0.6533963",
"0.64329624",
"0.6227141",
"0.6193963",
"0.6119053",
"0.6087474",
"0.60702777",
"0.6059164",
"0.60467255",
"0.5873384",
"0.58444184",
"0.58381826",
"0.5819411",
"0.5790388",
"0.5787507",
"0.5787152",
"0.57777953",
... | 0.86145705 | 0 |
Takes a dataframe and adds the 3top tags associated with the LDA model prediction over a corpus of interest. | def add_tags(df,lda,corpus,pmin):
vector =[]
for doc in corpus:
prediccion = lda[doc]
prediccion.sort(reverse= True,key=lambda x: x[1])
prediccion = (filtro_probs(prediccion,pmin))
vector.append(prediccion)
M1_glob = [item[0] for item in vector]
M1_final = [item[0] ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tag_pred(model, vectorized_input, feature_names, top_t, nb_tag_pred=10,\n threshold=0.15):\n\n # Topic df -----------------------------------------------------------------\n topic_df = display_topics2(model, feature_names)\n # associate each topic with a list of tags\n topics_kwords_df ... | [
"0.6544521",
"0.615879",
"0.6092302",
"0.5765394",
"0.56590444",
"0.5627526",
"0.5603541",
"0.55920047",
"0.5513635",
"0.54929227",
"0.54802614",
"0.5461552",
"0.54266167",
"0.54266167",
"0.53978384",
"0.5396371",
"0.53603154",
"0.5324885",
"0.5318619",
"0.5304675",
"0.527568... | 0.68351144 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.