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 |
|---|---|---|---|---|---|---|
Uses the selected spell | async def cast(
event,
spell: ('str', 'select a spell'),
):
spell = get_spell_or_abort(spell)
return f'{event.user:f} just used {spell}; It is super effective!' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def func(self):\n spell_list = sorted(SPELLS.keys())\n args = self.args.lower()\n args = args.strip(\" \")\n caller = self.caller\n spell_to_learn = []\n\n if not args or len(args) < 3: # No spell given\n caller.msg(\"Usage: learnspell <spell name>\")\n ... | [
"0.6842631",
"0.6699569",
"0.6081688",
"0.6040999",
"0.57929784",
"0.578911",
"0.57451016",
"0.56992674",
"0.5644914",
"0.56293833",
"0.5603479",
"0.5585289",
"0.5547602",
"0.5472606",
"0.54705864",
"0.5456883",
"0.5443241",
"0.54431385",
"0.5424684",
"0.5421093",
"0.5412749"... | 0.69981647 | 0 |
Adds an emoji to the guild. | async def add_emoji(
client,
event,
emoji: ('str', 'The emoji to add.'),
name: ('str', 'Custom name to add the emoji with.') = None
):
if not client.is_owner(event.user):
abort('Owner only!')
emoji = parse_emoji(emoji)
if emoji is None:
abort('That\'s not an emoji.')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emoji(self, new_emoji):\n self._manager._items[self.name][\"emoji\"] = new_emoji",
"async def process_add_emoji(\n emoji,\n emoji_name,\n user_id,\n ctx: commands.Context = None,\n inter: AppCmdInter = None,\n allowed_mentions=None,\n):\n response_deferred = await defer_inter(inte... | [
"0.7171064",
"0.71063775",
"0.6896429",
"0.68556017",
"0.6616149",
"0.6526354",
"0.6435637",
"0.64106715",
"0.6385405",
"0.6366206",
"0.6337566",
"0.6321024",
"0.6158689",
"0.60777974",
"0.60739106",
"0.6055111",
"0.6034358",
"0.6017389",
"0.5974898",
"0.5964543",
"0.586553",... | 0.75170183 | 0 |
Add role to a user. | async def add_role(
client,
event,
user: ('user', 'User to add role to'),
role: ('role', 'The role to give'),
):
# Check for permissions
if not event.user_permissions.can_manage_roles:
abort('You need `manage roles` permission to invoke this command.')
if not event.guild.cached_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def addrole(self, ctx, user: discord.Member=None, *, role=None):\r\n if user is None or role is None:\r\n return await ctx.send(\"Incorrect usage! *;addrole @user role*\")\r\n r = discord.utils.get(ctx.guild.roles, name=str(role))\r\n if r is None:\r\n return await ... | [
"0.82571524",
"0.8177443",
"0.78452474",
"0.7781555",
"0.77604127",
"0.7734932",
"0.7703948",
"0.76375777",
"0.7601349",
"0.74736786",
"0.74103475",
"0.7407653",
"0.7396722",
"0.73556995",
"0.73501986",
"0.72284776",
"0.7225049",
"0.71885777",
"0.7181446",
"0.71257436",
"0.70... | 0.8291285 | 0 |
Add a new waifu to the database! | async def add_waifu():
return WAIFU_FORM | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_database():\n db_conn.execute(\"INSERT INTO Fietsenstalling (Naam, Achternaam, Adress, FietsNr, PIN) VALUES \"\n \"(?, ?, ?, ?, ?);\",(Naam, Achternaam, Adress, FietsNr, PIN))\n\n db_conn.commit()",
"def addUsertoDatabase(self):\r\n self.c.execute(\"\"\"INSERT INTO stud... | [
"0.62806755",
"0.6170017",
"0.60218495",
"0.59828955",
"0.5796458",
"0.57776827",
"0.5697804",
"0.5691923",
"0.56790346",
"0.5661239",
"0.56476194",
"0.5644497",
"0.563909",
"0.5632404",
"0.5625129",
"0.5596024",
"0.5571909",
"0.55557925",
"0.55294317",
"0.55294317",
"0.55242... | 0.67905253 | 0 |
Returns an added waifu. | async def get_waifu(
name: ('str', 'Their name?')
):
try:
waifu = WAIFUS[name.casefold()]
except KeyError:
abort(f'There is no waifu named like: {name}.')
return waifu.embed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def add_waifu():\n return WAIFU_FORM",
"def wave_add_new():\n return _u2i(_pigpio_command(_control, _PI_CMD_WVNEW, 0, 0))",
"def wishlist_add(request):\n\n result = {}\n\n u = request.user\n\n p = Product.objects.get_by_sku(request.POST['sku'])\n\n if p is None:\n result[\"result\... | [
"0.6947331",
"0.5965967",
"0.5626294",
"0.5455911",
"0.53932244",
"0.5364499",
"0.53162444",
"0.5274032",
"0.5195086",
"0.5140979",
"0.5055691",
"0.5050816",
"0.504182",
"0.5026168",
"0.50212723",
"0.498674",
"0.4972312",
"0.49669898",
"0.4939952",
"0.49216947",
"0.49164072",... | 0.61611295 | 1 |
Edits a waifu. | You must own her. | async def edit_waifu(
event,
name: ('str', 'Their name?'),
field : (['age', 'bio', 'hair'], 'Which field to edit?'),
):
key = name.casefold()
try:
waifu = WAIFUS[key]
except KeyError:
abort(f'There is no waifu named like: {name}.')
if waifu.user is not event.user:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit():",
"def home_edituser():\n\tpass",
"def update_user():",
"def update_user():\n #TODO user update \n pass",
"async def add_waifu():\n return WAIFU_FORM",
"def update(self, user: U) -> None:\n ...",
"def edit():\n database.ask(mode='single')\n F = database.check(single=Tr... | [
"0.703681",
"0.67200714",
"0.6531209",
"0.6521494",
"0.64730537",
"0.6406972",
"0.6234079",
"0.61912",
"0.61450255",
"0.60919994",
"0.60782635",
"0.59584224",
"0.59353",
"0.5903634",
"0.5852486",
"0.5777315",
"0.57746786",
"0.5765526",
"0.5761504",
"0.57450265",
"0.57444936",... | 0.7640311 | 0 |
Shows the given custom emoji. | async def show_emoji(
emoji_name: str
):
emoji = parse_emoji(emoji_name)
if emoji is None:
abort('Please give an emoji')
if emoji.is_unicode_emoji():
abort('Cannot link unicode emojis.')
return f'**Name:** {emoji} **Link:** {emoji.url}' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def emoji(self, ctx):\n emb = discord.Embed(colour=self.color)\n emb.add_field(name='Usage', value=f'```{self.bot.command_prefix}emoji <emojiname>```')\n await ctx.message.edit(embed=emb)",
"def is_custom_emoji(self):\n ...",
"async def getemoji(self, ctx):\n pass",
"... | [
"0.74917614",
"0.6761148",
"0.6492297",
"0.619809",
"0.61710256",
"0.6136859",
"0.61155015",
"0.6039681",
"0.59957427",
"0.5945978",
"0.5936778",
"0.5936708",
"0.58585626",
"0.5836026",
"0.5809411",
"0.5724715",
"0.5692132",
"0.5662418",
"0.5606713",
"0.55910206",
"0.5587064"... | 0.75498223 | 0 |
Returns the selected text channel's name's length. | async def text_channel_name_length(
channel: Channel
):
return len(channel.name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def voice_channel_name_length(\n channel: P('channel', 'Select a voice channel', channel_types = [ChannelType.guild_voice])\n):\n return len(channel.name)",
"async def thread_channel_name_length(\n channel: ('channel_group_thread', 'Select a thread channel.')\n):\n return len(channel.name)",
... | [
"0.7989445",
"0.77088827",
"0.67712826",
"0.6691694",
"0.6674016",
"0.6535482",
"0.64485866",
"0.6269007",
"0.6205133",
"0.61872053",
"0.6186812",
"0.6179118",
"0.6176119",
"0.6155029",
"0.61237496",
"0.6103924",
"0.60789996",
"0.60677344",
"0.6062524",
"0.6050127",
"0.605012... | 0.85015506 | 0 |
Encode a position given in float arguments latitude, longitude to a geohash which will have the character count precision. | def geohash_encode(latitude, longitude, precision=12):
lat_interval, lon_interval = (-90.0, 90.0), (-180.0, 180.0)
base32 = '0123456789bcdefghjkmnpqrstuvwxyz'
geohash = []
bits = [16, 8, 4, 2, 1]
bit = 0
ch = 0
even = True
while len(geohash) < precision:
if even:
mid ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode(latitude, longitude, precision=12):\n lat_interval, lon_interval = (-90.0, 90.0), (-180.0, 180.0)\n geohash = []\n bits = [ 16, 8, 4, 2, 1 ]\n bit = 0\n ch = 0\n even = True\n while len(geohash) < precision:\n if even:\n mid = (lon_interval[0] + lon_interval[1]) / ... | [
"0.7769761",
"0.7752675",
"0.72821146",
"0.71992105",
"0.6168017",
"0.61100185",
"0.59604454",
"0.5934149",
"0.5906312",
"0.5894907",
"0.5872776",
"0.58589303",
"0.56805354",
"0.5602078",
"0.5597624",
"0.5574245",
"0.5522198",
"0.5442411",
"0.537271",
"0.5353991",
"0.53291243... | 0.79064786 | 0 |
Push the executor pacakge to Jina Hub. | def push(self) -> None:
with ImportExtensions(required=True):
import requests
pkg_path = Path(self.args.path)
if not pkg_path.exists():
self.logger.critical(f'`{self.args.path}` is not a valid path!')
exit(1)
request_headers = self._get_request_head... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def launch():\n\n core.openflow.addListenerByName(\"ConnectionUp\", _handle_ConnectionUp)\n log.info(\"Hub running\")",
"def pull(self) -> None:\n cached_zip_filepath = None\n try:\n scheme, name, tag, secret = parse_hub_uri(self.args.uri)\n\n executor = HubIO.fetch(name... | [
"0.6232041",
"0.5887297",
"0.58601266",
"0.58165723",
"0.5768271",
"0.56156373",
"0.55585796",
"0.55408835",
"0.5533365",
"0.5520638",
"0.5495429",
"0.54430073",
"0.5429095",
"0.5398484",
"0.53716093",
"0.53678733",
"0.5364028",
"0.53437376",
"0.5337322",
"0.5332302",
"0.5331... | 0.7116745 | 0 |
Pull the executor package from Jina Hub. | def pull(self) -> None:
cached_zip_filepath = None
try:
scheme, name, tag, secret = parse_hub_uri(self.args.uri)
executor = HubIO.fetch(name, tag=tag, secret=secret)
if not tag:
tag = executor.tag
uuid = executor.uuid
image_n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push(self) -> None:\n\n with ImportExtensions(required=True):\n import requests\n\n pkg_path = Path(self.args.path)\n if not pkg_path.exists():\n self.logger.critical(f'`{self.args.path}` is not a valid path!')\n exit(1)\n\n request_headers = self._g... | [
"0.641738",
"0.61639076",
"0.58618015",
"0.5724971",
"0.53448755",
"0.52730477",
"0.5237997",
"0.5234491",
"0.52015465",
"0.51506555",
"0.5101893",
"0.5095056",
"0.5087197",
"0.50491524",
"0.5016268",
"0.50123864",
"0.5008125",
"0.50051403",
"0.4996761",
"0.4936391",
"0.49340... | 0.77400756 | 0 |
Function put_histogram Create the histogram of color of the person under it Color field | def put_histogram(self, img, coords):
self.char_color.update(img, coords) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_histogram(self, tag, values, global_step=None, bins='tensorflow'):\n values = make_np(values)\n self.vis.histogram(make_np(values), opts={'title': tag})",
"def makeHistogram(values, numBins, xLabel, yLabel, title=None):",
"def hist(self):\r\n plt.hist(self.data_array, bins='auto', ... | [
"0.6663404",
"0.6595014",
"0.63798743",
"0.63636565",
"0.63032633",
"0.6286832",
"0.62409437",
"0.62236524",
"0.6212975",
"0.62078536",
"0.6198712",
"0.6159521",
"0.61527514",
"0.61278516",
"0.6118984",
"0.60784984",
"0.60736775",
"0.60601574",
"0.6052596",
"0.6043766",
"0.60... | 0.7029851 | 0 |
Reopen streams here to prevent buffering. | def reopen_streams(self):
sys.stdin = os.fdopen(0, 'r', 0)
sys.stdout = os.fdopen(1, 'w', 0)
sys.stderr = os.fdopen(2, 'w', 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reopen():",
"def refresh(self) -> None:\n if self._is_buffer_full():\n self.stream.close()\n self._open_stream() # re-initial self.stream\n self._buffer = bytearray()\n self._buffer_pointer = -1",
"def reopen_files(self):\r\n for log in (self.error_log... | [
"0.7697773",
"0.6703574",
"0.6626337",
"0.6617042",
"0.654685",
"0.65099376",
"0.6501303",
"0.6500059",
"0.64899385",
"0.64335364",
"0.6267602",
"0.6215058",
"0.61688745",
"0.61634976",
"0.61516905",
"0.6137321",
"0.61222017",
"0.6106612",
"0.6052286",
"0.6048962",
"0.6047413... | 0.80338305 | 0 |
the data is in SORT1, but the flags are wrong | def set_as_sort1(self):
if self.is_sort1:
#if self.analysis_code == 1:
#self.nonlinear_factor = np.nan
#print(self.data_code)
#print(self._times, type(self._times))
#aaa
return
#print(f'{self.class_name}-{self.table_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_for_sorting() -> NoReturn:\n raise NotImplementedError",
"def data_for_sorting() -> NoReturn:\n raise NotImplementedError",
"def reversesort(self):\n ...",
"def oldsortslice(self):\n ...",
"def data_for_sorting():\n return RaggedArray([[1, 0], [2, 0], [0, 0]])",
"def sortK... | [
"0.53327185",
"0.53327185",
"0.53093725",
"0.52391124",
"0.5232353",
"0.52152324",
"0.52016133",
"0.5197189",
"0.51695603",
"0.5158035",
"0.51258236",
"0.5116387",
"0.51104957",
"0.5099126",
"0.5062088",
"0.5054855",
"0.5042443",
"0.5038638",
"0.5018408",
"0.50026417",
"0.499... | 0.6509692 | 0 |
Delete an appointment from the appointment table | def delete_appointment(request, appointment_id):
appointment_id = appointment_id
if not appointment_id:
return HttpResponse("Please provide an appointment Id"), 406
try:
appointment = Appointment.objects.get(id=int(appointment_id))
except:
return HttpResponse("No appointmen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_patient_appointment():\n if request.method == 'POST':\n appointment_id = request.form['appointment_id']\n response_delete_patient_appointment = requests.post(server_url + 'patient/delete_appointment', json={\n 'appointment_id': appointment_id\n })\n response_del... | [
"0.7246865",
"0.69911546",
"0.6967758",
"0.69243217",
"0.6683708",
"0.6667006",
"0.64580506",
"0.6360693",
"0.63219357",
"0.6229985",
"0.6189006",
"0.6186252",
"0.6182702",
"0.615862",
"0.61367667",
"0.6119257",
"0.6077346",
"0.60747683",
"0.60690594",
"0.6059356",
"0.605511"... | 0.7938065 | 0 |
For a given reward function and horizon, calculate the MaxEnt policy that gives equal weight to equal reward trajectorie \s | def calcMaxEntPolicy(trans_mat, horizon, r_weights, state_features):
n_states = np.shape(trans_mat)[0]
n_actions = np.shape(trans_mat)[1]
partition = np.zeros((n_states, 1))
policy = np.zeros((n_states, n_actions))
partition[n_states-1] = 1
reward = np.exp(np.dot(r_weights, state_features.T))
# Calculate part... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_policy(env, policy, V, discount_factor):\n\n for state in range(env.nS):\n # for a given state compute state-action value.\n action_values = one_step_lookahead(env, state, V, discount_factor)\n\n # choose the action which maximizes the state-action value.\n policy[state] =... | [
"0.65174586",
"0.6455131",
"0.62911916",
"0.6210671",
"0.61917514",
"0.6106755",
"0.60980415",
"0.60720646",
"0.6065897",
"0.60095304",
"0.5995886",
"0.5988406",
"0.59755456",
"0.5938648",
"0.59124494",
"0.5908187",
"0.58875597",
"0.58874375",
"0.58826035",
"0.5856284",
"0.58... | 0.71800405 | 0 |
Given a MaxEnt policy, begin with the start state distribution and propagate forward to find the expected state frequencies over the horizon | def calcExpectedStateFreq(trans_mat, horizon, start_dist, policy):
n_states = np.shape(trans_mat)[0]
n_actions = np.shape(trans_mat)[1]
# Copy start_dist for complete horizon, states x horizon
exp_svf = np.zeros((n_states, horizon))
exp_svf[0,0] = 1.0
# Calculate Expected State Frequency for (state, time) pair
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calcMaxEntPolicy(trans_mat, horizon, r_weights, state_features):\n\tn_states = np.shape(trans_mat)[0]\n\tn_actions = np.shape(trans_mat)[1]\n\n\tpartition = np.zeros((n_states, 1))\n\tpolicy = np.zeros((n_states, n_actions))\n\n\tpartition[n_states-1] = 1\n\treward = np.exp(np.dot(r_weights, state_features.T))... | [
"0.6379594",
"0.6345793",
"0.62748617",
"0.6227867",
"0.61537546",
"0.60586053",
"0.60436994",
"0.60436994",
"0.6035179",
"0.6025242",
"0.6023306",
"0.60075766",
"0.5958909",
"0.59503",
"0.5950126",
"0.5924466",
"0.5919219",
"0.5919196",
"0.5918052",
"0.58889544",
"0.5880986"... | 0.70631313 | 0 |
Compute expected feature expectations from demonstration trajectories | def find_feature_expectations(state_features, demos):
feature_exp = np.zeros(state_features.shape[1])
for demo in demos:
for state in demo:
feature_exp += state_features[state]
# Expected feature_exp
return feature_exp/np.shape(demos)[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_predictor():",
"def test_basic(self):\n data = get()\n metrics = [verif.metric.Within(),\n verif.metric.A(), # Hit\n verif.metric.B(), # FA\n verif.metric.C(), # Miss\n verif.metric.D(), # Correct rejection\n v... | [
"0.6707237",
"0.6620154",
"0.6500564",
"0.64482635",
"0.6439859",
"0.6421214",
"0.6377413",
"0.6242838",
"0.62241733",
"0.61963874",
"0.61854374",
"0.6150502",
"0.6111971",
"0.6109932",
"0.60865235",
"0.60865235",
"0.6078514",
"0.6074583",
"0.6064137",
"0.6050908",
"0.6041128... | 0.6980132 | 0 |
Unfolds a tensor T into a matrix, taking the dimension "dim" of T as the first dimension of the matrix, and flattening all the other dimensions into the other one dimension of the matrix. dim starts from 0. | def unfold(T, dim):
Tm=np.moveaxis(T, dim, 0)
return Tm.reshape(T.shape[dim],-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flatten(tensor):\n C = tensor.size(1)\n # new axis order\n axis_order = (1, 0) + tuple(range(2, tensor.dim()))\n # Transpose: (N, C, D, H, W) -> (C, N, D, H, W)\n transposed = tensor.permute(axis_order)\n # Flatten: (C, N, D, H, W) -> (C, N * D * H * W)\n return transposed.contiguous().vie... | [
"0.7043688",
"0.6872559",
"0.6866148",
"0.6625046",
"0.6595738",
"0.6544334",
"0.6462534",
"0.6318924",
"0.63155955",
"0.6307684",
"0.6298893",
"0.62986493",
"0.62389565",
"0.6198749",
"0.6193831",
"0.6192542",
"0.6138287",
"0.60814816",
"0.6069293",
"0.6062363",
"0.60362655"... | 0.81962144 | 0 |
nMode product of a tensor T and a matrix M, the summation is made along the nth dim. definition in paper "A MULTILINEAR SINGULAR VALUE DECOMPOSITION" by LIEVEN DE LATHAUWER , BART DE MOOR , AND JOOS VANDEWALLE For example, n with value 0, 1, or 2, would specify the 1st, 2nd or 3rd dim of the tensor T. For the matrix M,... | def nModeProduct(T, M, n):
P=tensordot(T, M, axes=([n], [1]))
return np.rollaxis(P, len(T.shape)-1, n) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ttm(t, m, k):\n\n dim_list = [] # initialize a list to save dimension index to transpose the tensor reshapped from 2D matrix\n shape_list = [] # initialize a list to save the dimensions to reshape 2D matrix back to tensor\n total_dim = len(t.shape)\n for i in range(total_dim):\n dim_list.a... | [
"0.60840887",
"0.5962957",
"0.5834595",
"0.57553023",
"0.5729404",
"0.56230754",
"0.55998474",
"0.558549",
"0.55777717",
"0.5541569",
"0.54854864",
"0.54752266",
"0.53972495",
"0.53863096",
"0.53441954",
"0.5337099",
"0.5322091",
"0.5305267",
"0.5296987",
"0.52967924",
"0.527... | 0.84308904 | 0 |
This is a recursive partioned QR. about two times faster than QR for tall matrices | def fast_qr(A):
N,M=A.shape
if N < M:
Q, R =qr(A) # not tall matrices, use normal qr
elif M>16: # the minimal partition size is 32
R=np.zeros((M,M))
k= np.ceil(M/2).astype(int)
qa, R[:k, :k]=fast_qr(A[:,:k])
R[:k,k:] = np.dot(qa.T, A[:,k:])
qb, R[k:, k:]=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def qr(in_A):\n # input checks\n Ndim = numpy.ndim(in_A)\n assert Ndim == 2\n N,M = numpy.shape(in_A)\n assert N==M\n D,P = in_A[0,0].data.shape\n\n # prepare R and QT\n R = in_A.copy()\n QT = numpy.array([[UTPS(numpy.zeros((D,P))) for c in range(N)] for r in range(N) ])\n for n in ra... | [
"0.7430045",
"0.71422714",
"0.6963531",
"0.68576527",
"0.6795892",
"0.66816163",
"0.65249866",
"0.65225244",
"0.65213066",
"0.65106",
"0.64953566",
"0.6453057",
"0.64338183",
"0.64164525",
"0.63908815",
"0.63486344",
"0.62450737",
"0.6244796",
"0.62227124",
"0.62222993",
"0.6... | 0.74643546 | 0 |
Populates CLOUDS variable with mappings from providers to clouds | def _populate_clouds():
for key, value in list(globals().items()):
if not key.startswith('_') and key.endswith(
'Cloud') and key != 'Cloud':
if not value._controller_cls:
continue
if issubclass(value, Cloud) and value is not Cloud:
CLOU... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_clouds(auth=None):\n get_operator_cloud(auth)\n get_openstack_cloud(auth)",
"def setup_clouds(auth=None):\n get_operator_cloud(auth)\n get_openstack_cloud(auth)",
"def get_clouds():\n clouds = [ x.get('cloud') for x in Schedconfig.objects.values('cloud').distinct() ]\n locale.setloc... | [
"0.5848229",
"0.5848229",
"0.5762712",
"0.5732575",
"0.55106837",
"0.5443013",
"0.54311204",
"0.5407812",
"0.5398516",
"0.5377608",
"0.5274966",
"0.52417177",
"0.5234368",
"0.52056146",
"0.5200299",
"0.5192333",
"0.51870906",
"0.51459664",
"0.5107439",
"0.50989896",
"0.508725... | 0.8129826 | 0 |
Decide whether the minitaur has fallen. If the up directions between the base and the world is larger (the dot product is smaller than 0.5), the minitaur is considered fallen. | def is_fallen(self):
orientation = self.minitaur_env.minitaur.GetBaseOrientation()
rot_mat = self.minitaur_env._pybullet_client.getMatrixFromQuaternion(orientation)
local_up = rot_mat[6:]
return (np.dot(np.asarray([0, 0, 1]), np.asarray(local_up)) < 0.3) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def at_goal(self):\n return self.distance_from_goal < self.robot.wheels.base_length/2",
"def at_goal(self):\n return self.distance_from_goal < self.robot.wheels.base_length/2",
"def is_upper(self):\n return self.z < 0",
"def is_at_wall(self):\n return self.distmin < self.distmax*0... | [
"0.63688046",
"0.63688046",
"0.58916235",
"0.58059263",
"0.5784403",
"0.5761813",
"0.57414496",
"0.5711356",
"0.5707844",
"0.5697768",
"0.5675407",
"0.56628335",
"0.56495374",
"0.56233096",
"0.55607885",
"0.555384",
"0.55337554",
"0.5527628",
"0.5523818",
"0.55205244",
"0.550... | 0.72476137 | 0 |
This function reads the meteo for a given day | def read_meteo_day(filename=None):
if not filename:
filename = settings.METEO_DAY_FILENAME
return pd.read_csv(filename, sep=';', parse_dates=[0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findReadData(day,scope,chan,shot):\n return readData(conf.dataDir + \"%d_01_2013_osc%d/C%dosc%d-%05d.txt\" % (day, scope, chan, scope, shot),\n conf.timeDelay[scope,chan],\n conf.ampMult[scope,chan])",
"def get_weather_on_date(date, meteo_day, store_id):\n return meteo_d... | [
"0.59969056",
"0.5583099",
"0.5550923",
"0.54960376",
"0.5361208",
"0.52583355",
"0.5196197",
"0.5166738",
"0.5159462",
"0.51388514",
"0.5126825",
"0.5095728",
"0.50937",
"0.5065566",
"0.5062365",
"0.5062365",
"0.5062365",
"0.5062365",
"0.5062365",
"0.50592273",
"0.50472623",... | 0.6528976 | 0 |
This function reads the meteo for a given week | def read_meteo_week(filename=None):
if not filename:
filename = settings.METEO_WEEK_FILENAME
# This function is the date parser for the week
parser = lambda x: pd.datetime.strptime(x, '%Y%W')
return pd.read_csv(filename, sep=';', parse_dates=[4], date_parser=parser) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weekly():",
"def LoadWeeklyChart(self, week):\n file = '%s.html' % week\n if file in os.listdir(self.HTML_DIR):\n print 'Loading chart for week of %s' % week\n with open(os.path.join(self.HTML_DIR, file), 'r') as f:\n chart = f.read()\n else:\n chart = self.DownloadWeeklyChart(... | [
"0.6283611",
"0.5888736",
"0.5871395",
"0.5666913",
"0.5573738",
"0.556567",
"0.5563634",
"0.5530871",
"0.5527525",
"0.54581827",
"0.54551387",
"0.54536134",
"0.539935",
"0.53837866",
"0.53796595",
"0.53618705",
"0.5316805",
"0.5285709",
"0.52359337",
"0.52143586",
"0.5210340... | 0.7170781 | 0 |
This function gives us all the weather information/prediction for a given day in a given store | def get_weather_on_date(date, meteo_day, store_id):
return meteo_day[(meteo_day['STO_EAN'] == store_id) & (meteo_day['DATE_KEY'] == date)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_weather_details(self, days: int = None):\n forecast = super().get_weather_forecast(self.BASE_URL)\n headers = [\n \"date\",\n \"min_temp\",\n \"max_temp\",\n \"phrase\",\n \"probability\",\n \"wind_speed\"]\n if days is ... | [
"0.6687217",
"0.65223783",
"0.64728045",
"0.64251363",
"0.6395729",
"0.63380027",
"0.6210881",
"0.61134636",
"0.59816873",
"0.59385264",
"0.589162",
"0.58533895",
"0.5828796",
"0.58262205",
"0.58206254",
"0.57987386",
"0.576516",
"0.5762254",
"0.5755952",
"0.57303375",
"0.571... | 0.6820833 | 0 |
This function gives us the sum of all sales value for a given product on a given date. It also return the quantity of products sold in weight | def get_volume_product_on_date(product_barcode, date, store_id, transactions):
transactions_day = transactions[(transactions['STO_EAN'] == store_id) &
(transactions['BARCODE'] == product_barcode) &
(transactions['TRX_DATETIME'] >= pd.to_datetime(date).date())
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_daily_product_sales(self):\n self.products['daily'] = self.products['session_start_date'].apply(lambda x: convert_dt_to_day_str(x))\n self.products = self.products.query(\"payment_amount == payment_amount\")\n self.products['payment_amount'] = self.products['payment_amount'].apply(lamb... | [
"0.68591684",
"0.6359811",
"0.6157366",
"0.60738873",
"0.6023802",
"0.5834238",
"0.58238226",
"0.5762609",
"0.5700813",
"0.56557745",
"0.5614207",
"0.5598102",
"0.5577538",
"0.55420864",
"0.5539422",
"0.55292135",
"0.5523316",
"0.54981434",
"0.54949695",
"0.5454806",
"0.54391... | 0.6372925 | 1 |
This function convert a date to the corresponding type of the day (working day/holiday/MonSun) | def generate_day_type(date):
cal = France()
if cal.is_holiday(date):
# If Mon-Friday
if date.weekday() in range(5):
return 0.
else:
return 1.
else:
if date.weekday() in range(5):
return 1.
else:
return 0. | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_to_day_of_week(date):\n return date.weekday()",
"def number_to_day(n):\n if n == 1:\n return \"Sunday\"\n elif n == 2:\n return \"Monday\"\n elif n == 3:\n return \"Tuesday\"\n elif n == 4:\n return \"Wednesday\"\n elif n == 5:\n return \"Thursday\"\n... | [
"0.65448165",
"0.6300779",
"0.61504966",
"0.61332077",
"0.612294",
"0.6048355",
"0.60400957",
"0.6037049",
"0.60039747",
"0.5941737",
"0.5941737",
"0.5905311",
"0.5904082",
"0.58850664",
"0.5838948",
"0.58364326",
"0.58314884",
"0.580064",
"0.5735178",
"0.5730053",
"0.5729248... | 0.73416775 | 0 |
This function generates the weather conditions using a minitype trapezium distribution the temperature and its type | def generate_weather_conditions(temperature, temp_type):
if temp_type == "MIN" or temperature < 5:
if temperature > 10:
return 0
elif temperature >= 0:
return (10.-temperature)/10.
else:
return 1
elif temp_type == "AVG":
if temperature > 25:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def genWeather():\n\n weather = random.choice(weather_conditions.keys())\n condition = weather_conditions[weather]\n (tMax, tMin) = condition[\"temperature\"]\n (pMax, pMin) = condition[\"pressure\"]\n (hMax, hMin) = condition[\"humidity\"]\n\n return weather + \"|\" + str(round(random.uniform(tM... | [
"0.6137704",
"0.5869371",
"0.57176363",
"0.5665171",
"0.56162924",
"0.5519943",
"0.55192375",
"0.54380035",
"0.54261625",
"0.5379157",
"0.52772623",
"0.52344805",
"0.52321464",
"0.5232041",
"0.52294254",
"0.52078223",
"0.5178827",
"0.51737756",
"0.5172065",
"0.51715505",
"0.5... | 0.74097484 | 0 |
Calculate net income after federal and state tax | def calc_tax(state: str, income: float, federal_tax: float = 10.0):
states_taxes = {
"AL": ("Alabama", 5),
"AK": ("Alaska", 3),
"FL": ("Florida", 4),
"IL": ("Illinois", 8),
}
state = state.upper()
if state not in states_taxes:
raise AssertionError("Taxes calcula... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def monthly_net_income(gross_income, income_tax):\n return gross_income - income_tax",
"def calculate_taxes(self, proforma, technologies):\n tax_calcs = copy.deepcopy(proforma)\n # 1) Redistribute capital cost according to the DER's MACRS value to get depreciation\n for der_inst in techno... | [
"0.7409301",
"0.67553556",
"0.66763127",
"0.6645111",
"0.64896935",
"0.64231426",
"0.63536626",
"0.6341549",
"0.6228795",
"0.61981183",
"0.61333615",
"0.6070119",
"0.6002093",
"0.5992931",
"0.59346694",
"0.5908333",
"0.589499",
"0.58864194",
"0.5868002",
"0.585597",
"0.583016... | 0.7955427 | 0 |
reads in a file and returns np.arrays containing values for frequency and amplitude | def makespectfile(afile):
x = []
y = []
with open(afile) as f:
for line in f:
if line.startswith('#'): continue
(freq,flux) = line.split()
x.append(float(freq))
y.append(float(flux))
return (np.asarray(x),np.asarray(y)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_filter_data(filename):\n gains = []\n freqs = []\n freq_scale = 0\n with open(filename) as f:\n for line in f:\n words = line.split()\n if line.startswith('Freq'):\n _, scale = words[0].split(\"(\")\n scale = scale.rstrip(\")\")\n ... | [
"0.7232917",
"0.71028847",
"0.709317",
"0.6883066",
"0.6783753",
"0.67701334",
"0.67288643",
"0.6692682",
"0.6670123",
"0.66636634",
"0.66447705",
"0.65392363",
"0.64900935",
"0.6441326",
"0.6395796",
"0.63950247",
"0.637628",
"0.6370568",
"0.6367199",
"0.6345476",
"0.6340855... | 0.7644199 | 0 |
Use apply_default decorator for the `default_args` feature to work properly; deprecated. In previous versions, all subclasses of BaseOperator must use apply_default decorator for the" `default_args` feature to work properly. In current version, it is optional. The decorator is applied automatically using the metaclass. | def apply_defaults(func: T) -> T:
warnings.warn(
"This decorator is deprecated. \n"
"\n"
"In previous versions, all subclasses of BaseOperator must use apply_default decorator for the "
"`default_args` feature to work properly.\n"
"\n"
"In current version, it is optio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_defaults(func: T) -> T:\n warnings.warn(\n \"This decorator is deprecated. \\n\"\n \"\\n\"\n \"In previous versions, all subclasses of BaseOperator must use apply_default decorator for the \"\n \"`default_args` feature to work properly.\\n\"\n \"\\n\"\n \"In c... | [
"0.82795125",
"0.6885742",
"0.6571699",
"0.6179261",
"0.60997844",
"0.60997844",
"0.60086507",
"0.597563",
"0.5938139",
"0.59069514",
"0.5854104",
"0.57146806",
"0.5672426",
"0.5663039",
"0.56135994",
"0.55640954",
"0.5539715",
"0.5507615",
"0.5487402",
"0.5466438",
"0.543263... | 0.8326598 | 0 |
Performs the scaled all_reduce operation on the provided tensors. The input tensors are modified inplace. Currently supports only the sum reduction operator. The reduced values are scaled by the inverse size of the process group. | def scaled_all_reduce(tensors: List[Tensor], num_gpus: int) -> List[Tensor]:
# There is no need for reduction in the single-proc case
if num_gpus == 1:
return tensors
# Queue the reductions
reductions = []
for tensor in tensors:
reduction = torch.distributed.all_reduce(tensor, async_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allreduce_hook(state: AllReduceState, grad: torch.Tensor):\n if state.gradient_predivide_factor > 1:\n grad.div_(state.gradient_predivide_factor)\n dist.all_reduce(grad, group=state.process_group)\n if state.gradient_postdivide_factor > 1:\n grad.div_(state.gradient_postdivide_factor)",
... | [
"0.6388613",
"0.60503924",
"0.5885183",
"0.5827911",
"0.5778461",
"0.55323684",
"0.5511012",
"0.5458916",
"0.54437757",
"0.5417451",
"0.5380227",
"0.5299009",
"0.5289442",
"0.52552223",
"0.52131027",
"0.5203694",
"0.5203694",
"0.5196382",
"0.515265",
"0.5149693",
"0.5122873",... | 0.8066509 | 0 |
Computes precise BN stats on training data. | def update_bn_stats(
model: nn.Module,
loader: DataLoader,
num_samples: int = 8192,
logger: Optional[Union[logging.Logger, str]] = None) -> None:
if is_model_wrapper(model):
model = model.module
# get dist info
rank, world_size = mmengine.dist.get_dist_info()
# C... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_precise_bn_stats(model, loader):\n # Compute the number of minibatches to use\n num_iter = min(cfg.BN.NUM_SAMPLES_PRECISE // loader.batch_size, len(loader))\n # Retrieve the BN layers\n bns = [m for m in model.modules() if isinstance(m, torch.nn.BatchNorm2d)]\n # Initialize stats storage... | [
"0.6964537",
"0.6422349",
"0.63577896",
"0.6318661",
"0.6236532",
"0.6216655",
"0.6173939",
"0.60070693",
"0.59611785",
"0.5951854",
"0.58218586",
"0.5805479",
"0.5786752",
"0.57796615",
"0.57740426",
"0.57325435",
"0.57291657",
"0.571751",
"0.56999123",
"0.5690688",
"0.56904... | 0.6554783 | 1 |
Computes the time_steps/ctc_input_length after convolution. | def compute_length_after_conv(max_time_steps, ctc_time_steps, input_length):
max_time_steps = tf.cast(max_time_steps, dtype=tf.float32)
ctc_input_length = tf.cast(tf.multiply(input_length, ctc_time_steps), dtype=tf.float32)
return tf.cast(tf.floordiv(ctc_input_length, max_time_steps), dtype=tf.int32) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_length_after_conv(max_time_steps, ctc_time_steps, input_length) -> tf.Tensor:\n return tf.to_int32(tf.floordiv(\n tf.to_float(tf.multiply(input_length, ctc_time_steps)), tf.to_float(max_time_steps)))",
"def _calc_ctc_input_length(args):\n # py2 needs explicit tf import for keras La... | [
"0.73321956",
"0.72471476",
"0.60040087",
"0.58424336",
"0.5774148",
"0.57553667",
"0.5680954",
"0.56687814",
"0.5620562",
"0.55967027",
"0.5519298",
"0.5454149",
"0.5431821",
"0.5431813",
"0.54018116",
"0.5376901",
"0.5364593",
"0.5363788",
"0.53633916",
"0.52863103",
"0.525... | 0.7509102 | 0 |
Generate a speech dataset. | def generate_dataset(data_dir: str, partition: str) -> dataset.DeepSpeechDataset:
global FLAGS
audio_conf = dataset.AudioConfig(
sample_rate=FLAGS.sample_rate, window_ms=FLAGS.window_ms, stride_ms=FLAGS.stride_ms, normalize=True)
data_conf = dataset.DatasetConfig(
audio_config=audio_conf, da... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generateDataset(self):\n if self.outdir[-1] != \"/\": \n self.outdir += \"/\"\n self.outdir += \"dataset_trackml\"\n i = 1\n while os.path.exists(self.outdir):\n self.outdir.replace(\"_\"+str(i-1), \"\")\n self.outdir += (\"_\"+str(i))\n i... | [
"0.64441484",
"0.63849944",
"0.62619036",
"0.6223697",
"0.6217612",
"0.6186893",
"0.61415535",
"0.61275953",
"0.6118419",
"0.6101546",
"0.606264",
"0.6042652",
"0.6013309",
"0.59911335",
"0.5944916",
"0.5930794",
"0.5930794",
"0.5919748",
"0.59102166",
"0.5889595",
"0.5887039... | 0.65369 | 0 |
Run deep speech training and eval loop. | def run_deep_speech():
global FLAGS
tf.set_random_seed(FLAGS.seed)
# Data precessing
tf.logging.info("Data Processing...")
train_speech_dataset = generate_dataset(FLAGS.data_dir, partition="train")
eval_speech_dataset = generate_dataset(FLAGS.data_dir, partition="dev")
# Number of label cla... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\n from audio import AudioRecorder\n\n loader = SingleInputLoader(128)\n recorder = AudioRecorder()\n\n with tf.Session() as sess:\n model = create_default_model('record', 128, loader)\n model.restore(sess, 'train/best-weights')\n \n while True:\n print('Listeni... | [
"0.6943727",
"0.6593037",
"0.6503868",
"0.6496803",
"0.64616853",
"0.64566225",
"0.64433736",
"0.6342452",
"0.6339075",
"0.6338328",
"0.6310606",
"0.6282557",
"0.62653345",
"0.6262677",
"0.6250832",
"0.6228017",
"0.6227637",
"0.6218155",
"0.6213814",
"0.61772126",
"0.6165034"... | 0.7373323 | 0 |
Create and return a stub test. | def CreateStubTest(phases=None): # pylint: disable=invalid-name
test_metadata = phase_data.TestMetadata('foo')
return phase_data.phase_data(test_metadata, phases or []) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CreateStubTest(phases=None, params=None): # pylint: disable=invalid-name\n test_metadata = htftest.TestMetadata('foo')\n # pylint: disable=protected-access\n if params is not None:\n test_metadata._parameter_list = (\n parameters.TestParameterList(params.parameters))\n return htftest.HTFTest(tes... | [
"0.74640894",
"0.68726027",
"0.65086746",
"0.6226904",
"0.59744567",
"0.5875409",
"0.5875409",
"0.5869115",
"0.5800327",
"0.57175136",
"0.5705263",
"0.5691941",
"0.5661378",
"0.5658473",
"0.5648882",
"0.5639574",
"0.5630987",
"0.5609541",
"0.55923575",
"0.55062956",
"0.549285... | 0.7049483 | 1 |
Return dict containing job's MRT params (applicable only when map_task is not None) | def get_map_task_params(self):
return {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_powermax_job_parameters():\n return dict(\n job_id=dict(type='str', required=True)\n )",
"def construct_job_params(self, hook: Any) -> dict[Any, Any | None]:\n missing_params = self.required_params - set(self.job_params)\n if missing_params:\n raise AirflowException(... | [
"0.63929814",
"0.6278747",
"0.6234184",
"0.60798496",
"0.601743",
"0.59797996",
"0.5893281",
"0.5834644",
"0.5736956",
"0.5709796",
"0.5683366",
"0.5677564",
"0.559777",
"0.5590839",
"0.5587835",
"0.556893",
"0.55425924",
"0.5519106",
"0.55032396",
"0.54824823",
"0.54682976",... | 0.8269762 | 0 |
Check wrether the job can be launched | def can_run(self):
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lantern_check():\n if not app.config.get(\"ENABLE_LANTERN\", False):\n print \"[{x}] Not checking Lantern jobs - interface disabled\".format(x=dates.now())\n return\n print \"[{x}] Checking Lantern jobs\".format(x=dates.now())\n LanternApi.check_jobs()",
"def check_env():\n job_file... | [
"0.6642071",
"0.66208327",
"0.66090924",
"0.6534082",
"0.6497826",
"0.64233065",
"0.63549906",
"0.6345807",
"0.63409173",
"0.6323821",
"0.63086534",
"0.6279424",
"0.62567234",
"0.62546295",
"0.62468517",
"0.621095",
"0.619517",
"0.61762893",
"0.6153152",
"0.61371064",
"0.6133... | 0.66355747 | 1 |
Return an action. >>> q = TabularQ([0,1,2,3],['b','c']) >>> q.set(0, 'b', 5) >>> q.set(0, 'c', 10) >>> q.set(1, 'b', 2) >>> eps = 0. >>> epsilon_greedy(q, 0, eps) greedy 'c' >>> epsilon_greedy(q, 1, eps) greedy 'b' | def epsilon_greedy(q, s, eps = 0.5):
if random.random()<eps:
return uniform_dist(q.actions).draw()
else:
return greedy(q,s) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eps_greedy(Q, epsilon, num_actions):\n if np.random.uniform(0,1,1) > epsilon:\n action = np.argmax(Q)\n else:\n action = np.random.randint(low=0, high=num_actions)\n \n Q_value = Q[action]\n return action, Q_value",
"def epsilon_greedy(Q, epsilon, n_actions, s, train=False):\n ... | [
"0.7148608",
"0.64981556",
"0.63126504",
"0.62986714",
"0.62594926",
"0.6258449",
"0.61423904",
"0.6026595",
"0.60167265",
"0.59709555",
"0.5897679",
"0.5888596",
"0.58737326",
"0.58079225",
"0.58033264",
"0.5781088",
"0.5732777",
"0.5710433",
"0.57000035",
"0.5699515",
"0.56... | 0.6940285 | 1 |
Attach the given phy layer to the chanel. After a short delay, the phy_layer should receive a `BusyIndication` or `IdleIndication` SDU | def attach(self, phy_layer):
self._attached_phys.append(phy_layer) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, layer_delay=_default_layer_delay):\n self._attached_phys = []\n self._layer_delay = layer_delay",
"def add_layer(self, layer: Union[CommandLayer, Type[CommandLayer]],\n active: Optional[bool] = True):\n if issubclass(layer, CommandLayer):\n layer = la... | [
"0.5359344",
"0.51606864",
"0.4981618",
"0.49739328",
"0.49689108",
"0.49641663",
"0.482585",
"0.4784602",
"0.47822216",
"0.47765702",
"0.4733921",
"0.4723825",
"0.4697315",
"0.46468836",
"0.46253222",
"0.46140853",
"0.46140155",
"0.46135888",
"0.45908052",
"0.45793292",
"0.4... | 0.6782705 | 0 |
Detach the given phy_layer from the channel | def detach(self, phy_layer):
self._attached_phys.remove(phy_layer) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_layer(self, layer: CommandLayer):\n try:\n index = self.command_layers.index(layer)\n except ValueError:\n return\n\n if layer.active: # Transfer the active status to another layer\n if index < 0: # ... to the previous layer in the stack\n ... | [
"0.5844689",
"0.5619299",
"0.55078894",
"0.54105484",
"0.5367822",
"0.5262961",
"0.52497536",
"0.51190823",
"0.51019",
"0.5091018",
"0.508095",
"0.5041397",
"0.5038449",
"0.50244045",
"0.5019844",
"0.49974367",
"0.4993187",
"0.49843723",
"0.4972273",
"0.49417922",
"0.49223176... | 0.84005505 | 0 |
Initialize an Unifi Protect Switch. | def __init__(self, coordinator, upv, camera, switch_type, ir_on, ir_off):
self.coordinator = coordinator
self.upv = upv
self._camera_id = camera
self._camera = self.coordinator.data[camera]
self._name = "{0} {1} {2}".format(
DOMAIN.capitalize(), SWITCH_TYPES[switch_ty... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, data, camera, switch_type):\n self.data = data\n self._camera_id = camera\n self._camera = self.data.devices[camera]\n self._name = \"{0} {1} {2}\".format(DOMAIN.capitalize(), SWITCH_TYPES[switch_type][0], self._camera[\"name\"])\n self._unique_id = self._name.... | [
"0.668283",
"0.6222391",
"0.6021048",
"0.592539",
"0.57956624",
"0.5783978",
"0.5776359",
"0.5716881",
"0.5700141",
"0.56954783",
"0.5673299",
"0.5581777",
"0.55620766",
"0.55259913",
"0.5523816",
"0.5519903",
"0.5512638",
"0.55101365",
"0.5487694",
"0.5478698",
"0.5470831",
... | 0.708648 | 0 |
Given an Item Number and library data dict Return the name of the library it's found in, and the symbol name | def findSymbolByItemnum(itemnum, libs_dict):
e_itemnum = re.escape(itemnum)
for libname, dat in libs_dict.items():
m = re.search(r'^DEF ([^ ]*) .*(?:\n[^\$].+)+\nF ?\d+ "'+e_itemnum+r'".* "Item Number"\n', dat, re.MULTILINE)
try:
symname = m.group(1)
return libname, symna... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_name_with_lib(datablock):\r\n text = datablock.name\r\n if datablock.library:\r\n # text += ' (Lib: \"%s\")' % datablock.library.name\r\n text = \"L \" + text\r\n return text",
"def get_symbols(doc, lib):\n\n basename = lib.replace(\".dll\", \"\").lower()\n filename = os.path... | [
"0.6351624",
"0.588709",
"0.558512",
"0.5506981",
"0.5491768",
"0.5448772",
"0.5388454",
"0.5337695",
"0.53156734",
"0.5299146",
"0.5281417",
"0.5229371",
"0.52056694",
"0.5185004",
"0.51806813",
"0.51693463",
"0.5163847",
"0.51593566",
"0.5133286",
"0.51013744",
"0.5091456",... | 0.78984857 | 0 |
Test on a data set of songs and known genres. | def test(self, songs, genres):
logging.info('Starting testing.')
num_matches = 0
confusion_matrix = ConfusionMatrix(genres)
for song, actual_genre in zip(songs, genres):
predicted_genre = self.classify(song)
logging.info('Actual genre: {}, predicted genre: {}'.for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_songs_by_genre(self, track_elms, service_config, request):\n genre_id = uuid.UUID(avalon.compat.to_uuid_input('c12d2a49-d086-43d6-953d-b870deb24228'))\n service_config.track_store.get_by_genre.return_value = track_elms\n service_config.id_cache.get_genre_id.return_value = genre_id... | [
"0.6808168",
"0.65337896",
"0.63130933",
"0.61084867",
"0.5960939",
"0.59207577",
"0.57667565",
"0.5645742",
"0.56377244",
"0.5593208",
"0.55835515",
"0.5554038",
"0.5543787",
"0.551411",
"0.55078",
"0.5503138",
"0.5479609",
"0.54730666",
"0.54501826",
"0.5445314",
"0.5428625... | 0.65475684 | 1 |
Classify a particular song. | def classify(self, song):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classify_playlist(classifier, playlist_feature_data, playlist_data_dict):\n\n clf, clf_name = classifier\n\n playlist_features, playlist_song_ids = playlist_feature_data\n # run classifier on playlist songs\n results = clf.predict_all(playlist_features)\n liked_songs = [playlist_song_ids[i] for ... | [
"0.6249288",
"0.5961244",
"0.57986456",
"0.56695867",
"0.5515968",
"0.5402372",
"0.53549737",
"0.52264583",
"0.52200854",
"0.52137727",
"0.5092305",
"0.50832874",
"0.50748336",
"0.50739837",
"0.5049888",
"0.5019744",
"0.5016217",
"0.50088155",
"0.49824685",
"0.49791542",
"0.4... | 0.82713926 | 0 |
Predict the genres of all songs in the given directory, saving this data in a file. Note that the genres of the songs are not known beforehand. | def predict_directory(self, directory_name, result_file_name):
logging.info('Starting prediction.')
with open(result_file_name, 'ab') as f:
writer = csv.writer(f)
writer.writerow(('id', 'category'))
for song_id in os.listdir(directory_name):
song = pd.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saveTmdbGenres():\n \n listGenres = tmdb.Genres().list()[\"genres\"]\n \n genres = { _format(g[\"name\"]):i for i, g in enumerate(listGenres) }\n\n np.save(GENRES_FILE, np.asarray([genres]))",
"def random_by_genre_list(self):\n\n for genre in self.connection.walk_genres():\n ... | [
"0.60163605",
"0.60031205",
"0.59263384",
"0.588661",
"0.58185124",
"0.58125246",
"0.5753232",
"0.5715541",
"0.56986034",
"0.56940067",
"0.56717575",
"0.5634953",
"0.5573612",
"0.5497498",
"0.5478532",
"0.5429409",
"0.5406123",
"0.53959244",
"0.53919566",
"0.5375165",
"0.5352... | 0.6846945 | 0 |
Finds the dimension of the points in the file. | def find_dimesion(filename):
file = open(filename,"r")
line = file.readline()
file.close()
return len(line.split()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dimensions ( file_in, separator ) :\n try :\n logger.info ( \"Extract dimensions from xyz file \" + str(file_in) ) \n d = {}\n first_row = True\n d[NOPS] = 0\n file = open(file_in, 'r')\n for line in file :\n d[NOPS] = d[NOPS] + 1\n l = lin... | [
"0.6812365",
"0.6810448",
"0.68029106",
"0.6689416",
"0.6590357",
"0.6507463",
"0.64789444",
"0.6432954",
"0.6427297",
"0.63916624",
"0.6285233",
"0.6277324",
"0.62739605",
"0.6271587",
"0.6249749",
"0.6227997",
"0.621909",
"0.6207011",
"0.6204155",
"0.6199409",
"0.6199409",
... | 0.6965317 | 0 |
Finds the closest points in a given list of Point objects. There are two for loops because I imagined the Point list this way. y > represents the rows x > represents the columns | def find_closest_points(points):
closest_dist = float("inf")
closest_points = None, None
for y, point_one in enumerate(points):
for x, point_two in enumerate(points):
if x > y:
dist= distance_between(point_one.points,point_two.points)
if dist < closest_dis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closest_points(self, points, maxdist=None):\n return [self.closest_point(point, maxdist) for point in points]",
"def closest_dist(x, y, x_list, y_list):\n points = np.array([x, y]).T\n points_list = np.array([x_list, y_list]).T\n\n dpt0 = points_list[:, 0] - points[:, 0, np.newaxis]\n dpt1... | [
"0.7746659",
"0.7575003",
"0.7565495",
"0.74907386",
"0.73184353",
"0.72928536",
"0.7258349",
"0.722991",
"0.6869522",
"0.67983764",
"0.67398",
"0.67391354",
"0.67248935",
"0.6715504",
"0.6708824",
"0.66605735",
"0.661304",
"0.6607124",
"0.6598075",
"0.659383",
"0.65821815",
... | 0.81107926 | 0 |
Tests whether the input file is empty. If input is not empty, it returns the file; otherwise it exits from the system. | def input_file_test(input):
try:
if os.stat(input).st_size == 0:
print ("The input file %s is empty, exiting." % input)
sys.exit()
except OSError as e:
print(e)
sys.exit()
return input | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_empty_file(self):\n\t\tmain.Main(['input/empty.txt']).run()\n\t\tself.assertTrue(filecmp.cmp('output/output.csv', 'output/empty.csv'))",
"def is_file_empty(file_name):\n # open ile in read mode\n with open(file_name, 'r') as read_obj:\n # read first character\n one_char = read_obj.re... | [
"0.68083346",
"0.68074083",
"0.6786199",
"0.67231107",
"0.6606845",
"0.6573466",
"0.65498596",
"0.6435035",
"0.6296949",
"0.6270471",
"0.6231167",
"0.62046707",
"0.61650205",
"0.61614615",
"0.5990059",
"0.58732206",
"0.5847673",
"0.58417505",
"0.5835229",
"0.5767335",
"0.5743... | 0.88009804 | 0 |
two dictionaries nd1 and nd2 and return the smallest positive value | def smallestValue(self, nd1, nd2):
minnd1 = min(nd1.values())
minnd2 = min(nd2.values())
totalmin = min(minnd1,minnd2)
return totalmin | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minInDict(dist):\r\n m = float('inf')\r\n for p in dist:\r\n for q in dist[p]:\r\n if dist[p][q] < m:\r\n m = dist[p][q]\r\n a,b = p,q\r\n return a,b",
"def keywithsecondminval(d): \r\n if len(d) == 1:\r\n d = (d.keys())\r\n return d[0... | [
"0.69349235",
"0.6200123",
"0.6040021",
"0.598441",
"0.59417975",
"0.59298074",
"0.5921851",
"0.5919063",
"0.589691",
"0.58484435",
"0.5841207",
"0.57669926",
"0.575807",
"0.57121885",
"0.570274",
"0.56867063",
"0.5659589",
"0.5648681",
"0.5617436",
"0.5614321",
"0.56119514",... | 0.78676057 | 0 |
return logprobability that dictionary d came from the distribution of data in the normalized dictionary nd1 and nd2 | def compareDictionaries(self, d, nd1, nd2):
normnd1 = self.normalizeDictionary(nd1)
normnd2 = self.normalizeDictionary(nd2)
total_log_prob1 = 0.0
total_log_prob2 = 0.0
epsilon = self.smallestValue(normnd1,normnd2)/2
for x in d:
if x not in normnd1:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log(d: D) -> NumDict:\n\n return d.log()",
"def compare_dictionaries(d1, d2):\r\n score = 0\r\n gef = 0\r\n for z in d1:\r\n gef += d1[z]\r\n total = gef\r\n \r\n for x in d2:\r\n if x in d1:\r\n score += math.log(d1[x] / total) * d2[x] \r\n else:\r\n... | [
"0.65142924",
"0.6498203",
"0.6478609",
"0.6398017",
"0.63931054",
"0.63005465",
"0.6257267",
"0.6251998",
"0.6210485",
"0.6205614",
"0.618205",
"0.61285675",
"0.61219615",
"0.6059671",
"0.6059194",
"0.59403294",
"0.592365",
"0.59173363",
"0.59089893",
"0.5902279",
"0.5892993... | 0.782096 | 0 |
Mostly ripped from nc3tonc4 in netCDF4python. Added ability to skip dimension and variables. Removed all of the unpacking logic for shorts. | def clone(src, dst_path, skip_globals, skip_dimensions, skip_variables):
if os.path.exists(dst_path):
os.unlink(dst_path)
dst = netCDF4.Dataset(dst_path, 'w')
# Global attributes
for attname in src.ncattrs():
if attname not in skip_globals:
setattr(dst, attname, getattr(src... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self,filename='slices.000000',nvar=8,nbuf=3,field=None):\n\n #Open file\n f=tables.openFile(filename)\n\n #Dataset \"para_real\"\n self.time=f.root.para_real[0]\n self.dt =f.root.para_real[1]\n self.dx =f.root.para_real[2]\n self.dy =f.root.para_real... | [
"0.5600547",
"0.54413694",
"0.54308397",
"0.5418377",
"0.54078954",
"0.53668946",
"0.5344015",
"0.5336579",
"0.5290628",
"0.52342385",
"0.52231324",
"0.51942706",
"0.5134216",
"0.5109639",
"0.50503546",
"0.50287384",
"0.5022853",
"0.5013268",
"0.49844584",
"0.496534",
"0.4931... | 0.5500222 | 1 |
Case 4 A node making multiple primary declarations for a particular node. Consider 4 nodes A, B, C and D. Lets say node B is malicious and is repeatedly declaring Node D as primary | def testPrimaryElectionCase4(case4Setup, looper):
allNodes = case4Setup
A, B, C, D = allNodes
looper.run(checkNodesConnected(allNodes))
# Node B sends multiple declarations of node D's 0th protocol instance as
# primary to all nodes
for i in range(5):
# B.send(Primary(D.name, 0, B.view... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primary(self):\n ...",
"def assign_ids(ast):\n def f_either(obj, *child_results):\n id_ = slast.SlAst.id_\n obj.id_ = id_[0]\n id_[0] += 1\n\n # def f_either(obj, *child_results):\n # _id_dict = slast.SlAst._id_dict\n # id_ = slast.SlAst.id_\n # # FIXME:... | [
"0.5375646",
"0.5154644",
"0.51295924",
"0.49382252",
"0.4831968",
"0.4788528",
"0.4788528",
"0.4756773",
"0.4754792",
"0.4708603",
"0.4700092",
"0.4677574",
"0.46142638",
"0.46059236",
"0.45961127",
"0.45947063",
"0.45883384",
"0.45769686",
"0.45754498",
"0.45723775",
"0.455... | 0.55320704 | 0 |
To convert tf.Tensor > json serializable np.ndarray > json serializable | def tf_tensor_2_serializable(obj):
import tensorflow as tf
import numpy as np
# Tensor -> ndarray or object
if isinstance(obj, tf.Tensor):
if tf.__version__.startswith("1."):
with tf.compat.v1.Session():
obj = obj.numpy()
else:
obj = obj.numpy()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_numpy(tensor):\n raise NotImplementedError",
"def tensor_to_json(self, tensor_name):\n name = tensor_name\n tup = self.tensor_info[name]\n pert_list = tup[1]\n repr = tup[2]\n\n repr_data = repr.to_json() if repr is not None else None\n pert_data = [o.to_js... | [
"0.68428576",
"0.6705407",
"0.6659738",
"0.6618609",
"0.6618609",
"0.6618609",
"0.6599845",
"0.6567279",
"0.64083153",
"0.63227916",
"0.63227916",
"0.62989205",
"0.628012",
"0.6269711",
"0.6266001",
"0.6180537",
"0.6166389",
"0.61231035",
"0.61231035",
"0.61120456",
"0.610484... | 0.78063214 | 0 |
>>> lst = [ [1], [1, 2], [1, 2, 3], None, ] >>> concat_list(lst) [1, 1, 2, 1, 2, 3], [slice(0, 1), slice(1, 3), slice(3, 6), None] | def concat_list(lst, batch_flags=None):
slices = [slice(0)] * len(lst)
datas = []
row_flag = 0
for i, r in enumerate(lst):
if r is None:
slices[i] = None
continue
j = -1
if batch_flags is None or batch_flags[i]:
for j, d in enumerate(r):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concat_list(in_list):\n return list(itertools.chain(*in_list))",
"def concat_succ(L):\n if len(L) < 2:\n return L\n res = []\n last = L.pop()\n othe = L.pop()\n for i in last:\n for j in othe:\n if type(i) is list:\n if type(j) is list:\n ... | [
"0.71166927",
"0.6419672",
"0.6270731",
"0.62562144",
"0.6135522",
"0.6087907",
"0.6058204",
"0.6038355",
"0.6037199",
"0.6023297",
"0.59915894",
"0.5978991",
"0.5917092",
"0.5858604",
"0.5852147",
"0.5850211",
"0.584778",
"0.58327496",
"0.58193696",
"0.58092976",
"0.57957524... | 0.74441135 | 0 |
utility to check if node names are unique | def check_onnx_node_name_uniqueness(onnx_model):
onnx_node_names = [node.name for node in onnx_model.graph.node]
assert len(onnx_node_names) == len(set(onnx_node_names)), f'list size mismatch, check if names are unique' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __has_conflicting_node_names(self):\n # check length of sets to determine if overlap exists\n return len({node.get_name() for node in self.get_nodeset()}) != len(self.get_nodeset())",
"def checkNamesUniqueness(names):\n topNames, deeperNames = getLevelNames(names)\n## print topNames\n## ... | [
"0.73011124",
"0.6985261",
"0.6725731",
"0.6644279",
"0.6635118",
"0.6553637",
"0.6456373",
"0.6453211",
"0.6446892",
"0.6387194",
"0.6358027",
"0.6313981",
"0.62614363",
"0.6214909",
"0.6204638",
"0.619209",
"0.6174945",
"0.6174945",
"0.61397904",
"0.6063441",
"0.60601556",
... | 0.8149716 | 0 |
test onxx based utility to find mapping between onnx node names and io tensors | def test_onnx_node_name_to_input_output_names_util(self):
model = models.resnet18(pretrained=False)
dummy_input = torch.randn(1, 3, 224, 224)
torch.onnx.export(model, dummy_input, './data/resnet18.onnx')
onnx_utils.OnnxSaver.set_node_names('./data/resnet18.onnx', model, dummy_input, is_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def onnx_extract_operator(node, model, nodes_dict):\n op_type = node.op_type\n input_tensors = []\n output_tensors = []\n\n \"\"\" input_tensors\n each input_tensor has its own soure op, but same dest op\n so both have single string\n \"\"\"\n input_names = []\n # name list\n input_te... | [
"0.65607023",
"0.6310749",
"0.6268617",
"0.6265941",
"0.6193158",
"0.60374105",
"0.5948364",
"0.5849513",
"0.57718235",
"0.57630116",
"0.5761633",
"0.5725777",
"0.57182246",
"0.56293416",
"0.5621835",
"0.56069314",
"0.55362374",
"0.55332834",
"0.5524223",
"0.5512426",
"0.5477... | 0.7777733 | 0 |
test onxx based utility to find mapping between onnx node names and io tensors when more than one onnx node maps to the same torch module | def test_single_pytorch_module_mapping_to_many_onnx_nodes(self):
AimetLogger.set_level_for_all_areas(logging.DEBUG)
class TwoLayerLstmModel(torch.nn.Module):
"""
Model using torch.nn.LSTM module
"""
def __init__(self):
super(TwoLayerLstmM... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_onnx_node_name_to_input_output_names_util(self):\n model = models.resnet18(pretrained=False)\n dummy_input = torch.randn(1, 3, 224, 224)\n torch.onnx.export(model, dummy_input, './data/resnet18.onnx')\n onnx_utils.OnnxSaver.set_node_names('./data/resnet18.onnx', model, dummy_in... | [
"0.75095046",
"0.6466577",
"0.64522165",
"0.6451405",
"0.6420626",
"0.6097081",
"0.5859226",
"0.5858057",
"0.5838287",
"0.57737774",
"0.5742301",
"0.5723268",
"0.56167114",
"0.55878025",
"0.558724",
"0.55839914",
"0.5539161",
"0.5493296",
"0.5454495",
"0.5449514",
"0.5327194"... | 0.69601613 | 1 |
Test that node names are set correctly for linear ops turned into matmul/add in onnx. | def test_set_node_name_for_matmul_add_linear(self, export_args):
class Linear(torch.nn.Module):
def __init__(self):
super(Linear, self).__init__()
self.linear = torch.nn.Linear(3, 2)
def forward(self, inp):
x = self.linear(inp)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_onnx_node_name_to_input_output_names_util(self):\n model = models.resnet18(pretrained=False)\n dummy_input = torch.randn(1, 3, 224, 224)\n torch.onnx.export(model, dummy_input, './data/resnet18.onnx')\n onnx_utils.OnnxSaver.set_node_names('./data/resnet18.onnx', model, dummy_in... | [
"0.6792893",
"0.67721677",
"0.65422505",
"0.61988956",
"0.6150528",
"0.6148229",
"0.5965357",
"0.59260803",
"0.5876603",
"0.58762425",
"0.584769",
"0.5770553",
"0.57376754",
"0.5707993",
"0.5700042",
"0.5673199",
"0.5655918",
"0.56137747",
"0.5602277",
"0.5545079",
"0.5532079... | 0.7743685 | 0 |
test dictionary input and output layers | def test_export_dict_input_output(self):
class Net(torch.nn.Module):
"""
Model using multiply as functional and module at different depths
"""
def __init__(self):
super().__init__()
self.layer = InputOutputDictModel()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_kwargs_input_dict_output(self):\n\n class KwargModel(torch.nn.Module):\n def __init__(self):\n super().__init__()\n self.mul = aimet_torch.elementwise_ops.Multiply()\n\n def forward(self, a, b, c):\n ab = a * b\n bc =... | [
"0.65281624",
"0.62313795",
"0.6157317",
"0.5946783",
"0.59059757",
"0.58558685",
"0.5855444",
"0.58469844",
"0.58335406",
"0.5805809",
"0.57551163",
"0.57410544",
"0.5736132",
"0.5734934",
"0.5715027",
"0.5689544",
"0.5608706",
"0.5605638",
"0.55747133",
"0.55457956",
"0.553... | 0.6687717 | 0 |
test dictionary input as kwargs in an intermediate layer | def test_kwargs_input_dict_output(self):
class KwargModel(torch.nn.Module):
def __init__(self):
super().__init__()
self.mul = aimet_torch.elementwise_ops.Multiply()
def forward(self, a, b, c):
ab = a * b
bc = b * c
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_kw_args_with_dict():\n arg_dict = {'visited_color': 'blue',\n 'link_color': 'red',\n 'back_color': 'yellow',\n 'fore_color': 'orange'}\n assert arguments.fun_opt_kw_params(**arg_dict) == ('orange', 'yellow',\n ... | [
"0.68380266",
"0.6642572",
"0.6544952",
"0.6419672",
"0.64001125",
"0.63954014",
"0.63548684",
"0.6272449",
"0.6210259",
"0.6194217",
"0.61427027",
"0.6134622",
"0.61176914",
"0.61130285",
"0.61014044",
"0.6090693",
"0.60874087",
"0.6078532",
"0.60526466",
"0.5990979",
"0.597... | 0.6957905 | 0 |
test naming works for model have large number of sequential nodes | def test_naming_for_model_with_deep_graph(self):
model = models.resnet152(pretrained=False)
dummy_input = torch.randn(1, 3, 224, 224)
onnx_path= './data/' + model.__class__.__name__ + '.onnx'
with onnx_simply(True):
onnx_utils.OnnxSaver.set_node_names(onnx_path, model, dumm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_set_unique_node_names(self):\n class TwoLayerLstmModel(torch.nn.Module):\n \"\"\"\n Model using torch.nn.LSTM module\n \"\"\"\n def __init__(self):\n super(TwoLayerLstmModel, self).__init__()\n self.lstm = torch.nn.LSTM(input... | [
"0.75483245",
"0.6777502",
"0.6655101",
"0.6572657",
"0.63191295",
"0.6208426",
"0.61246103",
"0.6104829",
"0.6082704",
"0.6061295",
"0.5965343",
"0.59363145",
"0.5935405",
"0.5920117",
"0.5828375",
"0.56998265",
"0.56853604",
"0.5650619",
"0.5605244",
"0.55901146",
"0.556722... | 0.6890959 | 1 |
Test the gateway can connect and have an empty dict of devices | def test_connect(self, gateway):
assert not gateway._devs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_devices(self):\n pass",
"def test_get_devices(self):\n pass",
"def test_verify_connection_to_a_device():",
"def test_verify_list_of_devices_in_my_network():",
"def test_gwservice_listdevices(self, setup_controller):\n resp = setup_controller.request(\"gw\", \"devices\", \"... | [
"0.6762325",
"0.6762325",
"0.672721",
"0.6718752",
"0.66731656",
"0.6479616",
"0.64170194",
"0.64170194",
"0.6373689",
"0.6370904",
"0.63623434",
"0.6293659",
"0.62630945",
"0.6125039",
"0.6104315",
"0.60881805",
"0.6080881",
"0.6077714",
"0.60736173",
"0.6019352",
"0.6019352... | 0.81306255 | 0 |
Test the gateway fixture contains drivers that were loaded from files | def test_device_add_from_file(self, gateway_with_devs):
assert 'daq' in gateway_with_devs._devs
assert 'pel' in gateway_with_devs._devs
assert 'sg' in gateway_with_devs._devs
assert 'not_a_driver' not in gateway_with_devs._devs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fixtures():",
"def fixture_example_data():\n import_example_data()",
"def _fixture_setup(self):\n pass",
"def test_load_configs_testing(self):\n global locator, config_paths\n locator.load_config(config_paths[0])\n\n self.assertEqual(locator.config['routines'], ['debug'])\n... | [
"0.6442319",
"0.6338353",
"0.63182837",
"0.61462885",
"0.61180353",
"0.60295516",
"0.5985679",
"0.5983612",
"0.5970922",
"0.5935132",
"0.593162",
"0.5924928",
"0.5904823",
"0.59045386",
"0.5870761",
"0.5864663",
"0.58519274",
"0.58161414",
"0.5772585",
"0.5764369",
"0.573519"... | 0.650908 | 0 |
Test the gateway can restart and remove devices | def test_device_mgmt(self, gateway_with_devs):
gateway_with_devs.restart('daq')
assert gateway_with_devs.daq
gateway_with_devs.remove('daq')
with pytest.raises(AttributeError):
gateway_with_devs.daq | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_device(self):\n pass",
"def test_delete_device(self):\n pass",
"def clean_rebind_test(**kwargs):\n if 'verify_traffic' not in kwargs:\n kwargs['verify_traffic'] = False\n prepare_subscriber_traffic(**kwargs)\n device_id = kwargs.get('device_id', bbe.get_devices(dev... | [
"0.6643423",
"0.6643423",
"0.64361143",
"0.6349524",
"0.63331807",
"0.6297916",
"0.6297916",
"0.620502",
"0.6202497",
"0.6154049",
"0.6146571",
"0.6097684",
"0.60750765",
"0.6045645",
"0.6028808",
"0.6019024",
"0.6019024",
"0.5986632",
"0.59689575",
"0.5868066",
"0.58662766",... | 0.7743327 | 0 |
Returns True if `word` consists exhaustively of valid IPA segments | def validate_word(self, word, normalize=True):
return not self._segs(word, include_valid=False, include_invalid=True, normalize=normalize) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_word(self, word):\n first_letter, rest = word[0], word[1:]\n\n for possible_start in self._find_letter(first_letter):\n if self._check_word(possible_start, rest):\n return True\n\n return False",
"def is_valid(text):\n return is_all_word_segment_in_text... | [
"0.7004589",
"0.6847744",
"0.6789878",
"0.6735888",
"0.6684416",
"0.6627616",
"0.651143",
"0.6505042",
"0.6428736",
"0.6355093",
"0.63382703",
"0.63290393",
"0.63254887",
"0.63188684",
"0.631191",
"0.6290618",
"0.62664974",
"0.626073",
"0.6243883",
"0.62189406",
"0.6189003",
... | 0.69290006 | 1 |
Return True if `segment` is in segment features database | def seg_known(self, segment, normalize=True):
if normalize:
segment = FeatureTable.normalize(segment)
return segment in self.seg_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __contains__(self, feature):\n return feature in self.features",
"def isSegmentFile(self, segment):\n return os.path.isfile(\"{wd}/{jn}-run/{seg}.rst7\".format( wd=self.workdir, jn=self.jobname, seg=segment.getNameString()))",
"def check_segment_for_agent(self, segment, agent):\n mappi... | [
"0.6365108",
"0.59316486",
"0.57967645",
"0.5662152",
"0.55408937",
"0.55408937",
"0.5423819",
"0.54050773",
"0.53360146",
"0.5335236",
"0.53037214",
"0.529815",
"0.529553",
"0.5255767",
"0.52465856",
"0.524252",
"0.5228098",
"0.522067",
"0.5215083",
"0.5206038",
"0.52032894"... | 0.75535554 | 0 |
Given list of strings, return only those which are valid segments | def filter_segs(self, segs, normalize=True):
return list(filter(lambda seg: self.seg_known(seg, normalize), segs)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def illegal_indirect_horizontal_intervals(a_list):\n allowed_intervals = ['1', 'b2', '2', 'b3', '3', '4', '5', 'b6', '6']\n intervals = indirect_horizontal_intervals(a_list)\n return [x for x in intervals if x[0][0] not in allowed_intervals]",
"def segment(raw_sents:List[str], segment=\"jieba\") -> List... | [
"0.60316664",
"0.57880795",
"0.5696511",
"0.56766254",
"0.5634419",
"0.5569252",
"0.55591166",
"0.54737127",
"0.5471725",
"0.5424363",
"0.5422917",
"0.5396598",
"0.52901965",
"0.52557975",
"0.5253024",
"0.5238155",
"0.52132607",
"0.52100533",
"0.5209123",
"0.5185486",
"0.5150... | 0.59074974 | 1 |
Return a string like the input but containing only legal IPA segments | def filter_string(self, word, normalize=True):
return ''.join(self.ipa_segs(word, normalize)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compact(number):\n number = clean(number, ' ').upper().strip()\n if number.startswith('AL'):\n number = number[2:]\n if number.startswith('(AL)'):\n number = number[4:]\n return number",
"def dummy_junction14():\n return \"junction:chr1:176-324:+\"",
"def defangIPaddr(address):... | [
"0.54550743",
"0.54391927",
"0.53663737",
"0.5322689",
"0.5241737",
"0.52362967",
"0.5214989",
"0.52047104",
"0.519561",
"0.51782346",
"0.5152315",
"0.51449424",
"0.51403505",
"0.5121869",
"0.50963056",
"0.506933",
"0.50592506",
"0.5054341",
"0.5052699",
"0.5051405",
"0.50455... | 0.5909749 | 0 |
Return `True` if all segments in `inv` matches the features in fts | def fts_match_all(self, fts, inv, normalize=True):
return all([self.fts(s, normalize) >= fts for s in inv]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fts_match_any(self, fts, inv, normalize=True):\n return any([self.fts(s, normalize) >= fts for s in inv])",
"def fts_intersection(self, segs, normalize=True):\n return reduce(lambda a, b: a & b,\n [self.fts(s, normalize) for s in self.filter_segs(segs, normalize)])",
"def... | [
"0.7694182",
"0.6534538",
"0.611552",
"0.59962875",
"0.56264204",
"0.55972457",
"0.5396527",
"0.53882056",
"0.5361637",
"0.52219254",
"0.5220756",
"0.5129794",
"0.5123007",
"0.5102911",
"0.5101226",
"0.506148",
"0.5042564",
"0.5027478",
"0.50159997",
"0.5011232",
"0.5005611",... | 0.78391874 | 0 |
Return `True` if any segments in `inv` matches the features in fts | def fts_match_any(self, fts, inv, normalize=True):
return any([self.fts(s, normalize) >= fts for s in inv]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fts_match_all(self, fts, inv, normalize=True):\n return all([self.fts(s, normalize) >= fts for s in inv])",
"def fts_intersection(self, segs, normalize=True):\n return reduce(lambda a, b: a & b,\n [self.fts(s, normalize) for s in self.filter_segs(segs, normalize)])",
"def... | [
"0.76956517",
"0.6445244",
"0.6092043",
"0.603439",
"0.5596667",
"0.55699706",
"0.5360697",
"0.53144646",
"0.52958703",
"0.52827823",
"0.51305246",
"0.51228803",
"0.50828075",
"0.50755215",
"0.50623965",
"0.50345546",
"0.5033701",
"0.502957",
"0.50193626",
"0.5012903",
"0.501... | 0.7692603 | 1 |
Return `True` if there is a segment in `inv` that contrasts in feature `ft_name`. | def fts_contrast(self, fs, ft_name, inv, normalize=True):
inv_segs = filter(lambda x: x >= fs, map(lambda seg: self.fts(seg, normalize), inv))
for a in inv_segs:
for b in inv_segs:
if a != b:
if a.differing_specs(b) == [ft_name]:
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fts_match_any(self, fts, inv, normalize=True):\n return any([self.fts(s, normalize) >= fts for s in inv])",
"def seg_known(self, segment, normalize=True):\n if normalize:\n segment = FeatureTable.normalize(segment)\n return segment in self.seg_dict",
"def fts_match_all(self,... | [
"0.5811271",
"0.57281613",
"0.5448158",
"0.5358385",
"0.53195685",
"0.53195685",
"0.52680486",
"0.52578926",
"0.52107763",
"0.5175667",
"0.5123594",
"0.5117304",
"0.5098134",
"0.5091532",
"0.50853395",
"0.5074376",
"0.50618905",
"0.5061141",
"0.50536674",
"0.50494987",
"0.504... | 0.67574793 | 0 |
Implements fixedwidth pattern matching. Matches just in case pattern is the same length (in segments) as the word and each of the segments in the pattern is a featural subset of the corresponding segment in the word. Matches return the corresponding list of feature sets; failed matches return None. | def match_pattern(self, pat, word, normalize=True):
segs = self.word_fts(word, normalize)
if len(pat) != len(segs):
return None
else:
if all([s >= p for (s, p) in zip(segs, pat)]):
return segs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_segs_matching_fts(self, ft_mask):\n matching_segs = [ipa for (ipa, fts) in self.segments if fts >= ft_mask]\n return sorted(matching_segs, key=lambda x: len(x), reverse=True)",
"def better_matching(self, pattern, offsets=False, slice_len=5):\n first_occurencies, counts_at = self.setu... | [
"0.55103326",
"0.5505358",
"0.5503776",
"0.54771847",
"0.5460074",
"0.53849596",
"0.536037",
"0.5330876",
"0.5322131",
"0.52336895",
"0.5171854",
"0.51623005",
"0.51623005",
"0.5151723",
"0.51417255",
"0.510438",
"0.50986654",
"0.5090402",
"0.5082829",
"0.50758904",
"0.507350... | 0.6005872 | 0 |
Return segments matching a feature mask, a dict of features | def all_segs_matching_fts(self, ft_mask):
matching_segs = [ipa for (ipa, fts) in self.segments if fts >= ft_mask]
return sorted(matching_segs, key=lambda x: len(x), reverse=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_seg_features(string):\n seg_feature = []\n for word in jieba.cut(string):\n if len(word) == 1:\n seg_feature.append(0)\n else:\n tmp = [2] * len(word)\n tmp[0] = 1\n tmp[-1] = 3\n seg_feature.extend(tmp)\n return seg_feature",
... | [
"0.5785783",
"0.57444733",
"0.56591356",
"0.5636957",
"0.5626444",
"0.5615696",
"0.5559518",
"0.5535667",
"0.55190414",
"0.5504409",
"0.54510874",
"0.5436337",
"0.54250914",
"0.5373862",
"0.5363101",
"0.5299349",
"0.5298827",
"0.52629185",
"0.52567637",
"0.52518916",
"0.52425... | 0.61812437 | 0 |
Given a string describing features masks for a sequence of segments, return a compiled regex matching the corresponding strings. | def compile_regex_from_str(self, pat):
s2n = {'-': -1, '0': 0, '+': 1}
seg_res = []
for mat in re.findall(r'\[[^]]+\]+', pat):
ft_mask = {k: s2n[v] for (v, k) in re.findall(r'([+-])(\w+)', mat)}
segs = self.all_segs_matching_fts(ft_mask)
seg_res.append('({})'.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_regex_search(search_string):\n\n sspat = None\n valid_flags = {\n 'i': re.IGNORECASE\n }\n if search_string:\n try:\n search_string, flag_letters = re.match(r'^(.+?)(?:/([a-z]+))?$', search_string).groups()\n flags = 0\n # if flags are given,... | [
"0.5923782",
"0.5887709",
"0.5868116",
"0.5849082",
"0.57891506",
"0.5740547",
"0.5644862",
"0.56026363",
"0.55648553",
"0.55601627",
"0.5549869",
"0.5541171",
"0.55295944",
"0.5511487",
"0.54896027",
"0.54493785",
"0.54365784",
"0.5426857",
"0.54144484",
"0.5406572",
"0.5356... | 0.6694643 | 0 |
Returns list of elements with length "num" that are found to be equally spaced in the sequence provided | def takespread(sequence, num):
length = float(len(sequence))
for i in range(num):
yield sequence[int(ceil(i * length / num))] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def takespread(sequence, num):\n length = float(len(sequence))\n for i in range(num):\n yield sequence[int(np.ceil(i * length / num))]",
"def makespread(sequence, num):\n length = float(len(sequence))\n seq = np.array(sequence)\n return seq[np.ceil(np.arange(num) * length / num).astype(int)... | [
"0.6423416",
"0.61214864",
"0.6046932",
"0.5743309",
"0.5673493",
"0.55953926",
"0.54691815",
"0.54635596",
"0.54383546",
"0.5431269",
"0.5416143",
"0.5397969",
"0.53908265",
"0.53346854",
"0.53308976",
"0.5270804",
"0.5267939",
"0.5258385",
"0.5253757",
"0.5242062",
"0.52373... | 0.63344747 | 1 |
Returns the point value of the card based on the point_sysm | def points(self):
if self.rank() >= 9:
return self.point_sysm[self.rank()]
else:
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_points(self):\n return self.card_points",
"def points(self):\r\n\t\tif self.rank() in self.point_sysm:\r\n\t\t\treturn self.point_sysm[self.rank()]\r\n\t\telse:\r\n\t\t\treturn (self.rank() + 2)",
"def get_value(self) -> float:\n return self.points[0, 0]",
"def get_value(self):\n ... | [
"0.62925595",
"0.62118644",
"0.61739796",
"0.6122231",
"0.60565126",
"0.6052252",
"0.59305984",
"0.5907347",
"0.5907347",
"0.58484674",
"0.583888",
"0.5818497",
"0.57965267",
"0.57405937",
"0.57035714",
"0.56290007",
"0.5627985",
"0.56179416",
"0.5547793",
"0.55453503",
"0.55... | 0.6351527 | 0 |
Finds the total points that the hand h has and returns that value | def total(h):
return sum(i.points() for i in h) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_points(self):\n points = 0\n for power in self.stats['powers']:\n points += self.stats['powers'][power]\n return points",
"def calculate_points(hand): \r\n hand_value = 0\r\n ace_count = 0 \r\n \r\n #Finds value of non-Ace cards, and counts number ... | [
"0.69434226",
"0.69146436",
"0.6852298",
"0.6826466",
"0.6719616",
"0.67074096",
"0.66723466",
"0.6659441",
"0.65662277",
"0.6562473",
"0.6524262",
"0.6511739",
"0.64851105",
"0.64222765",
"0.6378741",
"0.63757426",
"0.636187",
"0.63509446",
"0.6337169",
"0.6326228",
"0.63157... | 0.76675487 | 0 |
Returns a deck full of a cards that are defined by the cla class | def new_deck(cla):
return [cla(i) for i in range(52)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_deck(self):\n\t\tsuits = [\"hearts\", \"spades\",\"diamonds\",\"clubs\"]\n\t\tcards = []\n\n\t\tfor suit in suits:\n\t\t\tif self.ace_as_eleven:\n\t\t\t\tace = Card(\"Ace\", 11, suit)\n\t\t\telse:\n\t\t\t\tace = Card(\"Ace\", 1, suit)\n\t\t\tcards.append(ace)\n\n\t\t\ttwo = Card(\"Two\", 2, suit)\n\t\... | [
"0.7541672",
"0.71924794",
"0.7061139",
"0.69914514",
"0.6714803",
"0.666234",
"0.664922",
"0.6637694",
"0.66035664",
"0.657957",
"0.6567809",
"0.6554334",
"0.6484326",
"0.6472026",
"0.6435984",
"0.64274347",
"0.6413029",
"0.6395127",
"0.63739616",
"0.63564146",
"0.635381",
... | 0.76038283 | 0 |
Pushes records to the server | def _push(self, server):
defns = [self.get_id(ident) for ident in list(self.ids)]
#for ident in list(self.ids):
# defn = self.get_id(ident)
if len(defns) == 0:
return
self.app.logger.info(f"Updating {server} with {len(defns)} records")
url = f"{server}/add_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _es_push_results(self, query_name, records):\n logger.debug(f\"Pushing {query_name}: {records}\")\n for c in self.es_clients:\n c.send_to_es(query_name, records)",
"def _push_to_server(self) -> None:\n timestamp = int(arrow.get().float_timestamp * 1000)\n\n datapoints: ... | [
"0.6992219",
"0.6472381",
"0.6440058",
"0.6413171",
"0.6410277",
"0.64007604",
"0.6349231",
"0.6322149",
"0.61902606",
"0.61212903",
"0.60770565",
"0.60610574",
"0.60589975",
"0.599316",
"0.5989526",
"0.5989526",
"0.5933634",
"0.5901903",
"0.5889706",
"0.5877791",
"0.58750814... | 0.7575993 | 0 |
Constructor Class for MixCriterion. | def __init__(self, criterion: Callable):
self.criterion = criterion | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args, **kwargs):\n\t\tsuper().__init__(*args, **kwargs)\n\t\tself.condition = None",
"def __init__(self, **kwargs: Any):\n self.multiclass_te_co = 3\n self.top_intersections = 5\n self.max_intersection_depth = 3\n self.subsample = 10000\n self.random_state =... | [
"0.6095481",
"0.60818535",
"0.60206497",
"0.60206497",
"0.5973565",
"0.5949284",
"0.5945663",
"0.57841676",
"0.5744737",
"0.5706614",
"0.56997925",
"0.5673495",
"0.5635301",
"0.5579832",
"0.5573683",
"0.55335826",
"0.55186737",
"0.5517108",
"0.5516155",
"0.5516155",
"0.551615... | 0.6339344 | 0 |
Reads from file environment.yaml values and changes environment variables. | def change_environment_variables():
values = load('environment.yaml')
for key in values.keys():
os.environ[key] = values[key]
info(f'Changed environment variables to {values}') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_evironment():\n environment = Utility.load_yaml(os.getenv(\"system_file\", \"./system.yaml\"))\n for key in environment:\n if key in os.environ:\n environment[key] = os.getenv(key)\n Utility.environment = environment",
"def load_envs_from_file(file_path=con... | [
"0.7406269",
"0.69363457",
"0.66602415",
"0.6634683",
"0.65131164",
"0.64999026",
"0.649091",
"0.6366587",
"0.63470614",
"0.6244345",
"0.61629504",
"0.6037942",
"0.6028842",
"0.5990134",
"0.5982547",
"0.59603816",
"0.59407336",
"0.59406185",
"0.5874832",
"0.5864534",
"0.58374... | 0.8063575 | 0 |
Check that the board used is large enough and has enough valid tiles for the given list of players, raises a ValueError if any of these conditions are not met. | def __check_board_is_valid(self, board, players):
total_tiles = board.get_rows() * board.get_cols()
# check the board is big enough
if total_tiles < (6 - len(players)) * len(players):
raise ValueError("Board specified by board_size is too small.")
# check that the board has e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_valid_board(board):\n valid = len(board) == 9\n valid &= -1 <= sum(board) <= 1\n valid &= reduce(lambda x, y: x and y, [utils.is_valid_player(p) for p in board])\n return valid",
"def test_generate_board_too_many_mines_errors(self):\n # arrange\n game = minesweeper.Minesweeper()\... | [
"0.6559245",
"0.65429807",
"0.6363457",
"0.63405097",
"0.6310487",
"0.61935323",
"0.61810786",
"0.61345714",
"0.60889655",
"0.6072533",
"0.5982412",
"0.5976069",
"0.5964283",
"0.59554005",
"0.5949775",
"0.59412664",
"0.59252197",
"0.5920554",
"0.59201723",
"0.5910528",
"0.589... | 0.8507374 | 0 |
Set the colors of the players, if needed. If all players have unique colors, return the players asis. | def __set_colors(self, players):
colors = set()
for p in players:
if p.get_color() is None:
continue
colors.add(p.get_color())
if len(colors) != 0 and len(colors) != len(players):
raise ValueError("Each player does not have a unique assigned c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_player_colors() -> List[Tuple[float, float, float]]:\n return PLAYER_COLORS",
"def init_players(self):\n complain = \"\"\n players_turn = random.sample(range(self.n_players), self.n_players)\n players_created = {}\n picked_colors = []\n for x in range(self.n_players)... | [
"0.6983501",
"0.661778",
"0.65605044",
"0.6559854",
"0.65476024",
"0.65333056",
"0.64143264",
"0.613175",
"0.6107858",
"0.60999984",
"0.6061564",
"0.59373385",
"0.58590215",
"0.58403534",
"0.58192056",
"0.57921976",
"0.5781316",
"0.5771787",
"0.5770856",
"0.5764907",
"0.57404... | 0.848916 | 0 |
Remove a player of a given color from the game along with his penguins and add him to the violator list. | def __remove_player(self, color):
self.state.remove_player(color)
self.violators.append(self.players[color]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removePlayer(self, color):\n if type(color) not in (player.Player, int):\n raise TypeError(\"Input to removePlayer must be of type int or Player.\")\n if type(color) is player.Player:\n color = color.getColor()\n if color not in self.__colordict__:\n raise ... | [
"0.7096801",
"0.6246487",
"0.6242192",
"0.59200877",
"0.5919842",
"0.5817426",
"0.57871246",
"0.57752347",
"0.57319325",
"0.57220024",
"0.57121086",
"0.5706811",
"0.5705507",
"0.5691792",
"0.56409585",
"0.564011",
"0.5619549",
"0.5613825",
"0.55753464",
"0.5562794",
"0.551482... | 0.8311631 | 0 |
Helper to put threaded function return value in a queue. Puts None in the queue if an exception occurs. | def __player_thread(self, func, arg, queue):
try:
queue.put(func(arg))
except Exception as exc:
#print(exc)
queue.put(None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ReturnWrapper(queue, fn):\n queue.put(fn())",
"def queue_wrapper(result_queue, wid,\n func, args):\n result_queue.put((wid, func(*args)))",
"def putting_on_queue(*args):\n results.put(main_func(*args))",
"def run(self, arg: _T) -> queue.Queue[Tuple[Optional[_R], Optional[Excepti... | [
"0.77862006",
"0.6819761",
"0.63104945",
"0.62345034",
"0.61928016",
"0.6103177",
"0.6083798",
"0.6009036",
"0.593441",
"0.5919444",
"0.59155446",
"0.5880543",
"0.58595",
"0.58402306",
"0.5773026",
"0.5739314",
"0.57106704",
"0.5703303",
"0.56909806",
"0.5687329",
"0.5681928"... | 0.7133484 | 1 |
Get the player scores. | def get_scores(self):
return [(self.players[p.get_color()], p.get_score()) for p in self.state.get_players()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_scores(self):\n return self.score",
"def get_score(self, player):\n if player in self.player_scores:\n return self.player_scores[player]\n else:\n raise Exception(\"Player not in score list\")",
"def score(self):\n return self.client.call('GET', self.na... | [
"0.81142956",
"0.7553951",
"0.738606",
"0.7267321",
"0.719919",
"0.71760154",
"0.7120312",
"0.704196",
"0.6985496",
"0.6970983",
"0.6936181",
"0.6799197",
"0.6795344",
"0.6784494",
"0.6777752",
"0.67771673",
"0.6773122",
"0.6722797",
"0.6709587",
"0.66867256",
"0.66849506",
... | 0.8255623 | 0 |
Get the victor(s) if the game is over. Players in the violators list are not eligible for victory. | def get_victors(self):
if self.is_game_over():
scores = [p.get_score() for p in self.state.get_players()]
if len(scores) == 0:
return []
max_score = max(scores)
victors = []
for p in self.state.get_players():
if p.get_co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CheckVictoryCondition(self):\n opponentVictory = True\n for char in self.screen.characters:\n if char.team == 1 and char.leader and not char.dead:\n opponentVictory = False\n if opponentVictory:\n self.screen.refresh()\n self.music.stop()\n ... | [
"0.59914505",
"0.5907969",
"0.58250535",
"0.5708909",
"0.5472831",
"0.54458094",
"0.5445035",
"0.5442779",
"0.5384571",
"0.5359108",
"0.5300459",
"0.5299243",
"0.5299243",
"0.5279039",
"0.52614534",
"0.52344775",
"0.5208366",
"0.5185099",
"0.5184724",
"0.5178754",
"0.516631",... | 0.75721735 | 0 |
Get a rule violators who have been ejected. | def get_violators(self):
return self.violators | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def affecteds(self):\n return [m for m in self.members if m.disease == PedigreeMember.AFFECTED]",
"def get_victors(self):\n if self.is_game_over():\n scores = [p.get_score() for p in self.state.get_players()]\n if len(scores) == 0:\n return []\n max_s... | [
"0.6156995",
"0.59065264",
"0.5629059",
"0.5474041",
"0.53551775",
"0.52045214",
"0.5177488",
"0.50929904",
"0.5079941",
"0.5059264",
"0.5059264",
"0.5011072",
"0.4973407",
"0.49627775",
"0.4929745",
"0.4920347",
"0.4912848",
"0.4911266",
"0.4906332",
"0.48964974",
"0.4874137... | 0.61693317 | 0 |
Get a copy of the current state. | def get_current_state(self):
return deepcopy(self.state) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state(self):\n return copy.deepcopy(self._state)",
"def __getstate__(self):\n state = self.__dict__.copy()\n self.__cleanState__(state)\n return state",
"def state(self):\n return self._state.copy()",
"def get_state(self, deepcopy: bool = True):\n s = self.cache_... | [
"0.8455732",
"0.79240113",
"0.78669524",
"0.78233796",
"0.76678777",
"0.76537627",
"0.7607961",
"0.75942713",
"0.7512252",
"0.74859667",
"0.74796313",
"0.7326282",
"0.7263944",
"0.7236717",
"0.7214216",
"0.7181021",
"0.7169202",
"0.71566755",
"0.715247",
"0.7142748",
"0.71140... | 0.81724 | 1 |
Get the ID for the pool assigned to the given queue. | def _pool_id(self, queue, project=None):
return self._catalogue_ctrl.get(project, queue)['pool'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _get_work_pool_queue_id_from_name(\n self, session: AsyncSession, work_pool_name: str, work_pool_queue_name: str\n ) -> UUID:\n work_pool_queue = await models.workers.read_work_pool_queue_by_name(\n session=session,\n work_pool_name=work_pool_name,\n work... | [
"0.7236343",
"0.7009467",
"0.6953268",
"0.6914265",
"0.6697232",
"0.66893286",
"0.6669339",
"0.6644398",
"0.65078753",
"0.6422109",
"0.63314754",
"0.63168746",
"0.63056153",
"0.62965095",
"0.6249178",
"0.6227463",
"0.62212545",
"0.61551255",
"0.61551255",
"0.6059136",
"0.6049... | 0.8461307 | 0 |
Register a new queue in the pool catalog. This method should be called whenever a new queue is being created, and will create an entry in the pool catalog for the given queue. After using this method to register the queue in the catalog, the caller should call `lookup()` to get a reference to a storage driver which wil... | def register(self, queue, project=None, flavor=None):
# NOTE(gengchc): if exist, get queue's pool.flavor:
# if queue's pool.flavor is different, first delete it and add it.
# Otherwise, if the flavor in the meteredata of the queue is
# modified, the catalog will be inconsistent.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register(self, queue, project=None):\n # NOTE(cpp-cabrera): only register a queue if the entry\n # doesn't exist\n if not self._catalogue_ctrl.exists(project, queue):\n # NOTE(cpp-cabrera): limit=0 implies unlimited - select from\n # all shards\n shard = se... | [
"0.71361166",
"0.6695945",
"0.64565563",
"0.6338736",
"0.6160316",
"0.6083422",
"0.5962883",
"0.59370244",
"0.5895258",
"0.5773519",
"0.5767887",
"0.5727844",
"0.5669611",
"0.5621137",
"0.55773187",
"0.5558326",
"0.5552847",
"0.55482846",
"0.55192804",
"0.5471164",
"0.5442383... | 0.7536504 | 0 |
Lookup the queue controller for the given queue and project. | def get_queue_controller(self, queue, project=None):
target = self.lookup(queue, project)
return target and target.queue_controller | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_claim_controller(self, queue, project=None):\n target = self.lookup(queue, project)\n return target and target.claim_controller",
"def get_message_controller(self, queue, project=None):\n target = self.lookup(queue, project)\n return target and target.message_controller",
"d... | [
"0.77063626",
"0.7698841",
"0.76416427",
"0.7288941",
"0.6930836",
"0.6912205",
"0.60668814",
"0.606344",
"0.60406834",
"0.594424",
"0.5849223",
"0.5683665",
"0.5642507",
"0.560627",
"0.559546",
"0.55402505",
"0.55328107",
"0.5492972",
"0.54287374",
"0.5398488",
"0.539153",
... | 0.86451554 | 0 |
Lookup the message controller for the given queue and project. | def get_message_controller(self, queue, project=None):
target = self.lookup(queue, project)
return target and target.message_controller | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queue_controller(self, queue, project=None):\n target = self.lookup(queue, project)\n return target and target.queue_controller",
"def get_claim_controller(self, queue, project=None):\n target = self.lookup(queue, project)\n return target and target.claim_controller",
"def g... | [
"0.80495954",
"0.73924774",
"0.73809624",
"0.6577108",
"0.6438663",
"0.6041202",
"0.5956915",
"0.5211523",
"0.5192648",
"0.5166102",
"0.5160857",
"0.5156492",
"0.5145304",
"0.51198655",
"0.51061904",
"0.50889635",
"0.49702215",
"0.49656522",
"0.49377242",
"0.49108028",
"0.487... | 0.8593036 | 0 |
Lookup the claim controller for the given queue and project. | def get_claim_controller(self, queue, project=None):
target = self.lookup(queue, project)
return target and target.claim_controller | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queue_controller(self, queue, project=None):\n target = self.lookup(queue, project)\n return target and target.queue_controller",
"def get_subscription_controller(self, queue, project=None):\n target = self.lookup(queue, project)\n return target and target.subscription_control... | [
"0.7787301",
"0.7567917",
"0.7170647",
"0.62005764",
"0.6165711",
"0.5723963",
"0.5608801",
"0.5049111",
"0.5029624",
"0.48735002",
"0.48166627",
"0.4790605",
"0.47787577",
"0.47474897",
"0.47414377",
"0.4711115",
"0.47098687",
"0.47030538",
"0.4683094",
"0.46805832",
"0.4673... | 0.8776693 | 0 |
Lookup the subscription controller for the given queue and project. | def get_subscription_controller(self, queue, project=None):
target = self.lookup(queue, project)
return target and target.subscription_controller | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queue_controller(self, queue, project=None):\n target = self.lookup(queue, project)\n return target and target.queue_controller",
"def get_claim_controller(self, queue, project=None):\n target = self.lookup(queue, project)\n return target and target.claim_controller",
"def g... | [
"0.76404476",
"0.7447651",
"0.69627404",
"0.63039684",
"0.62465614",
"0.6126285",
"0.60098344",
"0.5344913",
"0.52650946",
"0.5261455",
"0.5224008",
"0.51507324",
"0.51497537",
"0.5039444",
"0.5002221",
"0.4991361",
"0.49808443",
"0.49703738",
"0.4967121",
"0.4910888",
"0.487... | 0.8589521 | 0 |
Lookup the topic controller for the given queue and project. | def get_topic_controller(self, topic, project=None):
target = self.lookup(topic, project)
return target and target.topic_controller | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queue_controller(self, queue, project=None):\n target = self.lookup(queue, project)\n return target and target.queue_controller",
"def get_subscription_controller(self, queue, project=None):\n target = self.lookup(queue, project)\n return target and target.subscription_control... | [
"0.7733818",
"0.7603851",
"0.74324155",
"0.728382",
"0.63744485",
"0.6344827",
"0.57456493",
"0.5728621",
"0.56051105",
"0.55933976",
"0.55091506",
"0.5342035",
"0.5326094",
"0.53004175",
"0.5222844",
"0.520292",
"0.5191208",
"0.51723534",
"0.5128026",
"0.5117455",
"0.508792"... | 0.7806749 | 0 |
Lookup a pool driver for the given queue and project. | def lookup(self, queue, project=None):
try:
pool_id = self._pool_id(queue, project)
except errors.QueueNotMapped as ex:
LOG.debug(ex)
return self.get_default_pool(use_listing=False)
return self.get_driver(pool_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookup(self, queue, project=None):\n\n try:\n shard_id = self._shard_id(queue, project)\n except errors.QueueNotMapped as ex:\n LOG.debug(ex)\n\n # NOTE(kgriffs): Return `None`, rather than letting the\n # exception bubble up, so that the higher layer d... | [
"0.7773466",
"0.6421427",
"0.61614996",
"0.58672553",
"0.58434623",
"0.5762848",
"0.56201243",
"0.5590634",
"0.5587302",
"0.5487426",
"0.54723954",
"0.5447157",
"0.5354828",
"0.5348546",
"0.53464115",
"0.52886975",
"0.5276325",
"0.5234317",
"0.521486",
"0.518824",
"0.51820177... | 0.8907264 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.