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 |
|---|---|---|---|---|---|---|
Checks the parameters of the model. | def _check_params(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_params(self, model_params):\n return model_params",
"def check_model(self, model):\n self.check_initial_conditions(model)\n self.check_variables(model)",
"def check_params(self):\n raise NotImplementedError",
"def check_parameters(self):\n\n torch = import_optional_de... | [
"0.79449046",
"0.76387304",
"0.76336086",
"0.7370287",
"0.7346179",
"0.7316737",
"0.72343695",
"0.721575",
"0.7215679",
"0.7136357",
"0.70601606",
"0.7024453",
"0.6995145",
"0.6990375",
"0.6948801",
"0.6930947",
"0.6913361",
"0.68509775",
"0.6849342",
"0.68300027",
"0.6825713... | 0.8077029 | 0 |
Fits the model to the given data and returns the transformed views | def fit_transform(self, views: Iterable[np.ndarray], **kwargs):
return self.fit(views, **kwargs).transform(views, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform(self, data):",
"def transform(self, data):\n return self.fit_transform(data, fitting=False)",
"def fit_transform(self, data):\n self.fit(data)\n return self.transform(data)",
"def transform_view(self):\n translation = self.get_translation()\n scale = self.get_... | [
"0.62394875",
"0.6203981",
"0.59221715",
"0.5886225",
"0.58586085",
"0.56938434",
"0.5686222",
"0.5657344",
"0.5654032",
"0.56479377",
"0.56011564",
"0.55510306",
"0.5533196",
"0.5530481",
"0.55159473",
"0.5502196",
"0.55004406",
"0.5484076",
"0.54676896",
"0.54398584",
"0.54... | 0.63983095 | 0 |
Returns the pairwise correlations between the views in each dimension | def pairwise_correlations(self, views: Iterable[np.ndarray], **kwargs):
transformed_views = self.transform(views, **kwargs)
all_corrs = []
for x, y in itertools.product(transformed_views, repeat=2):
all_corrs.append(
np.diag(
np.corrcoef(x.T, y.T)[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def score(self, views: Iterable[np.ndarray], y=None, **kwargs):\n # by default return the average pairwise correlation in each dimension (for 2 views just the correlation)\n pair_corrs = self.pairwise_correlations(views, **kwargs)\n # sum all the pairwise correlations for each dimension. Subtr... | [
"0.687762",
"0.6277934",
"0.61075205",
"0.5992598",
"0.5980461",
"0.59673196",
"0.59582573",
"0.5945774",
"0.59225094",
"0.5834123",
"0.58247465",
"0.58193845",
"0.5773706",
"0.5744255",
"0.57327443",
"0.5723805",
"0.57147974",
"0.56864536",
"0.5668266",
"0.56554824",
"0.5597... | 0.8108276 | 0 |
Returns the average pairwise correlation between the views | def score(self, views: Iterable[np.ndarray], y=None, **kwargs):
# by default return the average pairwise correlation in each dimension (for 2 views just the correlation)
pair_corrs = self.pairwise_correlations(views, **kwargs)
# sum all the pairwise correlations for each dimension. Subtract the ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pairwise_correlations(self, views: Iterable[np.ndarray], **kwargs):\n transformed_views = self.transform(views, **kwargs)\n all_corrs = []\n for x, y in itertools.product(transformed_views, repeat=2):\n all_corrs.append(\n np.diag(\n np.corrcoef... | [
"0.6617222",
"0.6011778",
"0.58698756",
"0.58413374",
"0.5837436",
"0.57250744",
"0.5684932",
"0.56639445",
"0.55933666",
"0.55677044",
"0.5544848",
"0.55300516",
"0.5527696",
"0.5409334",
"0.53779644",
"0.536796",
"0.53631103",
"0.5339732",
"0.5338818",
"0.5334139",
"0.53221... | 0.7085823 | 0 |
Returns the factor loadings for each view | def factor_loadings(self, views: Iterable[np.ndarray], normalize=True, **kwargs):
transformed_views = self.transform(views, **kwargs)
if normalize:
loadings = [
np.corrcoef(view, transformed_view, rowvar=False)[
: view.shape[1], view.shape[1] :
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_factor_loadings(self):\n factor_loadings = pd.DataFrame(self.fa.loadings_)\n factor_loadings.set_index( self.df.columns, inplace=True)\n if self.verbose:\n print(f'Factor Loadings\\n{factor_loadings}')\n return factor_loadings",
"def get_loadings(self):\n ret... | [
"0.7569796",
"0.64155626",
"0.6262308",
"0.60139525",
"0.5724581",
"0.5591016",
"0.5565233",
"0.5539466",
"0.5533563",
"0.5400046",
"0.5298056",
"0.52517444",
"0.52228385",
"0.5194878",
"0.5146029",
"0.5134194",
"0.5119847",
"0.50797606",
"0.50706387",
"0.50684136",
"0.506425... | 0.69983065 | 1 |
This function read a csv file into MongoDB database The input csv file is stricted to only one field one element, can't process list, dictionary fields, can't read in int or float numbers. | def read_csv_file(dir_name, csv_file, collection, error_list):
count = 0
try:
filename = os.path.join(dir_name, csv_file)
with open(filename, 'r') as file:
csv_reader = csv.DictReader(file)
# create the document for products collection
for row in csv_reader:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_csv_to_mongodb(collection, csv_file_path):\n with open(csv_file_path) as csv_file:\n result = collection.insert_many(csv.DictReader(csv_file))\n return len(result.inserted_ids)",
"def loadCSV(input_file):",
"def ingest_rental_csv(csv_path):\n # Create a CSV import generator (next... | [
"0.7781327",
"0.6797164",
"0.67759633",
"0.6767162",
"0.6761368",
"0.6646175",
"0.6620393",
"0.6598354",
"0.65957636",
"0.6592284",
"0.6531607",
"0.64007837",
"0.63669914",
"0.62906754",
"0.6285865",
"0.62316895",
"0.6205388",
"0.6197284",
"0.61418647",
"0.61303824",
"0.61121... | 0.7105215 | 1 |
This function takes a directory name three csv files as input, one with product data, one with customer data and the third one with rentals data and creates and populates a new MongoDB database with these data. | def import_data(dir_name, product_file, customer_file, rentals_file):
client = MongoDBConnection()
with client:
LOGGER.info('Create A MongoDB database')
hp_norton_db = client.connection.rental
hp_norton_db.products.drop()
hp_norton_db.customers.drop()
hp_norton_db.rentals... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_data(directory_name, product_file, customer_file, rentals_file):\n with MongoDBConnection() as mongo:\n database = mongo.connection[DATABASE]\n\n product_error_count = 0\n try:\n product_collection = database[PRODUCT_COLLECTION]\n product_count = 0\n ... | [
"0.8205872",
"0.819157",
"0.7942803",
"0.7490987",
"0.7284789",
"0.703176",
"0.6705547",
"0.6495682",
"0.64772546",
"0.64501595",
"0.64154",
"0.63732433",
"0.6351757",
"0.62371415",
"0.6207875",
"0.61869067",
"0.6176881",
"0.60962427",
"0.5934948",
"0.58733636",
"0.5861458",
... | 0.83695525 | 0 |
Returns all courses in the given queryset, plus Sections, Periods, and SectionPeriod data. Optionally can have all related data to be filtered by semester year and month. Since this operation performs multiple selects and merges the resulting queries, the queryset is actively evaluated. | def full_select(self, year=None, month=None, amount=None):
from courses.models import SectionPeriod
sps = SectionPeriod.objects.by_courses(self, year, month).select_related(
'period', 'section', 'section__course__id'
)
# TODO: optimize into one loop
sid2sps = dict_by... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_courses(self) -> None:\n\n courses_content: NavigableString = self.soup.find(\"div\", \n {\"class\": \"coursesContent\"})\n course_items: ResultSet = courses_content.find_all(\"div\", \n {\"class\": \"courseItem\"})\n\n for item in course_items:\n cour... | [
"0.56945807",
"0.5608934",
"0.55728096",
"0.55554354",
"0.54784656",
"0.5406834",
"0.53803873",
"0.5341636",
"0.52954787",
"0.5284727",
"0.5273403",
"0.5241605",
"0.5236115",
"0.52102524",
"0.52040535",
"0.514425",
"0.5136502",
"0.5108133",
"0.51016325",
"0.50860673",
"0.5084... | 0.67250794 | 0 |
Calculates mode of a list | def mode(lst):
cnt = Counter(lst)
return cnt.most_common(1)[0][0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mode(lst):\n freq = {}\n for i in lst:\n if i in freq:\n freq[i] += 1\n else:\n freq[i] = 1\n\n return max(freq, key=lambda f: freq[f])",
"def get_mode(numlist):\n count = np.bincount(numlist)\n return np.argmax(count)",
"def find_mode(lst):\n\n num... | [
"0.7980381",
"0.78476495",
"0.7838688",
"0.76969916",
"0.7639157",
"0.74811214",
"0.74279225",
"0.7414053",
"0.7298286",
"0.7202574",
"0.7169501",
"0.7037024",
"0.6990023",
"0.69786406",
"0.69549483",
"0.69495195",
"0.6941531",
"0.69219345",
"0.68846333",
"0.68621325",
"0.669... | 0.7965854 | 1 |
Calculates accuracy for each slice and for each song | def calculate_acc(y_trues, y_preds):
slice_acc = accuracy_score(reduce(lambda x, v: x + v, y_trues.values(), []),
reduce(lambda x, v: x + v, y_preds.values(), []))
song_acc = accuracy_score(reduce(lambda x, v: x + [mode(v)], y_trues.values(), []),
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accuracy(self):",
"def compute_accuracy(self,pad_pred:torch.Tensor, pad_targets:torch.Tensor):\n pad_pred = pad_pred.argmax(2)\n mask = pad_targets != self.ignore_label\n numerator = torch.sum(\n pad_pred.masked_select(mask) == pad_targets.masked_select(mask)\n )\n ... | [
"0.7185807",
"0.66084236",
"0.6604089",
"0.654449",
"0.65258336",
"0.64952296",
"0.63675445",
"0.63352686",
"0.629656",
"0.6277787",
"0.6240571",
"0.62381846",
"0.6232816",
"0.621298",
"0.61832625",
"0.6182181",
"0.61794037",
"0.61783755",
"0.61783755",
"0.6164823",
"0.616038... | 0.713074 | 1 |
Patch resource so that it calls the callable pre before each put/get/request/release operation and the callable post after each operation. The only argument to these functions is the resource instance. | def patch_resource(resource, pre=None, post=None):
def get_wrapper(func):
# Generate a wrapper for put/get/request/release
@wraps(func)
def wrapper(*args, **kwargs):
# This is the actual wrapper
# Call "pre" callback
if pre:
pre(resource)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch(self, resource, data, target=None, verb='patch', **kwargs):\n return self._modify_resource(resource, data, target, verb, **kwargs)",
"def patch_resource(self, **kwargs):\n results = self.api.action.resource_patch(**kwargs)\n self.get_ckan_metadata(True)\n if 'upload' in kwar... | [
"0.6120927",
"0.6011239",
"0.58463246",
"0.5785852",
"0.5735555",
"0.5725382",
"0.5654193",
"0.56375927",
"0.55021036",
"0.5501393",
"0.54998237",
"0.545091",
"0.5426528",
"0.54240966",
"0.54201496",
"0.5418442",
"0.5393934",
"0.5386511",
"0.53829396",
"0.53645015",
"0.535814... | 0.8116243 | 0 |
get the remote url for the file | def remote_url(self) -> str:
return f"https://api.figma.com/v1/files/{self.file_id}" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_url(self):\n return self.get_file(uri_type=URI_URL, no_copy=True)",
"def get_url(self):\n try:\n return self._file.url\n except AttributeError:\n raise NotImplementedError(\"Underlying file does not have a URL.\")",
"def get_url(self):\r\n if self.mod.f... | [
"0.80667883",
"0.75128084",
"0.72968525",
"0.71413326",
"0.71055317",
"0.70775384",
"0.70324135",
"0.7018196",
"0.69482",
"0.692873",
"0.6885646",
"0.6881912",
"0.68533486",
"0.6806094",
"0.68018657",
"0.6789157",
"0.6785938",
"0.6762972",
"0.67446107",
"0.673748",
"0.6735034... | 0.79630995 | 1 |
has this content been downloaded | def downloaded(self) -> bool:
return not (self.data is None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_downloaded(self):\n for o in self.order_lst:\n for item in o.get_items():\n mdata = item.get_metadata()\n if 'downloaded' in mdata.keys():\n if str(mdata['downloaded']) == 'True':\n return True\n ... | [
"0.7533916",
"0.7452861",
"0.7362797",
"0.7071965",
"0.66356957",
"0.66356957",
"0.66356957",
"0.6528854",
"0.65264374",
"0.65214056",
"0.65142983",
"0.64201146",
"0.63998693",
"0.6376459",
"0.63735604",
"0.6372385",
"0.63491863",
"0.63163435",
"0.6280215",
"0.6258859",
"0.62... | 0.7665523 | 0 |
Compute the average of two rgb tuples. | def average(rgb1: Tuple[int, int, int], rgb2: Tuple[int, int, int]) \
-> Tuple[int, int, int]:
r = int((rgb1[0] + rgb2[0] + 0.5) / 2)
g = int((rgb1[1] + rgb2[1] + 0.5) / 2)
b = int((rgb1[2] + rgb2[2] + 0.5) / 2)
return r, g, b | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def return_average(rgb):\n value = sum(rgb[:3])//3 \n return (value, value, value)",
"def meanrgb(color1,color2):\r\n if check_colormath:\r\n srgb1 = sRGBColor(color1[0],color1[1],color1[2])\r\n srgb2 = sRGBColor(color2[0],color2[1],color2[2])\r\n\r\n lab1 = convert_color (srgb1,Lab... | [
"0.7532136",
"0.73949045",
"0.6777661",
"0.67640865",
"0.6677188",
"0.6501506",
"0.6441341",
"0.6394425",
"0.63594425",
"0.6321916",
"0.6256805",
"0.6251599",
"0.6191894",
"0.6155251",
"0.6155251",
"0.6098403",
"0.6091762",
"0.6080772",
"0.6058031",
"0.6053467",
"0.60022825",... | 0.9042956 | 0 |
Create the dictionary mapping (hue, value, chroma) to (r, g, b). | def create_color_dict() -> Dict[Tuple[str, int, int], Tuple[int, int, int]]:
file = 'real_sRGB.csv'
dictionary = dict()
hues = set()
with open(file, 'r') as f:
lines = f.read().splitlines()
for i in range(1, len(lines)):
_, hue, value, chroma, *_, r, g, b = lines[i].split(','... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assigning_colors():\n rgb_colors = {}\n for name, hex in matplotlib.colors.cnames.items():\n color = []\n # So the values are from 0-255 and not 0-1\n for i in matplotlib.colors.to_rgb(hex):\n color.append(int(i * 255))\n\n color = tuple(color)\n rgb_colors[n... | [
"0.6521122",
"0.6407489",
"0.6395887",
"0.6384011",
"0.6355249",
"0.6270379",
"0.6185299",
"0.61111516",
"0.6052305",
"0.6003623",
"0.5983676",
"0.59575754",
"0.59559864",
"0.5905832",
"0.59008056",
"0.5875743",
"0.58578753",
"0.5851728",
"0.5845633",
"0.58097744",
"0.5807728... | 0.7695673 | 0 |
Compute the Euclidean distance between two rgb tuples. | def distance(rgb1: Tuple[int, int, int], rgb2: Tuple[int, int, int]) -> float:
r = rgb1[0] - rgb2[0]
g = rgb1[1] - rgb2[1]
b = rgb1[2] - rgb2[2]
return math.sqrt(r**2 + g**2 + b**2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(rgb1, rgb2):\n diffs = np.array(rgb1) - np.array(rgb2)\n return math.sqrt(np.sum(diffs**2))",
"def color_distance(RGB1, RGB2):\n d2_r = (RGB1[0] - RGB2[0]) ** 2\n d2_g = (RGB1[1] - RGB2[1]) ** 2\n d2_b = (RGB1[2] - RGB2[2]) ** 2\n return d2_r + d2_g + d2_b",
"def color_dist(c1, c... | [
"0.8431144",
"0.7962131",
"0.7925061",
"0.78625214",
"0.78265333",
"0.76969683",
"0.7578853",
"0.73972464",
"0.7392219",
"0.73097533",
"0.72125167",
"0.7079692",
"0.70452595",
"0.702196",
"0.70077556",
"0.69635195",
"0.6938877",
"0.6878512",
"0.6867688",
"0.6861411",
"0.68155... | 0.8502466 | 0 |
Return the nearest munsell color for an RGB tuple. | def from_rgb(rgb: Tuple[int, int, int]) -> (str, int, int):
min_distance = 1e50
min_color = None
for munsell, rgb_ in munsell_to_rgb.items():
dist = distance(rgb, rgb_)
if dist < min_distance:
min_distance = dist
min_color = munsell
return min_color | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_nearest_color(color):\n\n result = color_re.match(color)\n if result is not None and len(result.groups()) == 5:\n color_red = int(result.groups()[1])\n color_green = int(result.groups()[2])\n color_blue = int(result.groups()[3])\n color_actual = np.array([color_red, color_... | [
"0.7289822",
"0.69045997",
"0.6538643",
"0.648513",
"0.64817286",
"0.64772224",
"0.6442071",
"0.64120704",
"0.6404169",
"0.63434416",
"0.6343069",
"0.630689",
"0.627451",
"0.6205028",
"0.6187722",
"0.61842436",
"0.6097063",
"0.6095762",
"0.60765326",
"0.60552156",
"0.60110575... | 0.8113078 | 0 |
Convert a Munsell (hue, value, chroma) color spec to RGB using linear interpolation | def to_rgb(hue: str, value: int, chroma: float) -> Tuple[int, int, int]:
if chroma == 0:
return gray_rgb_values[value]
else:
# Since our munsell_to_rgb map is indexed by integers but our chroma
# is is float, interpolate.
low_chroma = math.floor(chroma)
high_chroma = math... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __RGB_to_Hue(var_R, var_G, var_B, var_min, var_max):\r\n\r\n if var_max == var_min:\r\n return 0.0\r\n elif var_max == var_R:\r\n return (60.0 * ((var_G - var_B) / (var_max - var_min)) + 360) % 360.0\r\n elif var_max == var_G:\r\n return 60.0 * ((var_B - var_R) / (var_max - var_mi... | [
"0.7235526",
"0.6780768",
"0.6774304",
"0.67141855",
"0.66827714",
"0.66150177",
"0.6529307",
"0.64904106",
"0.6387493",
"0.63594687",
"0.6325428",
"0.6304786",
"0.6296314",
"0.62686557",
"0.6236277",
"0.6230893",
"0.6228938",
"0.6211711",
"0.6194424",
"0.61855125",
"0.617239... | 0.7151431 | 1 |
Refine bboxes by gradient of iou_score w.r.t the bboxes in one image | def refine_by_iou(self, x, bbox, score, label, img_idx, img_meta, cfg):
det_bboxes, det_scores, det_ious, det_labels = [], [], [], []
with torch.set_grad_enabled(True):
prev_bbox, prev_label, prev_score = bbox, label, score
prev_bbox.requires_grad_(True)
bbox_roi = to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postprocess_boxes(pred_bbox, original_image, train_input_size, score_threshold):\n \n # valid scle for box\n valid_scale=[0, np.inf]\n \n # turn bbox to array\n pred_bbox = np.array(pred_bbox)\n \n # obtain predicted x, y, w, h, objectiveness score, class probabilities\n pred_xywh = ... | [
"0.6099716",
"0.60361266",
"0.6031912",
"0.59667045",
"0.5872649",
"0.5812923",
"0.5801404",
"0.5769079",
"0.5747224",
"0.571826",
"0.56906986",
"0.5682612",
"0.5678004",
"0.56652546",
"0.56586134",
"0.5592956",
"0.55569994",
"0.5540416",
"0.5535932",
"0.5513554",
"0.54999566... | 0.74682355 | 0 |
Test that system with dynamics uses correct default dt | def test_change_default_dt(self, dt):
ct.set_defaults('control', default_dt=dt)
assert ct.ss(1, 0, 0, 1).dt == dt
assert ct.tf(1, [1, 1]).dt == dt
nlsys = ct.NonlinearIOSystem(
lambda t, x, u: u * x * x,
lambda t, x, u: x, inputs=1, outputs=1)
assert nlsys... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_change_default_dt_static(self):\n ct.set_defaults('control', default_dt=0)\n assert ct.tf(1, 1).dt is None\n assert ct.ss([], [], [], 1).dt is None",
"def dt(self, _):\n raise NotImplementedError(\n \"We do not support setting dt/ time step except during setup\")",... | [
"0.7408399",
"0.6956977",
"0.63730705",
"0.6249239",
"0.6185136",
"0.61222976",
"0.6076282",
"0.6044117",
"0.5992999",
"0.59589064",
"0.5919272",
"0.59182847",
"0.59081215",
"0.58835864",
"0.58748347",
"0.58709896",
"0.5840593",
"0.5833936",
"0.576698",
"0.5673184",
"0.567306... | 0.7455555 | 0 |
Test that static gain systems always have dt=None | def test_change_default_dt_static(self):
ct.set_defaults('control', default_dt=0)
assert ct.tf(1, 1).dt is None
assert ct.ss([], [], [], 1).dt is None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test1(self):\n sig1 = np.array([0, 1, 0])\n sig2 = np.array([0, 1, 0])\n d, p = EventSync.estimate_delay(sig1, sig2)\n self.assertTrue(d == 0)",
"def test3(self):\n sig1 = np.array([0, 1, 0])\n sig2 = np.array([0, 1, 0, 0])\n d, p = EventSync.estimate_delay(si... | [
"0.6476887",
"0.64258045",
"0.64170635",
"0.63524544",
"0.632837",
"0.63091904",
"0.6247306",
"0.62301874",
"0.62106705",
"0.6206436",
"0.61709315",
"0.61499965",
"0.61211413",
"0.61175793",
"0.60975224",
"0.60562986",
"0.6033655",
"0.5974612",
"0.5925494",
"0.5902325",
"0.58... | 0.66030085 | 0 |
Test _get_param last keyword | def test_get_param_last(self):
kwargs = {'first': 1, 'second': 2}
with pytest.raises(TypeError, match="unrecognized keyword.*second"):
assert ct.config._get_param(
'config', 'first', kwargs, pop=True, last=True) == 1
assert ct.config._get_param(
'config'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_param(param):\n return PREPEND_STR+param if keyword.iskeyword(param) else param",
"def getParameter(self, name):",
"def test_get_context_parameter(params, expected):\n assert get_context_parameter(params) == expected",
"def getParam(self,param):\n if param in self.params.keys():\n ... | [
"0.6965432",
"0.6631773",
"0.66310567",
"0.65644526",
"0.64257896",
"0.63952404",
"0.6324647",
"0.6259721",
"0.6256765",
"0.6185759",
"0.6098916",
"0.6082595",
"0.6070437",
"0.6039953",
"0.6018189",
"0.5988625",
"0.5983495",
"0.5982721",
"0.59760284",
"0.5974159",
"0.59688437... | 0.706146 | 0 |
Get dataset names in correct order as used in the validation framework ) reference dataset = ref ) first other dataset = k1 ) second other dataset = k2 This is important to correctly iterate through the HSAF metrics and to save each metric with the name of the used datasets | def get_dataset_names(ref_key, datasets):
ds_dict = {}
for ds in datasets.keys():
ds_dict[ds] = datasets[ds]['columns']
ds_names = get_result_names(ds_dict, ref_key, n=3)
dataset_names = []
for name in ds_names[0]:
dataset_names.append(name[0])
return dataset_names | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def datasets(self):\n return [Dataset.GWAS_CATALOG, Dataset.CLINVAR, Dataset.EFO]",
"def getDatasetName(sitemover, datasetDict, lfn, pdsname):\n # (dsname_report is the same as dsname but might contain _subNNN parts)\n\n # get the dataset name from the dictionary\n if datasetDict:\n try:\n ... | [
"0.56773084",
"0.5571152",
"0.5533781",
"0.54732907",
"0.5439962",
"0.5436593",
"0.5419731",
"0.5390552",
"0.5386441",
"0.5266213",
"0.5257855",
"0.525707",
"0.5255192",
"0.52550995",
"0.52497834",
"0.52319205",
"0.5218447",
"0.5205827",
"0.5193374",
"0.5188892",
"0.5171463",... | 0.6364497 | 0 |
Return an iterable of available actions at state. If state is not specified, default to the current state. | def get_actions(self, state: TState = None) -> Sequence[TAction]:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_available_actions(self, state):\n pass",
"def getActions(self, state): \n util.raiseNotDefined()",
"def get_possible_actions(self, state):\n return [LEFT, DOWN, RIGHT, UP]",
"def actions(self, state):\n myActionList= (1,2);\n return myActionList",
"def actions(... | [
"0.8277153",
"0.79832304",
"0.7570984",
"0.7415713",
"0.7298199",
"0.7231417",
"0.722858",
"0.71281105",
"0.7086365",
"0.7078392",
"0.70137125",
"0.68945676",
"0.6875312",
"0.6870959",
"0.6870931",
"0.68464303",
"0.67741674",
"0.6692644",
"0.66597867",
"0.6658482",
"0.6645392... | 0.8154208 | 1 |
Run a single actandtrain step. Returns the tuple (S_t, A_t, R_{t+1}). | def act_and_train(self, t: int) -> Tuple[TState, TAction, float]:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def TrainOneStep(self):\n pass",
"def train_step(self):\n pass",
"def run_step(self):\n self.hooked_sess.run(self.train_op)",
"def eval_step_a(self, sess, task_a_data):\n x_a, y_a = task_a_data\n fdict = self.get_fdict(task_a_data=task_a_data)\n prediction_a, y_a = sess.run([sel... | [
"0.70092875",
"0.66954255",
"0.64699775",
"0.62712634",
"0.6224097",
"0.6189791",
"0.61162895",
"0.6095587",
"0.6087337",
"0.6084674",
"0.6065545",
"0.60538787",
"0.6028692",
"0.6023635",
"0.59864765",
"0.5975973",
"0.5975631",
"0.59701496",
"0.59697425",
"0.59598327",
"0.593... | 0.69478923 | 1 |
Trains the agent in its environment. At the end of each timestep, calls on_action(S_t, A_t, R_{t+1}, t) At the end of each episode, calls on_episode_end(T) | def train(
env: DiscreteEnvironment[TState, TAction],
agent: DiscreteAgent[TState, TAction],
n_episodes: int,
on_action: Callable[[TState, TAction, float, int], None] = None,
on_episode_end: Callable[[int], None] = None,
) -> None:
for ep in range(n_episodes):
t = 0
while not env... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rollout_an_episode(self):\n self._steps = 0\n me_id = self._learning_agent_id # short name\n oppo_id = self._oppo_agent_id # short name\n logger.log('episode begins with the task: {}'.format(str(self.task)))\n\n # passing me and oppo hyperparams to the arena interface\n assert self.task.hy... | [
"0.7263131",
"0.7017281",
"0.6894103",
"0.6870479",
"0.6831118",
"0.68021125",
"0.6674697",
"0.6665866",
"0.66278803",
"0.66267455",
"0.6537956",
"0.65186983",
"0.6508413",
"0.6453616",
"0.6426858",
"0.63971114",
"0.6384944",
"0.6357389",
"0.6332097",
"0.6330122",
"0.63054234... | 0.7600154 | 0 |
Creates a patchset for a single slide This creates a PatchSet for a single slide. | def make_patchset_for_slide(
slide_path: Path,
annot_path: Path,
slide_label: str,
loader: Loader,
tissue_detector: TissueDetector,
patch_finder: PatchFinder,
project_root: Path = Path('/')
) -> PatchSet:
with loader.load_slide(project_root / slide_path) as slide:
annotations = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_photoset():\n return core.PhotoSet()",
"def patch_set(self, *patch_tuples):\n return PatchSet(*patch_tuples)",
"def visualise_patches_on_slide(ps: PatchSet, vis_level: (int), project_root: Path = Path('/')) -> Image:\n assert len(ps.settings) == 1, \"The input patch set contains patche... | [
"0.5744651",
"0.56712204",
"0.56489134",
"0.5592712",
"0.5339742",
"0.5301161",
"0.5230243",
"0.5168246",
"0.5071445",
"0.50654876",
"0.5017482",
"0.50046384",
"0.49635142",
"0.49329877",
"0.4829867",
"0.48155797",
"0.4762006",
"0.47519368",
"0.4733621",
"0.4692702",
"0.46659... | 0.7102883 | 0 |
Creates PatchSets for all slides in a dataset For each slide in the dataset this creates the PatchSet then saves it in a sub directory of the output_dir | def make_and_save_patchsets_for_dataset(
dataset: pd.DataFrame,
loader: Loader,
tissue_detector: TissueDetector,
patch_finder: PatchFinder,
output_dir: Path,
project_root: Path = Path('/')
) -> List[PatchSet]:
patchsets = []
output_dir = Path(output_dir)
for row in dataset.itert... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_patches(self):\n sets = os.listdir(self.__data_dir)\n import re\n sets = [a_set for a_set in sets if re.match(r'[0-9a-zA-Z_]+', a_set)]\n total = len(sets)\n count = 1\n for a_set in sets:\n print('\\r', 'slicing {0}/{1}'.format(count, total).ljust(... | [
"0.68254083",
"0.6283648",
"0.62608784",
"0.6081597",
"0.60552466",
"0.60042644",
"0.59631425",
"0.5945658",
"0.5904896",
"0.5902023",
"0.58635426",
"0.5820674",
"0.57965267",
"0.5763565",
"0.5745205",
"0.5722761",
"0.5705266",
"0.5650072",
"0.5648188",
"0.5624213",
"0.562252... | 0.73118013 | 0 |
Creates PatchSets for all slides in a dataset For each slide in the dataset this creates the PatchSet | def make_patchsets_for_dataset(
dataset: pd.DataFrame,
loader: Loader,
tissue_detector: TissueDetector,
patch_finder: PatchFinder,
project_root: Path = Path('/')
) -> List[PatchSet]:
patchsets = []
for row in dataset.itertuples():
patchset = make_patchset_for_slide(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_and_save_patchsets_for_dataset(\n dataset: pd.DataFrame,\n loader: Loader,\n tissue_detector: TissueDetector,\n patch_finder: PatchFinder,\n output_dir: Path,\n project_root: Path = Path('/') \n) -> List[PatchSet]:\n\n patchsets = []\n output_dir = Path(output_dir)\n for row ... | [
"0.7088063",
"0.67391914",
"0.6291186",
"0.606787",
"0.59243375",
"0.59094286",
"0.585917",
"0.58064145",
"0.57734776",
"0.57441443",
"0.5677027",
"0.5637872",
"0.5635088",
"0.563015",
"0.5549309",
"0.5526841",
"0.55001897",
"0.5481712",
"0.5450806",
"0.54289186",
"0.54152095... | 0.75513446 | 0 |
Loads PatchSets from a directory Loads patchsets for a whole dataset stored in subdirectories of patchsets_dir | def load_patchsets_from_directory(patchsets_dir: Path):
patchset_dir_list = [x for x in Path(patchsets_dir).iterdir() if x.is_dir()]
patchset_list = [PatchSet.load(p) for p in patchset_dir_list]
return patchset_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadSets(self, indir=\"\"):\n\n if indir==\"\":\n print(\"specify folder\")\n return -1\n\n self.train = pd.read_pickle(\"{}/train.pkl\".format(indir))\n self.valid = pd.read_pickle(\"{}/valid.pkl\".format(indir))\n self.test = pd.read_pickle(\"{}/test.pkl\".fo... | [
"0.6319724",
"0.62242323",
"0.6157851",
"0.60138506",
"0.59787524",
"0.5950172",
"0.5950172",
"0.5852212",
"0.58365333",
"0.5813799",
"0.58093363",
"0.5803925",
"0.57615",
"0.55967456",
"0.5591764",
"0.55741495",
"0.55371463",
"0.5518638",
"0.551647",
"0.55142206",
"0.5506752... | 0.8648056 | 0 |
Combines multiple patchsets into one This gives a combined dataframe with all patches in a dataset, for example to use to sample patches. It also renumbers settings so that indexes in dataframe match correct setting in combined_settings list | def combine(patchsets: List[PatchSet]) -> PatchSet:
# compute and apply the settings index offset
# offset is equal to the size of the settings object up to this point
offset = 0
for ps in patchsets:
ps.df["setting"] += offset # todo: do we mind mutating ps and thus patchsets
offset += ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_patches(self):\n sets = os.listdir(self.__data_dir)\n import re\n sets = [a_set for a_set in sets if re.match(r'[0-9a-zA-Z_]+', a_set)]\n total = len(sets)\n count = 1\n for a_set in sets:\n print('\\r', 'slicing {0}/{1}'.format(count, total).ljust(... | [
"0.559636",
"0.546889",
"0.54349804",
"0.5390934",
"0.5357136",
"0.5347434",
"0.53426737",
"0.52996886",
"0.52972007",
"0.5275128",
"0.5253688",
"0.51971537",
"0.5164356",
"0.5159226",
"0.51366895",
"0.5136591",
"0.5045975",
"0.5030461",
"0.50248724",
"0.5021024",
"0.50115675... | 0.8071056 | 0 |
Draws patches on a thumbnail of the slide Visualise where on the slide the patches occur. Assumes a patch set for one slide with only one set of settings | def visualise_patches_on_slide(ps: PatchSet, vis_level: (int), project_root: Path = Path('/')) -> Image:
assert len(ps.settings) == 1, "The input patch set contains patches from more than one slide, or more than one patch size / level"
slide_settings = ps.settings[0]
def convert_ps_to_thumb_level(ps... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visualize_patches(\n patches,\n patch_centers,\n figure_size=(7, 7),\n browser_style=\"buttons\",\n custom_info_callback=None,\n):\n # Make sure that patches is a list even with one member\n if (isinstance(patches, list) and isinstance(patches[0], Image)) or not isinstance(\n patche... | [
"0.6362144",
"0.62431216",
"0.6084633",
"0.60054344",
"0.58709335",
"0.5793564",
"0.57591844",
"0.5748621",
"0.57214457",
"0.57214457",
"0.5711059",
"0.5706892",
"0.5667929",
"0.56496435",
"0.56290567",
"0.5608083",
"0.5580989",
"0.55794597",
"0.55646884",
"0.5549183",
"0.553... | 0.788942 | 0 |
see ServoJoint for parameters | def __init__( self, owner, shoulderindex, wristindex, ctrlindex=0 ):
self.shoulder = ServoJoint( owner, shoulderindex, ctrlindex )
self.wrist = ServoJoint( owner, wristindex, ctrlindex ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parameters(self):",
"def define_parameters(self):",
"def params():\n raise NotImplementedError",
"def addParameters(self):\n\n self.pRefArray = self.addParam(\"ikrefarray\", \"string\", \"\")\n self.pUseIndex = self.addParam(\"useIndex\", \"bool\", False)\n\n self.pParentJoint... | [
"0.6273324",
"0.60755783",
"0.5805521",
"0.5776904",
"0.5770701",
"0.5673146",
"0.56296647",
"0.5591992",
"0.5541747",
"0.55045223",
"0.5475025",
"0.54562557",
"0.5448725",
"0.5442981",
"0.54360217",
"0.5431233",
"0.5402328",
"0.5385403",
"0.53349155",
"0.530722",
"0.5301658"... | 0.6223078 | 1 |
request an edit token and update the cookie_jar in order to add the session cookie | def generate_edit_credentials(self):
params = {
'action': 'query',
'meta': 'tokens',
'format': 'json'
}
response = requests.get(self.base_url, params=params, cookies=self.cookie_jar)
self.edit_token = response.json()['query']['tokens']['csrftoken']
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_edit_cookie(self):\n if not self.cookie_jar or (time.time() - self.instantiation_time) > self.token_renew_period:\n self.generate_edit_credentials()\n self.instantiation_time = time.time()\n\n return self.cookie_jar",
"def _update_token(token):\n session.token = tok... | [
"0.6829017",
"0.6552336",
"0.6084768",
"0.6052417",
"0.6044414",
"0.6035273",
"0.5940581",
"0.59082705",
"0.58456063",
"0.5839862",
"0.5810167",
"0.5778239",
"0.5740443",
"0.5726869",
"0.571872",
"0.57095593",
"0.5698594",
"0.56953746",
"0.5689469",
"0.56476593",
"0.564506",
... | 0.7649784 | 0 |
Can be called in order to retrieve the edit token from an instance of WDLogin | def get_edit_token(self):
if not self.edit_token or (time.time() - self.instantiation_time) > self.token_renew_period:
self.generate_edit_credentials()
self.instantiation_time = time.time()
return self.edit_token | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_edit_token():\r\n\r\n print 'Getting edit token'\r\n url = 'http://shank.trikeapps.com/mediawiki/index.php?title=Special:Import'\r\n feed = urllib2.urlopen(url)\r\n buf = feed.read()\r\n tree = etree.fromstring(buf, parser)\r\n nodes = tree.xpath('//input[@name=\"editToken\"]')\r\n if ... | [
"0.7423933",
"0.656299",
"0.64786434",
"0.6306935",
"0.6199241",
"0.60753524",
"0.607358",
"0.60502046",
"0.6034152",
"0.6025066",
"0.5935602",
"0.5923639",
"0.59185857",
"0.5912252",
"0.587644",
"0.58571887",
"0.58213174",
"0.5820395",
"0.5820395",
"0.5812893",
"0.5807266",
... | 0.7558446 | 0 |
Testing functions measuring different lengths for a tx | def test_lengths(self):
for tx_hex, length in [
(TX_FAKE_HEX, 60),
(TX_HEX, 224),
(TX_WITNESS_HEX, 125),
]:
tx = self.tx_deserialize_hex(tx_hex)
length_with_witness = len(tx_hex) // 2
witness_len = length_with_witness - length
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_length(t_list):\n if not get_length(t_list) == 10:\n raise ValueError(\"Wrong number of transactions\")",
"def testLengthsOfFunction(self):\n\t\tfunc_len = len(self.d3.func_terms)\n\t\tself.assertEqual(3, func_len)",
"def test_within_length(self):\r\n\r\n flow1 = Flowgram(\"0 1.2 ... | [
"0.64650005",
"0.6276596",
"0.6272229",
"0.6114736",
"0.60718954",
"0.58691853",
"0.58383834",
"0.57942814",
"0.5793124",
"0.5793124",
"0.5793124",
"0.5793124",
"0.5793124",
"0.5793124",
"0.5793124",
"0.5777737",
"0.5757066",
"0.5706175",
"0.5706175",
"0.5682278",
"0.5681881"... | 0.691899 | 0 |
Testing functions manipulating witness stacks | def test_witness(self):
witness = wally_tx_witness_stack()
item, item_len = make_cbuffer('00')
out, out_len = make_cbuffer('00'*128)
for args in [
(None, item, item_len), # NULL stack
(witness, None, item_len), # NULL stack item
]:
self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_peek_on_small_stack(small_stack):\n assert small_stack.peek().val == 3",
"def test_inputs(self):\n # Add\n txhash, txhash_len = make_cbuffer('00'*32)\n script, script_len = make_cbuffer('00')\n for args in [\n (None, txhash, txhash_len, 0, 0xffffffff, script, sc... | [
"0.63709205",
"0.5887398",
"0.5870148",
"0.58111113",
"0.57996917",
"0.5653969",
"0.5647287",
"0.5611212",
"0.55797887",
"0.5565525",
"0.5563858",
"0.5539119",
"0.5446278",
"0.5412754",
"0.5404378",
"0.538511",
"0.53791",
"0.53343993",
"0.5329976",
"0.5320896",
"0.5247108",
... | 0.70744616 | 0 |
Testing function to get the signature hash | def test_get_signature_hash(self):
tx = self.tx_deserialize_hex(TX_FAKE_HEX)
script, script_len = make_cbuffer('00')
out, out_len = make_cbuffer('00'*32)
for args in [
(None, 0, script, script_len, 1, 1, 0, out, out_len), # Empty tx
(tx, 0, None, script_len, 1, 1,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RSA_SIGNATURE_HASH() :\n return \"SHA-256\"",
"def _get_signature(value):\n mySha = hashlib.sha256()\n mySha.update(value)\n # print mySha.hexdigest()\n return mySha.hexdigest()",
"def signature(request) -> str:\n return get_test_data(request, __name__, \"signature\", \"r\")",
"def test... | [
"0.72522295",
"0.7118092",
"0.6962875",
"0.6725924",
"0.6722758",
"0.6702743",
"0.669831",
"0.66803306",
"0.6674518",
"0.66335404",
"0.65883154",
"0.6582335",
"0.65816987",
"0.6578941",
"0.6560341",
"0.64982843",
"0.64982843",
"0.64982843",
"0.64982843",
"0.64982843",
"0.6498... | 0.76045924 | 0 |
Test functions computing hash_prevouts | def test_hash_prevouts(self):
if not wally_is_elements_build()[1]:
# The direct access tx.num_inputs/tx.inputs[i].txhash/tx.inputs[i].index
# below only works if this is an elements build. Skip this test for
# non-elements builds until the tx accessors are available to call
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_hash(self):",
"def hash_functions(self):\n pass",
"def test_hash(self):\r\n self.assertEqual(processor_hash('test'), 'GqNJWF7X7L07nEhqMAZ+OVyks1Y=')\r\n self.assertEqual(processor_hash('edx '), '/KowheysqM2PFYuxVKg0P8Flfk4=')",
"def test_rendezvous_hash_roughly_fractional_cha... | [
"0.64374894",
"0.63083476",
"0.6126053",
"0.60666585",
"0.600083",
"0.5959502",
"0.59289616",
"0.59117466",
"0.58998424",
"0.58467466",
"0.57924736",
"0.5777996",
"0.57616204",
"0.57536227",
"0.5742025",
"0.57337195",
"0.57261777",
"0.5725072",
"0.57187015",
"0.5718261",
"0.5... | 0.7914517 | 0 |
Tests for computing the taproot signature hash | def test_get_taproot_signature_hash(self):
keyspend_case = JSON['keyPathSpending'][0]
input_spending = keyspend_case['inputSpending']
utxos = keyspend_case['given']['utxosSpent']
num_utxos = len(utxos)
scripts = pointer(wally_map())
wally_map_init_alloc(num_utxos, None,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_signature_hash(self):\n tx = self.tx_deserialize_hex(TX_FAKE_HEX)\n script, script_len = make_cbuffer('00')\n out, out_len = make_cbuffer('00'*32)\n for args in [\n (None, 0, script, script_len, 1, 1, 0, out, out_len), # Empty tx\n (tx, 0, None, script... | [
"0.7306346",
"0.67878217",
"0.67379993",
"0.65791255",
"0.65272444",
"0.6521382",
"0.65158147",
"0.6515455",
"0.6494473",
"0.64850247",
"0.64580804",
"0.6361062",
"0.6354172",
"0.6354172",
"0.6354172",
"0.6354172",
"0.6354172",
"0.6354172",
"0.63422406",
"0.6334671",
"0.62990... | 0.7531539 | 0 |
uses 'if val in str_or_list'. returns True if val_to_find is in str_or_list. | def contains(str_or_list, val_to_find):
return (val_to_find in str_or_list) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(ss, list_seq):\n\tfor item in list_seq:\n\t\tif item in ss:\n\t\t\treturn True\n\treturn False",
"def in_list(value, arg):\r\n return value in arg",
"def __match_value(needle, haystack):\n\n if haystack in [ None, [], \"\", \"*\" ]:\n return True\n\n if isinstance(haystack,... | [
"0.6980658",
"0.6935137",
"0.68438077",
"0.66982305",
"0.64455277",
"0.634361",
"0.6338559",
"0.62630934",
"0.6177178",
"0.60729283",
"0.60717875",
"0.60483295",
"0.597657",
"0.59729517",
"0.59638566",
"0.59631807",
"0.59156036",
"0.5912719",
"0.5912713",
"0.5900636",
"0.5886... | 0.9234701 | 0 |
uses utilities to determine if debug info is allowed for this request. | def debug_allowed(request_object):
return utilities.debug_allowed(request_object) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DebugInfo( self, request_data ):\n pass",
"def debug() -> bool:",
"def is_debug ():\n\n return __debug__ and DEBUG",
"def is_debug(cls):\n return Traceable.debug & cls.DEBUG_ENABLE",
"def _debug():\n return _DEBUG",
"def debug():\n assert current_app.debug == False, \"Don't pan... | [
"0.7435488",
"0.6834311",
"0.6782017",
"0.65772843",
"0.6547984",
"0.6509061",
"0.6438754",
"0.63431764",
"0.62866163",
"0.62752175",
"0.6224649",
"0.62222284",
"0.62184817",
"0.6110516",
"0.60397923",
"0.603709",
"0.59925544",
"0.5991294",
"0.5985263",
"0.5982328",
"0.597285... | 0.7806079 | 0 |
applies class='itemdisabled' to admin change_list.results.item if the object has .disabled attribute and it is set to True. This is used in change_list_results.html template for admin. | def disabled_css(item):
obj_match = disabled_pat.search(item)
if obj_match is None:
# This is not an object link.
return item
else:
# grab object.
if len(obj_match.groups()) == 4:
# beginning of a tag (<a href) (Not used right now)
# tag = obj_match.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disable(self, item_id):\n pass",
"def on_varEnable(self, item):\n state = item.wdgEnabled.isChecked()\n item.wdgLabel.setEnabled(state)\n item.wdgType.setEnabled(state)\n item.wdgValue.setEnabled(state)\n item.wdgComment.setEnabled(state)",
"def set_disabled(self, ... | [
"0.56540865",
"0.53771347",
"0.51727283",
"0.51727283",
"0.51422185",
"0.51397413",
"0.51397413",
"0.51281595",
"0.5105484",
"0.50969875",
"0.50819623",
"0.50819623",
"0.5081686",
"0.5063089",
"0.5063089",
"0.50517005",
"0.50496775",
"0.5041621",
"0.5030509",
"0.49857676",
"0... | 0.6722628 | 0 |
uses str_.endswith() to check a value. returns True if str_.endswith(val_to_check) | def ends(str_, val_to_check):
return (str_.endswith(val_to_check)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def endswith(self, val):\n\t\treturn EndsWith(self, val)",
"def _iendswith(string, suffix):\n return string.lower().endswith(suffix)",
"def ends_with(strn, suffix):\n return strn.endswith(suffix)",
"def endswith(self, suffix):\n return self.joined().endswith(suffix)",
"def endswith(self, s):\n... | [
"0.77089614",
"0.744264",
"0.7077548",
"0.70557904",
"0.69548595",
"0.69548595",
"0.68519235",
"0.6835415",
"0.6664481",
"0.6606964",
"0.6431315",
"0.6397096",
"0.6312334",
"0.6249763",
"0.6117389",
"0.602617",
"0.5949974",
"0.5934679",
"0.5877196",
"0.58564484",
"0.5850036",... | 0.89305955 | 0 |
if object has .disabled attribute, returns it, if not, returns False. | def is_disabled(model_obj):
if hasattr(model_obj, 'disabled'):
return model_obj.disabled
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_disabled(self):\n return self._tag == 'disabled'",
"def get_disabled(self):\n return self._disabled",
"def get_disabled(self):\n return self._disabled",
"def disabled(self) -> bool:\n return pulumi.get(self, \"disabled\")",
"def disabled(self) -> bool:\n return pul... | [
"0.78513855",
"0.7751248",
"0.7751248",
"0.7743556",
"0.7743556",
"0.7705866",
"0.7704667",
"0.7665056",
"0.75958884",
"0.7568",
"0.7568",
"0.7565383",
"0.7565383",
"0.7565383",
"0.7565383",
"0.7565383",
"0.7565383",
"0.7565383",
"0.7565383",
"0.7565383",
"0.7565383",
"0.75... | 0.853476 | 0 |
checks python value for false | def is_false(value):
return (value is False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_for_bool(check):",
"def __bool__(x):\n if x.value == 1:\n return True\n elif x.value == -1:\n return False\n else:\n raise ValueError('cannot determine boolean value of Unknown')",
"def __bool__(self):\n return bool(self.get_value())",
"d... | [
"0.7816097",
"0.7736493",
"0.7698852",
"0.76820946",
"0.75596195",
"0.7526254",
"0.7498264",
"0.7468798",
"0.74631107",
"0.74294955",
"0.7409398",
"0.7359763",
"0.7272459",
"0.72445786",
"0.71598166",
"0.7140796",
"0.713629",
"0.71099216",
"0.7095251",
"0.7061183",
"0.7040984... | 0.82233524 | 0 |
determines whether or not the client is mobile/tablet. requires a request object. returns True/False. | def is_mobile(request_object):
return utilities.is_mobile(request_object) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mobile(request):\n MOBILE_AGENT_RE = re.compile(\n r\".*(iphone|mobile|androidtouch)\", re.IGNORECASE)\n if MOBILE_AGENT_RE.match(request.META['HTTP_USER_AGENT']):\n return True\n else:\n return False",
"def check_mobile(request):\n MOBILE_AGENT_RE=re.compile(r\".*(iphone|mob... | [
"0.80431396",
"0.7772343",
"0.6576394",
"0.6073721",
"0.59578633",
"0.577806",
"0.5623567",
"0.55905294",
"0.55746615",
"0.55300605",
"0.54696333",
"0.54378504",
"0.5427469",
"0.5302055",
"0.52785003",
"0.52515644",
"0.5204059",
"0.5194955",
"0.517742",
"0.5168378",
"0.515606... | 0.79570174 | 1 |
determines whether or not the site is a testserver. looks for 'test.welbornprod' domains. returns True/False. | def is_test_site(request_object):
if (request_object is None or
request_object.META is None or
(not request_object)):
# happens on errors,
# Should always do what the live site does in case of error.
return False
# Get current server name for this instance.
# Could be ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __matchDomain(self, cookieDomain, siteDomain):\n if not siteDomain:\n # empty URLs always match\n return True\n \n if cookieDomain.startswith(\".\"):\n cookieDomain = cookieDomain[1:]\n if siteDomain.startswith(\".\"):\n siteDomain = siteD... | [
"0.61874837",
"0.6138271",
"0.6063733",
"0.58472294",
"0.5844848",
"0.58347887",
"0.58227885",
"0.57552624",
"0.57399696",
"0.57175887",
"0.57092845",
"0.57033116",
"0.56786674",
"0.56685036",
"0.56659365",
"0.5657037",
"0.56339794",
"0.5629722",
"0.5628374",
"0.5624892",
"0.... | 0.7685936 | 0 |
checks python value for true | def is_true(value):
return (value is True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pythonvalue(self, value):\n return value in (\"true\", \"1\")",
"def boolean(val):\n\tif val == \"True\" or val == \"1\":\n\t\treturn True\n\telse:\n\t\treturn False",
"def check_for_bool(check):",
"def __bool__(self):\n return bool(self.get_value())",
"def check_active(value):\r\n\tif va... | [
"0.8369112",
"0.8170016",
"0.80784726",
"0.7975221",
"0.7746322",
"0.7697612",
"0.7680747",
"0.76379085",
"0.75648415",
"0.7473122",
"0.7465493",
"0.7436258",
"0.7415998",
"0.7412983",
"0.7404234",
"0.73874474",
"0.7354028",
"0.72744006",
"0.7265795",
"0.7254807",
"0.72507644... | 0.84263355 | 0 |
returns .META dict value from request | def meta_value(request_object, dictkey):
try:
val = request_object.META[dictkey]
except: # Exception as ex:
val = ''
return val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def meta_params(request):\n return request.param",
"def meta_est(request):\n return request.param",
"def meta(self):\r\n url = '{0}/{1}'.format(self.get_url(), 'meta')\r\n\r\n return http.Request('GET', url), parsers.parse_json",
"def _get_request_header(request, header_name, default=''):... | [
"0.6860854",
"0.6682526",
"0.63909286",
"0.622113",
"0.619917",
"0.61559874",
"0.60640436",
"0.60098106",
"0.59663737",
"0.5912337",
"0.58886594",
"0.5879663",
"0.5840489",
"0.5837623",
"0.57936585",
"0.5786767",
"0.57731503",
"0.5744824",
"0.5734018",
"0.5729786",
"0.5722078... | 0.698108 | 0 |
returns repr(object_) to the template | def repr_(object_):
return repr(object_) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def srepr(obj):\n return repr(str(obj))",
"def get_str(self, obj):\n if self.pretty:\n return pprint.pformat(obj)\n else:\n return str(obj)",
"def repr(space, w_object):\n return space.repr(w_object)",
"def str_(object_):\n return str(object_)",
"def __repr__(se... | [
"0.7416736",
"0.723864",
"0.72172844",
"0.70896786",
"0.7067116",
"0.7040995",
"0.70001686",
"0.6887471",
"0.6868755",
"0.6816098",
"0.6787675",
"0.678411",
"0.6782005",
"0.6725407",
"0.67083853",
"0.67083853",
"0.67083853",
"0.67003375",
"0.66359305",
"0.6622372",
"0.6593867... | 0.83090186 | 0 |
uses str_.startswith() to check a value. returns True if str_.startswith(val_to_check) | def starts(str_, val_to_check):
return (str_.startswith(val_to_check)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def startswith(value, s):\n\n if not value: return False\n return value.find(s) == 0",
"def val_starts_with(base_string, strings):\n for the_string in strings:\n if base_string.startswith(the_string):\n return True",
"def beginswith(sel... | [
"0.81703633",
"0.78033334",
"0.7728935",
"0.7513582",
"0.7189139",
"0.7158327",
"0.7008055",
"0.6940706",
"0.6940706",
"0.6907152",
"0.6891375",
"0.6830384",
"0.68223464",
"0.67964363",
"0.6735688",
"0.6724997",
"0.67129076",
"0.6712062",
"0.66685987",
"0.66492397",
"0.663751... | 0.91464436 | 0 |
returns str(object_) to the template. | def str_(object_):
return str(object_) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_str(self, obj):\n if self.pretty:\n return pprint.pformat(obj)\n else:\n return str(obj)",
"def __str__(self):\n t = Template(\n \"\"\"\n <h4>$title</h4>\n $imgs\n $footnotes\n <hr/>\"\"\")\n # Return... | [
"0.74584556",
"0.7204605",
"0.7067867",
"0.6991106",
"0.69612724",
"0.6912521",
"0.682159",
"0.677374",
"0.6772831",
"0.6657477",
"0.6652963",
"0.663706",
"0.6633795",
"0.6631691",
"0.662793",
"0.6627587",
"0.66269803",
"0.6611301",
"0.65864795",
"0.6538112",
"0.6504004",
"... | 0.72697335 | 1 |
Return a list containing all names given that start with a vowel. | def get_vowel_names(): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_words_using_all_vowels():\n pass",
"def _get_vowels(sequence: str) -> list:\n vowels = []\n for char in sequence:\n if char in VOWELS:\n vowels.append(char)\n return vowels",
"def vowels(self):\n vas = []\n file = self.read()\n wor... | [
"0.70864594",
"0.6845165",
"0.63141286",
"0.61466324",
"0.61304927",
"0.60781354",
"0.6056478",
"0.6021999",
"0.5940651",
"0.5906015",
"0.5838582",
"0.58123296",
"0.5783902",
"0.57265985",
"0.5726025",
"0.56740415",
"0.5665687",
"0.5648352",
"0.5640403",
"0.56257415",
"0.5606... | 0.7898417 | 0 |
Return a list that contains each number raised to the ith power. | def power_list(): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def powers_of(num, min_power, max_power):\n return [num+p for p in range(min_power, max_power + 1)]",
"def power(numbers):\n if len(numbers) % 2 == 1: \n print('too few numbers, should be even')\n newlist = []\n for i in range(len(numbers)):\n newlist.append(i ** i+1)\n return newlis... | [
"0.807664",
"0.73226",
"0.7139822",
"0.71139526",
"0.70572597",
"0.6933644",
"0.68556625",
"0.6816917",
"0.6751091",
"0.6696277",
"0.66711634",
"0.6662618",
"0.66488016",
"0.6602348",
"0.6549204",
"0.6486972",
"0.64522725",
"0.6412159",
"0.63791066",
"0.63570243",
"0.6347603"... | 0.76916087 | 1 |
Add corresponding numbers in given 2D matrices. | def matrix_add(): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_matrices(m1, m2): \n output = []\n \n for index in range(len(m1)):\n row_1 = m1[index]\n row_2 = m2[index]\n new_row = []\n for index2 in range(len(row_1)):\n sum = row_1[index2] + row_2[index2]\n new_row.append(sum)\n output.append(new_r... | [
"0.7559766",
"0.7449436",
"0.74390155",
"0.72347176",
"0.7212037",
"0.6995729",
"0.69535553",
"0.69160366",
"0.6896857",
"0.6825186",
"0.6809705",
"0.6750765",
"0.67110014",
"0.6633727",
"0.65869576",
"0.65453583",
"0.6533952",
"0.64940804",
"0.6468396",
"0.6456392",
"0.63716... | 0.77871627 | 0 |
Get a list of all the devices used by the employee. | def get_devices_used_by(employee_id: int) -> list:
conn = database_connect()
if(conn is None):
return None
cur = conn.cursor()
try:
# SQL statement and execute
sql = """SELECT D.deviceID, D.manufacturer, D.modelNumber
FROM Device D JOIN DeviceUsedBy DUB USING(d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_devices():\n return _lib.SeaTeaseAPI().list_devices()",
"def list_devices():\r\n DeviceManagerCLI.BuildDeviceList()\r\n return DeviceManagerCLI.GetDeviceList()",
"def get_devices(self):\n return self.api_request('GET', self.url + '/device', {})",
"def get_issued_devices_for_user(empl... | [
"0.76229954",
"0.7509358",
"0.7411484",
"0.7347487",
"0.7236283",
"0.7208733",
"0.7138899",
"0.71287864",
"0.70979404",
"0.708892",
"0.69977707",
"0.69909376",
"0.69762063",
"0.69348323",
"0.6930538",
"0.69130564",
"0.6891412",
"0.6884089",
"0.6883338",
"0.68633336",
"0.68543... | 0.7896588 | 0 |
Get all repairs made to a device. | def get_device_repairs(device_id: int) -> list:
conn = database_connect()
if(conn is None):
return None
cur = conn.cursor()
try:
# SQL statement and execute
sql = """SELECT R.repairID, R.faultReport, R.startDate, R.endDate, R.cost
FROM Repair R
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_chairs(self):\n return self.chairs",
"def getDeviceList(self):\n return defer.succeed(self.discovered)",
"def doorbells(self):\n return self._doorbells_by_id.values()",
"def process(self, device, results, log):\n log.info('processing %s for device %s', self.name(), device.... | [
"0.5398555",
"0.5046706",
"0.49287528",
"0.48863626",
"0.48778644",
"0.4843946",
"0.4828989",
"0.48045683",
"0.47835082",
"0.47731847",
"0.47569847",
"0.47161895",
"0.47129184",
"0.47086382",
"0.46982932",
"0.46803945",
"0.4674976",
"0.46552896",
"0.46087393",
"0.46087393",
"... | 0.6825993 | 0 |
Get information about a repair in detail, including service information. | def get_repair_details(repair_id: int) -> Optional[dict]:
conn = database_connect()
if(conn is None):
return None
cur = conn.cursor()
try:
# SQL statement and execute
sql = """SELECT R.repairID, R.faultReport, R.startDate, R.endDate, R.cost, S.abn, S.serviceName, S.email, R.doneT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_info(self):\n for i in range(self.n_retries + 1):\n try:\n return self._info_proxy()\n except rospy.ServiceException as e:\n rospy.logwarn(\n '%s could not retrieve info: %s, retrying...', self._name, str(e))\n tim... | [
"0.57112694",
"0.5674774",
"0.5652152",
"0.55726254",
"0.5530891",
"0.5407416",
"0.53675944",
"0.5331116",
"0.53126454",
"0.52861154",
"0.52731055",
"0.5243719",
"0.5210022",
"0.5206627",
"0.52049077",
"0.5196526",
"0.518313",
"0.5176908",
"0.51693743",
"0.5142101",
"0.514009... | 0.71543014 | 0 |
Get the number of devices owned per employee in a department matching the model. | def get_employee_department_model_device(department_name: str, manufacturer: str, model_number: str) -> list:
conn = database_connect()
if(conn is None):
return None
cur = conn.cursor()
try:
# SQL statement and execute
sql = """SELECT Employee.empid, Employee.name, count(Device.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_devs_count_by_type(self, vmDeviceType):\n\t\treturn call_sdk_function('PrlVmCfg_GetDevsCountByType', self.handle, vmDeviceType)",
"def get_number_of_devices(self):\n return self.drt_manager.get_number_of_devices()",
"def get_devs_count(self):\n\t\treturn call_sdk_function('PrlVmCfg_GetDevsCount', se... | [
"0.61172354",
"0.60120255",
"0.595281",
"0.5812946",
"0.57363987",
"0.5721532",
"0.5621879",
"0.55683404",
"0.55388504",
"0.55178255",
"0.55105865",
"0.55031896",
"0.5385099",
"0.53810096",
"0.53271604",
"0.52596045",
"0.52485096",
"0.5169976",
"0.516956",
"0.5134565",
"0.511... | 0.74051267 | 0 |
Get all devices matching the model and manufacturer and show True/False if the employee has the device assigned. E.g. Model = Pixel 2, Manufacturer = Google, employee_id = 1337 [123656, False] [123132, True] [51413, True] [8765, False] | def get_model_device_assigned(model_number: str, manufacturer: str, employee_id: int) -> list:
conn = database_connect()
if(conn is None):
return None
cur = conn.cursor()
try:
# SQL statement and execute
sql = """SELECT Device.deviceID,
CASE WHEN (Device... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_employee_department_model_device(department_name: str, manufacturer: str, model_number: str) -> list:\n conn = database_connect()\n if(conn is None):\n return None\n cur = conn.cursor()\n\n try:\n # SQL statement and execute\n sql = \"\"\"SELECT Employee.empid, Employee.nam... | [
"0.7005823",
"0.6598192",
"0.61380196",
"0.59124863",
"0.5790217",
"0.5675171",
"0.56596357",
"0.5642285",
"0.5602389",
"0.55838096",
"0.55506885",
"0.55481386",
"0.54637796",
"0.54443264",
"0.54415464",
"0.5417799",
"0.54079926",
"0.5397424",
"0.5393373",
"0.539236",
"0.5392... | 0.7595464 | 0 |
Get all unassigned devices for the model. | def get_unassigned_devices_for_model(model_number: str, manufacturer: str) -> list:
conn = database_connect()
if(conn is None):
return None
cur = conn.cursor()
try:
# SQL statement and execute
sql = """SELECT Device.deviceID
FROM Device
WHERE D... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_discoverable_devices(self):\n available = self.get_available_devices()\n paired = self.get_paired_devices()\n return [d for d in available if d not in paired]",
"def get_discoverable_devices(self):\n available = self.get_available_devices()\n paired = self.get_paired_de... | [
"0.62098616",
"0.6135995",
"0.6083987",
"0.60300785",
"0.60210913",
"0.5989892",
"0.597985",
"0.5795616",
"0.57944936",
"0.57553595",
"0.5751607",
"0.5715041",
"0.569264",
"0.56730306",
"0.5664944",
"0.5664944",
"0.5664944",
"0.5664944",
"0.56614995",
"0.5651261",
"0.56455594... | 0.73793423 | 0 |
Return all the employees' IDs and names in a given department. | def get_employees_in_department(department_name: str) -> list:
conn = database_connect()
if(conn is None):
return None
cur = conn.cursor()
try:
# SQL statement and execute
sql = """SELECT Employee.empid, Employee.name
FROM Employee JOIN EmployeeDepartments USIN... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def department(department_id):\n # gather data from db about all employees\n return render_template(\"department.html\",\n department_id=department_id)",
"def getDepartmentNames():\n return list(Cuebot.getStub('department').GetDepartmentNames(\n department_pb2.DeptGetDep... | [
"0.69531727",
"0.68164986",
"0.66236746",
"0.64236677",
"0.6301057",
"0.62625134",
"0.62499946",
"0.6229222",
"0.6205687",
"0.6179576",
"0.61432016",
"0.6116803",
"0.61135745",
"0.6063087",
"0.59423494",
"0.583391",
"0.58224016",
"0.5752348",
"0.57511085",
"0.5712943",
"0.560... | 0.7350954 | 0 |
Issue the device to the chosen employee. | def issue_device_to_employee(employee_id: int, device_id: int):
conn = database_connect()
if(conn is None):
return None
cur = conn.cursor()
try:
# SQL statement and execute
sql = """SELECT COUNT(*)
FROM Device
WHERE Device.deviceID = %s AND Dev... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_device(self, args):\n self.device_command.cmdloop(\"Enter to device mode\")",
"def device_action(self, client, action):\r\n client.deviceAction(action)",
"def open_device_dialog(self):\n res, device = DeviceDialog.get_device(self.indexer)\n if res and device:\n sel... | [
"0.6378262",
"0.59657174",
"0.58966446",
"0.56755584",
"0.5663658",
"0.565638",
"0.5507164",
"0.5494308",
"0.5468433",
"0.5435343",
"0.538032",
"0.53636736",
"0.5328787",
"0.5326917",
"0.53076065",
"0.5293685",
"0.52884984",
"0.5276404",
"0.52762675",
"0.52647567",
"0.5263493... | 0.70986974 | 0 |
Revoke the device from the employee. | def revoke_device_from_employee(employee_id: int, device_id: int):
conn = database_connect()
if(conn is None):
return None
cur = conn.cursor()
try:
# SQL statement and execute
sql = """SELECT COUNT(*)
FROM Device
WHERE Device.deviceID = %s AND De... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def revoke(config, hostname, username):\n\n response = make_api_request('DELETE', config, '/machines/' + hostname +\n '/users/' + username)\n print 'Permission revoked successfully.'",
"def deregister(self, device_token):\n url = DEVICE_TOKEN_URL + de... | [
"0.6454705",
"0.6217701",
"0.62115955",
"0.61567014",
"0.60158235",
"0.59487706",
"0.5938955",
"0.5904292",
"0.5780341",
"0.5775011",
"0.5762005",
"0.5762005",
"0.5733728",
"0.57277143",
"0.57124597",
"0.57087195",
"0.56873167",
"0.567247",
"0.5644481",
"0.56395596",
"0.56329... | 0.7369513 | 0 |
Constructs a ResNet44 model. | def sphere_resnet44(**kwargs):
model = ResNet(44, **kwargs)
return model | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resnet34(pretrained=False, **kwargs):\n model = ResNet(BasicBlock, [3, 4, 6, 3], **kwargs)\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['resnet34']))\n fc = transfer_fc(model.fc)\n model.fc = fc\n return model",
"def resnet46(pretrained=False):\n model = Res... | [
"0.61464566",
"0.6131247",
"0.6121061",
"0.6047131",
"0.60446835",
"0.60446835",
"0.60446835",
"0.603721",
"0.60096526",
"0.5997441",
"0.5926571",
"0.5882806",
"0.5858409",
"0.58513224",
"0.58504117",
"0.581615",
"0.5799397",
"0.5796782",
"0.5768739",
"0.5738697",
"0.5731397"... | 0.64207953 | 0 |
convert one or more Jupyter notebooks to a published format paths can be string of an existing file or folder, or a pathlib.Path like object all files linked in the documents are placed into a single folder | def publish(ipynb_path,
outformat='latex_ipypublish_main',
outpath=None, dump_files=False,
ignore_prefix='_', clear_files=False,
create_pdf=False, pdf_in_temp=False, pdf_debug=False):
if isinstance(ipynb_path,basestring):
ipynb_path = pathlib.Path(ipynb_path)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_notebooks_to_md(notebooks):\n\n for notebook in notebooks:\n name = Path(notebook).name.split('.')[0]\n nb_raw = nbformat.read(notebook, 4)\n (body, resources) = md_exporter.from_notebook_node(nb_raw)\n output_file = NOTEBOOK_MD_DIR/name/(name+'.md')\n if not outpu... | [
"0.6977955",
"0.62920386",
"0.6198336",
"0.61873597",
"0.6042875",
"0.589361",
"0.58605915",
"0.5763023",
"0.5728314",
"0.57039154",
"0.56994057",
"0.5576597",
"0.5485907",
"0.5408591",
"0.53602326",
"0.5337952",
"0.53331363",
"0.5312051",
"0.5285677",
"0.52774996",
"0.525178... | 0.63751507 | 1 |
Fits variational parameters with respect to the provided logs. Returns the predictions for the log data used for fitting. | def fit(self, logs, num_clusters, log_labels=LOG_LABELS_DEF,
cs_weights=CS_WEIGHTS_DEF, p_weights=P_WEIGHTS_DEF,
epsilon=EPSILON_DEF, max_iter=MAX_ITER_DEF,
sample_resp=SAMPLE_RESP_DEF, n_restarts=N_RESTART_DEF):
self.init(logs, num_clusters, log_labels, cs_weights,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predictions(logits):\n # TODO implement predictions\n return logits",
"def on_predict_begin(self, logs: tp.Optional[tp.Dict[str, np.ndarray]] = None):\n pass",
"def on_predict_begin(self, logs=None):",
"def on_predict_begin(self, logs=None):",
"def on_predict_end(self, logs: tp.Optional[tp... | [
"0.6511352",
"0.65069395",
"0.62976485",
"0.62976485",
"0.6252163",
"0.61799675",
"0.6151001",
"0.6131185",
"0.6086639",
"0.6080412",
"0.5992971",
"0.5992971",
"0.5985858",
"0.595953",
"0.5933956",
"0.5927369",
"0.589057",
"0.5860014",
"0.5834541",
"0.58300024",
"0.5823897",
... | 0.65879834 | 0 |
Check if another VB iteration should be performed. Update self.prev_ll and self.iter variables. | def _should_continue(self):
# should_continue = self.iter < 20
# self.iter += 1
# return should_continue
if self.iter > self.max_iter:
return False
elif self.prev_elbo is None:
self.prev_elbo = self._get_elbo()
return True
elbo = self._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _do_iteration(self):\n return True",
"def next_iter(self):\n self.is_first_iter = False\n self.handles_to_post_forward_order_index.clear()\n self.handles_post_forward_order.clear()\n if self._checking_order:\n self.current_order_index = 0\n if self.war... | [
"0.6510494",
"0.5939916",
"0.58529633",
"0.5839369",
"0.580597",
"0.5762732",
"0.57518554",
"0.5750537",
"0.5724456",
"0.5649212",
"0.5634321",
"0.563371",
"0.56196654",
"0.55885583",
"0.5573801",
"0.5567565",
"0.5567565",
"0.5564638",
"0.55642575",
"0.5550561",
"0.5546281",
... | 0.62703604 | 1 |
Groups the models that use identical dataset into separate lists. | def group_models(model_list):
grouped_models = {}
for item in model_list:
grouped_models.setdefault((item['window'], item['binary_labels'], item['n_dim'], item['screwdriver_only']), []).append(item)
return grouped_models | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_models(self):\n model_list = []\n for i in range(0, len(self.X.cluster.unique())):\n foo_model = self.model\n foo_model.set_params(**self.best_params_list[i])\n model_list.append(foo_model)\n return model_list",
"def _identifyModels(self):\n ... | [
"0.59951776",
"0.5857341",
"0.5780542",
"0.5773224",
"0.57366127",
"0.5728204",
"0.57179016",
"0.5683895",
"0.56801504",
"0.5679104",
"0.5672214",
"0.5669302",
"0.56674093",
"0.565982",
"0.5659793",
"0.5639113",
"0.5607664",
"0.558664",
"0.5579476",
"0.5570005",
"0.5567214",
... | 0.6261022 | 0 |
Draw an AI agent Also displays circles with ```AI_FAR_RADIUS``` and ```AI_NEAR_RADIUS``` when debug is True | def draw(self, win, cam, team_id, debug=False):
if debug:
cam.circle(
win, (0, 100, 0), (self.pos-PLAYER_CENTER).val, AI_NEAR_RADIUS(self.difficulty), LINE_WIDTH)
cam.circle(
win, (0, 200, 0), (self.pos-PLAYER_CENTER).val, AI_FAR_RADIUS(self.difficulty), L... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_world(agent_list, object_list, world_radius, initial_plot):\n delta_angle = 0.2\n \n # Plot agents.\n for agent in agent_list:\n x_circle_points = []\n y_circle_points = []\n angle = 0\n while angle < math.pi * 2 + delta_angle:\n angle += delta_angle\n x_circle_points.append(agen... | [
"0.628059",
"0.62551165",
"0.6090929",
"0.5969536",
"0.5948323",
"0.5828753",
"0.57707024",
"0.57431114",
"0.56911415",
"0.56905264",
"0.56512624",
"0.56444067",
"0.5613877",
"0.56023425",
"0.55857235",
"0.5568706",
"0.5561327",
"0.55556625",
"0.5505935",
"0.54976386",
"0.549... | 0.62560564 | 1 |
Select a player based on the balls position | def select_player(self, ball):
dists = [player.pos.dist(ball.pos) +
player.rnd for player in self.players]
# Default - Ball goes to nearest player
self.selected = dists.index(min(dists))
if min(dists) > PLAYER_RADIUS + BALL_RADIUS and abs(ball.pos.x - self.goal_x) < W/... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(player1,player2,ball):\n pass",
"def pick_coup_target(self, callback):\n players_copy = copy.copy(self.game.players)\n if self in players_copy:\n players_copy.remove(self) # dont pick yourself\n if players_copy:\n target = random.choice(players_copy)\... | [
"0.5916942",
"0.58607996",
"0.5780231",
"0.57257247",
"0.5716752",
"0.5703355",
"0.5673696",
"0.5663263",
"0.5651894",
"0.5597483",
"0.55855846",
"0.5583621",
"0.55566585",
"0.55324316",
"0.5522929",
"0.55028194",
"0.5498753",
"0.54976743",
"0.54939663",
"0.54753387",
"0.5449... | 0.80363387 | 0 |
Return a Lambda layer that performs slicing on a tensor. | def slice_layer(start, end, step=None, axis=1):
if axis < 0:
raise ValueError("'slice_layer' can only work on a specified axis > 0")
def slice_func(x):
slices = [slice(None)] * axis
slices.append(slice(start, end, step))
return x[tuple(slices)]
return Lambda(slice_func) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _slice(tensor, size, i):\n return tensor[:, i * size : (i + 1) * size]",
"def crop(dimension, start, end):\n def func(x):\n if dimension == 0:\n return x[start: end]\n if dimension == 1:\n return x[:, start: end]\n if dimension == 2:\n return x[:, :... | [
"0.66275454",
"0.6391693",
"0.6305291",
"0.614591",
"0.5931871",
"0.5915826",
"0.5770445",
"0.57634896",
"0.5741946",
"0.5648242",
"0.55649984",
"0.54456764",
"0.54125327",
"0.5404694",
"0.5399862",
"0.5341658",
"0.5338727",
"0.52715975",
"0.52614665",
"0.5260301",
"0.5237027... | 0.6644071 | 0 |
Create a loss function that weights inputs by a function of latitude before calculating the loss. | def latitude_weighted_loss(loss_function=mean_squared_error, lats=None, output_shape=(), axis=-2, weighting='cosine'):
if weighting not in ['cosine', 'midlatitude']:
raise ValueError("'weighting' must be one of 'cosine' or 'midlatitude'")
if lats is not None:
lat_tensor = K.zeros(lats.shape)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, loss_function, lats, data_format='channels_last', weighting='cosine'):\n self.loss_function = loss_function\n self.lats = lats\n self.data_format = K.normalize_data_format(data_format)\n if weighting not in ['cosine', 'midlatitude']:\n raise ValueError(\"'w... | [
"0.68781596",
"0.6329892",
"0.6323015",
"0.62242746",
"0.6216297",
"0.61247945",
"0.6101485",
"0.60615444",
"0.60591424",
"0.6035702",
"0.6033604",
"0.6032601",
"0.60201824",
"0.59764326",
"0.59619296",
"0.5950042",
"0.594614",
"0.5931988",
"0.5928715",
"0.5925443",
"0.591088... | 0.71536607 | 0 |
Construct the map from the chosen ids to the corresponding physical qubits available on the platform. | def allocate_single_qubits(
platform: Optional[Platform], qubit_ids: list[QubitId]
) -> dict[QubitId, Qubit]:
return {q: platform.qubits[q] for q in qubit_ids} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allocate_qubits_pairs(\n platform: Optional[Platform], qubit_pairs_ids: list[tuple[QubitId, QubitId]]\n) -> dict[tuple[QubitId, QubitId], QubitPair]:\n return {tuple(qq): platform.pairs[tuple(sorted(qq))] for qq in qubit_pairs_ids}",
"def _build_ID_sets(self):\n raise NotImplementedError",
"de... | [
"0.6694281",
"0.5771979",
"0.57044435",
"0.561172",
"0.5610195",
"0.55837834",
"0.5574067",
"0.55452186",
"0.5532591",
"0.55150515",
"0.5512505",
"0.54999375",
"0.54794145",
"0.5450446",
"0.543241",
"0.5418475",
"0.5414715",
"0.54141295",
"0.5360951",
"0.5355756",
"0.53421646... | 0.67055035 | 0 |
Construct the map from the chosen id pairs to the corresponding physical qubit pairs available on the platform. | def allocate_qubits_pairs(
platform: Optional[Platform], qubit_pairs_ids: list[tuple[QubitId, QubitId]]
) -> dict[tuple[QubitId, QubitId], QubitPair]:
return {tuple(qq): platform.pairs[tuple(sorted(qq))] for qq in qubit_pairs_ids} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _createMap(self,dimensions, density):\n compMap = []\n xmin, xmax = dimensions[0], dimensions[1]\n imin, imax = dimensions[2], dimensions[3]\n\n #Ideally the hsteps and the vsteps are the same\n hsteps = int((xmax - xmin)/density)\n vsteps = int((imax - imin)/density)\... | [
"0.6062132",
"0.60412514",
"0.5945857",
"0.59305876",
"0.59138465",
"0.5904615",
"0.5901272",
"0.589069",
"0.5863087",
"0.58123565",
"0.575146",
"0.5749783",
"0.5729729",
"0.5646868",
"0.5613289",
"0.5610191",
"0.55909854",
"0.55679584",
"0.55554986",
"0.5521607",
"0.5503183"... | 0.6937312 | 0 |
Converts a Picard SequenceDictionary file to a BedRegion Generator. | def dict_file_to_regions(in_file: Union[str, os.PathLike]
) -> Generator[BedRegion, None, None]:
with open(in_file, "rt") as in_file_h:
for line in in_file_h:
fields = line.strip().split()
if fields[0] != "@SQ":
continue
contig: O... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bed_file_to_regions(in_file: Union[str, os.PathLike]\n ) -> Generator[BedRegion, None, None]:\n with open(in_file, \"rt\") as in_file_h:\n for line in in_file_h:\n fields = line.strip().split()\n # Skip browser and track fields and other invalid lines.\n ... | [
"0.6090384",
"0.5910861",
"0.56954473",
"0.56817096",
"0.52949846",
"0.5234422",
"0.51356375",
"0.50657725",
"0.50497913",
"0.50323004",
"0.49958685",
"0.49925402",
"0.49626485",
"0.4946026",
"0.49209324",
"0.49058735",
"0.48900145",
"0.4867171",
"0.4855806",
"0.48342767",
"0... | 0.70179707 | 0 |
Converts a BED file to a generator of BED regions | def bed_file_to_regions(in_file: Union[str, os.PathLike]
) -> Generator[BedRegion, None, None]:
with open(in_file, "rt") as in_file_h:
for line in in_file_h:
fields = line.strip().split()
# Skip browser and track fields and other invalid lines.
if ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dict_file_to_regions(in_file: Union[str, os.PathLike]\n ) -> Generator[BedRegion, None, None]:\n with open(in_file, \"rt\") as in_file_h:\n for line in in_file_h:\n fields = line.strip().split()\n if fields[0] != \"@SQ\":\n continue\n\n ... | [
"0.68258864",
"0.56819206",
"0.56468076",
"0.55572426",
"0.54127157",
"0.54065",
"0.5401644",
"0.53573495",
"0.5352528",
"0.532851",
"0.5304997",
"0.53033644",
"0.5250234",
"0.52344173",
"0.5213607",
"0.51621664",
"0.51566",
"0.51244426",
"0.5120947",
"0.5115895",
"0.5100907"... | 0.72599936 | 0 |
makes every property in a string !important. | def make_important(bulk):
return ';'.join('%s !important' % p if not p.endswith('!important') else p
for p in bulk.split(';')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def override_properties(char, new_properties):\n char.properties.update(new_properties)",
"def restore_needed_space(css):\n return css.replace(\"!important\", \" !important\").replace( # !important\n \"@media(\", \"@media (\").replace( # media queries # jpeg > jpg\n \"data:image/jpeg;ba... | [
"0.56750894",
"0.5530134",
"0.5456333",
"0.54243076",
"0.51791257",
"0.50367785",
"0.49051762",
"0.48879558",
"0.48081613",
"0.47645018",
"0.47433445",
"0.46917972",
"0.46872804",
"0.46538237",
"0.4633459",
"0.45820102",
"0.45607078",
"0.45531818",
"0.4545231",
"0.4540242",
"... | 0.6718231 | 0 |
loads an external stylesheet from a remote url or local path | def _load_external(self, url):
if url.startswith('//'):
# then we have to rely on the base_url
if self.base_url and 'https://' in self.base_url:
url = 'https:' + url
else:
url = 'http:' + url
if url.startswith('http://') or url.startsw... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_stylesheet(name):\n with suppress(FileNotFoundError):\n with open(STATIC_PATH / name, 'rt') as stylesheet:\n style = stylesheet.read().replace('@Path', (IMAGES_PATH / settings.value(Key.Theme)).as_posix())\n return style\n return ''",
"def load_url(src):\n return LO... | [
"0.6463143",
"0.60517496",
"0.6031524",
"0.5997467",
"0.5864724",
"0.5807122",
"0.5790323",
"0.56401026",
"0.56067747",
"0.55976367",
"0.54397446",
"0.5395931",
"0.5395931",
"0.53814423",
"0.5368214",
"0.5364866",
"0.5356252",
"0.53332764",
"0.53101045",
"0.52807534",
"0.5266... | 0.80462795 | 0 |
Set symbol into current position | def set_symbol(self, row, col, symbol):
self.field[row, col] = symbol | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_symbol(self, symbol):\r\n self.symbol = symbol",
"def put_symbol(self, symbol, row, column):\n\n self.board[row][column] = symbol",
"def symbol(self, symbol):\n self._symbol = symbol",
"def symbol(self, symbol):\n\n self._symbol = symbol",
"def set_character(self, y_pos,... | [
"0.73527914",
"0.7333711",
"0.7063088",
"0.6975132",
"0.6875314",
"0.6691054",
"0.6382481",
"0.63728315",
"0.63343257",
"0.63304055",
"0.62556505",
"0.6248476",
"0.6221346",
"0.6221288",
"0.61484957",
"0.6135693",
"0.6121064",
"0.61120474",
"0.6106495",
"0.61025465",
"0.60875... | 0.7654977 | 0 |
Check if certain position is cross | def is_cross(self, row, col):
return self.field[row, col] == 'O' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crossunder(x, y):\n return x[-1] < y[-1] and x[-2] > y[-2]",
"def crossover(x, y):\n return x[-1] > y[-1] and x[-2] < y[-2]",
"def check_inside(self, pos):\n x,y = pos\n return x >= self.posx and x <= self.posx + self.sizex and y >= self.posy and y <= self.posy + self.sizey",
"def is_in_colli... | [
"0.6963292",
"0.69521195",
"0.6877735",
"0.67772996",
"0.6722552",
"0.66963834",
"0.6661036",
"0.662266",
"0.6619683",
"0.6601838",
"0.6597616",
"0.65967333",
"0.6576726",
"0.65745586",
"0.6564663",
"0.6517698",
"0.6500501",
"0.6483487",
"0.6455018",
"0.64377636",
"0.6433994"... | 0.7387848 | 0 |
Reviced TK'S TCN model. num_block = 2. initial_conv_num=64. | def TK_TCN_resnet(
n_classes,
feat_dim,
max_len,
gap=1,
dropout=0.0,
activation="relu"):
ROW_AXIS = 1
CHANNEL_AXIS = 2
initial_conv_len = 8
initial_conv_num = 64
config = [
[(1,8,64)],
[(1,8,64)],
[(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def TCN(input_dim): \r\n # Number of dilations in order to use for the temporal blocks.\r\n dilations = np.array([1, 2, 4, 8, 16, 32])\r\n\r\n input_dim.insert(0,1)\r\n print(f\"input_dim: {input_dim}\")\r\n input_layer = Input(shape=input_dim)\r\n cropping = 0\r\n assert (sum(dilations) * blo... | [
"0.68942255",
"0.68528354",
"0.6683044",
"0.65449023",
"0.6541062",
"0.6530428",
"0.6437009",
"0.64252394",
"0.6398522",
"0.62898976",
"0.62263954",
"0.62163436",
"0.611939",
"0.61027503",
"0.6088047",
"0.6072917",
"0.6066379",
"0.6066081",
"0.6032926",
"0.6026914",
"0.602170... | 0.6901448 | 0 |
TCN regression model. num_block = 2. initial_conv_num=64. The last layer is fulllyconnected instead of softmax. | def TK_TCN_regression(
n_classes,
feat_dim,
max_len,
gap=1,
dropout=0.0,
W_regularizer=l1(1.e-4),
activation="relu"):
ROW_AXIS = 1
CHANNEL_AXIS = 2
initial_conv_len = 8
initial_conv_num = 64
config = [
[(1,8,64)],... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def TK_TCN_resnet(\n n_classes, \n feat_dim,\n max_len,\n gap=1,\n dropout=0.0,\n activation=\"relu\"):\n ROW_AXIS = 1\n CHANNEL_AXIS = 2\n \n initial_conv_len = 8\n initial_conv_num = 64\n\n config = [ \n [(1,8,64)],\n [(1,8... | [
"0.69995457",
"0.67794526",
"0.6420011",
"0.6303853",
"0.6280748",
"0.62714636",
"0.62052983",
"0.6107216",
"0.6102136",
"0.6093884",
"0.60819083",
"0.6068726",
"0.60674006",
"0.60495216",
"0.60443157",
"0.60360926",
"0.60230833",
"0.60013217",
"0.599608",
"0.5991251",
"0.596... | 0.73883975 | 0 |
Takes input from file. Path is provided by the method argument. Input should be provided as Adjacency List. | def addEdge_file(self, path):
with open(path, 'r') as File:
for line in File.readlines():
ints = list(map(int, line.strip().split()))
u = ints[0]
v = ints[1:]
for i in v:
self.addEdge(u, i) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_input(input_path):\n\n # Parse lines from input file into list\n with open(input_path, 'r') as input_file:\n lines = input_file.readlines()\n\n # Declare component lists and helper variables\n vertex_map = {} # Mapping of named vertices to indices, handles duplicate connections\n ... | [
"0.726996",
"0.60998154",
"0.60980654",
"0.58807373",
"0.58712083",
"0.5857996",
"0.5844285",
"0.5789363",
"0.57380736",
"0.5736321",
"0.5715027",
"0.5610502",
"0.55981505",
"0.55973846",
"0.5596148",
"0.559431",
"0.559249",
"0.5588808",
"0.55554086",
"0.5542649",
"0.5531438"... | 0.65473914 | 1 |
Gets best set of controllers from neighbors of provided set of nodes | def optimal_neighbors(self, graph, controllers : list) -> (list, int):
# This isn't efficient and does not take advantage of other variables in the class
# TODO: Optimize to use cluster_info
clusters = nx.get_node_attributes(graph, 'cluster')
neighbors_list = []
for i in controllers:
cluster = []
cluste... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def neighbors(node, topology):\n return [n for n in topology[node]]",
"def get_neighbours(lookups, model):\n movie_layer = model.get_layer(\"movie_embedding\")\n movie_weights = movie_layer.get_weights()[0]\n movie_lengths = np.linalg.norm(movie_weights, axis=1)\n\n normalised_movies = (movie_weig... | [
"0.5721627",
"0.5489162",
"0.5374165",
"0.53514844",
"0.53346765",
"0.5215939",
"0.5214041",
"0.51686734",
"0.51502234",
"0.512018",
"0.5088564",
"0.5081918",
"0.504484",
"0.50310206",
"0.50128627",
"0.50120884",
"0.49992216",
"0.49945664",
"0.4990665",
"0.49854285",
"0.49530... | 0.7126016 | 0 |
Return the current tree of fragments. | def fragments_tree(self):
return self.__fragments_tree | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tree(self):\n return html.fragment_fromstring(self.html)",
"def fragments(self):\n return self.fragments_tree.vchildren_not_empty",
"def tree(self):\r\n return self._tree",
"def get_tree(self):\n current = self\n nodes = []\n while current is not None:\n n... | [
"0.717223",
"0.66561615",
"0.6512672",
"0.6367306",
"0.6326681",
"0.6326681",
"0.6326681",
"0.6326681",
"0.6212404",
"0.6168607",
"0.6087147",
"0.6039931",
"0.60298365",
"0.5972522",
"0.59143937",
"0.5885449",
"0.58644503",
"0.57790774",
"0.57521635",
"0.57494605",
"0.5733215... | 0.84554595 | 0 |
Return ``True`` if the sync map has only one level, that is, if it is a list of fragments rather than a hierarchical tree. | def is_single_level(self):
return self.fragments_tree.height <= 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def leaves_are_consistent(self):\n self.log(u\"Checking if leaves are consistent\")\n leaves = self.leaves()\n if len(leaves) < 1:\n self.log(u\"Empty leaves => return True\")\n return True\n min_time = min([l.interval.begin for l in leaves])\n self.log([u\"... | [
"0.6629884",
"0.64945316",
"0.6467849",
"0.64206326",
"0.6241622",
"0.6241622",
"0.6241622",
"0.6241622",
"0.6219544",
"0.6143083",
"0.6133136",
"0.6120344",
"0.61035854",
"0.6093982",
"0.608292",
"0.60678726",
"0.6066365",
"0.6060789",
"0.6035434",
"0.60094637",
"0.60034037"... | 0.7508867 | 0 |
Return ``True`` if the sync map fragments which are the leaves of the sync map tree are all adjacent. | def has_adjacent_leaves_only(self):
leaves = self.leaves()
for i in range(len(leaves) - 1):
current_interval = leaves[i].interval
next_interval = leaves[i + 1].interval
if not current_interval.is_adjacent_before(next_interval):
return False
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def leaves_are_consistent(self):\n self.log(u\"Checking if leaves are consistent\")\n leaves = self.leaves()\n if len(leaves) < 1:\n self.log(u\"Empty leaves => return True\")\n return True\n min_time = min([l.interval.begin for l in leaves])\n self.log([u\"... | [
"0.7319423",
"0.6530777",
"0.6509751",
"0.6461713",
"0.6363584",
"0.6335099",
"0.61958694",
"0.6194637",
"0.61618984",
"0.61597484",
"0.61222214",
"0.61071444",
"0.609492",
"0.60827684",
"0.607346",
"0.60706186",
"0.60676575",
"0.6059726",
"0.6024598",
"0.60201997",
"0.601431... | 0.7376981 | 0 |
Return ``True`` if there is at least one sync map fragment which has zero length among the leaves of the sync map tree. | def has_zero_length_leaves(self):
for l in self.leaves():
if l.has_zero_length:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def leaves_are_consistent(self):\n self.log(u\"Checking if leaves are consistent\")\n leaves = self.leaves()\n if len(leaves) < 1:\n self.log(u\"Empty leaves => return True\")\n return True\n min_time = min([l.interval.begin for l in leaves])\n self.log([u\"... | [
"0.71172523",
"0.70737237",
"0.6872424",
"0.6833554",
"0.6809706",
"0.67979896",
"0.67979896",
"0.6782689",
"0.6765271",
"0.67428535",
"0.6735443",
"0.6728312",
"0.67182654",
"0.6706817",
"0.66952956",
"0.66934305",
"0.6676792",
"0.6676304",
"0.666644",
"0.6663899",
"0.666389... | 0.7566502 | 0 |
Return ``True`` if the sync map fragments which are the leaves of the sync map tree (except for HEAD and TAIL leaves) are all consistent, that is, their intervals do not overlap in forbidden ways. | def leaves_are_consistent(self):
self.log(u"Checking if leaves are consistent")
leaves = self.leaves()
if len(leaves) < 1:
self.log(u"Empty leaves => return True")
return True
min_time = min([l.interval.begin for l in leaves])
self.log([u" Min time: %.3f"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_atomic_overlaps(self):\n atomic_overlaps = self._get_atomic_overlaps()\n return len(atomic_overlaps) > 0",
"def check_consistent(self):\n # * END LIST The end list itself must be consistent.\n # ** Each end must be of understood type\n # ** Each end must have a valid se... | [
"0.69126606",
"0.6766974",
"0.6694312",
"0.66003346",
"0.65112936",
"0.64985895",
"0.64744806",
"0.6272579",
"0.6256419",
"0.6204049",
"0.62021416",
"0.61787343",
"0.6162518",
"0.6158997",
"0.6154389",
"0.6154389",
"0.61323094",
"0.6079736",
"0.59908587",
"0.5982117",
"0.5944... | 0.79154557 | 0 |
Add the given sync map fragment, as the first or last child of the root node of the sync map tree. | def add_fragment(self, fragment, as_last=True):
if not isinstance(fragment, SyncMapFragment):
self.log_exc(u"fragment is not an instance of SyncMapFragment", None, True, TypeError)
self.fragments_tree.add_child(Tree(value=fragment), as_last=as_last) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_fragment(self, fragment_dict, fragment):\n if fragment is not None:\n fragment_dict[\"fragment\"] = fragment\n fragment_dict[\"chain_id\"] = fragment.chain_id\n fragment_dict[\"frag_id\"] = fragment.fragment_id\n fragment_dict[\"res_name\"] = ... | [
"0.55610836",
"0.5372106",
"0.53353375",
"0.52164817",
"0.51740694",
"0.514758",
"0.514112",
"0.514112",
"0.509896",
"0.50863856",
"0.50459266",
"0.49393004",
"0.49289238",
"0.4891236",
"0.48688662",
"0.48378634",
"0.48043355",
"0.47952762",
"0.47440308",
"0.4733262",
"0.4718... | 0.7508192 | 0 |
Clear the sync map, removing all the current fragments. | def clear(self):
self.log(u"Clearing sync map")
self.fragments_tree = Tree() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear(self) -> None:\n self._updates.clear()\n self._fragments.clear()\n self._initialized = False # next access should reload all fragments",
"def clearMap(self):\n for key in self.componentMap.keys():\n del self.componentMap[key][:]",
"def clear(self):\n sel... | [
"0.7575226",
"0.73882234",
"0.73806286",
"0.68896496",
"0.6852297",
"0.67994666",
"0.6788261",
"0.67645746",
"0.67365015",
"0.6710038",
"0.67046225",
"0.66924447",
"0.6593916",
"0.6593916",
"0.6558014",
"0.6552275",
"0.6533073",
"0.65251327",
"0.65241826",
"0.6471572",
"0.644... | 0.9012502 | 0 |
Read sync map fragments from the given file in the specified format, and add them the current (this) sync map. Return ``True`` if the call succeeded, ``False`` if an error occurred. | def read(self, sync_map_format, input_file_path, parameters=None):
if sync_map_format is None:
self.log_exc(u"Sync map format is None", None, True, ValueError)
if sync_map_format not in SyncMapFormat.CODE_TO_CLASS:
self.log_exc(u"Sync map format '%s' is not allowed" % (sync_map_f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self, sync_map_format, output_file_path, parameters=None):\n def select_levels(syncmap, levels):\n \"\"\"\n Select the given levels of the fragments tree,\n modifying the given syncmap (always pass a copy of it!).\n \"\"\"\n self.log([u\"Level... | [
"0.53733176",
"0.5254925",
"0.5025687",
"0.48922312",
"0.48845756",
"0.48079976",
"0.4802709",
"0.4769521",
"0.4756503",
"0.47541055",
"0.4739254",
"0.47366694",
"0.471501",
"0.46992177",
"0.46768147",
"0.46767375",
"0.4637656",
"0.46307403",
"0.46225312",
"0.46045893",
"0.45... | 0.5729626 | 0 |
Write the current sync map to file in the requested format. Return ``True`` if the call succeeded, ``False`` if an error occurred. | def write(self, sync_map_format, output_file_path, parameters=None):
def select_levels(syncmap, levels):
"""
Select the given levels of the fragments tree,
modifying the given syncmap (always pass a copy of it!).
"""
self.log([u"Levels: '%s'", levels])... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mapFile_save(self, ad_json, astr_mapFile):\n b_ret = False\n\n if not os.path.exists(astr_mapFile):\n try:\n with open(astr_mapFile, 'w') as f:\n json.dump(ad_json, f)\n f.close()\n b_ret = True\n ex... | [
"0.58239394",
"0.5664589",
"0.5579532",
"0.5530572",
"0.5457981",
"0.5443911",
"0.54438895",
"0.5436824",
"0.5404191",
"0.53843796",
"0.53319955",
"0.53267103",
"0.53161126",
"0.5303174",
"0.5297106",
"0.5292992",
"0.5253701",
"0.52080554",
"0.5174646",
"0.5160978",
"0.515616... | 0.62188745 | 0 |
Select the given levels of the fragments tree, modifying the given syncmap (always pass a copy of it!). | def select_levels(syncmap, levels):
self.log([u"Levels: '%s'", levels])
if levels is None:
return
try:
levels = [int(l) for l in levels if int(l) > 0]
syncmap.fragments_tree.keep_levels(levels)
self.log([u"Selected level... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pickMap(self, selectedmap):\r\n for lvl in self.maplevels:\r\n lvl.style.border_color = (255,255,255)\r\n self.selectedmap = selectedmap;\r\n self.maplevels[selectedmap].style.border_color = (0,0,0)\r\n self.repaint()\r\n self.slevel.mapimage.value = pygame.image.l... | [
"0.5129216",
"0.5092046",
"0.4906114",
"0.48873883",
"0.48667443",
"0.4805125",
"0.47860113",
"0.4752473",
"0.47371283",
"0.45888057",
"0.4583458",
"0.45654127",
"0.45034736",
"0.44744822",
"0.44537768",
"0.44424555",
"0.4437613",
"0.44323862",
"0.4431255",
"0.44052202",
"0.4... | 0.7454031 | 0 |
Set the appropriate head/tail nodes of the fragments tree, modifying the given syncmap (always pass a copy of it!). | def set_head_tail_format(syncmap, head_tail_format=None):
self.log([u"Head/tail format: '%s'", str(head_tail_format)])
tree = syncmap.fragments_tree
head = tree.get_child(0)
first = tree.get_child(1)
last = tree.get_child(-2)
tail = tree.get_child(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self, sync_map_format, output_file_path, parameters=None):\n def select_levels(syncmap, levels):\n \"\"\"\n Select the given levels of the fragments tree,\n modifying the given syncmap (always pass a copy of it!).\n \"\"\"\n self.log([u\"Level... | [
"0.5799475",
"0.5399805",
"0.52214706",
"0.51202184",
"0.50646895",
"0.5000751",
"0.49190965",
"0.48311803",
"0.47621846",
"0.46972978",
"0.46885705",
"0.46759856",
"0.46574265",
"0.45800754",
"0.45796484",
"0.45722967",
"0.45618415",
"0.4549599",
"0.45358542",
"0.45320705",
... | 0.5746928 | 1 |
Perform Linking of features in trajectories. The linking determines which of the features detected in a specific timestep is most likely identical to an existing feature in the previous timestep. For each existing feature, the movement within a time step is extrapolated based on the velocities in a number previous time... | def linking_trackpy(
features,
field_in,
dt,
dxy,
dz=None,
v_max=None,
d_max=None,
d_min=None,
subnetwork_size=None,
memory=0,
stubs=1,
time_cell_min=None,
order=1,
extrapolate=0,
method_linking="random",
adaptive_step=None,
adaptive_stop=None,
cel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tracking(main_params, link_params, check_params, manual_log_path=''):\n \n vect_path, csv_path, dest_path, verbose = main_params\n createCSV, forced_matching, search_range, memory, adaptive_stop = link_params\n params = {'r':search_range, 'm':memory}\n check, img_path, size = check_params\n \... | [
"0.5679041",
"0.56064534",
"0.5307301",
"0.5280053",
"0.5204079",
"0.5160614",
"0.514337",
"0.5073769",
"0.50675637",
"0.5062969",
"0.5062473",
"0.5056669",
"0.50469744",
"0.50466573",
"0.50402105",
"0.5025745",
"0.49864918",
"0.4980299",
"0.49660167",
"0.49375853",
"0.493033... | 0.64387393 | 0 |
add cell time as time since the initiation of each cell | def add_cell_time(t: pd.DataFrame, cell_number_unassigned: int):
# logging.debug('start adding time relative to cell initiation')
t_grouped = t.groupby("cell")
t["time_cell"] = t["time"] - t.groupby("cell")["time"].transform("min")
t["time_cell"] = pd.to_timedelta(t["time_cell"])
t.loc[t["cell"] =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def increment_time_step(self):\n for grid in self.get_grid_list():\n try:\n self[grid].increment_time_step()\n except AttributeError:\n pass",
"def update_time(self):\n pass # Do nothing",
"def update_time(self):\n time_metrics = self._f... | [
"0.62415624",
"0.6129399",
"0.60363364",
"0.60304415",
"0.59488475",
"0.59046245",
"0.5899519",
"0.58547056",
"0.58412486",
"0.58412486",
"0.58203864",
"0.58203864",
"0.58203864",
"0.5754435",
"0.57536703",
"0.5733048",
"0.5703268",
"0.57000446",
"0.5699983",
"0.5695495",
"0.... | 0.77058333 | 0 |
Remaps the particles to new cells given an input map and the current particle. Helper function that is designed to be vectorized with np.vectorize | def remap_particle_to_cell_nv(particle_cell_map, input_particle):
return particle_cell_map[input_particle] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remap_partition(particles):\n remap_gid_partition_cython(particles, gl_to_loc_map_b.value)\n return particles",
"def update_poi (POIn, POInm1, new, current_cell_mask):\n row, col = cuda.grid(2)\n\n if row < POIn.shape[0] and col < POIn.shape[1]:\n POIn[row,col] = 0 \n ... | [
"0.6815664",
"0.62032104",
"0.57686967",
"0.57509863",
"0.5745527",
"0.57149065",
"0.5694885",
"0.569227",
"0.5682248",
"0.5672766",
"0.563928",
"0.56127995",
"0.561089",
"0.5545472",
"0.55257684",
"0.5508094",
"0.5507648",
"0.5491645",
"0.54811716",
"0.54694974",
"0.5465449"... | 0.7515533 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.