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 |
|---|---|---|---|---|---|---|
Return the date (UTC) from 10 days ago formatted as YYYYMMDD. | def _ten_days_ago() -> str:
ten_days_ago = gmtime(mktime(gmtime()) - TEN_DAYS_SECONDS)
return strftime(DATE_FORMAT, ten_days_ago) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ago(self):\n return human(self.timestamp/1000.0, precision=1, abbreviate=True)",
"def relativeTime(date):\n diff = datetime.utcnow() - date\n\n if diff.days > 7 or diff.days < 0:\n return date.ctime()\n elif diff.days == 1:\n return '1 day ago'\n elif diff.days > 1:\n return '%d days ago'... | [
"0.63436246",
"0.6039876",
"0.5983086",
"0.5962784",
"0.58728963",
"0.581312",
"0.58069855",
"0.5791033",
"0.5787348",
"0.5763219",
"0.56588507",
"0.5579537",
"0.5577654",
"0.55374175",
"0.5471164",
"0.539841",
"0.53682923",
"0.5352607",
"0.53389454",
"0.53330094",
"0.5331382... | 0.7581562 | 0 |
Return the last month (UTC) formatted as YYYYMM. | def _last_month() -> str:
time_now = gmtime()
return (
f"{time_now.tm_year}-{time_now.tm_mon - 1:02d}" if time_now.tm_mon > 1
else f"{time_now.tm_year - 1}-12"
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_month_day():\r\n return (datetime.now().replace(day=1) + relativedelta(months=1) + timedelta(days=-1)).strftime(\r\n '%d-%m-%Y')",
"def make_last_month_period(dt=None):\n if not dt:\n dt = datetime.utcnow()\n dt = dt.replace(day=1) - timedelta(days=1)\n return dt.strftime('%Y%m... | [
"0.7890911",
"0.77757496",
"0.7772196",
"0.74962604",
"0.7192194",
"0.6839517",
"0.6807995",
"0.6761683",
"0.6746424",
"0.6616606",
"0.66151744",
"0.6588002",
"0.6588002",
"0.6579385",
"0.6565151",
"0.65579987",
"0.65383244",
"0.64961576",
"0.6473222",
"0.64433897",
"0.639331... | 0.8435946 | 0 |
Calculate the 15min delayed BTC market price in GBP. | def _get_btc_gbp_15min(self) -> None:
self._get_eur_gbp_last_daily()
self.btc_gbp_15min = self.btc_eur_15min * self.eur_gbp_last_day | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_work(self) -> None:\n self._get_btc_eur_15min()\n print(\n f\"1 BTC = {self.btc_eur_15min} EUR\"\n f\"\\t\\t(15min delayed market price)\"\n )\n\n self._get_eur_gbp_last_month()\n print(\n f\"1 EUR = {self.eur_gbp_last_month} GBP\"\n ... | [
"0.6735869",
"0.6266725",
"0.61613244",
"0.6135455",
"0.6012119",
"0.5998848",
"0.5924012",
"0.5846881",
"0.58299065",
"0.58050394",
"0.5770253",
"0.5769695",
"0.576529",
"0.5724111",
"0.57105625",
"0.5661389",
"0.563068",
"0.56113887",
"0.560933",
"0.5585725",
"0.5583436",
... | 0.7985306 | 0 |
Return whether or not an email or password combination is valid. | def authenticate():
# Get JSON data from request
json = request.get_json()
if 'email' not in json or 'password' not in json:
raise CustomError(400, message='Must include an email and a password')
# Check email
user = User.query.filter_by(email=json['email']).first()
if user is None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_auth(email, password):\n if not email or not password:\n return False\n sha = sha1(email).hexdigest()\n user_info = redis.hgetall(\"sl:account:{}\".format(sha))\n\n return bool(\n type(user_info) == dict and\n user_info.get(\"password\") == pas... | [
"0.7349685",
"0.68957275",
"0.6839669",
"0.6783419",
"0.67657584",
"0.6671322",
"0.66452736",
"0.663105",
"0.6579197",
"0.6508494",
"0.6490613",
"0.647486",
"0.6462656",
"0.6462656",
"0.6454392",
"0.64511716",
"0.64275295",
"0.64244556",
"0.6408592",
"0.6401601",
"0.64013714"... | 0.0 | -1 |
Get a user by its id. | def get_user_by_id(id):
user = User.query.get(id)
if user is None:
raise CustomError(404, 'User with id: {} was not found.'.format(id))
return jsonify({'success': True, 'user': user.to_dict()}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_by_id(self, id):\n\t\treturn self.users.get(id)",
"def get(self, id):\n\t\ttry:\n\t\t\tflask_app.logger.debug('We are getting the user: %d', id)\n\t\t\treturn user_service.get(id)\n\t\texcept AssertionError as e:\n\t\t\tuser_space.abort(400, e.args[0], status = \"Could not get user\", statusCode = \... | [
"0.89340585",
"0.8621323",
"0.85916656",
"0.8508148",
"0.8499932",
"0.84347427",
"0.8386604",
"0.8384479",
"0.8328696",
"0.8305895",
"0.82829595",
"0.82829595",
"0.82829595",
"0.82829595",
"0.8282169",
"0.82745594",
"0.8266114",
"0.82544875",
"0.82501876",
"0.8243749",
"0.821... | 0.8168108 | 27 |
Return checked to HTML input (checkbox) | def check_ignore(self):
return "checked" if not self.ignore else "" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uiCheckboxChecked(checkbox):\n\n return clibui.uiCheckboxChecked(checkbox)",
"def htmlCheckbox(labelText, parName, args, labelAttr='', attr=''):\n snippet = htmlLabel(labelText,parName,labelAttr)\n checked = 'checked=\"checked\"' if parName in args else ''\n snippet += '<input type=\"checkbox\" n... | [
"0.73874754",
"0.7013393",
"0.67862654",
"0.6326686",
"0.6137979",
"0.61240286",
"0.61000293",
"0.60839576",
"0.60712683",
"0.60165775",
"0.5976162",
"0.59326965",
"0.58932775",
"0.588823",
"0.5887761",
"0.5884953",
"0.5875955",
"0.5836536",
"0.5805211",
"0.57928985",
"0.5773... | 0.49396482 | 93 |
initialize parameters using kaiming normal | def init_parameters(module: nn.Module):
for m in module.modules():
if isinstance(m, nn.Conv2d):
# todo: check if fan_out is valid
nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu')
elif isinstance(m, nn.BatchNorm2d):
nn.init.constant_(m.weight,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __setup_parameters__(self):\r\n self.M=self.N+1\r\n self.u=1+self.pu\r\n self.d=1-self.pd\r\n self.qu=(math.exp((self.r-self.div)*self.dt)-self.d)/(self.u-self.d)\r\n self.qd=1-self.qu",
"def init_paramters(self):\r\n carb_bg_ratio = 5.0\r\n time_to_breakdown ... | [
"0.7051572",
"0.6925155",
"0.6915251",
"0.68529457",
"0.68099403",
"0.6714396",
"0.6687382",
"0.6675767",
"0.6673424",
"0.66504097",
"0.66460747",
"0.66280675",
"0.66103244",
"0.6576185",
"0.6574086",
"0.65717214",
"0.6559772",
"0.65528405",
"0.6546903",
"0.6539553",
"0.65352... | 0.0 | -1 |
Return False if command is dead, otherwise True. | def check_command(self):
return self.process is not None and self.process.poll() is None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_dead(self):\n if self.killer:\n if self.killer.stype == 'fire' and not (self.killer in self.pjs.fires):\n return True\n elif self.killer.stype == 'enemy' and self.timeout == 0:\n return True\n else:\n return False",
"def __is_act... | [
"0.6922289",
"0.6847067",
"0.68249875",
"0.66671854",
"0.66655314",
"0.6653957",
"0.65789324",
"0.6558258",
"0.6550506",
"0.649371",
"0.64785314",
"0.64250284",
"0.63963515",
"0.6387006",
"0.6375392",
"0.6337235",
"0.62643814",
"0.62609",
"0.6241368",
"0.6222854",
"0.62103415... | 0.69605875 | 0 |
Plot and save confusion matrix computed from predicted and real labels. Arguments | def plot_confusion_matrix(real_labels, pred_prob, classes,
normalize=False,
img_name="confusion.png"):
real_labels = np.array(real_labels)
# Binarize predicted probabilities
pred_prob = np.array(pred_prob)
pred_labels = np.zeros_like(pred_prob)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(self, y_true, y_pred, title=None):\r\n\r\n if not title:\r\n title = 'confusion matrix'\r\n\r\n # Compute confusion matrix\r\n\r\n y_pred = np.array(y_pred)\r\n y_true = np.array(y_true)\r\n cm = confusion_matrix(y_true, y_pred)\r\n # O... | [
"0.7909803",
"0.77706945",
"0.7693289",
"0.7669506",
"0.7644297",
"0.7616977",
"0.757757",
"0.75686",
"0.7555622",
"0.7483602",
"0.74831176",
"0.74774474",
"0.7476126",
"0.7471495",
"0.7468893",
"0.7465456",
"0.74556404",
"0.7446722",
"0.74444157",
"0.7443814",
"0.74419767",
... | 0.7841449 | 1 |
Return the device class of the sensor. | def device_class(self) -> Optional[str]:
class_or_icon = SENSOR_DEVICE_CLASS_ICON_MAP.get(
self._tasmota_entity.quantity, {}
)
return class_or_icon.get(DEVICE_CLASS) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_class(self):\n return self.sensor_type[\"class\"]",
"def device_class(self):\n return SENSOR_TYPES[self.sensor][3].get(\"device_class\")",
"def device_class(self):\n return self._sensor_type",
"def device_class(self):\r\n return self._sensor_cfg[3]",
"def device_class... | [
"0.93628424",
"0.92430294",
"0.9240069",
"0.9161452",
"0.9161452",
"0.9156968",
"0.90412056",
"0.90412056",
"0.8956785",
"0.89529496",
"0.8950599",
"0.8919914",
"0.871994",
"0.8717259",
"0.87069035",
"0.8660478",
"0.8652474",
"0.83961546",
"0.83828783",
"0.8380708",
"0.838070... | 0.81339943 | 31 |
Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
)
)
if unload_ok:
has... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def async_unload_entry(hass, config_entry):\n unload_ok = await hass.config_entries.async_forward_entry_unload(\n config_entry, \"climate\"\n )\n return unload_ok",
"async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:\n hass.data.pop(DOMAIN)\n return True",
... | [
"0.697284",
"0.6888074",
"0.6779855",
"0.6747459",
"0.6689002",
"0.6657831",
"0.66162205",
"0.6603433",
"0.65925974",
"0.65595686",
"0.65411645",
"0.6507643",
"0.6507643",
"0.6507643",
"0.6507643",
"0.64977276",
"0.64931643",
"0.6486601",
"0.6486601",
"0.6486601",
"0.6486601"... | 0.6459733 | 28 |
Attempt to place mover into contents. Returns a Boolean representation of success. | def contain(self, mover):
# Check if mover can exit old location
old_location = mover.location
if(not old_location):
return False
if(not old_location.allow_exit(mover)):
return False
# Check if mover can enter current location
if(not self.allow_ent... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move(self) -> bool:\n pass",
"def allow_entry(self, mover):\n return True",
"def test_object_move(self):\n self.assertTrue(self.obj1 in self.room1.contents)\n # use move_to hook\n self.obj1.move_to(self.room2)\n self.assertFalse(self.obj1 in self.room1.contents)\n ... | [
"0.5737424",
"0.5638439",
"0.5441351",
"0.5409434",
"0.5399845",
"0.5309671",
"0.52931213",
"0.5276102",
"0.5168468",
"0.5082271",
"0.50646865",
"0.505076",
"0.50131536",
"0.50104046",
"0.50004804",
"0.4979135",
"0.49734983",
"0.4963041",
"0.49610388",
"0.49543136",
"0.495197... | 0.7234833 | 0 |
Determines if the mover is permitted to exit the room. | def allow_exit(self, mover):
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_exited(self):\n agents = self.board[self.agent_locs_idx]\n return agents & (CellTypes.agent | CellTypes.exit) == CellTypes.exit",
"def can_exit(self) -> bool:\n return False",
"def check_exit(self, position, direction):\n if self.get_room((position[0] + direction[0], positio... | [
"0.6301413",
"0.6263654",
"0.62400985",
"0.60136616",
"0.58825636",
"0.58812755",
"0.58409286",
"0.5794512",
"0.5793184",
"0.5782265",
"0.5782265",
"0.57529366",
"0.5692975",
"0.5673591",
"0.56546485",
"0.56517553",
"0.5650926",
"0.5650613",
"0.5642109",
"0.56175417",
"0.5615... | 0.7196453 | 0 |
Creates a tree from list. First element is root value, others are children nodes. (values or subtrees). | def construct(lst):
t = Tree()
t.root = lst[0]
for node in lst[1:]:
if isinstance(node, list):
t.nodes.append(construct(node))
else:
t.nodes.append(node)
return t | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_tree(tree_list, nums):\n\n if len(nums) == 0:\n return tree_list\n next_list = []\n j = 0\n for i in tree_list:\n for _ in range(2):\n if i is not None and j < len(nums):\n if nums[j] is No... | [
"0.70470774",
"0.69341266",
"0.6903691",
"0.6826804",
"0.67401844",
"0.6710746",
"0.65991884",
"0.6522682",
"0.63863814",
"0.6339975",
"0.63145685",
"0.63064444",
"0.6274908",
"0.6264302",
"0.62484676",
"0.62479275",
"0.6221631",
"0.62191725",
"0.6189883",
"0.6159182",
"0.615... | 0.7338503 | 0 |
If the x,y equal, we assume that the both Nodes are same | def equal(self,other):
if(self.x == other.x) and (self.y == other.y):
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_same_as(self, other) -> bool:\n return self.x == other.x and self.y == other.y",
"def compareNodes(x, y):\n return x.pathValue - y.pathValue",
"def __eq__(self, other):\n return self.x == other.x and self.y == other.y",
"def __eq__(self, second):\r\n\t\treturn self.x == other.x and se... | [
"0.7050482",
"0.70344174",
"0.69647264",
"0.693082",
"0.69281536",
"0.68705666",
"0.68475515",
"0.68315655",
"0.67769325",
"0.67707807",
"0.67489284",
"0.67242",
"0.67242",
"0.6677688",
"0.6663041",
"0.6656221",
"0.6656221",
"0.6656221",
"0.6656221",
"0.6656221",
"0.66506815"... | 0.69610524 | 3 |
Diagonal distance h_diagonal(n) = min(abs(n.x goal.x), abs(n.y goal.y)) h_straight(n) = (abs(n.x goal.x) + abs(n.y goal.y)) h(n) = D_diagnoal h_diagonal(n) + D_straight (h_straight(n) 2h_diagonal(n))) | def heuristic_cost_estimate(start, goal,d_diagnoal,d_straight):
start_x = start.x
start_y = start.y
goal_x = goal.x
goal_y = goal.y
h_diagonal = min(np.abs(start_x - goal_x),np.abs(start_y - goal_y))
h_straight = np.abs(start_x - goal_x) + np.abs(start_y - goal_y)
h = d_diagnoal * h_diagona... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dist_between(current, neighbor,d_diagnoal,d_straight):\n start_x = current.x\n start_y = current.y\n goal_x = neighbor.x\n goal_y = neighbor.y\n\n h_diagonal = min(np.abs(start_x - goal_x),np.abs(start_y - goal_y))\n h_straight = np.abs(start_x - goal_x) + np.abs(start_y - goal_y)\n h = d_... | [
"0.8049952",
"0.6934964",
"0.69334024",
"0.6747959",
"0.644159",
"0.62714773",
"0.6160783",
"0.6144977",
"0.6144977",
"0.61420053",
"0.6101649",
"0.6096123",
"0.60647726",
"0.6007809",
"0.59770143",
"0.5892348",
"0.5882317",
"0.5860657",
"0.5833256",
"0.58259183",
"0.57475424... | 0.7815696 | 1 |
Diagonal distance h_diagonal(n) = min(abs(n.x goal.x), abs(n.y goal.y)) h_straight(n) = (abs(n.x goal.x) + abs(n.y goal.y)) h(n) = D_diagnoal h_diagonal(n) + D_straight (h_straight(n) 2h_diagonal(n))) | def dist_between(current, neighbor,d_diagnoal,d_straight):
start_x = current.x
start_y = current.y
goal_x = neighbor.x
goal_y = neighbor.y
h_diagonal = min(np.abs(start_x - goal_x),np.abs(start_y - goal_y))
h_straight = np.abs(start_x - goal_x) + np.abs(start_y - goal_y)
h = d_diagnoal * h_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def heuristic_cost_estimate(start, goal,d_diagnoal,d_straight):\n start_x = start.x\n start_y = start.y\n goal_x = goal.x\n goal_y = goal.y\n\n h_diagonal = min(np.abs(start_x - goal_x),np.abs(start_y - goal_y))\n h_straight = np.abs(start_x - goal_x) + np.abs(start_y - goal_y)\n h = d_diagnoa... | [
"0.7815963",
"0.6935118",
"0.69333106",
"0.6748271",
"0.6441967",
"0.6272037",
"0.616098",
"0.614516",
"0.614516",
"0.6142244",
"0.61005026",
"0.6096975",
"0.60649806",
"0.60074985",
"0.59759593",
"0.58921903",
"0.5882251",
"0.58594304",
"0.58325016",
"0.5826039",
"0.57475173... | 0.80509466 | 0 |
Get neighbors of current node | def getNeighbors(current,width,height):
x = current.x
y = current.y
neighbors = np.array([[x],[y]])
if (x - 1) >= 0:
t = np.array([[x - 1], [y]])
neighbors = np.hstack((neighbors, t))
if (y - 1) >= 0:
t = np.array([[x - 1], [y - 1]])
neighbors = np.hstack(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def neighbors(self, node):\r\n return list(self.graph.neighbors(node))",
"def get_neighbors(self):\n return self.neighbors",
"def get_neighbors(self):\n return self.neighbors",
"def get_neighbors(self):\n return self.neighbors",
"def get_neighbors(self):\n return self.nei... | [
"0.82076806",
"0.81595117",
"0.81595117",
"0.81595117",
"0.81595117",
"0.81556916",
"0.81038094",
"0.8046027",
"0.80142957",
"0.79389143",
"0.7928019",
"0.7904153",
"0.78723794",
"0.7864975",
"0.78584856",
"0.7812342",
"0.78112066",
"0.77656096",
"0.77593744",
"0.772959",
"0.... | 0.66926175 | 100 |
One dimensional power law derivative with respect to parameters | def fit_deriv(x, amplitude, x_0, alpha):
xx = x / x_0
d_amplitude = xx ** (-alpha)
d_x_0 = amplitude * alpha * d_amplitude / x_0
d_alpha = -amplitude * d_amplitude * np.log(xx)
return [d_amplitude, d_x_0, d_alpha] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dgdy(self, X):\n \n return 3*X[1]**2",
"def dV(X):\n return -4 * a * np.power(X, 3) + 2 * b * X",
"def derivatives(x_p, y_p):\r\n # set up the matrix equation\r\n n = x_p.shape[0]\r\n M = np.zeros( [n,n] )\r\n d = np.zeros( [n,1] )\r\n \r\n # fill in the constants where t... | [
"0.6734102",
"0.65710866",
"0.64798695",
"0.6456969",
"0.64338213",
"0.64268124",
"0.63887954",
"0.63887954",
"0.634643",
"0.63460815",
"0.6338571",
"0.63372827",
"0.6308936",
"0.63080084",
"0.6305035",
"0.6289483",
"0.62714446",
"0.62588847",
"0.62584984",
"0.6250596",
"0.62... | 0.6106129 | 44 |
One dimensional broken power law derivative with respect to parameters | def fit_deriv(x, amplitude, x_break, alpha_1, alpha_2):
alpha = np.where(x < x_break, alpha_1, alpha_2)
xx = x / x_break
d_amplitude = xx ** (-alpha)
d_x_break = amplitude * alpha * d_amplitude / x_break
d_alpha = -amplitude * d_amplitude * np.log(xx)
d_alpha_1 = np.whe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dgdy(self, X):\n \n return 3*X[1]**2",
"def derivativeW(self, *args):\n if self.n_dims >= 4:\n j = 0\n else:\n assert (\n False\n ), \"Derivative with respect to W can't be called when n_dims < 4!\"\n if self.i_dim == j:\n ... | [
"0.6551897",
"0.646485",
"0.64178663",
"0.64106286",
"0.6382745",
"0.6354045",
"0.63523704",
"0.6345646",
"0.6331496",
"0.63267994",
"0.6326617",
"0.63140196",
"0.63140196",
"0.6313484",
"0.6305103",
"0.6294662",
"0.6289381",
"0.6286769",
"0.6270342",
"0.62632966",
"0.6260843... | 0.0 | -1 |
Recursively fuse conv and bn in a module. During inference, the functionary of batch norm layers is turned off but only the mean and var alone channels are used, which exposes the chance to fuse it with the preceding conv layers to save computations and simplify network structures. | def fuse_conv_bn(module):
last_conv = None
last_conv_name = None
for name, child in module.named_children():
if isinstance(child,
(nn.modules.batchnorm._BatchNorm, nn.SyncBatchNorm)):
if last_conv is None: # only fuse BN that is after Conv
continue... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fuse_conv_bn(conv, bn):\n conv_w = conv.weight\n conv_b = conv.bias if conv.bias is not None else torch.zeros_like(\n bn.running_mean)\n\n factor = bn.weight / torch.sqrt(bn.running_var + bn.eps)\n conv.weight = nn.Parameter(conv_w *\n factor.reshape([conv.out_... | [
"0.695171",
"0.6805263",
"0.6269793",
"0.62578046",
"0.6063939",
"0.6063939",
"0.60563296",
"0.6027096",
"0.60044354",
"0.5954461",
"0.5929739",
"0.5882636",
"0.58481455",
"0.5835012",
"0.5830163",
"0.57766056",
"0.57479167",
"0.5734447",
"0.57262725",
"0.5723586",
"0.5721918... | 0.7612941 | 0 |
Updates this configuration object from a dictionary. | def update_from_dict(self, dct):
if not dct:
return
all_props = self.__class__.CONFIG_PROPERTIES
for key, value in six.iteritems(dct):
attr_config = all_props.get(key)
if attr_config:
setattr(self, key, value)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, config_dict):\r\n self._update(config_dict, allow_new_keys=True)",
"def update(self, config_dict):\n self._update(config_dict, allow_new_keys=True)",
"def update_from_dict(self, dictionary):\n for key in dictionary:\n setattr(self, key, dictionary[key])\n ret... | [
"0.7539606",
"0.7526402",
"0.73409635",
"0.6924898",
"0.6826344",
"0.68139464",
"0.67985266",
"0.6760424",
"0.6756888",
"0.66938514",
"0.65406144",
"0.6525585",
"0.6479391",
"0.64561343",
"0.6436355",
"0.6408912",
"0.6408051",
"0.63989556",
"0.63800776",
"0.63728046",
"0.6356... | 0.7746895 | 0 |
Updates the configuration with the contents of the given configuration object or dictionary. In case of a dictionary, only valid attributes for this class are considered. Existing attributes are replaced with the new values. The object is not cleaned before or after, i.e. may accept invalid input. In case of an update ... | def update(self, values, copy_instance=False):
if isinstance(values, self.__class__):
self.update_from_obj(values, copy=copy_instance)
elif isinstance(values, dict):
self.update_from_dict(values)
else:
raise ValueError("{0} or dictionary expected; found '{1}'.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update(self, config_dict, allow_new_keys=True):\r\n if not config_dict:\r\n return\r\n\r\n for k, v in six.iteritems(config_dict):\r\n if k not in self.__dict__:\r\n if allow_new_keys:\r\n self.__setattr__(k, v)\r\n else:\r\n raise KeyError('Key `{}` does not ex... | [
"0.7369526",
"0.72188014",
"0.71054125",
"0.6892814",
"0.68874276",
"0.68512803",
"0.641856",
"0.63729274",
"0.6282296",
"0.61824185",
"0.6173597",
"0.61599773",
"0.61506504",
"0.6055091",
"0.6051019",
"0.6051019",
"0.6043906",
"0.60201603",
"0.59867066",
"0.59764946",
"0.596... | 0.55972207 | 51 |
Returns a copy of the configuration dictionary. Changes in this should not reflect on the original object. | def as_dict(self):
self.clean()
d = OrderedDict()
all_props = self.__class__.CONFIG_PROPERTIES
for attr_name, attr_config in six.iteritems(all_props):
value = self._config[attr_name]
attr_type = attr_config.attr_type
if attr_type:
if va... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __copy__(self):\n d = dict()\n d.update(self.items())\n return d",
"def copy(self):\n return self.from_dict(self.to_dict(True))",
"def get(self) -> dict:\n return clone(self.__dict__)",
"def clone(self) -> 'ContainerConfig':\n return deepcopy(self)",
"def copy(... | [
"0.74385566",
"0.7369222",
"0.73497945",
"0.7333246",
"0.7279644",
"0.7213318",
"0.72081774",
"0.7177167",
"0.71266174",
"0.70725924",
"0.70725346",
"0.7034118",
"0.69861895",
"0.69729465",
"0.69077206",
"0.69053024",
"0.68810904",
"0.68651885",
"0.6863838",
"0.6860341",
"0.6... | 0.0 | -1 |
Convert a set of `InputExample`s to a list of `InputFeatures`. | def convert_examples_to_features(tokenizer, examples, max_seq_length=256):
input_ids, input_masks, segment_ids, labels = [], [], [], []
# for example in tqdm(examples, desc="Converting examples to features"):
for example in examples:
input_id, input_mask, segment_id, label = convert_single_example(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_examples_to_features(examples, tokenizer, is_training, args):\n all_features = []\n positive_features = 0\n negative_features = 0\n logger.info(\"Converting a list of NqExamples into InputFeatures ...\")\n for index, example in enumerate(tqdm(examples)):\n example_index = example[... | [
"0.73133975",
"0.7042608",
"0.69537765",
"0.6883128",
"0.68623626",
"0.685001",
"0.68385124",
"0.6820685",
"0.6765126",
"0.67010623",
"0.66909826",
"0.66590303",
"0.6587141",
"0.6575663",
"0.655151",
"0.64223295",
"0.64164066",
"0.6334047",
"0.6323665",
"0.6314246",
"0.628306... | 0.69446 | 3 |
Gathers this tensor from all processes. Supports backprop. | def gather(input: torch.Tensor) -> Tuple[torch.Tensor]:
return GatherLayer.apply(input) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process(self, sess):\n\n sess.run(self.sync) # copy weights from shared to local\n rollout = self.pull_batch_from_queue()\n batch = process_rollout(rollout, gamma=0.99, lambda_=1.0)\n\n should_compute_summary = self.task == 0 and self.local_steps % 11 == 0\n\n if should_comp... | [
"0.60234517",
"0.59920496",
"0.59397244",
"0.59397244",
"0.5855692",
"0.5820956",
"0.5770425",
"0.57674265",
"0.57518774",
"0.56285346",
"0.56285346",
"0.56052834",
"0.55982333",
"0.5576598",
"0.55694216",
"0.5524458",
"0.55227476",
"0.5519531",
"0.55187434",
"0.54854375",
"0... | 0.0 | -1 |
Plots the probability of observing a sample from state i (row) in state j (column). For convenience, the neigboring state cells are fringed in bold. | def plotOverlapMatrix(O):
max_prob = O.max()
fig = pl.figure(figsize=(K/2.,K/2.))
fig.add_subplot(111, frameon=False, xticks=[], yticks=[])
for i in range(K):
if i!=0:
pl.axvline(x=i, ls='-', lw=0.5, color='k', alpha=0.25)
pl.axhline(y=i, ls='-', lw=0.5, color='... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __draw(self, state:dict):\n _, ax = plt.subplots()\n ax.set_axis_off()\n tb = Table(ax, bbox=[0,0,1,1])\n\n width = height = 1.0 /9 \n\n\n for key in self.state.keys():\n # Add cells\n i,j = self.__display_table_map[key]\n tb.add_cell(i, j, wi... | [
"0.62075657",
"0.6059904",
"0.60067856",
"0.5875241",
"0.58613783",
"0.5835459",
"0.57914424",
"0.5699644",
"0.5671611",
"0.56513095",
"0.5606568",
"0.5569045",
"0.5562588",
"0.55362916",
"0.5512227",
"0.550696",
"0.54794586",
"0.5475376",
"0.54668474",
"0.54337996",
"0.54149... | 0.0 | -1 |
True if expires is not equal to orig_expires. | def updated(self):
return self.expires != self.orig_expires | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_expires(self):\n # We aren't bother going to test the actual time in expires, that\n # way lies pain with broken tests later.\n up = self.get(self.good_data)\n hdrs = dict(up.get_headers(1))\n lm = datetime(*utils.parsedate_tz(hdrs['Last-Modified'])[:7])\n exp = d... | [
"0.7073698",
"0.69195384",
"0.6914716",
"0.69129467",
"0.67846453",
"0.6679914",
"0.660565",
"0.65767676",
"0.6557804",
"0.6405459",
"0.638651",
"0.63783026",
"0.6330744",
"0.6310361",
"0.6259558",
"0.6224024",
"0.6209609",
"0.6207446",
"0.61312985",
"0.61132365",
"0.609304",... | 0.76405764 | 0 |
Promotes new_expiry to expiry. | def rotate_lists(self):
for item in self.new_expiry:
item.moving()
self.expiry = sorted(self.new_expiry, key=lambda x:x.orig_expires)
self.new_expiry = []
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modify_expiration(self, new_expiration):\n if self.is_cancellable:\n if self.expiration!=new_expiration:\n log.info(\"bo#%s: modify expiration of pending order\" % self.ticket)\n dt = get_datetime()\n new_expiration = dt_td_to_dt(new_expiration, dt... | [
"0.6488498",
"0.6143769",
"0.5902444",
"0.5682059",
"0.5525352",
"0.54472095",
"0.5412708",
"0.5358802",
"0.5306796",
"0.5305444",
"0.52702665",
"0.5263881",
"0.5237109",
"0.52044123",
"0.519679",
"0.5190725",
"0.5186643",
"0.5186452",
"0.5183078",
"0.5131201",
"0.5110786",
... | 0.4541154 | 83 |
Get the absolute path of the given path relative to the project root. | def root(*args):
return join(abspath(dirname(__file__)), *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def absolute_path(path):\n return os.path.abspath(\n os.path.join(\n os.path.dirname(__file__),\n \"..\",\n path\n )\n )",
"def get_abspath(path: str) -> str:\n if os.path.isabs(path):\n return path\n\n return os.path.join(os.path.dirname(__file__... | [
"0.8670202",
"0.84047705",
"0.8294552",
"0.821738",
"0.820904",
"0.8198882",
"0.811792",
"0.8009987",
"0.79817665",
"0.79465127",
"0.79298115",
"0.79059446",
"0.7758221",
"0.76706994",
"0.7659717",
"0.761842",
"0.7523429",
"0.74900115",
"0.7480654",
"0.74671346",
"0.74658513"... | 0.0 | -1 |
Changes the subreddit name. Name of the subreddit you want to change to. | def setSubreddit(self, subredditName):
self.nameOfSubreddit = subredditName
self.subreddit = self.praw.subreddit(nameOfSubreddit) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_name(self, new_name):\r\n self.__name = new_name",
"def update_name(self, new_name):\r\n self.__name = new_name",
"def ChangeName(self, newName):\n if newName != \"\":\n newPath = self.format + os.sep + \"playlists\" + os.sep + newName + \".txt\"\n os.repla... | [
"0.6665063",
"0.6665063",
"0.6544932",
"0.6535344",
"0.638324",
"0.63765067",
"0.63743895",
"0.636293",
"0.6334866",
"0.612783",
"0.612274",
"0.612274",
"0.6089802",
"0.6071336",
"0.60371286",
"0.6034261",
"0.6018913",
"0.6016731",
"0.6003661",
"0.59978575",
"0.591629",
"0.... | 0.77809405 | 0 |
Initialize hyperparameters for the spectralmixture kernel. Weights are all set to be uniformly distributed, means are given as the peaks in the frequency spectrum, and variances are given by a random sample from a uniform distribution with a max equal to the max distance. | def initSMParamsFourier(Q, x, y, sn, samplingFreq, nPeaks, relMaxOrder=2):
x = np.atleast_2d(x)
y = np.atleast_2d(y)
n, D = x.shape
w = np.zeros(Q)
m = np.zeros((D,Q))
s = np.zeros((D,Q))
w[:] = np.std(y) / Q
hypinit = {
'cov': np.zeros(Q+2*D*Q),
'lik': np.atleast_1d(np.l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_parameters(self):\n stdv = 1. / math.sqrt(self.weight.data.size(1))\n self.weight.data.uniform_(-stdv, stdv)\n if self.bias is not None:\n self.bias.data.uniform_(-stdv, stdv)",
"def initialize_parameters(self):\n for i in range(1, self.L):\n self.W[i - ... | [
"0.6774762",
"0.6662212",
"0.6590797",
"0.6580719",
"0.653845",
"0.65343827",
"0.6457986",
"0.6452538",
"0.64459723",
"0.64149785",
"0.6335864",
"0.62844634",
"0.6237224",
"0.61584514",
"0.61222535",
"0.6107818",
"0.6079155",
"0.6045198",
"0.5999778",
"0.5988833",
"0.598171",... | 0.5759183 | 59 |
Initialize hyperparameters for the spectralmixture kernel. Weights are all set to be uniformly distributed, means are given by a random sample from a uniform distribution scaled by the Nyquist frequency, and variances are given by a random sample from a uniform distribution scaled by the max distance. | def initSMParams(Q, x, y, sn):
x = np.atleast_2d(x)
y = np.atleast_2d(y)
n, D = x.shape
w = np.zeros(Q)
m = np.zeros((D,Q))
s = np.zeros((D,Q))
w[:] = np.std(y) / Q
hypinit = {
'cov': np.zeros(Q+2*D*Q),
'lik': np.atleast_1d(np.log(sn)),
'mean': np.array([])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_parameters(self):\n stdv = 1. / math.sqrt(self.weight.data.size(1))\n self.weight.data.uniform_(-stdv, stdv)\n if self.bias is not None:\n self.bias.data.uniform_(-stdv, stdv)",
"def initialize_parameters(self):\n for i in range(1, self.L):\n self.W[i - ... | [
"0.6870166",
"0.67820096",
"0.66796654",
"0.667258",
"0.6586674",
"0.65543795",
"0.64954084",
"0.64887315",
"0.64326423",
"0.64283997",
"0.6424432",
"0.6400535",
"0.63936627",
"0.6386461",
"0.62629104",
"0.62402385",
"0.6229552",
"0.61286724",
"0.6112169",
"0.61040556",
"0.60... | 0.5852104 | 56 |
Check if clusters1 equals to clusters2, return True if so, or False if not. | def is_converged(clusters1, clusters2, k, num_of_cords):
for i in range(k):
for j in range(num_of_cords):
if clusters1[i][j] != clusters2[i][j]:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def identical_cds(sc1,sc2):\n # Input 2 identical segment chains, return True if cds the same\n if sc1.covers(sc2) and sc2.covers(sc1):\n return True\n else:\n return False",
"def are_clusters_similar(cls, c1, c2, proportion=0.8):\n if len(c1.indices) > len(c2.indices):\n ... | [
"0.6819774",
"0.67053854",
"0.6577482",
"0.6567598",
"0.6566153",
"0.6465101",
"0.6442963",
"0.6380351",
"0.6379164",
"0.6357021",
"0.63215804",
"0.6296718",
"0.62854797",
"0.6203128",
"0.62005913",
"0.61896455",
"0.6144872",
"0.61378944",
"0.6137696",
"0.61299753",
"0.610979... | 0.8044068 | 0 |
creates n distint colors for plts, where n = num_colors | def get_colors(num_colors):
import colorsys
colors = []
for i in np.arange(0., 360., 360. / num_colors):
hue = i/360.
lightness = (50 + np.random.rand() * 10)/100.
saturation = (90 + np.random.rand() * 10)/100.
colors.append(colorsys.hls_to_rgb(hue, lightness, saturation)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_funky_cmap(n_colors):\n\n colors = []\n for i in np.arange(0., 360., 360. / n_colors):\n h = i / 360.\n l = (50 + np.random.rand() * 10) / 100.\n s = (90 + np.random.rand() * 10) / 100.\n colors.append(hls_to_rgb(h, l, s))\n\n return colors",
"def generate_n_colors... | [
"0.749464",
"0.74524117",
"0.7178915",
"0.71482074",
"0.7119622",
"0.7088267",
"0.6929152",
"0.6905464",
"0.68315506",
"0.6754532",
"0.672276",
"0.6686234",
"0.6637927",
"0.66152275",
"0.6572149",
"0.6569774",
"0.6569445",
"0.65186614",
"0.650056",
"0.6491387",
"0.6475267",
... | 0.66890764 | 11 |
Create a Pandas DataFrame out of a .yaml file. Examples | def yaml_to_pandas(filename: str) -> Tuple[pd.DataFrame, Optional[str]]:
# Read the yaml file
with open(filename, 'r') as f:
dict_ = yaml.load(f, Loader=yaml.SafeLoader)
project = dict_.pop("__project__", None)
# Convert the yaml dictionary into a dataframe
data: Dict[str, Dict[Tuple[Hashab... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_to_dataframe(\n filename: Union[Path, str],\n marker: str = \"---\",\n csv_options: Optional[Dict[str, Any]] = None,\n yaml_options: Optional[Dict[str, Any]] = None,\n) -> Tuple[DataFrame, Dict[str, Any]]:\n if DataFrame is None:\n raise ModuleNotFoundError(\n \"Module pan... | [
"0.6223266",
"0.6129303",
"0.6100554",
"0.60840815",
"0.6082889",
"0.5902778",
"0.5898788",
"0.5859711",
"0.5854862",
"0.5829673",
"0.5819154",
"0.58064884",
"0.58064884",
"0.5772481",
"0.5768575",
"0.57589835",
"0.5717933",
"0.5713953",
"0.5706922",
"0.5706922",
"0.5701406",... | 0.6970648 | 0 |
Returns the path for configuration data for all major platforms | def getConfigPath():
if sys.platform == 'linux':
configpath = os.path.normpath(os.path.expanduser('~/.config/phobos'))
elif sys.platform == 'darwin':
configpath = os.path.normpath(os.path.expanduser('~/Library/Application Support/phobos'))
elif sys.platform == 'win32':
configpath = o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def platform_config_dir():\n if POSIX: # nocover\n dpath_ = os.environ.get('XDG_CONFIG_HOME', '~/.config')\n elif DARWIN: # nocover\n dpath_ = '~/Library/Application Support'\n elif WIN32: # nocover\n dpath_ = os.environ.get('APPDATA', '~/AppData/Roaming')\n else: # nocover\n ... | [
"0.7201866",
"0.67362136",
"0.6644315",
"0.66377807",
"0.6636949",
"0.66022515",
"0.65694153",
"0.65639627",
"0.65615714",
"0.64916116",
"0.64902836",
"0.64741963",
"0.6470176",
"0.6469606",
"0.6384029",
"0.6373276",
"0.63566935",
"0.63498926",
"0.63385725",
"0.6334437",
"0.6... | 0.72742504 | 0 |
Returns the configuration path for userspecific blender data. | def getBlenderConfigPath(blenderversion):
if sys.platform == 'linux':
scriptspath = os.path.normpath(
os.path.expanduser('~/.config/blender/{0}/config'.format(blenderversion))
)
elif sys.platform == 'darwin':
scriptspath = os.path.normpath(
os.path.expanduser(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cfg_path(self):\n return self._cfg_path",
"def config_file_and_path():\n return str(rmfriend_dir() / 'config.cfg')",
"def configPath(self):\n return os.path.dirname(__file__)",
"def get_config_file_location():\n\n return './' + CONFIG_FILE_NAME",
"def get_data_path(name):\n js = ... | [
"0.72044575",
"0.6985214",
"0.6869317",
"0.68644977",
"0.67701125",
"0.6757046",
"0.67386943",
"0.6731083",
"0.66863096",
"0.66134137",
"0.6526606",
"0.650571",
"0.65033567",
"0.65007305",
"0.64274645",
"0.6427291",
"0.64223856",
"0.64209414",
"0.6402593",
"0.6392462",
"0.634... | 0.7370779 | 0 |
Calculate the area of each grid cell for a userprovided grid cell resolution. Area is in square meters, but resolution is given in decimal degrees. | def do_grid (resolution):
# Calculations needs to be in radians
lats = np.deg2rad(np.arange(-57,84, resolution))
r_sq = 6371000**2
n_lats = int(360./resolution)
area = r_sq*np.ones(n_lats)[:, None]*np.deg2rad(resolution)*(
np.sin(lats[1:]) - np.sin(lats[:-1]))
return area.T | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grid_area(ulon,ulat):\n R = 6371. * 1000. # radius of Earth in meters\n dlon = N.diff(ulon)\n dlat = N.diff(ulat)\n dx = N.outer(deg2rad * R * N.cos(deg2rad * ulat),dlon) # dx (meters)\n dy = 60. * 1852. * dlat # dy (meters)\n area = (dx[1:] + dx[:-1])... | [
"0.6939898",
"0.6827993",
"0.6783789",
"0.6774796",
"0.6750549",
"0.67404014",
"0.6659824",
"0.6657721",
"0.66374826",
"0.66325015",
"0.6627994",
"0.6614619",
"0.65675646",
"0.653298",
"0.6518739",
"0.64830256",
"0.6461933",
"0.6324823",
"0.63124484",
"0.6302911",
"0.6300791"... | 0.743558 | 0 |
This custom filter take a string as input with comma separated values. Note that the value here is already a list as it has been transformed by the BaseInFilter class. | def filter_names(self, qs, name, value):
return qs.filter(name__in=value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_(self, value):\n if isinstance(value, (str, text_type)):\n value = [value]\n return Filter(self, value, 'in')",
"def to_python(self, value):\n # Return an empty list if no input was given.\n if not value:\n return []\n return value.split(',')",
"d... | [
"0.7434211",
"0.64544165",
"0.63526255",
"0.6277826",
"0.61804974",
"0.6147383",
"0.61087376",
"0.5946269",
"0.5861053",
"0.58073354",
"0.5784654",
"0.5750738",
"0.5747868",
"0.57219",
"0.5701402",
"0.5690323",
"0.55717665",
"0.55665094",
"0.5539709",
"0.55298066",
"0.5491114... | 0.5347189 | 30 |
Returns a boolean indicating whether `bitmask` is enabled within the base attribute. | def __get__(self, obj, type=None):
return bool(getattr(obj, self.base_attr) & self.bitmask) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bitmask(self, bit):\r\n if (int((format(self.__bitmask__, '016b')[2:])[bit]) == 0):\r\n return True\r\n return False",
"def get_bitmask(self):\r\n return self.__bitmask__",
"def is_bit_mask(enumeration, potential_mask):\n if not isinstance(potential_mask, six.integer_types):\n ... | [
"0.6370673",
"0.60460484",
"0.5293593",
"0.51872855",
"0.51568425",
"0.50588435",
"0.4949427",
"0.49299628",
"0.49284515",
"0.48571622",
"0.48510534",
"0.48098966",
"0.48055518",
"0.48039997",
"0.4784679",
"0.4772266",
"0.47695738",
"0.4745472",
"0.4741142",
"0.47368795",
"0.... | 0.6028671 | 2 |
Handles the home route | def home():
# if session.get('username'):
# return redirect(url_for('categories'))
# else:
return render_template('home.html') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def go_home(request):\n\n url = request.route_url('home', _app_url=get_app_url(request))\n return HTTPFound(location=url)",
"def home(self, *args, **kwargs):\n pass",
"def home():\n logging.info('Entering route: HOME')\n\n logging.info('Rendering template: main.html')\n return render_temp... | [
"0.79052025",
"0.78745264",
"0.7848005",
"0.7505829",
"0.7453932",
"0.7407278",
"0.73913604",
"0.7381116",
"0.7372379",
"0.7372379",
"0.7320766",
"0.72788364",
"0.7265526",
"0.7234542",
"0.7204967",
"0.7204967",
"0.7204967",
"0.7204967",
"0.7204967",
"0.7204967",
"0.7204967",... | 0.6969318 | 67 |
Creates the book table in the Book database | def __init__(self, db):
self.connection = sqlite3.connect(db)
self.cursor = self.connection.cursor()
self.cursor.execute("CREATE TABLE IF NOT EXISTS Book (Id INTEGER PRIMARY KEY, \
Title TEXT, Author TEXT, Year INTEGER, ISBN INTEGER)")
self.connection.commit() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_books_table():\n try:\n print(\"Creating 'books' table..\")\n db.execute(\"CREATE TABLE books (\\\n id SERIAL PRIMARY KEY, \\\n isbn VARCHAR NOT NULL, \\\n title VARCHAR NOT NULL, \\\n author VARCHAR NOT NULL, \\\n year INTEGER NOT ... | [
"0.8391721",
"0.8073142",
"0.75710934",
"0.7502907",
"0.74889827",
"0.7375526",
"0.72876626",
"0.72835785",
"0.72679055",
"0.72471905",
"0.7243783",
"0.7243783",
"0.72309494",
"0.7198741",
"0.71855557",
"0.7175286",
"0.71568626",
"0.71470326",
"0.7044951",
"0.69564736",
"0.69... | 0.6404445 | 81 |
Continue getting updates until the regex finds a match in a message, then return the first capture group. | def __wait_for_regex(self, regex: str, cancellable: bool = False) -> Union[str, CancelSignal]:
log.debug("Waiting for a regex...")
while True:
# Get the next update
update = self.__receive_next_update()
# If a CancelSignal is received...
if isinstance(upda... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMatch(reMatch,group=0):\n if reMatch: return reMatch.group(group)\n else: return ''",
"def recvregex(self, regex):\n if isinstance(regex, str):\n regex = re.compile(regex)\n buf = ''\n match = None\n\n while not match:\n buf += d(self.recv(1))\n ... | [
"0.629262",
"0.62774885",
"0.6136326",
"0.61299783",
"0.6032749",
"0.6029412",
"0.59464234",
"0.5920094",
"0.57432276",
"0.57361436",
"0.5642497",
"0.56279725",
"0.5584992",
"0.55632395",
"0.5546507",
"0.5532469",
"0.54971576",
"0.5486865",
"0.54025245",
"0.53982574",
"0.5376... | 0.69942236 | 0 |
Calculate the average score associated with this Student. | def get_average(self) -> float:
return sum(self._scores) / len(self._scores) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAverage(self):\n return sum(self.scores) / len(self.scores)",
"def get_mean_score(rating_scores):\n return sum(rating_scores) / len(rating_scores)",
"def get_average(self):\n self.avg = math.floor((self.maths + self.phy + self.che) / 3, )\n self.assign_grade()\n return self.... | [
"0.79639894",
"0.73673606",
"0.7196625",
"0.71720856",
"0.7162906",
"0.71442413",
"0.70670134",
"0.7030095",
"0.7030095",
"0.6999512",
"0.69382113",
"0.69370216",
"0.6887286",
"0.68780196",
"0.6849795",
"0.6842055",
"0.6833306",
"0.6798177",
"0.6760756",
"0.6755839",
"0.67513... | 0.78896713 | 1 |
Determine the highest score associated with this Student. | def get_high_score(self) -> float:
return max(self._scores) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_score(self):\n return max(self._extract_set('score') or [0])",
"def max_score(self):\r\n max_score = None\r\n if self.check_if_done_and_scored():\r\n max_score = self._max_score\r\n return max_score",
"def max_score(self):\r\n return self.lcp.get_max_score(... | [
"0.83337474",
"0.8101874",
"0.8077302",
"0.7876038",
"0.77509063",
"0.76949257",
"0.7678623",
"0.7557908",
"0.75277",
"0.74828833",
"0.74728924",
"0.7361729",
"0.73598534",
"0.72938806",
"0.7234977",
"0.7211712",
"0.71563286",
"0.71198565",
"0.7111701",
"0.705322",
"0.6986172... | 0.7729899 | 5 |
Returns self < other. | def __lt__(self, other):
extremes = self._numerator * other.denominator()
means = other.numerator() * self._denominator
return extremes < means | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __lt__(self, other):\n return self <= other and self != other",
"def __lt__(self, other):\n return self <= other and self != other",
"def __lt__(self, other):\n return self <= other and not self >= other",
"def __lt__(self, other):\n return self.__cmp__(other) < 0",
"def __l... | [
"0.88831526",
"0.88831526",
"0.88809276",
"0.88266224",
"0.87825954",
"0.87616193",
"0.8735927",
"0.86838645",
"0.86838645",
"0.85984594",
"0.8593426",
"0.8587446",
"0.85867065",
"0.85752547",
"0.85608375",
"0.85526484",
"0.85441566",
"0.85100424",
"0.85084605",
"0.8507573",
... | 0.79021734 | 98 |
Returns self >= other. | def __ge__(self, other):
extremes = self._numerator * other.denominator()
means = other.numerator() * self._denominator
return extremes >= means | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ge__(self, other):\n return other <= self",
"def __gt__(self, other):\n return self >= other and self != other",
"def __gt__(self, other):\n return self >= other and self != other",
"def __gt__(self, other):\n return self >= other and not self <= other",
"def __gt__(self, ... | [
"0.8782747",
"0.8661218",
"0.8661218",
"0.8599558",
"0.8597423",
"0.85728633",
"0.85680884",
"0.85315",
"0.852308",
"0.85042644",
"0.84803677",
"0.84770334",
"0.84770334",
"0.8403545",
"0.8370605",
"0.8354243",
"0.8347908",
"0.8347908",
"0.8346253",
"0.832667",
"0.8312259",
... | 0.0 | -1 |
Tests self and other for equality. | def __eq__(self, other):
if self is other:
return True
elif not isinstance(other, Rational):
return False
else:
return self._numerator == other.numerator() and \
self._denominator == other.denominator() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return equal(self, other)",
"def __eq__(self, other):\n return self is other",
"def __eq__(self, other):\n return self is oth... | [
"0.88391733",
"0.88391733",
"0.88139397",
"0.86130553",
"0.86130553",
"0.855895",
"0.85263485",
"0.85263485",
"0.8492665",
"0.84854174",
"0.84620726",
"0.84174746",
"0.84174746",
"0.839733",
"0.839733",
"0.839733",
"0.83951354",
"0.837963",
"0.83764756",
"0.8330343",
"0.83218... | 0.0 | -1 |
Get one from the tensor. | def get_value(self, indices):
assert len(indices) == 3, indices
if self.model_tensor is None:
raise ValueError("Please set the tensor")
return self.model_tensor[indices[0], indices[1], indices[2]] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTensor(self):\n\t\treturn self.cur_tensor",
"def get_tensor(name):\n if name.rfind(':') == -1:\n name += ':0'\n return tf.get_default_graph().get_tensor_by_name(name)",
"def named_tensor(self, name):\n return self._tensor_name_to_result[name]",
"def scalar(val: torch.Tensor):\n retu... | [
"0.71460956",
"0.67891514",
"0.65588135",
"0.64748013",
"0.6413598",
"0.638628",
"0.63685715",
"0.62808436",
"0.62593913",
"0.6162621",
"0.615739",
"0.61546993",
"0.61231315",
"0.60698557",
"0.60295755",
"0.60068893",
"0.6005453",
"0.59869796",
"0.59539455",
"0.59465075",
"0.... | 0.6247127 | 9 |
Set value to the tensor. | def set_value(self, indices, val):
assert len(indices) == 3, indices
if self.model_tensor is None:
raise ValueError("Please set the tensor")
self.model_tensor[indices[0], indices[1], indices[2]] = val
return val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Update(self, value):\n self.SetValue(self.GetValue() + tf.cast(value, self.dtype))",
"def Update(self, value):\n self.SetValue(self.GetValue() + tf.cast(value, self.dtype))",
"def set_node_value(node: Node, value: np.ndarray):\n if node.type != 'Const':\n raise Exception('Can\\'t set value ... | [
"0.73305565",
"0.73305565",
"0.7164538",
"0.7106505",
"0.69294816",
"0.6863438",
"0.67309785",
"0.6588569",
"0.65452635",
"0.6523065",
"0.6523065",
"0.6513894",
"0.6425833",
"0.6411298",
"0.6411298",
"0.63991857",
"0.63785946",
"0.6368179",
"0.63664836",
"0.6361774",
"0.63610... | 0.76344925 | 0 |
Get the first identifier for the next month. | def _next_yymm_id(self, identifier: Identifier) -> Optional[Identifier]:
next_yymm_id = None
if identifier.year is not None and \
identifier.month is not None:
new_year = identifier.year
new_month = identifier.month + 1
new_num = 1
if new_m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_of_next_month(ref_date):\n year, month = add_months(ref_date.year, ref_date.month, 1)\n return type(ref_date)(year, month, 1)",
"def _next_id(self, identifier: Identifier) -> Optional['Identifier']:\n next_id = None\n if identifier.year is not None and \\\n identifier... | [
"0.71140623",
"0.70819384",
"0.65288323",
"0.64989054",
"0.64522034",
"0.6431146",
"0.6364784",
"0.63500136",
"0.63453865",
"0.62631005",
"0.6257072",
"0.6244404",
"0.6200054",
"0.6192637",
"0.6188998",
"0.6186235",
"0.6151943",
"0.61216503",
"0.61216503",
"0.61076903",
"0.60... | 0.74007684 | 0 |
Get the absolute path of this DocMetadata's source file. | def _get_source_path(self, docmeta: DocMetadata) -> Optional[str]:
identifier = docmeta.arxiv_identifier
version = docmeta.version
file_noex = identifier.filename
if not docmeta.is_latest:
parent_path = self._get_parent_path(identifier, version)
file_noex = f'{fil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def source_file_path(self) -> str:\n return self._source_file_path",
"def get_source_path(self):\n return self.source_path",
"def get_source_file(self):\n return self.get_attribute(\"source_file\")",
"def path(self) -> str:\n return self.src + \"/\"",
"def source(self) -> str | ... | [
"0.8547733",
"0.82610506",
"0.8053611",
"0.7574011",
"0.75686365",
"0.7461368",
"0.74287295",
"0.73307705",
"0.7301582",
"0.7259421",
"0.725329",
"0.7234538",
"0.7218298",
"0.7183691",
"0.7129371",
"0.7121566",
"0.710466",
"0.70831716",
"0.707813",
"0.70628047",
"0.6983357",
... | 0.7473641 | 5 |
Get the absolute parent path of the provided identifier. | def _get_parent_path(self, identifier: Identifier,
version: Optional[int] = None) -> str:
parent_path = os.path.join(
(self.latest_versions_path if not version
else self.original_versions_path),
('arxiv' if not identifier.is_old_id or identifier.arch... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_parent(self, id_) -> str:\n return list(self._nodes[id_]['parents'].keys())[0]",
"def parent_dir_path(path):\n return absolute_path(os.path.dirname(path))",
"def get_parent_id_from_trace_id():\n trace_id = get_trace_id()\n return trace_id.parent_id",
"def get_parent(path):\n\n # secu... | [
"0.74234164",
"0.7001471",
"0.698503",
"0.69271344",
"0.69162315",
"0.6713711",
"0.6697498",
"0.66670144",
"0.66431475",
"0.66178703",
"0.6597941",
"0.6594848",
"0.6549766",
"0.6548474",
"0.6538243",
"0.6464383",
"0.64623785",
"0.64418644",
"0.64418644",
"0.63819927",
"0.6351... | 0.7567351 | 0 |
Common util function that generates random string of desired length from set of letters and digits | def generate_key(length):
return ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(length)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def randomStringDigits(stringLength:int=4)->str:\n lettersAndDigits = string.ascii_letters + string.digits\n return ''.join(random.choice(lettersAndDigits) for i in range(stringLength))",
"def _generate_random_string(length: int):\n\tall_chars = string.ascii_letters + string.digits\n\treturn ''.join(random... | [
"0.81941396",
"0.8172787",
"0.814063",
"0.81391037",
"0.8110602",
"0.8100234",
"0.80905783",
"0.8060947",
"0.803296",
"0.8026487",
"0.8021553",
"0.8010257",
"0.80099964",
"0.80039036",
"0.79910237",
"0.79653245",
"0.7934098",
"0.7928981",
"0.7907178",
"0.79025376",
"0.7882018... | 0.767259 | 53 |
Returns a JSON response, transforming 'context' to make the payload. | def render_to_json_response(self, context, **response_kwargs):
return JsonResponse(
self.get_data(context),
**response_kwargs
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_to_response(self, context):\n return self.get_json_response(self.convert_context_to_json(context))",
"def render_to_response(self, context):\n\t\treturn self.get_json_response(self.convert_context_to_json(context))",
"def render_to_json_response(self, context, **response_kwargs):\n ret... | [
"0.7898263",
"0.7824009",
"0.76766837",
"0.76766837",
"0.7560496",
"0.75058556",
"0.73821956",
"0.73662317",
"0.7348336",
"0.7347456",
"0.7309291",
"0.7130906",
"0.6941217",
"0.6892298",
"0.6722085",
"0.663044",
"0.663044",
"0.663044",
"0.663044",
"0.6624278",
"0.66101027",
... | 0.74115 | 9 |
Gets the label/shape field from example as a list of int64. | def get_label_shape_from_example(example):
assert len(example.features.feature['label/shape'].int64_list.value) == 1
return example.features.feature['label/shape'].int64_list.value[:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def label_from_example(example):\n val = example.features.feature['label'].int64_list.value\n if val:\n return int(val[0])\n else:\n return None",
"def provide_label(self):\n return [(k, v.shape) for k, v in self.label]",
"def provide_label(self):\r\n return [(k, tuple([1] + list(v.shape... | [
"0.679036",
"0.6569586",
"0.62951785",
"0.6134868",
"0.6108419",
"0.59921026",
"0.59756845",
"0.5952071",
"0.5952071",
"0.59401375",
"0.58788294",
"0.5849895",
"0.5831298",
"0.5816761",
"0.5816761",
"0.5807753",
"0.5801871",
"0.5795513",
"0.5795513",
"0.5795513",
"0.5794914",... | 0.74587005 | 0 |
Returns tf.Example created from the given DeepConsensusInput proto. | def deepconsensus_input_to_example(
deepconsensus_input: deepconsensus_pb2.DeepConsensusInput,
example_height: int,
inference: bool,
counters: Optional[Dict[str, metrics.Metrics.counter]] = None,
) -> Optional[tf.train.Example]:
if not deepconsensus_input.subreads:
if counters and counters['exampl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_encoded_deepconsensus_input_from_example(example):\n return example.features.feature[\n 'deepconsensus_input/encoded'].bytes_list.value[0]",
"def _create_example(self):\n source = np.random.randn(self.batch_size, self.max_decode_length,\n self.input_depth)\n source... | [
"0.6588792",
"0.5950223",
"0.58684516",
"0.5803522",
"0.5487936",
"0.5469294",
"0.5404084",
"0.5355273",
"0.527753",
"0.51956975",
"0.5192631",
"0.51771414",
"0.516648",
"0.51630205",
"0.51613873",
"0.51525664",
"0.5150702",
"0.5136441",
"0.51273745",
"0.5113387",
"0.511311",... | 0.70847815 | 0 |
Gets the donor_participant of this AllOfCreateClaimResponseClaim. | def donor_participant(self) -> Object:
return self._donor_participant | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def donor_participant(self, donor_participant: Object):\n\n self._donor_participant = donor_participant",
"def participant(self) -> AllOfCancelClaimRequestParticipant:\n return self._participant",
"def participant(self) -> AllOfAcknowledgeClaimRequestParticipant:\n return self._participant... | [
"0.64143723",
"0.62174505",
"0.5898315",
"0.50857437",
"0.49990976",
"0.48347864",
"0.48060545",
"0.46557683",
"0.45774764",
"0.45774764",
"0.45192257",
"0.4476471",
"0.44539085",
"0.4446725",
"0.4414176",
"0.43843213",
"0.43202215",
"0.43045747",
"0.42562267",
"0.42562267",
... | 0.7721172 | 0 |
Gets the id of this AllOfCreateClaimResponseClaim. | def id(self) -> str:
return self._id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def claim_id(self) -> str:\n return self._claim_id",
"def claim_id(self) -> str:\n return self._claim_id",
"def post(self):\n dao = ClaimDao()\n return dao.create(api.payload)",
"def participant(self) -> AllOfAcknowledgeClaimRequestParticipant:\n return self._participant",
... | [
"0.64186335",
"0.64186335",
"0.56785434",
"0.5100735",
"0.5089649",
"0.49505824",
"0.4929038",
"0.478927",
"0.47847793",
"0.4719559",
"0.46991652",
"0.46991652",
"0.46991652",
"0.46991652",
"0.46991652",
"0.46991652",
"0.46991652",
"0.46991652",
"0.46991652",
"0.46991652",
"0... | 0.0 | -1 |
Sets the id of this AllOfCreateClaimResponseClaim. | def id(self, id: str):
if id is None:
raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501
self._id = id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_id(self, id):\n self.data['id'] = id",
"def id(self, _id):\n self.metadata[\"id\"] = _id",
"def set_id(self, id):\n self.__id = id",
"def set_id(self, id_):\n\n self.id_ = id_",
"def claim_id(self, claim_id: str):\n if claim_id is None:\n raise ValueErr... | [
"0.54797524",
"0.54327804",
"0.5338967",
"0.53236276",
"0.529317",
"0.529317",
"0.5160128",
"0.5160128",
"0.5160128",
"0.5160128",
"0.5160128",
"0.5097142",
"0.5097142",
"0.5097142",
"0.5097142",
"0.5097142",
"0.5097142",
"0.5097142",
"0.5097142",
"0.5097142",
"0.5097142",
... | 0.0 | -1 |
Gets the status of this AllOfCreateClaimResponseClaim. | def status(self) -> str:
return self._status | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status(self):\n props = self.properties\n if props:\n if props.get('created'):\n return CREATED_STATUS",
"def post(self):\n dao = ClaimDao()\n return dao.create(api.payload)",
"def create(self):\n return (True == self.client.put(self.name).getBodyD... | [
"0.572883",
"0.55275935",
"0.54706526",
"0.52699614",
"0.5234164",
"0.5156991",
"0.48911265",
"0.48664638",
"0.48566645",
"0.4801761",
"0.48016563",
"0.47769982",
"0.47740877",
"0.47602236",
"0.47471672",
"0.47409746",
"0.47378886",
"0.4730465",
"0.47272745",
"0.47255358",
"0... | 0.0 | -1 |
Split the dataset with train_percentage | def split_dataset(dataset, train_percentage, feature_headers, target_header):
# Split dataset into train and test dataset
train_x, test_x, train_y, test_y = train_test_split(dataset[feature_headers], dataset[target_header],train_size=train_percentage)
return train_x, test_x, train_y, test_y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_train_test_by_percentage(dataset, train_percentage=0.8):\n train_length = int(len(dataset) * train_percentage)\n return torch.utils.data.random_split(dataset, (train_length, len(dataset) - train_length))",
"def split_dataset(dataset, train_percentage, valid_percentage):\n\n # Split dataset int... | [
"0.8460871",
"0.8151334",
"0.7983524",
"0.7791796",
"0.76440144",
"0.7603226",
"0.7581921",
"0.7538712",
"0.7538712",
"0.7535976",
"0.7356462",
"0.7356462",
"0.72785723",
"0.72672325",
"0.7246208",
"0.7207059",
"0.71712476",
"0.7159764",
"0.7064658",
"0.7043388",
"0.7031485",... | 0.769264 | 4 |
Returns a list of all a project's components. | def components(accountable, project_key):
components = accountable.project_components(project_key)
headers = sorted(['id', 'name', 'self'])
rows = [[v for k, v in sorted(component.items()) if k in headers]
for component in components]
rows.insert(0, headers)
print_table(SingleTable(rows)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_projects():\n if '.wcscanner' not in os.listdir(context.__BASE_PATH__):\n return []\n return os.listdir(context.__PROJECTS_PATH__)",
"def get_projects(self):\n unaligned_path = self.get_unaligned_path()\n logger.debug(\"collecting list of projects\")\n return [p for p i... | [
"0.7027259",
"0.68796676",
"0.6818949",
"0.6719623",
"0.67192936",
"0.6683855",
"0.66704535",
"0.66671795",
"0.66467714",
"0.6640229",
"0.65798545",
"0.6556899",
"0.65495473",
"0.65493363",
"0.65490365",
"0.6516722",
"0.6468194",
"0.64657927",
"0.64543396",
"0.64378566",
"0.6... | 0.63358796 | 31 |
Unload a config entry. | async def async_unload_entry(opp: OpenPeerPower, entry: ConfigEntry) -> bool:
return await opp.config_entries.async_unload_platforms(entry, PLATFORMS) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def async_unload_entry(hass, config_entry):\n unload_ok = await hass.config_entries.async_forward_entry_unload(\n config_entry, \"climate\"\n )\n return unload_ok",
"async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:\n hass.data.pop(DOMAIN)\n return True",
... | [
"0.697284",
"0.6888074",
"0.6779855",
"0.6747459",
"0.6689002",
"0.6657831",
"0.66162205",
"0.6603433",
"0.65925974",
"0.65595686",
"0.65411645",
"0.6507643",
"0.6507643",
"0.6507643",
"0.6507643",
"0.64977276",
"0.64931643",
"0.6486601",
"0.6486601",
"0.6486601",
"0.6486601"... | 0.58642447 | 78 |
returns the number of combinations of size k that can be made from n items. >>> nchoosek(5,3) 10 >>> nchoosek(1,1) 1 >>> nchoosek(4,2) 6 | def nchoosek(n, k):
if (n, k) in known:
return known[(n,k)]
if k == 0:
return 1
if n == k:
return 1
if n < k:
return "n must be greater than k"
result = nchoosek(n - 1, k - 1) + nchoosek(n - 1, k)
known[(n,k)] = result
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nchoosek(n, k):\n if n < k:\n return 0\n return partition(n, [k, n - k])",
"def n_choose_k(N,K):\n return factorial(N) // (factorial(N - K) * factorial(K))",
"def n_choose_k(n: int, k: int) -> int:\n # Edge case, no possible way to choose.\n if k > n or k < 0 or n < 0: return 0\n #... | [
"0.8256239",
"0.7943082",
"0.77849466",
"0.77155447",
"0.75553346",
"0.75553226",
"0.7516673",
"0.7516673",
"0.7516148",
"0.74694544",
"0.73904",
"0.7390276",
"0.7361454",
"0.72738117",
"0.72258496",
"0.7099127",
"0.7037198",
"0.7019336",
"0.70099944",
"0.7001311",
"0.6997127... | 0.7859963 | 2 |
Return the source type, eg gps or router, of the device. | def source_type(self) -> SourceType:
return SourceType.ROUTER | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def source_type(self):\n return SOURCE_TYPE_GPS",
"def source_type(self):\n return SOURCE_TYPE_GPS",
"def source_type(self):\n return SOURCE_TYPE_ROUTER",
"def source_type(self):\n return SOURCE_TYPE_ROUTER",
"def source_type(self) -> Optional[str]:\n return pulumi.get(se... | [
"0.79885626",
"0.79885626",
"0.7760277",
"0.7760277",
"0.7449024",
"0.72812986",
"0.71759343",
"0.66198623",
"0.6579725",
"0.64343446",
"0.6371079",
"0.62237245",
"0.6218695",
"0.6187604",
"0.6182113",
"0.61786586",
"0.61733663",
"0.61695445",
"0.6154849",
"0.6086145",
"0.608... | 0.7750512 | 5 |
Return True if currency_code valid, False otherwise. | def validateCurrency(self, currency_code):
if currency_code in self.travel_db.currencies:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_currency(currency_code):\n try:\n rate = rates.get_rates(currency_code)\n return 0\n except:\n flash(f'Error: {currency_code} is not a valid currency')\n return 1",
"def _is_valid_code(self, code):\r\n return code in COUNTRY_CODES",
"def is_valid(postal_cod... | [
"0.759342",
"0.70800674",
"0.6537341",
"0.62727094",
"0.62223756",
"0.619591",
"0.6130835",
"0.60933155",
"0.6079185",
"0.6059149",
"0.6046414",
"0.60261106",
"0.5977034",
"0.59302557",
"0.5910405",
"0.5875142",
"0.5865183",
"0.5845647",
"0.5834872",
"0.57638985",
"0.57544607... | 0.85613906 | 0 |
Check if a project/subject/session identifier is valid. Identifiers can only contain alphanumeric characters and underscores. | def _validate_identifier(self, identifier):
for c in identifier:
if c not in string.letters + string.digits + '_':
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def IsProjectIDValid(project):\n if len(project) < 6 or len(project) > 30:\n return False\n return bool(re.match('^[a-z][a-z0-9\\\\-]*[a-z0-9]$', project))",
"def IsValidIdentifier(string):\n counter = 0\n if string in keyword.kwlist:\n feedback = (False, \"Invalid: can't use a keyword as your ... | [
"0.7817043",
"0.7263203",
"0.71657807",
"0.6915533",
"0.6915533",
"0.6901704",
"0.68005633",
"0.6792642",
"0.67050254",
"0.6685971",
"0.6454717",
"0.64318484",
"0.6427234",
"0.64037365",
"0.6375381",
"0.6367689",
"0.6350279",
"0.6343211",
"0.6312446",
"0.63092995",
"0.6287927... | 0.7744844 | 1 |
Converts string to URL compatible. | def make_url_compatible(category: str) -> str:
return urllib.parse.quote(category) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text_to_url(self, text):\r\n return QUrl(text)",
"def url(value: Any) -> str:\n url_in = str(value)\n\n if urlparse(url_in).scheme in [\"http\", \"https\"]:\n return cast(str, vol.Schema(vol.Url())(url_in))\n\n raise vol.Invalid(\"Invalid URL\")",
"def url_fix(s, charset='utf-8'):\n ... | [
"0.6706412",
"0.6616591",
"0.6346535",
"0.63381904",
"0.6220913",
"0.6202903",
"0.6197797",
"0.6176937",
"0.6167852",
"0.6164724",
"0.61420554",
"0.61230433",
"0.6118814",
"0.61146235",
"0.6109616",
"0.60942715",
"0.60720885",
"0.6057571",
"0.6017928",
"0.59949386",
"0.595964... | 0.5838849 | 35 |
Get most likely categorical variables (onehot) | def get_most_likely(self):
c_cat = self.theta.argmax(axis=1)
T = np.zeros((self.d, self.max))
for i, c in enumerate(c_cat):
T[i, c] = 1
return T | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unhot(one_hot_labels):\n return np.argmax(one_hot_labels, axis=1)",
"def infer_categorical_variables_in_place(df: pd.DataFrame):\n # infer which variables are categorical\n MAX_UNIQUE_VALUES = 10\n for column in df.columns:\n if df[column].nunique() <= MAX_UNIQUE_VALUES:\n df[co... | [
"0.7186164",
"0.71264297",
"0.700594",
"0.6770333",
"0.66180325",
"0.6554686",
"0.65422523",
"0.6527132",
"0.6494277",
"0.6475236",
"0.64435905",
"0.64244854",
"0.64193946",
"0.64063036",
"0.6401098",
"0.63921547",
"0.63824326",
"0.63524544",
"0.63380814",
"0.6334604",
"0.632... | 0.0 | -1 |
Returns a list of field names that should have their last used values persisted on a perproject basis. | def get_persisted_default_config_fields(self):
return [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stored_field_names(self):\r\n \r\n bn = self._by_name\r\n return [name for name in self._names if bn[name].stored]",
"def get_fieldnames(self):\n fieldnames = self._fields.keys()\n fieldnames.remove('time')\n fieldnames.remove('lon')\n fieldnames.remove('lat')... | [
"0.7186901",
"0.66612464",
"0.6604475",
"0.64602005",
"0.6406558",
"0.6403274",
"0.63492525",
"0.63447577",
"0.63416326",
"0.6341628",
"0.6330346",
"0.63049877",
"0.6242699",
"0.6180476",
"0.615603",
"0.61414677",
"0.6139766",
"0.6136323",
"0.6128718",
"0.611067",
"0.61068535... | 0.543067 | 87 |
Returns the display name of the issue. This is not required but helpful for integrations whose external issue key does not match the disired display name. | def get_issue_display_name(self, external_issue):
return '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_name(self) -> Optional[str]:\n return pulumi.get(self, \"display_name\")",
"def display_name(self) -> Optional[str]:\n return pulumi.get(self, \"display_name\")",
"def display_name(self) -> Optional[str]:\n return pulumi.get(self, \"display_name\")",
"def display_name(self) -... | [
"0.71604306",
"0.71604306",
"0.71604306",
"0.7145177",
"0.7145177",
"0.7145177",
"0.7145177",
"0.7145177",
"0.7145177",
"0.7145177",
"0.7145177",
"0.7145177",
"0.7145177",
"0.7145177",
"0.7145177",
"0.70821923",
"0.69916433",
"0.69874066",
"0.69397634",
"0.69397634",
"0.69397... | 0.8553241 | 0 |
return the current position in axis y | def get_pos_y(self):
return self.__pos_y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_y(self):\n return self.position.y",
"def get_y_position(self):\n return self.actual_coordinates[1]",
"def get_y(self):\n return self.coords[1]",
"def y(self):\r\n return self.position.y",
"def get_axis_y(self):\r\n return self.__y_axis",
"def getY(self):\n r... | [
"0.8298365",
"0.819705",
"0.8127928",
"0.8116509",
"0.80807966",
"0.8054",
"0.80265415",
"0.80205864",
"0.80196774",
"0.79003936",
"0.7895202",
"0.7861297",
"0.78577423",
"0.78577423",
"0.77969265",
"0.7770738",
"0.77373946",
"0.7711272",
"0.7710626",
"0.76898646",
"0.7657803... | 0.8150986 | 2 |
Return an empty RequiredParameters object. | def _required_parameters(self) -> RequiredParameters:
return RequiredParameters([]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_required_params():\n return {}",
"def get_empty_required_fields(self):\n empty_fields = self.get_empty_fields()\n return [f for f in empty_fields if f in self.REQUIRED_FIELDS]",
"def get_required_parameters(self) -> list:\n results = []\n if self.no_params or self.par... | [
"0.7562365",
"0.6865271",
"0.6684548",
"0.6580648",
"0.642038",
"0.6418872",
"0.63192177",
"0.6319068",
"0.6306489",
"0.6298723",
"0.623854",
"0.62329423",
"0.6214493",
"0.61800486",
"0.61040115",
"0.6102065",
"0.6099858",
"0.6063706",
"0.60514194",
"0.6025997",
"0.6002806",
... | 0.86397606 | 0 |
Return an empty RequiredParameters object. | def _required_parameters(self) -> RequiredParameters:
return RequiredParameters([]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_required_params():\n return {}",
"def get_empty_required_fields(self):\n empty_fields = self.get_empty_fields()\n return [f for f in empty_fields if f in self.REQUIRED_FIELDS]",
"def get_required_parameters(self) -> list:\n results = []\n if self.no_params or self.par... | [
"0.7562365",
"0.6865271",
"0.6684548",
"0.6580648",
"0.642038",
"0.6418872",
"0.63192177",
"0.6319068",
"0.6306489",
"0.6298723",
"0.623854",
"0.62329423",
"0.6214493",
"0.61800486",
"0.61040115",
"0.6102065",
"0.6099858",
"0.6063706",
"0.60514194",
"0.6025997",
"0.6002806",
... | 0.86397606 | 1 |
Split string by upper case letters. F.e. useful to convert camel case strings to underscore separated ones. words (list) | def camel_case_to_lower_case_underscore(string):
words = []
from_char_position = 0
for current_char_position, char in enumerate(string):
if char.isupper() and from_char_position < current_char_position:
words.append(
string[from_char_position:current_char_position].lower(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_uppercase(word):\r\n final_word = ''\r\n for i in word:\r\n final_word += ' %s' % i if i.isupper() else i\r\n\r\n return final_word.strip()",
"def camelCaseSplit(text):\n matches = re.finditer('.+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)', text)\n return [m.group(0) for ... | [
"0.7751512",
"0.7259431",
"0.7180602",
"0.7063711",
"0.70595056",
"0.70409745",
"0.69426405",
"0.6801742",
"0.67717946",
"0.6744924",
"0.67325515",
"0.6694427",
"0.6669808",
"0.6653575",
"0.6632303",
"0.66086304",
"0.66041285",
"0.66029406",
"0.65299785",
"0.65299785",
"0.649... | 0.63527435 | 28 |
Siftup the last node (end1) in the given max heap. | def sift_up(heap, start, end):
# Swap last node with parents until no longer greater.
i = end - 1
heaped = False
while i > start and not heaped:
parent = (i - 1) // 2
if compare(heap[i], heap[parent]) > 0:
heap[i], heap[parent] = heap[parent], heap[i]
i = parent
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sift_down(heap, start, end):\n # Swap first node with children until no longer smaller.\n i = start\n heaped = False\n while not heaped:\n left = i * 2 + 1\n right = i * 2 + 2\n largest = i\n\n # Find largest of i, left and right\n if left < end and compare(heap[l... | [
"0.71801686",
"0.7001086",
"0.6813224",
"0.65404683",
"0.6508815",
"0.6496566",
"0.6474151",
"0.63565713",
"0.63440263",
"0.6343961",
"0.6335834",
"0.63289756",
"0.63112545",
"0.6272625",
"0.62513417",
"0.6242469",
"0.6241716",
"0.61991626",
"0.6170931",
"0.6164732",
"0.61421... | 0.73906344 | 0 |
Reorder a given array into a max heap. | def heapify(array):
# Start by sifting down the first parent node
n = len(array)
node = (n - 2) // 2
# Sift down all nodes, finishing with the root
while node >= 0:
sift_down(array, node, n)
node -= 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def heap_sort(array):\n highest_index = len(array)-1\n Heap.heapify(array, highest_index)\n for end in range(highest_index, 0, -1):\n array[end], array[0] = array[0], array[end]\n Heap.sift_down(array, 0, end-1)",
"def heapify(array, highest_index):\n first = (hi... | [
"0.7620014",
"0.7408683",
"0.7295518",
"0.7191452",
"0.7178755",
"0.71406955",
"0.7130052",
"0.70784956",
"0.70300376",
"0.6989501",
"0.69802624",
"0.6953432",
"0.6950196",
"0.6909327",
"0.69041264",
"0.68877125",
"0.68816626",
"0.6856917",
"0.6704577",
"0.66487557",
"0.66159... | 0.69547015 | 11 |
Initalize name and age attibutes. | def __init__(self, name, age):
self.name = name
self.age = age | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, first_name, last_name, age):\n self.first_name = first_name\n self.last_name = last_name\n self.age = age",
"def __init__(self, first_name, last_name, age):\n self.first_name = first_name\n self.last_name = last_name\n self.age = age",
"def __init__(... | [
"0.74732316",
"0.74732316",
"0.74732316",
"0.74732316",
"0.74732316",
"0.74732316",
"0.74732316",
"0.74732316",
"0.7472384",
"0.736729",
"0.7351724",
"0.7351724",
"0.7351724",
"0.7351724",
"0.72921795",
"0.7189177",
"0.7124933",
"0.711583",
"0.6997387",
"0.6881059",
"0.686831... | 0.75609356 | 1 |
Reduce product of x. | def product(x):
return functools.reduce(lambda x, y: x * y, x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prod(x):\n return functools.reduce(lambda a, b: a * b, x, 1)",
"def prod(self, x, y):\n return self.reduce(x + y)",
"def prod(l):\n return reduce(lambda a, b: a*b, l)",
"def prod(lst):\n return reduce(mul, lst, 1)",
"def _prod(seq):\n return reduce(lambda x, y: x*y, seq, 1)",
"def ... | [
"0.8485899",
"0.75339127",
"0.71145695",
"0.70959675",
"0.7030964",
"0.70278287",
"0.70278287",
"0.70278287",
"0.7009414",
"0.69021314",
"0.6851268",
"0.6762479",
"0.6750255",
"0.67320514",
"0.6707632",
"0.66387403",
"0.6615138",
"0.6581234",
"0.6580697",
"0.65709585",
"0.656... | 0.8354631 | 1 |
Pad or truncate a list `x` with the values `pad_value` and `maxlen`. | def list_pad_or_truncate(x, maxlen, pad_value=None):
length = len(x)
if maxlen > length:
x += [pad_value] * (maxlen - length)
elif maxlen < length:
x = x[:maxlen]
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad_with_zero(list, max_length, pad_type):\n padded_list = pad_sequences(list, maxlen=max_length, padding=pad_type, truncating='post')\n return padded_list",
"def pad_tokens(x, max_length, pad_token_id,\n truncate_from=\"left\",\n pad_from=\"left\"):\n assert truncate_fro... | [
"0.7232516",
"0.7194974",
"0.70571303",
"0.7005884",
"0.69063616",
"0.69063616",
"0.6899334",
"0.68993306",
"0.68805975",
"0.68804926",
"0.68802965",
"0.6851657",
"0.6702354",
"0.66523",
"0.6640961",
"0.65956634",
"0.65647626",
"0.65528095",
"0.6521586",
"0.6515963",
"0.64783... | 0.8817511 | 0 |
Process all examples in the input directory. Filenames should be of the form CLASSNAMEEXAMPLENAME.yaml E.g Person001.yaml | def process_examples(self):
input_dir = self.input_directory
counter_example_dir = self.counter_example_input_directory
if input_dir is None:
input_dir = Path.cwd() / "examples"
if counter_example_dir is None:
counter_example_dir = Path.cwd() / "counter_examples"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_yamls(folder):\n for item in iglob(folder + \"/*.yaml\"):\n data_file = os.path.join(folder, item)\n data = yaml.load(open(data_file))\n load_data(data)",
"def generate_yaml_tests(directory):\n for yml_file in directory.glob(\"*/*.yml\"):\n data = yaml.safe_load(yml_... | [
"0.6632809",
"0.62900645",
"0.62750703",
"0.61933035",
"0.6179182",
"0.6156422",
"0.60064507",
"0.5971663",
"0.5965593",
"0.5941546",
"0.59226394",
"0.59129375",
"0.5911364",
"0.58914095",
"0.58837914",
"0.58785766",
"0.5834951",
"0.583384",
"0.5827961",
"0.58051383",
"0.5797... | 0.74208486 | 0 |
Get the list of example source inputs. | def example_source_inputs(self, class_name: str = None) -> List[str]:
input_dir = self.input_directory
if input_dir is None:
return []
all_inputs = []
for fmt in self.input_formats:
glob_expr = f"*.{fmt}"
if class_name is not None:
glob... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_train_inputs(self, example):\n return example",
"def inputs(self) -> List[str]:\n return self._model.inputs",
"def get_inputs(self):\n return self.inputs",
"def prepare_inputs(example):\n return example['input_ids'], example['label_ids']",
"def prepare_inputs(example):\n ... | [
"0.7428947",
"0.7054078",
"0.6997518",
"0.6961838",
"0.6961838",
"0.6924607",
"0.6878051",
"0.6812642",
"0.6788958",
"0.6788958",
"0.6788958",
"0.6773123",
"0.6742478",
"0.67293483",
"0.67270637",
"0.6706153",
"0.6706153",
"0.6660394",
"0.6660394",
"0.6660394",
"0.66560566",
... | 0.7485938 | 0 |
Load an object from a dict, using the target class to determine the type of object to create. | def _load_from_dict(self, dict_obj: Any, target_class: Union[str, ElementName] = None) -> Any:
if not self.use_type_designators:
return dict_obj
sv = self.schemaview
if target_class is None:
target_class_names = [c.name for c in sv.all_classes().values() if c.tree_root]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_obj_by_type_from_dict(self):\n test_obj = {}\n returned_obj = self.tested_class._create_obj_by_type(test_obj)\n self.assertIsInstance(returned_obj, self.tested_class)",
"def from_dict(cls, obj):\r\n raise NotImplementedError",
"def load(d):\n\n def _load(d):\n ... | [
"0.70920396",
"0.6989815",
"0.6780296",
"0.6534313",
"0.65280795",
"0.650231",
"0.64138657",
"0.6346336",
"0.625308",
"0.62314886",
"0.62314886",
"0.62314886",
"0.62314886",
"0.62314886",
"0.62314886",
"0.62314886",
"0.62314886",
"0.62314886",
"0.62314886",
"0.62314886",
"0.6... | 0.7511082 | 0 |
Clones layer_op with input_tensor and weight_tensor as new inputs. | def _CloneWithNewOperands(layer_op, input_tensor, weight_tensor):
new_layer_name = layer_op.name.split('/')[-1] + '_Fold'
if layer_op.type == 'Conv2D':
return nn_ops.conv2d(
input_tensor,
weight_tensor,
strides=layer_op.get_attr('strides'),
padding=layer_op.get_attr('padding'),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _CloneOp(op, new_name, new_inputs):\n inputs = list(op.inputs)\n for new_input in new_inputs:\n inputs[new_input[0]] = new_input[1]\n return _OP_CLONER.Clone(op, inputs, new_name)",
"def build(self, input_layer, trainable=True):\n\n with tf.variable_scope(self.name):\n # Determine the size... | [
"0.62645614",
"0.6237233",
"0.6156408",
"0.61453366",
"0.5968321",
"0.58285654",
"0.5824187",
"0.58094114",
"0.58049345",
"0.5748741",
"0.5666261",
"0.5660313",
"0.5655159",
"0.5610911",
"0.5606715",
"0.55708444",
"0.55697495",
"0.5538788",
"0.5504511",
"0.547193",
"0.5451717... | 0.7447388 | 0 |
Gets tensors needed for FusedBatchNormMatch from match_result. | def _GetCommonTensors(match_result, bn_op, bn_input_tensor):
input_tensor = match_result.get_tensor(input_pattern)
weight_tensor = match_result.get_tensor(weight_pattern)
gamma_tensor = match_result.get_tensor(gamma_pattern)
beta_tensor = match_result.get_tensor(beta_pattern)
# FusedBatchNorm in tra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _FindFusedBatchNorms(graph):\n input_pattern = graph_matcher.OpTypePattern('*')\n weight_pattern = graph_matcher.OpTypePattern('*')\n gamma_pattern = graph_matcher.OpTypePattern('*')\n beta_pattern = graph_matcher.OpTypePattern('*')\n mean_pattern = graph_matcher.OpTypePattern('*')\n variance_pattern = g... | [
"0.687296",
"0.53285825",
"0.52761436",
"0.526731",
"0.52641547",
"0.52601016",
"0.52112883",
"0.5158161",
"0.51153666",
"0.51105905",
"0.5093035",
"0.5083832",
"0.5050526",
"0.50354075",
"0.50354075",
"0.50307226",
"0.50050557",
"0.49959216",
"0.49791405",
"0.49321866",
"0.4... | 0.6739167 | 1 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, FtsSftpSettings):
return False
return self.to_dict() == other.to_dict() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
if not isinstance(other, FtsSftpSettings):
return True
return self.to_dict() != other.to_dict() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
... | 0.0 | -1 |
Return a list of fitting parameters. | def _fit_params(cls) -> List[str]:
fsigs = set()
for series_def in cls.__series__:
fsigs.add(inspect.signature(series_def.fit_func))
if len(fsigs) > 1:
raise AnalysisError(
"Fit functions specified in the series definition have "
"different... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_fitted_params(self):\n self.check_is_fitted()\n return {\n name: self._fitted_forecaster.params.get(name)\n for name in self._get_fitted_param_names()\n }",
"def _get_fitted_param_names(self):\n return self._fitted_param_names",
"def get_random_fit_para... | [
"0.7828273",
"0.77081746",
"0.76167715",
"0.7338232",
"0.7242317",
"0.7235081",
"0.7188947",
"0.71217304",
"0.70609885",
"0.7037319",
"0.70190436",
"0.69019854",
"0.68696225",
"0.68649846",
"0.68517315",
"0.6831097",
"0.68142086",
"0.6786738",
"0.6786738",
"0.67717886",
"0.67... | 0.76450473 | 2 |
Return type of experiment. | def _experiment_type(self) -> str:
try:
return self.__experiment_metadata["experiment_type"]
except (TypeError, KeyError):
# Ignore experiment metadata is not set or key is not found
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def experiment_type(filename):\n assert(isinstance(filename, str))\n exp_type = filename.split('/')[-1].split('.')[-2].split('_')[1:-1]\n exp_type = '_'.join(exp_type)\n logger.debug('{} is of type {}'.format(filename, exp_type))\n return exp_type",
"def get_test_type(self):\n return self.t... | [
"0.701162",
"0.69926196",
"0.6970925",
"0.6970925",
"0.6970925",
"0.6970925",
"0.6970925",
"0.6970925",
"0.6970925",
"0.6970925",
"0.6970925",
"0.6970925",
"0.6970925",
"0.6970925",
"0.6970925",
"0.6970925",
"0.6970925",
"0.6970925",
"0.6970925",
"0.6970925",
"0.6970925",
"... | 0.8181823 | 0 |
Interface to Dark Sky API. Requests data from Boston Airport for a specific time. | def ping_darksky(time, key):
boston = forecast(key, *BOSTON, time=time.isoformat())
fetch = {
'day': time,
'tempMin': boston["daily"]["data"][0].get('temperatureMin', np.nan),
'tempMax': boston["daily"]["data"][0].get('temperatureMax', np.nan),
'summary': boston["daily"]["data"]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_flights(self, time_start, time_end, limit=None):\n\n t_start = parser.parse(str(time_start))\n t_end = parser.parse(str(time_end))\n string_start = t_start.strftime(timestring_traffic)\n string_end = t_end.strftime(timestring_traffic)\n\n logger.info(\"Downloading fl... | [
"0.62457645",
"0.59939075",
"0.58592993",
"0.5772396",
"0.5735043",
"0.5696683",
"0.5681655",
"0.562768",
"0.5607731",
"0.55556893",
"0.5517979",
"0.54691505",
"0.54423225",
"0.53862786",
"0.5370203",
"0.5335187",
"0.53251284",
"0.5310476",
"0.52809924",
"0.5272097",
"0.52525... | 0.59688425 | 2 |
Escapes any characters that would be invalid in an ansible group name. | def to_safe(self, word):
return re.sub("[^A-Za-z0-9\-]", "_", word) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Escape(name):\n return re.sub(r'[^\\w#-]', '_', name)",
"def validate_group_name(self, key, value):\n if len(value.split(':')) != 2:\n raise AssertionError('group_name {} is not prefixed'.format(value))\n return value",
"def escape_env_var(varname: str) -> str:\n varletters = l... | [
"0.68663985",
"0.59834987",
"0.58701265",
"0.57611465",
"0.5732694",
"0.571592",
"0.5629738",
"0.55753237",
"0.5558366",
"0.5516642",
"0.55165267",
"0.54932815",
"0.5471602",
"0.5458619",
"0.5414491",
"0.5395632",
"0.5392031",
"0.5369823",
"0.5364962",
"0.5322491",
"0.5320037... | 0.507992 | 40 |
Converts a dict to a JSON object and dumps it as a formatted string. | def json_format_dict(self, data, pretty=False):
if pretty:
return json.dumps(data, sort_keys=True, indent=2)
else:
return json.dumps(data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dict_to_beautified_json(d):\n return jsbeautifier.beautify(json.dumps(d))",
"def format_dictionary(dct, indent=4):\n return json.dumps(dct, indent=indent, sort_keys=True)",
"def serialize_dict(d):\n txt = '{'\n for k in d:\n txt += f'\"{k}\":'\n if isinstance(d[k], dict):\n ... | [
"0.78440636",
"0.7770831",
"0.77035886",
"0.76633406",
"0.76391345",
"0.75981855",
"0.74306023",
"0.73690313",
"0.72739345",
"0.7262992",
"0.71151763",
"0.7112965",
"0.70745146",
"0.7053805",
"0.70487416",
"0.69528365",
"0.69198143",
"0.68998283",
"0.687098",
"0.6843199",
"0.... | 0.6903701 | 17 |
Computes the precision for the specified values of k | def accuracy(output, target, topk=(1,)):
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
correct_k = correct[:k].reshape(-1).float().sum(0, keepdim... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\... | [
"0.76427615",
"0.74189496",
"0.7418079",
"0.72710466",
"0.72456723",
"0.72446615",
"0.7237539",
"0.72213703",
"0.7210107",
"0.7058935",
"0.6852219",
"0.6786084",
"0.67836976",
"0.6768417",
"0.67273885",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.... | 0.0 | -1 |
Fused elementwise_add/mul and activation layers This function computes an elementwise_add/mul cooperated with an activation. | def fused_elemwise_activation(x,
y,
functor_list,
axis=-1,
scale=0.0,
save_intermediate_out=True):
if isinstance(functor_list, str):
functor_list = functor_li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call(self, inputs):\n\n x = tf.matmul(inputs, self.w) + self.b\n x = self.activation(x)\n\n return x",
"def _forward(z: np.array, W: np.array, b: np.array,\n activation: str) -> np.array:\n a = np.dot(z, W) + b\n if activation == 'sigmoid':\n return sigmoid(a)\n elif acti... | [
"0.6785041",
"0.66848034",
"0.66607964",
"0.65622807",
"0.6544377",
"0.6528224",
"0.64593065",
"0.6396585",
"0.6381647",
"0.63695455",
"0.6353182",
"0.63472384",
"0.631924",
"0.6301697",
"0.62578636",
"0.6245912",
"0.62452966",
"0.6238974",
"0.62210476",
"0.62139124",
"0.6186... | 0.64662856 | 6 |
Add callback to self._daemon_execute_callbacks. See service_actions function to their usages. | def append_thread_callback(self, callback: collections.Callable) -> None:
self._daemon_execute_callbacks.append(callback) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_post_exec_callback(action_logger):\n logging.debug(\"Adding %s to post execution callback\", action_logger)\n __post_exec_callbacks.append(action_logger)",
"def add_done_callback(self, callback):\n with self._done_condition:\n if self._state in [PENDING, RUNNING]:\n ... | [
"0.595641",
"0.57329416",
"0.5647649",
"0.56453633",
"0.56191623",
"0.55979604",
"0.5584443",
"0.5554504",
"0.5554059",
"0.5503657",
"0.55009544",
"0.5450373",
"0.54332",
"0.5432897",
"0.5395858",
"0.53488904",
"0.53168035",
"0.53141373",
"0.53129905",
"0.53031254",
"0.528276... | 0.71937627 | 0 |
Model forward pass input, current input in t contextState, previous output in (t 1) the sequence of hidden states | def forward(self, x, contextState):
#concatenate input and context state
#x = x.t()
xAndContext = torch.cat((x, contextState), 1)
#calculate next context state (hidden output for current t) with tanh(xAndContext * W1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, prev_state, obs_t):\r\n # Use your network to compute qvalues for given state\r\n #print(state_t.shape)\r\n h = self.conv(obs_t)\r\n\r\n h = h.view(h.size(0), -1)\r\n\r\n new_state = h_new, c_new = self.lstm(h, prev_state)\r\n advantage = self.adv(h_new)\... | [
"0.70666903",
"0.6960144",
"0.6944148",
"0.6924527",
"0.68692386",
"0.68370396",
"0.68172926",
"0.6813111",
"0.68120724",
"0.68052375",
"0.67952406",
"0.6781737",
"0.67794245",
"0.6764326",
"0.6733078",
"0.6679583",
"0.66273844",
"0.6616958",
"0.65847284",
"0.657578",
"0.6555... | 0.7525371 | 0 |
Determine the Young's modulus of the Elongation. Modulus is calculated as the peak of the derivative of the stress strain curve. | def youngs_modulus(self, x_limit=None):
if x_limit is not None:
raise NotImplementedError('Limits on x not yet implemented, see youngs_modulus_array().')
return max(self.youngs_modulus_array) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def YoungModulus(material):\n if material == \"mild\":\n return 200e9\n else:\n if material == \"al\":\n return 69e9\n else:\n raise ValueError(\"Invalid material `\"+material+\"'\")",
"def _calc_young_modulus(dataset: np.ndarray) -> YoungModulus:\n segment_x_l... | [
"0.75485635",
"0.74274933",
"0.6333822",
"0.602804",
"0.5853094",
"0.58021337",
"0.5751449",
"0.5742924",
"0.56657714",
"0.5579836",
"0.5565335",
"0.55258816",
"0.5520236",
"0.5520098",
"0.5503216",
"0.54897547",
"0.54739076",
"0.54691815",
"0.5460389",
"0.5448125",
"0.542998... | 0.6033121 | 3 |
Multilayer Perceptron is sensitive to feature scaling, so it is highly recommended to scale your data. For example, scale each attribute on the input vector X to [0, 1] or [1, +1], or standardize it to have mean 0 and variance 1. Note that you must apply the same scaling to the test set for meaningful results. | def scale_data(data_matrix):
scaler = StandardScaler()
# Don't cheat - fit only on training data
scaler.fit(data_matrix)
X_train = scaler.transform(data_matrix)
return X_train | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_perceptron(train_exs: List[SentimentExample], feat_extractor: FeatureExtractor) -> PerceptronClassifier:\n raise Exception(\"Must be implemented\")",
"def train_perceptron(train_exs: List[SentimentExample], feat_extractor: FeatureExtractor) -> PerceptronClassifier:\n raise Exception(\"Must be imp... | [
"0.66160285",
"0.66160285",
"0.6479322",
"0.6373529",
"0.6332721",
"0.6278016",
"0.62647",
"0.62536883",
"0.6185974",
"0.6184712",
"0.6036722",
"0.6031992",
"0.5954827",
"0.5831484",
"0.5821886",
"0.58213013",
"0.57672703",
"0.57202554",
"0.5689846",
"0.5683262",
"0.5657926",... | 0.5182711 | 84 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.