query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Run layer normalization on the last dimension of the tensor. | def layer_norm(input_tensor, name=None):
return tf.contrib.layers.layer_norm(
inputs=input_tensor, begin_norm_axis=-1, begin_params_axis=-1, scope=name)
# return layer_norm_utils.layer_norm(
# inputs=input_tensor, begin_norm_axis=-1, begin_params_axis=-1, scope=name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def norm_layer( x, training, name):\n top = tf.layers.batch_normalization( x, \n axis=3, # channels last \n training=training,\n name=name )\n return... | [
"0.7188906",
"0.69637734",
"0.6945734",
"0.6798118",
"0.6788187",
"0.6748983",
"0.67479163",
"0.6699479",
"0.66064614",
"0.65870273",
"0.65647274",
"0.6562947",
"0.6558574",
"0.65531063",
"0.65426546",
"0.6530644",
"0.65272397",
"0.6524653",
"0.65179014",
"0.6512279",
"0.6502... | 0.6301082 | 37 |
Creates a `truncated_normal_initializer` with the given range. | def create_initializer(initializer_range=0.02):
return tf.truncated_normal_initializer(stddev=initializer_range) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_initializer(initializer_range=0.02):\n return tf.compat.v1.truncated_normal_initializer(stddev=initializer_range)",
"def create_initializer(initializer_range=0.02):\n return tf.truncated_normal_initializer(stddev=initializer_range)",
"def create_initializer(initializer_range=0.02):\n return t... | [
"0.824108",
"0.81743896",
"0.81743896",
"0.739506",
"0.6658517",
"0.65715015",
"0.6412829",
"0.6391333",
"0.63818395",
"0.6278954",
"0.6278954",
"0.62506354",
"0.6214777",
"0.62131006",
"0.6147218",
"0.6080626",
"0.5928713",
"0.58490723",
"0.57324564",
"0.57044655",
"0.570007... | 0.8153106 | 3 |
Check if two boards are equal | def board_equals(board, newboard):
return (newboard == board).all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other) -> None:\n\t\tfor k, v in enumerate(self.board):\n\t\t\tif v != other.board[k]:\n\t\t\t\treturn False\n\t\treturn True",
"def __eq__(self, other):\n for row in range( self.n ):\n if self.board[row] != other.board[row]:\n return False\n return True",... | [
"0.76765525",
"0.7590167",
"0.7520879",
"0.73166174",
"0.7049794",
"0.6997381",
"0.69779974",
"0.696249",
"0.69501203",
"0.6933911",
"0.6929893",
"0.68988365",
"0.6865647",
"0.68118745",
"0.6808368",
"0.67976785",
"0.67858136",
"0.6755733",
"0.673824",
"0.67163175",
"0.660529... | 0.7748529 | 0 |
Skips current track, playing next track in queue, if any. | async def skip(self, ctx):
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
if not player.is_connected:
# We can't disconnect, if we're not connected.
return await ctx.send(embed=self.error_embed(f'Not playing. [{ctx.message.author.mention}]'))
if not ctx.aut... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def skip(self, ctx: commands.Context) -> None:\n player = self.get_player(ctx.guild)\n\n # Don't even try if we're not connected.\n if not player.is_connected:\n fail = Embeds.status(success=False, desc=\"I'm not even connected. 😪\")\n return await ctx.send(embed=f... | [
"0.72729826",
"0.72056466",
"0.6949376",
"0.6840954",
"0.6783104",
"0.6651116",
"0.65805197",
"0.6566165",
"0.65586954",
"0.6519272",
"0.6447256",
"0.6398561",
"0.6396144",
"0.63762",
"0.63680774",
"0.6246496",
"0.6237764",
"0.6228871",
"0.6214305",
"0.6163204",
"0.6098798",
... | 0.6394138 | 13 |
Skips to song on index [song_index 1] | async def jump(self, ctx, song_index: int):
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
if not player.is_connected:
# We can't disconnect, if we're not connected.
return await ctx.send(embed=self.error_embed(f'Not playing. [{ctx.message.author.mention}]'))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def skip(self, ctx: commands.Context, index: int = None) -> Optional[Player]:\n\n queue = self.queue[ctx.guild.id]\n\n # Created duplicate to make sure InvalidSkipIndex isn't raised when the user does pass an index and the queue\n # is empty.\n skip_index = 0 if index is None else... | [
"0.74536604",
"0.660435",
"0.65800935",
"0.6564887",
"0.65644896",
"0.6449226",
"0.643171",
"0.6391717",
"0.6304532",
"0.62767243",
"0.6233605",
"0.62085",
"0.61736286",
"0.61491734",
"0.6035632",
"0.6006644",
"0.59841126",
"0.59568334",
"0.59429246",
"0.59388036",
"0.5889418... | 0.64065945 | 7 |
Render the front page | def home_view(request):
status_list = Status.objects.filter(reply_to=None).order_by('-created')
paginator = Paginator(status_list, 20)
page = request.GET.get('page')
try:
statuses = paginator.page(page)
except PageNotAnInteger:
statuses = paginator.page(1)
except EmptyPage:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self):\n self.render_front()",
"def render_home():\r\n\treturn render_template(\"index.html\")",
"def home(request):\n assert isinstance(request, HttpRequest)\n return render(\n request,\n 'AscensionESports_Baseline/index.html',\n {\n 'background': getSiteBa... | [
"0.7950714",
"0.74666595",
"0.73518693",
"0.72748566",
"0.7248063",
"0.7182079",
"0.712583",
"0.71192783",
"0.7117115",
"0.711143",
"0.7096715",
"0.70903045",
"0.70779085",
"0.70491207",
"0.704007",
"0.7033552",
"0.7033552",
"0.7017236",
"0.70099777",
"0.70099777",
"0.7009977... | 0.0 | -1 |
Translate with a given direction scaled by dist | def translate(self, axis: Vector, dist: float):
self.origin = self.origin + axis * dist | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _define_transdist(self, loc: torch.Tensor, scale: torch.Tensor):\n\n return _define_transdist(loc, scale, self.increment_dist, self.ndim)",
"def ty(self, dist: float) -> \"Mate\":\n self.translate(self.y_dir, dist)\n return self",
"def zoom(self, dr):\n d = self.getDistance()\n ... | [
"0.64987594",
"0.63573056",
"0.6215362",
"0.619352",
"0.61720383",
"0.6116733",
"0.6090099",
"0.6078002",
"0.60694516",
"0.60694516",
"0.60559475",
"0.60549414",
"0.601227",
"0.6008165",
"0.5907597",
"0.58837587",
"0.5868495",
"0.5858269",
"0.5742285",
"0.57237685",
"0.571494... | 0.7711936 | 0 |
Translate with a given distance along x axis | def tx(self, dist: float) -> "Mate":
self.translate(self.x_dir, dist)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def translate(self, axis: Vector, dist: float):\n self.origin = self.origin + axis * dist",
"def translate(self, displacement):\n\n self.center = (self.center[0] + displacement[0],\n self.center[1] + displacement[1])",
"def _translate_x(self, x, pixels):\r\n pixels = (pixels/... | [
"0.7099483",
"0.65959543",
"0.6470794",
"0.6267494",
"0.6220674",
"0.61500096",
"0.6098971",
"0.6067018",
"0.6067018",
"0.6063745",
"0.603237",
"0.5900952",
"0.5894472",
"0.5883814",
"0.58670795",
"0.5854436",
"0.58415574",
"0.5832695",
"0.5792232",
"0.57817256",
"0.576255",
... | 0.630293 | 3 |
Translate with a given distance along y axis | def ty(self, dist: float) -> "Mate":
self.translate(self.y_dir, dist)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def y(self, destination):\n destination = (self.center[0], destination)\n self.move(destination=destination, origin=self.center, axis=\"y\")",
"def translate(self, axis: Vector, dist: float):\n self.origin = self.origin + axis * dist",
"def _translate_y(self, x, pixels):\r\n pixels ... | [
"0.6673237",
"0.6609074",
"0.6309279",
"0.616408",
"0.6041089",
"0.6022442",
"0.60171205",
"0.60005295",
"0.59970003",
"0.59389627",
"0.58593106",
"0.58135325",
"0.5808749",
"0.57823074",
"0.57431877",
"0.5738963",
"0.5726749",
"0.5726749",
"0.5716009",
"0.5711633",
"0.569359... | 0.647869 | 2 |
Initialize with tokenizer to split documents into words. | def __init__(self, tokenizer=simple_tokenize):
# Set tokenizer to use for tokenizing new documents
self.tokenize = tokenizer
# The term document matrix is a sparse matrix represented as a
# list of dictionaries. Each dictionary contains the word
# counts for a document.
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenize(self):\n\n x = [] # input documents\n for file_path in glob.glob(self.train_dir + '*.txt'):\n file_as_string = open(file_path).read()\n x.append(file_as_string)\n\n self.tokenizer.fit_on_texts(x)\n print('input vocabulary size:', len(self.tokenizer.word_index))\n pickle_file =... | [
"0.7294537",
"0.72017705",
"0.69860333",
"0.68886244",
"0.661977",
"0.6515793",
"0.64932626",
"0.6460047",
"0.6445212",
"0.64141256",
"0.63538796",
"0.634325",
"0.63242966",
"0.63150656",
"0.6312389",
"0.6238258",
"0.6234263",
"0.6231918",
"0.6220183",
"0.61834913",
"0.616647... | 0.6863716 | 4 |
Returns the name of the channel for the given radio and channel. | def channel_name(radio_id: int, channel_id: int) -> str:
return f"COMM{radio_id} Ch {channel_id}" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def channelName(self):\n channel_list = (\"Neutral\",\n \"BBC1\",\n \"BBC2\",\n \"ITV\",\n \"Channel 4\",\n \"Channel 5\")\n channel_name = channel_list[self.channel]\n return cha... | [
"0.72019213",
"0.7178412",
"0.7178412",
"0.7178412",
"0.7178412",
"0.7178412",
"0.7178412",
"0.7178412",
"0.7178412",
"0.7178412",
"0.7178412",
"0.7178412",
"0.7178412",
"0.7178412",
"0.7178412",
"0.7178412",
"0.7178412",
"0.7178412",
"0.7178412",
"0.7178412",
"0.70424455",
... | 0.8595431 | 0 |
Returns the type of aircraft in this flight. | def aircraft_type(self) -> FlyingType:
return self.units[0].unit_type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAircraft(self, code):\n \t\n return self.aircraftDict[code.upper()]",
"def landing_airport(self, **kwargs: Any) -> \"Airport\":\n\n from ..core.distance import guess_airport\n\n # The following cast secures the typing\n self = cast(\"Flight\", self)\n\n data = self.da... | [
"0.6327988",
"0.6149255",
"0.6035162",
"0.59869665",
"0.5729768",
"0.56378406",
"0.55666333",
"0.5497275",
"0.5460754",
"0.5430962",
"0.53903615",
"0.5380597",
"0.53774005",
"0.5364313",
"0.535924",
"0.53532493",
"0.5348655",
"0.5333701",
"0.5304017",
"0.5296175",
"0.5294151"... | 0.84770125 | 0 |
Cleans up the bot's messages from the channel. You must have the Manage Messages permission to use this. | async def cleanup(self, ctx, search=100):
await self.run_purge(
ctx, search, lambda m: m.author == ctx.me or m.content.startswith(ctx.prefix)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def cleanup(self, ctx):\r\n msgs = await ctx.message.channel.history(limit=100).flatten()\r\n msgs = [msg for msg in msgs if msg.author.id == self.amethyst.user.id]\r\n\r\n if (len(msgs) > 0 and\r\n ctx.me.permissions_in(ctx.channel).manage_messages):\r\n await ... | [
"0.7616181",
"0.745067",
"0.71939385",
"0.7137196",
"0.71077174",
"0.6853759",
"0.6785673",
"0.6658688",
"0.6653616",
"0.66379696",
"0.6596929",
"0.65137434",
"0.6412353",
"0.6377085",
"0.63298213",
"0.62498647",
"0.62126213",
"0.6188841",
"0.61473376",
"0.6130192",
"0.611968... | 0.0 | -1 |
Denormalize to uint8 [0...255] tensor from a float32 [0...1] tensor. | def denormalize(float32_frame):
if (not isinstance(float32_frame, tf.Tensor) or
float32_frame.dtype != tf.float32):
raise ValueError(f"Invalid input: {float32_frame}")
return tf.image.convert_image_dtype(float32_frame, tf.uint8, saturate=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def float32_to_uint8(inputs):\n return np.uint8(np.clip(np.round(inputs * 255), 0, 255))",
"def uint8_to_float(im: np.array):\n if im.dtype == np.float32:\n warnings.warn(\"Image is already np.float32\")\n return im\n im = im.astype(np.float32) / 255\n return im",
"def uint8_to_float(... | [
"0.72965324",
"0.67540747",
"0.67540747",
"0.6749495",
"0.6719711",
"0.66579753",
"0.6494371",
"0.64181966",
"0.6409996",
"0.63891613",
"0.6387406",
"0.6382331",
"0.6354447",
"0.63429034",
"0.6335926",
"0.6300085",
"0.6289246",
"0.6245077",
"0.6231531",
"0.6220535",
"0.618546... | 0.72193897 | 1 |
Raise ValueError if we have invalid shapes. | def validate_shape_and_dtype(self):
if self.rgb.dtype != tf.float32:
raise ValueError("Expected float32 rgb!")
if len(self.rgb.shape) != 4:
raise ValueError(f"Expected (B, H, W, C), got {self.rgb.shape}")
_, _, _, channels = self.rgb.shape.as_list()
if channels != 3:
raise ValueError(f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_shape(self):\n if len(self._first_rgb.shape) != 5:\n raise ValueError(f\"Invalid shape: {self._first_rgb.shape}\")",
"def _shape_check(self, X, y):\n if not len(y.shape) > 1:\n raise RuntimeError(\"The shape of y is incorrect.\")\n if y.shape != X.shape[:-1]:\n ... | [
"0.7520749",
"0.6995105",
"0.6986119",
"0.6962179",
"0.695349",
"0.6889278",
"0.68580693",
"0.6736823",
"0.6689245",
"0.6615782",
"0.65720016",
"0.6547961",
"0.65478575",
"0.6534164",
"0.6530391",
"0.6463948",
"0.6453337",
"0.6426276",
"0.6411735",
"0.64014214",
"0.639231",
... | 0.6341107 | 23 |
Obtain a new Frame batch by applying `fn` on each element. | def apply(self, fn):
return Frame(fn(self.rgb)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batchify(fn, chunk):\n if chunk is None:\n return fn\n\n def ret(inputs, styles, alpha, feature):\n results = []\n for i in range(0, inputs.shape[0], chunk):\n input_chunk = inputs[i:i + chunk]\n style_chunk = styles[i:i + chunk]\n alpha_chunk = alpha... | [
"0.61101085",
"0.61065644",
"0.59294605",
"0.5812814",
"0.57043624",
"0.57043624",
"0.5694395",
"0.56770957",
"0.56308436",
"0.5596898",
"0.5539138",
"0.5528681",
"0.53403354",
"0.5315339",
"0.5265743",
"0.52645123",
"0.5256261",
"0.5194063",
"0.51897436",
"0.51605433",
"0.51... | 0.7081017 | 0 |
Obtain a new Frame batch by applying `reduce_fn` on each element. | def reduce(cls, frames,
reduce_fn):
rgb = reduce_fn([f.rgb for f in frames])
return Frame(rgb) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply(self, fn):\n return Frame(fn(self.rgb))",
"def reduce(self, function):\n return reduce(function, self.data)",
"def batchify(fn, chunk, world_fn = lambda x:x, gather_func = None):\n if chunk is None:\n return fn\n def ret(inputs, training = False, world_fn=world_fn):\n em... | [
"0.5898605",
"0.5626834",
"0.5527074",
"0.54001063",
"0.5352686",
"0.52958137",
"0.5288031",
"0.52771777",
"0.5268288",
"0.524487",
"0.52035064",
"0.51752454",
"0.51169777",
"0.50755507",
"0.5073291",
"0.5058255",
"0.5054055",
"0.50492036",
"0.5028246",
"0.49981123",
"0.49937... | 0.71606076 | 0 |
Create an instance from frames. | def from_frames(cls, frames):
rgbs = []
for frame in frames:
rgbs.append(frame.rgb)
return cls(tf.stack(rgbs, axis=1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, frames=[], loop = 0):\n\t\t\n\t\tif isinstance(frames, (list, tuple)):\n\t\t\tself.frames = frames\n\t\telse:\n\t\t\traise TypeError\n\t\t\t\n\t\tif not loop:\n\t\t\tself.loop = 0\n\t\telse:\n\t\t\tself.loop = 1\n\t\t\t\n\t\tself.present_frame = None",
"def __init__(self, frames):\n sel... | [
"0.7005853",
"0.6985454",
"0.6985454",
"0.6985454",
"0.6985454",
"0.6715102",
"0.6715102",
"0.6715102",
"0.6715102",
"0.6715102",
"0.6715102",
"0.63013303",
"0.62931854",
"0.62253046",
"0.6058778",
"0.6043134",
"0.57654005",
"0.5662797",
"0.5658757",
"0.5640733",
"0.5473115",... | 0.6860101 | 5 |
Raise ValueError if we have invalid shapes. | def validate_shape(self):
if len(self._first_rgb.shape) != 5:
raise ValueError(f"Invalid shape: {self._first_rgb.shape}") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _shape_check(self, X, y):\n if not len(y.shape) > 1:\n raise RuntimeError(\"The shape of y is incorrect.\")\n if y.shape != X.shape[:-1]:\n raise RuntimeError(\"X and y must have the same number of \" +\n \"samples and microstructure shape.\")\n... | [
"0.6995105",
"0.6986119",
"0.6962179",
"0.695349",
"0.6889278",
"0.68580693",
"0.6736823",
"0.6689245",
"0.6615782",
"0.65720016",
"0.6547961",
"0.65478575",
"0.6534164",
"0.6530391",
"0.6463948",
"0.6453337",
"0.6426276",
"0.6411735",
"0.64014214",
"0.639231",
"0.6366248",
... | 0.7520749 | 0 |
initializes the particle filter with a normal distribution | def __init__(self, init_pos, init_stdev, num_particles, sense_noise):
self.particles = np.random.multivariate_normal(
init_pos, [[init_stdev**2, 0], [0, init_stdev**2]], num_particles)
self.weights = np.array(
[1. / num_particles for _ in range(num_particles)])
self.n = n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_particles(self):\n \n # Each particle is a dimension-K vector. We generate each particle \n # uniformly at random from the space [0,1]^K. \n self.Particles = np.random.uniform(0, 1, (self.Npar, self.K))\n #print(\"Particles: \", self.Particles) \n return None",
... | [
"0.64824027",
"0.6470281",
"0.63342357",
"0.632274",
"0.632274",
"0.632274",
"0.632274",
"0.632274",
"0.62671024",
"0.6255693",
"0.6255693",
"0.6152836",
"0.6148171",
"0.61125165",
"0.61011827",
"0.6100128",
"0.6099897",
"0.6076007",
"0.60639673",
"0.60597944",
"0.6055383",
... | 0.75238234 | 0 |
Shift demand with help of load factor. All demand above the maximum load is shifted proportionally to all hours having below average demand (see Section XY). Arguments | def peak_shaving_max_min(
loadfactor_yd_cy_improved,
average_yd,
fuel_yh,
mode_constrained
):
# ------------------------------------------
# Calculate new maximum demand for every day
# and fueltype with help of newly adaped load factor
# -----------------------------... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def demand(self, demand):\n\n self._demand = demand",
"def calculate_demand(self):\r\n \r\n for cell in self.cells:\r\n cell.demand = min(cell.volume, self.max_volume) /self.interval\r\n self.demand = self.cells[-1].demand",
"def load_shifting(\n fuel_yh,\n ... | [
"0.5589906",
"0.535102",
"0.52928716",
"0.51611745",
"0.5129113",
"0.5099356",
"0.49711052",
"0.4970545",
"0.49385718",
"0.49201313",
"0.488957",
"0.48629197",
"0.48009354",
"0.47831377",
"0.47760922",
"0.47626808",
"0.47109523",
"0.47007328",
"0.46605188",
"0.46561545",
"0.4... | 0.46686667 | 18 |
Shuffle the given dataset and split it into a training set and a test set | def create_train_test_sets(self,x,y,lenTest):
nbInd = x.shape[0]
shuffler = np.random.permutation(nbInd)
x_train = x[shuffler][0:(nbInd-lenTest),]
y_train = y[shuffler][0:(nbInd-lenTest),]
x_test = x[shuffler][(nbInd-lenTest):nbInd,]
y_test = y[shuffler][(nbInd-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_data(dataset, test_size=0.5):\n shuffled_data = np.random.RandomState(seed=721).permutation(dataset)\n train_set = shuffled_data[: int(len(dataset) * (1 - test_size)), :]\n test_set = shuffled_data[int(len(dataset) * (1 - test_size)):, :]\n return train_set, test_set",
"def train_test_split... | [
"0.8595426",
"0.8134506",
"0.80697596",
"0.7951852",
"0.7934613",
"0.7761503",
"0.7725137",
"0.77123195",
"0.76206905",
"0.7597599",
"0.7575826",
"0.755232",
"0.7507371",
"0.74951476",
"0.74870634",
"0.74870634",
"0.74833435",
"0.7441801",
"0.74408114",
"0.74378437",
"0.73700... | 0.68687177 | 96 |
Testing if padding works correctly for common scenarios of 2D data (batch_size x sequences). Specifically testing whether it produces proper padded sequences, and their masks. Also, testing if when symbol_to_mask is provided if it correctly masks those symbols. | def test_2D_padding(self):
field_names = ["text"]
mask_field_names = ['text_mask']
data_path = "mldp/tests/data/news.csv"
pad_symbol = "<PAD>"
mask_field_name_suffix = "mask"
padding_modes = ['left', 'right', 'both']
symbols_to_mask = ["The", "a", "to", "as"]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_3D_padding(self):\n field_name = \"dummy\"\n mask_field_name = 'dummy_mask'\n pad_symbol = -99\n mask_fn_suffix = \"mask\"\n padding_mode = \"both\"\n axis = 2\n\n data_chunk = DataChunk(**{field_name: np.array([\n [[0, 1, 2], [3, 4, 5], [], [6]]... | [
"0.66571194",
"0.6441682",
"0.632566",
"0.6228574",
"0.6153739",
"0.61087537",
"0.6105533",
"0.60827976",
"0.6003496",
"0.5982256",
"0.5972349",
"0.5965401",
"0.59637886",
"0.59558815",
"0.5952085",
"0.591786",
"0.5871366",
"0.5843445",
"0.5820535",
"0.5779922",
"0.5775166",
... | 0.75791377 | 0 |
Light version test to check if the padder works for 3D data. | def test_3D_padding(self):
field_name = "dummy"
mask_field_name = 'dummy_mask'
pad_symbol = -99
mask_fn_suffix = "mask"
padding_mode = "both"
axis = 2
data_chunk = DataChunk(**{field_name: np.array([
[[0, 1, 2], [3, 4, 5], [], [6]],
[[1], ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_Pad3D3():\n input_shape = (1, 1, 2, 3, 2)\n pad = [1, 0, 1, 2, 1, 0]\n mode = \"constant\"\n res = [\n [\n [\n [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]],\n [[0, 0, 0], [0, 1, 2], [0, 3, 4], [0, 5, 6], [0, 0, 0], [0, 0, 0]... | [
"0.6824534",
"0.66838425",
"0.6630269",
"0.66077274",
"0.65853065",
"0.6516807",
"0.65082043",
"0.65043795",
"0.64946616",
"0.648253",
"0.6417899",
"0.63924766",
"0.6375224",
"0.6359866",
"0.6327758",
"0.6305439",
"0.62622947",
"0.6182932",
"0.617922",
"0.61383235",
"0.611106... | 0.6957212 | 0 |
When this resource itself is rendered, redirect to the default shared item. | def renderHTTP(self, ctx):
return url.URL.fromContext(ctx).child('') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home_page():\n return redirect(url_for(_DEFAULT_ROUTE, _external=True))",
"def root_redirect():\r\n return redirect(url_for(\"display_top\"))",
"def get(self, request, **kwargs):\n self.object = self.get_object()\n if self.request.path != self.object.get_absolute_url():\n ret... | [
"0.59624314",
"0.58645654",
"0.5837715",
"0.5692611",
"0.5636384",
"0.55870676",
"0.55821115",
"0.55416816",
"0.5481628",
"0.545407",
"0.54492134",
"0.54492134",
"0.5442079",
"0.5420158",
"0.5420158",
"0.5420158",
"0.5409866",
"0.54068685",
"0.5396666",
"0.5393483",
"0.538152... | 0.0 | -1 |
Initializes this loss scale optimizer. | def __init__(self, optimizer, loss_scale):
if not isinstance(optimizer, optimizer_v2.OptimizerV2):
raise ValueError('"optimizer" must be an instance of OptimizerV2, but '
'got: %s' % optimizer)
if optimizer.clipnorm is not None:
raise ValueError('LossScaleOptimizer does not su... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_loss_and_optimizer(self):\n self.criterion = CrossEntropyLoss()\n self.optimizer = Adam(self.model.parameters(), lr=self.hyper_parameters['lr'])",
"def __init__(self, **kwargs):\n\n super().__init__(**kwargs)\n self.criterion = self._initLoss()",
"def __init__(self, **kwarg... | [
"0.7157795",
"0.6916654",
"0.6916654",
"0.68659997",
"0.6758468",
"0.67563814",
"0.6621184",
"0.66053504",
"0.660172",
"0.6601449",
"0.6474571",
"0.6467551",
"0.64525384",
"0.6447518",
"0.64248365",
"0.641149",
"0.63619477",
"0.6337405",
"0.6334744",
"0.632274",
"0.63118184",... | 0.71536416 | 1 |
Multiply a (possibly sparse) gradient by the given scale factor. | def _multiply_gradient(gradient, scale):
scale = math_ops.cast(scale, gradient.dtype)
if isinstance(gradient, ops.IndexedSlices):
return ops.IndexedSlices(
gradient.values * scale,
gradient.indices,
dense_shape=gradient.dense_shape)
else:
return gradient * scale | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grad_scale(x, multiplier):\n return GradScale(multiplier)(x)",
"def scaling(mat, factor):\n\treturn mat / (mat + factor)",
"def scale(self, scale_factor: float) -> None:\n self.tensor[:, :3] *= scale_factor",
"def scale(self, factor):\n self.b = factor * self.b",
"def supervised_cost_s... | [
"0.6945256",
"0.6364424",
"0.6349341",
"0.63197815",
"0.62594366",
"0.6207935",
"0.6151295",
"0.60449195",
"0.602039",
"0.5922737",
"0.5878117",
"0.5822671",
"0.580783",
"0.5759809",
"0.5734907",
"0.5721659",
"0.57112604",
"0.5709619",
"0.5707256",
"0.56965876",
"0.56932414",... | 0.80634993 | 0 |
Return write file name reflecting the current file number | def current_filename(self):
if self.char_limit is not None:
return '{}/{}.{}.n{}.maf'.format(self.out_dir, self.chrom,
self.taxon, self.file_num)
else:
return '{}/{}.{}.maf'.format(self.out_dir, self.chrom, self.taxon) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_file_name(self):\n self._session_iterator = None # New file invalidate old interator\n self._img_count += 1\n self._current_file = '{0}/frame_{1}.jpg'.format(self._relative_path,self._img_count)\n return self.current_file",
"def get_file_name(self):\n return str(s... | [
"0.695474",
"0.67840314",
"0.6740607",
"0.66484565",
"0.6624556",
"0.66118366",
"0.6506273",
"0.65023524",
"0.6497927",
"0.6490236",
"0.64883685",
"0.6452973",
"0.6441209",
"0.64156073",
"0.63949245",
"0.638736",
"0.6329144",
"0.63142765",
"0.63101363",
"0.63057315",
"0.63024... | 0.6732508 | 3 |
Show our index page. | def testing():
return render_template("testing.html") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_index_page():\n\n return render_template('index.html')",
"def index():\n return render_template(\"index.html\",\n title='Index')",
"def index():\n return render_template('index.html')",
"def index():\n return render_template('index.html')",
"def index(... | [
"0.8649516",
"0.8400286",
"0.8323099",
"0.8323099",
"0.8311098",
"0.8298778",
"0.8295712",
"0.82686216",
"0.8243951",
"0.82074285",
"0.81817985",
"0.810957",
"0.810957",
"0.8098042",
"0.8087482",
"0.80548614",
"0.8052861",
"0.80047053",
"0.79835534",
"0.7960083",
"0.7960083",... | 0.0 | -1 |
Computes the probability of finding an active transcription factor at a given range of ligand concentrations. | def p_act(c_range, k_a, k_i, ep_ai=5, n_sites=int(2)):
if type(n_sites) is not int:
raise TypeError('n_sites must be an integer.')
numer = (1 + c_range / k_a)**n_sites
denom = numer + np.exp(-ep_ai) * (1 + c_range / k_i)**n_sites
return numer / denom | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_probability_for(fixation):\n probabilities = np.zeros(Number_of_locs) #MOD Number_of_locs deleted\n for possible_target_location in xrange(Number_of_locs): #MOD Number_of_locs deleted\n probabilities[possible_target_location] = integrate.quad(\n integral_function,\n ... | [
"0.578839",
"0.5781874",
"0.5769571",
"0.5661054",
"0.56165594",
"0.55934966",
"0.55533504",
"0.5542344",
"0.55398613",
"0.55281544",
"0.5497608",
"0.54954404",
"0.54951864",
"0.54611725",
"0.5446603",
"0.5415126",
"0.5392379",
"0.5385614",
"0.53782094",
"0.53614104",
"0.5341... | 0.58372784 | 0 |
Gets the image tensor from the path | def get_image_tensor(img_path):
img_tensor = path_to_tensor(img_path) / 255.0
return img_tensor | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_image_as_tensor(path: Path) -> tf.Tensor:\n img_data = tf.io.read_file(str(path))\n img_tensor = tf.io.decode_jpeg(img_data, channels=3)\n\n return img_tensor",
"def path_to_tensor(img_path, dim):\n\n # Load RGB image\n img = image.load_img(img_path, target_size=(dim,dim))\n # Convert ... | [
"0.7548212",
"0.74834365",
"0.73381865",
"0.7061357",
"0.7038939",
"0.701489",
"0.69295824",
"0.67972696",
"0.67446417",
"0.67446417",
"0.66678107",
"0.6606885",
"0.65754026",
"0.6573447",
"0.65305334",
"0.643628",
"0.64324105",
"0.64258087",
"0.6414476",
"0.6360211",
"0.6355... | 0.8271076 | 0 |
Translates the center point, and keeps it in bounds. | def translate_center(self, dx, dy, dz):
center = self.center
center[0] -= dx
center[1] -= dy
center[2] -= dz
center[0] = min(max(center[0], self.bounds[0]), self.bounds[1])
center[1] = min(max(center[1], self.bounds[0]), self.bounds[1])
center[2] = min(max(center[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def center(self):\n if self.pos != 0.0:\n self.pos = 0.0",
"def translate(self, displacement):\n\n self.center = (self.center[0] + displacement[0],\n self.center[1] + displacement[1])",
"def update_center(self): \r\n \r\n self.grfx[0].center = self.center\r\n\r\n ... | [
"0.71007794",
"0.7073161",
"0.70145607",
"0.6979378",
"0.6753653",
"0.6747097",
"0.66957575",
"0.6648545",
"0.66472554",
"0.6637636",
"0.660891",
"0.6562517",
"0.64696074",
"0.6463932",
"0.6463932",
"0.6411822",
"0.6394372",
"0.6394372",
"0.6394372",
"0.63817835",
"0.6370019"... | 0.76299447 | 0 |
Return the free execution time for a migratory task in this partition | def _calcExecTime(self, migTask, dPrime):
#print "ae", self
# Let's start making U = 0.9999 (which probably causes deadline misses).
# If we force U = 1, we won't be able to use La.
if self.util() >= 0.9999:
self._lastCost = 0.0
return 0.0
cPrime = (0.9999... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def estimated_time(self):\n self._update()\n if not self.running_mode:\n return 0 if self._is_finished() else float(\"nan\")\n elif self.running_mode == \"local\":\n start = self.processes[0].create_time()\n elif self.running_mode == \"grid\":\n start = ... | [
"0.6263205",
"0.60351074",
"0.59931386",
"0.5978507",
"0.5912567",
"0.5891301",
"0.58882743",
"0.5881097",
"0.5842023",
"0.5826707",
"0.5752384",
"0.5737175",
"0.57205445",
"0.5720036",
"0.5698623",
"0.5698623",
"0.5694059",
"0.5669578",
"0.5656949",
"0.5654609",
"0.56376934"... | 0.6479419 | 0 |
Return time as a string | def timestr():
return dt.strftime(dt.now(),'%H:%M:%S') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_time() -> str:\n return strftime(\"%H:%M:%S\")",
"def get_time() -> str:\r\n return time.strftime(TIMEFORMAT)",
"def _time_str(self):\n try:\n if not self._time:\n raise ValueError\n format_ = '%a, %d %b %Y %H:%M:%S'\n return datetime.fromtim... | [
"0.8559975",
"0.8342602",
"0.8303421",
"0.8176281",
"0.80305576",
"0.7968672",
"0.79652303",
"0.79423606",
"0.79199684",
"0.79052913",
"0.7892776",
"0.7873904",
"0.7864454",
"0.785743",
"0.7819786",
"0.7692401",
"0.76851183",
"0.76786953",
"0.7673926",
"0.760527",
"0.7554719"... | 0.83846116 | 1 |
Create or replace file indicated by filename, as a yaml serialization of dict d. | def save_file(filename,d):
f = open(filename, 'w')
yaml.dump(d, f)
f.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_file(filename,d):\n if os.path.exists(filename):\n f_old = open(filename,'r')\n d_old = yaml.load(f_old)\n f_old.close()\n d_old.update(d)\n d = d_old\n f = open(filename, 'w')\n yaml.dump(d, f)\n f.close()",
"def save(self, filename):\n with open(... | [
"0.79054904",
"0.7014788",
"0.6703491",
"0.66639715",
"0.6618562",
"0.65786463",
"0.6543921",
"0.6513153",
"0.64326257",
"0.6422186",
"0.64148986",
"0.63806546",
"0.636776",
"0.62917686",
"0.6282388",
"0.62787414",
"0.62067103",
"0.61989194",
"0.61850554",
"0.6184453",
"0.618... | 0.7766528 | 1 |
Generator yielding the flight index, assigned bay and flight object of departing flights. | def departing_flights(self):
for i in range(self.flights.n_flights):
if self.flights.departing(i):
yield i, self.bay[i], self.flights.flight_schedule[i] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_return_flights(self):\n flights = []\n for date in self.return_dates:\n for src in self.src_airports:\n for dst in self.dst_airports:\n flights.append( Flight(dst, src, date) )\n\n return flights",
"def __iter__(self):\n\n return i... | [
"0.6066153",
"0.60416305",
"0.5919573",
"0.5495734",
"0.5476187",
"0.54701424",
"0.53442407",
"0.5342146",
"0.5320868",
"0.53155226",
"0.5294439",
"0.5286481",
"0.528069",
"0.5221552",
"0.51874614",
"0.5186745",
"0.5112128",
"0.5110774",
"0.5096295",
"0.50627136",
"0.50627136... | 0.79937047 | 0 |
Gets the gbr_ul of this RequestedQos. | def gbr_ul(self):
return self._gbr_ul | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gbr_dl(self):\n return self._gbr_dl",
"def getBL(self):\r\n return self.bL;",
"def gbr_ul(self, gbr_ul):\n\n self._gbr_ul = gbr_ul",
"def get_bribe(self):\r\n return self.bribe",
"def _get_qos(self):\n return self.__qos",
"def _get_qos(self):\n return self.__qos",
... | [
"0.6624793",
"0.6183227",
"0.5677202",
"0.56101704",
"0.55133814",
"0.55133814",
"0.55133814",
"0.5454623",
"0.5451101",
"0.5410858",
"0.54033214",
"0.54033214",
"0.54033214",
"0.54033214",
"0.54033214",
"0.54033214",
"0.54033214",
"0.54033214",
"0.54033214",
"0.54033214",
"0... | 0.7476282 | 0 |
Gets the gbr_dl of this RequestedQos. | def gbr_dl(self):
return self._gbr_dl | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gbr_ul(self):\n return self._gbr_ul",
"def getBL(self):\r\n return self.bL;",
"def snmpqosqos_packets_droppedrate(self) :\n\t\ttry :\n\t\t\treturn self._snmpqosqos_packets_droppedrate\n\t\texcept Exception as e:\n\t\t\traise e",
"def _get_ldp_sync_hold_down(self):\n return self.__ldp_syn... | [
"0.6006991",
"0.5707925",
"0.5370055",
"0.53580135",
"0.5345465",
"0.5287211",
"0.52737546",
"0.5232863",
"0.52164197",
"0.52164197",
"0.52164197",
"0.51493675",
"0.51317436",
"0.51186025",
"0.51073915",
"0.5064704",
"0.505674",
"0.50535154",
"0.5048442",
"0.50189704",
"0.501... | 0.7665163 | 0 |
Adds a Binding to this Frame. | def add_binding(self, variable, value):
# If there's already a binding, update it rather than add a new one.
for binding in self.bindings:
if binding.variable.name == variable:
return self.update_binding(variable, value)
variable = Variable(self.canvas, self, variable... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addBindingToFrame(var, val, frame):\n set_car(frame, cons(var, frame_variables(frame)))\n set_cdr(frame, cons(val, frame_values(frame)))\n return",
"def bind(self, sequence=None, func=None, add=None):\n return self._widget_bind(sequence, func, add, internal=False)",
"def add_binding(ctx, bi... | [
"0.66476285",
"0.61366373",
"0.6026425",
"0.60156393",
"0.59045696",
"0.58596855",
"0.57560503",
"0.5732177",
"0.5641009",
"0.54628783",
"0.5456201",
"0.5436792",
"0.54301035",
"0.53278595",
"0.532564",
"0.5314",
"0.52351445",
"0.5233988",
"0.52169967",
"0.51750636",
"0.51471... | 0.73459095 | 0 |
Total mass of the compound tail. | def weight(self):
return self.stabilizer_h.weight + self.stabilizer_vright.weight + self.stabilizer_vleft.weight | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_mass(self):\n return self._total_mass",
"def total_mass(self):\n return self._total_mass",
"def total_mass_au(self):\n return np.sum(self.atomic_mass)",
"def get_total_mass(self) -> int:\n total_mass = 0\n for i_complex, i_abundance in self._complexes.items():\n ... | [
"0.78116035",
"0.78116035",
"0.74165624",
"0.73085344",
"0.7300267",
"0.72972685",
"0.7153672",
"0.7138629",
"0.70916116",
"0.70916116",
"0.6897456",
"0.68918955",
"0.68834573",
"0.68834573",
"0.6853273",
"0.68314683",
"0.6778429",
"0.67212886",
"0.6720359",
"0.6712391",
"0.6... | 0.0 | -1 |
Find a cycle in a graph. s is a solver object, graph is an igraph object. Given the graph iterate over the graph, convert the key and values to symbolic terms and check for a cycle. Returns the unsat core as a list of strings e.g. [1>2, 2>3, 3>4, 4>1] I'm leaving this here just to try to get the abstract hamiltonian cy... | def find_all_cycles(s,graph):
grph = u.edge_to_list_dict(graph)
node_cnt = len(grph)
k = z.Int("k")
syms = [z.Int('node%s'%i) for i in range(node_cnt)]
# s.add(syms[0] == 0) # start node is a 0
s.add(k < node_cnt)
s.add(k > 1)
o = z.Optimize()
# for source, sinks i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_eulerian_cycle(adj_dict, edges):\n if not adj_dict:\n return []\n\n checked = [False] * len(edges)\n list_keys = list(adj_dict.keys())\n for i in list_keys: # the first time will return true anyway\n cycle = []\n if dfs(i, adj_dict, edges, checked, cycle, i):\n ... | [
"0.6317372",
"0.611582",
"0.5957695",
"0.5797448",
"0.57344425",
"0.5620256",
"0.56129",
"0.5610811",
"0.5604997",
"0.5584068",
"0.5572033",
"0.5533192",
"0.5509296",
"0.550141",
"0.5495953",
"0.5464865",
"0.5461448",
"0.54586077",
"0.5360699",
"0.5358017",
"0.5301723",
"0.... | 0.7576485 | 0 |
Combine script files basted on the path of the request. For a request for ``/gist.github.com.js``, tries to load ``gist.github.com.js`` as well as ``github.com.js`` and ``com.js``, in addition to the global ``default.js``. Returns the combined contents of the scripts found. | def build_body(self) -> str:
# Always include default.js
files = [os.path.join(self.directory, "default.js")]
# Find increasingly less specific files based on the request path.
paths = self.path.replace("/", "").split(".")
while paths:
files.append(os.path.join(self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_script(self,\n script_path,\n domain=\"raw.githubusercontent.com\",\n urlpath=_GITHUB_URLPATH):\n info = self.script_path(script_path)\n _fetch_script(info, script_path, domain, urlpath)\n return info",
"def get_source_fil... | [
"0.54122865",
"0.53973025",
"0.5321434",
"0.53174424",
"0.5260792",
"0.5172825",
"0.5163565",
"0.5132076",
"0.5092393",
"0.50862974",
"0.5047552",
"0.50348",
"0.4977795",
"0.49442473",
"0.49381855",
"0.4916476",
"0.49147418",
"0.489088",
"0.4888798",
"0.4885273",
"0.48759082"... | 0.5625085 | 0 |
Return angles, axis pair that corresponds to rotation matrix m. The case where ``m`` is the identity matrix corresponds to a singularity where any rotation axis is valid. In that case, ``Vector([1, 0, 0])``, is returned. | def m2rotaxis(m):
eps = 1e-5
# Check for singularities a la http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/
if (
abs(m[0, 1] - m[1, 0]) < eps
and abs(m[0, 2] - m[2, 0]) < eps
and abs(m[1, 2] - m[2, 1]) < eps
):
# Singularity encountered.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rotate_(self, x: np.array, m: np.array) -> (np.array, np.array):\n # get a random angle\n angle = np.random.randint(0, self.rotate)\n # get a random sign for the angle\n sign = np.random.randint(0, 2)\n x = rotate(x, -sign * angle, reshape=False)\n m = rotate(m, -sign... | [
"0.663678",
"0.62896967",
"0.6157976",
"0.6006294",
"0.59815663",
"0.5924986",
"0.5909249",
"0.58380806",
"0.58301306",
"0.5824258",
"0.57651687",
"0.57651037",
"0.5755777",
"0.57331914",
"0.57147455",
"0.5714623",
"0.5711759",
"0.57107013",
"0.5710682",
"0.5695341",
"0.5695"... | 0.8007706 | 0 |
Return a (left multiplying) matrix that rotates p onto q. | def rotmat(p, q):
rot = numpy.dot(refmat(q, -p), refmat(p, -p))
return rot | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quat_rotate(X, q):\n # repeat q along 2nd dim\n ones_x = X[[0], :, :][:, :, [0]] * 0 + 1\n q = torch.unsqueeze(q, 1) * ones_x\n\n q_conj = torch.cat([q[:, :, [0]], -1 * q[:, :, 1:4]], dim=-1)\n X = torch.cat([X[:, :, [0]] * 0, X], dim=-1)\n\n X_rot = hamilton_product(q, hamilton_product(X, q_... | [
"0.7235314",
"0.7235314",
"0.6990883",
"0.69877553",
"0.69679874",
"0.6881361",
"0.6804596",
"0.6750322",
"0.6703256",
"0.6547457",
"0.6546621",
"0.6531093",
"0.6472698",
"0.63746524",
"0.6359099",
"0.6341709",
"0.63394356",
"0.6274029",
"0.624419",
"0.6177997",
"0.61512566",... | 0.8370842 | 0 |
Return vector 3D coordinates. | def __repr__(self):
x, y, z = self._ar
return "<Vector %.2f, %.2f, %.2f>" % (x, y, z) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vector3(x, y, z):\n return np.array([x, y, z], dtype=np.float)",
"def vector3(x, y, z):\n return np.array([x, y, z], dtype=float)",
"def three_dimensional(self, z): # Maybe I misunderstood the task. My method looks weird\n return (self.x, self.y, z)",
"def xyz(self) -> np.ndarray:\n r... | [
"0.7777274",
"0.77766913",
"0.7510238",
"0.7503369",
"0.745999",
"0.74336594",
"0.7361752",
"0.7296652",
"0.72539973",
"0.716033",
"0.71575993",
"0.70996886",
"0.708405",
"0.70800275",
"0.70012933",
"0.6915805",
"0.6915805",
"0.68983006",
"0.68291783",
"0.677742",
"0.6770605"... | 0.0 | -1 |
Return Vector.Vector (dot product). | def __mul__(self, other):
return sum(self._ar * other._ar) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vec_dot(v1,v2):\r\n \r\n return np.dot(v1,v2)",
"def vector_dot(v1,v2):\n return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z)",
"def dot(self, vec):\n if not isinstance(vec, self.__class__):\n raise TypeError('Dot product operand must be a vector')\n return np.dot(self, v... | [
"0.82532036",
"0.8240061",
"0.789683",
"0.7809362",
"0.7715081",
"0.7686175",
"0.7667458",
"0.7638591",
"0.7632838",
"0.7622248",
"0.75743777",
"0.7567853",
"0.7564591",
"0.75262725",
"0.7522437",
"0.7518532",
"0.751494",
"0.7451295",
"0.7447172",
"0.74326205",
"0.7432134",
... | 0.0 | -1 |
Return value of array index i. | def __getitem__(self, i):
return self._ar[i] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getitem__(self, i):\n\t\tif i < self.n:\n\t\t\treturn self.v[i]",
"def __getitem__(self, i):\n return self.get(i, i + 1)",
"def __getitem__(self, i):\n return self.data[i]",
"def __getitem__(self, i):\n return self.__x[i]",
"def xval(self, i):\n return self.x[i]",
"def _... | [
"0.7630643",
"0.7395586",
"0.73718834",
"0.7324915",
"0.727493",
"0.7198595",
"0.71864104",
"0.6988594",
"0.6973699",
"0.69633764",
"0.6930768",
"0.6863983",
"0.6862375",
"0.68333304",
"0.67888004",
"0.67888004",
"0.6754036",
"0.67357033",
"0.6730818",
"0.6709809",
"0.6709809... | 0.7823676 | 0 |
Normalize the Vector object. Changes the state of ``self`` and doesn't return a value. If you need to chain function calls or create a new object use the ``normalized`` method. | def normalize(self):
if self.norm():
self._ar = self._ar / self.norm() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize(self):\n\t\tnorm = self.norm()\n\t\tif norm == 0:\n\t\t\traise ValueError(\"Can't normalize zero vector\")\n\t\treturn self / norm",
"def normalize(self): # Function is fucked TODO\n l = self.length()\n for i in range(0, len(self.coords)):\n self.coords[i] /= l\n re... | [
"0.8464527",
"0.82733166",
"0.8261069",
"0.8040781",
"0.7954581",
"0.7890101",
"0.7851316",
"0.7839219",
"0.7804802",
"0.779757",
"0.7701071",
"0.7647099",
"0.76387185",
"0.75412595",
"0.7426399",
"0.7424648",
"0.7402389",
"0.7369007",
"0.73416305",
"0.7305429",
"0.73021066",... | 0.68350106 | 35 |
Return a normalized copy of the Vector. To avoid allocating new objects use the ``normalize`` method. | def normalized(self):
v = self.copy()
v.normalize()
return v | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalized(self):\n len = self.length\n return Vector(self.x / len, self.y / len)",
"def normalize(self):\n\t\tnorm = self.norm()\n\t\tif norm == 0:\n\t\t\traise ValueError(\"Can't normalize zero vector\")\n\t\treturn self / norm",
"def normalize(self): # Function is fucked TODO\n l =... | [
"0.833693",
"0.82636696",
"0.8204577",
"0.820379",
"0.8159068",
"0.81145406",
"0.7987801",
"0.79800314",
"0.79383814",
"0.7758294",
"0.77219254",
"0.7705531",
"0.76207787",
"0.75954235",
"0.75868297",
"0.75632155",
"0.7512669",
"0.75026625",
"0.7420862",
"0.73888093",
"0.7337... | 0.81192946 | 5 |
Update existing X rotation matrix to new angle. | def set_X_homog_rot_mtx(angle_rads: float, mtx: numpy.ndarray):
cosang = numpy.cos(angle_rads)
sinang = numpy.sin(angle_rads)
mtx[1][1] = mtx[2][2] = cosang
mtx[2][1] = sinang
mtx[1][2] = -sinang | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rotate(self, angle):\n angle *= self._degreesPerAU\n self._orient = self._orient.rotate(angle)",
"def rotate(self, angle=0.0):\n # TODO: Implement the rotate function. Remember to record the value of\n # rotation degree.\n self.rotDegree = angle\n self.x = rotate(se... | [
"0.68538",
"0.6824456",
"0.67855126",
"0.6772674",
"0.6697259",
"0.66709644",
"0.6662576",
"0.663144",
"0.66183186",
"0.66129375",
"0.6589346",
"0.6568182",
"0.6562166",
"0.6559313",
"0.6422722",
"0.640486",
"0.6396426",
"0.63858956",
"0.6380407",
"0.63724697",
"0.63665795",
... | 0.59683895 | 48 |
Assert that events can be retrieved and decoded from the Queue. | async def test_account_mailer_queue(app, session, stan_server, event_loop, client_id, events_stan, future):
# Call back for the subscription
from account_mailer.worker import cb_subscription_handler
# vars
org_id = '1'
events_subject = 'test_subject'
events_queue = 'test_queue'
events_dura... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_queue_simple(self):\n events = self.run_and_get_events('fixtures/queue/queue_simple.json')\n\n expected_events = self.events_from_tuples((\n ('on_b_dial', {\n 'call_id': 'e83df36bebbe-1507019160.61',\n 'caller': CallerId(code=15001, number='+311500100... | [
"0.66706574",
"0.6602465",
"0.65494907",
"0.64545363",
"0.64254266",
"0.63869125",
"0.6384696",
"0.6306324",
"0.62395716",
"0.61526036",
"0.6133326",
"0.6132558",
"0.60419923",
"0.6025255",
"0.602304",
"0.6010839",
"0.60008454",
"0.5985004",
"0.5969868",
"0.5965943",
"0.59467... | 0.0 | -1 |
Assert that events can be retrieved and decoded from the Queue. | async def test_lock_account_mailer_queue(app, session, stan_server, event_loop, client_id, events_stan, future):
# Call back for the subscription
from account_mailer.worker import cb_subscription_handler
# vars
user = factory_user_model_with_contact()
org = factory_org_model()
factory_membershi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_queue_simple(self):\n events = self.run_and_get_events('fixtures/queue/queue_simple.json')\n\n expected_events = self.events_from_tuples((\n ('on_b_dial', {\n 'call_id': 'e83df36bebbe-1507019160.61',\n 'caller': CallerId(code=15001, number='+311500100... | [
"0.66706574",
"0.6602465",
"0.65494907",
"0.64545363",
"0.64254266",
"0.63869125",
"0.6384696",
"0.6306324",
"0.62395716",
"0.61526036",
"0.6133326",
"0.6132558",
"0.60419923",
"0.6025255",
"0.602304",
"0.6010839",
"0.60008454",
"0.5985004",
"0.5969868",
"0.5965943",
"0.59467... | 0.0 | -1 |
Assert that events can be retrieved and decoded from the Queue. | async def test_unlock_account_mailer_queue(app, session, stan_server, event_loop, client_id, events_stan, future):
# Call back for the subscription
from account_mailer.worker import cb_subscription_handler
# vars
user = factory_user_model_with_contact()
org = factory_org_model()
factory_members... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_queue_simple(self):\n events = self.run_and_get_events('fixtures/queue/queue_simple.json')\n\n expected_events = self.events_from_tuples((\n ('on_b_dial', {\n 'call_id': 'e83df36bebbe-1507019160.61',\n 'caller': CallerId(code=15001, number='+311500100... | [
"0.66706574",
"0.6602465",
"0.65494907",
"0.64545363",
"0.64254266",
"0.63869125",
"0.6384696",
"0.6306324",
"0.62395716",
"0.61526036",
"0.6133326",
"0.6132558",
"0.60419923",
"0.6025255",
"0.602304",
"0.6010839",
"0.60008454",
"0.5985004",
"0.5969868",
"0.5965943",
"0.59467... | 0.0 | -1 |
Assert that events can be retrieved and decoded from the Queue. | async def test_account_conf_mailer_queue(app, session, stan_server, event_loop, client_id, events_stan, future):
# Call back for the subscription
from account_mailer.worker import cb_subscription_handler
# vars
user = factory_user_model_with_contact()
org = factory_org_model()
factory_membershi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_queue_simple(self):\n events = self.run_and_get_events('fixtures/queue/queue_simple.json')\n\n expected_events = self.events_from_tuples((\n ('on_b_dial', {\n 'call_id': 'e83df36bebbe-1507019160.61',\n 'caller': CallerId(code=15001, number='+311500100... | [
"0.66706574",
"0.6602465",
"0.65494907",
"0.64545363",
"0.64254266",
"0.63869125",
"0.6384696",
"0.6306324",
"0.62395716",
"0.61526036",
"0.6133326",
"0.6132558",
"0.60419923",
"0.6025255",
"0.602304",
"0.6010839",
"0.60008454",
"0.5985004",
"0.5969868",
"0.5965943",
"0.59467... | 0.0 | -1 |
Assert that events can be retrieved and decoded from the Queue. | async def test_account_pad_invoice_mailer_queue(app, session, stan_server, event_loop, client_id, events_stan, future):
# Call back for the subscription
from account_mailer.worker import cb_subscription_handler
# vars
user = factory_user_model_with_contact()
org = factory_org_model()
factory_me... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_queue_simple(self):\n events = self.run_and_get_events('fixtures/queue/queue_simple.json')\n\n expected_events = self.events_from_tuples((\n ('on_b_dial', {\n 'call_id': 'e83df36bebbe-1507019160.61',\n 'caller': CallerId(code=15001, number='+311500100... | [
"0.66706574",
"0.6602465",
"0.65494907",
"0.64545363",
"0.64254266",
"0.63869125",
"0.6384696",
"0.6306324",
"0.62395716",
"0.61526036",
"0.6133326",
"0.6132558",
"0.60419923",
"0.6025255",
"0.602304",
"0.6010839",
"0.60008454",
"0.5985004",
"0.5969868",
"0.5965943",
"0.59467... | 0.0 | -1 |
Assert that events can be retrieved and decoded from the Queue. | async def test_account_admin_removed(app, session, stan_server, event_loop, client_id, events_stan, future):
# Call back for the subscription
from account_mailer.worker import cb_subscription_handler
# vars
user = factory_user_model_with_contact()
org = factory_org_model()
factory_membership_mo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_queue_simple(self):\n events = self.run_and_get_events('fixtures/queue/queue_simple.json')\n\n expected_events = self.events_from_tuples((\n ('on_b_dial', {\n 'call_id': 'e83df36bebbe-1507019160.61',\n 'caller': CallerId(code=15001, number='+311500100... | [
"0.66706574",
"0.6602465",
"0.65494907",
"0.64545363",
"0.64254266",
"0.63869125",
"0.6384696",
"0.6306324",
"0.62395716",
"0.61526036",
"0.6133326",
"0.6132558",
"0.60419923",
"0.6025255",
"0.602304",
"0.6010839",
"0.60008454",
"0.5985004",
"0.5969868",
"0.5965943",
"0.59467... | 0.0 | -1 |
Assert that events can be retrieved and decoded from the Queue. | async def test_account_team_modified(app, session, stan_server, event_loop, client_id, events_stan, future):
# Call back for the subscription
from account_mailer.worker import cb_subscription_handler
# vars
user = factory_user_model_with_contact()
org = factory_org_model()
factory_membership_mo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_queue_simple(self):\n events = self.run_and_get_events('fixtures/queue/queue_simple.json')\n\n expected_events = self.events_from_tuples((\n ('on_b_dial', {\n 'call_id': 'e83df36bebbe-1507019160.61',\n 'caller': CallerId(code=15001, number='+311500100... | [
"0.66706574",
"0.6602465",
"0.65494907",
"0.64545363",
"0.64254266",
"0.63869125",
"0.6384696",
"0.6306324",
"0.62395716",
"0.61526036",
"0.6133326",
"0.6132558",
"0.60419923",
"0.6025255",
"0.602304",
"0.6010839",
"0.60008454",
"0.5985004",
"0.5969868",
"0.5965943",
"0.59467... | 0.0 | -1 |
Assert that events can be retrieved and decoded from the Queue. | async def test_online_banking_emails(app, session, stan_server, event_loop, client_id, events_stan, future):
# Call back for the subscription
from account_mailer.worker import cb_subscription_handler
# vars
user = factory_user_model_with_contact()
org = factory_org_model()
factory_membership_mo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_queue_simple(self):\n events = self.run_and_get_events('fixtures/queue/queue_simple.json')\n\n expected_events = self.events_from_tuples((\n ('on_b_dial', {\n 'call_id': 'e83df36bebbe-1507019160.61',\n 'caller': CallerId(code=15001, number='+311500100... | [
"0.66706574",
"0.6602465",
"0.65494907",
"0.64545363",
"0.64254266",
"0.63869125",
"0.6384696",
"0.6306324",
"0.62395716",
"0.61526036",
"0.6133326",
"0.6132558",
"0.60419923",
"0.6025255",
"0.602304",
"0.6010839",
"0.60008454",
"0.5985004",
"0.5969868",
"0.5965943",
"0.59467... | 0.0 | -1 |
Assert that events can be retrieved and decoded from the Queue. | async def test_pad_failed_emails(app, session, stan_server, event_loop, client_id, events_stan, future):
# Call back for the subscription
from account_mailer.worker import cb_subscription_handler
# vars
user = factory_user_model_with_contact()
org = factory_org_model()
factory_membership_model(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_queue_simple(self):\n events = self.run_and_get_events('fixtures/queue/queue_simple.json')\n\n expected_events = self.events_from_tuples((\n ('on_b_dial', {\n 'call_id': 'e83df36bebbe-1507019160.61',\n 'caller': CallerId(code=15001, number='+311500100... | [
"0.66706574",
"0.6602465",
"0.65494907",
"0.64545363",
"0.64254266",
"0.63869125",
"0.6384696",
"0.6306324",
"0.62395716",
"0.61526036",
"0.6133326",
"0.6132558",
"0.60419923",
"0.6025255",
"0.602304",
"0.6010839",
"0.60008454",
"0.5985004",
"0.5969868",
"0.5965943",
"0.59467... | 0.0 | -1 |
Assert that events can be retrieved and decoded from the Queue. | async def test_payment_pending_emails(app, session, stan_server, event_loop, client_id, events_stan, future):
# Call back for the subscription
from account_mailer.worker import cb_subscription_handler
# vars
user = factory_user_model_with_contact()
org = factory_org_model()
factory_membership_m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_queue_simple(self):\n events = self.run_and_get_events('fixtures/queue/queue_simple.json')\n\n expected_events = self.events_from_tuples((\n ('on_b_dial', {\n 'call_id': 'e83df36bebbe-1507019160.61',\n 'caller': CallerId(code=15001, number='+311500100... | [
"0.66706574",
"0.6602465",
"0.65494907",
"0.64545363",
"0.64254266",
"0.63869125",
"0.6384696",
"0.6306324",
"0.62395716",
"0.61526036",
"0.6133326",
"0.6132558",
"0.60419923",
"0.6025255",
"0.602304",
"0.6010839",
"0.60008454",
"0.5985004",
"0.5969868",
"0.5965943",
"0.59467... | 0.0 | -1 |
Assert that events can be retrieved and decoded from the Queue. | async def test_ejv_failure_emails(app, session, stan_server, event_loop, client_id, events_stan, future):
# Call back for the subscription
from account_mailer.worker import cb_subscription_handler
events_subject = 'test_subject'
events_queue = 'test_queue'
events_durable_name = 'test_durable'
w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_queue_simple(self):\n events = self.run_and_get_events('fixtures/queue/queue_simple.json')\n\n expected_events = self.events_from_tuples((\n ('on_b_dial', {\n 'call_id': 'e83df36bebbe-1507019160.61',\n 'caller': CallerId(code=15001, number='+311500100... | [
"0.66706574",
"0.6602465",
"0.65494907",
"0.64545363",
"0.64254266",
"0.63869125",
"0.6384696",
"0.6306324",
"0.62395716",
"0.61526036",
"0.6133326",
"0.6132558",
"0.60419923",
"0.6025255",
"0.602304",
"0.6010839",
"0.60008454",
"0.5985004",
"0.5969868",
"0.5965943",
"0.59467... | 0.0 | -1 |
Assert that events can be retrieved and decoded from the Queue. | async def test_passcode_reset_email(app, session, stan_server, event_loop, client_id, events_stan, future):
# Call back for the subscription
from account_mailer.worker import cb_subscription_handler
events_subject = 'test_subject'
events_queue = 'test_queue'
events_durable_name = 'test_durable'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_queue_simple(self):\n events = self.run_and_get_events('fixtures/queue/queue_simple.json')\n\n expected_events = self.events_from_tuples((\n ('on_b_dial', {\n 'call_id': 'e83df36bebbe-1507019160.61',\n 'caller': CallerId(code=15001, number='+311500100... | [
"0.66706574",
"0.6602465",
"0.65494907",
"0.64545363",
"0.64254266",
"0.63869125",
"0.6384696",
"0.6306324",
"0.62395716",
"0.61526036",
"0.6133326",
"0.6132558",
"0.60419923",
"0.6025255",
"0.602304",
"0.6010839",
"0.60008454",
"0.5985004",
"0.5969868",
"0.5965943",
"0.59467... | 0.0 | -1 |
Tell if a process is running. The proc object is cached so it doesn't need to be looked up every time. | def is_process_running(name):
if not hasattr(is_process_running, "proc"):
is_process_running.proc = None # it doesn't exist yet, so init it
if is_process_running.proc:
if is_process_running.proc.is_running():
return True
else:
is_process_running.proc = None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_proc_running(name):\n\n for p in psutil.process_iter(['name']):\n if p.info['name'] == name:\n return True\n\n return False",
"def is_running(self):\r\n if self._gone:\r\n return False\r\n try:\r\n # Checking if pid is alive is not enough as the ... | [
"0.7895711",
"0.7814375",
"0.7768379",
"0.77449167",
"0.7729471",
"0.7717063",
"0.77083045",
"0.77081454",
"0.7664434",
"0.7623029",
"0.75754946",
"0.75263417",
"0.742384",
"0.7372659",
"0.7331689",
"0.72935724",
"0.7286316",
"0.72350216",
"0.7228423",
"0.7215268",
"0.7159771... | 0.8501636 | 0 |
Gets the associated Licence. | def Licence1(self) -> ElementTree.Element:
return self.m_Licence1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def get_license(self) -> APIReturn:\n return await self._request(\"GET\", \"/getLicense\")",
"def grabLicence(self):\n\t\t\treturn pulpCPLEX.grabLicence()",
"def get_licence(self, _return):\n return _return.licence.licence_number",
"def license(self): # noqa: A003\n logger.debug(\... | [
"0.72851545",
"0.72668165",
"0.7156478",
"0.71510565",
"0.7076799",
"0.66523343",
"0.6550223",
"0.65497965",
"0.64848375",
"0.6396124",
"0.63388246",
"0.62663984",
"0.6097757",
"0.59137106",
"0.5904991",
"0.58706224",
"0.58521897",
"0.57853025",
"0.5764598",
"0.57257617",
"0.... | 0.6494658 | 8 |
Resample audio files in ${task_dir}/48000/ to ${task_dir}/${target_sr}/ | def resample_hear_corpus(task_dir: str, target_sr: int = 16000, num_workers: int = 6):
task_dir: Path = Path(task_dir)
target_audio_dir: Path = task_dir / f"{target_sr}"
if target_audio_dir.is_dir():
logger.info(f"{target_audio_dir} already exist. Do not need to resample")
return
defau... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def audio_resample(self, data):\n\n data = np.asarray(data)\n if data.ndim <= 1:\n logging.log_first_n(logging.INFO,\n 'Converting %s sound from shape %s to 2-D' %\n (self._name, data.shape), 5)\n data = np.reshape(data, (-1, 1))\n if data.shape[... | [
"0.6366487",
"0.63232714",
"0.6174829",
"0.61593074",
"0.60996795",
"0.608292",
"0.6074825",
"0.60149586",
"0.5962723",
"0.59391665",
"0.5921867",
"0.58278805",
"0.5824111",
"0.5806314",
"0.56739146",
"0.56591153",
"0.56460583",
"0.5642763",
"0.56418234",
"0.56304383",
"0.562... | 0.76220435 | 0 |
Test a remote file using skip_verify | def test_file_managed_http_source_skip_verify(file, tmp_path, remote_grail_scene33):
name = str(tmp_path / "testfile")
ret = file.managed(name=name, source=remote_grail_scene33.url, skip_verify=True)
assert ret.result is True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testRemote(self):\n try:\n remoteLocator = self.__httpsFileUrl\n ok = self.__fileU.isLocal(remoteLocator)\n self.assertFalse(ok)\n #\n ok = self.__fileU.exists(remoteLocator)\n self.assertTrue(ok)\n size = self.__fileU.size(rem... | [
"0.7251301",
"0.7052198",
"0.6622951",
"0.6618357",
"0.6608947",
"0.6568611",
"0.6540163",
"0.6483996",
"0.6450933",
"0.6418295",
"0.64047265",
"0.6379879",
"0.6374588",
"0.6258586",
"0.62566084",
"0.6240293",
"0.6215035",
"0.62099105",
"0.6209236",
"0.6159993",
"0.615858",
... | 0.78441286 | 0 |
Return whether the given Vertex constitutes one end of the Edge. | def has_vertex(self, vertex) -> bool:
return self._start is vertex or self._end is vertex | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def containsEdge(self, e):\n return any(e.nvt in [self.vertices[i-2], self.vertices[i]] and self.vertices[i-1] == e.pvt for i in range(len(self.vertices)))",
"def is_edge(self, v, w):\n return self.op_norm(v[0], w[0]) == (v[1] + w[1]) and (self.variant.is_bipartite() or v != w)",
"def is_adjacent... | [
"0.76288044",
"0.70967877",
"0.6977022",
"0.67843217",
"0.674925",
"0.6741775",
"0.67264235",
"0.667477",
"0.6587415",
"0.6529085",
"0.6496197",
"0.64839035",
"0.64819247",
"0.646801",
"0.6465473",
"0.64421",
"0.64376503",
"0.6427465",
"0.6426235",
"0.64196527",
"0.6361983",
... | 0.683127 | 3 |
Override the __eq__ method. | def __eq__(self, other) -> bool:
return (
self._start is other._start
and self._end is other._end
and self._label == other._label
and self._has_direction is other._has_direction
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n pass",
"def __eq__(self, other):\n pass",
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n pass",
... | [
"0.88621426",
"0.88621426",
"0.8802366",
"0.8802366",
"0.8802366",
"0.8802366",
"0.8802366",
"0.8802366",
"0.8802366",
"0.8802366",
"0.8802366",
"0.8802366",
"0.8802366",
"0.8757959",
"0.8757959",
"0.8757959",
"0.8695948",
"0.8695948",
"0.8695948",
"0.8695948",
"0.8695948",
... | 0.0 | -1 |
Readonly property for the end attribute. | def end(self) -> Vertex:
return self._end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end(self):\n return self.__end_line",
"def setEnd(self):\n return _libsbml.XMLToken_setEnd(self)",
"def get_end(self):\n return self.__end",
"def get_endline(self):\n return self.get_attribute(\"endline\")",
"def get_end(self):\n return self._end",
"def setEnd(self,... | [
"0.73059696",
"0.71708596",
"0.7106488",
"0.71050495",
"0.6997485",
"0.69182646",
"0.6889657",
"0.6889657",
"0.6889657",
"0.68412256",
"0.67680645",
"0.6744929",
"0.67442906",
"0.6733118",
"0.6712099",
"0.66414064",
"0.66414064",
"0.66414064",
"0.66324586",
"0.6619295",
"0.66... | 0.62907684 | 37 |
Test that SLURM environment variables are properly checked for rank_zero_only. | def test_rank_zero_known_cluster_envs(env_vars: Mapping[str, str]):
from pytorch_lightning.utilities.distributed import _get_rank, rank_zero_only
rank_zero_only.rank = _get_rank()
with mock.patch.dict(os.environ, env_vars):
from pytorch_lightning.utilities.distributed import _get_rank, rank_zero_o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _assert_local_rank_set(self):\n assert self.local_rank >= 0, 'The environment variable LOCAL_RANK is not set, thus the coordinator is not aware of the local rank of the current process.'",
"def test_rank_zero_none_set(rank_key, rank):\n\n with mock.patch.dict(os.environ, {rank_key: rank}):\n ... | [
"0.6818698",
"0.6449645",
"0.61541635",
"0.57703334",
"0.5661064",
"0.5612566",
"0.5535392",
"0.5509749",
"0.5493569",
"0.54028124",
"0.5381893",
"0.5332986",
"0.5329292",
"0.5304521",
"0.52791685",
"0.52758074",
"0.52317387",
"0.52317387",
"0.52295375",
"0.52202594",
"0.5189... | 0.7357966 | 0 |
Returns the full path to the test data directory | def test_data_dir(self):
return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_test_data_path():\n return os.path.abspath(os.path.join(os.path.dirname(__file__), \"data\") + os.path.sep)",
"def data_dir():\n return os.path.join(os.path.dirname(_here), 'test', 'data')",
"def data_dir():\n return os.path.join(os.path.dirname(__file__), 'test', 'data')",
"def test_data_di... | [
"0.91113776",
"0.90987366",
"0.887621",
"0.86290467",
"0.8481252",
"0.8396891",
"0.831865",
"0.826754",
"0.8233042",
"0.8229824",
"0.8090345",
"0.80200744",
"0.80070865",
"0.7992242",
"0.7949754",
"0.7906792",
"0.7864156",
"0.7812648",
"0.7732339",
"0.77273315",
"0.7723905",
... | 0.92368877 | 0 |
Returns the full paath to the test task directory | def test_task_dir(self):
return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tasks') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dir():\n return os.path.abspath(os.path.dirname(__file__))",
"def get_test_path():\n path, name = os.path.split(__file__)\n return os.path.join(path,\"..\", 'test-data')",
"def test():\n return os.path.dirname(__file__)",
"def testnodes_path() -> str:\n return os.path.abspath(\n ... | [
"0.7674695",
"0.7589369",
"0.71511745",
"0.7132654",
"0.7118378",
"0.70436317",
"0.7012108",
"0.69527984",
"0.6950599",
"0.6936121",
"0.689541",
"0.6856171",
"0.6844601",
"0.68313617",
"0.67896086",
"0.67874813",
"0.6763031",
"0.67000246",
"0.66965204",
"0.66603136",
"0.66419... | 0.85292554 | 0 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(y_true, y_pred, classes,
normalize=False,
title=None,
cmap=plt.cm.Blues):
if not title:
if normalize:
title = 'Normalized confusion matrix'
else:
title = 'Confusion matrix,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.81949747",
"0.80953693",
"0.80294114",
"0.8019143",
"0.79937863",
"0.79912597",
"0.7980661",
"0.79754096",
"0.7960909",
"0.79568285",
"0.79377204",
"0.79348296",
"0.7934468",
"0.79314184",
"0.79262596",
"0.792439",
"0.79241437",
"0.79229194",
"0.7922838",
"0.7922132",
"0.7... | 0.0 | -1 |
Tests equality with another object. | def __eq__(self, other):
if not isinstance(other, type(self)):
return NotImplemented
return (self.member_role == other.member_role and
self.member_type == other.member_type and
self.member_email == other.member_email) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testEquality(self):\n pass",
"def __eq__(self, other):\n return equal(self, other)",
"def __eq__(self, other):\r\n return self.__dict__ == other.__dict__",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, o... | [
"0.8054736",
"0.8047661",
"0.8034323",
"0.8029533",
"0.8029533",
"0.8011173",
"0.8011173",
"0.8011173",
"0.8011173",
"0.8011173",
"0.8011173",
"0.8011173",
"0.8011173",
"0.8011173",
"0.8011173",
"0.8011173",
"0.8011173",
"0.8011173",
"0.8011173",
"0.8011173",
"0.8011173",
"... | 0.0 | -1 |
Tests inequality with another object. | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_equality_check_against_other_object_doesnt_raise_exception(self):\n test_object = Vec3(1, 2, 3)\n self.assertFalse(test_object == Quat(1, 2, 3, 4))\n self.assertFalse(Quat(1, 2, 3, 4) == test_object)\n self.assertTrue(test_object != Quat(1, 2, 3, 4))\n self.assertTrue(Qu... | [
"0.7981764",
"0.78231955",
"0.7807243",
"0.78045034",
"0.76759416",
"0.7651025",
"0.7617935",
"0.76135784",
"0.76135784",
"0.7606654",
"0.760384",
"0.760384",
"0.7581507",
"0.75759876",
"0.7569481",
"0.7559457",
"0.7559457",
"0.7559457",
"0.7558674"
] | 0.0 | -1 |
Returns the default value or the value of the environment variable. | def get_config(key: str, path="secrets", source="twitter") -> str:
# Creating os independent path to the secrete file
path = generate_file_path(path, "secrets.json")
# Useful when we want to provide name from environment variables for overriding values in production
secrets = load_json_file(path)
# ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_environment_var(env_name, default_value):\n if env_name in os.environ:\n return os.environ[env_name]\n else:\n return default_value",
"def get(self):\n self.value = os.getenv(self.name, self.default)\n return self.value",
"def get_env_variable(var_name, default_value=N... | [
"0.8108466",
"0.7833075",
"0.76763755",
"0.7659311",
"0.76536256",
"0.76365465",
"0.76244545",
"0.7621877",
"0.7496304",
"0.7496304",
"0.74562883",
"0.7453269",
"0.74471915",
"0.74319017",
"0.74313194",
"0.7394097",
"0.72944",
"0.72447073",
"0.7230049",
"0.72292423",
"0.72010... | 0.0 | -1 |
Returns an addon's localized 'unicode string'. | def getLocalizedString(self, stringId):
langPath = 'special://home/addons/' + self.addonId + '/resources/language/English/strings.xml'
langPath = xbmc.translatePath(langPath)
if os.path.exists(langPath):
with open(langPath, 'r') as langFile:
langStr = langFile.r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ugettext(self):\n return self._translations.gettext",
"def get_localized_string(key):\n return _localized_strings[key]",
"def getUniStr(self):\n return(\"%s.%s.%s-%s\"%(self.getPrefix,self.getSentenceId,\n self.offset_bgn,self.offset_end))",
"def resource_str... | [
"0.63678354",
"0.6067025",
"0.59664506",
"0.5815764",
"0.5815764",
"0.57575786",
"0.5754689",
"0.5749508",
"0.57430583",
"0.5739456",
"0.57330155",
"0.57330155",
"0.57330155",
"0.57330155",
"0.57330155",
"0.57330155",
"0.57330155",
"0.57330155",
"0.57330155",
"0.57294494",
"0... | 0.5452837 | 33 |
Places an annotation on the subplot. | def annotate(self, text: str, position: Tuple[int, int],
axes: plt.Axes = None) -> Union[plt.Annotation, None]:
if text == '':
return None
if axes is None:
axes = self.subplot
annotation = axes.annotate(text,
xy=position... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_annotation(self):\n annotation = self.ax_fig.annotate(\n '', xy=(0, 0), ha='left',\n xytext=(-20, 20), textcoords='offset points', va='bottom',\n bbox=dict(\n boxstyle='round,pad=0.5', fc='yellow', alpha=0.2),\n arrowprops=dict(\n ... | [
"0.75712043",
"0.66481596",
"0.66481596",
"0.65520364",
"0.6466267",
"0.6395885",
"0.6376006",
"0.63704646",
"0.63694793",
"0.63456666",
"0.62419534",
"0.6173931",
"0.61660546",
"0.61497045",
"0.6126607",
"0.6117126",
"0.6056929",
"0.60535574",
"0.60533553",
"0.5986669",
"0.5... | 0.5945307 | 23 |
Adds a vertex to the graph at the position defined by the mpl event. | def add_vertex(self, event: matplotlib.backend_bases.LocationEvent) \
-> None:
transform_func = event.inaxes.transData.inverted().transform
new_coords = transform_func((event.x, event.y))
log.info(f'Adding Vertex @ {event.x} - {event.y}, axis: '
f'{new_coords}')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_vertex(self, vertex):\n raise NotImplementedError",
"def add_vertex(self, vertex_id):\n pass # TODO",
"def add_vertex(self, vertex):\n self.vertices.append(vertex)\n self.vertex_edge[vertex] = []",
"def add_vertex(self, label):\n\n if label in self._vertices:\n ... | [
"0.7563129",
"0.723222",
"0.7161543",
"0.7156355",
"0.71207875",
"0.71198916",
"0.7035426",
"0.6999496",
"0.6957054",
"0.69250786",
"0.6904555",
"0.6765922",
"0.67454743",
"0.66659695",
"0.66659695",
"0.6649009",
"0.66469586",
"0.66432774",
"0.66098505",
"0.6546472",
"0.65267... | 0.8221702 | 0 |
Add an edge between two vertices to a graph. | def _add_edge(self, graph: Graph, vertex1: Vertex, vertex2: Vertex) \
-> None:
new_edge = Edge(vertex1, vertex2)
graph.add(new_edge) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(self, vertex1, vertex2):\n\n vertex1.add_outgoing_node(vertex2)\n vertex2.add_incoming_node(vertex1)",
"def add_edge(self, v1, v2):\n if v2 in self.vertices:\n self.vertices[v1].add(v2)\n else:\n raise ValueError(f\"The second Vertices you provided: ... | [
"0.84961265",
"0.84685177",
"0.8449795",
"0.8418122",
"0.8407118",
"0.83785975",
"0.835683",
"0.83395135",
"0.83237904",
"0.83171517",
"0.8220658",
"0.81392616",
"0.8089658",
"0.80719817",
"0.8069369",
"0.80659175",
"0.8057464",
"0.7817144",
"0.7786346",
"0.7777983",
"0.77509... | 0.829248 | 10 |
Connects any two elements if it makes sense in context. Adds a new Edge between two vertices, if self.selected_element is not None and both vertices are in the same axes. If selected_element is None then it sets self.selected_element to the vertex passed as argument. If two edges are in the same axes nothing happens. I... | def connect_elements(self, event: matplotlib.backend_bases.LocationEvent,
element: 'FigureElement') -> None:
if self.selected_element is None:
self.selected_element = element
element.add_extra_path_effect('selection',
pe.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(self, v1, v2):\n pass # TODO",
"def add_edge(self, item1: Any, item2: Any, weight: Union[int, float]) -> None:\n if item1 in self._vertices and item2 in self._vertices:\n v1 = self._vertices[item1]\n v2 = self._vertices[item2]\n\n # Add the new edge\n ... | [
"0.5999846",
"0.59856063",
"0.5815487",
"0.57965994",
"0.57955956",
"0.57671285",
"0.57221603",
"0.5625872",
"0.5615395",
"0.5603937",
"0.5591767",
"0.55876136",
"0.5574401",
"0.55651414",
"0.5539157",
"0.55012083",
"0.54722184",
"0.5467264",
"0.5466253",
"0.5464435",
"0.5457... | 0.750268 | 0 |
Test if an event is inside the axes of this Panel. | def event_in_axes(self, event: matplotlib.backend_bases.LocationEvent) \
-> bool:
return event.inaxes == self.subplot | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def axes_enabled(self):\n if hasattr(self, 'axes_widget'):\n return bool(self.axes_widget.GetEnabled())\n return False",
"def _check_axes(axes):\n _check_type(axes, (Axes, np.ndarray), \"axes\")\n if isinstance(axes, np.ndarray):\n if axes.ndim == 1:\n for ax in a... | [
"0.671091",
"0.6208423",
"0.6156233",
"0.61335844",
"0.60991186",
"0.6088695",
"0.60207427",
"0.57926714",
"0.57722473",
"0.5760292",
"0.57368016",
"0.5726686",
"0.562051",
"0.56115305",
"0.5580775",
"0.5571055",
"0.5563919",
"0.5550448",
"0.5470026",
"0.5459179",
"0.5459179"... | 0.8854843 | 0 |
Returns the two points connecting the centers of the two elements with a straight line, taking into account the circumference of the figure elements. | def connection_points_between_figure_elements(element1: FigureElement,
element2: FigureElement
) -> Tuple[Vec, Vec]:
if isinstance(element1, FigureVertex):
center1 = Vec(x1=element1.center[0], y1=element1.center[1])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mapping_points_between_figure_elements(element1: FigureElement,\n element2: FigureElement\n ) -> Tuple[Vec, Vec]:\n if isinstance(element1, FigureVertex):\n center1 = Vec(x1=element1.center[0], y1=element1.center[1])\... | [
"0.66054904",
"0.64072263",
"0.6248832",
"0.62166214",
"0.62028444",
"0.61827886",
"0.612428",
"0.6113595",
"0.6099789",
"0.6065092",
"0.60411304",
"0.6020374",
"0.60182923",
"0.5980456",
"0.59705496",
"0.595651",
"0.5934626",
"0.5933855",
"0.5900288",
"0.58866364",
"0.588513... | 0.65649503 | 1 |
Get data as a pandas dataframe. | def get_dataframe(self, params=None, chunksize=None):
if chunksize:
raise NotImplementedError("Buffered reading not supported yet")
# the resulting `rows` of a query provides a nice way to do this, though
query = self.config["query"]
params = params or {}
logger... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_to_df(data):\r\n ans = pd.DataFrame(data)\r\n return ans",
"def as_dataframe(self) -> \"pd.DataFrame\":\n import pandas as pd\n\n df = pd.DataFrame([row.as_series() for row in self.rows])\n return df",
"def to_pandas_df(self):\n data = self._get_data(pd=True)\n ... | [
"0.8515501",
"0.8206588",
"0.81622106",
"0.79191244",
"0.79154384",
"0.78859025",
"0.774719",
"0.7598638",
"0.75892365",
"0.75878376",
"0.7555098",
"0.75477064",
"0.75360626",
"0.75124526",
"0.7501661",
"0.7495387",
"0.7407304",
"0.73777467",
"0.7373512",
"0.7361605",
"0.7352... | 0.6712965 | 76 |
Get the geolocation data from the request. | def get_geo_data(request):
# Note that geoip2 (from maximind) doesn't work on GAE because there is a
# C lib in there apparently.
# We can use Appengine's added headers to do that work though thankfully.
geo = dict()
geo['region'] = request.headers.get("X-AppEngine-Region", "unknown")
geo['city... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_geolocation(self, location):\n\n response = self.request(dict(\n method=\"GET\",\n query=dict(location=location),\n ))\n\n return response['data']",
"def getLocation(self):\n send_url = 'https://ipinfo.io'\n r = requests.get(send_url)\n resp... | [
"0.7609283",
"0.70273775",
"0.67268974",
"0.6568262",
"0.65253556",
"0.6492344",
"0.6459893",
"0.64520943",
"0.6426659",
"0.6425953",
"0.6342649",
"0.63417333",
"0.63356334",
"0.63080126",
"0.6297456",
"0.62643236",
"0.62602955",
"0.6233702",
"0.6208337",
"0.6201374",
"0.6194... | 0.7446573 | 1 |
Set up the platform from config_entry. | async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entities):
name = config_entry.data["name"]
async_add_entities([IPSensor(name)], True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def setup_platform(hass, platform: str, *,\n devices=None, scenes=None):\n hass.config.components.add(DOMAIN)\n config_entry = ConfigEntry(2, DOMAIN, \"Test\",\n {CONF_INSTALLED_APP_ID: str(uuid4())},\n SOURCE_USER, CO... | [
"0.6831646",
"0.659668",
"0.65196484",
"0.646407",
"0.63446957",
"0.6341726",
"0.63239086",
"0.62973005",
"0.6268766",
"0.6237635",
"0.62204295",
"0.61891663",
"0.6177308",
"0.6169877",
"0.6168103",
"0.61043787",
"0.6031153",
"0.60188097",
"0.60015845",
"0.5991391",
"0.599087... | 0.0 | -1 |
Return the name of the sensor. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return self._sensor.name",
"def get_sensor_name(self):\n return self.data[1]",
"def name(self):\n return self.device.device_data[self.device_id]['name'] + \\\n f' {self._sensor_type}'",
"def name(self):\n return f\"{self._name} {SENSOR_TYPES[self.senso... | [
"0.91896784",
"0.9168378",
"0.890185",
"0.8770976",
"0.8511273",
"0.8479953",
"0.844435",
"0.8299758",
"0.8186503",
"0.8105667",
"0.8079737",
"0.8066149",
"0.8049647",
"0.7700968",
"0.7612295",
"0.7611456",
"0.7600605",
"0.7600605",
"0.7600605",
"0.75392073",
"0.75166553",
... | 0.0 | -1 |
Asserts that arg in command has a resource argument completer. | def AssertCommandArgResourceCompleter(self, command, arg):
self.AssertCommandArgCompleter(command, arg, _COMPLETER_MODULE_PATH) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RunResourceCompleter(self, resource_spec, attribute_name, prefix='',\n expected_completions=None, args=None,\n presentation_name=None, dest=None,\n flag_name_overrides=None, projects=None):\n args = args or {}\n flag_name_overr... | [
"0.63553154",
"0.57756376",
"0.5686924",
"0.54825395",
"0.53907144",
"0.53843004",
"0.5378544",
"0.5372374",
"0.5353488",
"0.5348231",
"0.5308486",
"0.5275861",
"0.52420455",
"0.5213123",
"0.5182557",
"0.51743853",
"0.51729286",
"0.51724285",
"0.51584214",
"0.5154543",
"0.512... | 0.8022566 | 0 |
Move lift close to the ground level | def move_lift_down():
return _move_lift(0.2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_lift_ground():\n return _move_lift(0)",
"def lift_down(self):\n\n # Can't reuse set_lift_pos due to bug above\n bottom_limit = self.get_lift_limit()\n self.send(self.cmd.SET_LIFT_SET, bottom_limit)",
"def jump(self):\r\n if self.grounded == True:\r\n self.vel.... | [
"0.8149269",
"0.6854262",
"0.68413323",
"0.6714419",
"0.65151966",
"0.64415556",
"0.62991387",
"0.6228117",
"0.61921024",
"0.61904323",
"0.617294",
"0.6154423",
"0.6126746",
"0.60275495",
"0.6003219",
"0.59435475",
"0.59210306",
"0.59191656",
"0.5919147",
"0.5905214",
"0.5900... | 0.7417945 | 1 |
Retrieve an environment variable. Any failures will cause an exception to be thrown. | def get_env_variable(self, var_name, optional=False):
try:
return environ[var_name]
except KeyError:
if optional:
return False
else:
error_msg = f'Error: You must set the {var_name} environment variable.'
raise Exception(error_msg) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_env_variable(var_name):\n try:\n return os.environ[var_name]\n except KeyError:\n error_msg = \"Set the {} environment variable\".format(var_name)\n\n raise Exception(error_msg)",
"def get_env_variable(var_name):\n try:\n return os.environ[var_name]\n except KeyError:\... | [
"0.8219711",
"0.7999004",
"0.7904889",
"0.7870026",
"0.7826477",
"0.7740203",
"0.77336615",
"0.77190036",
"0.7707803",
"0.76930946",
"0.76501966",
"0.7644564",
"0.75845987",
"0.7573528",
"0.75723463",
"0.7517979",
"0.7484092",
"0.7442207",
"0.74171025",
"0.74168986",
"0.73590... | 0.8043275 | 1 |
Find indices into the state_data array, | def find_modifiable_states(state_data):
modifiable = (state_data['pcad_mode'] == 'NPNT') & (state_data['clocking'] == 1) & (
state_data['fep_count'] == state_data['ccd_count']) & (state_data['fep_count'] < 4)
states_ind = np.where(modifiable)[0]
cases = list(product([0, 1], repeat=len(state... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _state_index(state):\n delta_y, delta_x, bird_lmh, pipe_lmh, is_flapping = state\n actions, height, width, _, _, _ = Q.shape\n\n y = int((height / 2) + (delta_y / step_r) - 1)\n x = int((width / 2) + (delta_x / step_c) - 1)\n\n return y, x, bird_lmh, pipe_lmh, is_flapping",
... | [
"0.6600081",
"0.6353671",
"0.6265204",
"0.6116195",
"0.6102874",
"0.60912144",
"0.60813206",
"0.6029227",
"0.6018618",
"0.60100675",
"0.5992335",
"0.5990695",
"0.5985374",
"0.5973648",
"0.5952727",
"0.5947303",
"0.59317124",
"0.59240097",
"0.59213734",
"0.59200215",
"0.591526... | 0.5825047 | 30 |
True if the current user has given permission rights. | def __has_permission(self, permission) -> bool:
if self.__manager.is_enabled and not self.__auth_session:
return False
return self.hasPermission(permission, None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_perm(self, user):\n return True",
"def has_permission(cls, perm, user):\n return perm in cls.get_permissions(user)",
"def current_user_has_access(self):\n return self.user_has_access(users.get_current_user())",
"def _has_permission(self, user, user_is_mod, command, db_session):\n\n ... | [
"0.79704714",
"0.79616475",
"0.7931218",
"0.7856532",
"0.7758904",
"0.77377945",
"0.7719295",
"0.7665662",
"0.76080096",
"0.76080096",
"0.760422",
"0.75819623",
"0.7555355",
"0.7555355",
"0.75214845",
"0.748658",
"0.7474744",
"0.74685115",
"0.74609417",
"0.74420166",
"0.74420... | 0.68756574 | 96 |
Returns whether or not the current loggedin user (or guest, if authentication is disabled) is granted the given permission. This method observes permission inheritance. | def hasPermission(self, permission, extra_params):
with DBSession(self.__config_db) as session:
perm, params = ThriftAuthHandler.__create_permission_args(
permission, extra_params, session)
return require_permission(perm, params,
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_access(\n self, permission: Union[str, Enum] = None, error: bool = False\n ) -> bool:\n access = (\n permission is None\n or self.belongs_to_user()\n or flask.g.user.has_permission(permission)\n )\n if error and not access:\n raise ... | [
"0.7348229",
"0.7266256",
"0.7186306",
"0.712743",
"0.7046967",
"0.69983274",
"0.6971383",
"0.69648206",
"0.6961335",
"0.6932548",
"0.6932231",
"0.6921144",
"0.6907247",
"0.6892704",
"0.6884271",
"0.68774223",
"0.6875044",
"0.68541956",
"0.68444264",
"0.68444264",
"0.68444264... | 0.6589182 | 50 |
Return min, max, value given input values with possible None. | def _get_min_max_value(min, max, value=None, step=None):
# Either min and max need to be given, or value needs to be given
if value is None:
if min is None or max is None:
raise ValueError('unable to infer range, value from: ({0}, {1}, {2})'.format(min, max, value))
diff = max - min
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minmax(xs):\n min_val = None\n max_val = None\n for x in xs:\n if min_val is None or x < min_val:\n min_val = x\n if max_val is None or x > max_val:\n max_val = x\n return (min_val, max_val)",
"def get_min_max(ints):\n if not ints:\n return None, None\n ... | [
"0.71916413",
"0.71181756",
"0.7098145",
"0.7044009",
"0.6769888",
"0.67608625",
"0.67160344",
"0.6710283",
"0.6672169",
"0.66507965",
"0.65802157",
"0.65526325",
"0.65471387",
"0.63813806",
"0.63495266",
"0.6338482",
"0.6316086",
"0.62620413",
"0.625826",
"0.6199835",
"0.619... | 0.6565917 | 11 |
Return the value for this widget which should be passed to interactive functions. Custom widgets can change this method to process the raw value ``self.value``. | def get_interact_value(self):
return self.value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_value(self):\n if self.notebook:\n return self.widget.value\n else:\n if hasattr(self.widget, \"value\"):\n return self.widget.value()\n elif hasattr(self.widget, \"currentText\"):\n return self.widget.currentText()\n e... | [
"0.82415944",
"0.7548149",
"0.7548149",
"0.7548149",
"0.7469256",
"0.74551094",
"0.74551094",
"0.73919475",
"0.73919475",
"0.73919475",
"0.73580617",
"0.73580617",
"0.7339713",
"0.7287065",
"0.7286482",
"0.7276106",
"0.72296405",
"0.722479",
"0.7199927",
"0.71925837",
"0.7192... | 0.79434526 | 1 |
PSO with flight operation based on sigmoid transformation | def run_PSO_LS(path, num_particles, max_iteration, max_flip, w, c1, c2):
pso = PSO(path, num_particles, max_iteration, max_flip, 0, w, c1, c2)
iteration = 0
num_satisfied_clauses = 0
while not pso.stop_condition(num_satisfied_clauses, iteration):
iteration += 1
#Calculate fitness
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swish(x):\n return x * tf.sigmoid(x)",
"def convert_hard_sigmoid(g, op, block):\n\n slope = op.attr(\"slope\")\n offset = op.attr(\"offset\")\n x = g.get_node(op.input(\"X\")[0])\n out = x * _expr.const(slope) + _expr.const(offset)\n out = _op.clip(out, 0, 1)\n g.add_node(op.output(\"Out... | [
"0.66853315",
"0.6630969",
"0.65470105",
"0.649457",
"0.6481648",
"0.64728546",
"0.6465036",
"0.64623916",
"0.6432219",
"0.64316547",
"0.6429397",
"0.6366685",
"0.6316702",
"0.63106835",
"0.63106835",
"0.630452",
"0.6300054",
"0.62883615",
"0.62817174",
"0.6276538",
"0.627354... | 0.0 | -1 |
Checks whether the object is a sheet | def isSheet(self):
return True if self.leftSon is None and self.rightSon is None else False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_sheet(path, sheet): \n xl = pd.ExcelFile(path)\n if sheet not in xl.sheet_names:\n raise ValueError(\"Invalid sheet name \\'\" + sheet +\"\\'\")",
"def check_presSheetExists(self):\n\n if not self.pres_sheetname:\n self.raise_excelerror(\"Required sheet for preservation files\"... | [
"0.66219234",
"0.61277586",
"0.60819465",
"0.5930213",
"0.5887744",
"0.5702059",
"0.5631677",
"0.56167376",
"0.55882126",
"0.5522886",
"0.55084896",
"0.5459295",
"0.5446342",
"0.54172677",
"0.5390506",
"0.5380341",
"0.5351818",
"0.53457916",
"0.53396326",
"0.533245",
"0.53252... | 0.7400545 | 0 |
f""" Purges a channel of a specified amount of messages. Currently no limit is set, but the discord library may have an upper limit. Requires manage_messages permissions to run | async def purge(self, ctx, limit: int, flags=""):
await ctx.message.delete()
if "all" in flags:
await ctx.message.channel.purge(limit=limit)
else:
await ctx.message.channel.purge(limit=limit,
check=lambda msg: not msg.pinned
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def channel(self, ctx, limit: int=100, channel: discord.TextChannel=None):\n\n if channel is None:\n channel = ctx.channel\n\n # noinspection PyUnresolvedReferences\n messages = await channel.purge(limit=limit)\n messages = len(messages)\n\n plural = '' if messag... | [
"0.7849875",
"0.77978814",
"0.7574485",
"0.74875337",
"0.7428854",
"0.738883",
"0.7376081",
"0.73051316",
"0.72878844",
"0.72793204",
"0.72322756",
"0.71918714",
"0.70793325",
"0.70075333",
"0.69981396",
"0.69172525",
"0.68477964",
"0.68360406",
"0.68141556",
"0.67238605",
"0... | 0.6602447 | 22 |
Highest block consensus information for all peers | def consensus(self):
total_peers = 0
blocks = list()
for peer in self.peers.values():
assert len(peer.blocks) > 0
if not peer.synched:
continue
total_peers += 1
blocks.extend(peer.blocks)
# blocks = [peer.blocks[-1] for peer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def consensus():\n global blockchain\n\n longest_chain = None\n current_len = len(blockchain.chain)\n\n for node in peers:\n response = requests.get('{}chain'.format(node))\n length = response.json()['length']\n chain = response.json()['chain']\n if length > current_len and ... | [
"0.6532132",
"0.6532132",
"0.649755",
"0.63097155",
"0.62579066",
"0.60755134",
"0.6013463",
"0.5995913",
"0.5967726",
"0.5833175",
"0.5774598",
"0.5754582",
"0.5719536",
"0.5695856",
"0.5680934",
"0.5660314",
"0.5659518",
"0.55405015",
"0.553655",
"0.5525904",
"0.55225396",
... | 0.7636462 | 0 |
Verify that the email exists | def clean_email(self):
email = self.cleaned_data.get("email")
if not email:
return email
if User.objects.filter(email__iexact=email).exclude(pk=self.instance.pk):
raise forms.ValidationError("That e-mail is already used.")
else:
return ema... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email_exists(self, email):\n user = [user for user in ALL_USERS if user['email'] == email]\n if user:\n return True\n return False",
"def email_exists(form, field):\n if User.select().where(User.email == field.data).exists():\n raise ValidationError('A user with that... | [
"0.7689403",
"0.765135",
"0.7533824",
"0.7524095",
"0.7495039",
"0.7457489",
"0.7449288",
"0.7435111",
"0.7427037",
"0.7413979",
"0.7402739",
"0.74022645",
"0.7400224",
"0.73930234",
"0.7370677",
"0.7362725",
"0.73592645",
"0.7330334",
"0.73037314",
"0.7303057",
"0.72869605",... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.