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 |
|---|---|---|---|---|---|---|
Get the location of the device. | def location(self) -> str:
ind = self._raw_result['locationIndex']
if ind > -1 and ind < len(self._client.locations):
return self._client.locations[ind]['name']
return "" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_location(self):\n return self.location",
"def get_location(self):\n\t\treturn self.location",
"def get_location(self):\r\n return self.__location",
"async def location(self):\n if not hasattr(self, \"_location\"):\n self._location = await Stack.fetch_stack_value(self, ... | [
"0.764787",
"0.7643548",
"0.7609037",
"0.7551382",
"0.7451123",
"0.7320496",
"0.7320496",
"0.7320496",
"0.7320496",
"0.7320496",
"0.7320496",
"0.7320496",
"0.7320496",
"0.7320496",
"0.7320496",
"0.7320496",
"0.7320496",
"0.7320496",
"0.72884095",
"0.72884095",
"0.72884095",
... | 0.0 | -1 |
Calculate the Normally distributed equivalent covariance from the LogNormally distributed mean and standard deviation | def LN2N_Covar(LN_Mean, LN_Covar, NParams):
N_Covar=np.zeros([NParams,NParams],float)
for i in range(NParams):
for j in range(i+1):
N_Covar[i,j] = LogCovar( LN_Covar[i,j], LN_Mean[i], LN_Mean[j] )
N_Covar[j,i] = N_Covar[i,j]
N_SD = np.sqrt(N_Covar.diagonal())
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lcov (x,y, keepdims=0):\r\n\r\n n = len(x)\r\n xmn = mean(x)\r\n ymn = mean(y)\r\n xdeviations = [0]*len(x)\r\n ydeviations = [0]*len(y)\r\n for i in range(len(x)):\r\n xdeviations[i] = x[i] - xmn\r\n ydeviations[i] = y[i] - ymn\r\n ss = 0.0\r\n for i in range(len(xdeviati... | [
"0.6548354",
"0.6453823",
"0.6441499",
"0.6427915",
"0.6400223",
"0.63873965",
"0.6380975",
"0.6367306",
"0.6361646",
"0.6343738",
"0.63418704",
"0.6336723",
"0.6335436",
"0.6319289",
"0.630919",
"0.62958384",
"0.6287269",
"0.6268483",
"0.6265126",
"0.6257694",
"0.622388",
... | 0.5967139 | 38 |
Remove the given reporter from the population's ReporterSet. | def remove_reporter(self, reporter):
self.reporters.remove(reporter) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_report_runner(self, runner: str) -> None:\n self.delete_document(Type._RUNNING, runner)",
"def remove(self, pset):\n self._sets.remove(pset)",
"def reporter(self, reporter):\n\n self._reporter = reporter",
"def on_trial_remove(self, trial_runner, trial):\n\n raise NotImplem... | [
"0.63444084",
"0.62534475",
"0.5465738",
"0.54571396",
"0.5455381",
"0.54182464",
"0.5351261",
"0.53505623",
"0.5285223",
"0.5164197",
"0.51604444",
"0.51604444",
"0.51213115",
"0.5115846",
"0.5108437",
"0.50929385",
"0.50457805",
"0.5043645",
"0.5036632",
"0.5031462",
"0.500... | 0.8546262 | 0 |
summary operators for tensorboard | def setup_summary():
episode_total_reward = tf.Variable(0.)
tf.summary.scalar('Total_Reward/Episode', episode_total_reward)
summary_vars = [episode_total_reward]
summary_placeholders = [tf.placeholder(tf.float32) for _ in range(len(summary_vars))]
update_ops = [summary_vars[i].assign(summary_pla... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_summary(self):\n for k, v in self.metrics.items():\n tf.summary.scalar(k, v)\n \n self.summary_op = tf.summary.merge_all()",
"def build_summaries(self):\n\n # Loss summary.\n tf.summary.scalar('loss', self.loss)\n\n merged = tf.summary.merge_all()\n self.summary_op = merged\n ... | [
"0.7839559",
"0.7424628",
"0.7424628",
"0.737441",
"0.7136893",
"0.6996576",
"0.6982558",
"0.69571507",
"0.6954744",
"0.69259715",
"0.68893015",
"0.68594164",
"0.685767",
"0.6842149",
"0.68393296",
"0.6812471",
"0.6810708",
"0.6794244",
"0.67881835",
"0.6771046",
"0.67438024"... | 0.73179084 | 4 |
Form the right clipping plane for a camera view frustum. In the camera coordinate frame, y is down the imager, x is across the imager, and z is along the optical axis. The focal length is the distance to the center | def form_right_clipping_plane(fx: float, img_width: int) -> np.ndarray:
right_plane = np.array([-fx, 0.0, img_width / 2.0, 0.0])
right_plane /= np.linalg.norm(right_plane)
return right_plane | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def frustum(self, left, right, bottom, top, near, far):\r\n \r\n return mat4( (2.0*near)/(right-left), 0.0, float(right+left)/(right-left), 0.0,\r\n 0.0, (2.0*near)/(top-bottom), float(top+bottom)/(top-bottom), 0.0,\r\n 0.0, 0.0, -float(far+near)/(far-near), -(... | [
"0.6371805",
"0.61543363",
"0.5812646",
"0.56834435",
"0.56070125",
"0.5573147",
"0.5571845",
"0.5563064",
"0.5559711",
"0.554106",
"0.55294794",
"0.55294794",
"0.55294794",
"0.55102634",
"0.55052304",
"0.5505003",
"0.5484796",
"0.54548645",
"0.543443",
"0.54266024",
"0.54228... | 0.62306595 | 1 |
r"""Form the left clipping plane for a camera view frustum. In the camera coordinate frame, y is down the imager, x is across the imager, and z is along the optical axis. The focal length is the distance to the center | def form_left_clipping_plane(fx: float, img_width: int) -> np.ndarray:
left_plane = np.array([fx, 0.0, img_width / 2.0, 0.0])
left_plane /= np.linalg.norm(left_plane)
return left_plane | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_left_clipping_plane() -> None:\n fx_px = 10.0\n width_px = 30\n\n pinhole_camera = _create_pinhole_camera(\n fx_px=fx_px,\n fy_px=0,\n cx_px=0,\n cy_px=0,\n height_px=30,\n width_px=width_px,\n cam_name=\"ring_front_center\",\n )\n left_plane... | [
"0.6576252",
"0.6037883",
"0.58467996",
"0.5709771",
"0.5624784",
"0.55616385",
"0.5467485",
"0.53785735",
"0.5218481",
"0.52064663",
"0.5161931",
"0.51512146",
"0.51024044",
"0.5084049",
"0.50803524",
"0.50793815",
"0.5064749",
"0.5017882",
"0.5006964",
"0.498917",
"0.498059... | 0.652811 | 1 |
r"""Form the top clipping plane for a camera view frustum. In the camera coordinate frame, y is down the imager, x is across the imager, and z is along the optical axis. The focal length is the distance to the center | def form_top_clipping_plane(fx: float, img_height: int) -> np.ndarray:
top_plane = np.array([0.0, fx, img_height / 2.0, 0.0])
top_plane /= np.linalg.norm(top_plane)
return top_plane | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_top_clipping_plane() -> None:\n fx_px = 10.0\n height_px = 45\n pinhole_camera = _create_pinhole_camera(\n fx_px=fx_px,\n fy_px=0,\n cx_px=0,\n cy_px=0,\n height_px=height_px,\n width_px=1000,\n cam_name=\"ring_front_center\",\n )\n\n top_pla... | [
"0.634829",
"0.5882758",
"0.55479276",
"0.5497832",
"0.5416896",
"0.54104906",
"0.53635204",
"0.5317329",
"0.5306931",
"0.5247168",
"0.5197019",
"0.5194893",
"0.5194893",
"0.5194893",
"0.5165252",
"0.5155119",
"0.51305944",
"0.5128192",
"0.5117306",
"0.50200576",
"0.5015055",... | 0.6523103 | 0 |
Compute the planes enclosing the field of view (viewing frustum) for a single camera. We do this using similar triangles. tan(theta/2) = (0.5 height)/focal_length "theta" is the vertical FOV. Similar for horizontal FOV. height and focal_length are both in pixels. Note that ring cameras and stereo cameras have different... | def generate_frustum_planes(K: np.ndarray, camera_name: str, near_clip_dist: float = 0.5) -> Optional[List[np.ndarray]]:
img_width, img_height = get_image_dims_for_camera(camera_name)
if img_width is None or img_height is None:
return None
P = np.array([0.0, 0.0, 0.0])
fx = K[0, 0]
fy = K[1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _getFrustrumPlanes(self, frame=None, allowClipping=True):\r\n from blur3d.mathutils import Vector, Matrix\r\n from Py3dsMax import AtTime\r\n import math\r\n attime = None\r\n # Explicit comparison to None in case we need to query frame 0\r\n if frame != None:\r\n ... | [
"0.62970257",
"0.6168795",
"0.59588856",
"0.5918871",
"0.5915276",
"0.58903575",
"0.58357817",
"0.58173656",
"0.5789509",
"0.5753345",
"0.5728148",
"0.5621074",
"0.55686086",
"0.55149096",
"0.5501537",
"0.541124",
"0.5333243",
"0.5314717",
"0.52813315",
"0.5266469",
"0.518822... | 0.5777675 | 9 |
Get sign of point to plane distance. This function does not compute the actual distance. Positive denotes that point v is on the same side of the plane as the plane's normal vector. Negative if it is on the opposite side. | def plane_point_side_v3(p: np.ndarray, v: np.ndarray) -> Any:
return p[:3].dot(v) + p[3] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signed_distance_to(self, v: Vector) -> float:\n return self._normal.dot(v) - self._distance_from_origin",
"def distance_point_plane(point, plane):\n base, normal = plane\n vector = subtract_vectors(point, base)\n return fabs(dot_vectors(vector, normal))",
"def distance_point_signed(self, po... | [
"0.7139961",
"0.6855669",
"0.6638735",
"0.636708",
"0.632617",
"0.6277414",
"0.62659323",
"0.6243039",
"0.6234178",
"0.6147753",
"0.603795",
"0.59623355",
"0.595946",
"0.5927485",
"0.59170735",
"0.5892435",
"0.5860098",
"0.58533126",
"0.58481073",
"0.58481073",
"0.58389896",
... | 0.57132983 | 32 |
Returns true if this login interface supports logging in multiple different times. | def supportsRelogin(self):
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _can_login(self):\n return all([self.user.is_active, self.status, self.status_detail == \"active\"])",
"def test_user_login_attempt_when_user_already_logged_in(self):\n\t\tpass",
"def any_active(self):\n for session_id in self.get_sessions():\n session = Session(self.session_cache,... | [
"0.6755857",
"0.62627876",
"0.60936135",
"0.6083165",
"0.6031901",
"0.6028888",
"0.6012355",
"0.59951544",
"0.5984724",
"0.5975969",
"0.5935373",
"0.58605015",
"0.5837737",
"0.5823551",
"0.5813661",
"0.5799477",
"0.5797808",
"0.57750046",
"0.5772315",
"0.5771057",
"0.57680124... | 0.6936608 | 0 |
Gets time series sequences for One day | def getOneDay(self,day_number=0):
return self.event_time_sequence[day_number] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_fire_time_series(self):\r\n self.fire_events =[]\r\n event = self.generate_fire_recurrence()\r\n end_event = event + 365.0\r\n self.fire_events.append([event, end_event])\r\n t = 0\r\n i = 0\r\n while t <= self.total_run_time:\r\n fire = self... | [
"0.591737",
"0.5830383",
"0.57229066",
"0.571217",
"0.56297576",
"0.5620911",
"0.5561776",
"0.55221695",
"0.54340875",
"0.5411167",
"0.54046196",
"0.53892434",
"0.53376186",
"0.5318647",
"0.5318351",
"0.5231008",
"0.5215481",
"0.5200333",
"0.51772946",
"0.5157684",
"0.5144961... | 0.50661355 | 30 |
Loads a give filepath image and returns PIL image which can be used with torchvision transforms. Resize the input image based on size and/or scale. | def load_image(filename, size=None, scale=None):
img = Image.open(filename)
if size is not None:
img = img.resize((size, size), Image.ANTIALIAS)
elif scale is not None:
img = img.resize((int(img.size[0]*scale), int(img.size[1]*scale)), Image.ANTIALIAS)
return img | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_image(path):\r\n image = Image.open(path)\r\n size = image.size\r\n \r\n image = image.resize((550,550), Image.ANTIALIAS)\r\n# image = image.thumbnail((200,200), Image.ANTIALIAS)\r\n return image",
"def load_image(self, path, target_size=None):\n ... | [
"0.7856949",
"0.7460769",
"0.7392047",
"0.73479635",
"0.73323697",
"0.7313163",
"0.73047835",
"0.7105167",
"0.7102316",
"0.706409",
"0.69642115",
"0.6961701",
"0.6938461",
"0.6859632",
"0.6846749",
"0.67984885",
"0.6790766",
"0.67750233",
"0.6757608",
"0.67330205",
"0.6649548... | 0.7414601 | 2 |
Default to utf8 if all else fails. | def test_response_default_encoding():
response = httpcore.Response(200, content=b"")
assert response.text == ""
assert response.encoding == "utf-8" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_utf8_locale():\n lang, encoding = locale.getlocale()\n if encoding != 'UTF-8':\n locale.setlocale(locale.LC_CTYPE, (lang, 'UTF-8'))",
"def test_response_fallback_to_utf8_encoding():\n headers = {\"Content-Type\": \"text-plain; charset=invalid-codec-name\"}\n content = \"おはようございます。\".en... | [
"0.71167135",
"0.7060224",
"0.7040925",
"0.68217254",
"0.67419004",
"0.6729384",
"0.67231715",
"0.6642953",
"0.6613679",
"0.65971214",
"0.65404004",
"0.65388143",
"0.6531479",
"0.65080005",
"0.6481666",
"0.64230055",
"0.64229065",
"0.6421989",
"0.63885",
"0.6386558",
"0.63482... | 0.6559279 | 10 |
hybolic space distance between point x and y. | def hybolic_distance(self, index, x, y):
r1, t1 = self.hyperspace[index][x]
r2, t2 = self.hyperspace[index][y]
delta_t = (pi - fabs(pi - fabs(t1 - t2))) + 0.0001
d = r1 + r2 + 2.0 * log(delta_t / 2.0)
#d = acosh(cosh(r1) * cosh(r2) - sinh(r1) * sinh(r2) * cos(delta_t))
T,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dist(self,x, y):\n\n x1, y1 = x\n x2, y2 = y\n return np.sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2))",
"def find_hypotenuse(x, y):\n return math.sqrt(x**2 + y**2)",
"def hypothenuse(x, y):\n return sqrt(x**2 + y**2)",
"def distance_to(self, x, y):\n\t\tdx = x - self.x\n\t\t... | [
"0.7672632",
"0.7666976",
"0.7457631",
"0.7451656",
"0.73708546",
"0.7213849",
"0.7189243",
"0.7177651",
"0.7034749",
"0.7028475",
"0.701813",
"0.6869763",
"0.6852683",
"0.68367535",
"0.68098533",
"0.67841375",
"0.6779564",
"0.67023885",
"0.66600037",
"0.6638552",
"0.6609961"... | 0.72909534 | 5 |
The output of the ``npm version`` command (a string). | def npm_version(self):
return self.context.capture('npm', '--version') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def version(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"version\")",
"def version():\n return Tns.exec_command(command='--version')",
"async def version(self):\n self.do(\"version\")\n return (await self.read(7)).strip()",
"def version():\n\n status, stdout, stderr =... | [
"0.7294686",
"0.72643274",
"0.71208227",
"0.70932186",
"0.7036567",
"0.7012068",
"0.6999609",
"0.6978405",
"0.694419",
"0.6875552",
"0.6849016",
"0.6834365",
"0.67529315",
"0.67087007",
"0.67069507",
"0.6706356",
"0.6687317",
"0.66778314",
"0.66396075",
"0.66385806",
"0.66358... | 0.850228 | 0 |
Initializes line class object. Creates and sets several internal properties. | def __init__(self, ping_time=None, data=None, color=[0.58, 0.0, 0.83],
name='line', linestyle='solid', thickness=1.0, **_):
super(line, self).__init__()
# Set the ping time.
self.ping_time = ping_time
# Set the number of pings.
if ping_time is not None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init():\n line.set_data([], [])\n return line,",
"def __init__(self, line):\n self.start = LineAndColumn(line, 1)\n self.end = LineAndColumn(line, 0)",
"def init(self) -> None:\n self.started = False\n self.lines = []\n self.text = ''\n self.graphics... | [
"0.7670786",
"0.73800004",
"0.72727174",
"0.7239013",
"0.72336185",
"0.7067391",
"0.69104517",
"0.6868688",
"0.66425705",
"0.6627292",
"0.6625873",
"0.65981156",
"0.65764785",
"0.6570101",
"0.6542242",
"0.6527248",
"0.6517854",
"0.6508795",
"0.65021276",
"0.64953476",
"0.6487... | 0.62252945 | 34 |
makes a boxplot of Infant mortality | def plot_boxplot(df):
# if graph is being plotted use this style
plt.style.use('seaborn-darkgrid')
# create a horizontal boxplot with title and axes of infant mortality
boxplot = df.boxplot(column='Infant mortality (per 1000 births)', vert = False, rot=90)
boxplot.set_title('Infant Mortality')
plt.axis([0, 200,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_boxplot(self):\n values = [37, 48, 30, 53, 3, 83, 19, 71, 90, 16, 19, 7, 11, 43, 43]\n result = boxplot(values)\n self.assertEqual(3, result['min_val'])\n self.assertEqual(17.5, result['q1_val'])\n self.assertEqual(37, result['mean_val'])\n self.assertEqual(50.5, ... | [
"0.67889845",
"0.6606236",
"0.65212405",
"0.63526344",
"0.631543",
"0.6293989",
"0.61845535",
"0.6151978",
"0.6145313",
"0.6029841",
"0.60168296",
"0.59721583",
"0.595611",
"0.5945604",
"0.5905023",
"0.5858546",
"0.58406365",
"0.5767579",
"0.57629055",
"0.57512236",
"0.571291... | 0.75931436 | 0 |
Calculate the great circle distance between two points on the earth (specified in decimal degrees) | def haversine(lon1, lat1, lon2, lat2): # 经度1,纬度1,经度2,纬度2 (十进制度数)
lon1 = float(lon1)
lat1 = float(lat1)
lon2 = float(lon2)
lat2 = float(lat2)
if lon1 == 0 or lat1 == 0:
return float(999999999)
if lon2 == 0 or lon2 ==[]:
return float(999999999)
if lat2 == 0 or lat2 ==[]:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def great_circle(lat_1, long_1, lat_2, long_2):\n long_1 = m.radians(long_1)\n lat_1 = m.radians(lat_1)\n long_2 = m.radians(long_2)\n lat_2 = m.radians(lat_2)\n\n d = 2 * 6367.45 * m.asin(\n m.sqrt(haversine(lat_2 - lat_1)\n + m.cos(lat_1)*m.cos(lat_2) *\n haversine(long... | [
"0.81450045",
"0.7863265",
"0.76322985",
"0.76064754",
"0.75978696",
"0.75965863",
"0.75944835",
"0.75720793",
"0.75630087",
"0.7555095",
"0.7528691",
"0.7517629",
"0.7492963",
"0.7467739",
"0.7452678",
"0.7434477",
"0.73914117",
"0.7357736",
"0.73484355",
"0.73318124",
"0.73... | 0.0 | -1 |
Load a configration yaml file. | def load_config(config_path):
with open(config_path, "r") as f:
conf = yaml.load(f)
params = conf['param']
return params | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_config_file(path):\n with open(path) as file:\n return yaml.load(file, Loader=yaml.FullLoader)",
"def load_config(path):\n return yaml.load(open('config.yaml', 'r'), Loader=yaml.SafeLoader)",
"def load_yaml(cls, file=None):\n if file is None: file = f'{rcp.base_path}cfg.yml'\n ... | [
"0.8207103",
"0.8179891",
"0.8148756",
"0.8117831",
"0.8109204",
"0.81076616",
"0.80809826",
"0.8078856",
"0.7984739",
"0.7981607",
"0.79621416",
"0.7847742",
"0.7831578",
"0.78291565",
"0.7826917",
"0.7775996",
"0.77680933",
"0.775037",
"0.77394754",
"0.76746035",
"0.7670806... | 0.0 | -1 |
Return a discrete colormap from the continuous colormap cmap. | def cmap_discretize(cmap, N):
if type(cmap) == str:
cmap = get_cmap(cmap)
colors_i = np.concatenate((np.linspace(0, 1., N), (0.,0.,0.,0.)))
colors_rgba = cmap(colors_i)
indices = np.linspace(0, 1., N+1)
cdict = {}
for ki,key in enumerate(('red','green','blue')):
cdict[key] = [ (... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discrete_cmap(N, base_cmap=None):\n base = plt.get_cmap(base_cmap)\n color_list = base(np.linspace(0, 1, N))\n cmap_name = base.name + str(N)\n return base.from_list(cmap_name, color_list, N)",
"def discrete_cmap(N, base_cmap=None):\n\t# Note that if base_cmap is a string or None, you can simply ... | [
"0.728505",
"0.72603613",
"0.72455084",
"0.72360593",
"0.72360593",
"0.72360593",
"0.72089005",
"0.7171376",
"0.7171376",
"0.7171376",
"0.7171376",
"0.71471137",
"0.7134598",
"0.7107368",
"0.6255922",
"0.6215949",
"0.6136177",
"0.61234826",
"0.6092151",
"0.6057911",
"0.602438... | 0.6235518 | 15 |
This method allows you to select a stock from the portfolio list | def select_stock(portfolio_list, portfolio_selected, give_prompt=0, portfolio_stock_choice=0):
if give_prompt == 0:
portfolio_stock_choice = prompt.shortcuts.radiolist_dialog(
values=[(x.stock_ticker, x.name) for x in
[x.stock_list for x in portfolio_list if x.portfolio_id ==... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_stock_object(portfolio_list, portfolio_selected):\n portfolio_stock_choice = prompt.shortcuts.radiolist_dialog(\n values=[(x, x.name) for x in\n [x.stock_list for x in portfolio_list if x.portfolio_id == portfolio_selected][0]],\n title=\"Portfolio Overview\",\n te... | [
"0.7955552",
"0.6443276",
"0.61463046",
"0.60774595",
"0.6059596",
"0.5913038",
"0.5877178",
"0.58088493",
"0.5808634",
"0.57372975",
"0.5691169",
"0.568218",
"0.56653225",
"0.56450915",
"0.5635502",
"0.5609732",
"0.559394",
"0.55869895",
"0.5577424",
"0.5547058",
"0.55278134... | 0.7929458 | 1 |
This given a stock ticker will return the index of that stock ticker in a stock list. | def index_of_ticker(l, name):
for i in range(len(l)):
if l[i].stock_ticker == name:
return i
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getindex(self):\n for index in range(1, len(self.quotes_list)):\n if str(index) not in self.quotes_list.keys():\n return index\n return len(self.quotes_list) + 1",
"def get_list_index(self):\r\n _debug('simq03b_api.get_list_index')\r\n \r\n s = sel... | [
"0.66369987",
"0.65936166",
"0.6426643",
"0.6426643",
"0.6402644",
"0.62848055",
"0.62794656",
"0.6217571",
"0.6190856",
"0.60110795",
"0.5990363",
"0.5967443",
"0.5950829",
"0.59488213",
"0.5935689",
"0.59102917",
"0.585059",
"0.58478343",
"0.5823558",
"0.5781658",
"0.576531... | 0.8471046 | 0 |
Reset the screen, terminate the scrolling process. | def reset(self):
self.sentinel = True
self.killedevent.wait()
self.clear()
self.show() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_scroll():\n send_command(0x2E)",
"def reset(self):\n\n game.reset()\n sm.get_screen('game_screen').reset()",
"def reset_scrollbar(self):\n self.testCanvas.bind('<Configure>', self.off_configure)\n self.testFrame.bind('<Configure>', self.off_configure)",
"def clearScree... | [
"0.68808895",
"0.675579",
"0.6615698",
"0.6602761",
"0.6589134",
"0.6579206",
"0.6542147",
"0.6525379",
"0.64864147",
"0.6439519",
"0.63891566",
"0.636647",
"0.6335703",
"0.6330365",
"0.630555",
"0.6288713",
"0.62657493",
"0.62209177",
"0.62045455",
"0.61612594",
"0.6149464",... | 0.6264099 | 17 |
Convert class labels from scalars to onehot vectors. | def dense_to_one_hot(labels_dense, num_classes):
print ('in onehot', labels_dense, num_classes)
num_labels = labels_dense.shape[0]
index_offset = numpy.arange(num_labels) * num_classes
labels_one_hot = numpy.zeros((num_labels, num_classes))
labels_one_hot.flat[index_offset + labels_dense.ravel()] = 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot(labels, classes=None):\n return K.utils.to_categorical(labels, classes)",
"def one_hot(labels, classes=None):\n\n one_hot_ = K.utils.to_categorical(labels, classes)\n return(one_hot_)",
"def to_onehot(labels: torch.Tensor, num_classes: int) -> torch.Tensor:\n if len(labels.size()) == 1:... | [
"0.8250402",
"0.807683",
"0.80523187",
"0.7977843",
"0.7908335",
"0.7900327",
"0.7892233",
"0.7869711",
"0.7849721",
"0.7849721",
"0.7826951",
"0.7826122",
"0.77677035",
"0.7765413",
"0.77540547",
"0.77540547",
"0.77540547",
"0.7742955",
"0.7737176",
"0.77226317",
"0.77123284... | 0.77489346 | 17 |
Ensures that get_empty_squares returns positions for all and only empty squares | def test_get_empty_squares(self):
self.assertEqual(self.game.get_empty_squares(), [
(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)])
for row in range(self.game._dim):
for col in range(self.game._dim):
self.game._board[row][col... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_empty_squares(self):\n return self.empty_squares",
"def find_empty(puzzle):\r\n empty_squares = []\r\n for y in range(len(puzzle.squares)):\r\n for x in range(len(puzzle.squares[0])):\r\n if puzzle.squares[y][x].is_editable() is True:\r\n empty_squares.append... | [
"0.80937165",
"0.79287744",
"0.7742241",
"0.7505487",
"0.7487581",
"0.7353775",
"0.7099774",
"0.69294804",
"0.6715829",
"0.6660283",
"0.66401243",
"0.659778",
"0.6592171",
"0.6587445",
"0.6490662",
"0.6447285",
"0.6427912",
"0.63832915",
"0.6358433",
"0.6307268",
"0.6263488",... | 0.825583 | 0 |
Checks if the workbook exists within the spreadsheet. | def check_workbook_exists(service, spreadsheet_id, tab_name):
try:
spreadsheet = service.spreadsheets().get(
spreadsheetId=spreadsheet_id).execute()
sheets = spreadsheet['sheets']
exists = [True for sheet in sheets if sheet['properties']
['title'] == tab_name]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_presSheetExists(self):\n\n if not self.pres_sheetname:\n self.raise_excelerror(\"Required sheet for preservation files\" +\n \"could not be found in workbook.\")\n\n return True",
"def checkOpenStatus(self):\n xl = win32.gencache.EnsureDispatch('Excel.Application')\n upd... | [
"0.73603034",
"0.6450957",
"0.63384753",
"0.6258127",
"0.61814404",
"0.61775357",
"0.6156461",
"0.61448574",
"0.6106542",
"0.6020768",
"0.6010706",
"0.600755",
"0.5974464",
"0.5972792",
"0.5967012",
"0.59625244",
"0.5945935",
"0.5944969",
"0.59072995",
"0.59021074",
"0.589425... | 0.75555295 | 0 |
Remove keys from dict. | def remove_keys_from_dict(dictionary, keys):
# Copy dictionary
dictionary_updated = dictionary.copy()
try:
[dictionary_updated.pop(key) for key in keys]
except:
print("Error: No ratio and sampling strategy parameters")
return dictionary_updated | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_keys(_dict, keys):\n if not _dict:\n return None\n new = dict(_dict)\n for key in keys:\n new.pop(key, None)\n return new",
"def remove_keys(_dict, _keys):\n if isinstance(_keys, str):\n if _keys in _dict:\n del _dict[_keys]\n ... | [
"0.77924424",
"0.7789427",
"0.77469206",
"0.76607066",
"0.7586614",
"0.75853425",
"0.75591606",
"0.75193053",
"0.74619323",
"0.73964864",
"0.73528683",
"0.7289648",
"0.71919847",
"0.709679",
"0.70546687",
"0.704237",
"0.70030296",
"0.69795114",
"0.69204664",
"0.6794681",
"0.6... | 0.7694005 | 3 |
Test the email and username validator | def test_email_username_validator(self):
# Test with good data
validator = self.validator.username_email_validator
resp = validator('moracha', 'moracha@gmail.com',
mock_data['user_dets'])
self.assertTrue(resp)
# Test with bad data
# Registered use... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_email(self):\r\n \r\n self.assertEqual('maryc123@yahoo.com', self.user.email)",
"def test_is_valid_email(self):\n self.assertTrue(is_valid_email('abc@example.com'))",
"def test_empty_email_field(self):\r\n result=self.user.get_user_register(\"Stephen\",\" Ochieng\",\"st... | [
"0.7522016",
"0.7493131",
"0.7414265",
"0.7289321",
"0.7236367",
"0.71856475",
"0.71265054",
"0.7087156",
"0.7073325",
"0.70222175",
"0.7019227",
"0.7007756",
"0.6933565",
"0.6932713",
"0.69212574",
"0.68850476",
"0.68725777",
"0.68630224",
"0.68576753",
"0.68301433",
"0.6826... | 0.84018666 | 0 |
Returns an OptionParser object with all the default options. | def MakeOpts():
opt_parser = OptionParser()
#opt_parser.add_option("-d", "--sqlite_db_filename",
# dest="sqlite_db_filename",
# default="../res/tecan.sqlite",
# help="The filename of the Sqlite database")
opt_parser.add_option("-p", ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_default_options():\n parser = OptionParser()\n add_option_group(parser)\n options, args = parser.parse_args([])\n return options",
"def initCmdLineParser():\n\n # Init parser and all general flags\n logging.debug(\"initiating command line option parser\")\n usage = \"usage: %prog [options... | [
"0.84064525",
"0.7035872",
"0.69315475",
"0.6762891",
"0.6612723",
"0.65971667",
"0.657549",
"0.65095645",
"0.65095645",
"0.63397056",
"0.6329244",
"0.63176024",
"0.6288814",
"0.6283019",
"0.6267587",
"0.6220962",
"0.6210075",
"0.6204305",
"0.6200668",
"0.619317",
"0.61901367... | 0.0 | -1 |
ResNet101 model of [1]. See resnet_v1() for arg and return description. | def resnet_v1_101_c4(inputs,
num_classes=None,
is_training=True,
global_pool=True,
output_stride=None,
spatial_squeeze=True,
reuse=None,
scope='resnet_v1_101'):
blocks = [
resnet_v1_bloc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resnet101(pretrained=False):\n model = ResNet(Bottleneck, [3, 4, 23, 3])\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['resnet101']))\n return model",
"def resnet101(**kwargs):\n model = ResNet(Bottleneck, [3, 4, 23, 3], **kwargs)\n return model",
"def resnet1... | [
"0.7354087",
"0.73518556",
"0.7318084",
"0.7312269",
"0.729412",
"0.729412",
"0.729412",
"0.729412",
"0.7217979",
"0.7164926",
"0.7047821",
"0.7047821",
"0.70410293",
"0.6985957",
"0.6935151",
"0.68581074",
"0.6797936",
"0.67149603",
"0.66381735",
"0.64763016",
"0.6461494",
... | 0.0 | -1 |
ResNet101 model of [1]. See resnet_v1() for arg and return description. | def resnet_v1_101_c1(inputs,
num_classes=None,
is_training=True,
global_pool=True,
output_stride=None,
spatial_squeeze=True,
reuse=None,
scope='resnet_v1_101'):
blocks = [
resnet_v1_bloc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resnet101(pretrained=False):\n model = ResNet(Bottleneck, [3, 4, 23, 3])\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['resnet101']))\n return model",
"def resnet101(**kwargs):\n model = ResNet(Bottleneck, [3, 4, 23, 3], **kwargs)\n return model",
"def resnet1... | [
"0.7354397",
"0.73525655",
"0.73184854",
"0.73128134",
"0.7294708",
"0.7294708",
"0.7294708",
"0.7294708",
"0.72181326",
"0.71658254",
"0.7048552",
"0.7048552",
"0.70414203",
"0.6986402",
"0.693545",
"0.68583596",
"0.67980367",
"0.671526",
"0.66386175",
"0.64768267",
"0.64627... | 0.6301241 | 25 |
This route gets a single team from the database and returns it as a json object. Args {string} id Returns {Object} 200 | def get_one_team(id):
# Try to get team from database
query = Team.query.filter_by(id=id)
try:
team = query.one()
# If no result found, return error
except NoResultFound:
return jsonify({'error': 'No result found!'}), 404
# If some other sqlalchemy error is thrown, return erro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_team(team_id):\n team = TeamController.get(filters={\"Team\": {\"id\": team_id}})\n return jsonify(format_team(team)), 200",
"def edit_team(id):\n # Get the user's id from access token\n uid = get_jwt_identity()\n\n # If no user id, return error\n if not uid:\n return make_respon... | [
"0.8333166",
"0.80708265",
"0.7748766",
"0.76819545",
"0.71936613",
"0.7187864",
"0.7098594",
"0.7055235",
"0.70538276",
"0.6962532",
"0.6896101",
"0.689492",
"0.68673736",
"0.6860177",
"0.679477",
"0.672956",
"0.6715738",
"0.6648282",
"0.6643447",
"0.6579241",
"0.6530701",
... | 0.8683444 | 0 |
Compute softmax values for each sets of scores in x. | def softmax(x):
return np.exp(x) / np.sum(np.exp(x), axis=1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(self, scores):\n\n\n # for each sample, for each class ,caclulate\n # np.exp(scores) : still (n_samples, n_classes)\n\n # axis = 1\n # a00, a01, a02 as a sinlge one to perfrom np_sum\n # which is the same sample \n # sum_exp : still (n_samples, 1)\n\n # ... | [
"0.7796294",
"0.7760558",
"0.7759004",
"0.77567077",
"0.76577055",
"0.76577055",
"0.76577055",
"0.76577055",
"0.7585655",
"0.743143",
"0.7407772",
"0.73941606",
"0.7358175",
"0.73174125",
"0.72689486",
"0.72623265",
"0.72614294",
"0.7256868",
"0.723019",
"0.7214918",
"0.72017... | 0.6979047 | 88 |
Testing providing a string instead of email | def test_failed_email(self):
self.assertEqual(send_email("testtestcom", "test", "test"), 'There was an error sending') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_email():\n assert is_email(None) is None\n assert is_email('test@example.com') is None\n assert is_email('other')",
"def test_is_valid_email(self):\n self.assertTrue(is_valid_email('abc@example.com'))",
"def test_email(self):\r\n \r\n self.assertEqual('maryc123@yahoo.com', self... | [
"0.7873138",
"0.7470895",
"0.74681914",
"0.7446869",
"0.72658867",
"0.72277725",
"0.7212912",
"0.72069514",
"0.71693593",
"0.71396536",
"0.7025685",
"0.70212555",
"0.7019924",
"0.7002416",
"0.6950605",
"0.6889759",
"0.6870627",
"0.6839101",
"0.6838109",
"0.682546",
"0.6815732... | 0.0 | -1 |
Given a username, returns ``True`` if it is valid, ``False`` if not. | def is_username_valid(username, min_length=2, max_length=25):
username_re = re.compile(r"^[\w_ ]+$")
if username_re.match(username):
return min_length <= len(username) <= max_length
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def username_is_valid(username: str) -> bool:\n pattern = re.compile(r'^[A-Za-z]+[A-Za-z0-9]*$')\n return pattern.match(username)",
"def validate_usr(username: str) -> bool:\n if MIN_USERNAME_LENGHT <= len(username) < MAX_USERNAME_LENGHT:\n return bool(re.search(ALLOWED_CHARACTERS_PATTERN... | [
"0.87550724",
"0.848177",
"0.83916444",
"0.8353001",
"0.8293428",
"0.8268191",
"0.82506466",
"0.8235913",
"0.82082295",
"0.81701857",
"0.8018828",
"0.79716665",
"0.7959811",
"0.7858905",
"0.7834735",
"0.7829715",
"0.7821553",
"0.77620655",
"0.7714279",
"0.75662714",
"0.755482... | 0.77089065 | 19 |
Get the current surface class. | def get_surface_class(self) -> SurfaceClassStr:
return SURFACE_CLASS.inverse[self.surfaceClass()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def specific_surface(self):\n srf = BRepAdaptor_Surface(self.topods_shape())\n surf_type = self.surface_type()\n if surf_type == \"plane\":\n return srf.Plane()\n if surf_type == \"cylinder\":\n return srf.Cylinder()\n if surf_type == \"cone\":\n ... | [
"0.6940537",
"0.6753206",
"0.66734993",
"0.6583985",
"0.65001476",
"0.64703465",
"0.64067113",
"0.6363636",
"0.621841",
"0.6144129",
"0.6113009",
"0.6091043",
"0.6063094",
"0.5925338",
"0.5849346",
"0.5816109",
"0.57847536",
"0.5735214",
"0.5735214",
"0.5709117",
"0.57045656"... | 0.8112508 | 0 |
Adds up all the numbers from 1 to the given n, and returns the sum. | def sum_to(n):
the_sum = 0
for counter in range(n+1):
the_sum = the_sum + counter
return the_sum | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_to_n(n):\n total = 0\n for i in range(1,n+1):\n total += i\n return total",
"def sumTo(n):\n\n sum_all = (n * (n+1))/2\n\n return sum_all",
"def sum(n):\n if n == 0:\n return 0\n return sum(n - 1) + n",
"def sumTo(n):\n \n the_sum = 0 #current sum\n a_numbe... | [
"0.86422515",
"0.84770644",
"0.83993167",
"0.83178717",
"0.81944203",
"0.7971606",
"0.79654896",
"0.79654896",
"0.7808245",
"0.77952695",
"0.74047834",
"0.7348683",
"0.7265785",
"0.7246132",
"0.7245896",
"0.7143377",
"0.7101615",
"0.7052252",
"0.7035835",
"0.70270216",
"0.702... | 0.8398175 | 3 |
Get a name of a file where image will be saved. | def _image_filename(image_name):
return '{}.tar'.format(image_name.replace(':', '_').replace('/', '_')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_image_filename(self, filename):\n path = 'images/{folder}/{filename}'.format(\n folder=self.folder,\n filename=filename\n )\n return path",
"def get_file_name(instance, filename):\n filename = make_unique_filename(filename)\n return os.path.join('uploads/profile_pics', filena... | [
"0.7593025",
"0.7573384",
"0.74126863",
"0.73232937",
"0.73180234",
"0.72829235",
"0.72784036",
"0.71705604",
"0.71384954",
"0.71143335",
"0.7087026",
"0.7046554",
"0.7043051",
"0.70252025",
"0.70225793",
"0.7006847",
"0.7004475",
"0.69837177",
"0.69768715",
"0.6968226",
"0.6... | 0.6671705 | 60 |
Missing docker images are checked slightly differently. | def _is_missing(self, item):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def images_exist(self):\n pass",
"def test_retag_valid_image(self):\n alpine = self.docker.images.get(constant.ALPINE)\n self.assertTrue(alpine.tag(\"demo\", \"rename\"))\n\n alpine = self.docker.images.get(constant.ALPINE)\n self.assertNotIn(\"demo:test\", alpine.tags)",
"de... | [
"0.697014",
"0.69207424",
"0.6907453",
"0.682817",
"0.68050957",
"0.6757396",
"0.6733495",
"0.6706203",
"0.6633923",
"0.66018957",
"0.659264",
"0.6581486",
"0.65381896",
"0.64963424",
"0.64760774",
"0.6420836",
"0.6418368",
"0.6377589",
"0.6354541",
"0.6337586",
"0.63139355",... | 0.0 | -1 |
Seek to an index in the string. | def seek(self, index: int, /) -> str:
self.index = index
return self.current | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def f_index(self, substring, direction=[]):\n substr = self.value(substring)\n if \"back\" in direction:\n pos = self._val.rfind(substr)\n else:\n pos = self._val.find(substr)\n\n return pos + 1",
"def findWithIndex(astring, achar, start):\n ix = start\n fo... | [
"0.70655054",
"0.6584507",
"0.6584507",
"0.6584507",
"0.6411309",
"0.6411309",
"0.62623453",
"0.60439265",
"0.60292536",
"0.60023504",
"0.59118515",
"0.58774793",
"0.5864663",
"0.57610536",
"0.5753554",
"0.57277644",
"0.5692792",
"0.56839126",
"0.5642636",
"0.5642636",
"0.564... | 0.6899866 | 1 |
Seeks to the previous character in the string. | def previous_character(self) -> str:
return self.seek(self.index - 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_forward(self):\n self.pos += 1\n if self.pos > len(self.text) - 1:\n self.current_char = None\n else:\n self.current_char = self.text[self.pos]",
"def prev_letter(letter, step):\r\n\r\n\tif letter in ascii_uppercase:\r\n\t\tnew_letter = get_new_letter(ascii_upp... | [
"0.67038774",
"0.6598808",
"0.6362795",
"0.63246745",
"0.62742394",
"0.6168036",
"0.61675936",
"0.60994065",
"0.6049407",
"0.6016162",
"0.5991858",
"0.5960641",
"0.5951857",
"0.5918674",
"0.59170574",
"0.58652633",
"0.58642596",
"0.58606976",
"0.5860314",
"0.5854177",
"0.5822... | 0.73601896 | 0 |
Counts the values in a series (with and without NaN, distinct). | def describe_counts_spark(
config: Settings, series: DataFrame, summary: dict
) -> Tuple[Settings, DataFrame, dict]:
value_counts = series.groupBy(series.columns).count()
value_counts = value_counts.sort("count", ascending=False).persist()
value_counts_index_sorted = value_counts.sort(series.columns[0]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def null_count(df):\n return df.isnull().sum().sum()",
"def count_placeholders(series):\n count = 0\n\n for i in range(series.size-1, -1, -1):\n if pd.isnull(series[i]) or series[i] == 0:\n count += 1\n else:\n break\n\n return count",
"def num_of_values(self):\n... | [
"0.7161416",
"0.6763747",
"0.6756556",
"0.6741333",
"0.6567011",
"0.6462748",
"0.64428264",
"0.64289254",
"0.64143026",
"0.63933873",
"0.63796043",
"0.6259558",
"0.6249989",
"0.607757",
"0.5947638",
"0.5892466",
"0.5888748",
"0.58702946",
"0.5833963",
"0.5820804",
"0.580511",... | 0.566218 | 25 |
_dedent(text, tabsize=8, skip_first_line=False) > dedented text "text" is the text to dedent. "tabsize" is the tab width to use for indent width calculations. "skip_first_line" is a boolean indicating if the first line should be skipped for calculating the indent width and for dedenting. This is sometimes useful for do... | def _dedent(text, tabsize=8, skip_first_line=False):
lines = text.splitlines(1)
_dedentlines(lines, tabsize=tabsize, skip_first_line=skip_first_line)
return ''.join(lines) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _dedent(text, tabsize=8, skip_first_line=False):\r\n lines = text.splitlines(1)\r\n _dedentlines(lines, tabsize=tabsize, skip_first_line=skip_first_line)\r\n return ''.join(lines)",
"def _dedentlines(lines, tabsize=8, skip_first_line=False):\r\n DEBUG = False\r\n if DEBUG:\r\n print(\"d... | [
"0.88707983",
"0.7607369",
"0.7596267",
"0.6904678",
"0.6879578",
"0.60991114",
"0.6098553",
"0.57050645",
"0.57050645",
"0.56979847",
"0.56303126",
"0.562045",
"0.55621105",
"0.55621105",
"0.53679353",
"0.51927364",
"0.51602703",
"0.5153548",
"0.5102171",
"0.50520265",
"0.50... | 0.8882523 | 0 |
_indent(s, [width=4]) > 's' indented by 'width' spaces The optional "skip_first_line" argument is a boolean (default False) indicating if the first line should NOT be indented. | def _indent(s, width=4, skip_first_line=False):
lines = s.splitlines(1)
indentstr = ' '*width
if skip_first_line:
return indentstr.join(lines)
else:
return indentstr + indentstr.join(lines) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indent(text, first_line=True, n=1, width=4):\n lines = text.split(\"\\n\")\n if not first_line:\n first = lines[0]\n lines = lines[1:]\n\n spaces = \" \" * (width * n)\n lines2 = [spaces + x for x in lines]\n\n if not first_line:\n lines2.insert(0, first)\n\n indented = \... | [
"0.7382324",
"0.66228735",
"0.6367907",
"0.63530266",
"0.6274042",
"0.6265277",
"0.622803",
"0.61960614",
"0.61186856",
"0.610532",
"0.6075138",
"0.595945",
"0.5947851",
"0.5906655",
"0.5866961",
"0.5790784",
"0.5754298",
"0.5698997",
"0.5698777",
"0.56976795",
"0.5688324",
... | 0.8882236 | 0 |
Create an organization and return the json response containing it | def post(self):
try:
# Create the organization
if request.headers['Content-Type'] == "application/json":
payload = request.get_json(silent=True)
elif request.form:
payload = request.data.to_dict()
else:
payload = req... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(self):\n request_user = User.get_by_id(token_auth.current_user())\n if request_user.role != 1:\n return {\n \"Error\": \"Only admin users can create organisations.\",\n \"SubCode\": \"OnlyAdminAccess\",\n }, 403\n\n try:\n ... | [
"0.7523657",
"0.742101",
"0.7320478",
"0.7082423",
"0.7034733",
"0.7020035",
"0.68885875",
"0.67146915",
"0.66803795",
"0.66376466",
"0.6627397",
"0.64501476",
"0.63610953",
"0.6284739",
"0.62055194",
"0.616251",
"0.6159382",
"0.6159382",
"0.6159382",
"0.6001103",
"0.59999955... | 0.8167164 | 0 |
Update an organization given its id. | def put(self, organization_id):
if organization_id is not None:
try:
org = Organization.query.filter_by(id=organization_id).first()
# return a 404 if org does not exist
abort(404) if org is None else org
if request.headers['Content-Typ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, request, pk=None):\n serializer = OrganizationUpdateBody(data=request.data)\n if serializer.is_valid(raise_exception=True):\n name = serializer.validated_data.get(\"name\")\n # agents = serializer.validated_data.get(\"agents\")\n # network = serialize... | [
"0.7486717",
"0.7062844",
"0.70367706",
"0.70263654",
"0.70088565",
"0.6960643",
"0.6767696",
"0.6767696",
"0.67667556",
"0.6715148",
"0.66322166",
"0.63672864",
"0.61431813",
"0.6114204",
"0.5910308",
"0.5910308",
"0.5910308",
"0.58583665",
"0.58169955",
"0.5816326",
"0.5783... | 0.7801741 | 0 |
Reads txt/smifile with SMILES\n on a string | def load_dataset(input_path):
with open(input_path, "r") as f:
smiles_list = f.read().strip().split("\n")
return smiles_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ReadMolFromSmile(smi=\"\"):\n mol = Chem.MolFromSmiles(string.strip(smi))\n \n return mol",
"def _read_string(data):\n lines = [l for l in data.split('\\n') if l.rstrip()]\n\n total_atoms = int(lines[0])\n\n comment = lines[1]\n\n positions = []\n atoms = []\n for i in range(2,... | [
"0.62279963",
"0.5964848",
"0.5963618",
"0.5881921",
"0.5807991",
"0.5591528",
"0.5580217",
"0.5530603",
"0.5501647",
"0.54731435",
"0.54567754",
"0.5404789",
"0.5387821",
"0.53800833",
"0.53638506",
"0.5362583",
"0.5340843",
"0.53290594",
"0.5323835",
"0.532353",
"0.5321366"... | 0.0 | -1 |
Return the global region class. | def get_regions(self):
if self.initiated is False:
raise RuntimeError("Initiate first")
return self.R | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def region(cls):\n return cls.REGION",
"def region(self):\n # type: () -> string_types\n return self._region",
"def region(self):\n return regions.lookup(self.state)",
"def region(self) -> str:\n return self.__region",
"def region(self):\n return self.config.region... | [
"0.7426655",
"0.6819321",
"0.6773036",
"0.6606111",
"0.6602732",
"0.6599282",
"0.6599282",
"0.6522798",
"0.64703244",
"0.63827777",
"0.63560957",
"0.63377374",
"0.6311484",
"0.6302464",
"0.6302464",
"0.6302464",
"0.6302464",
"0.6302464",
"0.6302464",
"0.61703664",
"0.61649543... | 0.63666826 | 10 |
Return the region dict (mostly internal). | def get_region_dict(self):
if self.initiated is False:
raise RuntimeError("Initiate first")
return self._region_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def regions_dict(self):\n regions_dict = dict()\n for i, r in enumerate(self.regions):\n regions_dict[getattr(r, 'ix', i)] = r\n return regions_dict",
"def region(self):\n return regions.lookup(self.state)",
"def region(self):\n return self._get(\"region\")",
"de... | [
"0.79705006",
"0.74118066",
"0.71905404",
"0.70989037",
"0.704352",
"0.704352",
"0.6983471",
"0.69118",
"0.68856114",
"0.6874822",
"0.68674123",
"0.6849244",
"0.67738456",
"0.6768203",
"0.67551106",
"0.6751231",
"0.6734139",
"0.6731087",
"0.665594",
"0.6516592",
"0.650879",
... | 0.81845945 | 0 |
Load the best checkpoint saved by a BestCheckpointSaverHook during a MonitoredSession. | def restore_best_checkpoint(session, ckpt_dir):
try:
evals_file = os.path.join(ckpt_dir, EVALUATIONS_FILE)
f = open(evals_file)
evals = json.load(f)
best_ckpt = max(evals, key=lambda e: e['accuracy'])
except Exception as e:
raise Exception('Error reading evaluations summ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_checkpoint(self):\n checkpoin_path = self.get_checkpoint_path()\n _logger.info('Load checkpoint ignored by tuner, checkpoint path: %s', checkpoin_path)",
"def load_checkpoint(self):\n if self.params.resume_from is not None and os.path.exists(self.params.resume_from):\n tr... | [
"0.7107283",
"0.6884053",
"0.6828325",
"0.6803193",
"0.675947",
"0.67451423",
"0.6731007",
"0.6710823",
"0.6709095",
"0.6602595",
"0.659301",
"0.6552964",
"0.65293235",
"0.6523743",
"0.65156996",
"0.64919084",
"0.64845043",
"0.64092004",
"0.637602",
"0.63294333",
"0.6327711",... | 0.664365 | 9 |
Return a ConfigProto configuration to not exhaust all the gpu memory | def default_config_proto():
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
return config | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config():\n config = tf.ConfigProto(allow_soft_placement=True)\n config.gpu_options.allow_growth = True\n return config",
"def get_config():\n config = tf.ConfigProto(allow_soft_placement=True)\n config.gpu_options.allow_growth=True\n return config",
"def create_config_proto(params):\... | [
"0.75489813",
"0.74897385",
"0.7171399",
"0.66392475",
"0.6516784",
"0.65061384",
"0.646011",
"0.63833255",
"0.61220986",
"0.608668",
"0.6066299",
"0.5968296",
"0.5933964",
"0.59100455",
"0.5845355",
"0.58299375",
"0.58222497",
"0.58046764",
"0.57735336",
"0.5759234",
"0.5703... | 0.7578824 | 0 |
Test case for delete_small_and_light_enrollment_by_seller_sku | def test_delete_small_and_light_enrollment_by_seller_sku(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_put_small_and_light_enrollment_by_seller_sku(self):\n pass",
"def test_get_small_and_light_enrollment_by_seller_sku(self):\n pass",
"def test_get_small_and_light_eligibility_by_seller_sku(self):\n pass",
"def test_delete_risk_profile_using_delete(self):\n pass",
"def te... | [
"0.81568635",
"0.78494626",
"0.7095789",
"0.6335945",
"0.6234111",
"0.61954796",
"0.6189981",
"0.6095135",
"0.6024793",
"0.59739256",
"0.5949117",
"0.5835822",
"0.5784029",
"0.5735453",
"0.571558",
"0.57107663",
"0.57062465",
"0.57018226",
"0.5681539",
"0.5671613",
"0.5671613... | 0.9662477 | 0 |
Check if the heap is empty. | def empty(heap):
return size(heap) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self):\n return self.heap_size <= 0",
"def is_empty(self) -> bool:\n return self.heap.length() == 0",
"def is_empty(self) -> bool:\n return self.heap.length() == 0",
"def is_empty(self):\n return len(self.__heap) == 0",
"def empty(self):\n return 0 >= len(sel... | [
"0.89089084",
"0.8879687",
"0.8879687",
"0.88671917",
"0.8592668",
"0.85500616",
"0.8512059",
"0.8028506",
"0.77420723",
"0.7731579",
"0.7708319",
"0.7698745",
"0.7691582",
"0.7657461",
"0.76529235",
"0.7627191",
"0.76019",
"0.75931704",
"0.7591967",
"0.75863975",
"0.7581968"... | 0.8910506 | 0 |
Swaps nodes i and j in heap. | def _swap(heap, i, j):
heap[i], heap[j] = heap[j], heap[i] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _swap(self, i, j):\n tmp = self._heap[i]\n self._heap[i] = self._heap[j]\n self._index[self._heap[j].key] = i\n self._heap[j] = tmp\n self._index[tmp.key] = j",
"def swap(self, i, j):\n swap = self.heap[i]\n self.heap[i] = self.heap[j]\n self.heap[j] = ... | [
"0.82078445",
"0.8107933",
"0.7047677",
"0.6927683",
"0.6902142",
"0.6845641",
"0.67761534",
"0.6747454",
"0.67451966",
"0.67352587",
"0.6698027",
"0.66948825",
"0.661552",
"0.65709573",
"0.65709573",
"0.6558617",
"0.6557945",
"0.65213096",
"0.6508577",
"0.64980036",
"0.64972... | 0.8090816 | 2 |
The _left child of a node. | def _left(node):
return 2 * node + 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_leftchild(self):\n return self._leftchild",
"def get_left(self):\n return self.__left",
"def getLeftChild(self):\n return _libsbml.ASTNode_getLeftChild(self)",
"def get_left(self):\n return self.left",
"def getLeft(self):\n return self.left",
"def left(self):\n\... | [
"0.89189017",
"0.83683443",
"0.8361554",
"0.83502847",
"0.8253393",
"0.81759244",
"0.81534445",
"0.81534445",
"0.81361735",
"0.8070665",
"0.80512935",
"0.80512935",
"0.8048674",
"0.8007655",
"0.79517496",
"0.7921656",
"0.79186594",
"0.783884",
"0.77041",
"0.7618256",
"0.76174... | 0.7842372 | 17 |
The right child of a node. | def _right(node):
return 2 * node + 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_rightchild(self):\n return self._rightchild",
"def getRightChild(self):\n return _libsbml.ASTNode_getRightChild(self)",
"def rightChild(self, pos):\n return (2 * pos) + 1",
"def rightChild(self, pos):\n return (2 * pos) + 1",
"def right_child(self, pos): \n ... | [
"0.85841835",
"0.8376527",
"0.8134612",
"0.8134612",
"0.78770083",
"0.7782154",
"0.7739479",
"0.7647694",
"0.7628607",
"0.7625631",
"0.7620159",
"0.7613046",
"0.7549176",
"0.7535326",
"0.74863183",
"0.74809754",
"0.74809754",
"0.74684775",
"0.7448042",
"0.737775",
"0.7314609"... | 0.7528211 | 14 |
Generates a URL for downloading the content of the handle. Returns ``None`` if not supported by the storage backend. | def download_link(self, handle):
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download(handle):\n storage = get_storage()\n # FIXME: 404 if not found or invalid?\n return storage.route(handle)",
"def getDownloadLink(self):\n context = aq_inner(self.context)\n type = context.file.getContentType()\n extension = ''\n \n if BLOB_SUPPORT:\n ... | [
"0.7226953",
"0.7028878",
"0.6286543",
"0.6254256",
"0.62152123",
"0.619817",
"0.6057522",
"0.6050053",
"0.59807736",
"0.59378654",
"0.59365124",
"0.59328127",
"0.5928464",
"0.59131986",
"0.59041727",
"0.58889925",
"0.58357495",
"0.58259",
"0.581367",
"0.58108217",
"0.5798754... | 0.70916146 | 1 |
Wrapper task for Helm Chart installations that makes sure the cluster is running and the Kubernetes API is up before the Helm Chart installations. | def cluster_post_deploy_steps(
auth_context_serialized,
cluster_external_id,
job_id,
job,
helm_charts,
waiters
):
try:
auth_context = AuthContext.deserialize(auth_context_serialized)
except TypeError:
cluster_post_deploy_steps.logger.error(
"Invalid serialized... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_helm(release):\n # First check the helm client and server versions\n client_helm_cmd = [\"helm\", \"version\", \"-c\", \"--short\"]\n client_version = (\n subprocess.check_output(client_helm_cmd)\n .decode(\"utf-8\")\n .split(\":\")[1]\n .split(\"+\")[0]\n .str... | [
"0.6232886",
"0.60631895",
"0.57473356",
"0.5731931",
"0.56088066",
"0.5573651",
"0.5523938",
"0.5493744",
"0.5493669",
"0.52937895",
"0.5293117",
"0.52891785",
"0.52582616",
"0.5228172",
"0.5208213",
"0.5199925",
"0.51837754",
"0.51832837",
"0.5173456",
"0.51381457",
"0.5129... | 0.5761329 | 2 |
Return features, labels and files at given indices | def get_data(features, labels_aud, labels_foc, files, indices):
features = [features[idx] for idx in indices]
labels_aud = [labels_aud[idx] for idx in indices]
labels_foc = [labels_foc[idx] for idx in indices]
files = [files[idx] for idx in indices]
return features, labels_aud, labels_foc, files | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_frame_with_index(self, indices: Union[List[int], List[List[int]]]) -> Tuple[Union[List[np.ndarray], List[List[np.ndarray]]], List[int]]:\n if isinstance(indices, int):\n indices = [indices]\n img_list = []\n if self.frame_zip_fid is None:\n self._check_available(s... | [
"0.6373018",
"0.6190452",
"0.6190315",
"0.6082126",
"0.5887073",
"0.58633184",
"0.5824866",
"0.58188814",
"0.579826",
"0.57432526",
"0.573198",
"0.5674371",
"0.56725335",
"0.5662636",
"0.5625809",
"0.5625635",
"0.5604566",
"0.55969304",
"0.5552838",
"0.55501485",
"0.55094665"... | 0.76458377 | 0 |
Return HTML file which was python formatted on startup. | def index(self):
return self.html | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def html_template_file(self):\n pass",
"def config_html(output_file=''):\n if output_file:\n f = open(output_file, 'w')\n else:\n f = sys.stdout\n create_config_html(f)",
"def main():\n return render_template(\"main.html\")",
"def main():\n return render_template(\"main.ht... | [
"0.6853076",
"0.6358319",
"0.63302296",
"0.63302296",
"0.6280444",
"0.625199",
"0.6236129",
"0.617955",
"0.61750114",
"0.61750114",
"0.6103522",
"0.61016273",
"0.60956293",
"0.59927154",
"0.5969963",
"0.59304684",
"0.5918464",
"0.5914396",
"0.58902866",
"0.5884376",
"0.586888... | 0.5538707 | 56 |
Create error for invalid config file value. | def __init__(self, yaml_file_path, key, expected):
super().__init__()
self.yaml_file_path = yaml_file_path
self.key = key
self.expected = expected | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_validate_failure_bad_config(self, value):\n sch = scheme.Scheme()\n with pytest.raises(errors.SchemeValidationError):\n sch.validate(value)",
"def test_configurations_create_invalid_value_type(self):\n values = '{\"key_buffer_size\": \"this is a string not int\"}'\n ... | [
"0.6809813",
"0.6687595",
"0.6509898",
"0.6441522",
"0.63705736",
"0.636918",
"0.63086057",
"0.62989855",
"0.62059045",
"0.62043536",
"0.61787826",
"0.61324435",
"0.61038285",
"0.60278314",
"0.6018091",
"0.59447783",
"0.5941696",
"0.5919477",
"0.59142005",
"0.59060806",
"0.59... | 0.0 | -1 |
Tokenize and then lemmatize the training data. | def tokenize(text):
tokens = word_tokenize(text)
lemmatizer = WordNetLemmatizer()
return [lemmatizer.lemmatize(token).lower().strip() for token in tokens] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lemmatize_fun(self):\n tokens = str(self.doc).split()\n cleaned_tokens = None\n if self.lemmatize_method == 'wordnet':\n cleaned_tokens = [self.lemmatizer.lemmatize(token) for token in tokens]\n else:\n cleaned_tokens = [self.lemmatizer.stem(token) for token in... | [
"0.75125813",
"0.72778785",
"0.72529864",
"0.7241408",
"0.72302824",
"0.7200522",
"0.71876407",
"0.7147698",
"0.70758665",
"0.70648676",
"0.69859993",
"0.69768494",
"0.69280076",
"0.687675",
"0.6871118",
"0.6821379",
"0.6800463",
"0.678686",
"0.6786675",
"0.67839015",
"0.6780... | 0.6903836 | 13 |
Creates an instance of this model from a dictionary | def from_dictionary(cls,
dictionary):
if dictionary is None:
return None
# Extract variables from the dictionary
wan_enabled = dictionary.get('wanEnabled')
using_static_ip = dictionary.get('usingStaticIp')
static_ip = dictionary.get('s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dictionary(cls,\n dictionary):\n if dictionary is None:\n return None\n\n # Extract variables from the dictionary\n id = dictionary.get('id')\n name = dictionary.get('name')\n mtype = dictionary.get('type')\n usage_bytes = diction... | [
"0.83181584",
"0.8168118",
"0.8168118",
"0.8118749",
"0.8089047",
"0.79787344",
"0.7949278",
"0.79231393",
"0.7898951",
"0.78923255",
"0.788838",
"0.7882321",
"0.7882212",
"0.7876749",
"0.78585315",
"0.7836853",
"0.7801407",
"0.7801407",
"0.7801407",
"0.7801407",
"0.7801407",... | 0.0 | -1 |
Creates a translation matrix where the rotation component is an identity matrix and the last column minus the last row is the given translation vector | def fromTranslation(cls, rows, cols, vector):
data = np.eye(rows, cols)
data[0:rows - 1, cols - 1] = vector[0:rows - 1]
return cls.create(rows, cols, data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_translation_matrix(translation_vector):\r\n T = torch.zeros(translation_vector.shape[0], 4, 4).to(device=translation_vector.device)\r\n\r\n t = translation_vector.contiguous().view(-1, 3, 1)\r\n\r\n T[:, 0, 0] = 1\r\n T[:, 1, 1] = 1\r\n T[:, 2, 2] = 1\r\n T[:, 3, 3] = 1\r\n T[:, :3, 3,... | [
"0.7297545",
"0.70872116",
"0.6925935",
"0.6893844",
"0.6847869",
"0.67990386",
"0.679691",
"0.6690128",
"0.668771",
"0.6618402",
"0.659717",
"0.6592675",
"0.6578762",
"0.65200657",
"0.6487062",
"0.6465503",
"0.6439747",
"0.6431303",
"0.63391334",
"0.63013124",
"0.6301061",
... | 0.6764617 | 7 |
Creates 3x3 translation matrix | def fromTranslation(cls, vector):
return super().fromTranslation(3, 3, vector) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matrix_translate_3d(tx: float, ty: float, tz: float) -> np.matrix:\n return np.matrix([[1, 0, 0, tx], [0, 1, 0, ty], [0, 0, 1, tz], [0, 0, 0, 1]])",
"def TranslationMatrix(x, y, z):\n\treturn np.matrix([ [1., 0., 0., x],\n\t\t\t\t\t\t[0., 1., 0., y],\n\t\t\t\t\t\t[0., 0., 1., z],\n\t\t\t\t\t\t[0., 0., 0.... | [
"0.8057956",
"0.765576",
"0.72426444",
"0.7069691",
"0.69821876",
"0.6871377",
"0.68281144",
"0.6691298",
"0.667849",
"0.66569364",
"0.6641082",
"0.6620099",
"0.65846276",
"0.65529895",
"0.652514",
"0.6509025",
"0.6420653",
"0.6376981",
"0.6374031",
"0.6372232",
"0.63688344",... | 0.0 | -1 |
Test specifying both plaintext and anoncrypt raises an error. | def test_plaintext_and_anoncrypt_raises_error(alice):
with pytest.raises(ValueError):
alice.pack({"test": "test"}, plaintext=True, anoncrypt=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_password_is_okay():\n\twith pytest.raises(Exception):\n\t\tassert password_is_ok('qqqqqqqq') == Exception('Password either has to contain a digit \\n or password has to contain uppercase \\n or password has to contain lowercase') \n\n\twith pytest.raises(Exception):\n\t\tassert password_is_ok('') == Ex... | [
"0.6626148",
"0.64805645",
"0.63252807",
"0.6215728",
"0.61947864",
"0.6187912",
"0.6176312",
"0.61632806",
"0.6101429",
"0.6081268",
"0.607704",
"0.60640734",
"0.6059558",
"0.6057419",
"0.6031116",
"0.6027076",
"0.60103947",
"0.59997976",
"0.59850866",
"0.5983449",
"0.596760... | 0.80658644 | 0 |
Test that bad input raises an error in pack. | def test_bad_input(alice):
with pytest.raises(TypeError):
alice.pack("blah") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_plaintext_and_anoncrypt_raises_error(alice):\n with pytest.raises(ValueError):\n alice.pack({\"test\": \"test\"}, plaintext=True, anoncrypt=True)",
"def test_only_nums_are_valid_inputs():\n bad_inputs = [[\"boop\", \"boink\"], 10, 99.99, {\"one\": 2, \"three:\": 4}]\n\n for input in bad_... | [
"0.6785054",
"0.6671001",
"0.6634966",
"0.65975827",
"0.6596685",
"0.6586108",
"0.64995915",
"0.64596045",
"0.6450375",
"0.6423519",
"0.6421",
"0.6401903",
"0.63772976",
"0.63745713",
"0.63497865",
"0.63372016",
"0.6304835",
"0.6272554",
"0.6255333",
"0.6247975",
"0.6233128",... | 0.8262003 | 0 |
Helper function for setup_display. Gets the y values used for sprites and labels. | def _get_y(self):
enabled = self.num_enabled
if self.heart_enabled:
self._heart_y = 45*(self.num_enabled - enabled) + 75
enabled -= 1
if self.speed_enabled:
self._speed_y = 45*(self.num_enabled - enabled) + 75
enabled -= 1
if self.cadence_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getYLabel(self): \n return self.__y_label__",
"def getY(self):\n return self.labels[0]",
"def get_y_position(self): \n return self.rect.y",
"def getY(self):\n y = self.getAttribute('y')\n kind = self.getKind()\n self._y = y if kind == 'pie' else Non... | [
"0.71614933",
"0.7016046",
"0.6965464",
"0.68591505",
"0.68126625",
"0.67518663",
"0.67363936",
"0.673337",
"0.6729146",
"0.6716376",
"0.6713041",
"0.6693623",
"0.6683546",
"0.6669925",
"0.66516244",
"0.66448516",
"0.66130483",
"0.66130483",
"0.6608026",
"0.65835226",
"0.6574... | 0.6801246 | 5 |
Basic conv transpose block for EncoderDecoder upsampling Apply successivly Transposed Convolution, BatchNormalization, ReLU nonlinearity Dropout (if dropout_p > 0) on the inputs | def conv_transpose_block(inputs, n_filters, strides=2, filter_size=[3, 3], dropout_p=0.0):
conv = slim.conv2d_transpose(inputs, n_filters, kernel_size=[3, 3], stride=[strides, strides])
out = tf.nn.relu(slim.batch_norm(conv, fused=True))
if dropout_p != 0.0:
out = slim.dropout(out, keep_prob=(1.0-dropout_p))
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_conv2d_transpose(g, op, block):\n\n dilations = op.attr(\"dilations\")\n groups = op.attr(\"groups\")\n paddings = op.attr(\"paddings\")\n padding_algorithm = op.attr(\"padding_algorithm\")\n strides = op.attr(\"strides\")\n output_padding = op.attr(\"output_padding\") if op.attr(\"ou... | [
"0.697245",
"0.6691039",
"0.650871",
"0.6439992",
"0.64227986",
"0.6393624",
"0.6351175",
"0.63310295",
"0.6313312",
"0.62897885",
"0.624936",
"0.61941874",
"0.6164377",
"0.6155109",
"0.6139118",
"0.61381185",
"0.61238414",
"0.6121921",
"0.60931706",
"0.60586005",
"0.6045268"... | 0.72000855 | 0 |
Test the json representation of a post. | def test_json():
post = Post("Test", "Test Content")
expected = {"title": "Test", "content": "Test Content"}
assert expected == post.json() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_can_get_a_post(self):\n post = Post.objects.get()\n response = self.client.get(\n '/posts/',\n kwargs={'pk':post.id},\n format=\"json\")\n self.assertEqual(response.status_code, status.HTTP_200_OK)\n self.assertContains(response, post)",
"... | [
"0.7133487",
"0.7045969",
"0.6908458",
"0.690201",
"0.6847445",
"0.68193924",
"0.68150914",
"0.67852795",
"0.67840844",
"0.67555714",
"0.67237043",
"0.67217",
"0.6701304",
"0.6691027",
"0.66851455",
"0.6522594",
"0.6520674",
"0.6417234",
"0.64073133",
"0.6396351",
"0.63872904... | 0.81980187 | 0 |
Check if the event's start time matches the item's. Return boolean. | def verify_event_timing(self, event, item):
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_time(self):\n return isinstance(self._start, datetime.datetime)",
"def is_happening(self):\n now = timezone.now()\n start = self.start\n end = self.end\n happening = False\n # check that the event has started and 'now' is btwn start & end:\n ... | [
"0.6975422",
"0.66054183",
"0.6494262",
"0.6428087",
"0.642161",
"0.64131373",
"0.63386387",
"0.6337101",
"0.63358307",
"0.62497884",
"0.62067556",
"0.6199338",
"0.6180189",
"0.61643386",
"0.6161433",
"0.6107592",
"0.6094647",
"0.6058391",
"0.6030316",
"0.60102373",
"0.599166... | 0.71227425 | 0 |
This method takes a piece that is moving and it's target position and calculates a list of positions that will be killed as a result of the move. This may include the moving piece itself. | def _get_killed_positions(self, moving_piece: Piece,
moving_piece_target_pos: Pos2D) -> List[Pos2D]:
killed_positions: List[Pos2D] = []
# Short for 'horizontally adjacent squares'.
x_adjacent: List[Square] = \
self._get_adjacent_squares(moving_pie... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_piece_moves(self, x, y):\n\n piece = self.get_piece(x, y)\n moves = []\n\n if not piece:\n return moves\n\n if piece.name == 'rook' or piece.name == 'queen':\n direcs = ['up', 'down', 'left', 'right']\n moves = [self._get_moves_indirection(x, y,... | [
"0.69673157",
"0.67096883",
"0.6637244",
"0.66304064",
"0.6425006",
"0.64143676",
"0.63872766",
"0.6338977",
"0.62747025",
"0.62301934",
"0.6184197",
"0.61503106",
"0.61457855",
"0.6079487",
"0.60390174",
"0.60271317",
"0.6026108",
"0.6017297",
"0.6003197",
"0.59989256",
"0.5... | 0.81791925 | 0 |
Returns a string representation of the calling instance. | def __str__(self) -> str:
output: str = ""
for row_i in range(Board._NUM_ROWS):
for col_i in range(Board._NUM_COLS):
pos: Pos2D = Pos2D(col_i, row_i)
output += ("{} ".format(self.squares[pos].get_representation()))
# Finished row, add new l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\r\n return self.__call__()",
"def __repr__(self):\n return \"%s()\" % self.__class__.__name__",
"def __repr__(self) -> str:\n return '{:s}({!r})'.format(self.__class__.__name__, self.getvalue())",
"def __repr__(self) -> str:\n return '{:s}({!r})'.format(self.__c... | [
"0.74466985",
"0.7336027",
"0.7324443",
"0.7324443",
"0.7324443",
"0.7314546",
"0.72618866",
"0.7247871",
"0.7201232",
"0.71701795",
"0.7153627",
"0.71504843",
"0.7149131",
"0.71294445",
"0.7095928",
"0.7095766",
"0.7095676",
"0.70822376",
"0.70762086",
"0.70567167",
"0.70567... | 0.0 | -1 |
Returns a deep copy of the calling instance. Necessary in order to ensure that different boards don't reference the same Square objects in memory. | def __deepcopy__(self, memodict={}) -> 'Board':
squares: Dict[Pos2D, Square] = deepcopy(self.squares)
round_num: int = self.round_num
phase: GamePhase = self.phase
winner: PlayerColor = self.winner
return Board(squares, round_num, phase, winner) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self):\r\n copy_board = Board(self._squareCount, self._pebbleCount)\r\n copy_board.squares = [list(row) for row in self.squares]\r\n return copy_board",
"def copy(self):\n cpy = deepcopy(self)\n # usually we use copy to perform transformations on the board\n # s... | [
"0.79875356",
"0.7862403",
"0.75832826",
"0.7487682",
"0.74024564",
"0.7397676",
"0.7322469",
"0.72719944",
"0.71431047",
"0.70793575",
"0.70669377",
"0.70513177",
"0.69926137",
"0.6985331",
"0.69417846",
"0.69417846",
"0.69414145",
"0.6935467",
"0.6918855",
"0.69089544",
"0.... | 0.77543133 | 2 |
This method initializes all square objects for a complete board as if it were the beginning of the game. | def _init_squares() -> Dict[Pos2D, Square]:
squares: Dict[Pos2D, Square] = {}
for col_i in range(Board._NUM_COLS):
for row_i in range(Board._NUM_ROWS):
pos: Pos2D = Pos2D(col_i, row_i)
if (pos.x == 0 and (
pos.y == 0 or pos.y ==... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self._board = []\n for i in range(10):\n self._board.append([None for i in range(9)])\n self.place_pieces()",
"def initial_board():\n board = [OUTER] * 100\n for i in Othello.squares():\n board[i] = EMPTY\n # The middle four sq... | [
"0.73076403",
"0.72631305",
"0.7259778",
"0.72589505",
"0.7208998",
"0.7199456",
"0.71809864",
"0.7170172",
"0.7094808",
"0.7076817",
"0.6982997",
"0.69385415",
"0.6922156",
"0.69116414",
"0.6903873",
"0.6889334",
"0.6879392",
"0.6879392",
"0.6879392",
"0.68661815",
"0.685348... | 0.6272461 | 97 |
Performs nonmaximum suppression on a boxlist. The ranking scores are specified in a boxlist field via score_field. | def boxlist_nms(boxlist, nms_thresh, max_proposals=-1, score_field="scores"):
if nms_thresh <= 0:
return boxlist
mode = boxlist.mode
boxlist = boxlist.convert("xyxy")
boxes = boxlist.bbox
score = boxlist.get_field(score_field)
keep = _box_nms(boxes, score, nms_thresh)
if max_proposal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def greedyNonMaximumSupression(boxlist,clipthresh=0.05,IOUthresh=0.5):\r\n NMSed_list=[]\r\n if len(boxlist)==0 or clipthresh>1:\r\n return NMSed_list\r\n \r\n # keep every box with largest score while doesn't overlap with all the other\r\n # boxes\r\n NMSed_list.append(boxlist[0])\r\n ... | [
"0.687446",
"0.6752846",
"0.6748554",
"0.6619577",
"0.6542218",
"0.65073025",
"0.64404565",
"0.63731503",
"0.62251544",
"0.616094",
"0.6149683",
"0.6056882",
"0.605002",
"0.60453826",
"0.59455067",
"0.5940545",
"0.5926563",
"0.5903152",
"0.5840305",
"0.57612646",
"0.5758822",... | 0.6780968 | 1 |
Only keep boxes with both sides >= min_size | def remove_small_boxes(boxlist, min_size):
# TODO maybe add an API for querying the ws / hs
xywh_boxes = boxlist.convert("xywh").bbox
_, _, ws, hs = xywh_boxes.unbind(dim=1)
keep = ((ws >= min_size) & (hs >= min_size)).nonzero().squeeze(1)
return boxlist[keep] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _filter_boxes(boxes, min_size):\n ws = boxes[:, 2] - boxes[:, 0] + 1\n hs = boxes[:, 3] - boxes[:, 1] + 1\n keep = np.where((ws >= min_size) & (hs >= min_size))[0]\n return keep",
"def _filter_boxes(boxes, min_size):\n ws = boxes[:, 2] - boxes[:, 0] + 1\n hs = boxes[:, 3] - boxes[:, 1] + 1\... | [
"0.8292327",
"0.8292327",
"0.82778513",
"0.823448",
"0.82263494",
"0.82224125",
"0.8012673",
"0.6646972",
"0.6528161",
"0.6382702",
"0.6295799",
"0.6295799",
"0.62554604",
"0.6229919",
"0.62291616",
"0.621005",
"0.620328",
"0.61907804",
"0.61548555",
"0.6110263",
"0.6107789",... | 0.7556005 | 7 |
Calculates the specified quantile across the sample. | def get_quantile_per_sample(df, quantile, base_column):
df = df.copy()
output = pd.DataFrame()
for unique_sample in df[base_column].unique():
object_df = df[df[base_column] == unique_sample]
output = output.append(object_df.quantile(quantile))
return output.sort_values(by=base_column) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_percentile(self, q):\n return self.sum_stat_sample_delta.get_percentile(q)",
"def get_percentile(self, q):\n return self.sum_stat_sample_ratio.get_percentile(q)",
"def quantile(self, hypercube):\n raise NotImplementedError()",
"def get_percentile(self, q):\n raise NotImple... | [
"0.7404899",
"0.7166998",
"0.710825",
"0.70242804",
"0.70190465",
"0.70168394",
"0.69650185",
"0.69650185",
"0.69142425",
"0.686119",
"0.679658",
"0.67602843",
"0.6688057",
"0.66742206",
"0.66742206",
"0.66742206",
"0.66575325",
"0.6598517",
"0.6598517",
"0.6598517",
"0.65469... | 0.67777663 | 11 |
Test a pipeline with a volume and volume mount. | def test_py_volume(self):
self._test_py_compile('volume') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_pipeline_basic(mockpipe, testdir):\n test = testdir.makepyfile(TEST_OK)\n result = testdir.inline_run(\n \"-v\",\n f\"--base-pipeline-dir={test.dirname}\",\n test\n )\n passed, skipped, failed = result.listoutcomes()\n\n assert len(passed) == 1\n assert len(skipped) ... | [
"0.616434",
"0.615829",
"0.6075627",
"0.5948916",
"0.58891016",
"0.5866036",
"0.58312035",
"0.58306247",
"0.5783069",
"0.57132804",
"0.55994606",
"0.55426395",
"0.54859644",
"0.54847157",
"0.54563177",
"0.54540217",
"0.5435708",
"0.54341084",
"0.54205114",
"0.5419053",
"0.539... | 0.59512293 | 3 |
Gets model status of the prediction. | def get_prediction_model_status(hub_name: Optional[str] = None,
prediction_name: Optional[str] = None,
resource_group_name: Optional[str] = None,
opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetPredictionModelSta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_prediction_model_status_output(hub_name: Optional[pulumi.Input[str]] = None,\n prediction_name: Optional[pulumi.Input[str]] = None,\n resource_group_name: Optional[pulumi.Input[str]] = None,\n ... | [
"0.71354663",
"0.6961648",
"0.6656483",
"0.6656483",
"0.6656483",
"0.6576668",
"0.6557602",
"0.6516778",
"0.6495045",
"0.64386725",
"0.6433557",
"0.6416671",
"0.6398391",
"0.63983107",
"0.638401",
"0.6353862",
"0.63295233",
"0.6309399",
"0.6307234",
"0.6269096",
"0.6269096",
... | 0.71804935 | 0 |
Gets model status of the prediction. | def get_prediction_model_status_output(hub_name: Optional[pulumi.Input[str]] = None,
prediction_name: Optional[pulumi.Input[str]] = None,
resource_group_name: Optional[pulumi.Input[str]] = None,
opts: Op... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_prediction_model_status(hub_name: Optional[str] = None,\n prediction_name: Optional[str] = None,\n resource_group_name: Optional[str] = None,\n opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetPrediction... | [
"0.71804935",
"0.6961648",
"0.6656483",
"0.6656483",
"0.6656483",
"0.6576668",
"0.6557602",
"0.6516778",
"0.6495045",
"0.64386725",
"0.6433557",
"0.6416671",
"0.6398391",
"0.63983107",
"0.638401",
"0.6353862",
"0.63295233",
"0.6309399",
"0.6307234",
"0.6269096",
"0.6269096",
... | 0.71354663 | 1 |
Converts a string into a list of numbers representing letters | def string_to_list(string):
al_dict = {'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7, 'i':8,
'j':9, 'k':10, 'l':11, 'm':12, 'n':13, 'o':14, 'p':15, 'q':16,
'r':17, 's':18, 't':19, 'u':20, 'v':21, 'w':22, 'x':23, 'y':24,
'z':25}
out = list(strin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def string_to_numbers(str):\n return [ord(ch) - ord(\"a\") for ch in str]",
"def alphanum_key(s):\n return [int(c) if c.isdigit() else c for c in re.split('([0-9]+)', s)]",
"def alphanum_key(s):\n return [int(c) if c.isdigit() else c for c in re.split('([0-9]+)', s)]",
"def alphanum_key(s):\n ret... | [
"0.7847252",
"0.72557956",
"0.72557956",
"0.7228709",
"0.72259396",
"0.72259396",
"0.72259396",
"0.72259396",
"0.71556175",
"0.714107",
"0.7081984",
"0.6965548",
"0.6888269",
"0.68727803",
"0.68543434",
"0.67607665",
"0.67233783",
"0.66633224",
"0.6662627",
"0.66514736",
"0.6... | 0.65805686 | 21 |
Return ybar associated with x's most violated constraint. The find most violated constraint function for margin rescaling. The default behavior is that this returns the value from the general find_most_violated_constraint function. | def find_most_violated_constraint_margin(self, x, y):
scores = np.zeros(self.num_classes)
#dotProd = np.zeros(self.num_classes)
Psi = self.psi(x, y)
for i in xrange(self.num_classes):
Psibar = self.psi(x, i)
deltaPsi = Psi-Psibar
#print Psi.shape
#print self.tempw.shape
scores[i] = loss(y, i) -... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_y_arg(self):\n return max((self(0).y,0), (self(1).y,1))[1]",
"def get_y_max(self):\n if len(self._statDict) == 0:\n return -1E10\n\n line_id_list = self._statDict.keys()\n max_y = self._statDict[line_id_list[0]][3]\n for i_plot in range(1, len(line_id_list)):... | [
"0.65256876",
"0.6383588",
"0.6297854",
"0.6295114",
"0.6248152",
"0.6169651",
"0.6077589",
"0.591088",
"0.58829266",
"0.5877548",
"0.58689237",
"0.5781577",
"0.5780249",
"0.5674909",
"0.5638617",
"0.56345457",
"0.5628929",
"0.5553416",
"0.5551641",
"0.5543589",
"0.55346787",... | 0.72795594 | 0 |
Generates a random string of SALT_CHARS with specified ``length``. | def gen_salt(length=10):
if length <= 0:
raise ValueError('requested salt of length <= 0')
return ''.join(choice(SALT_CHARS) for i in xrange(length)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_random_string(length: int):\n\tall_chars = string.ascii_letters + string.digits\n\treturn ''.join(random.choices(all_chars, k=length))",
"def generate_random_string(length = 30):\n\n m_available_chars = ascii_letters + digits\n\n return \"\".join(choice(m_available_chars) for _ in xra... | [
"0.8066662",
"0.8037013",
"0.8014298",
"0.80059946",
"0.79467416",
"0.789508",
"0.7835952",
"0.77983415",
"0.7797171",
"0.7797171",
"0.7792034",
"0.7763505",
"0.7758479",
"0.7742617",
"0.77258134",
"0.7702626",
"0.7684176",
"0.7679957",
"0.7672278",
"0.76685226",
"0.7654863",... | 0.82069516 | 0 |
Checks a password against a given hash value. Since many systems save md5 passwords with no salt and it's technically impossible to convert this to a sha hash with a salt we use this to be able to check for legacy plain | def check_password(pwhash, password):
if not pwhash or not password:
return False
if isinstance(password, unicode):
password = password.encode('utf-8')
if pwhash.count('$') < 2:
return False
method, salt, hashval = pwhash.split('$', 2)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkPassword(password, passwordHash):\n context = CryptContext(schemes=[encryption_algorithm])\n return context.verify(password, passwordHash)",
"def verify_password(password, password_hash):\n\n password_entered = hash_password(password)\n return secrets.compare_digest(password_entered, passwor... | [
"0.7751523",
"0.7621896",
"0.7594086",
"0.7552453",
"0.75010496",
"0.74814695",
"0.7460166",
"0.7438101",
"0.7435141",
"0.7399331",
"0.7399331",
"0.73582685",
"0.7322129",
"0.7307114",
"0.7282645",
"0.7260369",
"0.7260369",
"0.7260369",
"0.7260369",
"0.7241671",
"0.7212154",
... | 0.7621986 | 1 |
Get the current user from the database based on the user id set in the request's session. | def get_current_user(request):
if 'user-id' in request.session and hasattr(request, 'dbsession'):
return request.dbsession.query(User).filter(and_(User.id == request.session['user-id'],
User.status == 'active')).first()
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_user(self):\n user_dict = self.auth.get_user_by_session()\n return self.auth.store.user_model.get_by_id(user_dict['user_id'])",
"def current_user(self):\n user_dict = self.auth.get_user_by_session()\n if user_dict is None:\n logging.debug(\"User dict is None.\")\n ... | [
"0.8326218",
"0.82878757",
"0.8075175",
"0.78589547",
"0.78418934",
"0.78150624",
"0.7803486",
"0.7765672",
"0.77468425",
"0.77371264",
"0.7729427",
"0.76524574",
"0.76089513",
"0.76004755",
"0.75947124",
"0.7586172",
"0.75732476",
"0.7563298",
"0.7548379",
"0.75301737",
"0.7... | 0.82671255 | 2 |
Wraps `torchvision.models.inception_v3` Skips default weight inititialization if supported by torchvision version. | def _inception_v3(*args, **kwargs):
try:
version = tuple(map(int, torchvision.__version__.split('.')[:2]))
except ValueError:
version = 0,
if version >= (0, 6):
kwargs['init_weights'] = False
return torchvision.models.inception_v3(*args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inception_v3(pretrained=False, **kwargs):\n # if pretrained:\n # if 'transform_input' not in kwargs:\n # kwargs['transform_input'] = True\n # if 'aux_logits' in kwargs:\n # original_aux_logits = kwargs['aux_logits']\n # kwargs['aux_logits'] = True\n # el... | [
"0.7976556",
"0.7479957",
"0.7211667",
"0.6634807",
"0.6555188",
"0.6284876",
"0.60411614",
"0.60072994",
"0.5884922",
"0.58612376",
"0.56974065",
"0.5679707",
"0.56637484",
"0.5656607",
"0.56168896",
"0.5600849",
"0.55740166",
"0.5548657",
"0.5514927",
"0.548707",
"0.5486493... | 0.88927996 | 0 |
This method computes spectral normalization for all conv layers in parallel. This method should be called after calling the forward method of all the conv layers in each iteration. | def spectral_norm_parallel(self):
weights = {}
for l in self.all_conv_layers:
weight = l.weight_normalized
weight_mat = weight.view(weight.size(0), -1)
if weight_mat.shape not in weights:
weights[weight_mat.shape] = []
weights[weight_mat.sh... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_compute_spectral_norms(self):\n\t\tdetails = self.watcher.analyze(layers=[self.second_layer], pool=False, randomize=False, plot=False, mp_fit=False, svd_method=ACCURATE_SVD)\n\n\t\t# SLOW method\n\t\ta = details.spectral_norm.to_numpy()\n\t\tself.assertAlmostEqual(a[0],20.2149, places=3)\n\t\tself.assertA... | [
"0.6263727",
"0.6259124",
"0.6222577",
"0.6084011",
"0.60302836",
"0.59758145",
"0.5970428",
"0.5970428",
"0.5850054",
"0.5837462",
"0.58330727",
"0.5734735",
"0.5734735",
"0.5730407",
"0.5725395",
"0.57148135",
"0.57135767",
"0.5695094",
"0.5693623",
"0.5685546",
"0.5665583"... | 0.76211405 | 0 |
This function will open the url in browser and maximize it | def open_url(self, url):
try:
if url != "":
self.driver.maximize_window()
self.driver.get(url)
print(url + " : url is opened")
else:
print("Please enter valid url")
except Exception as e:
print(str(e)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open(url):\r\n webbrowser.open(url)",
"def newwindow(url):\n\n # Open the URL\n webbrowser.open_new(url)",
"def openurl(url):\n\n # Open the URL\n webbrowser.open(url)",
"def open_browser(url):\n import webbrowser\n webbrowser.open_new(url)",
"def open_in_browser(self):\n we... | [
"0.7347669",
"0.7170193",
"0.71404785",
"0.7088914",
"0.70653176",
"0.7030823",
"0.7019673",
"0.6931729",
"0.6888034",
"0.6787701",
"0.6739426",
"0.6716605",
"0.66835177",
"0.6668243",
"0.663655",
"0.6620144",
"0.65873307",
"0.6521996",
"0.64866555",
"0.6468926",
"0.6438249",... | 0.7208016 | 1 |
String for representing the Model object (in Admin site etc.) | def __str__(self):
return self.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return '%s%s' % (self.name, ' - %s' % self.model if self.model else '')",
"def __str__(self):\n model = self._meta.verbose_name.title()\n return f\"{model:s}: {self.name:s}\"",
"def __str_... | [
"0.7802202",
"0.7711799",
"0.7674433",
"0.7674433",
"0.752465",
"0.7403027",
"0.7398214",
"0.7378213",
"0.7327721",
"0.7271377",
"0.72439706",
"0.7235207",
"0.72073966",
"0.71746266",
"0.71665883",
"0.7110483",
"0.70384824",
"0.70384824",
"0.7012211",
"0.69870925",
"0.6968247... | 0.0 | -1 |
String for representing the model object (in Admin site etc.) | def __str__(self):
return self.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return '%s%s' % (self.name, ' - %s' % self.model if self.model else '')",
"def __str__(self):\n model = self._meta.verbose_name.title()\n return f\"{model:s}: {self.name:s}\"",
"def __str_... | [
"0.78066945",
"0.77119315",
"0.76349086",
"0.76349086",
"0.75804526",
"0.757928",
"0.7446873",
"0.74373364",
"0.7418256",
"0.7294505",
"0.72883445",
"0.72049195",
"0.72049195",
"0.71796703",
"0.71708316",
"0.7147078",
"0.71035784",
"0.7078311",
"0.7065632",
"0.70415115",
"0.7... | 0.0 | -1 |
String for representing the Model object. | def __str__(self):
return self.title | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return \"DataModel(name={},attributes={},description={})\".format(\n self.name, {a.name: str(a) for a in self.attributes}, self.description\n )",
"def __str__(self):\n \n res =... | [
"0.82368803",
"0.79901737",
"0.7849152",
"0.78468513",
"0.77520275",
"0.7625378",
"0.7625378",
"0.76225406",
"0.76225406",
"0.75483394",
"0.7522958",
"0.7470355",
"0.7469358",
"0.7447144",
"0.7447144",
"0.74314755",
"0.7427648",
"0.7389925",
"0.7351721",
"0.73424315",
"0.7322... | 0.0 | -1 |
Creates a string for the Genre. This is required to display genre in Admin. | def display_genre(self):
# Get first 3 genres and join to a string.
return ', '.join([ genre.name for genre in self.genre.all()[:3] ]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_genre(request):\n\tif request.method == \"POST\":\n\t\tform = GenreForm(request.POST)\n\t\tif form.is_valid():\n\t\t\tgenre = form.save(commit=False)\n\t\t\tgenre.save()\n\telse:\n\t\tform = GenreForm()\n\n\tgenres = Genre.objects.all()\n\tif genres:\n\t\tavailable_genre = parse_genres(genres)\n\t\tmessage... | [
"0.68393534",
"0.6691706",
"0.6685899",
"0.66391927",
"0.6590391",
"0.6586578",
"0.65841824",
"0.6565586",
"0.6549204",
"0.64926285",
"0.6376736",
"0.6343249",
"0.6290307",
"0.62804145",
"0.6139377",
"0.6097108",
"0.60841537",
"0.60435575",
"0.5983955",
"0.5960737",
"0.587684... | 0.6890127 | 0 |
String for representing the Model object. | def __str__(self):
return '%s (%s)' % (self.id, self.book.title) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return \"DataModel(name={},attributes={},description={})\".format(\n self.name, {a.name: str(a) for a in self.attributes}, self.description\n )",
"def __str__(self):\n \n res =... | [
"0.82368803",
"0.79901737",
"0.7849152",
"0.78468513",
"0.77520275",
"0.7625378",
"0.7625378",
"0.76225406",
"0.76225406",
"0.75483394",
"0.7522958",
"0.7470355",
"0.7469358",
"0.7447144",
"0.7447144",
"0.74314755",
"0.7427648",
"0.7389925",
"0.7351721",
"0.73424315",
"0.7322... | 0.0 | -1 |
String for representing the Model object. | def __str__(self):
return '%s, %s' % (self.last_name, self.first_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return \"DataModel(name={},attributes={},description={})\".format(\n self.name, {a.name: str(a) for a in self.attributes}, self.description\n )",
"def __str__(self):\n \n res =... | [
"0.82368803",
"0.79901737",
"0.7849152",
"0.78468513",
"0.77520275",
"0.7625378",
"0.7625378",
"0.76225406",
"0.76225406",
"0.75483394",
"0.7522958",
"0.7470355",
"0.7469358",
"0.7447144",
"0.7447144",
"0.74314755",
"0.7427648",
"0.7389925",
"0.7351721",
"0.73424315",
"0.7322... | 0.0 | -1 |
Steps for optimizer and lr scheduler | def optimizer_step(self, epoch, batch_idx, optimizer, optimizer_idx, second_order_closure=None):
# if self.trainer.use_tpu:
# xm.optimizer_step(optimizer)
# else:
# optimizer.step()
optimizer.step()
optimizer.zero_grad()
# need to define here to step afte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lr_scheduler(self, lr_init, global_step):\n pass",
"def step(self):\n\n self.compute_lr()\n\n self.optimizer.param_groups[self.param_group]['lr'] = self.lr\n self.optimizer.param_groups[self.param_group]['momentum'] = self.momentum",
"def step_and_update_lr(self):\r\n sel... | [
"0.7425612",
"0.7076409",
"0.69215924",
"0.685483",
"0.6792643",
"0.677404",
"0.66615546",
"0.6647706",
"0.66093737",
"0.6579639",
"0.6496551",
"0.64564264",
"0.64477265",
"0.6446155",
"0.64331245",
"0.6425555",
"0.6416218",
"0.6400999",
"0.6393877",
"0.6348875",
"0.63480556"... | 0.645745 | 11 |
Returns the pairwise squared distances between rows of the data matrix | def pairwise_squared_distances(data):
n = data.shape[0]
distances = np.zeros((n,n))
for i in range(n):
for j in range(i+1,n):
d = data[i,:]-data[j,:]
distances[i,j] = d@d
distances[j,i] = distances[i,j]
return distances | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pairwise_distances(data):\n distances = []\n for x in data:\n distances_row = []\n for y in data:\n distances_row.append(metric(x, y)**2)\n distances.append(distances_row)\n return distances",
"def distance_matrix(data):\n D = numpy.zeros( (data.shape[0], data.shap... | [
"0.72957367",
"0.7270368",
"0.693366",
"0.6584238",
"0.6531533",
"0.64993757",
"0.646974",
"0.6463756",
"0.64570934",
"0.6426268",
"0.64089936",
"0.64088273",
"0.63959026",
"0.63836116",
"0.63642585",
"0.6347011",
"0.63019377",
"0.62993807",
"0.6265769",
"0.6260977",
"0.62291... | 0.82672215 | 0 |
Returns the entropicallyregularized W2 distance between two couplings | def coupling_W2(coupling_1, coupling_2, source, target, epsilon):
cost_matrix = coupling_to_coupling_cost_matrix(source, target)
return ot.sinkhorn2(coupling_1.flatten(), coupling_2.flatten(), cost_matrix, epsilon) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_distance_2(pos1, pos2):\n\treturn (pos2[0] - pos1[0])**2 + (pos2[1] - pos1[1])**2",
"def distance(self, wn1, wn2):\n return abs(self.chunk_map[wn1] - self.chunk_map[wn2])",
"def distance(self) -> float:\n return self._dist_two_wire() # at this time we only support 2-wire meausre",
"def... | [
"0.71417284",
"0.6994682",
"0.6884806",
"0.6876483",
"0.68694055",
"0.6862688",
"0.68144286",
"0.6798113",
"0.6763125",
"0.6669497",
"0.6645947",
"0.66400015",
"0.66379607",
"0.6619412",
"0.6610197",
"0.65892506",
"0.6584617",
"0.65681565",
"0.65681565",
"0.6562757",
"0.65569... | 0.6629059 | 13 |
Closes the database connection | def Close(self):
l_logger.debug("Closing database connection")
self.db.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_db_connection(cls):\n db.close()",
"def close_database(self):\n if self._conn is not None:\n self._conn.close()\n self._conn = None",
"def close(self):\n Log.debug('DB -> close')\n # 关闭数据库连接\n self.conn.close()",
"def close(self):\n if... | [
"0.85662735",
"0.8412375",
"0.8293456",
"0.8184272",
"0.81580645",
"0.8057031",
"0.80505526",
"0.80190814",
"0.79888546",
"0.7972568",
"0.79306155",
"0.79142356",
"0.7873472",
"0.7871479",
"0.7852316",
"0.782567",
"0.78119534",
"0.77649176",
"0.77649176",
"0.77649176",
"0.775... | 0.80922866 | 5 |
Return the number of subscribers for a given subreddit | def number_of_subscribers(subreddit):
url = "https://www.reddit.com/r/{}.json".format(subreddit)
r = requests.get(url, headers={'User-agent': 'shoji'},
allow_redirects=False)
data = r.json()
if not r.status_code == 200:
return 0
try:
sub = data.get("data")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_of_subscribers(subreddit):\n header = {'User-Agent': 'Chrome/90.0.4430.212 Safari/537.36'}\n req = requests.get('https://www.reddit.com/r/{}/about.json'\n .format(subreddit), allow_redirects=False,\n headers=header)\n if req.status_code == 200:\n ... | [
"0.89708257",
"0.89649713",
"0.8906029",
"0.8894725",
"0.8894061",
"0.88912326",
"0.8873681",
"0.88682926",
"0.8852758",
"0.8845935",
"0.8841656",
"0.88343346",
"0.881102",
"0.8776621",
"0.87757254",
"0.87656564",
"0.8761039",
"0.87291354",
"0.8726809",
"0.8676262",
"0.860885... | 0.8828314 | 12 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.