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 |
|---|---|---|---|---|---|---|
The name of the Event. | def event_name(self):
return dict.get(self, 'event_name', None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_name(self):\n return self._event_name",
"def getName(self):\n return _libsbml.Event_getName(self)",
"def cal_name(self):\n return self.event_name",
"def event_name(self, event_name):\n self['event_name'] = event_name",
"def setName(self, *args):\n return _libsbm... | [
"0.914251",
"0.8779574",
"0.8218363",
"0.7748643",
"0.7721498",
"0.771181",
"0.75794125",
"0.7545769",
"0.7544376",
"0.7417364",
"0.7392395",
"0.73624647",
"0.7352431",
"0.72882885",
"0.72882885",
"0.72882885",
"0.72882885",
"0.72882885",
"0.72882885",
"0.72882885",
"0.728828... | 0.88853073 | 1 |
Set the event name. | def event_name(self, event_name):
self['event_name'] = event_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_name(self, event_name):\n\n self._event_name = event_name",
"def setName(self, *args):\n return _libsbml.Event_setName(self, *args)",
"def set_name(self, _name):\n self.name = _name",
"def event_def_name(self, event_def_name):\n\n self._event_def_name = event_def_name",
... | [
"0.8554447",
"0.8545698",
"0.7631831",
"0.76218736",
"0.76011735",
"0.7582119",
"0.7563849",
"0.7563849",
"0.75514656",
"0.75162405",
"0.7503605",
"0.7490394",
"0.7490394",
"0.7490394",
"0.7490394",
"0.7490394",
"0.7444846",
"0.7444846",
"0.74408394",
"0.7368176",
"0.7335487"... | 0.87372917 | 0 |
Parses [(the VAR_TYPE) VAR_NAME] lines Returns the string and the type | def InterpretVariableDeclaration(line: str, variables: dict, report) -> (str,FClass.FiMVariable):
line_split = line.split(' ')
variable_name: str = ""
variable_type: FClass.FiMVariableTypes = FClass.FiMVariableTypes.UNKNOWN
variable_value = None
variable_constant = False
# Grab variable na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GrabVariableInitializerType(line: str) -> (FClass.FiMVariableTypes,int):\n # Boolean\n if line.startswith( FGlobal.Methods['Variable Boolean Array'] ):\n length = len( _findFirst(FGlobal.Methods['Variable Boolean Array'], lambda x: line.startswith(x)) )\n return FClass.FiMVariableTypes.BOOL... | [
"0.72110385",
"0.6684339",
"0.6570947",
"0.6499427",
"0.6297661",
"0.62916815",
"0.6266233",
"0.6097753",
"0.6085287",
"0.59952575",
"0.5978942",
"0.5960347",
"0.58345133",
"0.58036333",
"0.5784733",
"0.5764294",
"0.576198",
"0.5746267",
"0.5746129",
"0.57393914",
"0.5738034"... | 0.6406134 | 4 |
Load peak definitions. The method must assign a peak definition dictionary to the self._peak_definitions attribute. The dictionary must have the keys 'center', 'sigma', 'amplitude', 'gamma', with value of [value_P1, bounds_P1, (fraction, distance) wrt P1 for P2, ... (fraction, distance) wrt P1 for Pn] Examples self._pe... | def _read_peak_definitions(self, *args, **kwargs):
raise NotImplementedError("This method must be implemented when sub-classing") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_peak_def_high():\n\n high_cf_opts = np.arange(50, 90, 1)\n\n # Generate peak definitions\n while True:\n\n cur_cen = np.random.choice(high_cf_opts)\n cur_pw = np.random.choice(PW_OPTS, p=PW_PROBS)\n cur_bw = np.random.choice(BW_OPTS, p=BW_PROBS)\n\n peak = [cur_cen, cur... | [
"0.63168603",
"0.6046201",
"0.5977809",
"0.58854425",
"0.58608097",
"0.58536106",
"0.5828217",
"0.5789251",
"0.5698267",
"0.56628263",
"0.56188095",
"0.56003404",
"0.5578688",
"0.55731547",
"0.556175",
"0.5560203",
"0.5547177",
"0.5529511",
"0.5503513",
"0.5497738",
"0.548399... | 0.7050395 | 0 |
Create tree from sqlite data | def create_d3json(jsonfile="static/data/graph.json"):
gateway = None
devices = defaultdict(list)
colors = {}
jsdata = HomeNetwork.read_sqlite3_current(jsondata=True)
devices["nodes"] = json.loads(jsdata)
for anode in devices["nodes"]:
if "osfamily" in anod... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieveTrees(c):\n\n all_nodes = dict()\n root_nodes = list()\n c.execute('''SELECT id, parent_id, title FROM node''')\n data_db = c.fetchall()\n \n # Initialize nodes list\n for data_line in data_db:\n db_child_id = data_line[0]\n db_parent_id = data_line[1]\n child_... | [
"0.69889605",
"0.66388494",
"0.6530566",
"0.64830005",
"0.64660484",
"0.64467305",
"0.6440712",
"0.63859665",
"0.63048893",
"0.6299472",
"0.6292835",
"0.62872106",
"0.62469125",
"0.62220967",
"0.62200874",
"0.6200817",
"0.6181151",
"0.6166043",
"0.6156164",
"0.6149793",
"0.61... | 0.0 | -1 |
Used to identify billing contact for stripe. | def email(self):
billing_contact = self.owner.organization_user.user
return billing_contact.email | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def billing_contact(self):\n return self._billing_contact",
"def get_billing_phone(self):\n if self.billing_phone:\n return self.billing_phone\n else:\n return self.contact.phone",
"def get_billing_name(self):\n if self.billing_name:\n return self.bi... | [
"0.7473322",
"0.70917904",
"0.70506287",
"0.67928725",
"0.6522469",
"0.6520297",
"0.6471558",
"0.64629865",
"0.6441742",
"0.62100846",
"0.62100846",
"0.62100846",
"0.62068194",
"0.6200433",
"0.61957145",
"0.61838496",
"0.61838496",
"0.61832756",
"0.61832756",
"0.6139515",
"0.... | 0.5277616 | 44 |
This function receives information from the main screen and writes it to a file with the extension json | def save_json_file():
global output_on_display, import_lst, column_names, data, new_data
if data_base == '':
mistake_load_table()
else:
column_names = new_data
step = len(column_names)
save_name = asksaveasfilename(title="Select file", filetypes=(("JSON", "*.json"), ("all fil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_to_file(data):\n\ttry:\n\t\toutput_file = open(\"output.json\", \"w\")\n\t\toutput_file.write(json.dumps(data))\n\texcept:\n\t print(Fore.GREEN + \"File not found or path is incorrect\")\n\tfinally:\n\t print(Fore.GREEN + \"Success go to output.json to look at the json\")",
"def save(filename, ... | [
"0.6821808",
"0.6820264",
"0.68076766",
"0.67360204",
"0.6712457",
"0.66676414",
"0.66601896",
"0.6612663",
"0.6594357",
"0.6560248",
"0.6553303",
"0.65516794",
"0.6528116",
"0.65225524",
"0.65145713",
"0.6495577",
"0.6492085",
"0.6475345",
"0.6475345",
"0.6472494",
"0.646146... | 0.6361456 | 30 |
Calculates the atom density of a material given a material with atom densities defined. | def set_atom_fractions(self, void_percent=1.0):
for zaidNum, zaid in enumerate(self.zaids):
for isotope, isotopeFraction in self.elementDict[zaid].atomPercentDict.items():
if zaid in self.isotopicAtomPercents:
print(self.elementDict[zaid].weightPercentDict[isotope... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Density(material):\n if material == \"mild\":\n return 7850.0\n else:\n if material == \"al\":\n return 2700.0\n else:\n raise ValueError(\"Invalid material `\"+material+\"'\")",
"def GetDensityForShape(*args):\n return _XCAFDoc.XCAFDoc_MaterialTool_Get... | [
"0.7006211",
"0.65377265",
"0.64411473",
"0.6376021",
"0.6268337",
"0.6262631",
"0.6240578",
"0.6213191",
"0.6193817",
"0.61501926",
"0.6084178",
"0.6075045",
"0.60393673",
"0.5935808",
"0.5922256",
"0.5920612",
"0.5896682",
"0.5895164",
"0.58939546",
"0.58643734",
"0.5850352... | 0.0 | -1 |
Returns a smeared material for the coolant and wire wrap. | def smear_coolant_wirewrap(info):
height = info[0]
fuel_radius = info[1] / 2
wirewrap_radius = info[2] / 2
wire_wrap_axial_pitch = info[3]
fuel_pitch = info[4]
coolant_material = info[5]
clad_material = info[6]
fuel_volume = utilities.get_cylinder_volume(fuel_radius, height)
wire_wra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_smeared_material(materials, void_material='', void_percent=1.0):\n smear_material = {}\n for material, materialWeightPercent in materials.items():\n void_multiplier = 1.0\n if material == 'Void':\n pass\n else:\n base_material = Material()\n base_... | [
"0.66321373",
"0.62594223",
"0.60387546",
"0.5944046",
"0.5875552",
"0.5739568",
"0.56960857",
"0.56770736",
"0.564192",
"0.55646825",
"0.5525133",
"0.5470988",
"0.5465184",
"0.54306227",
"0.54144156",
"0.5376519",
"0.5360755",
"0.5315837",
"0.52805245",
"0.52402693",
"0.5233... | 0.7692396 | 0 |
Returns the path of the local (downloaded) zip file | def zipname(self):
_, tail = os.path.split(self.url)
return self.folder + '/' + tail | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_ReportsZipPath(self):\n path_to_zip_file = self.xbrl_download_dir + '\\Informes.zip'\n return path_to_zip_file",
"def getZipArchiveFullPath(self):\n\n if self._mode == \"zip\":\n return self._rootExportPath + \".zip\"\n\n return \"\"",
"def get_zipfile_path(url,... | [
"0.7133516",
"0.709186",
"0.7052304",
"0.67431414",
"0.6729529",
"0.6682555",
"0.6651933",
"0.66154504",
"0.65643615",
"0.65585375",
"0.64418876",
"0.64405274",
"0.6428813",
"0.63516",
"0.63464946",
"0.6346317",
"0.6336631",
"0.62781155",
"0.6277847",
"0.6277847",
"0.6265609"... | 0.681256 | 3 |
Takes the URL and extracts the table name based on filename | def tablename(self):
_, tail = os.path.split(self.url)
return tail[:-4] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_table_name(url):\n try:\n return urlparse(url).path.strip('/').split('/')[1]\n except IndexError:\n return None",
"def convertTableName(fileName: str):\n if m := pattern.match(fileName):\n return m.group(\"tableName\")",
"def get_table_from_dataset_path(ds... | [
"0.8116714",
"0.6845925",
"0.6461912",
"0.6457437",
"0.63222957",
"0.6306733",
"0.62379616",
"0.6237906",
"0.60564196",
"0.6036914",
"0.601242",
"0.60033494",
"0.59999204",
"0.5986188",
"0.58853424",
"0.58568525",
"0.581859",
"0.5806277",
"0.5776187",
"0.57597035",
"0.5732305... | 0.7307592 | 1 |
Saves a reference picture and an accompanying difference picture to /saved_images/ in the current working directory. | def saveMotionDiffPair(aMotionImg, aDiffImg, aTimestamp, aTag):
motionImgName = './saved_images/' + aTimestamp + aTag + '.jpg'
diffImgName = './saved_images/' + aTimestamp + aTag + 'diff.jpg'
cv2.imwrite(motionImgName, aMotionImg)
cv2.imwrite(diffImgName, aDiffImg) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_img(self):\r\n self.extract_info_from_file()\r\n path_0 = os.path.join(self.output_path, self.field_id, self.patient_id + self.ext)\r\n path_1 = os.path.join(self.output_path, self.field_id + '_' + self.instance, self.patient_id + self.ext)\r\n if self.shot == '0': # first sho... | [
"0.706071",
"0.6954861",
"0.6775793",
"0.6679474",
"0.63764745",
"0.6267105",
"0.62616324",
"0.61953914",
"0.6180397",
"0.61716527",
"0.6164669",
"0.6147488",
"0.61230916",
"0.6097626",
"0.6087242",
"0.6083324",
"0.601656",
"0.5958957",
"0.59300005",
"0.59122884",
"0.5903185"... | 0.61618084 | 11 |
Will remove the blobs that are smaller than the specified amount in an image. | def removeSmallBlobs(aDiffImg, aMinArea):
# First let us get a list of all the blob areas in the picture
blobs, numBlobs = getBlobs(aDiffImg)
blobAreaList = getBlobAreaList(blobs, numBlobs)
# Extract the labels we want to remove. The label is index+1.
labelList = list()
for index in range(len(b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size_filter(db, threshold):\n idx2rm = []\n for i, x in db.iterrows():\n if x['size'] < threshold:\n idx2rm.append(i)\n\n print(\"Numero de imagenes: \",len(db)-len(idx2rm),\" de \", len(db))\n return db.drop(idx2rm)",
"def remove_small_objects(img, min_size=7500):\n img2 = n... | [
"0.70217144",
"0.654012",
"0.63129383",
"0.63080096",
"0.62526983",
"0.61300766",
"0.5933446",
"0.59267145",
"0.5919248",
"0.59090453",
"0.59090453",
"0.588557",
"0.5872041",
"0.58580405",
"0.5851809",
"0.5838447",
"0.56530607",
"0.56007165",
"0.5590379",
"0.5580091",
"0.5575... | 0.6408585 | 2 |
Get the delta X from a right direction | def test_findXCoordinateFromDirection_right(self):
actual_result = rules.findXCoordinateFromDirection(3)
expected_result = 2
self.assertEqual(actual_result, expected_result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pos_right(self, x=1):\n\n self.x += x\n return self.pos(self.x, self.y)",
"def right_distance(self):\n return self.board.length - 1 - self.x",
"def downleft(self):\n return Coord([self.x - 1, self.y + 1])",
"def __get_x__(self):\n return self.Direction['x']",
"def dow... | [
"0.7264559",
"0.7254064",
"0.70186067",
"0.69288874",
"0.68650204",
"0.6834055",
"0.6834055",
"0.68162286",
"0.68127686",
"0.6766622",
"0.6632616",
"0.6575811",
"0.653798",
"0.651622",
"0.64885324",
"0.6469153",
"0.6453102",
"0.64430046",
"0.64377105",
"0.6426004",
"0.6399436... | 0.6203853 | 28 |
Get the delta Y from a left direction | def test_findYCoordinateFromDirection_left(self):
actual_result = rules.findYCoordinateFromDirection(7)
expected_result = 0
self.assertEqual(actual_result, expected_result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def downleft(self):\n return Coord([self.x - 1, self.y + 1])",
"def get_left(self):\n return -self.l_motor.get()",
"def pos_down(self, y=1):\n\n self.y += y\n return self.pos(self.x, self.y)",
"def upleft(self):\n return Coord([self.x - 1, self.y - 1])",
"def __get_y__(se... | [
"0.735407",
"0.7098737",
"0.69108516",
"0.6823766",
"0.6746996",
"0.6623058",
"0.6428845",
"0.6383905",
"0.6308379",
"0.63070005",
"0.6301892",
"0.6296186",
"0.62940204",
"0.6260142",
"0.6233566",
"0.6217046",
"0.6187829",
"0.61841154",
"0.6119185",
"0.6114301",
"0.61121523",... | 0.67268586 | 5 |
Get the delta Y from a right direction | def test_findYCoordinateFromDirection_up(self):
actual_result = rules.findYCoordinateFromDirection(1)
expected_result = 2
self.assertEqual(actual_result, expected_result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_y__(self):\n return self.Direction['y']",
"def calculate_position_y(cls, position_y, direction):\n cls.raise_exception_if_invalid_direction(direction)\n return position_y + cls.DIRECTION_MAPPER[direction][1]",
"def getBotRightVelocity(self):\n\t\tif len(self.prevPositions) < 2:\n... | [
"0.7415944",
"0.7058163",
"0.6893687",
"0.6861486",
"0.679843",
"0.67935485",
"0.67726815",
"0.6753201",
"0.6743264",
"0.6693129",
"0.6676823",
"0.6672408",
"0.6672115",
"0.6671134",
"0.66600674",
"0.6654607",
"0.6645873",
"0.6626593",
"0.66253406",
"0.6601017",
"0.65896916",... | 0.6340395 | 45 |
Get the delta Y from a left direction | def test_findYCoordinateFromDirection_down(self):
actual_result = rules.findYCoordinateFromDirection(4)
expected_result = -2
self.assertEqual(actual_result, expected_result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def downleft(self):\n return Coord([self.x - 1, self.y + 1])",
"def get_left(self):\n return -self.l_motor.get()",
"def pos_down(self, y=1):\n\n self.y += y\n return self.pos(self.x, self.y)",
"def upleft(self):\n return Coord([self.x - 1, self.y - 1])",
"def __get_y__(se... | [
"0.735407",
"0.7098737",
"0.69108516",
"0.6823766",
"0.6746996",
"0.67268586",
"0.6623058",
"0.6428845",
"0.6383905",
"0.6308379",
"0.63070005",
"0.6301892",
"0.6296186",
"0.62940204",
"0.6260142",
"0.6233566",
"0.6217046",
"0.6187829",
"0.61841154",
"0.6119185",
"0.6114301",... | 0.59450686 | 46 |
Initialize the graphics view. | def __init__(self, type, controller):
super(GUI, self).__init__()
self.controller = controller
self.layout = QtWidgets.QHBoxLayout(self)
self.leftSide = QtWidgets.QVBoxLayout(self)
self.generateWidget = Generate(self, self.controller)
self.leftSide.addWidget(self.gene... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_graphics(self):\n self.renderer = vtk.vtkRenderer()\n self.window = vtk.vtkRenderWindow()\n self.window.AddRenderer(self.renderer)\n self.renderer.SetBackground(1.0, 1.0, 1.0)\n self.window.SetSize(1000, 1000)\n\n # Create a trackball interacter to transofor... | [
"0.738486",
"0.7245235",
"0.7245235",
"0.71699125",
"0.69324094",
"0.6878057",
"0.68248576",
"0.67956203",
"0.67449474",
"0.67285466",
"0.67102",
"0.67010546",
"0.66953194",
"0.66546637",
"0.6624726",
"0.6610313",
"0.6596297",
"0.6591724",
"0.6586789",
"0.65769166",
"0.655664... | 0.0 | -1 |
Return an operator given the path to a database. | def loadOperator(pathToDb, loadCycle, loadNode, allowMissing=False):
# `import armi` doesn't work if imported at top
from armi import cases
if not os.path.exists(pathToDb):
raise ValueError(
f"Specified database at path {pathToDb} does not exist. \n\n"
"Double check that esc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def operator(self):\n col = self.pos\n operators = [\"||\", \"&&\", \">>\", \"<<\", \"!=\", \">=\", \"<=\", \"==\", \"##\"] + \\\n [\"-\", \"+\", \"!\", \"*\", \"/\", \"|\", \"&\", \"^\", \"<\", \">\", \"?\", \":\", \"~\", \"#\", \"=\", \"%\"]\n try:\n index = self.match_... | [
"0.5361934",
"0.5345323",
"0.52730507",
"0.5133861",
"0.51303923",
"0.5125685",
"0.5095104",
"0.5086308",
"0.5076296",
"0.50663847",
"0.504918",
"0.5047888",
"0.5047888",
"0.5047888",
"0.5047888",
"0.5047888",
"0.5047888",
"0.5047888",
"0.5047888",
"0.5047888",
"0.5047888",
... | 0.5978742 | 0 |
Load instance masks for the given image. Different datasets use different ways to store masks. Override this method to load instance masks and return them in the form of am array of binary masks of shape [height, width, instances]. | def load_mask(self, image_id):
# Override this function to load a mask from your dataset.
# Otherwise, it returns an empty mask.
mask = np.empty([0, 0, 0])
class_ids = np.empty([0], np.int32)
return mask, class_ids | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_mask(self, image_id):\n # If not a vesicle dataset image, delegate to parent class.\n image_info = self.image_info[image_id]\n if image_info[\"source\"] != \"vesicle\":\n return super(self.__class__, self).load_mask(image_id)\n\n # Convert polygons to a bitmap mask o... | [
"0.7870074",
"0.7866982",
"0.78071177",
"0.7536204",
"0.7487115",
"0.7484187",
"0.74017537",
"0.7394961",
"0.73513556",
"0.73370403",
"0.7289716",
"0.7251488",
"0.7209784",
"0.7201714",
"0.711484",
"0.71026736",
"0.70940757",
"0.6973878",
"0.6933921",
"0.68129724",
"0.6784072... | 0.7264167 | 11 |
Resizes a mask using the given scale and padding. Typically, you get the scale and padding from resize_image() to ensure both, the image and the mask, are resized consistently. | def resize_mask(mask, scale, padding):
h, w = mask.shape[:2]
mask = scipy.ndimage.zoom(mask, zoom=[scale, scale, 1], order=0)
mask = np.pad(mask, padding, mode='constant', constant_values=0)
return mask | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resize_mask(mask, scale, padding, crop=None):\n # Suppress warning from scipy 0.13.0, the output shape of zoom() is\n # calculated with round() instead of int()\n with warnings.catch_warnings():\n warnings.simplefilter(\"ignore\")\n mask = scipy.ndimage.zoom(mask, zoom=[scale, scale, 1],... | [
"0.7524376",
"0.6026159",
"0.60111076",
"0.5996426",
"0.59808886",
"0.59013957",
"0.58934987",
"0.58934987",
"0.58655715",
"0.5847212",
"0.5544648",
"0.55316556",
"0.551225",
"0.55118865",
"0.5439356",
"0.5435618",
"0.5432131",
"0.5410762",
"0.5406681",
"0.5390748",
"0.538310... | 0.78870475 | 0 |
Compute bounding boxes from masks. | def extract_bboxes(mask):
boxes = np.zeros([mask.shape[-1], 4], dtype=np.int32)
for i in range(mask.shape[-1]):
m = mask[:, :, i]
# Bounding box.
horizontal_indicies = np.where(np.any(m, axis=0))[0]
vertical_indicies = np.where(np.any(m, axis=1))[0]
if horizontal_indicies... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_bboxes(mask):\r\n boxes = np.zeros([mask.shape[-1], 4], dtype=np.int32)\r\n for i in range(mask.shape[-1]):\r\n m = mask[:, :, i]\r\n # Bounding box.\r\n horizontal_indicies = np.where(np.any(m, axis=0))[0]\r\n vertical_indicies = np.where(np.any(m, axis=1))[0]\r\n ... | [
"0.78467315",
"0.78130674",
"0.77246463",
"0.7462639",
"0.73268336",
"0.7318628",
"0.7165459",
"0.70358133",
"0.7027821",
"0.6983254",
"0.68408525",
"0.6769498",
"0.6769209",
"0.6680738",
"0.66408485",
"0.6610212",
"0.66068614",
"0.6589283",
"0.65518355",
"0.64983237",
"0.649... | 0.7821438 | 1 |
Calculates IoU of the given box with the array of the given boxes. | def compute_iou(box, boxes, box_area, boxes_area):
# Calculate intersection areas
x1 = np.maximum(box[0], boxes[:, 0])
x2 = np.minimum(box[2], boxes[:, 2])
y1 = np.maximum(box[1], boxes[:, 1])
y2 = np.minimum(box[3], boxes[:, 3])
intersection = np.maximum(x2 - x1, 0) * np.maximum(y2 - y1, 0)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_iou(box, boxes):\n # Calculate intersection areas\n iou = [box.intersection(b).area / box.union(b).area for b in boxes]\n\n return np.array(iou, dtype=np.float32)",
"def compute_iou(box, boxes, box_area, boxes_area):\n # Calculate intersection areas\n y1 = np.maximum(box[0], boxes[:, 0... | [
"0.8233654",
"0.8116598",
"0.8116598",
"0.8116598",
"0.80252707",
"0.79859704",
"0.7928408",
"0.77582073",
"0.77385104",
"0.77119327",
"0.7706524",
"0.7639222",
"0.7638932",
"0.7638932",
"0.76373506",
"0.76087755",
"0.76022065",
"0.76022065",
"0.75603807",
"0.7515975",
"0.721... | 0.8128509 | 1 |
Computes IoU overlaps between two sets of boxes. | def compute_overlaps(boxes1, boxes2):
# Areas of anchors and GT boxes
area1 = (boxes1[:, 2] - boxes1[:, 0]) * (boxes1[:, 3] - boxes1[:, 1])
area2 = (boxes2[:, 2] - boxes2[:, 0]) * (boxes2[:, 3] - boxes2[:, 1])
# Compute overlaps to generate matrix [boxes1 count, boxes2 count]
# Each cell contains t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bbox_overlaps(bboxes1, bboxes2, mode='iou'):\n\n from icv.data.core.bbox import BBox\n assert mode in ['iou', 'iof']\n\n bboxes1 = np.array([np.array(b.bbox) if isinstance(b,BBox) else b for b in bboxes1])\n bboxes2 = np.array([np.array(b.bbox) if isinstance(b,BBox) else b for b in bboxes2])\n\n ... | [
"0.7990615",
"0.7887685",
"0.76905334",
"0.76589406",
"0.76580244",
"0.75641197",
"0.75641197",
"0.7538061",
"0.7536853",
"0.75354326",
"0.7535125",
"0.75168645",
"0.74753267",
"0.7447682",
"0.7441888",
"0.74396497",
"0.7353138",
"0.733241",
"0.7319857",
"0.7306891",
"0.72513... | 0.81738555 | 1 |
Polynomial decay of learning rate | def poly_lr_scheduler(optimizer, init_lr, iter, lr_decay_iter=1, max_iter=89280, power=0.9):
curr_lr = init_lr
if iter % lr_decay_iter or iter > max_iter:
return curr_lr
for param_group in optimizer.param_groups:
curr_lr = init_lr * (1 - iter / max_iter) ** power
param_group['lr'] =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lr_decay(step):\n return(alpha / (1 + decay_rate * step))",
"def decay_learning_rate(initial_learning_rate, i, n_iterations):\n return initial_learning_rate * np.exp(-i / n_iterations)",
"def learning_rate_decay(alpha, decay_rate, global_step, decay_step):\n epoc_number = int(global_st... | [
"0.7101829",
"0.7059696",
"0.6914346",
"0.6776829",
"0.67757654",
"0.67602867",
"0.67482287",
"0.6728288",
"0.67137057",
"0.67137057",
"0.6695183",
"0.66131467",
"0.65852076",
"0.6568543",
"0.6567431",
"0.65560806",
"0.6546024",
"0.6538584",
"0.65287113",
"0.6522781",
"0.6497... | 0.5925285 | 62 |
r""" Calculates various metrics for each labeled region in a 3D image. This functions offers a few extras for 3D images that are not provided by the ``regionprops`` function in ``scikitimage``. | def regionprops_3D(im):
results = regionprops(im)
for i, obj in enumerate(results):
a = results[i]
b = RegionPropertiesPS(a.slice,
a.label,
a._label_image,
a._intensity_image,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def computerecondensity(d3d, label, leafs=16, PIX=10, IMGMAX=40000):\n points = d3d[:, :2].copy()\n mx, MX = np.min(points[:, 0]), np.max(points[:, 0])\n my, MY = np.min(points[:, 1]), np.max(points[:, 1])\n if mx < 0:\n points[:, 0] += np.abs(mx)\n print(\"Neg pos for {}\".format(label))... | [
"0.5946176",
"0.5602765",
"0.5601565",
"0.5576514",
"0.55764306",
"0.5502203",
"0.54844123",
"0.5399035",
"0.53916234",
"0.53817475",
"0.53667015",
"0.5359348",
"0.5357632",
"0.53525645",
"0.5342931",
"0.53415495",
"0.5309446",
"0.5309116",
"0.5304132",
"0.53030264",
"0.53002... | 0.6498146 | 0 |
Set a new Plex Home PIN for a managed home user. This must be done from the Plex Home admin account. | def setManagedUserPin(self, user, newPin):
user = user if isinstance(user, MyPlexUser) else self.user(user)
url = self.MANAGEDHOMEUSER.format(userId=user.id)
params = {'pin': newPin}
return self.query(url, self._session.post, params=params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setPin(self, newPin, currentPin=None):\n url = self.HOMEUSER.format(userId=self.id)\n params = {'pin': newPin}\n if currentPin:\n params['currentPin'] = currentPin\n return self.query(url, self._session.put, params=params)",
"def home_phone_number(self, home_phone_numbe... | [
"0.65767866",
"0.57163674",
"0.5661071",
"0.5636177",
"0.5433339",
"0.5433339",
"0.5417261",
"0.5402434",
"0.53720695",
"0.53613627",
"0.5345811",
"0.53364843",
"0.52735096",
"0.5249116",
"0.5218774",
"0.5218737",
"0.521368",
"0.518866",
"0.51820076",
"0.51588714",
"0.5135046... | 0.7289205 | 0 |
Get all Play History for a user in all shared servers. | def history(self, maxresults=None, mindate=None):
hist = []
for server in self.servers:
hist.extend(server.history(maxresults=maxresults, mindate=mindate))
return hist | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def history(self, maxresults=None, mindate=None):\n servers = [x for x in self.resources() if x.provides == 'server' and x.owned]\n hist = []\n for server in servers:\n conn = server.connect()\n hist.extend(conn.history(maxresults=maxresults, mindate=mindate, accountID=1)... | [
"0.68091244",
"0.66874796",
"0.65401554",
"0.6415962",
"0.61404586",
"0.60052866",
"0.59981656",
"0.5929341",
"0.5906145",
"0.5895015",
"0.58845526",
"0.58747715",
"0.5853269",
"0.57827127",
"0.5767588",
"0.5760741",
"0.57576877",
"0.57384866",
"0.5734536",
"0.57342786",
"0.5... | 0.64243823 | 3 |
Get all Play History for a user for this section in this shared server. | def history(self, maxresults=None, mindate=None):
server = self._server._server.resource(self._server.name).connect()
return server.history(maxresults=maxresults, mindate=mindate,
accountID=self._server.accountID, librarySectionID=self.sectionKey) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_history(user_id):\n return History.where('user_id', user_id).get()",
"def get_game_history(self, request):\n return games_ctrl.get_game_history(request.urlsafe_game_key)",
"def get_game_history(self, req):\n return models.BattleShip.getByUrlKey(req.url_key).getHistory()",
"def histo... | [
"0.6978014",
"0.6969228",
"0.6638498",
"0.65219235",
"0.6497225",
"0.6410002",
"0.6367215",
"0.6261751",
"0.6252674",
"0.62357324",
"0.62320465",
"0.62255275",
"0.619295",
"0.6162945",
"0.6137662",
"0.61277443",
"0.6118014",
"0.611488",
"0.6106509",
"0.6078418",
"0.6065834",
... | 0.59333855 | 37 |
Get all Play History for a user in this shared server. | def history(self, maxresults=9999999, mindate=None):
server = self._server.resource(self.name).connect()
return server.history(maxresults=maxresults, mindate=mindate, accountID=self.accountID) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_game_history(self, request):\n return games_ctrl.get_game_history(request.urlsafe_game_key)",
"def show_history(user_id):\n return History.where('user_id', user_id).get()",
"def get_game_history(self, req):\n return models.BattleShip.getByUrlKey(req.url_key).getHistory()",
"def get_u... | [
"0.7164864",
"0.70367354",
"0.697591",
"0.66738105",
"0.6545098",
"0.65412354",
"0.64714295",
"0.645157",
"0.63795525",
"0.6374508",
"0.6345612",
"0.6320159",
"0.6312117",
"0.6295848",
"0.6290764",
"0.6258834",
"0.6240537",
"0.6216408",
"0.6216408",
"0.62016493",
"0.6195327",... | 0.60635304 | 38 |
Creates the ScheduledEvents table. | async def create_table_scheduled_events(self, ctx: commands.Context) -> None:
member = ctx.author
await ctx.message.delete()
if await self.check_scheduled_events_exists():
return await ctx.send(f"**Table `ScheduledEvents` already exists, {member.mention}!**")
mycur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_table(self):\n self.c.execute(\n \"\"\"CREATE TABLE IF NOT EXISTS {table} (\n id integer primary key,\n {event} integer,\n {desc} text,\n {date} text,\n {link} text)\n \"\"\".format(\n table=TABLE,\n ... | [
"0.6760438",
"0.66445494",
"0.6625416",
"0.6529982",
"0.64881086",
"0.64517707",
"0.64487267",
"0.6446051",
"0.62144834",
"0.6160995",
"0.61342657",
"0.6047282",
"0.6020282",
"0.59020716",
"0.58956474",
"0.5894661",
"0.5871112",
"0.5869499",
"0.5816645",
"0.5795914",
"0.57930... | 0.8704623 | 0 |
Creates the ScheduledEvents table. | async def drop_table_scheduled_events(self, ctx: commands.Context) -> None:
member = ctx.author
await ctx.message.delete()
if not await self.check_scheduled_events_exists():
return await ctx.send(f"**Table `ScheduledEvents` doesn't exist, {member.mention}!**")
mycursor, db... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def create_table_scheduled_events(self, ctx: commands.Context) -> None:\n\n member = ctx.author\n await ctx.message.delete()\n\n if await self.check_scheduled_events_exists():\n return await ctx.send(f\"**Table `ScheduledEvents` already exists, {member.mention}!**\")\n ... | [
"0.8704623",
"0.6760438",
"0.66445494",
"0.6529982",
"0.64881086",
"0.64517707",
"0.64487267",
"0.6446051",
"0.62144834",
"0.6160995",
"0.61342657",
"0.6047282",
"0.6020282",
"0.59020716",
"0.58956474",
"0.5894661",
"0.5871112",
"0.5869499",
"0.5816645",
"0.5795914",
"0.57930... | 0.6625416 | 3 |
Creates the ScheduledEvents table. | async def reset_table_scheduled_events(self, ctx: commands.Context) -> None:
member = ctx.author
await ctx.message.delete()
if not await self.check_scheduled_events_exists():
return await ctx.send(f"**Table `ScheduledEvents` doesn't exist yet, {member.mention}!**")
mycurso... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def create_table_scheduled_events(self, ctx: commands.Context) -> None:\n\n member = ctx.author\n await ctx.message.delete()\n\n if await self.check_scheduled_events_exists():\n return await ctx.send(f\"**Table `ScheduledEvents` already exists, {member.mention}!**\")\n ... | [
"0.8704623",
"0.6760438",
"0.66445494",
"0.6625416",
"0.6529982",
"0.64517707",
"0.64487267",
"0.6446051",
"0.62144834",
"0.6160995",
"0.61342657",
"0.6047282",
"0.6020282",
"0.59020716",
"0.58956474",
"0.5894661",
"0.5871112",
"0.5869499",
"0.5816645",
"0.5795914",
"0.579309... | 0.64881086 | 5 |
Checks whether the advertising time is due. | async def check_advertising_time(self, current_ts: int, event_label: str, ad_time: int) -> bool:
mycursor, _ = await the_database()
await mycursor.execute("""
SELECT * from ScheduledEvents
WHERE event_label = %s AND %s - event_ts >= %s
""", (event_label, current_ts, ad_t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_attack(self):\n now = time.time() * 1000\n if self.prev_time is None:\n return True\n else:\n next_time = self.prev_time + self.get_recharge\n if now >= next_time:\n return True\n else:\n return False",
"def ... | [
"0.72752774",
"0.6964547",
"0.6849957",
"0.6738011",
"0.66971064",
"0.6653395",
"0.6607808",
"0.657862",
"0.6547221",
"0.65231436",
"0.6503476",
"0.64633894",
"0.64558476",
"0.64554447",
"0.645044",
"0.6448048",
"0.6444591",
"0.6404285",
"0.6402235",
"0.6397026",
"0.63682806"... | 0.73352146 | 0 |
Time elapsed since data last received, in seconds as float. | def idle(self):
return (datetime.datetime.now() - self._last_received).total_seconds() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ms(self):\n # my clock uses seconds internally\n return 1000 * self.read()",
"def recv_time(self) -> float:\n return ntp_to_system_time(self.recv_timestamp)",
"def elapsed_time_in_seconds(self):\n return self._elapsed_time_in_seconds",
"def get_elapsed(self):\n delta = ... | [
"0.75423217",
"0.73701847",
"0.732486",
"0.7265605",
"0.7202403",
"0.717337",
"0.71578866",
"0.7030599",
"0.70195496",
"0.69572425",
"0.6928816",
"0.69168377",
"0.69168377",
"0.69168377",
"0.69168377",
"0.69168377",
"0.69168377",
"0.69095606",
"0.69031376",
"0.6891059",
"0.68... | 0.64703196 | 65 |
Creates a new mapping for an object. | def add_object(world_id, object_to_be_added):
try:
new_mapping = Map(world_id,
object_to_be_added.x,
object_to_be_added.y,
object_to_be_added.__class__.__name__)
new_mapping.save()
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_mapping(self):\n\n indice = client.IndicesClient(self.es)\n\n indice.put_mapping(index=self.es_main_index,\n doc_type=self.es_main_type,\n body=self.mapping)",
"def createObjectPropertyMap(self, propertyName: unicode, objectClass: java.... | [
"0.6933795",
"0.6713559",
"0.64649796",
"0.6422688",
"0.6359902",
"0.63087314",
"0.61878854",
"0.6184359",
"0.61745393",
"0.61547184",
"0.6150395",
"0.6137379",
"0.61200297",
"0.61163414",
"0.60887134",
"0.6078142",
"0.60079116",
"0.588799",
"0.588419",
"0.58624023",
"0.58471... | 0.6281971 | 6 |
Change from date to month | def date_to_month(date):
return re.sub(r'(\d{4}-\d{2})-\d{2}', r'\1', date) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_month(date):\n return date.month",
"def MONTH(date):\n return _make_datetime(date).month",
"def setMonth(self, *args):\n return _libsbml.Date_setMonth(self, *args)",
"def get_month(self, indate):\n return indate.strftime(\"%B\") + \"-\" + indate.strftime(\"%Y\")",
"def decrement_... | [
"0.77243966",
"0.735111",
"0.71769124",
"0.71729517",
"0.6849947",
"0.6843161",
"0.6707294",
"0.66655874",
"0.6617973",
"0.661158",
"0.6599854",
"0.6599854",
"0.65967923",
"0.6558509",
"0.65565616",
"0.65458804",
"0.6489243",
"0.64884037",
"0.63371634",
"0.63212645",
"0.63069... | 0.7433812 | 1 |
Generate a month step of dates | def date_range(starting_date, ending_date):
l = list()
curr_month = get_date_end_num(starting_date)
e_y, e_m, _ = map(int, ending_date.split('-'))
c_y, c_m, _ = map(int, curr_month.split('-'))
while e_y > c_y or (e_y == c_y and e_m >= c_m):
l.append(curr_month)
c_m += 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def per_month(start: datetime, end: datetime, n: int = 1):\n curr = start.replace(day=1, hour=0, minute=0, second=0, microsecond=0)\n while curr < end:\n curr_end = add_month(curr, n)\n yield curr, curr_end\n curr = curr_end",
"def daysPassedMonth():\n daysPerMonth = np.array([31,28... | [
"0.6915523",
"0.65227723",
"0.65222013",
"0.6505257",
"0.6489711",
"0.64721024",
"0.6427783",
"0.63848954",
"0.638474",
"0.63519174",
"0.6351915",
"0.6335714",
"0.6320129",
"0.63189155",
"0.6214998",
"0.62080663",
"0.6198794",
"0.61806583",
"0.6155854",
"0.61311424",
"0.61062... | 0.5385918 | 98 |
Ensure an authenticated user cannot join a community that does not exists | def test_join_wrong_community(self):
url = '/api/v1/communities/15/join_community/'
response = self.client.post(url, HTTP_AUTHORIZATION=self.auth('user4'))
self.assertEquals(status.HTTP_400_BAD_REQUEST, response.status_code)
self.assertEqual(15, Member.objects.all().count()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_cant_ban_user_from_community_if_member(self):\n user = make_user()\n headers = make_authentication_headers_for_user(user)\n\n other_user = make_user()\n community = make_community(creator=other_user, type='P')\n community_name = community.name\n\n user.join_commun... | [
"0.7300854",
"0.71112937",
"0.70641446",
"0.69880414",
"0.6895106",
"0.68399394",
"0.6777246",
"0.6458241",
"0.6438161",
"0.64138967",
"0.63462913",
"0.62895274",
"0.6252131",
"0.62423515",
"0.61970246",
"0.6186647",
"0.6176099",
"0.615934",
"0.61395776",
"0.61223435",
"0.601... | 0.69475484 | 4 |
Ensure a member can leave a community | def test_leave_community(self):
url = '/api/v1/communities/3/leave_community/'
response = self.client.post(url, HTTP_AUTHORIZATION=self.auth('user3'))
self.assertEquals(status.HTTP_204_NO_CONTENT, response.status_code)
self.assertEqual(14, Member.objects.all().count()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_leave_community_banned(self):\n url = '/api/v1/communities/5/leave_community/'\n\n response = self.client.post(url, HTTP_AUTHORIZATION=self.auth('user3'))\n self.assertEquals(status.HTTP_401_UNAUTHORIZED, response.status_code)\n\n self.assertEqual(15, Member.objects.all().count... | [
"0.755527",
"0.6848541",
"0.68042284",
"0.6512431",
"0.6444627",
"0.6382766",
"0.6282716",
"0.62807584",
"0.626154",
"0.61867917",
"0.6175655",
"0.6155387",
"0.6050245",
"0.6015117",
"0.6000263",
"0.59927756",
"0.5978494",
"0.597619",
"0.5971745",
"0.59683484",
"0.5955255",
... | 0.7604314 | 0 |
Gets the current head | def head(self):
return self._head | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first(self):\r\n return self.__head",
"def first(self):\n return self.__head",
"def currenthead(self):\n return self.repo.head.object",
"def peek(self):\n return self.list.head",
"def head(self) -> object:\n if not self._head:\n raise EmptyListException(\"T... | [
"0.80130213",
"0.7923789",
"0.7821768",
"0.75414413",
"0.73890346",
"0.73000383",
"0.7205366",
"0.7202247",
"0.72009563",
"0.71663415",
"0.71562153",
"0.71256787",
"0.710123",
"0.7087479",
"0.7047039",
"0.7027316",
"0.7017254",
"0.69998443",
"0.69862455",
"0.69797623",
"0.697... | 0.85257405 | 1 |
Gets the current tail | def tail(self):
return self._tail | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tail(self):\n return self._readahead.getvalue()",
"def get_tail(self):\n pointer = self.head\n while pointer.next_node:\n pointer = pointer.next_node\n return pointer",
"def peek_last(self):\n if self.is_empty(): raise RuntimeError(\"Empty list\")\n ... | [
"0.7987476",
"0.75084555",
"0.7217858",
"0.7078854",
"0.70251787",
"0.6993961",
"0.69410443",
"0.6919684",
"0.6894651",
"0.68824685",
"0.6878774",
"0.6853597",
"0.68393075",
"0.67811173",
"0.6733288",
"0.6732261",
"0.6592453",
"0.65848786",
"0.65684897",
"0.6545789",
"0.65059... | 0.864701 | 1 |
Adds a node to the front of the list | def addFront(self, data):
new_list = _Node(data)
temp = self._head
if self._head is None:
self._head = new_list
self._tail = new_list
else:
new_list.next = temp
new_list.next.prev = new_list
self._head = new_list
self._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push_front(self, item):\n new_node = Node(item)\n # if the list is empty, make it head\n if self.head is None:\n self.head = new_node\n # else, \n else:\n new_node.next = self.head # new node points to current head\n self.head = new_node # c... | [
"0.82249105",
"0.7810608",
"0.7768546",
"0.7768546",
"0.7755671",
"0.7738799",
"0.77328646",
"0.7720509",
"0.7625948",
"0.7588103",
"0.75430006",
"0.752145",
"0.7492182",
"0.746664",
"0.745477",
"0.7394027",
"0.7339842",
"0.73390335",
"0.73347354",
"0.728799",
"0.7265528",
... | 0.7907306 | 1 |
Test whether we can delete a campaign. | def testDeleteCampaign(self):
if self.__class__.campaign2 is None:
self.testSaveCampaign()
self.assertEqual(self.__class__.service.DeleteCampaign(
self.__class__.campaign2['id']), None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_campaign_by_admin_passes(self):\n response = self.client.delete(\n f\"{self.endpoint_url}{self.test_campaign.id}/\",\n headers={\"Authorization\": self.admin_token},\n )\n response_body = response.get_json()\n self.assertEqual(response.status_code, ... | [
"0.7160737",
"0.6712778",
"0.66537017",
"0.6412838",
"0.6403892",
"0.6248027",
"0.62260723",
"0.6173202",
"0.61620015",
"0.61620015",
"0.6158001",
"0.6153437",
"0.61174256",
"0.61138195",
"0.60950786",
"0.606821",
"0.60502833",
"0.60258365",
"0.59846985",
"0.59573454",
"0.591... | 0.6538772 | 3 |
Test whether we can fetch a campaign. | def testGetCampaign(self):
if self.__class__.campaign1 is None:
self.testSaveCampaign()
self.assert_(isinstance(self.__class__.service.GetCampaign(
self.__class__.campaign1['id']), tuple)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_if_can_fetch(self, url, useragent=\"*\"):\n logger.debug(\"Checking if can fetch %s\" % url)\n return self.rp.can_fetch(useragent=useragent, url=url)",
"def can_fetch(self, agent, url):\n if not url.startswith(self.base_url):\n url = urljoin(self.base_url, url)\n ... | [
"0.6951294",
"0.66682565",
"0.6388986",
"0.6277096",
"0.6162821",
"0.6039939",
"0.5521341",
"0.5516752",
"0.5443673",
"0.5427626",
"0.53725314",
"0.5343013",
"0.53338003",
"0.53287655",
"0.5325066",
"0.5308681",
"0.5290137",
"0.5257859",
"0.52291495",
"0.52203906",
"0.5171033... | 0.61979556 | 4 |
Test whether we can fetch landing pages for a campaign. | def testGetLandingPagesForCampaign(self):
if self.__class__.campaign1 is None:
self.testSaveCampaign()
self.assert_(isinstance(self.__class__.service.GetLandingPagesForCampaign(
self.__class__.campaign1['id']), tuple)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def available(self):\n existing_url = self.context.get_personal_fundraising_campaign_url()\n same = existing_url == self.context.absolute_url()\n creating = 'create-personal-campaign-page' in self.request.URL\n return not same and not creating",
"def test_contact_landing_success(self)... | [
"0.67742693",
"0.6306628",
"0.62808394",
"0.6120006",
"0.59452415",
"0.57627016",
"0.5738992",
"0.5561723",
"0.5556827",
"0.55112934",
"0.54937756",
"0.54576766",
"0.5449263",
"0.542853",
"0.54040414",
"0.53753954",
"0.53047925",
"0.53038776",
"0.5275955",
"0.5274629",
"0.526... | 0.67377996 | 1 |
Test whether we can create a campaign. | def testSaveCampaign(self):
self.testSaveLandingPage()
dt = datetime.datetime.now()
campaign = {
'advertiserId': self.__class__.advertiser_id,
'archived': 'false',
'name': 'Campaign #%s' % Utils.GetUniqueName(),
'defaultLandingPageId': self.__class__.landing_page_id,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_campaign(self):\n campaign = self.campaign\n\n self.assertTrue(isinstance(campaign, Campaign))\n self.assertEqual(campaign.name, \"Test Campaign\")",
"def test_create_already_existing_campaign_fails(self):\n test_campaign = return_canned_campaign()\n self.test_o... | [
"0.7282776",
"0.6861378",
"0.6769927",
"0.6562641",
"0.6446506",
"0.64025927",
"0.63065374",
"0.62620866",
"0.61669487",
"0.61126655",
"0.6082157",
"0.60696846",
"0.60404605",
"0.5802044",
"0.5785592",
"0.5767152",
"0.5753982",
"0.5717169",
"0.5715338",
"0.5704595",
"0.567379... | 0.52247524 | 54 |
Render home page of the site | def homepage():
return render_template("home/index.html", title="Welcome") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_home():\r\n\treturn render_template(\"index.html\")",
"def home():\n\n return render_template('home_page.html')",
"def home():\n return render_template('homepage.html')",
"def homepage():\n return render_template(\"home/index.html\")",
"def homepage():\n return render_template('home/... | [
"0.8892464",
"0.8681746",
"0.868129",
"0.85841256",
"0.8567517",
"0.8564356",
"0.8539393",
"0.8536602",
"0.8536602",
"0.8527715",
"0.85203385",
"0.8516136",
"0.8516136",
"0.8516136",
"0.8516136",
"0.8516136",
"0.8516136",
"0.8516136",
"0.8516136",
"0.8516136",
"0.8516136",
... | 0.85693485 | 4 |
Converts from bitwise representation into an array of vertex indices | def bits_to_verts(n):
return [v for v in range(8) if 2**v & n > 0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toIndexes(self, binaryVector):\n\t\treturn n.array([i for i,v in enumerate(binaryVector) if v], dtype=\"int32\")",
"def indices(self):\n\n # We used lookup tables here. Read more about other methods here:\n # https://chessprogramming.wikispaces.com/Bitboard+Serialization\n\n if self.num ... | [
"0.6880614",
"0.66368663",
"0.6283147",
"0.61515015",
"0.59993356",
"0.5996714",
"0.5987039",
"0.597378",
"0.58865625",
"0.5886015",
"0.58810294",
"0.5878558",
"0.5835041",
"0.5816263",
"0.57732755",
"0.5763688",
"0.57467073",
"0.57454824",
"0.57390153",
"0.572041",
"0.569220... | 0.6249408 | 3 |
Test for overflow nmax_val/n = max_val | async def mean_overflow_test(dut):
BUS_WIDTH = int(dut.BUS_WIDTH.value)
DATA_WIDTH = int(dut.DATA_WIDTH.value)
await value_test(dut, [2**DATA_WIDTH - 1] * BUS_WIDTH) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_valid_range(val, max_val):\n if val < 0:\n val = 0\n elif val > max_val:\n val = max_val\n else:\n pass\n return val",
"def normexponent(val):\n n = np.log10(val)\n if n < 0:\n n = int(n) - 1\n else:\n n = int(n)\n r... | [
"0.63276565",
"0.6182196",
"0.6137918",
"0.6084422",
"0.6055982",
"0.6047039",
"0.6044521",
"0.5964492",
"0.59547186",
"0.5945219",
"0.59124607",
"0.5856389",
"0.5852122",
"0.5821489",
"0.5820828",
"0.5815797",
"0.580666",
"0.5793909",
"0.5789581",
"0.57884365",
"0.5772079",
... | 0.5406247 | 61 |
Given an OpenFF Interchange object, return singlepoint energies as computed by OpenMM. | def get_openmm_energies(
interchange: Interchange,
round_positions: Optional[int] = None,
combine_nonbonded_forces: bool = True,
detailed: bool = False,
platform: str = "Reference",
) -> EnergyReport:
if "VirtualSites" in interchange.collections:
if len(interchange["VirtualSites"].key_ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_o_energies(mol):\n try:\n ev_to_hartree = 1./convertor(1,'hartree','eV')\n g=hack_parser.Gaussian(mol.calc.log, loglevel=50)\n d=g.parse()\n #lm, hm, lr\n o_component_es = np.array(d.oniomenergies)\n except AttributeError:\n return 0\n\n return (ev_to_hart... | [
"0.69773567",
"0.65272796",
"0.64571553",
"0.6419705",
"0.63294005",
"0.62931216",
"0.6201568",
"0.6199804",
"0.6066136",
"0.6042173",
"0.6034497",
"0.5962602",
"0.5949897",
"0.592898",
"0.5925742",
"0.5923861",
"0.590306",
"0.58978987",
"0.5897633",
"0.58953375",
"0.588566",... | 0.53286237 | 89 |
Gets the class_ref of this ExtraLink. | def class_ref(self):
return self._class_ref | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_class(self):\n\t\treturn self.CLASS",
"def class_id(self):\n return self._class_id",
"def get_class_attribute(self):\n return self.class_attr",
"def _class(self):\n return self.__class",
"def class_id(self) -> str:\n return self._class_id",
"def class_id(self) -> str:\... | [
"0.65787274",
"0.6499837",
"0.6441003",
"0.633477",
"0.6297404",
"0.6297404",
"0.60447276",
"0.6017914",
"0.5997474",
"0.5912678",
"0.59080553",
"0.5890727",
"0.586411",
"0.5799989",
"0.5785895",
"0.57600605",
"0.57169163",
"0.56916183",
"0.5678962",
"0.5666141",
"0.56647825"... | 0.81063294 | 0 |
Sets the class_ref of this ExtraLink. | def class_ref(self, class_ref):
self._class_ref = class_ref | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_id(self, class_id):\n\n self._class_id = class_id",
"def _class(self, _class):\n\n self.__class = _class",
"def _class(self, _class):\n\n self.__class = _class",
"def set_ref(self, new_ref):\n self.__ref = new_ref",
"def class_ref(self):\n return self._class_ref... | [
"0.66160256",
"0.6506323",
"0.6506323",
"0.61303324",
"0.5789517",
"0.5653708",
"0.5653708",
"0.5644072",
"0.56309736",
"0.55408466",
"0.55408466",
"0.5468603",
"0.54295385",
"0.5406994",
"0.53981334",
"0.5388326",
"0.5387655",
"0.5356944",
"0.5233787",
"0.52302057",
"0.51907... | 0.8206257 | 0 |
Gets the name of this ExtraLink. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return utf82unicode(pn_link_name(self._impl))",
"def get_name(self):\n return self.attributes[\"name\"]",
"def get_name(self) -> str:\n\n return self.name_",
"def get_name(self):\n\n return self.name",
"def get_name(self):\n\n return self.name",
"def g... | [
"0.79793715",
"0.73502254",
"0.7302598",
"0.72630215",
"0.72630215",
"0.7255761",
"0.7255761",
"0.7251672",
"0.7251672",
"0.7251672",
"0.7251672",
"0.7251672",
"0.7251672",
"0.7251672",
"0.7251672",
"0.7251672",
"0.7251672",
"0.7250691",
"0.7246036",
"0.7225374",
"0.7225374",... | 0.0 | -1 |
Sets the name of this ExtraLink. | def name(self, name):
self._name = name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_name(self, name):\n self._name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n ... | [
"0.7728652",
"0.77218515",
"0.77218515",
"0.77218515",
"0.77218515",
"0.77218515",
"0.76941884",
"0.76941884",
"0.76355064",
"0.76140046",
"0.7613152",
"0.76041967",
"0.75440353",
"0.7519226",
"0.74782056",
"0.74782056",
"0.74360126",
"0.74360126",
"0.74360126",
"0.74360126",
... | 0.74247396 | 100 |
Sets the href of this ExtraLink. | def href(self, href):
self._href = href | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_href(self, item_href):\n\n self._item_href = item_href",
"def link(self, link):\n\n self._set_field(\"link\", link)",
"def link(self, link):\n\n self._link = link",
"def link(self, link):\n\n self._link = link",
"def link(self, link):\n\n self._link = link",
"d... | [
"0.64866495",
"0.641666",
"0.6201337",
"0.6201337",
"0.6201337",
"0.6201337",
"0.6201337",
"0.6201337",
"0.6201337",
"0.60863066",
"0.60482925",
"0.60482925",
"0.5887726",
"0.5863164",
"0.57704544",
"0.5733876",
"0.5725257",
"0.57206154",
"0.57206154",
"0.57206154",
"0.572061... | 0.8182388 | 3 |
Find the top 10 users with the highest number of activities | def query_three(self, table_name_activities):
query = (
"SELECT user_id, COUNT(*) as Count "
"FROM %s "
"GROUP BY user_id "
"ORDER BY Count DESC "
"LIMIT 10"
)
self.cursor.execute(query % table_name_activities)
rows = self.cur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_from_top_ten(title,users,max = 3):\n \"\"\" ten prolific users \"\"\"\n \"\"\" max : number of user with related followers \"\"\"\n getAllUsers(users,all_users,users_set,proceeded_users,max,user_cpt,title)\n for data in users_set:\n print(data.id)",
"def get_top(n=10):\r\n sql ... | [
"0.7368929",
"0.7344022",
"0.6710669",
"0.66784954",
"0.6555825",
"0.6535713",
"0.64940435",
"0.6468146",
"0.64122295",
"0.6393935",
"0.6384817",
"0.6366222",
"0.6358851",
"0.63547736",
"0.6283554",
"0.6283363",
"0.6254878",
"0.6236455",
"0.6217411",
"0.6196639",
"0.61705524"... | 0.6007872 | 31 |
Find the number of users that have started the activity in one day and ended the activity the next day. | def query_four(self, table_name):
query = (
"SELECT user_id, COUNT(*) as NumActivites "
"FROM %s "
"WHERE DATEDIFF(start_date_time, end_date_time) = -1 "
"GROUP BY user_id "
)
self.cursor.execute(query % (table_name))
rows = self.cursor.f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_events(self, time_from='', time_to=''):\n count_from, count_up = self._validate_input(time_from, time_to)\n\n count = 0\n #assimption: the user more often is interested in newest data\n for i in reversed(self.events_by_seconds):\n if i[0] >= count_up:\n ... | [
"0.62942237",
"0.6208868",
"0.62016845",
"0.6155571",
"0.6101234",
"0.59438586",
"0.587805",
"0.5864595",
"0.5842169",
"0.58003056",
"0.5760895",
"0.5736726",
"0.57347304",
"0.5697322",
"0.566749",
"0.5645066",
"0.56308085",
"0.56206423",
"0.55819076",
"0.5578228",
"0.5560255... | 0.57113695 | 13 |
Find activities that are registered multiple times. You should find the query even if you get zero results. | def query_five(self, table_name_activities):
query = (
"SELECT user_id, transportation_mode, start_date_time, end_date_time, COUNT(*) AS NumDuplicates "
"FROM %s "
"GROUP BY user_id, transportation_mode, start_date_time, end_date_time "
"HAVING NumDuplicates >1 "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_list_activity_occurrences(self):\n pass",
"def get_activities(self, user_id=None, group_id=None, app_id=None,\n activity_id=None, start_index=0, count=0):\n raise NotImplementedError()",
"def activities(self):\n return self._activities",
"def __ui_find_activities... | [
"0.63341004",
"0.57011014",
"0.5677445",
"0.56412303",
"0.5640431",
"0.5504351",
"0.546893",
"0.5462067",
"0.5432692",
"0.54266936",
"0.5410815",
"0.53793097",
"0.53693116",
"0.5323399",
"0.5299379",
"0.5280299",
"0.5255576",
"0.52236176",
"0.52144575",
"0.52102506",
"0.52045... | 0.5983168 | 1 |
a) Find the year and month with the most activities. | def query_nine_a(self, table_name_activities):
query = (
"SELECT YEAR(start_date_time) as Year, MONTH(start_date_time) as Month, COUNT(*) AS ActivityCount "
"FROM %s "
"GROUP BY YEAR(start_date_time), MONTH(start_date_time) "
"ORDER BY ActivityCount DESC "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def most_common_month(df):\n common_month = df['month'].mode()[0]\n print(\"Most common month is {}.\".format(get_month_name(common_month)))",
"def get_month_most_posts(dates):\n posts_yr_mo = [post_date.strftime(\"%Y-%m\") for post_date in dates]\n posts_frequency = collections.Counter(posts_yr_mo)\... | [
"0.635691",
"0.62816685",
"0.5969048",
"0.5869156",
"0.58485764",
"0.5803788",
"0.57649577",
"0.57571036",
"0.57255596",
"0.57208604",
"0.5712416",
"0.5706924",
"0.5705092",
"0.5695326",
"0.56618917",
"0.5649617",
"0.5642169",
"0.5630825",
"0.5629095",
"0.5619249",
"0.5619231... | 0.54729927 | 43 |
b) Which user had the most activities this year and month, and how many recorded hours do they have? Do they have more hours recorded than the user with the second most activities? | def query_nine_b(self, table_name_activities):
query = (
"SELECT user_id, COUNT(*) AS ActivityCount"
", SUM(TIMESTAMPDIFF(HOUR, start_date_time, end_date_time)) as HoursActive "
"FROM %s "
"WHERE YEAR(start_date_time) = '2008' AND MONTH(start_date_time) = '11' "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_stats(df):\n\n print('\\nCalculating The Most Frequent Times of Travel...\\n')\n start_time = time.time()\n\n # TO DO: display the most common month\n if len(df['Month'].unique()) != 1:\n a = df['Month'].mode()[0]\n print('The most popular month: ', a)\n\n # TO DO: display th... | [
"0.6475652",
"0.64616454",
"0.64578974",
"0.64363235",
"0.64292324",
"0.6413384",
"0.6412211",
"0.640618",
"0.6394706",
"0.6383782",
"0.63697183",
"0.6365011",
"0.63590086",
"0.63465524",
"0.6344959",
"0.6342446",
"0.6331201",
"0.6329994",
"0.63283557",
"0.6324795",
"0.632194... | 0.6653954 | 0 |
Find the total distance (in km) walked in 2008, by user with id=112. | def query_ten(self, table_name_activities, table_name_trackpoints):
query = (
"SELECT Activity.id,lat,lon "
"FROM %s INNER JOIN %s on Activity.id = TrackPoint.activity_id "
"WHERE user_id='112' and "
"EXTRACT(YEAR FROM date_time) = 2008 "
"and transpo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_total_distance_by_user_on_foot(self, user_id: int):\n return self._get_total_distance_by_user(user_id, [ActivityType.Run, ActivityType.Walk])",
"def get_position_total_distance_on_foot(self, user_id: int):\n return self._get_position_total_distance(user_id, [ActivityType.Run, ActivityType.W... | [
"0.74692726",
"0.7009982",
"0.6886206",
"0.6750707",
"0.66686654",
"0.6530963",
"0.62489533",
"0.6235815",
"0.6079774",
"0.6079774",
"0.6017214",
"0.59642243",
"0.58515024",
"0.58402413",
"0.5767565",
"0.5739665",
"0.57288766",
"0.572131",
"0.56991506",
"0.5686757",
"0.566886... | 0.0 | -1 |
show the index page | def show_homepage():
return render_template("blank-slate.html") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_index_page():\n\n return render_template('index.html')",
"def index():\n return render_template(\"index.html\",\n title='Index')",
"def index(self):\n\t\treturn render_template('index.html')",
"def index():\r\n return render_template('index.html')",
"def ... | [
"0.84962547",
"0.8126018",
"0.8078417",
"0.80677384",
"0.80667824",
"0.80554676",
"0.8025317",
"0.8025317",
"0.80098003",
"0.79683125",
"0.79594547",
"0.79392713",
"0.79071647",
"0.7883275",
"0.7883275",
"0.7875503",
"0.78479445",
"0.7777909",
"0.77555305",
"0.7745303",
"0.77... | 0.0 | -1 |
Get the latest refresh datetime of a cohort. Returns current time formatted as a string if the field is not found. | def get_cohort_refresh_datetime(utm_id):
# @TODO MOVE DB REFS INTO QUERY MODULE
conn = dl.Connector(instance=settings.__cohort_data_instance__)
query = """ SELECT utm_touched FROM usertags_meta WHERE utm_id = %s """
conn._cur_.execute(query, int(utm_id))
utm_touched = None
try:
utm_tou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_last_meas_time(self):\n\n #if flag for whole data regeneration is set\n if self._process_type == 'full_gen':\n return datetime.datetime(1900, 1, 1, 0, 0, 0)\n \n \n res = self._db.Query(\"\"\"SELECT last_measurement_time\n FROM last... | [
"0.62165296",
"0.616487",
"0.6088386",
"0.60617465",
"0.6045005",
"0.5971621",
"0.5926703",
"0.5917341",
"0.59016716",
"0.58545",
"0.5838771",
"0.5812011",
"0.57949024",
"0.5793899",
"0.57753074",
"0.57753074",
"0.5775221",
"0.5765011",
"0.5749749",
"0.5748395",
"0.5720312",
... | 0.7260143 | 0 |
Generate grid representation of the state space. grid_params stores default values for bounds and grid density; the function constructs a grid with dimensionality dims from these defaults | def get_grid(grid_params, dims):
orders = np.array(object=grid_params["orders"][:dims], dtype=int)
grid_min = np.array(object=grid_params["lower bounds"][:dims], dtype=float)
grid_max = np.array(object=grid_params["upper bounds"][:dims], dtype=float)
# calculate number of grid points and generate index... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_param_grid():\n layer_width = [32, 64, 128, 256, 512]\n layers = [2, 3, 4, 5, 6]\n epochs = [10, 25, 50, 75, 100]\n batch_size = [32, 64, 96, 128, 160, 192, 224, 256]\n activation = ['softmax', 'softplus', 'softsign', 'relu', 'tanh', 'sigmoid', 'hard_sigmoid', 'linear']\n init_mode = ['un... | [
"0.7363759",
"0.7167829",
"0.6743477",
"0.6558941",
"0.65435964",
"0.6514001",
"0.64314175",
"0.63536054",
"0.6307485",
"0.6304103",
"0.6289735",
"0.62861055",
"0.62022144",
"0.6196542",
"0.6194783",
"0.61569643",
"0.6149171",
"0.61468774",
"0.6132944",
"0.6113889",
"0.608744... | 0.68191546 | 2 |
Calculate mean squared error. If ``x1`` and ``x2`` have different shapes, then they need to broadcast. This uses | def mse(x1, x2, axis=0):
x1 = np.asanyarray(x1)
x2 = np.asanyarray(x2)
return np.mean((x1 - x2) ** 2, axis=axis) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean_squared_error(x0, x1):\n return MeanSquaredError()(x0, x1)",
"def msre(x1, x2, axis=0):\n x1 = np.asanyarray(x1)\n x2 = np.asanyarray(x2)\n return np.mean((((x1 - x2) ** 2) / x1), axis=axis)",
"def _mean_squared_error(img1, img2):\n err = np.sum((img1.astype(\"float\") - img2.astype(\"f... | [
"0.8226302",
"0.7394932",
"0.70136625",
"0.70063365",
"0.68697226",
"0.67129135",
"0.659804",
"0.65663034",
"0.65424967",
"0.64867127",
"0.64791524",
"0.6449142",
"0.64091104",
"0.63836336",
"0.62251514",
"0.6153482",
"0.6134623",
"0.6100003",
"0.60949916",
"0.59974325",
"0.5... | 0.7577179 | 1 |
Calculate mean squared relative error. If ``x1`` and ``x2`` have different shapes, then they need to broadcast. This uses | def msre(x1, x2, axis=0):
x1 = np.asanyarray(x1)
x2 = np.asanyarray(x2)
return np.mean((((x1 - x2) ** 2) / x1), axis=axis) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean_squared_error(x0, x1):\n return MeanSquaredError()(x0, x1)",
"def mean_absolute_error(x0, x1):\n return MeanAbsoluteError()(x0, x1)",
"def mse(x1, x2, axis=0):\n x1 = np.asanyarray(x1)\n x2 = np.asanyarray(x2)\n return np.mean((x1 - x2) ** 2, axis=axis)",
"def _mean_squared_error(img1... | [
"0.8137443",
"0.73585516",
"0.71538997",
"0.69549376",
"0.6705897",
"0.6618502",
"0.65939456",
"0.6451038",
"0.6431475",
"0.641674",
"0.64155227",
"0.6316561",
"0.6163102",
"0.6124665",
"0.6085341",
"0.60831666",
"0.6047767",
"0.6047288",
"0.60459423",
"0.60148704",
"0.592659... | 0.7301853 | 2 |
Evaluate model using the validation set. | def evaluate():
model.eval()
with torch.no_grad():
loss, n = 0, 0
for xb, yb in valid_dl:
n += len(xb)
loss += loss_func(model(xb), yb) * len(xb)
return loss/n | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate(self):\n self.set_model_mode('eval')\n self.evaluator.reset()\n losses = MetricMeter()\n\n print('Do evaluation on {} set'.format('valid set'))\n data_loader = self.val_loader\n assert data_loader is not None\n for batch_idx, batch in enumerate(data_loa... | [
"0.7556931",
"0.7128",
"0.6986451",
"0.69822556",
"0.688941",
"0.6866641",
"0.68387544",
"0.67861927",
"0.6768624",
"0.6768624",
"0.6768624",
"0.6747499",
"0.6704247",
"0.66950506",
"0.6688258",
"0.66860074",
"0.66801274",
"0.6664884",
"0.66432977",
"0.66401047",
"0.65844405"... | 0.6838491 | 7 |
Returns a path to a fixture via the given fname and label | def fixture(fname, label="reference"):
return os.path.join(FIXTURES, label, fname) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fixture_file(*path):\n return os.path.join(os.path.dirname(__file__), 'fixtures', *path)",
"def get_test_fname(fname):\n path = get_test_path()\n full_path = os.path.join(path, fname)\n return full_path",
"def get_filename(label):\n return op.splitext(op.splitext(op.basename(label))[0])[0]",... | [
"0.6520794",
"0.6382769",
"0.63656783",
"0.6110005",
"0.5983235",
"0.5950241",
"0.5911903",
"0.59048057",
"0.59048057",
"0.59048057",
"0.5869462",
"0.5829332",
"0.5817864",
"0.58178484",
"0.58095974",
"0.5808435",
"0.57983226",
"0.57849145",
"0.5742818",
"0.5695899",
"0.56913... | 0.8895459 | 0 |
Retrieve an organization Return details on an individual organization including various details such as membership access, features, and teams. {method} {path} | def get(self, request, organization):
team_list = list(Team.objects.filter(
organization=organization,
status=TeamStatus.VISIBLE,
))
feature_list = []
if features.has('organizations:sso', organization, actor=request.user):
feature_list.append('sso')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_organization(organization):\n return fetch_json(organization_url, organization)",
"def test_get_organization(self):\n pass",
"def test_retrieve_l_organization(self):\n pass",
"def GetOrganization(**argd):\n flag, ret = CGateway.core.GetOrganizationName(argd[\"session\"])\n ... | [
"0.7148548",
"0.7105574",
"0.6952284",
"0.65545195",
"0.6552218",
"0.64303905",
"0.64210945",
"0.63243663",
"0.6256752",
"0.6247144",
"0.6243915",
"0.6230795",
"0.61991656",
"0.6193295",
"0.6187062",
"0.6177847",
"0.61678433",
"0.6031752",
"0.6031751",
"0.6006261",
"0.5959868... | 0.64187884 | 7 |
Returns the underlying singlefile configs represented by this object. | def configs(self):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configs(self):\n return self._configs",
"def configs(self):\n\n return self.__configs",
"def get_full_config(self):\n return self._read_config()",
"def config(self) -> dict:\n return self._configs",
"def config(self):\n return self._cfg",
"def config(self):\r\n r... | [
"0.71781963",
"0.71364343",
"0.70960563",
"0.6913402",
"0.69121945",
"0.66923416",
"0.6692044",
"0.6692044",
"0.6688849",
"0.6688849",
"0.6688849",
"0.6674267",
"0.6649714",
"0.66398054",
"0.65898687",
"0.6565974",
"0.65383905",
"0.65109235",
"0.65039575",
"0.650033",
"0.6458... | 0.6552234 | 16 |
computes bounding box of warped image under homography, without actually warping the image | def compute_bounding_box(homography, w, h):
corners = np.array([[0,0],
[0,h],
[w,0],
[w,h]])
t_corners = apply_homography(corners, homography)
return np.array([t_corners.min(axis=0),t_corners.max(axis=0)],
dtype= np.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_bounding_box(homography, w, h):\n top_left_x, top_left_y = apply_homography(np.array([[0, 0]]), homography).transpose()\n top_right_x, top_right_y = apply_homography(np.array([[w, 0]]), homography).transpose()\n bottem_left_x, bottem_left_y = apply_homography(np.array([[0, h]]), homography).tr... | [
"0.68395644",
"0.68263465",
"0.6565394",
"0.65440303",
"0.65215236",
"0.63024795",
"0.6185591",
"0.6115287",
"0.60751134",
"0.6052541",
"0.59913546",
"0.5959734",
"0.59432757",
"0.59432757",
"0.5937751",
"0.59291124",
"0.5924142",
"0.59106493",
"0.5907376",
"0.59039426",
"0.5... | 0.6808969 | 2 |
The naming convention for a sequence of images is file_prefixN.jpg, where N is a running number 001, 002, 003... | def __init__(self, data_dir, file_prefix, num_images):
self.file_prefix = file_prefix
self.files = [os.path.join(data_dir, '%s%03d.jpg' % (file_prefix, i + 1)) for i in range(num_images)]
self.files = list(filter(os.path.exists, self.files))
self.panoramas = None
self.homographie... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_prefix() :\n \n import glob\n filenames = glob.glob(picture_folder+'*.jpg')\n max_prefix = 0\n for filename in filenames :\n parts = filenames.split('_')\n if len(parts) > 1 :\n possible_prefix = parse_int(parts[0])\n if possible_prefix > max_prefix :\n max_prefix = possible_pre... | [
"0.769489",
"0.73024964",
"0.6996918",
"0.695735",
"0.6912876",
"0.68801117",
"0.6853592",
"0.67820257",
"0.6771336",
"0.67199373",
"0.6704712",
"0.66808397",
"0.6628377",
"0.658693",
"0.6585913",
"0.65571696",
"0.65143126",
"0.6469766",
"0.64489675",
"0.64109373",
"0.6376563... | 0.58315897 | 73 |
Return a number of bins for this dataset using the FreedmanDiaconis rule. | def binning(data, low, high):
if len(data) == 0: return 1
mask1 = (data >= low)
mask2 = (data < high)
mask3 = numpy.logical_and(mask1, mask2)
data = data[mask3]
if len(data) == 0: return 10
data.sort()
q1 = data[int(math.floor(0.25*len(data)))]
q3 = data[int(math.floor(0.75*len(da... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def freedman_diaconis_bins(self, arr):\n # From https://stats.stackexchange.com/questions/798/\n if len(arr) < 2:\n return 1\n # Calculate the iqr ranges.\n self.iqr(arr)\n # Calculate the h\n h = 2 * (self.q3 - self.q1) / (len(arr) ** (1 / 3))\n # fall b... | [
"0.69271",
"0.6696379",
"0.6671535",
"0.6590386",
"0.6581825",
"0.65656954",
"0.6553514",
"0.6543408",
"0.6536041",
"0.6536041",
"0.65276605",
"0.6514374",
"0.6472568",
"0.6446772",
"0.64086914",
"0.6390756",
"0.6386423",
"0.6348384",
"0.6332559",
"0.6332559",
"0.6318721",
... | 0.0 | -1 |
Convert a time string or many time strings into a number(s) of seconds. | def fromtimestring(timestrings, format, subseconds=False, t0=0.):
if isinstance(t0, (numbers.Number, numpy.number)) or format is None:
t0 = float(t0)
else:
if subseconds:
pytimestring, subsecs = t0.split(".")
subsecs = float("0." + subsecs)
else:
pyti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def str2seconds(strtime):\n\n result = 0\n\n for i in re.split(r\"([0-9]+[a-z]+)\", strtime):\n\n stri = i.strip().lower() # Case insensitive\n if not stri:\n continue\n\n digits = \"\".join([i for i in stri if i.isdigit()])\n\n if len(stri) == len(digits): # Without ... | [
"0.790042",
"0.77960193",
"0.7617983",
"0.75185776",
"0.7437581",
"0.7420613",
"0.735528",
"0.731489",
"0.72933215",
"0.72796965",
"0.72436625",
"0.7190395",
"0.71774894",
"0.7173548",
"0.7173548",
"0.71201843",
"0.7105515",
"0.7100587",
"0.70640224",
"0.70492315",
"0.7029429... | 0.0 | -1 |
Instantiates the Flask instance and associated parameters. | def create_app(config_filename):
app = Flask(__name__)
app.config.from_object(config_filename)
from app import api_bp
app.register_blueprint(api_bp, url_prefix='/api')
from Model import db
with app.app_context():
db.init_app(app)
db.create_all([None])
return ap... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize():\n app = Flask(__name__)\n # Load private config at instance/config.py\n config_path = 'instance/config.py'\n if os.path.exists(config_path):\n app.config.from_pyfile(os.path.abspath(config_path))\n\n # Initialize database\n init_db(\n app.config['DB_USERNAME'],\n ... | [
"0.7546474",
"0.7465154",
"0.7437626",
"0.729399",
"0.71954864",
"0.71917486",
"0.71597254",
"0.70166236",
"0.70074224",
"0.69816077",
"0.6921856",
"0.6921187",
"0.69106394",
"0.6906584",
"0.6897556",
"0.6897512",
"0.68827015",
"0.68768495",
"0.68698466",
"0.6868935",
"0.6865... | 0.0 | -1 |
Return the resource with the specified resource class. | def get_resource_from_class(klass):
return _class_to_resources.get(klass, None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource_class(self):\n resource_module = '.'.join(self.resource_class_path.split('.')[:-1])\n resource_class_name = self.resource_class_path.split('.')[-1]\n return getattr(import_module(resource_module), resource_class_name)",
"def resource_class(self):\n resource_module = '.'.j... | [
"0.7832141",
"0.7832141",
"0.7712705",
"0.6950276",
"0.68987846",
"0.66122043",
"0.6541201",
"0.6495036",
"0.6437813",
"0.6411328",
"0.6365627",
"0.63542414",
"0.6345779",
"0.63337135",
"0.6322805",
"0.63152754",
"0.62987596",
"0.62941813",
"0.62185717",
"0.6204819",
"0.62022... | 0.8665222 | 0 |
Delete any whitespace in a given string | def del_whitespace(selfs, text):
return text.replace(' ', '') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_space(string):\n return string.replace(' ', '')",
"def _clean(self, string):\n return re.sub('\\s+', ' ', string).strip()",
"def remove_white_spaces(input_string):\n return re.sub(r'\\s+', ' ', input_string).strip()",
"def _clean(s):\n return re.sub(r'\\s+', ' ', s.strip())",
"def... | [
"0.8386853",
"0.8282755",
"0.8259965",
"0.8231743",
"0.82165647",
"0.81852895",
"0.8062439",
"0.7945549",
"0.79050696",
"0.7848309",
"0.7831649",
"0.7806161",
"0.7806161",
"0.77685887",
"0.77685887",
"0.7742288",
"0.76699007",
"0.7577561",
"0.7572943",
"0.7553713",
"0.7528789... | 0.81443447 | 6 |
Uppercase all characer in a given string | def to_upper(self, text):
return text.upper() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upper(string):\n new_string = '' # Empty string to append to\n for char in string: # Itterate over each character in user's string\n if char.isalpha() and not char.isupper(): # If the character is an alphabet and not already uppercase\n char = (chr(ord(char) - 32)) # Subtract 32 from it... | [
"0.790776",
"0.7735673",
"0.77356625",
"0.7521186",
"0.74673855",
"0.74584377",
"0.7438182",
"0.7413072",
"0.7411056",
"0.73737097",
"0.7281533",
"0.7273776",
"0.7201532",
"0.7180221",
"0.7129265",
"0.70013803",
"0.6978227",
"0.6964081",
"0.69567746",
"0.6934419",
"0.68477446... | 0.7509662 | 4 |
Return a confusion matrix, classification report, and matplotlib.axes.Axes of confusion matrix in dictionary form | def get_metric(self, X=None, y=None,
random_state=None, n_neighbors=None, ax=None):
param = self._set_data(X, y, random_state, n_neighbors)
X = param['X']
y = param['y']
ds = train_test_split(X, y, test_size=self.test_size,
random_state=ra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conf_matrix(model, X_train, y_train, X_test, y_test, train=True):\n from sklearn.metrics import confusion_matrix\n import itertools\n if train==True: \n ypredTrain = model.predict(X_train)\n cm = confusion_matrix(y_train, ypredTrain)\n def plot_conf_matrix(cm, classes, title='C... | [
"0.68781376",
"0.68362397",
"0.6781775",
"0.6672712",
"0.66222155",
"0.6609204",
"0.65948915",
"0.6585669",
"0.6573767",
"0.65571666",
"0.65413755",
"0.6507808",
"0.6453033",
"0.64469814",
"0.64313364",
"0.6412364",
"0.63966286",
"0.6386278",
"0.63823116",
"0.6377449",
"0.636... | 0.0 | -1 |
Function finds the negative mean squared distance from mean for point in Y (variance) | def negative_mse ( target_array ):
return -1 * mse ( target_array )
# End negative_mse() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mse(x, y):\n\n return (x - y).pow(2).sum(dim=1, keepdim=True).mean() / x.size(1)",
"def rmse(x: np.ndarray, y: np.ndarray):\n x, y = np.copy(x), np.copy(y)\n if x.ndim > 1:\n return np.sqrt(np.nanmean((x-y)**2, axis=1))\n return np.sqrt(np.nanmean((x-y)**2))",
"def d_mse(x, y):\n\n re... | [
"0.69241166",
"0.69005483",
"0.6845944",
"0.67627764",
"0.67190903",
"0.66590434",
"0.6627769",
"0.6610583",
"0.6524916",
"0.65237314",
"0.65040076",
"0.64928967",
"0.64775354",
"0.64648354",
"0.6457528",
"0.6452227",
"0.6450612",
"0.6444482",
"0.64413154",
"0.64091843",
"0.6... | 0.0 | -1 |
Convert a character into an array of 22 bytes. | def get_char(c):
data = (ctypes.c_uint8 * 22)()
ret = _LIB.oled_click_get_char(c, ctypes.byref(data))
if ret < 0:
raise Exception("oled click get char failed")
return [data[i] for i in range(22)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bytes_as_char_array(b):\n return \"{ \" + \", \".join(\"0x%02x\" % x for x in b) + \" }\"",
"def to_char_array(s):\n if type(s) != bytes:\n raise ValueError('Input to to_char_array function should be in bytes')\n char_array = []\n tokens = s.split(b' ')\n for token in tokens:\n c... | [
"0.6772518",
"0.64857394",
"0.6455129",
"0.6275554",
"0.6080935",
"0.6075504",
"0.6041937",
"0.6011441",
"0.6011441",
"0.60084045",
"0.5997307",
"0.59810466",
"0.59715194",
"0.59327745",
"0.5909544",
"0.5848634",
"0.58313006",
"0.58160806",
"0.5803004",
"0.5797645",
"0.578704... | 0.57538843 | 23 |
Returns a random hand containing n lowercase letters. At least n/3 the letters in the hand should be VOWELS. Hands are represented as dictionaries. The keys are letters and the values are the number of times the particular letter is repeated in that hand. | def dealHand(n):
hand={}
numVowels = n / 3
for i in range(numVowels):
x = VOWELS[random.randrange(0,len(VOWELS))]
hand[x] = hand.get(x, 0) + 1
for i in range(numVowels, n):
x = CONSONANTS[random.randrange(0,len(CONSONANTS))]
hand[x] = hand.get(x, 0) + 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deal_hand(n):\n hand = {}\n num_vowels = n // 3\n\n for i in range(num_vowels):\n x = VOWELS[random.randrange(0, len(VOWELS))]\n hand[x] = hand.get(x, 0) + 1\n\n for i in range(num_vowels, n):\n x = CONSONANTS[random.randrange(0, len(CONSONANTS))]\n hand[x] =... | [
"0.78006905",
"0.7678525",
"0.7669588",
"0.74499804",
"0.6461991",
"0.6153672",
"0.60777944",
"0.60667515",
"0.60564005",
"0.5998895",
"0.59673965",
"0.59573287",
"0.59163105",
"0.59163105",
"0.59163105",
"0.5879762",
"0.58750254",
"0.584636",
"0.5825631",
"0.58003813",
"0.57... | 0.76973146 | 1 |
Sets the learning rate to the initial LR decayed by 0.2 every steep step | def pt_adjust_learning_rate(epoch, opt, optimizer):
# if epoch < 2:
# for param_group in optimizer.param_groups:
# param_group['lr'] = 1e-7
# return 0
# print(epoch)
# print(np.asarray(opt.pt_lr_decay_epochs))
steps = np.sum(epoch > np.asarray(opt.pt_lr_decay_epochs))
if ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_learning_rate(self):\n\n if (self.FLAGS.learning_rate_decay is \"exponential\"):\n self.learning_rate = tf.train.exponential_decay(\n self.FLAGS.learning_rate,\n self.global_step,\n self.... | [
"0.79089844",
"0.7856753",
"0.7856753",
"0.76767546",
"0.75567615",
"0.75240135",
"0.75000376",
"0.7454447",
"0.7426672",
"0.74171114",
"0.7404257",
"0.7401694",
"0.7386987",
"0.73657304",
"0.7329806",
"0.73260325",
"0.73156565",
"0.7304068",
"0.73000455",
"0.7264402",
"0.725... | 0.0 | -1 |
Sets the learning rate to the initial LR decayed by 10 every 30 epochs | def ft_adjust_learning_rate(optimizer, intial_lr, epoch, lr_steps):
decay = 0.3 ** (sum(epoch >= np.array(lr_steps)))
lr = intial_lr * decay
for param_group in optimizer.param_groups:
param_group['lr'] = lr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_learning_rate(init_lr, optimizer, epoch, n=100):\n init_lr = init_lr * (0.1 ** (epoch // n))\n print('learning rate : ', init_lr)\n for param_group in optimizer.param_groups:\n param_group['lr'] = init_lr",
"def adjust_learning_rate(start_lr, optimizer, epoch, total_epoch_num):\n #l... | [
"0.79140896",
"0.7908034",
"0.7850816",
"0.7776915",
"0.7735598",
"0.7732588",
"0.7723862",
"0.77235436",
"0.77208304",
"0.7710736",
"0.76948273",
"0.7675381",
"0.76670265",
"0.76670265",
"0.76670265",
"0.7657111",
"0.76431805",
"0.7640621",
"0.7639109",
"0.76275903",
"0.7625... | 0.7563326 | 36 |
Initializes the priority heap | def __init__(self, g):
self._data = []
self.graph = g
self.pqLocator = {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.min_heap = []\n self.max_heap = []\n self.size_max, self.size_min = 0, 0",
"def __init__(self):\n self.min_heap = []\n self.max_heap = []",
"def __init__(self):\n self.__max_heap = []\n self.__min_heap = []",
"def __init__(self):\n ... | [
"0.7895022",
"0.78730625",
"0.78242964",
"0.7812003",
"0.7795688",
"0.77610606",
"0.7727318",
"0.7712711",
"0.77093875",
"0.7683902",
"0.7657671",
"0.764797",
"0.76411146",
"0.76411146",
"0.76411146",
"0.76315606",
"0.76188815",
"0.75978863",
"0.75660425",
"0.756221",
"0.7523... | 0.0 | -1 |
Finds if heap is empty | def empty(self):
return True if len(self) == 0 else False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def empty(heap):\n return size(heap) == 0",
"def is_empty(self):\n return self.heap_size <= 0",
"def is_empty(self):\n return len(self.__heap) == 0",
"def is_empty(self) -> bool:\n return self.heap.length() == 0",
"def is_empty(self) -> bool:\n return self.heap.length() == 0"... | [
"0.87432164",
"0.8080125",
"0.80508566",
"0.7974598",
"0.7974598",
"0.78623253",
"0.7857394",
"0.7734315",
"0.7480083",
"0.71097034",
"0.69872475",
"0.6981132",
"0.6887114",
"0.6812178",
"0.67947066",
"0.67928696",
"0.6768594",
"0.67281306",
"0.6711304",
"0.6684485",
"0.66307... | 0.0 | -1 |
Finds the minimum child of the index | def max_child(self, index):
# left and right child
left = self._data[(index*2)+1] if (index*2)+1 < len(self) else None
right = self._data[(index*2)+2] if (index*2)+2 < len(self) else None
# if has both children
if left and right:
if left < right:
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_child(self, index):\n if self.empty():\n return None\n if self._has_left(index):\n left = self._left(index)\n small_child = left\n if self._has_right(index):\n right = self._right(index)\n if self._data[right] < self._d... | [
"0.80425453",
"0.791862",
"0.7847695",
"0.7785256",
"0.75363547",
"0.7435741",
"0.7424413",
"0.73639077",
"0.71918046",
"0.71815383",
"0.70990807",
"0.7095202",
"0.70832723",
"0.70796996",
"0.70733607",
"0.7018999",
"0.6948961",
"0.69062304",
"0.68996906",
"0.6890181",
"0.686... | 0.67524004 | 26 |
Determines if natural number N is prime by trial division. | def trial_div(n: int) -> bool:
if n == 1:
return False
i = 2
while i**2 <= n:
if n % i == 0:
return False
i += 1
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isprime(n):\r\n\treturn is_prime(n)",
"def prime_t(n: int) -> bool:\n tests = set(range(2, int(math.sqrt(n) + 1)))\n non_factors = set(takewhile(lambda i: n % i != 0, tests))\n return tests == non_factors",
"def prime_t(n: int) -> bool:\n tests = set(range(2, int(math.sqrt(n) + 1)))\n non_fa... | [
"0.75904524",
"0.7572783",
"0.7572783",
"0.7533633",
"0.75022924",
"0.74241966",
"0.73947245",
"0.73647577",
"0.73487324",
"0.7345413",
"0.7342212",
"0.72686034",
"0.7251062",
"0.72339666",
"0.7232719",
"0.72271216",
"0.72271216",
"0.7186987",
"0.71865153",
"0.7166788",
"0.71... | 0.7699925 | 0 |
Determines if Mersenne number 2^N 1 is prime via the LucasLehmer primality test. | def ll_primality(n: int) -> bool:
if n <= 2 or not trial_div(n):
return False
luc_leh = lucas_lehmer()
for _ in range(n - 1):
ll = next(luc_leh)
return ll % (2**n - 1) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_prime(n):\n return mr_prime(n)",
"def test_prime(n):\n if SIEVE[n]:\n return True\n else:\n return False",
"def isprime(n):\r\n\treturn is_prime(n)",
"def isprime(n=936):\n if n < 3: return False\n for i in range(2, n):\n if n % i == 0:\n return False\n ... | [
"0.7239062",
"0.7073942",
"0.7019739",
"0.70070904",
"0.7005515",
"0.6946308",
"0.6864864",
"0.68361056",
"0.678722",
"0.6734504",
"0.6730105",
"0.6687569",
"0.66823626",
"0.667622",
"0.6668467",
"0.6650945",
"0.6643008",
"0.6626922",
"0.661976",
"0.66106534",
"0.6610468",
... | 0.7341868 | 0 |
NYI returns true if W is a Wire standard. W must belong to the list returned by MakeBlock. | def IsWire(self, *args):
return _BRepAlgo.BRepAlgo_EdgeConnector_IsWire(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isWatt(self):\n return _libsbml.Unit_isWatt(self)",
"def test_wireable_object(self):\n result = attributeAsLDIF(\"dn\", WireableObject())\n self.assertEqual(result, b\"dn: wire\\n\")",
"def wwn(self) -> SmartSsdWwn:\n return self._wwn",
"def CanBalanceWithWater(self):\n ... | [
"0.5597362",
"0.55873543",
"0.5548783",
"0.55013156",
"0.54576916",
"0.53746676",
"0.5354919",
"0.5347618",
"0.52789843",
"0.5266089",
"0.51734984",
"0.51449096",
"0.513721",
"0.50930214",
"0.50891733",
"0.5074785",
"0.5068847",
"0.50615853",
"0.5049344",
"0.50426847",
"0.504... | 0.6148025 | 0 |
For a projected edge, returns the corresponding initial face. | def Couple(self, *args):
return _BRepAlgo.BRepAlgo_NormalProjection_Couple(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def faces_from_edge(self, edge):\n assert isinstance(edge, Edge)\n return map(Face, self._top_exp.faces_from_edge(edge.topods_shape()))",
"def face(self):\n\n return self.faceup",
"def get_face(self, image):\n face = self.__detect_face(image)[0]\n x1, y1, x2, y2, _, _ = face.... | [
"0.6326266",
"0.6022131",
"0.59142417",
"0.5786397",
"0.56976974",
"0.56215537",
"0.56146854",
"0.56094706",
"0.5577278",
"0.5577278",
"0.55683047",
"0.5539707",
"0.55011696",
"0.54858553",
"0.5437727",
"0.5425079",
"0.5405903",
"0.5399007",
"0.5397073",
"0.5339341",
"0.53367... | 0.0 | -1 |
Indicates if the Pcurve must be (or not) performed on first part. | def ComputePCurveOn1(self, *args):
return _BRepAlgo.BRepAlgo_Section_ComputePCurveOn1(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isSetCurve(self):\n return _libsbml.ReactionGlyph_isSetCurve(self)",
"def isSetCurve(self):\n return _libsbml.GeneralGlyph_isSetCurve(self)",
"def isSetCurve(self):\n return _libsbml.ReferenceGlyph_isSetCurve(self)",
"def isSetCurve(self):\n return _libsbml.SpeciesReferenceGly... | [
"0.66216546",
"0.6554725",
"0.64873916",
"0.63525736",
"0.6299431",
"0.6262032",
"0.61106616",
"0.6055835",
"0.6034955",
"0.60219824",
"0.5987621",
"0.59857976",
"0.59857976",
"0.59446955",
"0.5892998",
"0.5862073",
"0.5846161",
"0.5800989",
"0.5759518",
"0.57186365",
"0.5702... | 0.0 | -1 |
Computes the relative phase error of x_pred w.r.t. x_true. This is done by finding the locations of the zero crossings in both signals, then corresponding crossings are compared to each other. | def relative_phase_error(x_pred, x_val):
ref_crossings = zero_crossings(x_val[:, 0])
pred_crossings = zero_crossings(x_pred[:, 0])
t_ref = np.mean(np.diff(ref_crossings)) * 2
t_pred = np.mean(np.diff(pred_crossings)) * 2
phase_error = t_ref/t_pred - 1
if len(pred_crossings) < len(ref_crossings) ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrapped_phase_difference(y_true, y_pred):\n\n diff = y_pred - y_true\n diff -= tf.multiply(\n tf.cast(tf.greater_equal(diff, dvpy.tf.pi), \"float32\"), 2.0 * dvpy.tf.pi\n )\n diff += tf.multiply(\n tf.cast(tf.less(diff, -dvpy.tf.pi), \"float32\"), 2.0 * dvpy.tf.pi\n )\n return d... | [
"0.6281197",
"0.59099185",
"0.58893096",
"0.5852402",
"0.5812844",
"0.57776743",
"0.5741355",
"0.571223",
"0.5664011",
"0.551934",
"0.5496603",
"0.5488607",
"0.5486976",
"0.5474592",
"0.5464117",
"0.5453587",
"0.54014504",
"0.53790504",
"0.536854",
"0.5364881",
"0.533917",
... | 0.80148506 | 0 |
Creates and saves a superuser with the given credentials. | def create_superuser(self, username, email: str = None, password: str = None, **kwargs):
kwargs.setdefault('is_staff', True)
kwargs.setdefault('is_superuser', True)
return self._create_user(username, email=email, password=password, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_superuser(self, username, firstname, lastname, email, password):\n user = self.create_user(\n username=username,\n firstname=firstname,\n lastname=lastname,\n email=email,\n password=password,\n )\n user.is_admin = True\n ... | [
"0.7665751",
"0.76599526",
"0.7633325",
"0.7613368",
"0.7548139",
"0.75175565",
"0.75017494",
"0.7498751",
"0.7497807",
"0.7497559",
"0.7497241",
"0.7488904",
"0.7484993",
"0.74615604",
"0.74535567",
"0.7444655",
"0.7431043",
"0.7430459",
"0.7427848",
"0.7412361",
"0.74012953... | 0.74214536 | 19 |
Get all valid knight's moves from location x0, y0 on the 9x9 sudoku grid. | def getAllValidMoves(x0, y0):
deltas = [
(-2, -1),
(-2, +1),
(+2, -1),
(+2, +1),
(-1, -2),
(-1, +2),
(+1, -2),
(+1, +2),
]
validPositions = []
for (x, y) in deltas:
xCandidate = x0 + x
yCandidate = y0 + y
if 0 < xCa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_legal_moves(self):\n moves = []\n if self.player_locations[self.whose_turn] is None:\n return self.get_blank_locations()\n matrix = [(1,0), (-1,0), (0,1), (0,-1), (1,1), (1,-1), (-1, 1), (-1,-1)]\n\n for dx, dy in matrix:\n x,y = self.player_locations[self.... | [
"0.7800498",
"0.7416829",
"0.73896676",
"0.7355546",
"0.72740203",
"0.7235792",
"0.71068656",
"0.70652497",
"0.6994112",
"0.6918404",
"0.6835368",
"0.6831226",
"0.68228096",
"0.6809941",
"0.67770463",
"0.6734217",
"0.67146814",
"0.67090935",
"0.6682379",
"0.66746056",
"0.6647... | 0.73486286 | 4 |
Check that all cells in 'variales' have unique values. | def exactly_one(variables):
cnf = [variables]
n = len(variables)
for i in range(n):
for j in range(i + 1, n):
v1 = variables[i]
v2 = variables[j]
cnf.append([-v1, -v2])
return cnf | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_unique_cols_unique(self, df):\n assert not df.duplicated(self.unique_cols).any()",
"def test_check_unique_var(self):\n\n for component_name in [\"var\", \"raw.var\"]:\n with self.subTest(component_name=component_name):\n\n # Resetting validator\n ... | [
"0.63620746",
"0.62129706",
"0.6201802",
"0.6193316",
"0.61617726",
"0.6146202",
"0.61371833",
"0.6137029",
"0.5997458",
"0.5884578",
"0.58836",
"0.5803739",
"0.5782447",
"0.5720199",
"0.5682489",
"0.56469285",
"0.5644524",
"0.56409854",
"0.5598229",
"0.55876446",
"0.55558944... | 0.0 | -1 |
Ordering is set by a comma delimited ?ordering=... query parameter. The `ordering` query parameter can be overridden by setting the `ordering_param` value on the OrderingFilter or by specifying an `ORDERING_PARAM` value in the API settings. | def get_ordering(self, request, queryset, view):
ordering = []
params = get_datatables_ordering(request.query_params)
if params:
fields = [param.strip() for param in params.split(',')]
ordering = self.remove_invalid_fields(queryset, fields, view, request)
if o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sort_by_query_string_param(self, songs):\n orderable_fields_dict = {\n 'name': Lower('name'),\n 'artist': Lower('artist__name'),\n 'avgRating': 'average_rating',\n 'year': 'year'\n }\n\n order_by = self.request.query_params.get('orderBy', None)\... | [
"0.6548646",
"0.6339288",
"0.63350976",
"0.6280332",
"0.6231859",
"0.60011864",
"0.59715325",
"0.5950593",
"0.5941029",
"0.58408827",
"0.58376485",
"0.5808046",
"0.5758433",
"0.57560813",
"0.5746289",
"0.57187814",
"0.56474346",
"0.56353605",
"0.55608726",
"0.554913",
"0.5512... | 0.5934701 | 9 |
Create an empty Message. | def __init__(self, openid_namespace=None):
self.args = {}
self.namespaces = NamespaceMap()
if openid_namespace is None:
self._openid_ns_uri = None
else:
implicit = openid_namespace in OPENID1_NAMESPACES
self.setOpenIDNamespace(openid_namespace, implici... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createMessage( self, *args, **kw ):\n return MailMessage( *args, **kw )",
"def Message(self, *args, **kwargs):\n return Message(self, *args, **kwargs)",
"def message(self, *args, **kwargs) -> Message:\n return Message(self.handle, *args, **kwargs)",
"def createMessage( self, *args, *... | [
"0.73098487",
"0.7020393",
"0.68267363",
"0.6607929",
"0.65662277",
"0.65537304",
"0.6550735",
"0.64826477",
"0.64555025",
"0.6449307",
"0.6400586",
"0.6335153",
"0.6331504",
"0.6273631",
"0.6228902",
"0.61994874",
"0.61625075",
"0.6162155",
"0.6099113",
"0.6082046",
"0.60644... | 0.0 | -1 |
Simplify a term using the convergent rewrite rules known. | def simplify(cls, x: Term, bound: int = -1) -> Optional[Term]:
if not isinstance(x, FuncTerm):
raise ValueError("simplify function expects a FuncTerm.")
return normal(x, cls.rules, bound)[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simplify(term):\n simplified_term = term\n\n if isinstance(term,StatementTerm):\n simplified_term = StatementTerm(subject_term=simplify(term.get_subject_term()),\n predicate_term=simplify(term.get_predicate_term()),\n copula=term.get_copula()... | [
"0.72734314",
"0.6471595",
"0.6139479",
"0.6090935",
"0.6069272",
"0.5980187",
"0.58624965",
"0.5855295",
"0.5781",
"0.56962633",
"0.5640727",
"0.561756",
"0.55975735",
"0.55692387",
"0.55635285",
"0.55527335",
"0.54700464",
"0.5453202",
"0.54434156",
"0.54423153",
"0.5435548... | 0.5815264 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.