query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Delete the upload ticket (to be used once get_last_uploaded_byte() == total file size) Makes a DELETE request to the given URI, removing the upload ticket and setting the upload status to "processing" | def delete_upload_ticket(self, complete_uri):
url = self.config['apiroot'] + complete_uri
log.info("Requesting %s" % url)
r = HTTPClient().fetch(url, method="DELETE", headers=self.standard_headers,
validate_cert=not self.config['dev'])
log.info("Upload comp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self, _uri):\n print(\"Deleting '%s'\"%(_uri))\n response = self.__httpsRequest('DELETE', _uri, '')",
"def delete(self):\n try:\n flash_message = request.json[\"flash_message\"]\n folder_path = \"{0}/user_uploads/{1}/{2}/\".format(self.__APP_PATH__, ... | [
"0.67701095",
"0.64577615",
"0.6345733",
"0.61198354",
"0.6112959",
"0.6029433",
"0.59412366",
"0.5909342",
"0.5896206",
"0.5832445",
"0.5818534",
"0.57876617",
"0.5784361",
"0.5783744",
"0.5763343",
"0.57614774",
"0.5744645",
"0.57401735",
"0.5735063",
"0.57311624",
"0.57280... | 0.7901534 | 0 |
Return world state HC state cooccurance matrix. | def get_co_occ_mat(s_hc_ml, n_s_real, n_s_hc):
co_occs = np.zeros((n_s_hc, n_s_real))
for idx, n in s_hc_ml.items():
co_occs[idx] = n
return co_occs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CTMCtoStormpy(h):\n\tstate_labelling = _buildStateLabeling(h)\n\ttransition_matrix = deepcopy(h.matrix)\n\te = array([h.e(s) for s in range(h.nb_states)])\n\ttransition_matrix /= e[:,newaxis]\n\ttransition_matrix = st.build_sparse_matrix(transition_matrix)\n\tcomponents = st.SparseModelComponents(transition_m... | [
"0.635167",
"0.59943235",
"0.58283806",
"0.5816899",
"0.5784517",
"0.57605594",
"0.5751287",
"0.5710274",
"0.57057977",
"0.56717366",
"0.5666582",
"0.56537753",
"0.562778",
"0.56184703",
"0.56027305",
"0.56016433",
"0.5601625",
"0.55812305",
"0.555667",
"0.5529863",
"0.552653... | 0.63109434 | 1 |
Return learned HC state order from cooccurance matrix by taking best matching pairs world location HC state pairs. | def get_s_order(co_occs, s_hc=None):
# Greedy approach: just go through items from max to min.
free_rows, free_cols = [list(range(n)) for n in co_occs.shape]
s_ord = -np.ones(co_occs.shape[0], dtype=int)
co_normed = norm_co_occ_matrix(co_occs)
isrtd = np.unravel_index(co_normed.argsort(axis=None)[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_nearest_state(self): # TODO: Check if we need here state, instead of self.state\n self.stateC = self.toConceptual(self.state)\n CTP, winners = self.find_winner()\n\n state_name = self.find_TPname(filleridx=winners)\n binding = self.find_symBinding(filleridx=winners)\n s... | [
"0.5657669",
"0.5559561",
"0.5372872",
"0.53349",
"0.5301023",
"0.5282986",
"0.52419263",
"0.5127219",
"0.5086206",
"0.50741035",
"0.5065264",
"0.50308555",
"0.5025374",
"0.50204796",
"0.50141317",
"0.5002204",
"0.5002081",
"0.4969301",
"0.49646002",
"0.4962375",
"0.4949405",... | 0.62907976 | 0 |
Link a spotify account to the bot. | async def link(self, ctx):
if not is_linked(ctx.author.id):
token = str(uuid.uuid4())
valid_until = int((datetime.utcnow() + timedelta(days=1)).timestamp())
add_token(ctx.author.display_name, ctx.author.id, token, valid_until, str(ctx.author.avatar_url))
web_base_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def link(ctx, bot: typing.Union[discord.Member, discord.User]):\n if not bot.bot:\n return await r(ctx, \"Not a bot.\")\n await r(ctx, f'<https://www.motiondevelopment.top/bots/{bot.id}>')",
"async def info(self, ctx):\n if ctx.guild is not None:\n await ctx.reply(\"This comm... | [
"0.6603521",
"0.63787323",
"0.6339056",
"0.6307534",
"0.62112045",
"0.6183406",
"0.60342115",
"0.6027001",
"0.60145694",
"0.60145694",
"0.5984008",
"0.59183764",
"0.5639046",
"0.5622354",
"0.5614502",
"0.5600881",
"0.5547755",
"0.5491989",
"0.5484494",
"0.54839873",
"0.547692... | 0.7880789 | 0 |
Unlink a spotify account from the bot. | async def unlink(self, ctx):
# Remove all link tokens and spotify details for this user
remove_tokens(ctx.author.id)
remove_spotify_details(ctx.author.id)
await ctx.reply("All your linked accounts were removed, if you had any!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unlink(self, link_id):",
"def unfollow_profile(self):\n self.find_clickable_element(self.ISFOLLOWED_BTN).click()",
"async def twitter_unfollow(self, ctx, handle):\n sane_handle = handle.lower().lstrip('@')\n conf = dutils.get(self.conf.follows, screen_name=sane_handle)\n chan_co... | [
"0.63025486",
"0.61723953",
"0.6036946",
"0.59427714",
"0.5927398",
"0.59164095",
"0.5912746",
"0.5850332",
"0.5843319",
"0.58328366",
"0.5821932",
"0.5803021",
"0.57848567",
"0.5749491",
"0.5748773",
"0.5742856",
"0.5740611",
"0.57387394",
"0.5726775",
"0.5691439",
"0.567866... | 0.745899 | 0 |
Displays basic info about your linked spotify account (name, avatar) | async def info(self, ctx):
if ctx.guild is not None:
await ctx.reply("This command can only be used in DMs, because of privacy reasons.")
raise commands.CommandError("Invoker not in DMs.")
if not is_linked(ctx.author.id):
await ctx.reply(f"You don't have a Spotify ac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status(verbose):\n user_data = Spotify.request('me', method='GET')\n click.echo('Logged in as {}'.format(user_data['display_name']))\n if verbose:\n click.echo('Credentials stored in {}'.format(CREDS_PATH))\n return",
"async def githubinfo_command(self, ctx, *, githubusername: str):\n ... | [
"0.65351516",
"0.6477003",
"0.64630944",
"0.62933874",
"0.62896085",
"0.6278736",
"0.6263717",
"0.6239856",
"0.62017554",
"0.61626744",
"0.61613786",
"0.6148831",
"0.6129267",
"0.6054022",
"0.60383016",
"0.6036688",
"0.6031312",
"0.6021112",
"0.5999502",
"0.599438",
"0.598736... | 0.7391768 | 0 |
Makes the bot leave your voice channel | async def leave(self, ctx):
if ctx.guild is None:
await ctx.reply("This command can only be used in a server, not in DMs.")
raise commands.CommandError("Invoker not in a guild.")
if ctx.author.voice is None or ctx.author.voice.channel is None:
await ctx.reply("You ne... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def leave(self, ctx):\n if ctx.guild.voice_client:\n await ctx.guild.voice_client.disconnect()\n await ctx.send(\"Left voice channel.\")\n else:\n await ctx.message.add_reaction('\\U0001F615');\n await ctx.send(\"Not in a voice channel.\")",
"async ... | [
"0.8343599",
"0.77186316",
"0.7650133",
"0.76289874",
"0.758633",
"0.7526717",
"0.74780494",
"0.7415649",
"0.7250327",
"0.7245011",
"0.7157922",
"0.70776135",
"0.70071197",
"0.6973833",
"0.6932585",
"0.69310313",
"0.6870495",
"0.6870495",
"0.68690455",
"0.68123126",
"0.680512... | 0.79554284 | 1 |
This function will get the whole dictionary of ytm. Here we set the low bound 0.001 and the high boung 0.1, the episilon 1e10. | def get_ytm_dict(self):
ytm=self.ytm
for term in self.Rmn.keys():
ytm = Bootstrapping.bisection(self,0.001, 0.1, 1e-10, 2 * term, self.Rmn, ytm)
return ytm | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yvals(self):\n return self.germs",
"def yvals(self):\n return self.germs",
"def bisection(self,\n low_bound: float,\n up_bound: float,\n epsilon: float,\n n: int,\n Rmn: dict,\n ytm: dict) ->... | [
"0.5608724",
"0.5608724",
"0.54514956",
"0.52048004",
"0.51582503",
"0.51236594",
"0.5118129",
"0.511333",
"0.51034176",
"0.49981782",
"0.49807763",
"0.49765843",
"0.4958691",
"0.49550095",
"0.49406016",
"0.4939153",
"0.49358478",
"0.49011344",
"0.4895696",
"0.48733735",
"0.4... | 0.715156 | 0 |
This funtion is to get the dataframe of yield to maturity and discount rate value. | def get_ytm_discount_data(self):
ytm=Bootstrapping.get_ytm_dict(self)
data = pd.DataFrame()
for i in ytm.keys():
data.loc[i / 2, 'Yield to maturity'] = ytm[i]
data.loc[i / 2, 'discount_rate'] = Bootstrapping.P_Tn(self,ytm[i], i)
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_treasury_yield(interval: str, maturity: str) -> pd.DataFrame:\n d_interval = {\"d\": \"daily\", \"w\": \"weekly\", \"m\": \"monthly\"}\n d_maturity = {\"3m\": \"3month\", \"5y\": \"5year\", \"10y\": \"10year\", \"30y\": \"30year\"}\n\n url = f\"https://www.alphavantage.co/query?function=TREASURY_Y... | [
"0.6506243",
"0.61616105",
"0.5973585",
"0.59033316",
"0.57318133",
"0.5705728",
"0.568607",
"0.56644547",
"0.5616574",
"0.55478776",
"0.55426395",
"0.5541117",
"0.5517417",
"0.55045354",
"0.55006254",
"0.5484498",
"0.54590946",
"0.54367566",
"0.5420372",
"0.53916895",
"0.539... | 0.6999018 | 0 |
Because get_ytm_discount_data will get dataframe but we want a function that we can input the term and then it give the discount rate. So this is that function. parameter | def get_discount_rate_function(self,x: float):
discount_rate = Bootstrapping.P_Tn(self,Bootstrapping.get_ytm_function(self,x), x)
return discount_rate | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ytm_discount_data(self):\n ytm=Bootstrapping.get_ytm_dict(self)\n data = pd.DataFrame()\n for i in ytm.keys():\n data.loc[i / 2, 'Yield to maturity'] = ytm[i]\n data.loc[i / 2, 'discount_rate'] = Bootstrapping.P_Tn(self,ytm[i], i)\n return data",
"def get... | [
"0.66182184",
"0.6007628",
"0.5676188",
"0.5622315",
"0.5424499",
"0.53397036",
"0.53334564",
"0.5288079",
"0.52863705",
"0.5247682",
"0.5206629",
"0.52029026",
"0.51883996",
"0.51745844",
"0.51648027",
"0.5149084",
"0.5111866",
"0.5102101",
"0.5075223",
"0.5066884",
"0.50492... | 0.6481532 | 1 |
This function is used to draw the zerocoupon bond yield curve. | def draw_yield_curve(self):
data = Bootstrapping.get_ytm_discount_data(self)
fig = plt.figure(figsize=[10, 6])
ax = fig.add_subplot(1, 1, 1)
ax.plot(data['Yield to maturity'])
ax.set_xlabel('year')
ax.set_ylabel('rate')
ax.set_title('Zero-coupon yield curve')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_discount_curve(self):\n data=Bootstrapping.get_ytm_discount_data(self)\n fig = plt.figure(figsize=[10, 6])\n ax = fig.add_subplot(1, 1, 1)\n ax.plot(data['discount_rate'])\n ax.set_xlabel('Term')\n ax.set_ylabel('value')\n ax.set_title('Discount Curves')\n ... | [
"0.63446325",
"0.5719501",
"0.54202026",
"0.53648794",
"0.5319175",
"0.53174984",
"0.53135353",
"0.53053623",
"0.53045815",
"0.5267609",
"0.52351516",
"0.52285373",
"0.5218341",
"0.5210886",
"0.5180416",
"0.5146694",
"0.51120013",
"0.50831884",
"0.5078383",
"0.5071085",
"0.50... | 0.7843739 | 0 |
This function is used to draw the zerocoupon bond yield curve. | def draw_discount_curve(self):
data=Bootstrapping.get_ytm_discount_data(self)
fig = plt.figure(figsize=[10, 6])
ax = fig.add_subplot(1, 1, 1)
ax.plot(data['discount_rate'])
ax.set_xlabel('Term')
ax.set_ylabel('value')
ax.set_title('Discount Curves')
plt.sh... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_yield_curve(self):\n data = Bootstrapping.get_ytm_discount_data(self)\n fig = plt.figure(figsize=[10, 6])\n ax = fig.add_subplot(1, 1, 1)\n ax.plot(data['Yield to maturity'])\n ax.set_xlabel('year')\n ax.set_ylabel('rate')\n ax.set_title('Zero-coupon yield ... | [
"0.7844901",
"0.57200205",
"0.5420235",
"0.5364439",
"0.531805",
"0.5317455",
"0.5312386",
"0.5305822",
"0.5303851",
"0.52682483",
"0.52347237",
"0.52280426",
"0.5218469",
"0.52114904",
"0.5181944",
"0.51469964",
"0.51128083",
"0.508417",
"0.5077651",
"0.50719845",
"0.5051411... | 0.6344681 | 1 |
Test create maze with properties. | def test_create_maze(self):
maze = Maze(4, 4)
self.assertEqual(maze.row_count, 4)
self.assertEqual(maze.col_count, 4)
self.assertEqual(maze.size, 16)
self.assertTrue(isinstance(maze.entrance, list))
self.assertTrue(isinstance(maze.exit, list)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testMazeExists(self):\n pass",
"def testMazeExists(self):\n\n pass",
"def test_ctor(self):\r\n cols = 5\r\n rows = 5\r\n maze = Maze(rows, cols)\r\n\r\n self.assertEqual(maze.num_cols, cols)\r\n self.assertEqual(maze.num_rows, rows)\r\n self.assertEqu... | [
"0.74951434",
"0.74755657",
"0.7341924",
"0.7205087",
"0.7166509",
"0.7000492",
"0.6800368",
"0.65627474",
"0.6447256",
"0.6320677",
"0.63178104",
"0.6252976",
"0.6162495",
"0.6116535",
"0.60331357",
"0.60119486",
"0.59742117",
"0.59120816",
"0.59075636",
"0.5906564",
"0.5855... | 0.78807545 | 0 |
Test create maze gets type error with noninteger. | def test_create_maze_non_integer(self):
try:
_ = Maze('I am not an integer', 4)
self.assertEqual(True, False, 'should not have got here: '
'maze created with non-integer index.')
except TypeError:
self.assertEqual(True, True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_maze(self):\n maze = Maze(4, 4)\n self.assertEqual(maze.row_count, 4)\n self.assertEqual(maze.col_count, 4)\n self.assertEqual(maze.size, 16)\n self.assertTrue(isinstance(maze.entrance, list))\n self.assertTrue(isinstance(maze.exit, list))",
"def testMaze... | [
"0.7993788",
"0.72578806",
"0.72363365",
"0.7099285",
"0.7063041",
"0.6861209",
"0.68212044",
"0.65768915",
"0.6436121",
"0.63770556",
"0.6309218",
"0.608427",
"0.6020378",
"0.5984016",
"0.5975598",
"0.5941816",
"0.58987296",
"0.58849007",
"0.5789791",
"0.57807946",
"0.576970... | 0.8117515 | 0 |
Test create maze gets type error with float. | def test_create_maze_with_float(self):
try:
_ = Maze(4.0, 4)
self.assertEqual(True, False, 'should not have got here: '
'maze created with float index.')
except TypeError:
self.assertEqual(True, True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_maze(self):\n maze = Maze(4, 4)\n self.assertEqual(maze.row_count, 4)\n self.assertEqual(maze.col_count, 4)\n self.assertEqual(maze.size, 16)\n self.assertTrue(isinstance(maze.entrance, list))\n self.assertTrue(isinstance(maze.exit, list))",
"def test_cre... | [
"0.7523571",
"0.6837212",
"0.66139513",
"0.6609147",
"0.6563737",
"0.6271226",
"0.62683207",
"0.6265946",
"0.6129293",
"0.60552156",
"0.5967328",
"0.5800113",
"0.5795364",
"0.5794256",
"0.57674694",
"0.5756952",
"0.57135016",
"0.56914604",
"0.5667238",
"0.5618049",
"0.5579303... | 0.83329034 | 0 |
Test maze creates entrance as list of two integers. | def test_create_entrance_is_list(self):
maze = Maze(4, 4)
self.assertTrue(isinstance(maze.entrance[0], int))
self.assertTrue(isinstance(maze.entrance[1], int)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_entrance_is_list(self):\n maze = Maze(4, 4)\n self.assertTrue(isinstance(maze.exit[0], int))\n self.assertTrue(isinstance(maze.exit[1], int))",
"def init_maze(width: int, height: int) -> list[int]:\n return [0] * width * height",
"def mazeTest():\r\n\tmyMaze = Maze()\r\n... | [
"0.76696694",
"0.6474169",
"0.64016163",
"0.63518304",
"0.63174134",
"0.63174134",
"0.62914747",
"0.62676936",
"0.6032349",
"0.59382766",
"0.59230834",
"0.5911689",
"0.58982056",
"0.58766043",
"0.5766839",
"0.57373405",
"0.57052636",
"0.5697641",
"0.5694257",
"0.5687101",
"0.... | 0.7438955 | 1 |
Test mazes creates exit as list of two integers | def test_create_entrance_is_list(self):
maze = Maze(4, 4)
self.assertTrue(isinstance(maze.exit[0], int))
self.assertTrue(isinstance(maze.exit[1], int)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_exit_reached(minimum: int, maximum: int) -> list:\n the_exit = [minimum - 1, maximum - 1]\n return the_exit",
"def test_list_int(self):\n result = mul(2, 4)\n self.assertEqual(result, 8)",
"def test_list_int2(self):\n inp = [(0, 0), (10, 1), (1, 2)]\n expected = 19\n... | [
"0.62346864",
"0.60159165",
"0.57737637",
"0.5748641",
"0.5747704",
"0.57114",
"0.56058764",
"0.56034714",
"0.5573308",
"0.5560567",
"0.5557499",
"0.55546963",
"0.55476743",
"0.55161655",
"0.5508791",
"0.5507034",
"0.5499264",
"0.54853886",
"0.5477175",
"0.54638946",
"0.54615... | 0.6633522 | 0 |
Test maze creates random indices between 0 and len(row) and 0 and len(column). | def test_get_random_indices_in_range(self):
maze = Maze(10, 10)
for test in range(1000):
position = maze._Maze__get_random_indices()
self.assertTrue(-1 < position[0] < 10)
self.assertTrue(-1 < position[1] < 10) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_maze_created_traversed_from_indices(self):\n maze = Maze(100, 100)\n\n for test in range(20):\n self.assertTrue(maze.can_reach_exit([random.randint(0, 99),\n random.randint(0, 99)]))",
"def testMazeExists(self):\n\n pass",
... | [
"0.76525325",
"0.69647396",
"0.69635177",
"0.6832171",
"0.6793682",
"0.6792029",
"0.6658967",
"0.66427785",
"0.66094947",
"0.65932906",
"0.6544248",
"0.6461002",
"0.6455614",
"0.6413605",
"0.63796437",
"0.63742",
"0.6348787",
"0.6320797",
"0.63205516",
"0.6318752",
"0.6299780... | 0.7503006 | 1 |
Test that a maze exit can be can be found at creation using private method __verify_exit_path. | def test_maze_created_can_be_traversed(self):
maze = Maze(100, 100)
self.assertTrue(maze._Maze__verify_exit_path()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testMazeExists(self):\n pass",
"def testMazeExists(self):\n\n pass",
"def test_maze_exit_pointers_are_none(self):\n maze = Maze(100, 100)\n\n row, col = maze.exit\n if maze.grid[row][col].up:\n maze.grid[row][col].up.down = None\n if maze.grid[row][col].... | [
"0.7718954",
"0.7711811",
"0.7170441",
"0.6457077",
"0.64257324",
"0.63298804",
"0.6325129",
"0.6186493",
"0.6110823",
"0.60940695",
"0.6087242",
"0.5893084",
"0.58477277",
"0.57537746",
"0.56882125",
"0.56534946",
"0.5650642",
"0.5640697",
"0.56240755",
"0.56226784",
"0.5569... | 0.7800023 | 0 |
Test that a maze exit can be found at creation from random positions. | def test_maze_created_traversed_from_indices(self):
maze = Maze(100, 100)
for test in range(20):
self.assertTrue(maze.can_reach_exit([random.randint(0, 99),
random.randint(0, 99)])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testMazeExists(self):\n pass",
"def testMazeExists(self):\n\n pass",
"def test_maze_created_can_be_traversed(self):\n maze = Maze(100, 100)\n\n self.assertTrue(maze._Maze__verify_exit_path())",
"def test_get_random_indices_in_range(self):\n maze = Maze(10, 10)\n\n ... | [
"0.7603047",
"0.75861",
"0.70993465",
"0.70667547",
"0.68742085",
"0.6755556",
"0.67491025",
"0.67421407",
"0.67201865",
"0.6700757",
"0.66145056",
"0.6428856",
"0.630201",
"0.61533684",
"0.6113033",
"0.60697323",
"0.6057306",
"0.599535",
"0.59817874",
"0.59677285",
"0.596192... | 0.81655616 | 0 |
Test that maze can not be exited when entrance pointers are set to None. | def test_maze_entrance_pointers_are_none(self):
maze = Maze(100, 100)
row, col = maze.entrance
maze.grid[row][col].up = None
maze.grid[row][col].right = None
maze.grid[row][col].down = None
maze.grid[row][col].left = None
self.assertFalse(maze.can_reach_exit([ro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_maze_exit_pointers_are_none(self):\n maze = Maze(100, 100)\n\n row, col = maze.exit\n if maze.grid[row][col].up:\n maze.grid[row][col].up.down = None\n if maze.grid[row][col].right:\n maze.grid[row][col].right.left = None\n if maze.grid[row][col].do... | [
"0.8649427",
"0.7370002",
"0.73293865",
"0.6856556",
"0.68072176",
"0.62326103",
"0.61708444",
"0.61359787",
"0.6099684",
"0.60358566",
"0.5930605",
"0.59018624",
"0.5899554",
"0.587606",
"0.5869301",
"0.58278805",
"0.57988024",
"0.5797692",
"0.5775867",
"0.5741775",
"0.57401... | 0.8637258 | 1 |
Test that a maze cannot be exited when rooms adjacent to the exit have their pointers set to None. | def test_maze_exit_pointers_are_none(self):
maze = Maze(100, 100)
row, col = maze.exit
if maze.grid[row][col].up:
maze.grid[row][col].up.down = None
if maze.grid[row][col].right:
maze.grid[row][col].right.left = None
if maze.grid[row][col].down:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_maze_entrance_pointers_are_none(self):\n maze = Maze(100, 100)\n\n row, col = maze.entrance\n maze.grid[row][col].up = None\n maze.grid[row][col].right = None\n maze.grid[row][col].down = None\n maze.grid[row][col].left = None\n\n self.assertFalse(maze.can_... | [
"0.84921086",
"0.7337513",
"0.7119611",
"0.6680111",
"0.6654044",
"0.6379823",
"0.62804466",
"0.61869204",
"0.61617595",
"0.61408913",
"0.6139881",
"0.61133355",
"0.6019866",
"0.5997094",
"0.5945427",
"0.593739",
"0.5920975",
"0.5908153",
"0.5904515",
"0.59022844",
"0.5888381... | 0.86979586 | 0 |
Test that a maze cannot be exited when rooms adjacent to the entrance are blocked. | def test_maze_entrance_adjacent_are_blocked(self):
maze = Maze(100, 100)
row, col = maze.entrance
if row - 1 >= 0:
maze.grid[row - 1][col].blocked = True
if col + 1 < 100:
maze.grid[row][col + 1].blocked = True
if row + 1 < 100:
maze.grid[row ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_maze_exit_adjacent_are_blocked(self):\n maze = Maze(100, 100)\n\n row, col = maze.exit\n if row - 1 >= 0:\n maze.grid[row - 1][col].blocked = True\n if col + 1 < 100:\n maze.grid[row][col + 1].blocked = True\n if row + 1 < 100:\n maze.gri... | [
"0.81660235",
"0.73107517",
"0.7274399",
"0.69842875",
"0.68054783",
"0.656764",
"0.65411395",
"0.63449854",
"0.61716986",
"0.6112959",
"0.60910326",
"0.60790956",
"0.6052811",
"0.600987",
"0.6005713",
"0.6005683",
"0.5965321",
"0.5943916",
"0.59438556",
"0.5941174",
"0.59009... | 0.81951046 | 0 |
Test that a maze cannot be exited when rooms adjacent to the exit are blocked. | def test_maze_exit_adjacent_are_blocked(self):
maze = Maze(100, 100)
row, col = maze.exit
if row - 1 >= 0:
maze.grid[row - 1][col].blocked = True
if col + 1 < 100:
maze.grid[row][col + 1].blocked = True
if row + 1 < 100:
maze.grid[row + 1][col... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_maze_entrance_adjacent_are_blocked(self):\n maze = Maze(100, 100)\n\n row, col = maze.entrance\n if row - 1 >= 0:\n maze.grid[row - 1][col].blocked = True\n if col + 1 < 100:\n maze.grid[row][col + 1].blocked = True\n if row + 1 < 100:\n ... | [
"0.80039895",
"0.7448992",
"0.7195284",
"0.6965521",
"0.6831383",
"0.66254824",
"0.659395",
"0.6501339",
"0.6198514",
"0.61660945",
"0.61389726",
"0.60900736",
"0.60867363",
"0.60384566",
"0.6005758",
"0.59558624",
"0.59533626",
"0.59515226",
"0.593887",
"0.5937304",
"0.59134... | 0.82839954 | 0 |
Returns 3xn numpy array describing motion accelerations Those acceleration are analytical calculated and aren't susceptible to errors | def get_analytical_accelerations(self):
# create empty numpy array for accelerations
accelerations = np.zeros((3, len(self.times)))
# radial accelerations is equal to angular velocity^2 / radius but radius is unitary is this trajectory
radial_acceleration = self.wz ** 2
# decompo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def acceleration(R,M,G):\r\n N = R.shape[0]\r\n a = np.zeros((N,3)) # initialize accelerations\r\n for n in range(N):\r\n for nn in range(N):\r\n if n!=nn:\r\n a[n,:] += G*M[nn] * (R[nn,:]-R[n,:]) / util.enod(R[nn,:],R[n,:])**(3) \r\n return a",
"def calculate_acce... | [
"0.67607427",
"0.6659853",
"0.65132993",
"0.6360973",
"0.6349496",
"0.6343993",
"0.62899894",
"0.62222946",
"0.6102571",
"0.6017444",
"0.6007366",
"0.599949",
"0.59906644",
"0.5926159",
"0.5886498",
"0.5861928",
"0.5837955",
"0.5786055",
"0.5779665",
"0.57683545",
"0.5741493"... | 0.74758273 | 0 |
Returns 3xn numpy array describing motion velocities Those velocities are analytical calculated and aren't susceptible to errors | def get_analytical_velocities(self):
# create empty numpy array for accelerations
velocities = np.zeros((3, len(self.times)))
# tangential velocity is angular velocity multiplied by radius but radius is one
vt = self.wz
# decompose tangential velocity in x and y components
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def motor_velocities(self):\n return np.asarray(self._robot_state.velocity)",
"def get_velocities(self):\n\n return np.array([p.velocity for p in self.particles])",
"def velocities(self, return_np=False):\n if return_np:\n return self.si_values()[3:]\n return [self.v_x, self.... | [
"0.7477564",
"0.71334136",
"0.6991451",
"0.6933057",
"0.67952305",
"0.66930515",
"0.66805524",
"0.6625498",
"0.6615499",
"0.6569754",
"0.6533391",
"0.64655375",
"0.6296626",
"0.6216558",
"0.6187872",
"0.6160401",
"0.6115366",
"0.6099247",
"0.6098212",
"0.6074818",
"0.6048958"... | 0.7648973 | 0 |
Check an external generated trajectory against the internally one | def check_trajectory(self, external_trajectory):
# Create empty array for error measure
error = np.zeros((3, external_trajectory.shape[1]))
# loop over external trajectory
for i, external_x in enumerate(external_trajectory.T):
# get trajectory coordinates at step i
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_trajectory(self):\n raise NotImplementedError",
"def test_object_with_trajectory() -> None:\n system_name = \"Octanol2\"\n system = database.system(system_name)\n parser = FlatfileParser()\n simulation_data = parser.get_simulation_data(\n units=system.un... | [
"0.6346247",
"0.61815774",
"0.5947306",
"0.58746684",
"0.58349323",
"0.5784224",
"0.575642",
"0.5685432",
"0.56115633",
"0.56095415",
"0.5555707",
"0.5527303",
"0.54907143",
"0.5460359",
"0.5445118",
"0.5434387",
"0.5405169",
"0.53977865",
"0.5394035",
"0.53772044",
"0.536921... | 0.65443593 | 0 |
For a given liaison and set of DLCs, update all unsent EmailMessages associated with those DLCs to have that Liaison. We can't make this part of, e.g., the save() method on DLC, because the liaison.dlc_set.update() commands used in views.py go straight to SQL, bypassing the ORM save() doesn't get hit, and neither do pr... | def update_emails_with_dlcs(dlcs, liaison=None):
for dlc in dlcs:
EmailMessage.objects.filter(
record__author__dlc=dlc,
date_sent__isnull=True).update(_liaison=liaison) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_attributes_by_domains(etl, update_kwargs):\r\n import arcetl\r\n func = functools.partial(\r\n etl.transform, transformation=arcetl.attributes.update_by_domain_code,\r\n )\r\n tuple(func(**kwargs) for kwargs in update_kwargs)",
"def update_data(self):\n staff = Staff.obje... | [
"0.52795607",
"0.5235836",
"0.5187958",
"0.50904024",
"0.50034666",
"0.48836243",
"0.48716804",
"0.48288625",
"0.47948357",
"0.4792678",
"0.47558114",
"0.47519177",
"0.47414127",
"0.47377956",
"0.4734942",
"0.46482447",
"0.46457776",
"0.4619367",
"0.4618994",
"0.46182483",
"0... | 0.7852708 | 0 |
Analytic expression for the normalized inverse cumulative mass function. The argument ms is normalized mass fraction [0,1] | def _icmf(self, ms):
return self._pot.a * numpy.sqrt(ms) / (1 - numpy.sqrt(ms)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mass(query, ts):\n\n m = len(query)\n q_mean = np.mean(query)\n q_std = np.std(query)\n mean, std = mov_mean_std(ts, m)\n dot = sliding_dot_product(query, ts)\n return 2 * m * (1 - (dot - m * mean * q_mean) / (m * std * q_std))",
"def normalize(X, m, s):\n return (X - m) / s",
"def nor... | [
"0.6188651",
"0.61184984",
"0.6113977",
"0.6110041",
"0.60532564",
"0.60418516",
"0.6002625",
"0.59949887",
"0.59357876",
"0.5919308",
"0.5904984",
"0.5893741",
"0.5891592",
"0.5873965",
"0.58559597",
"0.5819413",
"0.58134836",
"0.5808183",
"0.5798541",
"0.57581913",
"0.57415... | 0.68552166 | 0 |
Split up seq in pieces of size | def split_seq(seq,size):
return [seq[i:i+size] for i in range(0, len(seq), size)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_seq(seq, size):\n return [seq[ii:ii + size] for ii in range(0, len(seq), size)]",
"def split_seq(seq,size):\n for i in range(0,len(seq),size):\n if i+size<len(seq) and seq[i+size] - seq[i] == size:\n yield seq[i:i+size]",
"def _chunker(self, seq, size):\n return (se... | [
"0.83308667",
"0.80712384",
"0.7818045",
"0.77790713",
"0.7623721",
"0.7519637",
"0.74383765",
"0.7353186",
"0.7353124",
"0.731081",
"0.72468454",
"0.7198315",
"0.713888",
"0.71279585",
"0.705325",
"0.7039897",
"0.7039241",
"0.70042735",
"0.69883114",
"0.69418406",
"0.694126"... | 0.8370639 | 0 |
Returns the parent/enclosing tag (instance of PythonTag()) from the specified tag list. If no such parent tag exists, returns None. | def getParentTag(self, tagsStack):
# DOC {{{
# }}}
# CODE {{{
# determine the parent tag {{{
if (len(tagsStack)):
parentTag = tagsStack[-1]
else:
parentTag = None
# }}}
# return the tag
return parentTag
# }}} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findTypeParent(element, tag):\n \n p = element\n while True:\n p = p.getparent()\n if p.tag == tag:\n return p\n \n # Not found\n return None",
"def parent(self):\n if not self._parents:\n return None\n el... | [
"0.66215205",
"0.62002236",
"0.61979115",
"0.5927018",
"0.58290815",
"0.5811783",
"0.57534534",
"0.566354",
"0.5655644",
"0.5645672",
"0.5637724",
"0.56282586",
"0.5618066",
"0.5561548",
"0.5546117",
"0.553552",
"0.5524999",
"0.5514182",
"0.55125684",
"0.5498307",
"0.5488604"... | 0.72540027 | 0 |
Returns instance of PythonTag() based on the specified data. | def getPythonTag(self, tagsStack, lineNumber, indentChars, tagName, tagTypeDecidingMethod):
# DOC {{{
# }}}
# CODE {{{
# compute the indentation level
indentLevel = self.computeIndentationLevel(indentChars)
# get the parent tag
parentTag = self.getParentTag(tagsS... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getNodeClassFromData(self, data: OrderedDict):\n return Node if self.node_class_selector is None else self.node_class_selector(data)",
"def tag(self) -> 'Tag':\n # project/lineage must exist so let's fetch it outside of try-except\n project = self.project.key\n lineage = self.line... | [
"0.5189606",
"0.5115586",
"0.5112532",
"0.51076484",
"0.51050496",
"0.5092901",
"0.508095",
"0.5072821",
"0.50573117",
"0.5042166",
"0.49817452",
"0.4949033",
"0.49404618",
"0.49232757",
"0.49211174",
"0.49181822",
"0.4915639",
"0.48730016",
"0.4843272",
"0.47862923",
"0.4766... | 0.5681472 | 0 |
Returns tag type of the current tag based on its previous tag (super tag) for classes. | def tagClassTypeDecidingMethod(self, parentTagType):
# DOC {{{
# }}}
# CODE {{{
# is always class no matter what
return PythonTag.TT_CLASS
# }}} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_class_for(self, elem):\r\n\t\treturn self.__tag_to_cls.get(elem.tag, self.__default_cls)",
"def get_type(self, ):\n return self.attrs.get(self.AttributeNames.TYPE, None)",
"def get_class_for_tag(self, tag):\r\n return self._mapping[tag]",
"def nic_tag_type(self):\n # return type ... | [
"0.582632",
"0.57994694",
"0.57834005",
"0.5781188",
"0.5757738",
"0.5732667",
"0.5722571",
"0.56800544",
"0.56718004",
"0.5639041",
"0.55776334",
"0.5570752",
"0.5524703",
"0.5488256",
"0.54447544",
"0.542426",
"0.5419941",
"0.5353941",
"0.5353941",
"0.5353941",
"0.5353941",... | 0.67080295 | 0 |
Returns tag type of the current tag based on its previous tag (super tag) for functions/methods. | def tagFunctionTypeDecidingMethod(self, parentTagType):
# DOC {{{
# }}}
# CODE {{{
if (parentTagType == PythonTag.TT_CLASS):
return PythonTag.TT_METHOD
else:
return PythonTag.TT_FUNCTION
# }}} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_tag(self):\n return self.__tag",
"def get_tag(self, tag_type: str) -> str:\n if tag_type in self.tags:\n return self.tags[tag_type]\n return None",
"def nic_tag_type(self):\n # return type of the nictag or empty string if self.nic_tag is not found in Node.all_nictags... | [
"0.6046639",
"0.5874162",
"0.5833042",
"0.5807177",
"0.5753416",
"0.57458633",
"0.5724362",
"0.56941104",
"0.56460464",
"0.56113297",
"0.55841863",
"0.55154127",
"0.55130136",
"0.54260707",
"0.5419026",
"0.5407151",
"0.5407151",
"0.5407151",
"0.5407151",
"0.5407151",
"0.54071... | 0.5995309 | 1 |
Initializes instances of VimReadlineBuffer(). | def __init__(self, vimBuffer):
# DOC {{{
# }}}
# CODE {{{
# remember the settings
self.vimBuffer = vimBuffer
# initialize instance attributes {{{
self.currentLine = -1
self.bufferLines = len(vimBuffer)
# }}}
# }}} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, buf):\n self.lines = buf.splitlines()\n self.col_offs = [OffsetList() for i in range(len(self.lines))]\n self.col_lens = [len(line) for line in self.lines]",
"def init_readline():\n if g.command_line:\n return\n\n if has_readline:\n g.READLINE_FILE = os... | [
"0.648197",
"0.6288714",
"0.61934733",
"0.6109114",
"0.60832447",
"0.592465",
"0.58992684",
"0.58968043",
"0.5819736",
"0.5803652",
"0.58010024",
"0.5799181",
"0.5773363",
"0.5733199",
"0.5715456",
"0.56676733",
"0.56251436",
"0.56089485",
"0.5603505",
"0.55618817",
"0.556059... | 0.79332894 | 0 |
Returns the index of line in 'tagLineNumbers' list that is nearest to the specified cursor row. | def getNearestLineIndex(row, tagLineNumbers):
# DOC {{{
# }}}
# CODE {{{
# initialize local auxiliary variables {{{
nearestLineNumber = -1
nearestLineIndex = -1
# }}}
# go through all tag line numbers and find the one nearest to the specified row {{{
for lineIndex, lineNumber ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLinescanPos(self):\n return self.handle.pos().toPoint()",
"def index_tag_in_lines(lines, tag):\n for index, line in enumerate(lines):\n if tag in line:\n return index\n raise ValueError(f'{tag} not found.')",
"def get_corresponding_lineno(self, lineno: int) -> int:\n ... | [
"0.649168",
"0.6456299",
"0.6421644",
"0.6305069",
"0.6262338",
"0.62518704",
"0.6186208",
"0.61382073",
"0.6082272",
"0.6054712",
"0.60263366",
"0.5928631",
"0.59212524",
"0.5885107",
"0.5832795",
"0.5810198",
"0.57756764",
"0.57733077",
"0.57636684",
"0.5742054",
"0.5691415... | 0.8415959 | 0 |
Reads the tags for the specified buffer number. Returns a tuple (taglinenumber[buffer], tags[buffer],). | def getTags(bufferNumber, changedTick):
# DOC {{{
# }}}
# CODE {{{
# define global variables
global TAGLINENUMBERS, TAGS, BUFFERTICKS
# return immediately if there's no need to update the tags {{{
if (BUFFERTICKS.get(bufferNumber, None) == changedTick):
return (TAGLINENUMBERS[buffe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findTag(bufferNumber, changedTick):\n # DOC {{{\n # }}}\n\n # CODE {{{\n # try to find the best tag {{{\n try:\n # get the tags data for the current buffer\n tagLineNumbers, tags = getTags(bufferNumber, changedTick)\n\n # link to vim's internal data {{{\n currentBuffe... | [
"0.67446077",
"0.6337529",
"0.6291825",
"0.61587244",
"0.5640741",
"0.5421108",
"0.5401528",
"0.53968465",
"0.53458995",
"0.53208137",
"0.5273067",
"0.52147645",
"0.51437765",
"0.5076457",
"0.5067522",
"0.5062207",
"0.50597274",
"0.5055507",
"0.4999549",
"0.49994224",
"0.4990... | 0.7614175 | 0 |
Tries to find the best tag for the current cursor position. | def findTag(bufferNumber, changedTick):
# DOC {{{
# }}}
# CODE {{{
# try to find the best tag {{{
try:
# get the tags data for the current buffer
tagLineNumbers, tags = getTags(bufferNumber, changedTick)
# link to vim's internal data {{{
currentBuffer = vim.current.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_max_tag(self, word):\n count = []\n for tag in self.pos_tags:\n count.append(self.tag_word_data.count((tag, word)))\n max_index = np.argmax(np.asarray(count))\n return self.pos_tags[max_index]",
"def find_first_tag(self, tag):\n for lm, _ in self.search(tag=... | [
"0.5941577",
"0.5846168",
"0.5729062",
"0.552021",
"0.54697645",
"0.54619795",
"0.54302764",
"0.53901774",
"0.53870636",
"0.5386353",
"0.5366242",
"0.53650975",
"0.5352395",
"0.5349397",
"0.534793",
"0.53451484",
"0.5316854",
"0.5307668",
"0.530126",
"0.5299683",
"0.52880454"... | 0.6160137 | 0 |
Removes tags data for the specified buffer number. | def deleteTags(bufferNumber):
# DOC {{{
# }}}
# CODE {{{
# define global variables
global TAGS, TAGLINENUMBERS, BUFFERTICKS
# try to delete the tags for the buffer {{{
try:
del TAGS[bufferNumber]
del TAGLINENUMBERS[bufferNumber]
del BUFFERTICKS[bufferNumber]
exc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def port_buffer_drop():",
"def _remove_buffer(self):\n if self._buffer is not None:\n self._engine.remove_window(self._buffer)\n self._buffer = None\n self._region = None",
"def remove_tag(self, index):\n\n model_index = self.GetItemData(index)\n self.Delet... | [
"0.57889014",
"0.5715625",
"0.57064915",
"0.569658",
"0.56588185",
"0.5638952",
"0.5633699",
"0.5570281",
"0.55377984",
"0.5502692",
"0.54355866",
"0.5407464",
"0.5381097",
"0.53683925",
"0.5340239",
"0.5336506",
"0.53318745",
"0.53140545",
"0.53066534",
"0.52959603",
"0.5267... | 0.8191595 | 0 |
When a resource record is deleted, delete all related attachments. When a bucket or collection is deleted, it removes the attachments of every underlying records. | def on_delete_record(event):
keep_old_files = asbool(utils.setting_value(event.request, 'keep_old_files', default=False))
# Retrieve attachments for these records using links.
resource_name = event.payload['resource_name']
filter_field = '%s_uri' % resource_name
uri = event.payload['uri']
utils... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unlink(self):\n if not self:\n return True\n \n # for recomputing fields\n self.modified(self._fields)\n \n self._check_concurrency()\n \n self.check_access_rig... | [
"0.6843386",
"0.67490435",
"0.6740739",
"0.66893613",
"0.66396093",
"0.65184605",
"0.64819264",
"0.6070061",
"0.60316944",
"0.59595275",
"0.5957353",
"0.59099954",
"0.5882116",
"0.5862595",
"0.5855745",
"0.5803972",
"0.57956177",
"0.577427",
"0.5731602",
"0.5699655",
"0.56986... | 0.7568625 | 0 |
Refresh the index by recomputing the embeddings for all points. | def refresh_index(self):
synchronize()
# TODO: add logger call here
self._compute_embeddings() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reindex(self):\n self._index = {w: i for i, w in enumerate(self._words)}\n self.n, self.d = self._vecs.shape\n assert self.n == len(self._words) == len(self._index)\n self._neighbors = None",
"def _index(self, corpus):\n\n # Transform documents to embeddings vectors\n ... | [
"0.6858606",
"0.68463606",
"0.657868",
"0.6389719",
"0.6132686",
"0.60244477",
"0.593333",
"0.593333",
"0.5909812",
"0.5907422",
"0.5894825",
"0.5894825",
"0.5894825",
"0.5868806",
"0.58638215",
"0.5859926",
"0.5838459",
"0.5817189",
"0.5815836",
"0.581031",
"0.581031",
"0.... | 0.8449123 | 0 |
Draw a plot of the MSE against lambda. Draw a plot of the MSE of the learning curve for lambda = 0,1. | def plot_mse(mse, lambda0, lambda1, scale, loc='lower right'):
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(211)
ax.plot(*zip(*mse))
plt.xlabel('$\lambda$')
plt.ylabel('MSE')
plt.yticks(scale)
ax = fig.add_subplot(212)
ax.plot(*zip(*lambda0), label='$\lam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cross_validation_visualization(lambdas, loss_train, loss_test):\n plt.semilogx(lambdas, loss_train, marker=\".\", color='b', label='train error')\n plt.semilogx(lambdas, loss_test, marker=\".\", color='r', label='test error')\n plt.xlabel(\"lambda\")\n plt.ylabel(\"rmse\")\n plt.title(\"cross va... | [
"0.6702873",
"0.65018433",
"0.64510727",
"0.6430095",
"0.63851696",
"0.63240314",
"0.62314105",
"0.6179983",
"0.6178999",
"0.6125472",
"0.61104375",
"0.6096812",
"0.6083498",
"0.60187566",
"0.5927236",
"0.59271985",
"0.5897805",
"0.5864213",
"0.58363026",
"0.5832725",
"0.5800... | 0.7470588 | 0 |
! Brief Gets the binary and source files from the Github Release server [in] `tag_name` Git tag of the current release [in] `config` confi metadata set in main.py `List[ReleaseFile]` List of release files `Dict[str, SourceFile]` Dictionary of source files Sends an `HTTP GET` request to github using their REST API to re... | def get_release_files(tag_name, config) -> Tuple[List[ReleaseFile], Dict[str, SourceFile]]:
@retry_multi(5) # retry at most 5 times
def execute_request(path):
"""!
@brief Performs a GET request with the given path. To be used with Github's REST API.
@returns If successful, returns a .JS... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(docker_hub_client, args):\n resp = docker_hub_client.get_tags(args.orgname, args.reponame, args.page)\n if resp['code'] == 200:\n if resp['content']['count'] > 0:\n rows = []\n for repo in resp['content']['results']:\n formatted_date = ''\n i... | [
"0.59825385",
"0.58761805",
"0.57182723",
"0.5670623",
"0.5653557",
"0.56310666",
"0.5565626",
"0.55542344",
"0.5533877",
"0.5509498",
"0.5492166",
"0.5470247",
"0.5463593",
"0.5457297",
"0.54524344",
"0.54264504",
"0.54025966",
"0.53729427",
"0.53684837",
"0.5364324",
"0.535... | 0.80856 | 0 |
! Performs a GET request with the given path. To be used with Github's REST API. If successful, returns a .JSON object | def execute_request(path):
headers = {
"Accept": "application/vnd.github.v3+json"
}
url = "https://api.github.com" + path
# GET https://api.github.com/<path> Accept: "application/vnd.github.v3+json"
response = requests.get(url, headers=headers, timeout=GLOBAL_TIMEOU... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get(self, path):\n r = requests.get(self._url(path))\n assert r.status_code == 200\n return r.json",
"def get(self, path):\n url = urljoin(self.api_endpoint, path)\n response = requests.get(url, headers=self.headers)\n if response.status_code == requests.codes.ok:\n... | [
"0.781501",
"0.742558",
"0.73796403",
"0.7367606",
"0.7359657",
"0.7286444",
"0.7283974",
"0.7187162",
"0.7146045",
"0.7120918",
"0.70935255",
"0.7091099",
"0.7059631",
"0.7059341",
"0.7053496",
"0.70428777",
"0.6986437",
"0.69172233",
"0.6824876",
"0.6779515",
"0.6770286",
... | 0.78895104 | 0 |
! Gets file metadata for nightlies hosted on FTP, as determined by config["ftp"] attributes [in] `build_type` Unknown str [in] `tag_name` Github tag name of the release [in] `config` config metadata set in main.py | def get_ftp_files(build_type, tag_name, config) -> List[ReleaseFile] :
tag_regex = re.compile("nightly_(.*)")
build_group_regex = re.compile("nightly_.*-builds-([^.]+).*")
files = []
try:
with FTP(config["ftp"]["host"], config["ftp"]["user"], config["ftp"]["pass"]) as ftp:
# extrac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clowder_file_metadata(session, url, fileid):\n try:\n ret = session.get(posixpath.join(url, \"api/files\", fileid, \"metadata.jsonld\"))\n except session.exceptions.RequestException as e:\n print(e)\n sys.exit(1)\n\n return ret",
"def get_file_info(filename):\n info = {'build... | [
"0.58197266",
"0.5817729",
"0.57113373",
"0.5679368",
"0.5664209",
"0.56055725",
"0.5591246",
"0.5514646",
"0.54909694",
"0.5488954",
"0.5428965",
"0.5408972",
"0.5381461",
"0.5341084",
"0.5333622",
"0.529747",
"0.5256132",
"0.5247465",
"0.5238741",
"0.52325314",
"0.5205857",... | 0.7348779 | 0 |
serialize triples to chosen format supported by rdflib, e.g. xml, turtle, n3, etc | def serialize(triples, format='xml'):
g = Graph()
for k, v in NAMESPACES.iteritems():
g.bind(k, v)
for triple in triples:
g.add(triple)
return g.serialize(format=format) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize_nx_node_to_triples(g, key, node=None):\n\n node = node or g and g.node.get(key) # <curie/key> # ... precis\n\n yield (key, 'a', node.get('type')) # <> a <type>\n\n for attr,value in node.items():\n yield (key, attr, value)\n\n # MultiDiGraph\n for edge in g.edge.get(key):\n ... | [
"0.6063675",
"0.5935797",
"0.5933383",
"0.5895876",
"0.5845123",
"0.5759756",
"0.5708165",
"0.5590648",
"0.5548313",
"0.55361754",
"0.553367",
"0.54797417",
"0.54766667",
"0.5440754",
"0.5416236",
"0.5388414",
"0.53399545",
"0.52932197",
"0.52865195",
"0.52275985",
"0.522483"... | 0.7633531 | 0 |
Returns an unbound port number on 127.0.0.1. | def find_unbound_port():
while True:
port = random.randint(*PORT_RANGE)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
sock.bind(("127.0.0.1", port))
return port
except socket.error:
print("randomly generated port %d is bound. Trying... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_unused_port():\n sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)\n sock.bind(('127.0.0.1', 0))\n sock.listen(socket.SOMAXCONN)\n ipaddr, port = sock.getsockname()\n sock.close()\n return port",
"def GetUnreservedAvailableLocalPort():\n tmp = socket.socket()\n tmp.bind((''... | [
"0.79000366",
"0.7862578",
"0.7742362",
"0.7707025",
"0.7701062",
"0.7686607",
"0.75873804",
"0.75825536",
"0.7564691",
"0.7556933",
"0.75550276",
"0.7499802",
"0.7461294",
"0.74481964",
"0.74385625",
"0.7360805",
"0.7261695",
"0.71875924",
"0.7181387",
"0.7119721",
"0.705185... | 0.7919572 | 0 |
Sends an email to a single recipient straight to his MTA. Looks up for the MX DNS records of the recipient SMTP server and attempts the delivery through them. | def send(self):
answers = dns.resolver.query(self.domain, 'MX')
try:
for answer in answers:
ex = answer.exchange.to_text()
server = smtplib.SMTP(ex)
server.set_debuglevel(self.verbose)
server.sendmail(self.sender, [self.recipien... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sendmail(self, message=None, subject=None, recipients=None):\n\n if not recipients:\n recipients = self.recipients\n if len(recipients) == 0:\n return False\n if not message:\n message = self.message\n if len(message) == 0:\n return False\... | [
"0.6710717",
"0.6321565",
"0.6236836",
"0.62081426",
"0.61137784",
"0.6100117",
"0.60243607",
"0.6002686",
"0.5987678",
"0.59080464",
"0.58790296",
"0.5877092",
"0.5850349",
"0.584703",
"0.5835367",
"0.5779802",
"0.5771508",
"0.57684636",
"0.5767812",
"0.5765022",
"0.5761345"... | 0.7115084 | 0 |
Starts an iterative task which update org admins. | def updateOrgAdmins(request):
return updateRole('gsoc_org_admin') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def actualize(self):\r\n for guild, settings in self.bot.settings.items():\r\n # Grab the roles and their requirements\r\n guild = self.bot.get_guild(guild)\r\n base_member = settings.get(\"rank_basic_member_role_id\")\r\n base_member = guild.get_role(base_m... | [
"0.56836027",
"0.5528564",
"0.53884643",
"0.5359931",
"0.53472096",
"0.5343001",
"0.53295594",
"0.53265554",
"0.5268255",
"0.5263433",
"0.5232607",
"0.52205235",
"0.5219957",
"0.52131385",
"0.5176218",
"0.5130246",
"0.5106985",
"0.50729245",
"0.50512886",
"0.50468695",
"0.504... | 0.59802717 | 0 |
Returns GSoCProfile or GCIProfile which corresponds to the specified entity. | def _getProfileForRole(entity, profile_model):
if isinstance(entity, profile_model):
return entity
if isinstance(entity, OrgAdmin) or isinstance(entity, Mentor):
key_name = entity.program.key().name() + '/' + entity.user.key().name()
else:
key_name = entity.key().name()
parent = entity.user
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _getProfileFromUser(self):\n # Make sure user is authenticated\n user = endpoints.get_current_user()\n if not user:\n raise endpoints.UnauthorizedException('Authorization required')\n # Get Profile from datastore\n user_id = user.email()\n p_key = ndb.Key(Pr... | [
"0.60517067",
"0.5931097",
"0.5920047",
"0.57531446",
"0.5752912",
"0.57454103",
"0.5593141",
"0.5578978",
"0.5446997",
"0.54374474",
"0.5414628",
"0.5366052",
"0.5310331",
"0.53044224",
"0.5297717",
"0.528342",
"0.5280851",
"0.5238035",
"0.5170172",
"0.5164785",
"0.51386154"... | 0.67691934 | 0 |
Returns Key instance of the Profile which corresponds to the Role which is represented by the specified Key. | def _getProfileKeyForRoleKey(key, profile_model):
entity = db.get(key)
profile = _getProfileForRole(entity, profile_model)
return profile.key() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_key(self, role):\n\n for key, role_name in self.assignable_roles[0].items():\n if role_name == role.name:\n return key",
"def get_key(self, key):\n ret = None\n qkey = key.__qualname__\n ret = self.get(qkey)\n if not ret:\n # check a... | [
"0.66111445",
"0.58805066",
"0.58505315",
"0.5831204",
"0.5803281",
"0.5803281",
"0.57678306",
"0.5754127",
"0.56673247",
"0.56673247",
"0.5639647",
"0.5624423",
"0.56116235",
"0.56116235",
"0.56116235",
"0.56116235",
"0.56116235",
"0.56116235",
"0.56116235",
"0.56116235",
"0... | 0.828253 | 0 |
1. Convert ifg phase data into numpy binary files. 2. Save the preread_ifgs dict with information about the ifgs that are later used for fast loading of Ifg files in IfgPart class | def _create_ifg_dict(dest_tifs, params):
ifgs_dict = {}
nifgs = len(dest_tifs)
process_tifs = mpiops.array_split(dest_tifs)
for d in process_tifs:
ifg = shared._prep_ifg(d, params)
ifgs_dict[d] = PrereadIfg(path=d,
nan_fraction=ifg.nan_fraction,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_ifgs(ifg_paths, params, rows, cols):\n\n if mpiops.size > 1: # turn of multiprocessing during mpi jobs\n params[cf.PARALLEL] = False\n outdir = params[cf.TMPDIR]\n if not os.path.exists(outdir):\n shared.mkdir_p(outdir)\n\n tiles = mpiops.run_once(get_tiles, ifg_paths[0], row... | [
"0.6318846",
"0.59935594",
"0.58033705",
"0.557617",
"0.5541329",
"0.548497",
"0.54715943",
"0.54680747",
"0.54556257",
"0.5448563",
"0.5441124",
"0.543736",
"0.54259264",
"0.5376901",
"0.53260976",
"0.5311196",
"0.5308559",
"0.5306656",
"0.52739114",
"0.524727",
"0.52424717"... | 0.69364214 | 0 |
MPI wrapper function for MST calculation | def _mst_calc(dest_tifs, params, tiles, preread_ifgs):
process_tiles = mpiops.array_split(tiles)
log.info('Calculating minimum spanning tree matrix')
def _save_mst_tile(tile, i, preread_ifgs):
"""
Convenient inner loop for mst tile saving
"""
mst_tile = mst.mst_multiprocessi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_mediation(task):\n\tatlas = 'power'\n\tproject='hcp'\n\tknown_membership,network_names,num_nodes,name_int_dict = network_labels(atlas)\n\tsubjects = np.load('%s/dynamic_mod/results/%s_%s_%s_subs_fz.npy' %(homedir,'hcp',task,atlas))\n\tstatic_results = graph_metrics(subjects,task,atlas,run_version='fz')\n... | [
"0.5712891",
"0.56743956",
"0.5644941",
"0.56176066",
"0.5497657",
"0.5445917",
"0.53922945",
"0.53776425",
"0.53776425",
"0.5272448",
"0.5257341",
"0.52249587",
"0.5215293",
"0.52147806",
"0.51855075",
"0.51734966",
"0.51608145",
"0.5157823",
"0.51528966",
"0.5091743",
"0.50... | 0.6318238 | 0 |
Convenient inner loop for mst tile saving | def _save_mst_tile(tile, i, preread_ifgs):
mst_tile = mst.mst_multiprocessing(tile, dest_tifs, preread_ifgs, params)
# locally save the mst_mat
mst_file_process_n = join(params[cf.TMPDIR], 'mst_mat_{}.npy'.format(i))
np.save(file=mst_file_process_n, arr=mst_tile) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saveTiles(z, x, y, ntiles, mapname, image, suffix = 'png', imgtype = None):\n for dx in range(0, ntiles):\n tilex = x*ntiles + dx\n ensureDirExists(getTileDir(mapname, z, tilex))\n for dy in range(0, ntiles): \n tiley = y*ntiles + dy\n offsetx = BORDER_WIDTH + d... | [
"0.7104713",
"0.6770546",
"0.66476554",
"0.6564062",
"0.6432503",
"0.63820964",
"0.63444513",
"0.62283266",
"0.62283266",
"0.6224158",
"0.6180002",
"0.6177511",
"0.61530757",
"0.61273086",
"0.61271673",
"0.61231756",
"0.60986423",
"0.6098325",
"0.6088457",
"0.60603994",
"0.60... | 0.73028386 | 0 |
Wrapper for reference pixel calculation | def _ref_pixel_calc(ifg_paths: List[str], params: dict) -> Tuple[int, int]:
lon = params[cf.REFX]
lat = params[cf.REFY]
ifg = Ifg(ifg_paths[0])
ifg.open(readonly=True)
# assume all interferograms have same projection and will share the same transform
transform = ifg.dataset.GetGeoTransform()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def referencepixel(self, *args, **kwargs):\n return _coordsys.coordsys_referencepixel(self, *args, **kwargs)",
"def calc(self, *args, **kwargs):\n return _image.image_calc(self, *args, **kwargs)",
"def pixel(self, x: int, y: int, colour: int, /) -> None:",
"def pixel_ref(self):\n return ... | [
"0.70273024",
"0.6470538",
"0.6387868",
"0.6360936",
"0.6305052",
"0.6197508",
"0.6159541",
"0.6128455",
"0.6084345",
"0.6061778",
"0.60592145",
"0.5950711",
"0.5843533",
"0.5832167",
"0.58209383",
"0.5817011",
"0.5734207",
"0.57130796",
"0.5680172",
"0.5634101",
"0.56332415"... | 0.6673501 | 1 |
MPI wrapper for maxvar and vcmt computation | def _maxvar_vcm_calc(ifg_paths, params, preread_ifgs):
log.info('Calculating the temporal variance-covariance matrix')
process_indices = mpiops.array_split(range(len(ifg_paths)))
def _get_r_dist(ifg_path):
"""
Get RDIst class object
"""
ifg = Ifg(ifg_path)
ifg.open()... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_max_and_argmax(node):\r\n if node.op == T._max_and_argmax:\r\n if len(node.outputs[1].clients) == 0:\r\n #MaxAndArgmax support variable axis,\r\n #but CAReduce support only constant axis.\r\n if node.inputs[1].data is None:\r\n axis = None\r\n ... | [
"0.6341681",
"0.61969894",
"0.6065083",
"0.60228604",
"0.60162735",
"0.596405",
"0.5831983",
"0.58185774",
"0.57805014",
"0.57521695",
"0.57240343",
"0.57173043",
"0.56774616",
"0.5617856",
"0.5602376",
"0.5560389",
"0.55562276",
"0.5540691",
"0.5516906",
"0.549255",
"0.54219... | 0.80074286 | 0 |
MPI wrapper for time series calculation. | def _timeseries_calc(ifg_paths, params, vcmt, tiles, preread_ifgs):
if params[cf.TIME_SERIES_CAL] == 0:
log.info('Time Series Calculation not required')
return
if params[cf.TIME_SERIES_METHOD] == 1:
log.info('Calculating time series using Laplacian Smoothing method')
elif params[cf.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_trajectory():\n pass",
"def mpi_schedule_job_array(csvstore, job_array, mpi_service=MPIService()):\n param_array = job_array.param_array\n job = job_array.job\n try:\n if mpi_service.rank == 0:\n # master\n results = []\n nb_completed_tasks = 0\n ... | [
"0.56803995",
"0.56590575",
"0.53260535",
"0.5320121",
"0.52309686",
"0.5216873",
"0.52014816",
"0.51989406",
"0.5178184",
"0.51628107",
"0.5117995",
"0.5109982",
"0.50846106",
"0.50473",
"0.5044743",
"0.50315577",
"0.49988696",
"0.4984488",
"0.49706215",
"0.49481472",
"0.493... | 0.622448 | 0 |
Sets the number of simulation threads to use in Calculix | def setNumThreads(cls, numThreads: int):
cls.NUMTHREADS = numThreads | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setNumThreads(self, num):\r\n self.threads = num",
"def setNumThreads(self, num):\r\n # implement ThreadPool interface\r\n assert not self.prepared, \"You can't change number of threads for working server\"\r\n self.threads = num",
"def setNThreads(self,n):\n assert(n>0)\n ... | [
"0.8256052",
"0.7567058",
"0.75560105",
"0.7523079",
"0.71850544",
"0.71713644",
"0.7045087",
"0.6716871",
"0.6572469",
"0.6557934",
"0.6522405",
"0.64511395",
"0.63847023",
"0.63694143",
"0.6355767",
"0.62587845",
"0.625188",
"0.625188",
"0.62317884",
"0.6220977",
"0.6196904... | 0.7770937 | 1 |
Returns the number of threads used | def getNumThreads(cls) -> int:
return cls.NUMTHREADS | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getThreads():\r\n return multiprocessing.cpu_count()",
"def nThreads(self):\n return self._c_param.n_threads",
"def getThreads():\n if sys.platform == 'win32':\n return int(os.environ['NUMBER_OF_PROCESSORS'])\n else:\n return int(os.popen('grep -c cores /proc/cpuinfo').read())... | [
"0.87160325",
"0.8365115",
"0.80756944",
"0.8064238",
"0.80488205",
"0.80468506",
"0.80122787",
"0.796875",
"0.79343176",
"0.79194176",
"0.7910496",
"0.78782344",
"0.78163666",
"0.76584685",
"0.76553136",
"0.76175404",
"0.76108193",
"0.7597156",
"0.7580023",
"0.7564992",
"0.7... | 0.86468875 | 1 |
Sets the path for the Calculix executable. Necessary when using Windows where there is not a default installation proceedure for Calculix | def setCalculixPath(cls, calculixPath: str) -> None:
if os.path.isdir(calculixPath) :
cls.CALCULIX_PATH = calculixPath | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_vernissagecmd_path(path):\n\n global vernissagecmd_path # Allows us to change the global value of the path.\n if path == 'default': # Change the file path back to the default value.\n vernissagecmd_path = default_vernissagecmd_path\n print('VernissageCmd.exe path changed to {path}'.fo... | [
"0.59972835",
"0.57588685",
"0.57472515",
"0.56947476",
"0.55666745",
"0.54746413",
"0.5436197",
"0.54127634",
"0.5398966",
"0.5395865",
"0.5377132",
"0.5316808",
"0.52898544",
"0.5277046",
"0.5276305",
"0.5267065",
"0.52460194",
"0.5244962",
"0.5238546",
"0.52273226",
"0.522... | 0.7140539 | 0 |
Creates node sets for any RBE connectors used in the simulation | def prepareConnectors(self):
# Kinematic Connectors require creating node sets
# These are created and added to the node set collection prior to writing
numConnectors = 1
for connector in self.connectors:
# Node are created and are an attribute of a Connector
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_nodes(self):",
"def gen_nodes(self):\n self.nodes = []\n for i in range(self.num_nodes):\n self.nodes.append(Node(self.fk))",
"def create_exporters(self):\n for node_cfg in self.node_cfg_list:\n self.create_node(node_cfg)",
"def create_nodes(self):\n ... | [
"0.6607326",
"0.6201226",
"0.61612624",
"0.6156707",
"0.6078838",
"0.6066718",
"0.6010416",
"0.598341",
"0.58685356",
"0.5867943",
"0.5858527",
"0.5854881",
"0.5841058",
"0.58386105",
"0.5774203",
"0.5754194",
"0.5719591",
"0.568923",
"0.5685475",
"0.56728554",
"0.56583863",
... | 0.70691216 | 0 |
Returns if the analysis was completed successfully. | def isAnalysisCompleted(self) -> bool:
return self._analysisCompleted | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_result(self):\n return len(self.__analysis_items) > 0",
"def successful(self) -> bool:\n\n return self._successful",
"def has_success(self) -> bool:\n return self._has_success",
"def is_successful(self) -> bool:\n return bool(self.result_state and self.result_state.is_succ... | [
"0.7395358",
"0.7370877",
"0.7368734",
"0.7324297",
"0.7295538",
"0.7222038",
"0.71889675",
"0.71834224",
"0.71548474",
"0.71323526",
"0.7120799",
"0.70954716",
"0.7075373",
"0.7017168",
"0.701042",
"0.7007025",
"0.7000122",
"0.698778",
"0.6979704",
"0.6962313",
"0.69311875",... | 0.80789053 | 0 |
Clears any files generated from the analysis | def clearAnalysis(self, includeResults:bool = False) -> None:
filename = 'input' # Base filename for the analysis
files = [filename + '.inp',
filename + '.cvg',
filename + '.sta']
if includeResults:
files.append(filename + '.frd')
file... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_files(self):\n self.filenames.clear()",
"def clean():\n clean_files()",
"def clear(self):\r\n shutil.rmtree(self._output_dir, ignore_errors=True)",
"def clear_local_output_directory():\n output_path = '../output/*'\n files = glob.glob(output_path)\n for single_... | [
"0.7968305",
"0.77191716",
"0.7537249",
"0.7515307",
"0.7513296",
"0.7491484",
"0.7484085",
"0.7410033",
"0.734755",
"0.7287088",
"0.72671735",
"0.72499853",
"0.7249866",
"0.7248436",
"0.72048616",
"0.7182686",
"0.7161519",
"0.71290827",
"0.7113421",
"0.7099185",
"0.70814157"... | 0.778449 | 1 |
crawl targeted twitter account, save tweets to csv | def crawlAccount(target):
# connect Twitter api
twitter = connectTwitter()
try:
user_timeline = twitter.get_user_timeline(screen_name=target, count=200, include_rts=False, exclude_replies=False)
except TwythonError:
sys.exit('Received 404 for %s. Account does not exist or is banned.' % target)
user_timelin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect_twitter_sentiment():\r\n # Open/create a file to append data to\r\n csvFile = open(NAME+'_posts.csv', 'a')\r\n # Use csv writer\r\n csvWriter = csv.writer(csvFile)\r\n # Calling the user function with current parameters\r\n results = twitter.user_timeline(id=NAME, count=TWEET_COUNT)\r... | [
"0.70010406",
"0.67850053",
"0.6734272",
"0.66105545",
"0.6591761",
"0.64855397",
"0.64794904",
"0.6473131",
"0.64262015",
"0.64123046",
"0.63488454",
"0.6339719",
"0.6291743",
"0.6237709",
"0.621407",
"0.62131447",
"0.61392415",
"0.6134089",
"0.6120575",
"0.60954064",
"0.606... | 0.7076422 | 0 |
adding an assertion for testing dataframe equality setting up a database_handler object with the dummy database path and connecting it | def setUp(self):
self.addTypeEqualityFunc(pandas.DataFrame, self.assertDataframeEqual)
self.database_connection.connect() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_build_dataframe(self):\n insert_good_data()\n dataframe = get_dataframe()\n # 1 2 3\n self.assertIs(type(dataframe['Total'][0]), numpy.float64)\n self.assertIs(type(dataframe['InvoiceDate'][0]), str)\n self.assertIs(type(dataframe['Count'][0]), numpy.int64)\n ... | [
"0.71694195",
"0.69254637",
"0.6790876",
"0.6677135",
"0.6648234",
"0.6580347",
"0.650768",
"0.6470732",
"0.6430044",
"0.6362951",
"0.6330373",
"0.632379",
"0.6319858",
"0.6303485",
"0.6296251",
"0.6263661",
"0.6252208",
"0.6215653",
"0.6214677",
"0.6211742",
"0.62074625",
... | 0.7636546 | 0 |
1.2.3 checking data type is correct 4. testing sum of columns is correct 5. (added assertion) testing dataframes are the same, one manufactured 6. clearing the database and inserting altered data CustomerId duplicate, checking difference in Count (34) 7. testing raising an exception of AssertionError with dataframe and... | def test_build_dataframe(self):
insert_good_data()
dataframe = get_dataframe()
# 1 2 3
self.assertIs(type(dataframe['Total'][0]), numpy.float64)
self.assertIs(type(dataframe['InvoiceDate'][0]), str)
self.assertIs(type(dataframe['Count'][0]), numpy.int64)
# 4
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_dataframe(dataframe):\n results = True\n rows = dataframe.shape[0]\n column_names = sorted(dataframe.columns)\n column_datatypes = list(dataframe[column_names].dtypes)\n\n # Checks columns match those specified in #1\n if column_names != DATA_COLUMNS:\n raise ValueError(\"D... | [
"0.7033019",
"0.6735344",
"0.66333157",
"0.644243",
"0.6424497",
"0.6372388",
"0.63426524",
"0.6339254",
"0.62987274",
"0.62735826",
"0.62442666",
"0.6217152",
"0.6199997",
"0.617955",
"0.61647725",
"0.61497754",
"0.6148181",
"0.6148095",
"0.6096861",
"0.60874194",
"0.6004757... | 0.78982604 | 0 |
1. testing the build_graph method returns the correct string, and waiting for file to open (less than 1 sec) | def test_build_graph(self):
insert_good_data()
dataframe = get_dataframe()
results = processing.build_graph(dataframe, figure_path, False)
# 1
self.assertEqual(results, "Updated html File and Opened it") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testGraphExtract(self):\n graph = Graph2()\n graph.parseFile(TESTFILE)",
"async def get_graph_for_file(\n file_name: str,\n score: int = 0,\n par_length: int = 0,\n co_occ: int = 0,\n target_collection: List[str] = Query([]),\n):\n database = get_db()\n query_graph_result =... | [
"0.6007912",
"0.59982365",
"0.5962933",
"0.5850433",
"0.5817421",
"0.57249165",
"0.57078034",
"0.568576",
"0.5582051",
"0.55256677",
"0.55047196",
"0.54700655",
"0.54588395",
"0.54585487",
"0.5439813",
"0.5436548",
"0.54200363",
"0.54097277",
"0.5380385",
"0.5369311",
"0.5364... | 0.6569553 | 0 |
Create a (potentially existing) directory without errors. Raise OSError if directory can't be created. If clobber is True, remove dirpath if it exists. | def mkdir(dirpath, clobber=False):
if clobber:
shutil.rmtree(dirpath, ignore_errors=True)
try:
os.mkdir(dirpath)
except OSError:
pass
if not path.exists(dirpath):
raise OSError('Failed to create %s' % dirpath)
return dirpath | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makedirectory(path):\n\n exist_ok = True\n if not exist_ok and os.path.isdir(path):\n with contextlib.suppress(OSError):\n Path.mkdir(path, parents=True)",
"def mkDir(path):\n if not os.path.exists(path):\n try:\n os.makedirs(path)\n except OSError:\n ... | [
"0.7061584",
"0.70569605",
"0.70226943",
"0.7006338",
"0.699954",
"0.6977039",
"0.6966338",
"0.6966338",
"0.6966338",
"0.6966338",
"0.69507277",
"0.6921338",
"0.68780476",
"0.68686837",
"0.6837868",
"0.6795552",
"0.67695946",
"0.67676157",
"0.67505884",
"0.6743762",
"0.672953... | 0.85963845 | 0 |
Copy fname from package data to outdir/subdir (creating dir if necessary), and return the path to the copy of fname relative to outdir. | def make_local_copy(outdir, subdir, fname):
destdir = path.join(outdir, subdir)
mkdir(destdir)
shutil.copyfile(package_data(fname), path.join(destdir, fname))
return path.join(subdir, fname) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def package_dest_path(self, package):\n\n if self.destdir is None:\n return self.package_final_path(package)\n else:\n return os.path.join(\n self.destdir,\n self.package_install_space(package).lstrip(os.sep))",
"def create_file_path(fname, direc=... | [
"0.62651706",
"0.6082093",
"0.60650736",
"0.6050992",
"0.5938889",
"0.58145124",
"0.5783093",
"0.5764241",
"0.57486904",
"0.57103425",
"0.57036674",
"0.5678299",
"0.56111586",
"0.56056064",
"0.5599549",
"0.5561045",
"0.5521641",
"0.54854083",
"0.5484105",
"0.5466086",
"0.5459... | 0.7523176 | 0 |
Given a course code, requests the correspnding course page | def get_coursepage(code):
url = 'http://gla.ac.uk/coursecatalogue/course/?code=' + code
print url
coursepage = requests.get(url)
return coursepage | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_course_page(self):\n\n print(\"Course URL: {}\".format(self.course_url))\n try:\n self.course_page = BeautifulSoup(requests.get(self.course_url).text, \"lxml\")\n except requests.ConnectionError as e:\n print(\"Error Connecting!\\n\", e)\n sys.exit(1)\n... | [
"0.7398104",
"0.6673765",
"0.66678524",
"0.64198714",
"0.6413772",
"0.63720846",
"0.6232175",
"0.61700314",
"0.6150578",
"0.6142026",
"0.61378634",
"0.60246366",
"0.6009835",
"0.5975768",
"0.5974896",
"0.59581447",
"0.5909168",
"0.58898294",
"0.58715636",
"0.5865942",
"0.5853... | 0.857764 | 0 |
Creates a dictionary with a headingvalue pair, which is the structure of all the sections in the courses dictionary | def new_dict(heading, value):
value = value.replace('%', '\%').replace('&', '\&').replace(u'\xa0', ' ')
# Currently encoding is causeing me problems - the quick fix below removes
# all the characters that have broken the code so far. This solution is not
# likely to work if more courses were added
v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _section_course_info(course_key, access):\r\n course = get_course_by_id(course_key, depth=None)\r\n\r\n section_data = {\r\n 'section_key': 'course_info',\r\n 'section_display_name': _('Course Info'),\r\n 'access': access,\r\n 'course_id': course_key,\r\n 'course_displa... | [
"0.7070789",
"0.60182756",
"0.6016982",
"0.5990312",
"0.5969372",
"0.59540147",
"0.59495693",
"0.59283185",
"0.58511907",
"0.58379775",
"0.58187705",
"0.5808631",
"0.5805773",
"0.58040214",
"0.5761286",
"0.57347447",
"0.5731346",
"0.5700729",
"0.5679609",
"0.5641057",
"0.5584... | 0.64286023 | 1 |
Each course page has a small info section at the beginning, which I had to extract and formulate in a different way to the main sections. This function constructs the dictionary entries for he course when given a string with all the details required for the info section | def get_info_list(info_string, course):
info_list = []
split_on_newline = info_string.split("\n")
for elem in split_on_newline:
split = elem.split(": ")
for s in split:
info_list.append(s)
info_list = info_list[1:-1]
info_tags = [
'session', 'school', 'credits', '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _section_course_info(course_key, access):\r\n course = get_course_by_id(course_key, depth=None)\r\n\r\n section_data = {\r\n 'section_key': 'course_info',\r\n 'section_display_name': _('Course Info'),\r\n 'access': access,\r\n 'course_id': course_key,\r\n 'course_displa... | [
"0.698141",
"0.6433248",
"0.61811566",
"0.608286",
"0.6082416",
"0.6056426",
"0.6050662",
"0.6001302",
"0.5982004",
"0.59207666",
"0.58908296",
"0.5850639",
"0.5830395",
"0.5818191",
"0.5790374",
"0.577954",
"0.57718724",
"0.5770274",
"0.57416594",
"0.57249576",
"0.57086146",... | 0.7118217 | 0 |
Given a list of course codes, ge5t their corresponding titles and format them in a bulletted TeX list. This is used to indicate in the abstract which courses have been deliberately discluded from the document | def create_not_included_list(codes):
string = '\\begin{itemize}\n'
for code in codes:
title = get_course_title_only(code)
string += '\\item{' + title + '}\n'
string += '\\end{itemize}\n'
return string | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_to_latex(codelist, unwanted_courses):\n # TODO: investigate a way to add large amounts of text outside of the\n # function\n abstract01 = \"I created this document to practice parsing html and using\\\n tools like Beautiful Soup which I've previously had little experience\\\n in. A... | [
"0.61776614",
"0.61535215",
"0.5460157",
"0.53928626",
"0.5347271",
"0.5328471",
"0.5140035",
"0.5117348",
"0.51146877",
"0.5056962",
"0.5048898",
"0.50328934",
"0.50134706",
"0.50019485",
"0.49917555",
"0.49796224",
"0.49568665",
"0.4950176",
"0.49257633",
"0.49147525",
"0.4... | 0.66535985 | 0 |
Creates a TeX formatted string for a given subsubsection | def latex_subsection(section):
string = '\\subsubsection*{' + section['heading'] + '}\n'
string += section['value'] + '\n'
return string | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sub(string, subscript):\n return string + \"<sub>\" + subscript + \"</sub>\"",
"def _build_sub(self) -> str:\n return dedent(\n \"\"\"\n @SP\n M=M-1\n A=M\n D=M\n @SP\n M=M-1\n A=M\n M=M-D\n ... | [
"0.65773475",
"0.63128084",
"0.62126887",
"0.6208371",
"0.61632997",
"0.6140767",
"0.6039124",
"0.6012975",
"0.5978812",
"0.5934507",
"0.58059335",
"0.5795126",
"0.569796",
"0.5690162",
"0.5618066",
"0.5618066",
"0.5604984",
"0.5596953",
"0.5590398",
"0.55688125",
"0.55626035... | 0.75560915 | 0 |
Creates a TeX formatted string for a course | def latex_course(course):
basic_info_list = [
'session', 'school', 'credits', 'level', 'offered',
'visiting_students', 'erasmus_students'
]
generic_subsection_list = [
'description', 'timetable', 'requirements_of_entry',
'excluded_courses', 'co_requisites', 'assessment_weight... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_tex(unwanted_courses, wanted_courses=None):\n page = requests.get(\n 'http://gla.ac.uk/coursecatalogue/courselist/' +\n '?code=REG30200000&name=School+of+Computing+Science')\n tree = html.fromstring(page.content)\n spans = tree.xpath('//span/text()')\n codes = []\n if wanted... | [
"0.6946371",
"0.6540668",
"0.63720375",
"0.62898386",
"0.6107234",
"0.6071788",
"0.5923579",
"0.585324",
"0.5844796",
"0.58082366",
"0.5749922",
"0.5556818",
"0.54912657",
"0.53892386",
"0.5379833",
"0.53704685",
"0.53665537",
"0.5356205",
"0.53560764",
"0.5349088",
"0.533566... | 0.7629145 | 0 |
Creates the TeX document from the Computer Science Course Catalog | def create_tex(unwanted_courses, wanted_courses=None):
page = requests.get(
'http://gla.ac.uk/coursecatalogue/courselist/' +
'?code=REG30200000&name=School+of+Computing+Science')
tree = html.fromstring(page.content)
spans = tree.xpath('//span/text()')
codes = []
if wanted_courses is ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeCourse( xmlFile, genPath, importPaths, commonFiles, rendererContent=True):\n\ttry:\n\n\t\t# parse the command line\n\t\tConfig.add_option('--verbose', help='Set verbosity to maximum', dest='verbosity', default=0, action='store_const', const=2)\n\t\tConfig.add_option('-v', '--verbosity', help='Set the verbo... | [
"0.6260808",
"0.6079598",
"0.5850458",
"0.5665877",
"0.55810404",
"0.55767274",
"0.5510529",
"0.55077094",
"0.550131",
"0.5462771",
"0.53828937",
"0.537524",
"0.53713846",
"0.5369341",
"0.533082",
"0.52978146",
"0.52650625",
"0.52579224",
"0.5252961",
"0.52399004",
"0.5219007... | 0.64500177 | 0 |
Generates a TeX document and then runs the pdflatex command to create a PDF from the TeX | def pdflatex(unwanted_courses):
create_tex(unwanted_courses)
cmd = ['pdflatex', '-interaction', 'nonstopmode', 'courses.tex']
proc = subprocess.Popen(cmd)
proc.communicate()
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pdf():\n env.file_ext = \".pdf\"\n local(\"pandoc {input_files} -o {output_file}{file_ext} -H {preamble_file} --template {template_file} --bibliography={bib_file} --csl={csl_file} -V fontsize=12pt -V papersize=a4paper -V documentclass:report -N --latex-engine=xelatex\".format(**env))",
"def compile_lat... | [
"0.7378825",
"0.71747476",
"0.7139049",
"0.70846206",
"0.6956496",
"0.6915404",
"0.69058365",
"0.68944186",
"0.67462385",
"0.66899025",
"0.66854495",
"0.66612506",
"0.65569717",
"0.6552778",
"0.65360767",
"0.64799696",
"0.6461581",
"0.6451979",
"0.6432288",
"0.63957024",
"0.6... | 0.7367564 | 1 |
Trim an upper triangle sparse matrix so that only the first n diagonals are kept. | def diag_trim(mat, n):
if sp.issparse(mat):
if mat.format != "csr":
raise ValueError("input type must be scipy.sparse.csr_matrix")
# Trim diagonals by removing all elements further than n in the
# upper triangle
trimmed = sp.tril(mat, n, format="csr")
trimmed = sp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trim_whitespace(matrix, details, min_gap):\r\n if details == -1:\r\n row = matrix[0, ]\r\n else:\r\n row = matrix[matrix.shape[0] - 1, ]\r\n\r\n min_left = np.argmin(row)\r\n min_right = np.argmin(row[::-1])\r\n\r\n if min_left > min_gap:\r\n ... | [
"0.64127666",
"0.58649224",
"0.57881296",
"0.5781573",
"0.5728801",
"0.57002896",
"0.5696073",
"0.568997",
"0.5671774",
"0.566362",
"0.566362",
"0.566362",
"0.56233585",
"0.5622041",
"0.5614353",
"0.55710584",
"0.55435014",
"0.5482823",
"0.5455417",
"0.54416484",
"0.54353005"... | 0.7814169 | 0 |
Computes genomic distance law by averaging over each diagonal in the upper triangle matrix. If a list of detectable bins is provided, pixels in missing bins will be excluded from the averages. A maximum distance can be specified to define how many diagonals should be computed. | def distance_law(
matrix, detectable_bins=None, max_dist=None, smooth=True, fun=np.nanmean
):
mat_n = matrix.shape[0]
if max_dist is None:
max_dist = mat_n
n_diags = min(mat_n, max_dist + 1)
dist = np.zeros(mat_n)
if detectable_bins is None:
detectable_bins = np.array(range(mat_n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_diag(max_lines):\r\n dsum = 1 # sum of diagonals\r\n cpt = 1 # number of lines processed\r\n val = 1 # value of the current place in the square\r\n inc = 0 # the increment between number for one line\r\n \r\n while cpt < max_lines:\r\n cpt += 2\r\n inc += 2\r\n \r\n ... | [
"0.5350398",
"0.52518773",
"0.5155675",
"0.5135908",
"0.50542927",
"0.502655",
"0.5009027",
"0.5004774",
"0.4977624",
"0.49264264",
"0.48782477",
"0.48724344",
"0.4847657",
"0.4825151",
"0.48010293",
"0.4734856",
"0.47299528",
"0.47192916",
"0.47074535",
"0.46959183",
"0.4675... | 0.6471979 | 0 |
Compute the sum of matrices bins (i.e. rows or columns) using only the upper triangle, assuming symmetrical matrices. | def sum_mat_bins(mat):
# Equivalaent to row or col sum on a full matrix
# Note: mat.sum returns a 'matrix' object. A1 extracts the 1D flat array
# from the matrix
return mat.sum(axis=0).A1 + mat.sum(axis=1).A1 - mat.diagonal(0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def row_col_sums(i, b_j, bins, C, n_u):\n s= C[i][i]*n_u[i]*n_u[i]\n for j in range(bins[b_j], bins[b_j+1]):\n if i != j:\n s+= (C[i][j] + C[j][i])*n_u[i]*n_u[j]\n return s",
"def block_sum(i, bins, C, n_u):\n s= 0.0\n for j in range(bins[i], bins[i+1]):\n for k in range(b... | [
"0.7041019",
"0.6156732",
"0.6129798",
"0.5976102",
"0.59643245",
"0.5771837",
"0.57445884",
"0.5654173",
"0.5501301",
"0.5317589",
"0.5288595",
"0.52820784",
"0.5261982",
"0.5255658",
"0.52305037",
"0.5229471",
"0.52255195",
"0.5207664",
"0.5206341",
"0.5196019",
"0.5180939"... | 0.7172675 | 0 |
Bootstrap sampling of contacts in a sparse HiC map. | def subsample_contacts(M, n_contacts):
S = M.data.copy()
# Match cell idx to cumulative number of contacts
cum_counts = np.cumsum(S)
# Total number of contacts to sample
tot_contacts = int(cum_counts[-1])
# Sample desired number of contacts from the range(0, n_contacts) array
sampled_conta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bootstrap(X):\n return X[np.random.choice(list(range(X.shape[0])), size=X.shape[0]), :]",
"def bootstrapping(datasample):\r\n \r\n datasample=df_to_array(datasample)\r\n \r\n boots_indexs=np.random.randint(len(datasample),size=(1,len(datasample)))\r\n \r\n whole_indexs=list(range(len(dat... | [
"0.60307676",
"0.5836601",
"0.57376236",
"0.56982666",
"0.5689801",
"0.5620543",
"0.5541793",
"0.5484117",
"0.54839253",
"0.5435804",
"0.54210573",
"0.53805405",
"0.5368052",
"0.5355705",
"0.5346038",
"0.5340237",
"0.5306805",
"0.53025925",
"0.5296711",
"0.5295456",
"0.528197... | 0.59620684 | 1 |
Adds a frame around input mask, given a kernel. The goal of this frame is define margins around the matrix where the kernel will not perform convolution (denoted by 1). If the matrix is upper symmetric, a margin of half the kernel's width is added below the diagonal and a maximum distance from the diagonal above which ... | def frame_missing_mask(mask, kernel_shape, sym_upper=False, max_dist=None):
if mask.dtype != bool:
raise ValueError("Mask must contain boolean values")
if not sp.issparse(mask):
raise ValueError("Mask must be a sparse matrix")
framed_mask = mask.copy()
ms, ns = mask.shape
mk, nk = k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slidekernelthroughdiagonal(kernel, matrix):\n size_kernel = kernel.shape[0]\n size_matrix = matrix.shape[0]\n result = np.zeros([size_matrix])\n for i in range(size_matrix):\n # Calculate zero padding needed\n padding_b = -min(i - int(size_kernel/2), 0)\n padding_a = -min(size_matrix - int(i + siz... | [
"0.56605875",
"0.5587884",
"0.5477105",
"0.5454366",
"0.5391526",
"0.5310862",
"0.52129424",
"0.509257",
"0.50285244",
"0.5000354",
"0.49889517",
"0.49485168",
"0.49176568",
"0.48939496",
"0.48860693",
"0.4881778",
"0.4866566",
"0.48574573",
"0.4845596",
"0.48219603",
"0.4799... | 0.5740741 | 0 |
Ensure all elements defined as missing by the mask are set to zero in the signal. If this is not the case, raises an error. | def check_missing_mask(signal, mask):
if sp.issparse(mask):
# Check if there are nonzero values in the signal reported as missing
# by the mask
missing_with_signal = np.nonzero(
abs(signal[mask.nonzero()[0], mask.nonzero()[1]]) > 0
)[0]
if len(missing_with_signal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def applymask(self,mask):\n self.spec[mask==0]=np.nan",
"def _check_missing_value_mask(self, missing_mask):\n if not missing_mask.any():\n raise ValueError(\"Input matrix is not missing any values\")\n if missing_mask.all():\n raise ValueError(\"Input matrix must have s... | [
"0.7038222",
"0.6567302",
"0.63071376",
"0.6267162",
"0.6249988",
"0.6000625",
"0.5920129",
"0.5898875",
"0.5888325",
"0.5880828",
"0.5875885",
"0.58599186",
"0.5855308",
"0.5855247",
"0.5853476",
"0.5831566",
"0.5795374",
"0.5774761",
"0.5770358",
"0.57691586",
"0.5761126",
... | 0.6792724 | 1 |
Given lists of valid rows and columns, generate a sparse matrix mask with missing pixels denoted as 1 and valid pixels as 0. If a max_dist is provided, upper symmetric matrices will only be flagged up to max_dist pixels from the diagonal. | def make_missing_mask(
shape, valid_rows, valid_cols, max_dist=None, sym_upper=False
):
# Error if the matrix upper symmetric but shape is rectangle or missing
# rows and cols are different
sm, sn = shape
if sym_upper and (sm != sn or len(valid_rows) != len(valid_cols)):
raise ValueError("Re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def frame_missing_mask(mask, kernel_shape, sym_upper=False, max_dist=None):\n if mask.dtype != bool:\n raise ValueError(\"Mask must contain boolean values\")\n if not sp.issparse(mask):\n raise ValueError(\"Mask must be a sparse matrix\")\n\n framed_mask = mask.copy()\n ms, ns = mask.shap... | [
"0.5894775",
"0.58664924",
"0.5579",
"0.55251396",
"0.545152",
"0.53834623",
"0.53789914",
"0.5377302",
"0.53023285",
"0.5288333",
"0.51945496",
"0.51902205",
"0.5188426",
"0.51522386",
"0.5135295",
"0.5130921",
"0.5122746",
"0.51174325",
"0.51109743",
"0.508941",
"0.5082233"... | 0.7036244 | 0 |
Adds margin of zeros around an input sparse matrix. | def zero_pad_sparse(mat, margin_h, margin_v, fmt="coo"):
sm, sn = mat.shape
padded_mat = mat.copy()
# Up and down margins initialized with zeros and filled as needed
margin_h_0 = sp.csr_matrix((sm, margin_h), dtype=mat.dtype)
margin_v_0 = sp.csr_matrix((margin_v, sn + 2 * margin_h), dtype=mat.dtype... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _pad_with_zeros(self, X, margin):\n newX = np.zeros((X.shape[0] + 2 * margin, X.shape[1] + 2 * margin, X.shape[2]))\n x_offset = margin\n y_offset = margin\n newX[x_offset:X.shape[0] + x_offset, y_offset:X.shape[1] + y_offset, :] = X\n return newX",
"def OffsetSparseMatrix(... | [
"0.6846492",
"0.6157045",
"0.6157045",
"0.6109819",
"0.59839016",
"0.59775317",
"0.59726745",
"0.59028137",
"0.5901642",
"0.5830433",
"0.57942516",
"0.57754564",
"0.5743076",
"0.57350683",
"0.57294387",
"0.57047725",
"0.5701384",
"0.5644425",
"0.5624889",
"0.56114304",
"0.560... | 0.7736398 | 0 |
Crop a kernel matrix to target size horizontally and vertically. If the target size is even, the target size is adjusted to the next integer up. | def crop_kernel(kernel, target_size):
# Use list for mutability
target = [d for d in target_size]
adjusted = False
for dim in range(len(target)):
if not target[dim] % 2:
target[dim] += 1
adjusted = True
if adjusted:
sys.stderr.write(
"WARNING: Crop... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crop_to_target(x, target):\n\n if target.ndim==3:\n t_h, t_w = target.shape[1], target.shape[2]\n elif target.ndim==4:\n t_h, t_w = target.shape[2], target.shape[3]\n cr = int((x.shape[2] - t_h) / 2)\n cc = int((x.shape[3] - t_w) / 2)\n x_cropped = x[:, :, cr:cr + t_h, cc:cc + t_w]... | [
"0.657598",
"0.62372273",
"0.6060326",
"0.58836097",
"0.56814396",
"0.5558945",
"0.5557947",
"0.55271006",
"0.54924375",
"0.5463341",
"0.54487395",
"0.5447843",
"0.5445061",
"0.544338",
"0.54312927",
"0.54123294",
"0.54112655",
"0.5396363",
"0.5391804",
"0.53821915",
"0.53773... | 0.78084946 | 0 |
Resize a kernel matrix based on the resolution at which it was defined and the signal resolution. E.g. if a kernel matrix was generated for 10kb and the input signal is 20kb, kernel size will be divided by two. If the kernel is enlarged, pixels are interpolated with a spline of degree 1. Alternatively, a resize factor ... | def resize_kernel(
kernel,
kernel_res=None,
signal_res=None,
factor=None,
min_size=7,
quiet=False,
):
km, kn = kernel.shape
if km != kn:
raise ValueError("kernel must be square.")
if not (km % 2) or not (kn % 2):
raise ValueError("kernel size must be odd.")
if fa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shrink_kernel(self, kernel, up_scale):\n up_scale = torch.tensor(up_scale).float()\n # boundary padding based on the scaling law\n pad_in = (torch.ceil(up_scale**2).int())*((kernel.shape[2]-1)//2)\n pad_h = (torch.ceil(up_scale).int())*((kernel.shape[3]-1)//2)\n pad_w = (torc... | [
"0.6673881",
"0.64376324",
"0.63498217",
"0.6145752",
"0.60997856",
"0.6078737",
"0.5899416",
"0.5899416",
"0.5854729",
"0.5854729",
"0.580574",
"0.58015907",
"0.57691246",
"0.57011503",
"0.56532955",
"0.55739254",
"0.5490137",
"0.5478357",
"0.5461603",
"0.5452446",
"0.529977... | 0.7894084 | 0 |
Performs truncated SVD on an input kernel, returning the singular vectors necessary to retain a given proportion of information contained in the kernel. | def factorise_kernel(kernel, prop_info=0.999):
u, sigma, v = la.svd(kernel)
total_info = np.sum(sigma ** 2)
# Compute min. number of singular vectors to retain enough info
keep_k = np.flatnonzero(np.cumsum(sigma ** 2) > prop_info * total_info)[0] + 1
if keep_k > np.floor(min(kernel.shape) / 2):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def truncated_svd(A,k=None):",
"def svd_shrink(X, tau):\n U,s,V = np.linalg.svd(X, full_matrices=False)\n return np.dot(U, np.dot(np.diag(shrink(s, tau)), V))",
"def reduce_svd(embeddings, seed=0):\n svd = TruncatedSVD(n_components=2, n_iter=10, random_state=seed)\n return svd.fit_transform(embeddi... | [
"0.7064768",
"0.6497113",
"0.647693",
"0.63251233",
"0.6254241",
"0.6164676",
"0.61603194",
"0.60960335",
"0.60589564",
"0.5987382",
"0.59055364",
"0.58650464",
"0.57826054",
"0.57542855",
"0.573676",
"0.56839186",
"0.5663144",
"0.5609878",
"0.5581168",
"0.5574882",
"0.557263... | 0.6894022 | 1 |
r"""Close a registry entry. | def close_registry_entry(cls, value):
out = False
if not value.closed: # pragma: debug
value.close()
out = True
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close(self):\n self.__exit__(None, None, None)",
"def close(self):\n self.__exit__(None, None, None)",
"def close(self):\n \n self.__exit__(None, None, None)\n return",
"def __del__(self):\n for key_path_prefix, registry_file in iter(self._registry_files.items()):\n ... | [
"0.62410325",
"0.62410325",
"0.6005659",
"0.6003081",
"0.59938776",
"0.5955254",
"0.592907",
"0.58687013",
"0.57975334",
"0.5778289",
"0.5778289",
"0.5778289",
"0.5778289",
"0.5778289",
"0.57693046",
"0.57626265",
"0.5747791",
"0.5740424",
"0.5720488",
"0.5720488",
"0.5716972... | 0.73456883 | 0 |
r"""Record the current position in the file/series. | def record_position(self):
_rec_pos = self.fd.tell()
_rec_ind = self._series_index
return _rec_pos, _rec_ind | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_position(self, file_pos, series_index=None):\n if series_index is None:\n series_index = self._series_index\n self.advance_in_series(series_index)\n self.advance_in_file(file_pos)",
"def record(self, pos):\n self.lasts += (datetime.now(), pos),\n if len(se... | [
"0.66489357",
"0.66329324",
"0.6479423",
"0.64465714",
"0.61586374",
"0.61237216",
"0.6114697",
"0.610729",
"0.6095362",
"0.60406315",
"0.5951866",
"0.59466505",
"0.5869703",
"0.58657867",
"0.58627445",
"0.58404976",
"0.5832795",
"0.58294195",
"0.5811629",
"0.5791412",
"0.575... | 0.7691817 | 0 |
r"""Change the position in the file/series. | def change_position(self, file_pos, series_index=None):
if series_index is None:
series_index = self._series_index
self.advance_in_series(series_index)
self.advance_in_file(file_pos) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setPosition(position):",
"def set_position(self, posicion):\n\n # FIXME: Actualmente no funciona bien\n posicion = int(posicion)\n if posicion != self.posicion:\n self.posicion = posicion\n self.entrada.write('seek %s %i 0\\n' % (posicion, 1))\n self.entr... | [
"0.72056144",
"0.70718175",
"0.67845094",
"0.6580323",
"0.6580323",
"0.6580323",
"0.6580323",
"0.6580323",
"0.6580323",
"0.6580323",
"0.6580323",
"0.6580323",
"0.6580323",
"0.6580323",
"0.6469467",
"0.6442066",
"0.64292395",
"0.64211136",
"0.6298545",
"0.62945306",
"0.6270689... | 0.84161323 | 0 |
r"""Advance to a certain position in the current file. | def advance_in_file(self, file_pos):
if self.is_open:
try:
self.fd.seek(file_pos)
except (AttributeError, ValueError): # pragma: debug
if self.is_open:
raise | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def advance(self) -> None:\n self.current_token = self.jack_file_tokens[self._token_idx]\n self._token_idx += 1",
"def change_position(self, file_pos, series_index=None):\n if series_index is None:\n series_index = self._series_index\n self.advance_in_series(series_index)\n... | [
"0.72152966",
"0.69049877",
"0.6838981",
"0.6814385",
"0.6776304",
"0.6665995",
"0.665468",
"0.6625875",
"0.6596541",
"0.65920854",
"0.65885144",
"0.6423817",
"0.62222093",
"0.61866915",
"0.61842614",
"0.6172611",
"0.6140963",
"0.61377656",
"0.61164963",
"0.6113868",
"0.60734... | 0.7815316 | 0 |
Return True if there is a pending symbolic updates for any one of the variables in `args`. If called with no arguments, return True if the update dictionary is nonempty. | def pending_update(*args):
if len(args) == 0:
return len(cf.symbolic_updates) > 0
else:
for x in _expand_args(args):
if is_graph_object(x) and x in cf.symbolic_updates:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(args):\n\n home = args.assert_home()\n\n if args.all:\n env_repos = list(home.iter_env_repos())\n else:\n env_repos = [home.get_env_repo(x) for x in args.repos] if args.repos else [home.get_env_repo()]\n\n success = True\n\n for env_repo in env_repos:\n did_update = e... | [
"0.5759457",
"0.5594278",
"0.5564285",
"0.5475863",
"0.54533947",
"0.5403371",
"0.5373276",
"0.53273535",
"0.5294355",
"0.52783906",
"0.52717745",
"0.52661645",
"0.5215869",
"0.52099615",
"0.5206429",
"0.51566654",
"0.5129506",
"0.51088214",
"0.5104792",
"0.509193",
"0.506166... | 0.8218321 | 0 |
Return the same function as theano.printing._print_fn, with the difference that 'file' is passed as a keyword argument to print(). | def _get_print_fn(file=sys.stdout):
def _print_fn(op, xin,):
for attr in op.attrs:
temp = getattr(xin, attr)
if callable(temp):
pmsg = temp()
else:
pmsg = temp
print(op.message, attr, '=', pmsg, file=file)
return _print_fn | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def real_print(*args, **kwargs):\n\n kwargs.setdefault('file', real_stdout)\n _python_print_function(*args, **kwargs)",
"def adv_print(*args, start='', in_file = False, **kwargs):\n max_line = kwargs.pop('max_line', False)\n print(kwargs)\n old_stdout = sys.stdout\n value = StringIO()\n sys.... | [
"0.7028008",
"0.60618174",
"0.58106077",
"0.58032954",
"0.57211655",
"0.57190937",
"0.57069385",
"0.568632",
"0.5670888",
"0.5670888",
"0.56702733",
"0.5655732",
"0.56508785",
"0.5643723",
"0.55961174",
"0.55758446",
"0.55572623",
"0.54762155",
"0.5462057",
"0.5454509",
"0.54... | 0.7636272 | 0 |
Helper function for printing just one element in an array. All parameters except `idx` are the same as for `print`. Returns an identity operation on `x`, so that it can be used as follows >>> x = shim.tensor(np.arange(100, 0.1)) >>> x = shim.print_array(x, idx=3) | def print_array(x, idx=slice(None), message=None, message_prefix="SHIM - ",
file=sys.stdout):
return set_subtensor(x[idx],
print(x[idx],
message=message,
message_prefix=message_prefix,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ndarray_print(nd):\n try:\n x = nd.tolist()\n except (TypeError, NotImplementedError):\n x = nd.tobytes()\n if isinstance(nd, ndarray):\n offset = nd.offset\n flags = nd.flags\n else:\n offset = 'unknown'\n flags = 'unknown'\n print(\n \"ndarray(%... | [
"0.60525095",
"0.601079",
"0.5855006",
"0.575493",
"0.5318782",
"0.52099293",
"0.5171336",
"0.5115472",
"0.50951475",
"0.50903505",
"0.50739056",
"0.5069581",
"0.49996632",
"0.49829748",
"0.4963213",
"0.49431276",
"0.49431276",
"0.49431276",
"0.49431276",
"0.4938878",
"0.4933... | 0.77429724 | 0 |
Call pretty printer (`pprint`) on Theano objects, otherwise standard `print` | def pprint(x):
if is_theano_object(x):
return _gettheano().printing.pprint(x)
else:
return str(x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_pydotprint_profile():\r\n\r\n # Skip test if pydot is not available.\r\n if not theano.printing.pydot_imported:\r\n raise SkipTest('pydot not available')\r\n\r\n A = tensor.matrix()\r\n f = theano.function([A], A + 1, mode='ProfileMode')\r\n theano.printing.pydotprint(f, print_output... | [
"0.67568576",
"0.66903853",
"0.6612041",
"0.64975744",
"0.63267666",
"0.63239855",
"0.62581927",
"0.6243194",
"0.61284935",
"0.61009616",
"0.5968577",
"0.5889163",
"0.58622116",
"0.5802376",
"0.5783404",
"0.57769144",
"0.5669858",
"0.5625584",
"0.5618598",
"0.55597955",
"0.55... | 0.7738382 | 0 |
If `value` is a Theano variable, return its test value if it is defined. Otherwise just return `value` unchanged. If `nofail` is False (default), will raise an error if no test value is found. Otherwise returns None | def get_test_value(var, nofail=False):
if 'theano' in sys.modules and isinstance(var, _getT().sharedvar.SharedVariable):
retval = var.get_value()
elif 'theano' in sys.modules and isinstance(var, _gettheano().graph.basic.Variable):
try:
retval = var.tag.test_value
except Attri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value_or_none(value):\n if value or value == 0:\n return value\n return None",
"def get_test_value(v):\r\n if not isinstance(v, graph.Variable):\r\n v_var = theano.tensor.as_tensor_variable(v)\r\n else:\r\n v_var = v\r\n return PureOp._get_test_value(v_var)",
"def _get_t... | [
"0.59126365",
"0.5759972",
"0.56993127",
"0.55516756",
"0.5535529",
"0.5529996",
"0.536491",
"0.53313243",
"0.5318258",
"0.5313379",
"0.53128356",
"0.5148102",
"0.509741",
"0.50536364",
"0.50174165",
"0.49973387",
"0.49730897",
"0.49612755",
"0.49369153",
"0.49357876",
"0.493... | 0.74623376 | 0 |
Todo There seems to be some redundancy between ``is_pure_symbolic(x)`` and ``not graph.is_computable(x)``. | def is_pure_symbolic(*var):
# return 'theano' in sys.modules and builtins.any(isinstance(v, _gettheano().tensor.TensorVariable)
return 'theano' in sys.modules and builtins.any(isinstance(v, cf.PureSymbolicTypes)
for v in _expand_args(var)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_pure(self) -> bool:\r\n return self.is_valid and np.all([x[\"operation\"].is_pure for x in self.operations_by_name.values()])",
"def is_pure(self):\r\n return isinstance(self, PureOperation)",
"def is_symbolic(self: Q) -> bool:\n\n symbolic = False\n\n if (\n h... | [
"0.65525603",
"0.6225219",
"0.6183948",
"0.6024547",
"0.57890093",
"0.55200416",
"0.5471868",
"0.5459004",
"0.5401552",
"0.53722376",
"0.5332143",
"0.53140587",
"0.5311742",
"0.5289241",
"0.5244963",
"0.5174868",
"0.51738834",
"0.517038",
"0.5164459",
"0.51191884",
"0.5084533... | 0.7302066 | 0 |
Return True if `var` is any recognized sparse format. | def issparse(var):
if 'theano.sparse' in sys.modules:
return (sp.sparse.issparse(var)
or isinstance(var, sys.modules['theano.sparse'].basic.SparseVariable))
else:
return sp.sparse.issparse(var) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isspsparse(var):\n if 'theano.sparse' in sys.modules:\n return (sp.sparse.issparse(var)\n or isinstance(var, sys.modules['theano.sparse'].basic.SparseVariable))\n else:\n return sp.sparse.issparse(var)",
"def is_sparse(constant) -> bool:\n return sp.issparse(constant)",
... | [
"0.80299467",
"0.7115952",
"0.6787843",
"0.66746426",
"0.6657034",
"0.6640711",
"0.65491956",
"0.647349",
"0.6378612",
"0.5713969",
"0.56804806",
"0.5675083",
"0.5631618",
"0.55671525",
"0.5554212",
"0.5530677",
"0.54940146",
"0.54143655",
"0.54069203",
"0.5393739",
"0.537159... | 0.7509615 | 1 |
Return True if `var` is sparse with `scipy.sparse` interface. True for scipy.sparse, theano.sparse. | def isspsparse(var):
if 'theano.sparse' in sys.modules:
return (sp.sparse.issparse(var)
or isinstance(var, sys.modules['theano.sparse'].basic.SparseVariable))
else:
return sp.sparse.issparse(var) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_sparse(x: Any, backend=None) -> bool:\r\n module = get_module(backend)\r\n return module.is_sparse(x)",
"def issparse(var):\n if 'theano.sparse' in sys.modules:\n return (sp.sparse.issparse(var)\n or isinstance(var, sys.modules['theano.sparse'].basic.SparseVariable))\n el... | [
"0.73790324",
"0.72182786",
"0.7192387",
"0.71083176",
"0.706764",
"0.65949607",
"0.6314302",
"0.62896657",
"0.62845683",
"0.6133798",
"0.6107449",
"0.6087067",
"0.6074301",
"0.6030176",
"0.60223293",
"0.5920868",
"0.585102",
"0.5810927",
"0.57268214",
"0.57231104",
"0.570871... | 0.86598843 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.