query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Returns the Extreme Points of a contour | def extremePointsTup(cnt):
leftmost = tuple(cnt[cnt[:,:,0].argmin()][0])
rightmost = tuple(cnt[cnt[:,:,0].argmax()][0])
topmost = tuple(cnt[cnt[:,:,1].argmin()][0])
bottommost = tuple(cnt[cnt[:,:,1].argmax()][0])
return (leftmost, rightmost, topmost, bottommost) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extent(self):\n\n x = np.array([0, self.nx]) * self.dx + self.corner_grid.x0\n ypoint = [0, self.ny] if self.origin == 'lower-left' else [self.ny, 0]\n y = np.array(ypoint) * self.dy + self.corner_grid.y0\n\n return [x[0], x[1], y[0], y[1]]",
"def get_cntr_points(self, contour, im... | [
"0.62368226",
"0.61413515",
"0.6069171",
"0.59376955",
"0.5935706",
"0.5870097",
"0.5838518",
"0.5815217",
"0.5814764",
"0.57886654",
"0.5784005",
"0.57744175",
"0.57623637",
"0.574569",
"0.57198995",
"0.5686353",
"0.567736",
"0.56730115",
"0.563668",
"0.562359",
"0.56228966"... | 0.53200597 | 63 |
Draws a line btw 2 points onto img. | def drawLine(img, start, end, color = (0,0,255), thickness = 3):
cv2.line(img, start, end, color, thickness) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_line(image, pt1, pt2, color):\n\n\t# TODO -> Add your line drawing code here\n\n\t# Sample code to draw white dots at pt1 and pt2 positions\n\tset_pixel(image, pt1, color)\n\tset_pixel(image, pt2, color)",
"def drawLine(img, p1, p2, color):\n p1 = (int(p1[0]*DISPLAY_SCALE), int(p1[1]*DISPLAY_SCAL... | [
"0.8275707",
"0.81932473",
"0.80199265",
"0.78069526",
"0.7677928",
"0.7619576",
"0.7494372",
"0.73717725",
"0.728805",
"0.72605205",
"0.72182786",
"0.7209821",
"0.71752787",
"0.7166648",
"0.7115649",
"0.7092167",
"0.7074217",
"0.7073948",
"0.705889",
"0.70519125",
"0.7017697... | 0.7854153 | 3 |
Draws an ellipse onto img. | def drawEllipse(img, center, axes, angle, startAngle=0, endAngle=360, color = (0,0,255), fill = -1):
cv2.ellipse(img, center, axes, angle, startAngle, endAngle, color, fill) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __DrawEllipse(self, image, rectangule, color):\n cv2.ellipse(image, rectangule, color, 2)\n points = cv2.boxPoints(rectangule)\n for i in range(4):\n cv2.line(image, tuple(np.array(points[i], np.int32)),\n tuple(np.array(points[(i + 1) % 4], np.int32)), color... | [
"0.7779611",
"0.76049566",
"0.7396142",
"0.71519816",
"0.71197325",
"0.7035058",
"0.69604146",
"0.69507027",
"0.694127",
"0.6926593",
"0.6876455",
"0.68486536",
"0.6809056",
"0.6794539",
"0.67827743",
"0.675281",
"0.6747277",
"0.6746051",
"0.6743991",
"0.6705124",
"0.66552705... | 0.8222343 | 0 |
Draws a nearest fitting ellipse to a contour | def drawFitEllipse(img, cnt):
d = fitEllipse(cnt)
cv2.ellipse(img, d["center"], (d["major"], d["minor"]), d["angle"]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fit_ellipse(x,y):\r\n \r\n def fit(x,y):\r\n x = x[:,np.newaxis]\r\n y = y[:,np.newaxis]\r\n D = np.hstack((x*x, x*y, y*y, x, y, np.ones_like(x)))\r\n S = np.dot(D.T,D)\r\n C = np.zeros([6,6])\r\n C[0,2] = C[2,0] = 2; C[1,1] = -1\r\n E, V = np.linalg.eig... | [
"0.67455137",
"0.64667124",
"0.64615935",
"0.64611447",
"0.6340184",
"0.6303694",
"0.61486316",
"0.606283",
"0.59977704",
"0.59962744",
"0.59726065",
"0.59513366",
"0.59466463",
"0.59445435",
"0.5934852",
"0.5898245",
"0.5885931",
"0.585715",
"0.5832287",
"0.5831045",
"0.5805... | 0.66356623 | 1 |
Saves a list of images to a file | def saveImgs(img, filename=None):
if filename is None:
date = time.strftime("%Y%m%d")
filename = "T" + str(date)
jpg = ".jpg"
count = 0
for item in img:
name = filename + str(count) + jpg
cv2.imwrite(name, item)
count += 1
else:
for i in range(0, len(img)):
cv2.imwrite(filename[i], img[i]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saveImages(image_list, name_list, path):\n\ti = 0\n\tfor image in image_list:\n\t\tname = name_list[i]\n\t\tio.imsave(path + \"/\" + name + \".jpg\", image)\n\t\ti += 1",
"def save_images(img_list, img_saving_path, label_list, label_saving_path):\n img_index = SAVING_INDEX\n label_index=SAVING_INDEX\n ... | [
"0.8203593",
"0.78217983",
"0.77478117",
"0.75045323",
"0.7440167",
"0.74169284",
"0.73372126",
"0.7309631",
"0.7289666",
"0.72501945",
"0.72411066",
"0.7206147",
"0.7189419",
"0.7174229",
"0.71612227",
"0.71528816",
"0.714284",
"0.7080968",
"0.69198835",
"0.69140065",
"0.690... | 0.745483 | 4 |
Splits an MPS tensor in two MPS tensors. | def svd_split(m: np.ndarray):
Dl, d, Dr = m.shape
u, s, v = np.linalg.svd(m.reshape(Dl * 2, Dr * d // 2))
D_middle = min(u.shape[-1], v.shape[0])
s = np.diag(s[:D_middle])
u = u[:, :D_middle].reshape((Dl, 2, D_middle))
sv = s.dot(v[:D_middle]).reshape((D_middle, d // 2, Dr))
return u, sv | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_and_concat_model():\n x = tf.keras.Input(shape=[224, 224, 3, ])\n # TODO: implement split for the following commented out method of splitting\n # y1 = x[:, :100, :, :]\n # y2 = x[:, 101:, :, :]\n y1, y2 = tf.split(x, [100, 124], 1)\n y1 = tf.nn.relu(y1)\n y2 = tf.keras.layers.BatchNo... | [
"0.5394845",
"0.5314789",
"0.5299116",
"0.5235955",
"0.5227186",
"0.50350887",
"0.5022935",
"0.49576718",
"0.4954816",
"0.48991227",
"0.4898438",
"0.48950312",
"0.48836675",
"0.4877415",
"0.48702902",
"0.48522276",
"0.48391676",
"0.4820576",
"0.481683",
"0.48153678",
"0.47947... | 0.0 | -1 |
r""" Summary Plot probability density distribution. No documentation as of 20181101. Future Development 1. Add option to view by Sacramento Index Water Year Types. | def __future__PlotPD(DF):
# TODOC: Provide docstring.
# <JAS 2018-11-01>
# Get list of Part B to verify DataFrame meets procedure specifications.
var_list = set(DF.columns.get_level_values('Part B'))
# Determine number of axes in the figure.
n_var = len(var_list)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distribution_plot(data):\r\n ready_data = sorted((data))\r\n fit = stats.norm.pdf(ready_data, np.mean(ready_data), np.std(ready_data))\r\n plt.plot(ready_data, fit, '-o')\r\n plt.ylabel(\"Prob\")\r\n plt.xlabel(\"Prices\")\r\n plt.title(\"Distribution of prices (Under ... | [
"0.61590064",
"0.58937997",
"0.5824077",
"0.57526475",
"0.57054085",
"0.5644698",
"0.56097686",
"0.55820024",
"0.5578682",
"0.55750066",
"0.5565971",
"0.5520006",
"0.55099964",
"0.5509225",
"0.5507384",
"0.5505618",
"0.5455496",
"0.54332995",
"0.54244936",
"0.5423401",
"0.540... | 0.0 | -1 |
Getter for accepted_records list. | def get_dataset(self):
return self.accepted_records | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validatedlist(self):\n return self.caller.player_ob.db.validated_list or []",
"def acceptedlines(self):\n return self._acceptedlines",
"def records(self):\n return self._records",
"def records(self):\n return self.db_data['records']",
"def get_accepted_players(self):\n ... | [
"0.62575746",
"0.6212596",
"0.5994255",
"0.58803505",
"0.5832748",
"0.5473037",
"0.5401151",
"0.52982515",
"0.52567697",
"0.5111115",
"0.51070464",
"0.50864327",
"0.50864327",
"0.50864327",
"0.50864327",
"0.506505",
"0.5031924",
"0.50122136",
"0.5009222",
"0.5007536",
"0.5006... | 0.65625346 | 0 |
Get the dictionary of substitution values for the correlation matrix | def get_corr_subs_values(corr):
subs_dict = {}
n_dim = corr.shape[0]
for irow in xrange(0, n_dim):
for icol in xrange(irow + 1, n_dim):
subs_dict['rho_p{}p{}'.format(irow, icol)] = corr[irow, icol]
return subs_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_corr(self):\n return self.corr_matrix, self.corr_signature",
"def calc_qcorr(self) -> Dict[int, float]:\n return self._calc_qcorr",
"def correlation(row):\n return row['correlation']",
"def correlation_matrix(self, attr_list, method=\"pearson\"):\n corr_matrix = self.data.corr... | [
"0.60773355",
"0.5937705",
"0.5928046",
"0.58747303",
"0.5837948",
"0.5746387",
"0.5676144",
"0.56687707",
"0.5661569",
"0.56377834",
"0.5631204",
"0.55615264",
"0.55370194",
"0.5509791",
"0.5488653",
"0.5486903",
"0.5473979",
"0.5458713",
"0.5447157",
"0.5421518",
"0.5372255... | 0.7407273 | 0 |
Sets the usercode for this object | def setUserCode(self, userCode):
self.userCode = userCode
logger.debug('user code set to: %s' % self.userCode) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def code(self, value: str) -> None:\n self._code = value",
"def code(self, code):\n\n self._code = code",
"def code(self, code: str):\n\n self._code = code",
"def code(self, code: int):\n\n self._code = code",
"async def async_set_zwave_lock_user_code(self, user_num: int, code: ... | [
"0.67118514",
"0.6658629",
"0.66468185",
"0.6457196",
"0.6357797",
"0.63123024",
"0.63053495",
"0.62903464",
"0.62903464",
"0.621532",
"0.621532",
"0.6189747",
"0.6189747",
"0.6172561",
"0.60310847",
"0.59753853",
"0.5957022",
"0.5828828",
"0.58207273",
"0.5805788",
"0.580476... | 0.820097 | 0 |
Creates a digraph (a tuple of chars) from the given row + col numbers. | def create_digraph(self, frow, fcol, srow, scol: int) -> tuple:
return (self.key[frow][fcol], self.key[srow][scol]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_adjactent(r,c, num_rows, num_columns): \n return [(adj_row, adj_col)\n for adj_row in [r+x for x in range(-1,2) if r+x >= 0 and r+x < num_rows]\n for adj_col in [c+x for x in range(-1,2) if c+x >= 0 and c+x < num_columns]\n if (adj_row, adj_col) != (r,c)]",
"def cells(... | [
"0.59369355",
"0.5887162",
"0.5854919",
"0.58440906",
"0.5814342",
"0.57257086",
"0.57229996",
"0.57114524",
"0.56640327",
"0.5640435",
"0.56323695",
"0.56259304",
"0.5625056",
"0.5571399",
"0.5528994",
"0.54961437",
"0.5493712",
"0.549109",
"0.5478688",
"0.5463726",
"0.54447... | 0.696209 | 0 |
Regularize the fitness vector to sum to 1. | def regularization(fitness):
if all(val == 0 for val in fitness):
return np.array([1/i for i in range(fitness.shape[0])])
return fitness/sum(fitness) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fitness(self):\n # TO BE DECIDED\n return 1",
"def fitness(self):\n pass",
"def adapt(self, fitness: np.ndarray):\n max_val = np.amax(fitness, axis=0)\n min_val = np.amin(fitness, axis=0)\n self.values = np.multiply(\n self.initial_values,\n n... | [
"0.6883125",
"0.6712311",
"0.65367615",
"0.6306168",
"0.62883186",
"0.62564754",
"0.6230146",
"0.6203829",
"0.6160371",
"0.6144281",
"0.61230785",
"0.61032933",
"0.6061126",
"0.60601443",
"0.59466374",
"0.59377205",
"0.59131664",
"0.5893865",
"0.58265716",
"0.58128595",
"0.57... | 0.82899326 | 0 |
return the number of subscribers from an Reddit API | def number_of_subscribers(subreddit):
import requests
resInf = requests.get("https://www.reddit.com/r/{}/about.json"
.format(subreddit),
headers={"User-Agent": "My-User-Agent"},
allow_redirects=False)
if resInf.status_code... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_of_subscribers(subreddit):\n\n url = \"https://www.reddit.com/r/{}/about.json\".format(subreddit)\n headers = {\"User-Agent\": \"my-integration/1.2.3\"}\n\n response = get(url=url, headers=headers)\n\n if response.status_code == 200:\n # print(response.json())\n\n response_json... | [
"0.8690226",
"0.852827",
"0.85145426",
"0.8506312",
"0.8458378",
"0.84446746",
"0.84387857",
"0.8436107",
"0.84342146",
"0.8407898",
"0.837066",
"0.8369056",
"0.8357816",
"0.83259296",
"0.83199066",
"0.8300205",
"0.828392",
"0.82822955",
"0.8178302",
"0.80417335",
"0.7842824"... | 0.83919066 | 10 |
Converts minutes to seconds for use when comparing timeframes with timestamps. Note that unix | def minutes_to_seconds(minutes):
return minutes * 60 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minutes_to_seconds( minutes: str ) -> int:\r\n return int(minutes)*60",
"def minutes_to_seconds(minutes) -> int:\n return int(minutes) * 60",
"def calculate_seconds_in_minutes(minutes):\n return int(minutes * 60)",
"def timestamp2sec(timestamp):\n return (int(timestamp.seconds) + 60 * int(t... | [
"0.77763426",
"0.7723302",
"0.74715537",
"0.7301524",
"0.7070065",
"0.7061977",
"0.70093197",
"0.69206357",
"0.6919833",
"0.69142526",
"0.6730017",
"0.6719046",
"0.6710146",
"0.6676277",
"0.6658639",
"0.66509336",
"0.6617928",
"0.6600639",
"0.6585108",
"0.6553683",
"0.6499296... | 0.77987653 | 0 |
Returns model class from name. | def get_feature_extractor(name):
if name == "MLP":
return MLP
elif name == "CNN":
return CNN
elif name == "Fixup":
return FixupCNN
else:
raise ValueError("Specified model not found!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_model_by_name(cls, name):\n model_name = inflection.camelize(name) # class name of the model to use\n model = cls.models[model_name]\n return model",
"def get_model(name):\n # Evil reflection\n model_name = name.lower()\n model_module = importlib.import_module('.'+model_nam... | [
"0.8350521",
"0.80171317",
"0.7696668",
"0.75552994",
"0.7503981",
"0.74854",
"0.7346131",
"0.7328943",
"0.7284878",
"0.7277501",
"0.72243315",
"0.7159031",
"0.7124333",
"0.70715046",
"0.70241",
"0.6967527",
"0.68931997",
"0.67149365",
"0.6668543",
"0.66665435",
"0.6635264",
... | 0.0 | -1 |
Save the current data frame as a csv filter | def save_csv(self, filename): # DONE
self.data.to_csv(filename) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_csv(self):\n self.tableView.df.to_csv('Data export.csv', index=False)\n print('CSV file exported')",
"def save(df, save_preprocessed_dataframe_path, name):\n\n df.to_csv(save_preprocessed_dataframe_path + name + '.csv', index=False)",
"def on_export_button(self, event):\n wild... | [
"0.7141041",
"0.69042283",
"0.6894039",
"0.6831629",
"0.6784716",
"0.671172",
"0.6711132",
"0.66984373",
"0.6697193",
"0.6691398",
"0.6686486",
"0.6665298",
"0.6656953",
"0.66529083",
"0.66270906",
"0.6581081",
"0.6573089",
"0.65584344",
"0.65407205",
"0.6530168",
"0.6512845"... | 0.7549787 | 0 |
Remove all entries from the_dict whose values cannot be converted to integers. | def remove_non_integers(the_dict):
return the_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _remove_nan(parsed_dictionary):\n for key, value in parsed_dictionary.items():\n if isinstance(value, np.ndarray):\n non_nan_value = np.nan_to_num(value, nan=123456789, posinf=2e308, neginf=-2e308)\n parsed_dictionary.update({key: non_nan_value})\... | [
"0.6412456",
"0.62956",
"0.62734354",
"0.61735386",
"0.609931",
"0.6084343",
"0.60367",
"0.5987266",
"0.5975014",
"0.59294957",
"0.58881366",
"0.5869249",
"0.58423907",
"0.5836237",
"0.582971",
"0.5812676",
"0.5804835",
"0.577178",
"0.5764925",
"0.5743125",
"0.5699217",
"0.... | 0.86471814 | 0 |
Generates a DIMENSIONSdimensional dataset consisting of uniformly distributed datapoints. The data is written to "OUTPUT.csv", the metadata to "OUTPUT.yaml". | def uniform(name, output, dimensions):
UniformDatasetProcessor(name=name,
output_filename=output,
dimensions=dimensions).process() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_dataset(output_dim=14, num_examples=10000):\n def int2vec(x, dim=output_dim):\n out = np.zeros(dim)\n binrep = np.array(list(np.binary_repr(x))).astype('int')\n out[-len(binrep):] = binrep\n return out\n\n x_left_int = (np.random.rand(num_examples) * 2 ** (output_dim ... | [
"0.66922957",
"0.6520077",
"0.6514204",
"0.6334754",
"0.63172555",
"0.628898",
"0.6126599",
"0.610102",
"0.6041607",
"0.6001088",
"0.59859574",
"0.5982031",
"0.59705704",
"0.59334403",
"0.59123117",
"0.59010655",
"0.58769643",
"0.5874625",
"0.5873734",
"0.5844333",
"0.5820533... | 0.5928038 | 14 |
Generates a DIMENSIONSdimensional dataset consisting of HOTSPOTS amount of hotspots. The data is written to "OUTPUT.csv", the metadata to "OUTPUT.yaml". | def hotspots(name, output, dimensions, hotspots):
HotspotsDatasetProcessor(name=name,
output_filename=output,
dimensions=dimensions,
hotspot_count=hotspots).process() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_dataset(self):\n\t\timg_set = []\n\t\tqa_set = []\n\t\tfor i in range(self.config.dataset_size):\n\t\t\timg, r = self.generate_image()\n\t\t\tq = self.generate_question()\n\t\t\ta = self.generate_answer(r, q)\n\t\t\timg_sample = {\n\t\t\t\t'id': i,\n\t\t\t\t'image': img.tolist()\n\t\t\t}\n\t\t\timg_se... | [
"0.6725107",
"0.6377063",
"0.6022692",
"0.5932971",
"0.5904078",
"0.5900421",
"0.5895363",
"0.5833199",
"0.5780031",
"0.57734895",
"0.5696269",
"0.5643451",
"0.55681753",
"0.55621475",
"0.555937",
"0.5557124",
"0.55400264",
"0.5519088",
"0.5497131",
"0.54878366",
"0.5481854",... | 0.6784829 | 0 |
Return a vector equal to this one rotated counterclockwise by the given angle. | def rotatedBy(self, angle):
x, y = self.x, self.y
c, s = cos(angle), sin(angle)
return Vector((c * x) - (s * y), (s * x) + (c * y)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate(self, angle):\r\n radians = angle*pi/180\r\n return Vector(self.x*cos(radians) - self.y*sin(radians),\r\n self.x*sin(radians) + self.y*cos(radians))",
"def rotate_clockwise(self, angle):\r\n angle = degrees_to_radians(angle)\r\n current_angle = atan(sel... | [
"0.80194724",
"0.7856469",
"0.7705653",
"0.74161404",
"0.7405685",
"0.73432416",
"0.7264688",
"0.7259307",
"0.72136265",
"0.71424145",
"0.7124553",
"0.69139045",
"0.6894555",
"0.6886583",
"0.6868462",
"0.6814357",
"0.67919666",
"0.6749294",
"0.6721626",
"0.66364795",
"0.65921... | 0.81299716 | 0 |
Find the outside boundary of the given boxes. | def union_boxes(boxes: List["Box"]) -> "Box":
left, top, right, bottom = float("inf"), float("inf"), float("-inf"), float("-inf")
for box in boxes:
l, t, r, b = box.coordinates
left = min(left, l)
top = min(top, t)
right = max(right, r)
bottom = max(bottom, b)
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def containing(*boxes):\n if not boxes:\n raise ValueError('At least one bounding box must be specified')\n boxes_objs = map(BoundingBox, boxes)\n start = boxes_objs[0].start\n end = boxes_objs[0].end\n for box in boxes_objs[1:]:\n start = np.minimum(start, box.start)\n end = np.maximum(end, box.end)... | [
"0.6991025",
"0.685841",
"0.67465067",
"0.6645942",
"0.6629786",
"0.6614065",
"0.6514421",
"0.6514421",
"0.6457277",
"0.64478195",
"0.6435729",
"0.639448",
"0.62931496",
"0.62832826",
"0.62784",
"0.6214227",
"0.6211104",
"0.6209543",
"0.6208336",
"0.6189129",
"0.61881757",
... | 0.0 | -1 |
Returns the left, top, right, bottom coordinates of the box | def coordinates(self) -> Tuple[float, float, float, float, float]:
return (self.x, self.y, self.x + self.width, self.y + self.height) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_box_coordinates(self):\n return QRect(self.box_begin,self.box_end)",
"def get_box_coordinates(self):\n return self.box_coordinates",
"def getLocation(bounding_box):\n ymin, xmin, ymax, xmax = bounding_box\n w=1280\n h=720\n left, right, top, bottom = (xmin ... | [
"0.8167447",
"0.7617109",
"0.7538739",
"0.74074924",
"0.72393316",
"0.72256863",
"0.7198177",
"0.7191977",
"0.7184502",
"0.71791744",
"0.71532327",
"0.71178836",
"0.70971406",
"0.7078757",
"0.70722544",
"0.7051677",
"0.7041489",
"0.7021559",
"0.7016818",
"0.69714504",
"0.6956... | 0.6782591 | 33 |
Determines whether the center of this box is contained inside another box with a soft margin. | def is_in(self, other: "Box", soft_margin: Dict = None) -> bool:
other = other.copy()
x, y = self.center
if soft_margin is not None:
other.pad(**soft_margin)
xa, ya, xb, yb = other.coordinates
return xa <= x <= xb and ya <= y <= yb | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contains(self, other: 'BaseBox'):\n return np.all(other.lower >= self.lower) and np.all(other.upper <= self.upper)",
"def is_center(self):\n if self.pupils_located:\n return self.is_right() is not True and self.is_left() is not True",
"def __word_is_near_border(bbox, margin, window... | [
"0.653653",
"0.64415926",
"0.62495285",
"0.6203098",
"0.6197216",
"0.6195328",
"0.6099794",
"0.6023828",
"0.59713674",
"0.59113157",
"0.5874914",
"0.58693755",
"0.586879",
"0.58515793",
"0.5796519",
"0.57880294",
"0.57776576",
"0.5775554",
"0.5774696",
"0.5739932",
"0.5722887... | 0.78895175 | 0 |
Returns this validator's error message. | def get_help_text(self):
msg = (
ungettext(
"Your password must contain %d or more uppercase letter.",
"Your password must contain %d or more uppercase letters.",
self.get_min_count(),
)
% self.get_min_count()
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_message(self) -> str:\n return self._error_message",
"def error_message(self):\n\n return self._error_message",
"def error_message(self):\n # type: () -> string_types\n return self._error_message",
"def get_error_message(self):\n\n return self.err_message",
"def... | [
"0.853024",
"0.849909",
"0.84819084",
"0.8437801",
"0.8362509",
"0.8306454",
"0.82648945",
"0.82648945",
"0.82648945",
"0.8209318",
"0.8191341",
"0.81733763",
"0.8122926",
"0.7964307",
"0.7964307",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098... | 0.0 | -1 |
Returns this validator's error message. | def get_help_text(self):
msg = (
ungettext(
"Your password must contain %d or more lowercase letter.",
"Your password must contain %d or more lowercase letters.",
self.get_min_count(),
)
% self.get_min_count()
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_message(self) -> str:\n return self._error_message",
"def error_message(self):\n\n return self._error_message",
"def error_message(self):\n # type: () -> string_types\n return self._error_message",
"def get_error_message(self):\n\n return self.err_message",
"def... | [
"0.853024",
"0.849909",
"0.84819084",
"0.8437801",
"0.8362509",
"0.8306454",
"0.82648945",
"0.82648945",
"0.82648945",
"0.8209318",
"0.8191341",
"0.81733763",
"0.8122926",
"0.7964307",
"0.7964307",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098... | 0.0 | -1 |
Returns this validator's error message. | def get_help_text(self):
msg = (
ungettext(
"Your password must contain %d or more alphabetic letter.",
"Your password must contain %d or more alphabetic letters.",
self.get_min_count(),
)
% self.get_min_count()
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_message(self) -> str:\n return self._error_message",
"def error_message(self):\n\n return self._error_message",
"def error_message(self):\n # type: () -> string_types\n return self._error_message",
"def get_error_message(self):\n\n return self.err_message",
"def... | [
"0.853024",
"0.849909",
"0.84819084",
"0.8437801",
"0.8362509",
"0.8306454",
"0.82648945",
"0.82648945",
"0.82648945",
"0.8209318",
"0.8191341",
"0.81733763",
"0.8122926",
"0.7964307",
"0.7964307",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098... | 0.0 | -1 |
Returns this validator's error message. | def get_help_text(self):
msg = (
ungettext(
"Your password must contain less than %d occurrences of the same letter.",
"Your password must contain less than %d occurrences of the same letter.",
self.get_max_count(),
)
% self.get... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_message(self) -> str:\n return self._error_message",
"def error_message(self):\n\n return self._error_message",
"def error_message(self):\n # type: () -> string_types\n return self._error_message",
"def get_error_message(self):\n\n return self.err_message",
"def... | [
"0.853024",
"0.849909",
"0.84819084",
"0.8437801",
"0.8362509",
"0.8306454",
"0.82648945",
"0.82648945",
"0.82648945",
"0.8209318",
"0.8191341",
"0.81733763",
"0.8122926",
"0.7964307",
"0.7964307",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098... | 0.0 | -1 |
Returns this validator's error message. | def get_help_text(self):
msg = (
ungettext(
"Your password must contain %d or more Non-Alphanumeric character.",
"Your password must contain %d or more Non-Alphanumeric characters.",
self.get_min_count(),
)
% self.get_min_count(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_message(self) -> str:\n return self._error_message",
"def error_message(self):\n\n return self._error_message",
"def error_message(self):\n # type: () -> string_types\n return self._error_message",
"def get_error_message(self):\n\n return self.err_message",
"def... | [
"0.853024",
"0.849909",
"0.84819084",
"0.8437801",
"0.8362509",
"0.8306454",
"0.82648945",
"0.82648945",
"0.82648945",
"0.8209318",
"0.8191341",
"0.81733763",
"0.8122926",
"0.7964307",
"0.7964307",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098... | 0.0 | -1 |
Returns this validator's error message. | def get_help_text(self):
msg = (
ungettext(
"Your password must contain %d or more digit.",
"Your password must contain %d or more digits.",
self.get_min_count(),
)
% self.get_min_count()
)
return msg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_message(self) -> str:\n return self._error_message",
"def error_message(self):\n\n return self._error_message",
"def error_message(self):\n # type: () -> string_types\n return self._error_message",
"def get_error_message(self):\n\n return self.err_message",
"def... | [
"0.853024",
"0.849909",
"0.84819084",
"0.8437801",
"0.8362509",
"0.8306454",
"0.82648945",
"0.82648945",
"0.82648945",
"0.8209318",
"0.8191341",
"0.81733763",
"0.8122926",
"0.7964307",
"0.7964307",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098195",
"0.79098... | 0.0 | -1 |
Returns True if person_1 lives on a floor immediately above or below person_2. | def adjacent_floor(person_1, person_2):
return abs(person_1 - person_2) == 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def higher_floor(person_1, person_2):\n return person_1 > person_2",
"def check_inside(self, person):\n p_top_x = person[0] + self.padding\n p_left_y = person[1] + self.padding\n p_bottom_x = person[2] - self.padding\n p_right_y = person[3] - self.padding\n\n return p_top_x ... | [
"0.77355796",
"0.66020983",
"0.6185451",
"0.5966002",
"0.59605634",
"0.5957124",
"0.5929882",
"0.5928673",
"0.59110063",
"0.5895963",
"0.581629",
"0.57970065",
"0.5794381",
"0.57892084",
"0.57874364",
"0.5784207",
"0.57775545",
"0.5764384",
"0.5752351",
"0.5729659",
"0.572685... | 0.7591348 | 1 |
This will clear the db after each test | def tearDown(self):
Review.query.delete() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n te... | [
"0.89044493",
"0.89044493",
"0.89044493",
"0.89044493",
"0.89044493",
"0.89044493",
"0.8740075",
"0.8740075",
"0.8740075",
"0.8740075",
"0.8740075",
"0.8740075",
"0.8740075",
"0.8740075",
"0.8740075",
"0.8489243",
"0.84169805",
"0.84093654",
"0.8405529",
"0.8405529",
"0.83240... | 0.0 | -1 |
Gets a random question that hasn't been seen in the current session. Optional exclude can be used to further questions to be excluded | def get_random(user_state, exclude_pks=None):
if user_state.current_session:
seen_pks = [qanda.question.pk for qanda in user_state.session_history]
seen_pks = seen_pks + exclude_pks if exclude_pks else seen_pks
qs = Question.objects.exclude(pk__in=seen_pks)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_question(self):\n available_qs = self.available_qs\n if available_qs.exists():\n return random.choice(available_qs)",
"def choose_random(self, exclude):\n other_edges = list(set(self.vertices()) - set(exclude))\n return random.choice(other_edges)",
"def get... | [
"0.7075658",
"0.63972825",
"0.6061905",
"0.59602034",
"0.58559525",
"0.57101595",
"0.5704721",
"0.56581724",
"0.56101656",
"0.5472467",
"0.5468189",
"0.54532266",
"0.54418176",
"0.5401206",
"0.5394314",
"0.53381675",
"0.53112036",
"0.5308834",
"0.5308732",
"0.5267203",
"0.525... | 0.7309913 | 0 |
Helper function to parse default boolean values. | def _parse_bool(self, value):
if isinstance(value, string_types):
return value.strip().lower() in ['true', '1', 't', 'y', 'yes']
return bool(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_bool_str(attr, key, default='False'):\n return attr.get(key, default).strip().lower() in ['true', '1', 't', 'y', 'yes']",
"def test_boolean_default_values(self):\n true_values = ['True', 'true', 'True', 'YES', 'yes', 'y', 'Y', 'Yes']\n false_values = ['FALSE', 'false', 'False', 'NO', '... | [
"0.71889156",
"0.68330115",
"0.6828692",
"0.6803678",
"0.679068",
"0.6773506",
"0.6739961",
"0.6705686",
"0.6620569",
"0.65791374",
"0.65027505",
"0.64707613",
"0.6430233",
"0.6377602",
"0.6373676",
"0.6345885",
"0.63440776",
"0.63409495",
"0.6334087",
"0.6301347",
"0.6299644... | 0.679545 | 4 |
AsyncHTTPTestCase method to get the application. | def get_app(self):
return Application() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app():\n _app = create_app(TestConfig)\n ctx = _app.test_request_context()\n ctx.push()\n\n yield _app\n\n ctx.pop()",
"def app():\n _app = create_app(TestConfig)\n ctx = _app.test_request_context()\n ctx.push()\n\n yield _app\n\n ctx.pop()",
"def app():\n _app = create_app... | [
"0.69769716",
"0.69769716",
"0.69769716",
"0.6928216",
"0.68177694",
"0.67734",
"0.6719138",
"0.6637866",
"0.6496801",
"0.64721555",
"0.6461488",
"0.6457647",
"0.6432402",
"0.6415221",
"0.64088035",
"0.63817346",
"0.6335964",
"0.63167506",
"0.6300002",
"0.62895423",
"0.628606... | 0.5830748 | 91 |
Saves the contents of the database to a SQL file, closes the database connection, and removes the SQLite database file. | def disconnect(self):
self._save_database()
self.dbh.close()
self._remove_temporary_file() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_db(connection: sqlite3.Connection):\n connection.commit()\n connection.close()",
"def close(self):\n self.db.commit()\n self.db.close()",
"def erase_db(file):\n open(file, 'w').close()",
"def _close_database(self):\n assert self._conn is not None\n logging.i... | [
"0.7644851",
"0.7346661",
"0.72280455",
"0.7216578",
"0.7134091",
"0.69593006",
"0.69380033",
"0.6925411",
"0.68807894",
"0.68411654",
"0.6822344",
"0.6801787",
"0.6744285",
"0.6737509",
"0.67297715",
"0.6725927",
"0.6695166",
"0.665023",
"0.6646943",
"0.66396606",
"0.6638708... | 0.68720335 | 9 |
Return the device class of the sensor. | def device_class(self):
if self.values.primary.command_class == CommandClass.BATTERY:
return DEVICE_CLASS_BATTERY
if self.values.primary.command_class == CommandClass.METER:
return DEVICE_CLASS_POWER
if "Temperature" in self.values.primary.label:
return DEVICE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_class(self):\n return self.sensor_type[\"class\"]",
"def device_class(self):\n return SENSOR_TYPES[self.sensor][3].get(\"device_class\")",
"def device_class(self):\n return self._sensor_type",
"def device_class(self):\r\n return self._sensor_cfg[3]",
"def device_class... | [
"0.93628424",
"0.92430294",
"0.9240069",
"0.9161452",
"0.9161452",
"0.9156968",
"0.90412056",
"0.90412056",
"0.8956785",
"0.89529496",
"0.8950599",
"0.8919914",
"0.871994",
"0.8717259",
"0.87069035",
"0.8660478",
"0.8652474",
"0.83961546",
"0.83828783",
"0.8380708",
"0.838070... | 0.8152038 | 30 |
Return the device specific state attributes. | def extra_state_attributes(self):
attributes = super().extra_state_attributes
# add the value's label as property
attributes["label"] = self.values.primary.value["Selected"]
return attributes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\n return self.attr",
"def device_state_attributes(self):\n return self.attr",
"def device_state_attributes(self):\n return self._state_attrs",
"def device_state_attributes(self):\... | [
"0.88270175",
"0.8766329",
"0.8766329",
"0.87205243",
"0.87205243",
"0.8702202",
"0.8687991",
"0.8683084",
"0.86829257",
"0.86669654",
"0.85930043",
"0.85930043",
"0.85930043",
"0.85930043",
"0.85930043",
"0.85930043",
"0.85930043",
"0.85930043",
"0.85930043",
"0.85930043",
"... | 0.0 | -1 |
Tests Get S3 file object with HTTP 400 error. Looks like HTTP 400 is returned when AWS token expires and S3.Object.load is called. | def test_get_s3_file_object_http_400_error():
load_method = MagicMock(
side_effect=botocore.exceptions.ClientError(
{"Error": {"Code": "400", "Message": "Bad Request"}},
operation_name="mock load",
)
)
s3object = MagicMock(load=load_method)
client = Mock()
cli... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def s3_request(func):\n\n @wraps(func)\n def wrapper(url, *args, **kwargs):\n try:\n return func(url, *args, **kwargs)\n except ClientError as exc:\n if int(exc.response[\"Error\"][\"Code\"]) == 404:\n raise EnvironmentError(\"file {} not found\".format(url)... | [
"0.689217",
"0.689217",
"0.67839795",
"0.6775989",
"0.67050296",
"0.64077353",
"0.6343086",
"0.6282254",
"0.6250445",
"0.6249468",
"0.61789745",
"0.6170697",
"0.6160462",
"0.6156918",
"0.6114678",
"0.61083835",
"0.61020815",
"0.60811967",
"0.6067952",
"0.6065819",
"0.6043932"... | 0.822358 | 0 |
Tests whether token expiry error is handled as expected when uploading. This test is a lot like test_upload_expiry_error, but it doesn't have an error message returned from the server side. | def test_upload_failed_error(caplog):
caplog.set_level(logging.DEBUG, "snowflake.connector")
mock_resource, mock_object = MagicMock(), MagicMock()
mock_resource.Object.return_value = mock_object
mock_object.upload_file.side_effect = S3UploadFailedError("ExpiredToken")
client_meta = {
"cloud_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_rejects_expired_token(self):\n config.set(xsrf_token_key='abcdef')\n tool = utils.XsrfTool()\n token = tool.generate_token(12345, 'test_action')\n utils.set_utcnow_for_test(XsrfToolTests.TEST_NOW +\n datetime.timedelta(hours=4, minutes=1))\n ... | [
"0.665243",
"0.6563446",
"0.6519539",
"0.64222616",
"0.64215",
"0.63979995",
"0.6377785",
"0.6370475",
"0.6290832",
"0.6265365",
"0.6254155",
"0.6212012",
"0.6191202",
"0.61902195",
"0.6175181",
"0.6151367",
"0.612304",
"0.61046684",
"0.6091152",
"0.6067618",
"0.6060338",
"... | 0.613516 | 16 |
Tests whether token expiry error is handled as expected when downloading. | def test_download_expiry_error(caplog, sdkless):
if not sdkless:
caplog.set_level(logging.DEBUG, "snowflake.connector")
mock_resource = MagicMock()
mock_resource.download_file.side_effect = botocore.exceptions.ClientError(
{"Error": {"Code": "ExpiredToken", "Message": "Just testi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_raises_token_expired_when_applicable(self):\n\n badgr = self.get_badgr_setup()\n with vcr.use_cassette('tests/vcr_cassettes/no_valid_auth_token.yaml'):\n with self.assertRaises(exceptions.TokenAndRefreshExpiredError):\n badgr.get_from_server(self._sample_url)",
"d... | [
"0.69434726",
"0.6625364",
"0.661292",
"0.66064274",
"0.6582399",
"0.65703607",
"0.64370793",
"0.638288",
"0.63809365",
"0.6378637",
"0.6358407",
"0.6339325",
"0.63236105",
"0.6305248",
"0.62850416",
"0.62755096",
"0.62755096",
"0.6239545",
"0.62200946",
"0.621084",
"0.619396... | 0.5737266 | 71 |
Darknet Convolution2D followed by BatchNormalization and LeakyReLU. | def Conv_DW(filters, *args, **kwargs):
no_bias_kwargs = {"use_bias": False}
no_bias_kwargs.update(kwargs)
return compose(
DarknetConv2D(
filters=filters, kernel_size=(3, 3), *args, **no_bias_kwargs
),
# DarknetConv2D(filters=filters, kernel_size=(1, 1), *args, **no_bias_k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def darknet_CBL(*args, **kwargs):\n\n no_bias_kwargs = {'use_bias': False} # 没懂为啥用 no_bias\n no_bias_kwargs.update(kwargs)\n return compose(\n darknet_Conv2D(*args, **no_bias_kwargs),\n custom_batchnormalization(),\n LeakyReLU(alpha=0.1)\n )",
"def darknet_CBM(*args, **kwargs):\... | [
"0.7275458",
"0.69691545",
"0.6878348",
"0.6808404",
"0.6770899",
"0.66237885",
"0.6614636",
"0.65974915",
"0.6548843",
"0.6491272",
"0.6434564",
"0.64130753",
"0.6402858",
"0.6385945",
"0.63840675",
"0.6366999",
"0.63605446",
"0.63488716",
"0.63365954",
"0.6316349",
"0.63162... | 0.0 | -1 |
Project points on to a certain plane | def proj_to_plane(norm, d, pts):
a = norm[0]
b = norm[1]
c = norm[2]
p = []
for i in range(len(pts)):
x_p = pts[i][0]
y_p = pts[i][1]
z_p = pts[i][2]
if a != 0:
x_0 = (b * b + c * c) * x_p - a * b * y_p - a * c * z_p - a * d
y_0 = (b * 1.0 /... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project_points_plane(points, plane):\n return [project_point_plane(point, plane) for point in points]",
"def project_point_plane(point, plane):\n base, normal = plane\n normal = normalize_vector(normal)\n vector = subtract_vectors(point, base)\n snormal = scale_vector(normal, dot_vectors(vecto... | [
"0.7696628",
"0.76764196",
"0.72310543",
"0.7029505",
"0.6976156",
"0.6900769",
"0.68228364",
"0.6789635",
"0.6743912",
"0.6727117",
"0.67133766",
"0.6599827",
"0.6528678",
"0.6515337",
"0.6487927",
"0.64668167",
"0.6450935",
"0.64164233",
"0.63942987",
"0.6354725",
"0.632539... | 0.68060803 | 7 |
Transfer dcm to quaternion | def coor_to_quater(coordinate):
coord = np.transpose(coordinate)
r = R.from_dcm(coord)
q = r.as_quat()
# m = r.as_dcm()
return q.tolist() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dcm_to_quaternions(dcm):\n trace = np.trace(dcm)\n b_2 = (1/4)*np.array([(1+trace), (1 + 2*dcm[0, 0] - trace), (1 + 2*dcm[1, 1] - trace), (1 + 2*dcm[2, 2] - trace)])\n argmax = np.argmax(b_2)\n b = np.zeros(4)\n b[argmax] = np.sqrt(b_2[argmax])\n\n # There is probably a cleaner way to do thes... | [
"0.7474201",
"0.7113331",
"0.7103733",
"0.70882505",
"0.69679654",
"0.68895775",
"0.67082304",
"0.67016673",
"0.66017455",
"0.65504813",
"0.6456338",
"0.64162135",
"0.635974",
"0.6248495",
"0.62439275",
"0.61844575",
"0.6140531",
"0.6115136",
"0.6067424",
"0.60571414",
"0.603... | 0.614215 | 16 |
Test that {{ message }} and {{ name }} are replaced in url, headers and body for POST. | def test_web_logger_wildcard_replacements_in_post(self, mock_post):
parsed_config = self._get_parsed_config("full_config.yml")
parsed_web_logger = parsed_config.loggers[1]
message = "test"
name = parsed_config.name
parsed_web_logger.emit(
LogRecord(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_error_html_using_post(self):\n pass",
"def test_bad_placeholder_2(self):\n with translation.override('fr'):\n t = Template('{% load i18n %}{% blocktrans %}My other name is {{ person }}.{% endblocktrans %}')\n rendered = t.render(Context({'person': 'James'}))\n ... | [
"0.58972067",
"0.578704",
"0.57665884",
"0.57407296",
"0.5731119",
"0.57120335",
"0.56881094",
"0.5672356",
"0.55752546",
"0.55600995",
"0.5523317",
"0.5515083",
"0.55117565",
"0.5499972",
"0.54896426",
"0.5415698",
"0.53869766",
"0.5384738",
"0.5377167",
"0.5375139",
"0.5358... | 0.62762177 | 0 |
Helper method to remove keys from dictionary with None values. | def _dict_clean(self, obj: list[tuple[str, Any]]) -> dict[str, Any]:
result = {}
for k, v in obj:
if v is None and k in ['revenue', 'value', 'tags', 'decisions']:
continue
else:
result[k] = v
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_none_values(dict_):\r\n\r\n res = {}\r\n res.update((key, value) for key, value in dict_.iteritems() \\\r\n if value is not None)\r\n return res",
"def remove_empty_values(_dict):\n return {k: v for k, v in list(_dict.items()) if v is not None}",
"def _drop_none_values(dic... | [
"0.83452713",
"0.8074721",
"0.80655813",
"0.7683692",
"0.76372546",
"0.76235104",
"0.7581779",
"0.75663316",
"0.7476397",
"0.7425392",
"0.739269",
"0.73780835",
"0.7345108",
"0.7323058",
"0.7301127",
"0.72742045",
"0.7192415",
"0.7172237",
"0.7154674",
"0.71188515",
"0.710872... | 0.6095522 | 63 |
In the constructor we instantiate two nn.Linear modules and assign them a member variables. | def __init__(self, D_in, H, D_out):
super(TwoLayerNet, self).__init__()
self.linear1 = torch.nn.Linear(D_in, H)
self.linear2 = torch.nn.Linear(H, D_out) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args):\n super(LinearND, self).__init__()\n self.fc = nn.Linear(*args)",
"def __init__(self, linear_args, activation_functions, softmax=False):\n super(NN, self).__init__()\n assert len(activation_functions) == len(linear_args) - 1\n k = len(linear_args)\n ... | [
"0.77227384",
"0.753052",
"0.7483487",
"0.73922247",
"0.7315289",
"0.73091024",
"0.729439",
"0.7283621",
"0.7261301",
"0.72583973",
"0.72583973",
"0.7245734",
"0.72256035",
"0.72234315",
"0.7207916",
"0.7158103",
"0.7083186",
"0.706643",
"0.7026294",
"0.7005491",
"0.69888383"... | 0.70500404 | 18 |
Comprueba que no exista un email igual en la Base de Datos | def clean_email(self):
email = self.cleaned_data['email']
if Dueno.objects.filter(email=email):
raise forms.ValidationError('Ya existe un email igual registado.')
return email | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_email(self, data):\n if User.objects.filter(email=data.lower()).exists():\n raise serializers.ValidationError('Already registered email!')\n return data.lower()",
"def clean_email(self):\n email = self.cleaned_data.get('email')\n email_exists = User.objects.fil... | [
"0.6831771",
"0.6821777",
"0.6764606",
"0.6681206",
"0.6647442",
"0.66472507",
"0.6646941",
"0.6630429",
"0.66265535",
"0.6612725",
"0.6603743",
"0.65703666",
"0.6566891",
"0.65354717",
"0.6532868",
"0.6440155",
"0.643161",
"0.640356",
"0.6398634",
"0.6395998",
"0.63955045",
... | 0.6971016 | 0 |
Comprueba que no exista un email igual en la Base de Datos | def clean_email(self):
email = self.cleaned_data['email']
if User.objects.filter(email=email):
raise forms.ValidationError('Ya existe un email igual registado.')
return email | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_email(self):\n email = self.cleaned_data['email']\n if Dueno.objects.filter(email=email):\n raise forms.ValidationError('Ya existe un email igual registado.')\n return email",
"def validate_email(self, data):\n if User.objects.filter(email=data.lower()).exists():\... | [
"0.6970433",
"0.6831335",
"0.682042",
"0.67630833",
"0.6682182",
"0.664644",
"0.664601",
"0.66458386",
"0.66298985",
"0.66275686",
"0.6611991",
"0.66031224",
"0.6569712",
"0.6566407",
"0.6532759",
"0.6441037",
"0.64312446",
"0.64037603",
"0.6397482",
"0.6395626",
"0.6394193",... | 0.6534734 | 14 |
Returns a SQLContext, which is the entry point to PySparks' data frames. | def sql_context(self):
if not self._sql_context:
import pyspark.sql
self._sql_context = pyspark.sql.SQLContext(self.context())
return self._sql_context | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sql_context_instance(spark_configuration):\n if 'sparkSessionSingletonInstance' not in globals():\n globals()['sparkSessionSingletonInstance'] = SparkSession.builder.config(conf=spark_configuration).getOrCreate()\n return globals()['sparkSessionSingletonInstance']",
"def get_db_data(self, sq... | [
"0.6137038",
"0.5712923",
"0.5564493",
"0.5508761",
"0.5498803",
"0.5490654",
"0.5487586",
"0.5477444",
"0.5471589",
"0.5460848",
"0.5460563",
"0.5458911",
"0.54517",
"0.543572",
"0.5420237",
"0.53948396",
"0.538981",
"0.5388202",
"0.5373302",
"0.5348661",
"0.5340168",
"0.5... | 0.7340628 | 0 |
The linked list provides the first node (self.head) of the linked list. | def __init__(self, head=None):
self.head = head | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def head(self) -> object:\n if not self._head:\n raise EmptyListException(\"The list is empty.\")\n return self._head",
"def first(self):\r\n return self.__head",
"def head(self):\n return self._head",
"def head(self):\n return self._head",
"def first(self):\n ... | [
"0.7386129",
"0.73754",
"0.7356761",
"0.7356761",
"0.73344105",
"0.73268175",
"0.718275",
"0.71287054",
"0.707694",
"0.70479566",
"0.70419645",
"0.70080155",
"0.6975189",
"0.6975189",
"0.6975189",
"0.6975189",
"0.694018",
"0.694018",
"0.694018",
"0.694018",
"0.694018",
"0.6... | 0.69010913 | 31 |
Checks if a file is an allowed extension. | def has_file_allowed_extension(filename, extensions):
return filename.lower().endswith(extensions) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_allowed_extension(filename):\n return '.' in filename and filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS",
"def allowed_file(filename, allowed_extension):\n return '.' in filename and get_file_ext(filename) in allowed_extension",
"def is_allowed_file(filename, allowed_ext):\n ext = filename.... | [
"0.895309",
"0.8786745",
"0.8764468",
"0.87614024",
"0.8612598",
"0.8612598",
"0.8612598",
"0.8612598",
"0.8612598",
"0.8612598",
"0.85555506",
"0.8541878",
"0.8525629",
"0.8525629",
"0.85190576",
"0.85190576",
"0.85155004",
"0.8498841",
"0.8496414",
"0.8496414",
"0.8496414",... | 0.85909545 | 11 |
Checks if a file is an allowed image extension. | def is_image_file(filename):
return has_file_allowed_extension(filename, IMG_EXTENSIONS) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_file(filename):\n return '.' in filename and \\\n\t filename.rsplit('.', 1)[1] in ALLOWED_IMAGE_EXTENSIONS",
"def allowed_image(filename):\n \n if not '.' in filename:\n return False\n \n ext = filename.rsplit('.', 1)[1]\n \n if ext.lower() in ALLOWED_IMAGE_EXTENSIONS:\n ... | [
"0.8670265",
"0.8492015",
"0.8165099",
"0.8164114",
"0.8088288",
"0.8078984",
"0.8011121",
"0.80064887",
"0.7972861",
"0.79575336",
"0.7957222",
"0.79048324",
"0.7892964",
"0.789242",
"0.78513193",
"0.78513193",
"0.78513193",
"0.78513193",
"0.78513193",
"0.78513193",
"0.78427... | 0.8286245 | 2 |
Returns starting state of the board. | def initial_state():
return [[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY]] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_state(self):\r\n return np.zeros(self.board_size, dtype=np.int8)",
"def start_state():\n return chess.Board()",
"def startingState(self):\n # Returns starting position and 4 false because no corners are visited yet\n return (self.startingPosition, (False, False, False, False))... | [
"0.8080877",
"0.78905165",
"0.7534062",
"0.72784334",
"0.72784334",
"0.72256136",
"0.72256136",
"0.72256136",
"0.72256136",
"0.72256136",
"0.72256136",
"0.72256136",
"0.72256136",
"0.72256136",
"0.72256136",
"0.72256136",
"0.72256136",
"0.72256136",
"0.72256136",
"0.72256136",
... | 0.0 | -1 |
Returns player who has the next turn on a board. | def player(board):
turn = 0
for i in range(3):
for j in range(3):
if board[i][j] != EMPTY:
turn+=1
if turn % 2 != 0:
return O
else:
return X | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_player(board, prev_player):\n opp = Othello.opponent(prev_player)\n if Othello.any_legal_move(opp, board):\n return opp\n elif Othello.any_legal_move(prev_player, board):\n return prev_player\n return None",
"def next_player(self,board, prev_player):\r\n... | [
"0.7911148",
"0.7521969",
"0.74204457",
"0.73687756",
"0.71954805",
"0.69775087",
"0.69621766",
"0.69253695",
"0.69208723",
"0.69010353",
"0.6845991",
"0.6841043",
"0.6838282",
"0.68265843",
"0.67751175",
"0.67751175",
"0.6769739",
"0.6713109",
"0.67060393",
"0.66561204",
"0.... | 0.0 | -1 |
Returns the optimal action for the current player on the board. | def minimax(board):
current_player = player(board)
if terminal(board):
return
if current_player == X:
optimal_value = -math.inf
else:
optimal_value = math.inf
for action in actions(board):
new_board = result(board, action)
minimax_valu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_best_action(self):\n if self.bestAction is None:\n self.calculate_best_action()\n return self.bestAction",
"def getAction(self, gameState: GameState):\n _max = float(\"-inf\")\n action = None\n for move in gameState.getLegalActions(0):\n util = min... | [
"0.7766856",
"0.76323676",
"0.75855315",
"0.75285065",
"0.75175256",
"0.74667144",
"0.7460485",
"0.74263537",
"0.7416421",
"0.73943585",
"0.7375846",
"0.7333894",
"0.73147565",
"0.7306611",
"0.7284639",
"0.72650313",
"0.72650313",
"0.7250975",
"0.72331834",
"0.7203267",
"0.71... | 0.7015889 | 35 |
Create datasets and dataloaders. | def create_dataloaders(data_dir, input_size, batch_size):
# Get dataset mean and std
dataset_mean, dataset_std = estimate_dataset_mean_and_std(expand_subdir(data_dir), input_size)
# Data augmentation and normalization for training
# Just normalization for validation
data_transforms = {
'tra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_creator(config):\n train_dataset, val_dataset = LinearDataset(2, 5), LinearDataset(2, 5)\n train_loader = DataLoader(train_dataset, batch_size=config[\"batch_size\"])\n val_loader = DataLoader(val_dataset, batch_size=config[\"batch_size\"])\n return train_loader, val_loader",
"def creates_da... | [
"0.77735287",
"0.7740785",
"0.7737177",
"0.7418781",
"0.7319778",
"0.71889585",
"0.71841204",
"0.7126762",
"0.7119504",
"0.7119504",
"0.71162844",
"0.7040561",
"0.70248044",
"0.7020804",
"0.70022327",
"0.69891316",
"0.69873416",
"0.6981885",
"0.6964285",
"0.6945724",
"0.69374... | 0.67452073 | 37 |
Math function returning MAX(cv_min, MIN(cv_max, ROUND(value))) | def float_to_cv(self, value):
return max(self.cv_min, min(self.cv_max, round(value))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clamp(value, min_value, max_value):\n return max(min_value, min(value, max_value))",
"def compute_closest_coordinate(value, range_min, range_max):\r\n \r\n v = None\r\n \r\n if range_min < value < range_max:\r\n v = value\r\n \r\n elif value <= range_min:\r\n v = range_min\r\n \r... | [
"0.68912506",
"0.68716997",
"0.6869824",
"0.68183225",
"0.6670935",
"0.6661698",
"0.6660178",
"0.664402",
"0.65678006",
"0.6557955",
"0.65453815",
"0.6540822",
"0.65134335",
"0.64734185",
"0.64456856",
"0.6393219",
"0.6392485",
"0.6373728",
"0.63648844",
"0.6309885",
"0.62885... | 0.75277376 | 0 |
Repeats elements of a Tensor (equivalent to np.repeat, but only for 1D tensors). | def repeat(x, repeats):
x = tf.expand_dims(x, 1)
max_repeats = tf.reduce_max(repeats)
tile_repeats = [1, max_repeats]
arr_tiled = tf.tile(x, tile_repeats)
mask = tf.less(tf.range(max_repeats), tf.expand_dims(repeats, 1))
result = tf.reshape(tf.boolean_mask(arr_tiled, mask), [-1])
return resu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tf_repeat(tensor, repeats):\n with tf.variable_scope(\"repeat\"):\n expanded_tensor = tf.expand_dims(tensor, -1)\n multiples = as_tuple(1, repeats)\n tiled_tensor = tf.tile(expanded_tensor, multiples)\n return tf.reshape(tiled_tensor, tf.shape(tensor) * repeats)",
"def repeat_e... | [
"0.80900806",
"0.7992903",
"0.79103696",
"0.7798611",
"0.7750798",
"0.7720652",
"0.76689845",
"0.7655345",
"0.7592264",
"0.7182516",
"0.691804",
"0.6889068",
"0.688868",
"0.6881596",
"0.68092054",
"0.6764589",
"0.6705033",
"0.6643503",
"0.6630341",
"0.65835226",
"0.6527176",
... | 0.73791957 | 9 |
Return mask with true values at indices of the given shape. This can be used as an inverse to tf.where. | def indices_to_mask(indices, shape, dtype=tf.bool):
indices = tf.convert_to_tensor(indices, dtype_hint=tf.int64)
if indices.shape.ndims == 1:
assert isinstance(shape, int) or shape.shape.ndims == 0
indices = tf.expand_dims(indices, axis=1)
if isinstance(shape, int):
shape = t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def idx_to_mask(idx, shape):\n output = np.zeros(shape)\n output[idx] = 1\n return output.astype(np.bool)",
"def boolmask(indices, shape=None):\n indices = np.asanyarray(indices)\n if indices.dtype.kind not in {'i', 'u'}:\n indices = indices.astype(int)\n if shape is None:\n shape... | [
"0.8021843",
"0.7506625",
"0.74998856",
"0.70579976",
"0.66829383",
"0.664171",
"0.63669086",
"0.63529086",
"0.6323865",
"0.62560785",
"0.61065674",
"0.6061758",
"0.60488284",
"0.6038983",
"0.5941297",
"0.59390503",
"0.5937012",
"0.59316784",
"0.5920707",
"0.5916833",
"0.5899... | 0.74603516 | 3 |
Converts bboxes in the form of [center_y, center_x, height, width] into form of [y_top, x_left, y_bottom, x_right] | def center_point_to_coordinates(bbox):
y, x, h, w = tf.split(bbox, 4, -1)
h2, w2 = tf.cast(h / 2, h.dtype), tf.cast(w / 2, w.dtype)
return tf.concat([y - h2, x - w2, y + h2, x + w2], -1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _decode_boxes(raw_boxes, anchors):\n boxes = np.zeros(raw_boxes.shape, np.float32)\n SCALE = 128\n x_center = raw_boxes[..., 0] / SCALE * anchors[:, 2] + anchors[:, 0]\n y_center = raw_boxes[..., 1] / SCALE * anchors[:, 3] + anchors[:, 1]\n\n w = raw_boxes[..., 2] / SCALE * anchors[:, 2]\n h ... | [
"0.71204",
"0.71111757",
"0.70825183",
"0.7032239",
"0.70122385",
"0.6996101",
"0.692208",
"0.69145215",
"0.69076514",
"0.69060045",
"0.69014704",
"0.6889957",
"0.6882059",
"0.68813413",
"0.6858002",
"0.6828021",
"0.6800085",
"0.6753522",
"0.6748139",
"0.6743758",
"0.6731826"... | 0.64197063 | 56 |
Converts bboxes in the form of [y_top, x_left, y_bottom, x_right] into form of [center_y, center_x, height, width] | def coordinates_to_center_point(bbox):
y_top, x_left, y_botton, x_right = tf.split(bbox, 4, -1)
h, w = y_botton - y_top, x_right - x_left
return tf.concat([y_top + tf.cast(h / 2, h.dtype), x_left + tf.cast(w / 2, w.dtype), h, w], -1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _decode_boxes(raw_boxes, anchors):\n boxes = np.zeros(raw_boxes.shape, np.float32)\n SCALE = 128\n x_center = raw_boxes[..., 0] / SCALE * anchors[:, 2] + anchors[:, 0]\n y_center = raw_boxes[..., 1] / SCALE * anchors[:, 3] + anchors[:, 1]\n\n w = raw_boxes[..., 2] / SCALE * anchors[:, 2]\n h ... | [
"0.71960074",
"0.7185448",
"0.7130102",
"0.7104308",
"0.70851845",
"0.6989498",
"0.6968603",
"0.69442964",
"0.68925756",
"0.6881483",
"0.6862328",
"0.6824929",
"0.6823459",
"0.6799759",
"0.6792086",
"0.67841035",
"0.67469573",
"0.6726466",
"0.66866004",
"0.6670376",
"0.666419... | 0.644881 | 40 |
Euclidean distance between 2 points | def Dist(p1,p2):
x1, y1 = p1
x2, y2 = p2
return (((x1-x2)*(x1-x2)) + ((y1-y2)*(y1-y2)))**0.5 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def euclidean_distance(point1, point2):\n\n return math.sqrt(sum([(x - y) ** 2 for x, y in zip(point1, point2)]))",
"def euclidean_distance(point1, point2):\n return np.linalg.norm(np.array(point1) - np.array(point2))",
"def euclidean_distance(point_one, point_two):\n return np.linalg.norm(point_one-p... | [
"0.8665912",
"0.8603578",
"0.85575724",
"0.8518997",
"0.8497151",
"0.8460999",
"0.8412516",
"0.836962",
"0.8344624",
"0.83078986",
"0.82841814",
"0.8269279",
"0.81608623",
"0.81585824",
"0.81567377",
"0.81557566",
"0.8089304",
"0.8054801",
"0.80439156",
"0.8043549",
"0.804143... | 0.0 | -1 |
Given 2 boxes, this function returns intersection area | def intersectarea(p1,p2,size):
x1, y1 = p1
x2, y2 = p2
ix1, iy1 = max(x1,x2), max(y1,y2)
ix2, iy2 = min(x1+size,x2+size), min(y1+size,y2+size)
iarea = abs(ix2-ix1)*abs(iy2-iy1)
if iy2 < iy1 or ix2 < ix1: iarea = 0
return iarea | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intersection(boxes1, boxes2):\n ymin1, xmin1, ymax1, xmax1 = np.split(boxes1, 4, axis=1)\n ymin2, xmin2, ymax2, xmax2 = np.split(boxes2, 4, axis=1)\n\n pairwise_min_ymax = np.minimum(ymax1, np.transpose(ymax2))\n pairwise_max_ymin = np.maximum(ymin1, np.transpose(ymin2))\n intersect_heights = np.maximum(\... | [
"0.808149",
"0.797772",
"0.7939772",
"0.7855122",
"0.7780438",
"0.77307713",
"0.77108145",
"0.7662492",
"0.76291543",
"0.753652",
"0.75249934",
"0.75054014",
"0.7504217",
"0.7441215",
"0.74195683",
"0.74096346",
"0.7399938",
"0.73754525",
"0.7351875",
"0.73510414",
"0.7350179... | 0.75131994 | 11 |
Convert given image into custom palette colors | def imagetopalette(image, palcolors):
assert image.mode == 'L', "Only grayscale images supported !"
pal = [(palcolors[i],palcolors[i+1]) for i in range(len(palcolors)-1)]
image.putdata([colortopalette(c,pal) for c in list(image.getdata())]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rebuild_palette(img: Image.Image) -> Tuple[Image.Image, int]:\n width, height = img.size\n img = img.convert(\"RGBA\")\n new_palette = Palette()\n alpha_layer: Image.Image = Image.new(\"L\", img.size)\n\n for x in range(width):\n for y in range(height):\n red, green, blue, alph... | [
"0.74353",
"0.71980727",
"0.69917405",
"0.6687847",
"0.6634555",
"0.65160006",
"0.63844216",
"0.63498706",
"0.62841034",
"0.62718153",
"0.62709147",
"0.6258379",
"0.6242585",
"0.62217647",
"0.6221244",
"0.618707",
"0.61789316",
"0.61639154",
"0.61616147",
"0.6160594",
"0.6136... | 0.694219 | 3 |
Sets the id of this HostedDoc. | def id(self, id):
self._id = id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_id(self, id):\n self.__id = id",
"def set_id(self, id_):\n\n self.id_ = id_",
"def set_id(self, id):\n self.data['id'] = id",
"def SetId(self, id):\n self.id = int(id)",
"def id(self, id: str):\n \n self._id = id",
"def id(self, id: str):\n self._i... | [
"0.7549935",
"0.7445114",
"0.73211277",
"0.7287825",
"0.7252782",
"0.72375417",
"0.72369",
"0.72369",
"0.72369",
"0.71928304",
"0.71928304",
"0.71928304",
"0.71928304",
"0.71928304",
"0.7182742",
"0.7182742",
"0.7182742",
"0.7182742",
"0.7182742",
"0.7182742",
"0.7182742",
... | 0.717032 | 91 |
Sets the user_id of this HostedDoc. | def user_id(self, user_id):
self._user_id = user_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id_user(self, id_user):\n\n self._id_user = id_user",
"def user(self, user):\n self.user_id = user.get_id()",
"def set_userId(self, userId):\n self.authentication.userId = userId",
"def user_id(self, user_id: str):\n if user_id is None:\n raise ValueError(\"Invalid ... | [
"0.77988344",
"0.7264747",
"0.7199108",
"0.7045349",
"0.70313",
"0.70313",
"0.7002845",
"0.69538677",
"0.6914102",
"0.6896659",
"0.68725383",
"0.68306965",
"0.67530525",
"0.67300165",
"0.6636379",
"0.6636379",
"0.6636379",
"0.6636379",
"0.6636379",
"0.6636379",
"0.6636379",
... | 0.78060514 | 8 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, HostedDoc):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Inference method. Switch model to `eval` mode, call `.forward(x)` with `torch.no_grad()` | def predict(self, x):
if self.training:
self.eval()
with torch.no_grad():
output = self.forward(x)
if self.classes > 1:
probs = torch.softmax(output, dim=1)
else:
probs = torch.sigmoid(output)
probs = probs.squeeze(0)
tf ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, x: Tensor) -> Any: # type: ignore[override]\n return self.model(x)",
"def forward(self, X: Tensor) -> Tensor:\n if self.training:\n if self.transform_on_train:\n return self.transform(X)\n elif self.transform_on_eval:\n if fantasize.off... | [
"0.6793961",
"0.67194325",
"0.66591483",
"0.65891796",
"0.65779716",
"0.65765405",
"0.6434522",
"0.6383541",
"0.6347136",
"0.6328052",
"0.63274986",
"0.63203883",
"0.63144624",
"0.6304984",
"0.62984115",
"0.62945604",
"0.6267837",
"0.6265283",
"0.62537205",
"0.6209163",
"0.62... | 0.0 | -1 |
Selects pairs of individuals at random from mating population and performs uniform crossover | def uniform_crossover(
self, mating_pop_dict, test=False, pairs=[], crossover_prob={}
):
print('Performing crossovers')
# Initialises dictionary of child networks
crossover_pop_dict = OrderedDict()
if test is False:
# Selects pairs of networks at random to cros... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crossover(population, kw=None, **kwargs):\n future_population = []\n while len(future_population) < len(population):\n p1, p2 = random.choice(population)['notes'], random.choice(population)['notes']\n split = random.randint(1, len(p1) - 1)\n map(future_population.append, [p1[:split] ... | [
"0.7380893",
"0.7152108",
"0.70001495",
"0.6927647",
"0.6886835",
"0.6865305",
"0.68208474",
"0.6793555",
"0.67773944",
"0.66755813",
"0.6660987",
"0.66530037",
"0.6640501",
"0.6633426",
"0.6632998",
"0.660032",
"0.65472764",
"0.6545151",
"0.6498023",
"0.649743",
"0.64895177"... | 0.7035463 | 2 |
Selects pairs of individuals at random from mating population and performs segmented crossover | def segmented_crossover(
self, mating_pop_dict, test=False, pairs=[], crossover_prob={}
):
print('Performing crossovers')
# Initialises dictionary of child networks
crossover_pop_dict = OrderedDict()
if test is False:
# Selects pairs of networks at random to cr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crossover(population, kw=None, **kwargs):\n future_population = []\n while len(future_population) < len(population):\n p1, p2 = random.choice(population)['notes'], random.choice(population)['notes']\n split = random.randint(1, len(p1) - 1)\n map(future_population.append, [p1[:split] ... | [
"0.6883596",
"0.6800745",
"0.67743516",
"0.6655921",
"0.6644784",
"0.6596214",
"0.65946054",
"0.6592522",
"0.6535841",
"0.64932644",
"0.6448248",
"0.6442825",
"0.63911873",
"0.63569015",
"0.6347295",
"0.6328471",
"0.6289912",
"0.626084",
"0.6254494",
"0.6241147",
"0.6207218",... | 0.68115205 | 1 |
Return the index of a column. | def column_index(self, column_label):
return self.column_labels.index(column_label) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_index(self, column):\r\n\r\n\t\treturn self.columns.index(column)",
"def getColIdx(self, col):\n try:\n return int(col)\n except:\n return ord(col)-ord('a')",
"def column_index(self, column_name: str) -> int:\n return self._column_indices[column_name]",
"def... | [
"0.8677354",
"0.8431196",
"0.8420052",
"0.8419143",
"0.8015686",
"0.7687867",
"0.75376517",
"0.7522614",
"0.7490025",
"0.7490025",
"0.7490025",
"0.7490025",
"0.7490025",
"0.7490025",
"0.7490025",
"0.7490025",
"0.7490025",
"0.7490025",
"0.7490025",
"0.7490025",
"0.7490025",
... | 0.83825827 | 4 |
Return a Table with selected column or columns by label. | def select(self, column_label_or_labels):
column_labels = _as_labels(column_label_or_labels)
table = Table()
for label in column_labels:
self._add_column_and_format(table, label, np.copy(self[label]))
return table | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select(self, labels):\n indexs = []\n \n for i in range(len(labels)):\n indexs.append(self.column_labels.index(labels[i]))\n new_rows = []\n for x in self.rows:\n new_row = []\n for index in indexs:\n new_row.append(x[index])\n ... | [
"0.71968764",
"0.5904027",
"0.5876918",
"0.58585215",
"0.5723955",
"0.54890376",
"0.5437755",
"0.5436814",
"0.53728235",
"0.53688955",
"0.5358947",
"0.5330313",
"0.5330187",
"0.5305329",
"0.5274468",
"0.5219712",
"0.5193768",
"0.5189129",
"0.51855576",
"0.5177512",
"0.5141539... | 0.7645611 | 0 |
Return a formatting function that pads values. | def format_column(cls, label, column, min_width=min_val_width, max_width=max_val_width, etc=' ...'):
val_width = 0 if len(column) == 0 else max(len(cls.format_value(v)) for v in column)
val_width = min(val_width, max_width)
width = max(val_width, len(str(label)), min_width, len(etc))
def... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _padboth(width, s):\n fmt = \"{0:^%ds}\" % width\n return fmt.format(s)",
"def pad(number, width=0):\n return str(number).zfill(width)",
"def filter_pad(val: Union[int, str], width: int, fillchar: str = '0') -> str:\n return str(val).rjust(width, fillchar)",
"def float_padding(length, val, de... | [
"0.6454873",
"0.644634",
"0.6349001",
"0.62581176",
"0.6157596",
"0.6154019",
"0.6149456",
"0.6139503",
"0.61233884",
"0.60975385",
"0.60717624",
"0.6044765",
"0.60441875",
"0.603975",
"0.6032162",
"0.5956833",
"0.5955617",
"0.59335303",
"0.5885808",
"0.58782494",
"0.5867972"... | 0.54398453 | 63 |
Wrap a function on an np.ndarray to return 0 on a type error. | def _zero_on_type_error(column_fn):
@functools.wraps(column_fn)
def wrapped(column):
try:
return column_fn(column)
except TypeError:
if isinstance(column, np.ndarray):
return column.dtype.type() # A typed zero value
else:
raise
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_numpy(func):\r\n return func",
"def check_np_array_nan(func):\r\n\r\n @functools.wraps(func)\r\n def wrapper(*args, **kwargs):\r\n result = func(*args, **kwargs)\r\n if type(result) in [tuple, list]:\r\n count = 0\r\n for an_array in result:\r\n ... | [
"0.6354827",
"0.63062966",
"0.6284868",
"0.6182963",
"0.60895485",
"0.5886592",
"0.5879297",
"0.57888615",
"0.57888615",
"0.5776397",
"0.5754397",
"0.57135016",
"0.5639571",
"0.5633456",
"0.5624895",
"0.56212294",
"0.56053144",
"0.5600506",
"0.5599613",
"0.5534893",
"0.550502... | 0.74555403 | 0 |
Whether a value is iterable. | def _is_non_string_iterable(value):
if isinstance(value, str):
return False
if hasattr(value, '__iter__'):
return True
if isinstance(value, collections.abc.Sequence):
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isIterable(value):\n try:\n iter(value)\n return True\n except:\n return False",
"def is_iterable(value):\n # noinspection PyUnresolvedReferences\n return hasattr(value, '__iter__') and hasattr(value, '__getitem__')",
"def _is_iterable(value):\n return isinstance(val... | [
"0.8671964",
"0.8461713",
"0.8273151",
"0.78620726",
"0.7836823",
"0.7771756",
"0.77457356",
"0.7739959",
"0.77177155",
"0.7698039",
"0.76362705",
"0.7573118",
"0.75347775",
"0.74825734",
"0.7475645",
"0.737838",
"0.7307623",
"0.72827333",
"0.7204324",
"0.7182979",
"0.7104745... | 0.75446236 | 12 |
Standard error of estimate (Root mean square error) | def see(p, y, yHat):
n = y.shape[0]
numer = ((y - yHat) ** 2).sum()
denom = n - p - 1
if (denom == 0):
s = 0
elif ( (numer / denom) < 0 ):
s = 0.001
else:
s = (numer / denom) ** 0.5
return s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def standard_deviation(self):\r\n\t\treturn self.variance()**(1/2)",
"def std(self):\n\t\treturn np.sqrt(0.6) #obtained by integrating 1.5x^4 from -1 to 1",
"def calculate_std(self) -> float:\n\n if self.data:\n return np.std(self.data)\n else:\n return self.sigma",
"def s... | [
"0.76255953",
"0.7551994",
"0.7505911",
"0.7503446",
"0.74603534",
"0.74244446",
"0.7412778",
"0.7363041",
"0.7363041",
"0.7333144",
"0.72901833",
"0.727787",
"0.72770953",
"0.7227539",
"0.7223049",
"0.72060466",
"0.7197942",
"0.71941084",
"0.7191991",
"0.71721727",
"0.716825... | 0.0 | -1 |
Detect language for a batch of documents. Returns the detected language and a numeric score between zero and one. Scores close to one indicate 100% certainty that the identified | def detect_language( # type: ignore
self,
documents, # type: Union[List[str], List[DetectLanguageInput], List[Dict[str, str]]]
**kwargs # type: Any
):
# type: (...) -> List[Union[DetectLanguageResult, DocumentError]]
country_hint_arg = kwargs.pop("country_hint", None)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detect_language(text, LANGUAGES):\n lang = None\n word_count = 0\n our_test = []\n \n for language in LANGUAGES:\n \n result = get_word_count(text, language['common_words'])\n print(result)\n #import pdb; pdb.set_trace()\n if result > word_count:\n l... | [
"0.68414056",
"0.6580281",
"0.63324946",
"0.6315463",
"0.6301533",
"0.618743",
"0.61461836",
"0.60928607",
"0.59702677",
"0.5946779",
"0.5925776",
"0.58808637",
"0.5868222",
"0.5837338",
"0.58271474",
"0.5774584",
"0.57127047",
"0.5673446",
"0.5643901",
"0.5637352",
"0.560735... | 0.6165304 | 6 |
Yield successive nsized chunks from a list. | def split_chunk(list, chunk_size):
for i in range(0, len(list), chunk_size):
yield list[i:i + chunk_size] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunks(self, lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]",
"def _chunks(l, n):\n\tfor i in range(0, len(l), n):\n\t\tyield l[i:i + n]",
"def chunks(item_list, n_items):\n for i in range(0, len(item_list), n_items):\n yield item_list[i : i + n_items]",
"def ... | [
"0.80128753",
"0.7941934",
"0.7932596",
"0.79320854",
"0.791561",
"0.791561",
"0.79144424",
"0.791114",
"0.791114",
"0.7907752",
"0.78383857",
"0.7838351",
"0.7814962",
"0.7791491",
"0.77740216",
"0.77740216",
"0.77740216",
"0.77740216",
"0.77740216",
"0.7770947",
"0.7768256"... | 0.0 | -1 |
Calculates the distribution of the probabilities of each word in the population occurring after the previous words that have been generated. | def get_population_prob_dist(population, prev_word_array, review_batch):
prob_dist = {}
for individual in population:
prob_dist[individual] = _prob_of_next_word(individual, prev_word_array, review_batch)
return prob_dist | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_probability(self, word, prev):\n bg = \"{} {}\".format(prev, word)\n p_c = self.model[word] if word in self.model else 1e-10 \n p_cw = self.bigrams[bg] if bg in self.bigrams else 1e-10 \n p = p_c * p_cw if prev else p_c\n return p",
"def probability(self, words):\n ... | [
"0.6966408",
"0.6783748",
"0.6783748",
"0.6755222",
"0.6701354",
"0.6677489",
"0.65107155",
"0.6502526",
"0.6493202",
"0.6414597",
"0.6376017",
"0.62759507",
"0.62560374",
"0.6211251",
"0.62070835",
"0.61722654",
"0.6141359",
"0.613355",
"0.61139965",
"0.60976756",
"0.6097628... | 0.72292715 | 0 |
Calculate the distribution of probabilities of all the unique words found in the review_batch occurring after the previously generated words. | def get_expected_prob_dist(prev_word_array, review_batch):
prob_dist = {}
all_words = loader.get_words(review_batch)
all_words_ = list(map(lambda x: len(x), all_words))
sorted_words = all_words[np.argsort(all_words)]
for i in range(0, len(sorted_words) - 1):
if sorted_words[i + 1] == sorted... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_population_prob_dist(population, prev_word_array, review_batch):\n prob_dist = {}\n\n for individual in population:\n prob_dist[individual] = _prob_of_next_word(individual, prev_word_array, review_batch)\n\n return prob_dist",
"def _prob_of_next_word(next_word, prev_word_array, review_bat... | [
"0.6778919",
"0.66591436",
"0.6347305",
"0.6313462",
"0.6313462",
"0.6273247",
"0.6206041",
"0.61933684",
"0.60889083",
"0.6058977",
"0.60536927",
"0.60290223",
"0.59934425",
"0.5992751",
"0.5992305",
"0.59823066",
"0.59795415",
"0.5961064",
"0.5904356",
"0.58872366",
"0.5876... | 0.7084932 | 0 |
Get random substrings of size substring_size from the substring_array. | def get_comparison_substrings(substring_array, min_num_substrings=round(len(population_dist))):
for individual in population_dist:
rand_index = random.randint(0, len(population_dist) - end)
parent = individual[begin + rand_index:end + rand_index]
np.append(substring_array, pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_subset(array, count):\n indices = np.random.permutation(len(array))[:count]\n return array[indices]",
"def substrings(a, b, n):\n\n # TODO\n return []",
"def test_find_all_substrings_02():\n assert (U.find_all_substrings(s, 17, 5) ==\n U.find_all_substrings(s, 17, 18))\n ... | [
"0.62674284",
"0.61499566",
"0.60506034",
"0.59336424",
"0.59216213",
"0.58888245",
"0.5888029",
"0.58263934",
"0.5806061",
"0.57688844",
"0.5653793",
"0.5629096",
"0.56038404",
"0.556558",
"0.5549378",
"0.5535475",
"0.5526019",
"0.5520514",
"0.5515632",
"0.548048",
"0.546061... | 0.68094176 | 0 |
This method should be used when you want to no longer draw a trail and delete it | def clear_trail(self):
self.obj.make_trail = False
self.obj.clear_trail()
self.sum_ang = 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def EndDraw(self):\r\n\r\n pass",
"def stopLineDrawing(self):\n taskMgr.remove(\"drawLineTask\")\n if self.line is not None:\n self.line.reset()\n self.line = None",
"def _clear(self):\n self._fillitem = self._fillpath = None\n for item in self.items:\n ... | [
"0.66773003",
"0.6676018",
"0.6404421",
"0.637547",
"0.63584983",
"0.615592",
"0.6147445",
"0.60753715",
"0.6029106",
"0.6020249",
"0.5996174",
"0.59637123",
"0.59339553",
"0.5893738",
"0.58905107",
"0.5885422",
"0.5857549",
"0.57881665",
"0.57863754",
"0.5781967",
"0.5781916... | 0.7081529 | 0 |
A function to aid in the production of more a y axis which rises above the highest data value (increases readability) | def round_up(number, decimals=0):
multiplier = 10 ** decimals
return math.ceil(number * multiplier) / multiplier | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_y_max(self):\n if len(self._statDict) == 0:\n return -1E10\n\n line_id_list = self._statDict.keys()\n max_y = self._statDict[line_id_list[0]][3]\n for i_plot in range(1, len(line_id_list)):\n if self._statDict[line_id_list[i_plot]][3] > max_y:\n ... | [
"0.71137637",
"0.6881365",
"0.68346685",
"0.6779634",
"0.6689509",
"0.6633723",
"0.65836114",
"0.6529373",
"0.6529373",
"0.651268",
"0.649996",
"0.64752394",
"0.6452737",
"0.63294804",
"0.6289473",
"0.628551",
"0.6272038",
"0.6259104",
"0.6247522",
"0.624057",
"0.62030333",
... | 0.0 | -1 |
Binary search of the index of the last element not greater than a given target in the ascending sorted array. If not found, return 1. | def bsearch_right_not_greater(nums: List[int], target: int) -> int:
low, high = 0, len(nums) - 1
while low <= high:
mid = low + (high - low) // 2
if nums[mid] <= target:
low = mid + 1
else:
high = mid - 1
if high >= 0 and nums[high] <= target:
return h... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Find_the_last_index(A, target):\n if len(A) == 0:\n return -1\n begin = 0\n end = len(A) - 1\n while end - begin > 1:\n mid = begin + (end - begin >> 1)\n if target < A[mid]:\n end = mid\n else:\n begin = mid\n if A[end] == target:\n retur... | [
"0.7624975",
"0.7468117",
"0.7464701",
"0.7410718",
"0.7409877",
"0.7327627",
"0.7323313",
"0.7304582",
"0.72164625",
"0.7214874",
"0.72084713",
"0.71855587",
"0.70754385",
"0.70535874",
"0.70356005",
"0.6986135",
"0.6983354",
"0.6978976",
"0.6892071",
"0.6885231",
"0.6814879... | 0.78546214 | 0 |
Compute the softmax of each element along an axis of X. | def softmax(X, theta = 1.0, axis = None):
# make X at least 2d
y = np.atleast_2d(X)
# find axis
if axis is None:
axis = next(j[0] for j in enumerate(y.shape) if j[1] > 1)
# multiply y against the theta parameter,
y = y * float(theta)
# subtract the max for numerical stability
y = y - np.expand_dims(np.ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(self, x):\n\n out = np.zeros(x.shape)\n for i in range(x.shape[0]):\n max_x = x[i] - np.max(x[i])\n out[i] = np.exp(max_x) / np.sum(np.exp(max_x), axis=0)\n\n return out",
"def softmax(x: npt.NDArray) -> npt.NDArray:\n row_wise_max = np.max(x, axis=1).res... | [
"0.8648168",
"0.8523443",
"0.8501356",
"0.845101",
"0.8424965",
"0.8401308",
"0.83822155",
"0.83788544",
"0.8372522",
"0.83631027",
"0.835532",
"0.8344603",
"0.8326291",
"0.8309666",
"0.82737535",
"0.8272703",
"0.82659155",
"0.824838",
"0.824838",
"0.8244414",
"0.82432497",
... | 0.0 | -1 |
convert a column from a select's "columns" clause. given a select() and a column element from its inner_columns collection, return a Label object if this column should be labeled in the columns clause. Otherwise, return None and the column will be used asis. The calling method will traverse the returned label to acquir... | def label_select_column(self, select, column):
# SQLite doesnt like selecting from a subquery where the column
# names look like table.colname. so if column is in a "selected from"
# subquery, label it synoymously with its column name
if \
(self.stack and self.stack[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _label(self, column):\n # XXX\n return column",
"def _get_column(self, column_or_label):\n c = column_or_label\n if isinstance(c, collections.Hashable) and c in self.column_labels:\n return self[c]\n else:\n assert len(c) == self.num_rows, 'column len... | [
"0.6369459",
"0.63435656",
"0.61962634",
"0.61262125",
"0.60707486",
"0.5874573",
"0.5780787",
"0.5736922",
"0.5468321",
"0.5404369",
"0.5373967",
"0.5372436",
"0.5368333",
"0.5356151",
"0.52621865",
"0.5244867",
"0.52299285",
"0.5227409",
"0.5212175",
"0.5209841",
"0.51956",... | 0.8088063 | 0 |
Construct a new ``IdentifierPreparer`` object. initial_quote Character that begins a delimited identifier. final_quote Character that ends a delimited identifier. Defaults to `initial_quote`. omit_schema Prevent prepending schema name. Useful for databases that do not support schemae. | def __init__(self, dialect, initial_quote='"', final_quote=None, omit_schema=False):
self.dialect = dialect
self.initial_quote = initial_quote
self.final_quote = final_quote or self.initial_quote
self.omit_schema = omit_schema
self.__strings = {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def PrepareIdentifier (s, in_use, aux_keywords=frozenset(), private=False, protected=False):\n s = DeconflictKeyword(MakeIdentifier(s).strip('_'), aux_keywords)\n if private:\n s = '__' + s\n elif protected:\n s = '_' + s\n return MakeUnique(s, in_use)",
"def from_parts(cls, year: int, ... | [
"0.52344036",
"0.48431653",
"0.47282967",
"0.46271473",
"0.45821825",
"0.4490583",
"0.4480203",
"0.43617234",
"0.4305039",
"0.42611578",
"0.42339948",
"0.42338768",
"0.42103657",
"0.4203634",
"0.41958946",
"0.418655",
"0.4172179",
"0.41227847",
"0.4100452",
"0.40884525",
"0.4... | 0.6530894 | 0 |
Escape an identifier. Subclasses should override this to provide databasedependent escaping behavior. | def _escape_identifier(self, value):
return value.replace('"', '""') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cypher_escape(identifier, **kwargs):\n if not isinstance(identifier, string_types):\n raise TypeError(type(identifier).__name__)\n encoder = CypherEncoder(**kwargs)\n return encoder.encode_key(identifier)",
"def quote_identifier(self, value):\n\n return self.initial_quote + self._escap... | [
"0.76901585",
"0.7171665",
"0.65619826",
"0.65088695",
"0.61848825",
"0.6037265",
"0.58837444",
"0.5860151",
"0.5817022",
"0.5760123",
"0.5731031",
"0.57090294",
"0.5649238",
"0.5634508",
"0.56285065",
"0.56276494",
"0.5619269",
"0.5584628",
"0.55839723",
"0.55744565",
"0.555... | 0.7771731 | 0 |
Canonicalize an escaped identifier. Subclasses should override this to provide databasedependent unescaping behavior that reverses _escape_identifier. | def _unescape_identifier(self, value):
return value.replace('""', '"') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _escape_identifier(self, value):\n\n return value.replace('\"', '\"\"')",
"def cypher_escape(identifier, **kwargs):\n if not isinstance(identifier, string_types):\n raise TypeError(type(identifier).__name__)\n encoder = CypherEncoder(**kwargs)\n return encoder.encode_key(identifier)",
... | [
"0.65034235",
"0.60171896",
"0.6013747",
"0.5867783",
"0.5840692",
"0.5691037",
"0.56629825",
"0.56344134",
"0.5533595",
"0.55119795",
"0.5463335",
"0.543442",
"0.53856874",
"0.5383206",
"0.53295106",
"0.529894",
"0.52880454",
"0.5247449",
"0.5217252",
"0.5204735",
"0.5202311... | 0.62047476 | 1 |
Quote an identifier. Subclasses should override this to provide databasedependent quoting behavior. | def quote_identifier(self, value):
return self.initial_quote + self._escape_identifier(value) + self.final_quote | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _escape_identifier(self, value):\n\n return value.replace('\"', '\"\"')",
"def quote(*a, **kw):\n return quote(*a, **kw)",
"def quote_id(self) -> Optional[str]:\n return pulumi.get(self, \"quote_id\")",
"def _quote(self, arg):\n arg = arg.replace('\\\\', '\\\\\\\\')\n a... | [
"0.6803792",
"0.62974304",
"0.62813836",
"0.6219816",
"0.62063813",
"0.6139694",
"0.6124852",
"0.59019285",
"0.5797045",
"0.57196015",
"0.56434613",
"0.558261",
"0.55634195",
"0.5561601",
"0.54825985",
"0.54253066",
"0.5424761",
"0.54112506",
"0.53987145",
"0.5398182",
"0.538... | 0.7929225 | 0 |
Prepare a quoted column name. | def format_column(self, column, use_table=False, name=None, table_name=None):
if name is None:
name = column.name
if not getattr(column, 'is_literal', False):
if use_table:
return self.format_table(column.table, use_schema=False, name=table_name) + "." + self.__ge... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encodeColumnName(self, column):\r\n return '\"{}\"'.format(column)",
"def _validate_column_name(col_name : str) -> str:\n\n if col_name[0].isdigit():\n return f'\"{col_name}\"'\n return col_name",
"def test_quoted_column_names_reading_specify_names(self):\n self.quoted_column_names... | [
"0.68267614",
"0.66763186",
"0.6517873",
"0.6474785",
"0.62641364",
"0.6239928",
"0.6202077",
"0.61548555",
"0.611496",
"0.611496",
"0.61074984",
"0.6096287",
"0.59523314",
"0.5924512",
"0.58921146",
"0.58921146",
"0.5803178",
"0.56872654",
"0.5643057",
"0.5600944",
"0.559376... | 0.54299146 | 26 |
Prepare a quoted column name with table name. | def format_column_with_table(self, column, column_name=None, table_name=None):
return self.format_column(column, use_table=True, name=column_name, table_name=table_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encodeColumnName(self, column):\r\n return '\"{}\"'.format(column)",
"def quote_name(self, name):\n if name.startswith(self.left_sql_quote) and name.endswith(self.right_sql_quote):\n return name # Quoting once is enough.\n return '%s%s%s' % (self.left_sql_quote, name, self.rig... | [
"0.6520167",
"0.6256638",
"0.6161232",
"0.61592764",
"0.597003",
"0.59199286",
"0.59132075",
"0.58414966",
"0.58414966",
"0.5752311",
"0.5744427",
"0.5720532",
"0.5717292",
"0.570639",
"0.57049805",
"0.5697452",
"0.5692428",
"0.56815195",
"0.567449",
"0.56293607",
"0.56027627... | 0.5139979 | 45 |
Returns the filtered queryset based on the value provided in the query string and retrievable via `self.value()`. | def queryset(self, request, queryset):
print("queryset: self.value() = {} with type = {}".format(self.value(), type(self.value())))
# Compare the requested value (either True or False)
# to decide how to filter the queryset.
filtered_person_ids = []
for person in Person.object... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queryset(self, request, queryset):\n # Compare the requested value (either '80s' or 'other')\n # to decide how to filter the queryset.\n\n if self.value() is None:\n return queryset.all()\n\n return queryset.filter(firm__pk=self.value())",
"def queryset(self, request, q... | [
"0.75409806",
"0.7420932",
"0.7244926",
"0.7205369",
"0.70882255",
"0.7050192",
"0.697692",
"0.6783912",
"0.67630154",
"0.67344415",
"0.66827345",
"0.6655746",
"0.6471968",
"0.6416057",
"0.6402888",
"0.6383319",
"0.6367874",
"0.6348132",
"0.63470876",
"0.62772644",
"0.6268568... | 0.65900356 | 12 |
Returns the filtered queryset based on the value provided in the query string and retrievable via `self.value()`. | def queryset(self, request, queryset):
print("queryset: self.value() = {} with type = {}".format(self.value(), type(self.value())))
filtered_person_ids = []
for person in Person.objects.all():
cur_position = person.get_latest_position()
if self.value() is None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queryset(self, request, queryset):\n # Compare the requested value (either '80s' or 'other')\n # to decide how to filter the queryset.\n\n if self.value() is None:\n return queryset.all()\n\n return queryset.filter(firm__pk=self.value())",
"def queryset(self, request, q... | [
"0.754024",
"0.7420306",
"0.7244771",
"0.72054714",
"0.7089471",
"0.70491016",
"0.69762397",
"0.6761089",
"0.67340565",
"0.66817456",
"0.6656211",
"0.65885806",
"0.64705604",
"0.64162385",
"0.64023226",
"0.63833594",
"0.63699883",
"0.63493246",
"0.6348757",
"0.62765163",
"0.6... | 0.6783078 | 7 |
Returns the filtered queryset based on the value provided in the query string and retrievable via `self.value()`. | def queryset(self, request, queryset):
print("queryset: self.value() = {} with type = {}".format(self.value(), type(self.value())))
filtered_pub_ids = []
for pub in Publication.objects.all():
if self.value() is None:
filtered_pub_ids.append(pub.id)
elif ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queryset(self, request, queryset):\n # Compare the requested value (either '80s' or 'other')\n # to decide how to filter the queryset.\n\n if self.value() is None:\n return queryset.all()\n\n return queryset.filter(firm__pk=self.value())",
"def queryset(self, request, q... | [
"0.75409806",
"0.7420932",
"0.7244926",
"0.7205369",
"0.70882255",
"0.7050192",
"0.697692",
"0.6783912",
"0.67630154",
"0.67344415",
"0.6655746",
"0.65900356",
"0.6471968",
"0.6416057",
"0.6402888",
"0.6383319",
"0.6367874",
"0.6348132",
"0.63470876",
"0.62772644",
"0.6268568... | 0.66827345 | 10 |
Returns the filtered queryset based on the value provided in the query string and retrievable via `self.value()`. | def queryset(self, request, queryset):
print("queryset: self.value() = {} with type = {}".format(self.value(), type(self.value())))
filtered_pub_ids = []
for pub in Publication.objects.all():
print("queryset: pub.book_title_short.lower() = {} self.value() = {}".format(pub.book_tit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queryset(self, request, queryset):\n # Compare the requested value (either '80s' or 'other')\n # to decide how to filter the queryset.\n\n if self.value() is None:\n return queryset.all()\n\n return queryset.filter(firm__pk=self.value())",
"def queryset(self, request, q... | [
"0.754024",
"0.7420306",
"0.7244771",
"0.72054714",
"0.7089471",
"0.70491016",
"0.6783078",
"0.6761089",
"0.67340565",
"0.66817456",
"0.6656211",
"0.65885806",
"0.64705604",
"0.64162385",
"0.64023226",
"0.63833594",
"0.63699883",
"0.63493246",
"0.6348757",
"0.62765163",
"0.62... | 0.69762397 | 6 |
Validates if the provided username is a valid UNIX username | def _is_valid_username(username):
return UNIX_USER_RE.match(username) is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_username(username):\n if username is None: # SQLite integrity check\n return False\n if len(username) > 32: # Arbitrary length cap\n return False\n if len(username) < 1: # Not-as-arbitrary length minimum\n return False\n for i in username:\n if i not in config.C... | [
"0.79573727",
"0.7757889",
"0.77010506",
"0.7651763",
"0.7626677",
"0.7536235",
"0.75265306",
"0.7501917",
"0.7479306",
"0.74507785",
"0.74310666",
"0.7419038",
"0.73955435",
"0.7392464",
"0.7320103",
"0.730303",
"0.72507656",
"0.7214872",
"0.7177691",
"0.71641016",
"0.715291... | 0.89550704 | 0 |
Return a view to use as the API root. | def get_api_root_view(self):
api_root_dict = {}
list_name = self.routes[0].name
for prefix, viewset, basename in self.registry:
api_root_dict[prefix] = list_name.format(basename=basename)
class APIRoot(views.APIView):
_ignore_model_permissions = True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_root():\r\n return render_template(\"index.html\"), 200",
"def get_root(self, request, *args, **kwargs):\n return self._root_factory(request, *args, **kwargs)",
"def get_api_root_view(self, api_urls=None):\n api_root_dict = OrderedDict()\n list_name = self.routes[0].name\n ... | [
"0.7414068",
"0.7298024",
"0.724371",
"0.71469635",
"0.70345426",
"0.70345426",
"0.70345426",
"0.7007782",
"0.69690424",
"0.6904303",
"0.685838",
"0.6843567",
"0.68409103",
"0.68318844",
"0.67578167",
"0.6753709",
"0.67217803",
"0.66900116",
"0.6664957",
"0.6649356",
"0.66385... | 0.8156992 | 0 |
Since we have create the Topping(PizzaTopping) model with the dunder method of string(__str__). It will return the string representation of the "name" attribute. We will check if that is same as what we have set. | def test_create_valid_topping_success(self):
topping = Topping.objects.create(name="Pepperoni")
self.assertEquals(str(topping), topping.name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return str(self.name)",
"def __str__(self):\n return str(self.name)",
"def __str__(self):\n return str(self.name)",
"def __str__(self):\n return str(self.name)",
"def __str__(self):\n return str(self.name)",
"def __str__(self):\n return str(s... | [
"0.68611056",
"0.68611056",
"0.68611056",
"0.68611056",
"0.68611056",
"0.68611056",
"0.68611056",
"0.67949563",
"0.67949563",
"0.66880953",
"0.6681636",
"0.6678034",
"0.6678034",
"0.6678034",
"0.66753346",
"0.66753346",
"0.66753346",
"0.66753346",
"0.66753346",
"0.66753346",
... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.