query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Return a queryset of with related fields. | def get_queryset(self):
return self.queryset().select_related(
'image'
).prefetch_related(
'authors',
'categories',
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def optimice_query(self, foreignkey_fields, many_to_many_fields):\n query = self.model.objects.select_related(\n *foreignkey_fields) if len(foreignkey_fields) else self.model.objects\n query = query.prefetch_related(\n *many_to_many_fields) if len(many_to_many_fields) else query... | [
"0.69294244",
"0.6857692",
"0.6675372",
"0.66136235",
"0.6612176",
"0.6577206",
"0.6465894",
"0.6455258",
"0.6439515",
"0.6383593",
"0.6370642",
"0.63489354",
"0.6324296",
"0.62965614",
"0.62830126",
"0.6280996",
"0.62657833",
"0.6165763",
"0.61640686",
"0.61603105",
"0.61032... | 0.65834844 | 5 |
If the status of the entry is not PUBLISHED, a preview is requested, so we check if the user has the 'can_view_all' permission or if it's an author of the entry. | def get_object(self, queryset=None):
qs = queryset or self.get_queryset()
obj = get_object_or_404(qs, slug=self.kwargs.get('slug', ''))
if obj.is_visible:
return obj
if self.request.user not in [author for author in obj.authors.all()]:
for permission in self.per... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_to_preview(user):\n if (\n user.is_authenticated and\n user.is_active and\n user.is_staff\n ):\n return True\n return False",
"def can_retrieve(self, user):\n return user.has_perm('agenda.can_see')",
"def can_view(self, user):\r\n return True",
"... | [
"0.67526895",
"0.67521596",
"0.6556264",
"0.64143735",
"0.6413414",
"0.6313495",
"0.6304207",
"0.6300576",
"0.6267087",
"0.6242798",
"0.6203541",
"0.6121337",
"0.60879236",
"0.60814244",
"0.60723",
"0.60635877",
"0.60631686",
"0.6060827",
"0.6048731",
"0.60215795",
"0.6016981... | 0.0 | -1 |
Overridde the get_queryset method to do some validations and build the search queryset. | def get_queryset(self):
entries = self.model_cls.published.none()
if self.request.GET:
self.pattern = self.request.GET.get('q', '')
if len(self.pattern) < 3:
self.error = _('The pattern is too short')
else:
query_parsed = QUERY.parseSt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n qs = super().get_queryset()\n search_value = self.request.GET.get('search_box')\n\n if search_value is not None:\n qs = qs.search_by(search_value)\n\n return qs",
"def get_queryset(self):\n qs = super(SearchForm, self).get_queryset()\n\n ... | [
"0.809329",
"0.77335596",
"0.75037104",
"0.74745685",
"0.73438495",
"0.7299719",
"0.7280401",
"0.72262883",
"0.7217715",
"0.72121865",
"0.71623135",
"0.71607935",
"0.71605796",
"0.7157986",
"0.7138896",
"0.7138896",
"0.71294045",
"0.7039188",
"0.7032896",
"0.7026869",
"0.6999... | 0.0 | -1 |
Return pandas.DataFrame with filename data. | def get_filename_df(level, env='stage', pattern=None):
fnames = get_filenames(level, env=env, pattern=pattern)
iuvs_fnames = []
for fname in fnames:
if not level == 'hk':
iuvs_fnames.append(ScienceFilename(fname))
else:
iuvs_fnames.append(HKFilename(fname))
df = p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_df(filepath):\n dd = [json.loads(f) for f in open(filepath).readlines()]\n return pd.DataFrame(dd)",
"def get_file_df(self, file_list):\n file_dict = {\n file.split(\".\")[0]: {\"Date\": file.split(\".\")[1], \"File\": file}\n for file in file_list\n }\n ... | [
"0.77002174",
"0.74857867",
"0.7412501",
"0.7384472",
"0.72650456",
"0.7207427",
"0.71808136",
"0.70936745",
"0.7061037",
"0.70224553",
"0.69458497",
"0.69425535",
"0.69010794",
"0.68461174",
"0.6835604",
"0.68334365",
"0.68062496",
"0.6785133",
"0.67844063",
"0.6783056",
"0.... | 0.0 | -1 |
Computes the backward pass for an affine layer. | def affine_backward(dout, cache):
x, w, b = cache
dx, dw, db = None, None, None
x_shape = x.shape
x_mutated = x.reshape(x_shape[0], np.prod(x_shape[1:]))
dx = np.dot(dout, w.T)
dw = np.dot(x_mutated.T, dout)
db = np.sum(dout, axis=0)
dx = dx.reshape(x_shape)
return dx, dw, db | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def affine_relu_backward(dout, cache):\n fc_cache, relu_cache = cache\n da = layers.relu_backward(dout, relu_cache)\n dx, dw, db = layers.affine_backward(da, fc_cache)\n return dx, dw, db",
"def affine_backward(dout, cache):\n x, w, b = cache\n dx, dw, db = None, None, None\n ###############... | [
"0.7518896",
"0.751513",
"0.7310849",
"0.73015374",
"0.73015374",
"0.73015374",
"0.73015374",
"0.7243401",
"0.7177609",
"0.7174102",
"0.7173503",
"0.71661735",
"0.71319",
"0.7106919",
"0.70978165",
"0.708432",
"0.7068546",
"0.70449376",
"0.70409757",
"0.6993727",
"0.6986414",... | 0.68831414 | 26 |
Computes the forward pass for a layer of rectified linear units (ReLUs). | def relu_forward(x):
out = None
out = np.maximum(0.0, x)
cache = x
return out, cache | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_relus(self):\n\n def relu_backward_hook_function(module, grad_in, grad_out):\n \"\"\"\n If there is a negative gradient, change it to zero\n \"\"\"\n # Get last forward output\n corresponding_forward_output = self.forward_relu_outputs[-1]\n ... | [
"0.67765754",
"0.6630487",
"0.6603554",
"0.6524658",
"0.65097666",
"0.64478433",
"0.6385381",
"0.62672025",
"0.62047166",
"0.6179713",
"0.61535424",
"0.61385596",
"0.6061572",
"0.6055216",
"0.6048094",
"0.6047937",
"0.6018342",
"0.59974337",
"0.59908754",
"0.59696555",
"0.596... | 0.0 | -1 |
Computes the backward pass for a layer of rectified linear units (ReLUs). | def relu_backward(dout, cache):
dx, x = None, cache
dx = dout
dout[x <= 0] = 0.0
return dx | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relu_backward(self, dUpper, cache):\n x = cache\n #############################################################################\n # TODO: Implement the ReLU backward pass. #\n #########################################################################... | [
"0.70408076",
"0.69492865",
"0.6897997",
"0.6847812",
"0.6847812",
"0.6847714",
"0.6841497",
"0.68197685",
"0.67684674",
"0.6757756",
"0.67559105",
"0.6755458",
"0.67431223",
"0.6740171",
"0.6716221",
"0.67097867",
"0.6700681",
"0.6697073",
"0.6697073",
"0.6688005",
"0.666655... | 0.65111107 | 44 |
A naive implementation of the forward pass for a max pooling layer. | def max_pool_forward_naive(x, pool_param):
N, C, H, W = x.shape
pool_height = pool_param['pool_height']
pool_width = pool_param['pool_width']
stride = pool_param['stride']
Hc = (H - pool_height) / stride + 1
Wc = (W - pool_width) / stride + 1
out = np.random.randn(N, C, Hc, Wc)
########################... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_pool_forward_naive(x, pool_param):\n out = None\n ###########################################################################\n # TODO: Implement the max pooling forward pass #\n ###########################################################################\n N,C,H,W ... | [
"0.8176104",
"0.7984787",
"0.7854871",
"0.76688087",
"0.763123",
"0.75106704",
"0.7398416",
"0.73303866",
"0.7267503",
"0.7173863",
"0.7142943",
"0.7042369",
"0.70236975",
"0.7022948",
"0.696239",
"0.68989724",
"0.689837",
"0.68944407",
"0.6884486",
"0.6883826",
"0.688134",
... | 0.7866907 | 2 |
NOT USED FOR ASSIGNMENT_07 Returns a dict containing information about customers who have rented a product based on the provided product_id. | def show_rentals(product_id): # {{{
cust_rent_dict = {}
try:
with MONGO:
DATABAE = MONGO.connection.assignment_07
customer_rental = DATABAE.rental.aggregate(
[
{
"$lookup": {
"from": "custome... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def customers_renting_product(product_id):\n logger.info(f\"Perparing rental dict for product_id: {product_id}...\")\n users_renting_product = []\n\n with MONGO:\n mdb = eval(Settings.connect_string)\n\n rentals = mdb[\"rental\"]\n customers = mdb[\"customers\"]\n query = {\"pr... | [
"0.7795496",
"0.7388176",
"0.72028625",
"0.685471",
"0.6852489",
"0.63175374",
"0.5973188",
"0.5707278",
"0.55884176",
"0.55630213",
"0.55298024",
"0.552132",
"0.5489038",
"0.54152846",
"0.5413372",
"0.53690314",
"0.53402364",
"0.53297937",
"0.5327381",
"0.5304467",
"0.519002... | 0.76678 | 1 |
Returns a list of subscription from self This is the list of clients you want to push to | def get_subscriptions_from_self(self):
return self._roster.get_my_subscriptions() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_subscriptions(self, client_id):\n return self.hub.get_subscriptions(self.get_private_key(), client_id)",
"def get_subscriptions(self):\n url = '{}/v2/subscriptions'.format(self.url)\n r = requests.get(url, headers=self.headers_v2)\n return r.json()",
"def get_subscriptions(s... | [
"0.75346535",
"0.74282503",
"0.7373272",
"0.72040546",
"0.7200954",
"0.71670425",
"0.714462",
"0.7103709",
"0.70590115",
"0.70528764",
"0.70007014",
"0.69982475",
"0.69904065",
"0.6983954",
"0.69731414",
"0.6959992",
"0.6929606",
"0.69161993",
"0.6878904",
"0.68626046",
"0.68... | 0.7015008 | 10 |
Calculate maximum value and units for axes | def compute_axes(self):
mini, maxi = self._get_extremes()
self.y_axis.min = mini
self.y_axis.max = maxi
self.y_axis._max_min()
if not None in [s.xvalues for s in self]:
mini, maxi = self._get_extremes('xvalues')
self.x_axis.min = mini
self.x_a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def y_max(self):\n return self.get_max_value(self.Y_INDEX)",
"def y_max(self) -> ir.FloatingValue:\n return ops.GeoYMax(self).to_expr()",
"def max_y_arg(self):\n return max((self(0).y,0), (self(1).y,1))[1]",
"def maxx(self):\n return self.__maxx",
"def onAxisMaximumChanged(self,... | [
"0.68784446",
"0.6845525",
"0.6694852",
"0.66816413",
"0.6577773",
"0.6567726",
"0.655792",
"0.65421635",
"0.6515711",
"0.6503462",
"0.6477138",
"0.64684176",
"0.6414913",
"0.6398861",
"0.63963366",
"0.63290495",
"0.6316894",
"0.6316176",
"0.6298949",
"0.6268864",
"0.62591434... | 0.6087633 | 33 |
Calculate the maximum and minimum values of all series for an axis 'values' for columns 'xvalues for rows | def _get_extremes(self, attr='values'):
# calculate the maximum and minimum for all series
series_max = [0]
series_min = [0]
for s in self:
if s is not None:
series_max.append(s.max(attr))
series_min.append(s.min(attr))
return min(serie... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minMax(df):\n max_, min_ = df.max(axis=0), df.min(axis=0)\n midrange = (max_ + min_) / 2\n half_range = (max_ - min_) / 2\n return (df - midrange) / half_range",
"def xminmax ( self ) :\n return self.xvar.minmax()",
"def compute_axes(self):\n mini, maxi = self._get... | [
"0.66076225",
"0.6471945",
"0.6391276",
"0.63118863",
"0.63118863",
"0.6278994",
"0.62640023",
"0.6240948",
"0.61388075",
"0.6135382",
"0.60807997",
"0.60373276",
"0.60211396",
"0.599636",
"0.59920996",
"0.59727955",
"0.59036803",
"0.5894996",
"0.5865304",
"0.5854356",
"0.584... | 0.67006063 | 0 |
Render index.html. Initialization is performed asynchronously in initialize() function | def landing():
return render_template('index.html', token=webview.token) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n return render_template('index.html')",
"def main():\n return render_template('index.html')",
"def index():\n # Render template\n return render_template('index.html')",
"def index():\r\n return render_template('index.html')",
"def index(self):\n return render_temp... | [
"0.75924486",
"0.75924486",
"0.7591326",
"0.7551682",
"0.75433177",
"0.75417954",
"0.7518462",
"0.75141764",
"0.75141764",
"0.74949324",
"0.74949324",
"0.74817026",
"0.7464088",
"0.7463117",
"0.74486864",
"0.7441125",
"0.7441125",
"0.7441125",
"0.7441125",
"0.7441125",
"0.744... | 0.0 | -1 |
Return left most child of node | def left_most_child(n):
if n == None:
return None
while n.left:
n = n.left
return n | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_leftmost_child(self):\n\t\tif self.left_child == None:\n\t\t\treturn self\n\t\telse:\n\t\t\treturn self.left_child.get_leftmost_child()",
"def left_child(self, position):\n child = 2 * position + 1\n if child > len(self.table) - 1:\n return None\n return child",
"def lef... | [
"0.8373466",
"0.8092487",
"0.7894623",
"0.78901035",
"0.78861636",
"0.7878979",
"0.77989924",
"0.77989924",
"0.77493393",
"0.7655658",
"0.7477981",
"0.74518734",
"0.73323846",
"0.7313927",
"0.7293937",
"0.72797036",
"0.72629493",
"0.7237921",
"0.722071",
"0.72177696",
"0.7172... | 0.81857544 | 1 |
Get all squares that the piece is allowed to move to. | def get_available_moves(self, board):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def guarded_places(self):\n guarded = []\n for x in range(8):\n for y in range(8):\n if self.squares[x][y].piece and self.squares[x][y].piece.color != self.turn:\n squares = self.squares[x][y].piece.actions(self, (x, y), True)\n if self.... | [
"0.76842695",
"0.7368328",
"0.7188977",
"0.71851486",
"0.7123327",
"0.6980735",
"0.6973738",
"0.69532406",
"0.68959486",
"0.6884979",
"0.6863356",
"0.6856457",
"0.68420833",
"0.6835366",
"0.68254775",
"0.6800773",
"0.6796985",
"0.6759987",
"0.66899514",
"0.66875696",
"0.66840... | 0.5999273 | 84 |
takes a df and a column label and graphs the distribution (continuous) for display | def display_dist(df, label):
# print(sns.__version__)
#TODO: make a categorical version of this?
sns.set(style="white", palette="pastel")
fig, axes = plt.subplots(2, 1, figsize=(6, 6)) # 6, 2 if OSA CSA
axes[1].get_shared_x_axes().join(axes[1], axes[0])
axes[1].set_aspect(aspect=25)
sns... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Numeric_plot(df,column = '', title='',ncols=2,trans_func = None):\n \n # Box plot\n trace1 = go.Box(y = df[column],name='Box')\n \n # Histogram\n trace2 = go.Histogram(x = df[column], name = 'x')\n \n fig = tools.make_subplots(rows=1, cols=ncols)\n fig.append_trace(trace1, 1,1)\n ... | [
"0.7023969",
"0.6924712",
"0.68914557",
"0.6811562",
"0.6736705",
"0.6688884",
"0.6558738",
"0.65332896",
"0.65221244",
"0.6514445",
"0.6382259",
"0.6260457",
"0.6255712",
"0.6186859",
"0.61838603",
"0.61682355",
"0.6149696",
"0.6143714",
"0.61169505",
"0.6096046",
"0.6086158... | 0.6594989 | 6 |
Deterministic string representation of the API instance for etag_cache. | def __repr__(self) -> str:
return (
"Superset.tags.api.TagRestApi@v"
f'{self.appbuilder.app.config["VERSION_STRING"]}'
f'{self.appbuilder.app.config["VERSION_SHA"]}'
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_etag(self): # real signature unknown; restored from __doc__\n return \"\"",
"def etag(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"etag\")",
"def etag(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"etag\")",
"def etag(self) -> pulumi.Output[str]:\n re... | [
"0.7271256",
"0.7237793",
"0.7237793",
"0.7237793",
"0.7237793",
"0.7237793",
"0.7237793",
"0.7237793",
"0.7158001",
"0.7158001",
"0.7158001",
"0.7158001",
"0.7158001",
"0.7158001",
"0.7158001",
"0.7158001",
"0.7158001",
"0.7158001",
"0.7158001",
"0.6865036",
"0.6862543",
"... | 0.6192034 | 55 |
Returns the derivative of x^2 (2x) at the input. | def derivative_x_squared(x):
return 2*x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _derivative_(self, x, diff_param=None):\n return 2*exp(-x**2)/sqrt(pi)",
"def derivative(xi, x, y):\n yi = ((xi-x[1])+(xi-x[2]))/((x[0]-x[1])*(x[0]-x[2])) * y[0]\\\n +((xi-x[0])+(xi-x[2]))/((x[1]-x[0])*(x[1]-x[2])) * y[1]\\\n +((xi-x[0])+(xi-x[1]))/((x[2]-x[0])*(x[2]-x[1])) * y[2]\n ... | [
"0.7365888",
"0.70614064",
"0.68726707",
"0.66712064",
"0.6648913",
"0.66283107",
"0.65764946",
"0.6571925",
"0.6523418",
"0.6518763",
"0.64251024",
"0.6420016",
"0.6417492",
"0.6384178",
"0.6384178",
"0.63834196",
"0.63289374",
"0.6325209",
"0.6280928",
"0.6278116",
"0.62667... | 0.7727061 | 0 |
Can set an initial value | def test_0_put(self):
self.assertIsNotNone(save_node_info(self.node.name, self.node)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_initial(self, value):\n # TODO: Make an Initial Stock Adjust here\n pass",
"async def set_init(self, value: int | float) -> bool:\n return await self.set_value(value, True)",
"def setInitialValue(self, *args):\n return _libsbml.Trigger_setInitialValue(self, *args)",
"def s... | [
"0.74489254",
"0.73642826",
"0.729574",
"0.71966565",
"0.71024",
"0.7064471",
"0.6984856",
"0.69269264",
"0.6819281",
"0.68124104",
"0.6798877",
"0.6793031",
"0.6787336",
"0.6781171",
"0.67532694",
"0.672437",
"0.6709393",
"0.6669517",
"0.66654336",
"0.6660875",
"0.65987414",... | 0.0 | -1 |
Calculates accuracy between truth labels and predictions. | def accuracy_fn(y_true, y_pred):
correct = torch.eq(y_true, y_pred).sum().item()
acc = (correct / len(y_pred)) * 100
return acc | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accuracy(preds, labels):\n correct = preds == labels\n return correct.sum().float() / correct.shape[0]",
"def accuracy(labels, predictions, n_classes):\n\t\tequality = tf.equal(x = predictions, y = labels) # match the type of labels\n\t\treturn tf.reduce_mean(tf.cast(equality, tf.float32))",
... | [
"0.87130684",
"0.8674318",
"0.86644745",
"0.854912",
"0.8523707",
"0.8471912",
"0.84568554",
"0.8359756",
"0.8356954",
"0.8356954",
"0.8336963",
"0.8286955",
"0.823785",
"0.8215967",
"0.8213891",
"0.82086533",
"0.81754017",
"0.8170142",
"0.8160432",
"0.8146372",
"0.81450003",... | 0.80693346 | 23 |
Makes a prediction on a target image with a trained model and plots the image. | def pred_and_plot_image(
model: torch.nn.Module,
image_path: str,
class_names: List[str] = None,
transform=None,
device: torch.device = "cuda" if torch.cuda.is_available() else "cpu",
):
# 1. Load in image and convert the tensor values to float32
target_image = torchvision.io.read_image(str... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Predict_image(image_path, model, show_img = True):\n test_image, preprocessed_image = Preproces_image(image_path)\n predictions = model.predict(preprocessed_image)\n prediction = Configs.CLASS_NAMES[np.argmax(predictions)]\n if show_img:\n plt.imshow(test_image)\n plt.title(prediction... | [
"0.73935586",
"0.7305404",
"0.73018754",
"0.72295403",
"0.72130954",
"0.7087915",
"0.70708907",
"0.7033366",
"0.7011689",
"0.69591796",
"0.695727",
"0.6886043",
"0.6883472",
"0.68523306",
"0.6839481",
"0.68180704",
"0.68079",
"0.6800002",
"0.6764993",
"0.6712348",
"0.6710486"... | 0.7004525 | 9 |
Initialize Conversation objects from utterances and conversations metadata | def initialize_conversations(corpus, utt_dict, convos_meta):
# organize utterances by conversation
convo_to_utts = defaultdict(list) # temp container identifying utterances by conversation
for u in utt_dict.values():
convo_key = u.root # each root is considered a separate conversation
convo_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_speakers_and_utterances_objects(corpus, utt_dict, utterances, speakers_dict, speakers_meta):\n if len(utterances) > 0: # utterances might be empty for invalid corpus start/end indices\n KeySpeaker = \"user\" if \"user\" in utterances[0] else \"speaker\"\n for i, u in enumerate(utterance... | [
"0.64719737",
"0.6312043",
"0.5735298",
"0.5610898",
"0.55534637",
"0.53624684",
"0.5338579",
"0.52947074",
"0.52843666",
"0.52603316",
"0.52556956",
"0.51028484",
"0.50719315",
"0.50575566",
"0.50543827",
"0.50524753",
"0.49875817",
"0.49830174",
"0.49307454",
"0.49234688",
... | 0.73922026 | 0 |
Add an element to the right side of the deque. | def append(self, *args, **kwargs): # real signature unknown
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def right_enqueue(self, item):\n item_to_add = Node(item)\n item_to_add.set_prev(self.tail)\n\n # if the deque is empty, the new item is the head\n if not self.head:\n self.head = item_to_add\n else:\n # connect the old tail to the new tail\n self... | [
"0.7211239",
"0.6879419",
"0.68729764",
"0.67506486",
"0.6747833",
"0.6699432",
"0.66625094",
"0.6488386",
"0.6420433",
"0.63702494",
"0.6360207",
"0.61647016",
"0.61568594",
"0.61564976",
"0.6152562",
"0.61409235",
"0.6139617",
"0.6115813",
"0.6100973",
"0.6063185",
"0.60482... | 0.0 | -1 |
Add an element to the left side of the deque. | def appendleft(self, *args, **kwargs): # real signature unknown
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def left_enqueue(self, item):\n item_to_add = Node(item)\n item_to_add.set_next(self.head)\n\n # if the deque is empty, the new item is the tail\n if not self.tail:\n self.tail = item_to_add\n else:\n # connect the old head to the new head\n self.... | [
"0.7578942",
"0.72930163",
"0.7192541",
"0.7124159",
"0.69704235",
"0.6962643",
"0.691528",
"0.6893327",
"0.6889453",
"0.6862317",
"0.68484277",
"0.68254745",
"0.68217516",
"0.6815901",
"0.678616",
"0.67832494",
"0.6776716",
"0.6770491",
"0.6747985",
"0.6660849",
"0.6660849",... | 0.6691957 | 19 |
Return a shallow copy of a deque. | def copy(self, *args, **kwargs): # real signature unknown
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_empty_deque():\n from deque import Deque\n new_deque = Deque()\n return new_deque",
"def copy(self):\r\n return copy.deepcopy(self)",
"def deepcopy(self):\n return self.copy()",
"def full_deque():\n from deque import Deque\n populated_deque = Deque(iterable=[1, 2, 3])\n ... | [
"0.6349479",
"0.6222582",
"0.6202566",
"0.61991954",
"0.61713153",
"0.6131602",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61220014",
... | 0.0 | -1 |
D.index(value, [start, [stop]]) > integer return first index of value. Raises ValueError if the value is not present. | def index(self, value, start=None, stop=None): # real signature unknown; restored from __doc__
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(self, value, start=0, stop=-1):\n return self.elem.index(value, start, stop)",
"def index(self, element, start=0, end=None):\n if end is None: # Only bound end if value has been provided\n end = self._length\n if end < 0: # For negative indexing, convert to positive co... | [
"0.7962",
"0.6861745",
"0.6848216",
"0.68206054",
"0.66506827",
"0.6420335",
"0.6407462",
"0.6382083",
"0.6328646",
"0.62298006",
"0.62259185",
"0.62259185",
"0.6210666",
"0.6164073",
"0.61577684",
"0.61506253",
"0.61481315",
"0.61431164",
"0.6141292",
"0.6053241",
"0.602599"... | 0.76280576 | 1 |
Remove and return the rightmost element. | def pop(self, *args, **kwargs): # real signature unknown
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_last_item_from_stack(self):\n if self.length > 0:\n return self.container.pop()\n else:\n return None",
"def pop(self):\n return self.popleft()",
"def get_rightmost_child(self):\n\t\tif self.right_child == None:\n\t\t\treturn self\n\t\telse:\n\t\t\treturn s... | [
"0.73805934",
"0.73023766",
"0.723817",
"0.7237201",
"0.72228837",
"0.70214623",
"0.6952377",
"0.69155926",
"0.69030625",
"0.6889738",
"0.68426186",
"0.6801426",
"0.67690605",
"0.67616796",
"0.6740858",
"0.67065924",
"0.66904616",
"0.66624075",
"0.66527665",
"0.66457117",
"0.... | 0.0 | -1 |
Remove and return the leftmost element. | def popleft(self, *args, **kwargs): # real signature unknown
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def popleft(self):\n try:\n return self._values.shift()\n except IndexError:\n raise IndexError('Cannot popleft from empty deque.')",
"def popleft(self):\n value = self.buffer[self.start]\n self.buffer[self.start] = None\n self.start = (self.start + 1) % l... | [
"0.7609626",
"0.75820863",
"0.7551782",
"0.741619",
"0.72918886",
"0.72882265",
"0.7263307",
"0.7103135",
"0.70737004",
"0.70367336",
"0.69823164",
"0.6924246",
"0.69142276",
"0.6897082",
"0.6897082",
"0.68950117",
"0.6892438",
"0.68749774",
"0.6861141",
"0.68471754",
"0.6830... | 0.68395156 | 20 |
Rotate the deque n steps to the right (default n=1). If n is negative, rotates left. | def rotate(self, *args, **kwargs): # real signature unknown
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate(l, n=1):\n return l[n:] + l[:n]",
"def rotate(l, n):\n return l[n:] + l[:n]",
"def rotate(l, n):\n return l[n:] + l[:n]",
"def vec_rotate_right_n(x, n):\n return jnp.roll(x, n)",
"def rotate(l: list, n: int) -> list:\n return l[-n:] + l[:-n]",
"def vec_rotate_left_n(x, n):\n ... | [
"0.7280998",
"0.7242433",
"0.7242433",
"0.72422236",
"0.688598",
"0.6872007",
"0.65214753",
"0.62785167",
"0.6202677",
"0.6085774",
"0.6080543",
"0.60671383",
"0.60642844",
"0.60639775",
"0.60504407",
"0.6032023",
"0.603172",
"0.60310507",
"0.6016403",
"0.597926",
"0.59378105... | 0.0 | -1 |
Return a shallow copy of a deque. | def __copy__(self, *args, **kwargs): # real signature unknown
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_empty_deque():\n from deque import Deque\n new_deque = Deque()\n return new_deque",
"def copy(self):\r\n return copy.deepcopy(self)",
"def deepcopy(self):\n return self.copy()",
"def full_deque():\n from deque import Deque\n populated_deque = Deque(iterable=[1, 2, 3])\n ... | [
"0.6349479",
"0.6222582",
"0.6202566",
"0.61991954",
"0.61713153",
"0.6131602",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61279",
"0.61220014",
... | 0.0 | -1 |
Move an existing element to the end (or beginning if last==False). Raises KeyError if the element does not exist. When last=True, acts like a fast version of self[key]=self.pop(key). | def move_to_end(self, *args, **kwargs): # real signature unknown
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop(self, last=True):\r\n if not self:\r\n raise KeyError('set is empty')\r\n key = reversed(self).next() if last else iter(self).next()\r\n self.discard(key)\r\n return key",
"def put(self, key, value):\n try: \n value = self.pop(key)\n \n ... | [
"0.6572634",
"0.6126293",
"0.5957631",
"0.59374195",
"0.5841973",
"0.5804189",
"0.57495236",
"0.5743748",
"0.5637006",
"0.56087834",
"0.5578949",
"0.5516298",
"0.54809946",
"0.5474769",
"0.54682726",
"0.54682726",
"0.54430443",
"0.5415699",
"0.54154366",
"0.54134846",
"0.5402... | 0.0 | -1 |
Return repr for the module. The method is deprecated. The import machinery does the job itself. | def module_repr(module): # reliably restored by inspect
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def module_repr(*args,**kw):\n pass",
"def __repr__(self) -> str:\n return f\"<Module[{self.path}]>\"",
"def __repr__(self):\n location = attr(self, '__spec__.origin',\n '__file__',\n '__package__')\n name = attr(self, '__nam... | [
"0.77780753",
"0.75000393",
"0.7397742",
"0.6893594",
"0.6770432",
"0.65819037",
"0.65785617",
"0.6530933",
"0.65229046",
"0.64664763",
"0.6382374",
"0.6342514",
"0.63051796",
"0.6303653",
"0.6292959",
"0.62465495",
"0.6232956",
"0.61731946",
"0.6146407",
"0.6121847",
"0.6023... | 0.8110311 | 2 |
Calculate pressure at specified loading. The Virial model calculates the pressure directly. | def pressure(self, loading):
return loading * numpy.exp(
-numpy.log(self.params['K']) + self.params['A'] * loading +
self.params['B'] * loading**2 + self.params['C'] * loading**3
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pressure(self, loading):\n return loading / (self.params[\"K\"] * (self.params[\"n_m\"] - loading))",
"def loading(self, pressure):\n kp = self.params[\"K\"] * pressure\n return self.params[\"n_m\"] * kp / (1.0 + kp)",
"def loading(self, pressure):\n def fun(x):\n ret... | [
"0.82703584",
"0.68636125",
"0.6701423",
"0.6674728",
"0.646471",
"0.62407786",
"0.62407786",
"0.62407786",
"0.6091799",
"0.6011328",
"0.6011328",
"0.5980501",
"0.5977851",
"0.5957151",
"0.59392357",
"0.58457243",
"0.5834206",
"0.5801399",
"0.57670504",
"0.5747486",
"0.572263... | 0.7911134 | 1 |
Returns the index of the given start date. Subclasses should define default behavior for start = None. That isn't handled here. Start can be a string or an integer if self.data.dates is None. | def _get_predict_start(self, start):
dates = self.data.dates
if isinstance(start, str):
if dates is None:
raise ValueError("Got a string for start and dates is None")
dtstart = self._str_to_date(start)
self.data.predict_start = dtstart
try:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(self, value: Any, start: int = 0, stop: int = 9223372036854775807) -> int:\n if isinstance(value, str):\n value = getattr(self, value)\n return super().index(value, start, stop)",
"def get_indices_for_start_and_end_dates(lines, startdate, enddate):\n if startdate > enddate:\... | [
"0.6237462",
"0.6043197",
"0.6005817",
"0.59620655",
"0.5915492",
"0.58372396",
"0.5765468",
"0.57453346",
"0.5734087",
"0.57179147",
"0.5700057",
"0.56639326",
"0.56639326",
"0.5638481",
"0.5627662",
"0.56263804",
"0.5608273",
"0.5594991",
"0.5594771",
"0.5572557",
"0.554843... | 0.61722726 | 1 |
Renormalize so that the peak is at a value of unity and the minimum value is zero. | def renorm(self):
self.data -= self.data.min()
self.data /= self.data.max()
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_flux(self):\n fmax = 0\n fmin = 1e99\n for n in self.graph:\n if n.flux > fmax:\n fmax = n.flux\n if n.flux < fmin:\n fmin = n.flux\n for n in self.graph:\n n.flux = (n.flux-fmin)/(fmax-fmin)",
"def minmax_no... | [
"0.7011616",
"0.69631946",
"0.67227876",
"0.6571013",
"0.65204656",
"0.65025663",
"0.6429963",
"0.6407749",
"0.63928366",
"0.63769186",
"0.6375997",
"0.6359423",
"0.6350038",
"0.634922",
"0.63451254",
"0.63389987",
"0.6326537",
"0.63177603",
"0.62938243",
"0.6293164",
"0.6281... | 0.63666284 | 11 |
Create a new ConvolutionEngine. This object is used to perform the convolution of two things, the instance should be discarded after doing so. | def __init__(self, c1, c2=None, spatial_finalization=(abs,), Q=2, pad_method='linear_ramp'):
self.c1 = c1
self.c2 = c2
self.spatial_finalization = spatial_finalization
self.Q = Q
self.pad_method = pad_method
self.spatial_x = None
self.spatial_y = None
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conv(self, other):\n e = ConvolutionEngine(self, other)\n return e.fire()",
"def convolve(self, other, mode='full'):\n if not self.compatible(other):\n raise ValueError(\"{} instances must be compatible (have bins of \"\n \"equal size and shape) to ... | [
"0.7475505",
"0.6174127",
"0.6107349",
"0.6016498",
"0.60063165",
"0.59907496",
"0.58912903",
"0.58325094",
"0.56420857",
"0.55642307",
"0.5531239",
"0.5506164",
"0.5476493",
"0.5464612",
"0.5434323",
"0.5413375",
"0.54105914",
"0.54087013",
"0.5408339",
"0.54005736",
"0.5334... | 0.0 | -1 |
check_extent() > None Makes sure left limit is less than right limit, and lower limit is less than upper limit. In other words, ensures that, immediately after the | def check_extent(self):
if self.lower_left.x > self.upper_right.x:
dlx = self.lower_left.x
self.lower_left.x = self.upper_right.x
self.upper_right.y = dlx
if self.lower_left.y > self.upper_right.y:
dly = self.lower_left.y
self.lower_left.y = s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkInBound(self,value,checkEdge):\n assert(checkEdge==0 or checkEdge==1)\n if checkEdge==0: # width\n assert(value>=0 and value<self.w)\n else:\n assert(value>=0 and value<self.h)",
"def check(self):\n self.lower_bound(5e-4)\n self.upper_bound(5e2)",... | [
"0.6588729",
"0.6540092",
"0.6471849",
"0.64596236",
"0.64591676",
"0.63633776",
"0.6347359",
"0.62776583",
"0.62022114",
"0.6195664",
"0.61871344",
"0.6115332",
"0.6110427",
"0.610017",
"0.60153145",
"0.6003828",
"0.6001943",
"0.6001682",
"0.5999328",
"0.59796566",
"0.596419... | 0.78591186 | 0 |
K correction factor to take into account tidal influences of the host star on the planetary atmosphere (from Erkaev et al. 2007). | def K_fct(a_pl, M_pl, M_star, R_pl):
AU = const.au.cgs.value
M_SUN = const.M_sun.cgs.value
M_EARTH = const.M_earth.cgs.value
R_EARTH = const.R_earth.cgs.value
if (type(M_pl) == float) or (type(M_pl) == np.float64):
# if M_pl is single value
R_roche = (a_pl*AU) \
* ((M_p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_k(self):\n\t\n\tself.k = -np.array([self.sth*self.cphi, self.sth*self.sphi, self.cth])\n\n\treturn",
"def F2K(T_F):\n return 5./9.*(T_F+459.67)",
"def f(k):\n return k * k * k * k * pk(k, suppression) * spherical_jn(0, k * r)",
"def f(k):\n return k * k * k * k * pk(k, s... | [
"0.69367003",
"0.6742401",
"0.6543646",
"0.65199226",
"0.6505585",
"0.6487021",
"0.6443187",
"0.63847476",
"0.6373113",
"0.63443893",
"0.63209134",
"0.6300363",
"0.6297922",
"0.6291968",
"0.62908477",
"0.6276572",
"0.6276572",
"0.6275026",
"0.62507194",
"0.6226852",
"0.622254... | 0.0 | -1 |
Compute softmax values for each sets of scores in x. | def softmax(x):
e_x = np.exp(x - np.max(x))
return e_x / e_x.sum() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(self, scores):\n\n\n # for each sample, for each class ,caclulate\n # np.exp(scores) : still (n_samples, n_classes)\n\n # axis = 1\n # a00, a01, a02 as a sinlge one to perfrom np_sum\n # which is the same sample \n # sum_exp : still (n_samples, 1)\n\n # ... | [
"0.7796294",
"0.7760558",
"0.7759004",
"0.77567077",
"0.76577055",
"0.76577055",
"0.76577055",
"0.76577055",
"0.7585655",
"0.743143",
"0.7407772",
"0.73941606",
"0.7358175",
"0.73174125",
"0.72689486",
"0.72623265",
"0.72614294",
"0.7256868",
"0.723019",
"0.7214918",
"0.72017... | 0.71583456 | 23 |
Apply tilde expansion and absolutization to a path. | def _fixpath(p):
return os.path.abspath(os.path.expanduser(p)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relativeToAbsoluteHomePath(path):\n if \"~\" in path:\n return path.replace(\"~\",expanduser(\"~\"))\n else:\n return path",
"def _normalized_path(path):\n return os.path.abspath(os.path.expanduser(path))",
"def _get_absolute(self, path: Path) -> Path:\n return path.expanduser... | [
"0.67730457",
"0.6398044",
"0.6370247",
"0.6354947",
"0.6306585",
"0.62351656",
"0.6195385",
"0.6143859",
"0.613771",
"0.61351126",
"0.6110445",
"0.609976",
"0.6091502",
"0.6034954",
"0.6021564",
"0.6001014",
"0.5976358",
"0.5938867",
"0.59254164",
"0.5916585",
"0.59038025",
... | 0.62935954 | 5 |
Return a list of default configuration dirs. | def find_config_dirs(project=None, prog=None, extension='.conf.d'):
return _find_config_files(project, prog, extension) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_default_paths():\n filename = os.path.join(os.path.expanduser('~'), '.gfail_defaults')\n if os.path.exists(filename):\n D = ConfigObj(filename)\n print('Default paths currently set to:\\n')\n for key in D:\n print('\\t%s = %s' % (key, D[key]))\n else:\n prin... | [
"0.7522569",
"0.750033",
"0.7335641",
"0.69914",
"0.6967185",
"0.6923748",
"0.6782982",
"0.666451",
"0.64998895",
"0.64862853",
"0.64281577",
"0.6369673",
"0.63662153",
"0.63626176",
"0.6311698",
"0.6271214",
"0.62463325",
"0.6245975",
"0.6234872",
"0.61764896",
"0.6172697",
... | 0.6039685 | 26 |
Check if default is a reference to another var. | def _default_is_ref(self):
if isinstance(self.default, str):
tmpl = self.default.replace(r'\$', '').replace('$$', '')
return '$' in tmpl
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_default(self):\r\n return self.default is not None",
"def isReference(node):\n return bool(isinstance(node, nodes.Referential)\n and node.get(DuAttrRefid, None))",
"def is_ref_known(self):\r\n \r\n if \"N\" in self.ref:\r\n return False\r\n ... | [
"0.60578936",
"0.60276395",
"0.599565",
"0.5985731",
"0.59614575",
"0.59157443",
"0.58454174",
"0.58381283",
"0.57921386",
"0.5720587",
"0.5720587",
"0.5720587",
"0.5659847",
"0.5643267",
"0.5641084",
"0.5606325",
"0.5597429",
"0.5592746",
"0.557228",
"0.55702686",
"0.5562748... | 0.7120536 | 0 |
Clear an override an opt's default value. Clear a previously set override of the default value of given option. | def clear_default(self, name, group=None):
opt_info = self._get_opt_info(name, group)
opt_info.pop('default', None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_override(self, name, group=None):\n opt_info = self._get_opt_info(name, group)\n opt_info.pop('override', None)",
"def _unset_defaults_and_overrides(self):\n for info, group in self._all_opt_infos():\n info.pop('default', None)\n info.pop('override', None)",
... | [
"0.77190924",
"0.7266398",
"0.6248375",
"0.6074347",
"0.6028291",
"0.59844416",
"0.5972622",
"0.5948366",
"0.5909248",
"0.5894575",
"0.5894575",
"0.58872086",
"0.5825965",
"0.57462126",
"0.5731998",
"0.57185876",
"0.55860066",
"0.5575102",
"0.55405176",
"0.5508069",
"0.549443... | 0.7840706 | 0 |
Return the location where the option is being set. | def get_location(self, name, group=None):
opt_group = OptGroup(group) if group is not None else None
value, loc = self._do_get(name, opt_group, None)
return loc | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_location(self):\n return self._overridden_location or self.get_default_location()",
"def location(self) -> Optional[str]:\n return pulumi.get(self, \"location\")",
"def location(self) -> Optional[str]:\n return pulumi.get(self, \"location\")",
"def location(self) -> Optional[str]... | [
"0.6903988",
"0.68077296",
"0.68077296",
"0.68077296",
"0.67958254",
"0.6782258",
"0.67711407",
"0.67711407",
"0.67711407",
"0.67711407",
"0.67711407",
"0.67711407",
"0.67711407",
"0.67711407",
"0.67711407",
"0.67711407",
"0.67711407",
"0.67711407",
"0.67711407",
"0.67711407",
... | 0.68130344 | 1 |
Construct a StrSubWrapper object. | def __init__(self, conf, group=None, namespace=None):
self.conf = conf
self.group = group
self.namespace = namespace | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args):\n _snap.TStrStrH_swiginit(self, _snap.new_TStrStrH(*args))",
"def __init__(self, *args):\n _snap.TRStr_swiginit(self, _snap.new_TRStr(*args))",
"def __init__(self, *args):\n _snap.TStr_swiginit(self, _snap.new_TStr(*args))",
"def __init__(self, *args):\n ... | [
"0.6118421",
"0.6054913",
"0.59066266",
"0.59055626",
"0.58551246",
"0.58251697",
"0.5819487",
"0.58181006",
"0.57857084",
"0.5747632",
"0.56739867",
"0.5666752",
"0.56566304",
"0.5653858",
"0.564312",
"0.56256175",
"0.5624805",
"0.5565181",
"0.55109197",
"0.5497292",
"0.5495... | 0.0 | -1 |
Check if the string is a URL. Arguments | def _is_url(s: str) -> bool:
return urlparse(s).netloc != "" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_url(string):\n return \"http\" in string",
"def is_url(string):\n try:\n urlparse(string)\n return True\n except:\n return False",
"def is_url_arg(str):\n return (True if URL_REGEX.match(str[1:-1] if is_quoted(str) else str)\n else False)",
"def __isUrl(sel... | [
"0.8706335",
"0.84683204",
"0.8213185",
"0.7959005",
"0.78763884",
"0.77912563",
"0.77738255",
"0.7770804",
"0.76906246",
"0.76355165",
"0.76232296",
"0.7603492",
"0.76028913",
"0.76008725",
"0.75710624",
"0.7571053",
"0.7384039",
"0.7357395",
"0.73455817",
"0.7325443",
"0.73... | 0.8188321 | 3 |
Returns an SCDynamicStore instance | def get_sc_store():
return SCDynamicStoreCreate(None, "crankd", handle_sc_event, None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_store(self):\n return self._store",
"def get_store(cls):\n store_path = cls.get_store_path()\n store = JsonStore(store_path)\n return store",
"def store(self) -> AbstractStore:\n if self._store is None:\n self._store = SquirrelStore(url=self.url, serialize... | [
"0.6690807",
"0.6508678",
"0.6349258",
"0.6334613",
"0.6252112",
"0.6189263",
"0.61643934",
"0.6145207",
"0.61362004",
"0.6114552",
"0.6102535",
"0.60670835",
"0.5862045",
"0.58321494",
"0.576417",
"0.57110476",
"0.56993306",
"0.5699004",
"0.56539637",
"0.5620685",
"0.5608460... | 0.7644329 | 0 |
Applies Nonmax suppression (NMS) to set of boxes | def yolo_non_max_suppression(scores, boxes, classes, max_boxes=10, iou_threshold=0.5):
# max_boxes_tensor = tf.Variable(max_boxes, dtype=tf.int32) # tensor to be used in tf.image.non_max_suppression()
# tf.InteractiveSession().run(tf.variables_initializer([max_boxes_tensor])) # initialize variable max_box... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def non_max_suppression(bboxes, iou_threshold, threshold, box_format=\"corners\"):\n\n # 49 x 6 \n assert type(bboxes) == list\n # print(bboxes)\n bboxes = [box for box in bboxes if box[1] > threshold]\n bboxes = sorted(bboxes, key=lambda x: x[1], reverse=True)\n bboxes_after_nms = []\n # prin... | [
"0.76230794",
"0.76126164",
"0.74127907",
"0.7306879",
"0.71079224",
"0.71008795",
"0.70298326",
"0.70005816",
"0.69779086",
"0.6936501",
"0.6912464",
"0.68846273",
"0.68759656",
"0.6837655",
"0.6809186",
"0.6785253",
"0.6781637",
"0.6781637",
"0.6773558",
"0.66929877",
"0.66... | 0.6980498 | 8 |
Convert YOLO box predictions to bounding box corners. | def yolo_boxes_to_corners(box_xy, box_wh):
box_mins = box_xy - (box_wh / 2.)
box_maxes = box_xy + (box_wh / 2.)
return tf.concat([
box_mins[..., 1:2], # y_min
box_mins[..., 0:1], # x_min
box_maxes[..., 1:2], # y_max
box_maxes[..., 0:1] # x_max
], axis=-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yolo_boxes_to_corners(box_xy, box_wh):\n box_mins = box_xy - (box_wh / 2.)\n box_maxes = box_xy + (box_wh / 2.)\n\n return K.concatenate([\n box_mins[..., 1:2], # y_min\n box_mins[..., 0:1], # x_min\n box_maxes[..., 1:2], # y_max\n box_maxes[..., 0:1] # x_max\n ])",
... | [
"0.68267363",
"0.6787722",
"0.66186357",
"0.6260657",
"0.6246353",
"0.6168256",
"0.6139021",
"0.61005795",
"0.5996188",
"0.5984095",
"0.5943488",
"0.58923995",
"0.58608633",
"0.5853569",
"0.5853427",
"0.5842434",
"0.58124983",
"0.58112895",
"0.5796839",
"0.5789817",
"0.578578... | 0.667874 | 2 |
Return the correct original file name of a module. | def module_file(module):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_module_name(filename: str) -> str:\n return \".\".join(_get_relative(filename).split(os.path.sep)[2:]).replace(\".pyi\", \"\").replace(\".__init__\", \"\")",
"def module_filename(module, filename):\n path, _ = os.path.split(module.__file__)\n return os.path.join(path, filename)",
"def modulen... | [
"0.7862815",
"0.75469196",
"0.7430269",
"0.729606",
"0.726982",
"0.726982",
"0.7207016",
"0.71916175",
"0.7174461",
"0.6998774",
"0.6980778",
"0.6938439",
"0.6910649",
"0.6898447",
"0.68801963",
"0.687956",
"0.6859904",
"0.6847839",
"0.6843535",
"0.68314177",
"0.68002087",
... | 0.65315896 | 29 |
Initialize the networkgit config user.email. | def __init__(self, input_dim=(3,32,32), num_filters=[32], hidden_layers=[100],
num_classes=10 ,filter_size=7, weight_scale=1e-3, reg=0, dropout=0,
use_batch_norm=False, dtype=np.float32):
self.params={}
self.use_dropout = dropout > 0
self.use_batch_norm =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initEmailCreds(sender):\n print (\"::initializing email creds...\")\n pw = getpass.getpass()\n entry = {'tardigrade': { 'username':sender, 'password':pw } }\n filepath = confighome+\"config\"\n appendJson(filepath,entry)",
"def config_email_address() -> str:\n print(\"Email address not conf... | [
"0.70603883",
"0.63110435",
"0.60520756",
"0.6023001",
"0.59611225",
"0.59531945",
"0.5931013",
"0.58767384",
"0.58584696",
"0.5823041",
"0.5774297",
"0.5745315",
"0.57134986",
"0.5713046",
"0.5696215",
"0.5696215",
"0.5696215",
"0.5696215",
"0.5696215",
"0.5696215",
"0.56962... | 0.0 | -1 |
Sets self._inside_brackets to True if left bracket found. | def visit_any_left_bracket(self, token: tokenize.TokenInfo) -> None:
self._bracket_stack.append(InconsistentComprehensionContext())
self._current_ctx = self._bracket_stack[-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def whitespace_or_bracket_before():\n d = get_app().current_buffer.document\n return bool(\n d.cursor_position == 0\n or d.char_before_cursor.isspace()\n or d.char_before_cursor in \"([{\"\n )",
"def isLeft(self):\n return self.left",
"def check_for_left(self) -> bool:\n\t\... | [
"0.60813683",
"0.58550274",
"0.5800551",
"0.5731238",
"0.57227486",
"0.5668241",
"0.55835974",
"0.5552061",
"0.5541748",
"0.55388975",
"0.55388975",
"0.5519901",
"0.55025023",
"0.5473584",
"0.54630464",
"0.5410604",
"0.5410123",
"0.5381645",
"0.53460515",
"0.5308878",
"0.5277... | 0.6285612 | 0 |
if search has nested dicts, remove them | def fix_search(search):
ends = ['w', 'l', 'i', 'n', 'f', 'p', 'x', 's']
if not search:
return
if isinstance(search, STRINGTYPE):
return search
if search.get('t'):
return search
newsearch = {}
for srch, pat in search.items():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop_non_relevant_search_fields(data: Dict):\n keys_to_keep = [\"title\", \"published_at\", \"identifier\"]\n for key in list(data):\n if key not in keys_to_keep:\n data.pop(key)",
"def remove_and_prune(a_dict, b_dict):\n for k in b_dict:\n if isinstance(b_dict[k], dict):\n ... | [
"0.7018232",
"0.6561164",
"0.63609487",
"0.6350369",
"0.6308525",
"0.6303163",
"0.61509377",
"0.6096511",
"0.60937995",
"0.60914725",
"0.6041254",
"0.5969095",
"0.5960998",
"0.5947356",
"0.5933058",
"0.59080493",
"0.5887565",
"0.5875051",
"0.5849548",
"0.5839574",
"0.5776645"... | 0.0 | -1 |
Test generate_random_sphere_vector to verify that the object normalized_vector is a 3D array with nonzero components and a norm of one. | def test_random_sphere_vector():
test_vector = o_gen_instance.generate_random_sphere_vector()
assert isinstance(test_vector, np.ndarray)
assert test_vector.shape == (3,)
for component in test_vector:
assert component != 0.
assert np.isclose(np.linalg.norm(test_vector), 1.0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_sphere():\n vec = np.random.standard_normal(3)\n return vec / np.linalg.norm(vec)",
"def test_norm_vector():\n random_state = np.random.RandomState(0)\n for n in range(1, 6):\n v = pr.random_vector(random_state, n)\n u = pr.norm_vector(v)\n assert_almost_equal(np.linalg.no... | [
"0.79352826",
"0.7224374",
"0.6926471",
"0.6906835",
"0.6901551",
"0.684564",
"0.67936563",
"0.6673033",
"0.6651192",
"0.6604039",
"0.6603412",
"0.6575389",
"0.6544342",
"0.6538467",
"0.6474279",
"0.64473206",
"0.6388019",
"0.6329042",
"0.63280094",
"0.6316557",
"0.63050807",... | 0.90886253 | 0 |
Find completion matches for the given text. Given the user's input text and a collection of available completions, find completions matching the last word of the text. If `start_only` is True, the text will match an available completion only at the beginning. Otherwise, a completion is considered a match if the text ap... | def find_matches(text, collection, start_only=False, fuzzy=True, casing=None):
last = last_word(text, include='most_punctuations')
text = last.lower()
completions = []
if fuzzy:
regex = '.*?'.join(map(re.escape, text))
pat = re.compile('(%s)' % regex)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_completion(self, original_text, remaining_text, options):\n if self.should_hide_completions(original_text=original_text,\n remaining_text=remaining_text,\n allowed_suffixes=(\" \", \".\")):\n return []\n\n ... | [
"0.5681952",
"0.5329823",
"0.527169",
"0.52684486",
"0.5164248",
"0.5139905",
"0.5139905",
"0.5129241",
"0.51232123",
"0.5080964",
"0.5075695",
"0.50329864",
"0.50222737",
"0.49978027",
"0.49869835",
"0.4973639",
"0.49638003",
"0.49585158",
"0.49314818",
"0.49203762",
"0.4902... | 0.659969 | 0 |
Decorator that caches return value of method based on args and kwargs, cache value stored in the object instance | def cache_method_result(func: _t.Callable) -> _t.Callable:
name: _t.Text = f'__cache_{func.__name__}'
def wrapper(self, *args, **kwargs):
result = getattr(self, name, None)
if result is None or result[0] != args or result[1] != kwargs:
result = (args, kwargs, func(self, *args, **kw... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrapper(*args, **kwargs):\n\n result = caching_services.try_get(name, method, args,\n kwargs, **options)\n if result is not None:\n return result\n\n result = method(*args, **kwargs)\n caching_services.try_s... | [
"0.80784196",
"0.80025035",
"0.76318836",
"0.7538034",
"0.7505437",
"0.74832314",
"0.7473139",
"0.7456825",
"0.741934",
"0.73985386",
"0.73948026",
"0.7358792",
"0.7347225",
"0.73286",
"0.7301686",
"0.72526693",
"0.72483146",
"0.72456825",
"0.7228972",
"0.72104114",
"0.716637... | 0.77771443 | 2 |
Returns a function that maps each index in 0, 1, ..., n1 to a distinct RGB color; the keyword argument name must be a standard mpl colormap name. | def get_cmap(n, name='hsv'):
return plt.cm.get_cmap(name, n) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cmap(n, name='jet'):\n return plt.cm.get_cmap(name, n)",
"def get_cmap(n, name='Paired'):\n return plt.cm.get_cmap(name, n)",
"def get_cmap(n, name=\"hsv\"):\n return plt.cm.get_cmap(name, n)",
"def get_cmap(n, name=\"hsv\"):\n return plt.cm.get_cmap(name, n)",
"def get_cmap(n, name=\"h... | [
"0.7025025",
"0.6943994",
"0.69275856",
"0.69275856",
"0.69275856",
"0.67215765",
"0.65778434",
"0.65096295",
"0.64259195",
"0.6359199",
"0.6328814",
"0.62854236",
"0.6180951",
"0.6138011",
"0.61124665",
"0.60948807",
"0.6041402",
"0.60194355",
"0.59901917",
"0.59601426",
"0.... | 0.69756675 | 2 |
Return a learning rate scheduler | def get_scheduler(optimizer, opt):
def lambda_rule(epoch):
lr_l = 1.0 - max(0, epoch + opt.epoch_count - opt.n_epochs) / float(opt.n_epochs_decay + 1)
return lr_l
scheduler = lr_scheduler.LambdaLR(optimizer, lr_lambda=lambda_rule)
return scheduler | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_scheduler(optimizer, opt):\n \n epochs_no_decay = opt.epochs - opt.lr_linear\n lr_policy = opt.lr_policy\n \n if lr_policy == 'linear':\n def lr_lambda(epoch):\n return 1. - max(0, epoch - epochs_no_decay) / float(opt.lr_linear + 1)\n scheduler = lr_scheduler.LambdaL... | [
"0.79357445",
"0.7631841",
"0.7620658",
"0.7587395",
"0.7579604",
"0.7452581",
"0.744563",
"0.74281615",
"0.7386596",
"0.73817253",
"0.7357768",
"0.7288603",
"0.7218676",
"0.7204649",
"0.7161282",
"0.71557266",
"0.71433187",
"0.7125463",
"0.7121791",
"0.71167016",
"0.71072483... | 0.7450352 | 6 |
Initialize network weights. Possibilities are 'Normal' and 'Xavier' | def init_weights(net, init_gain=0.02):
def init_func(m): # define the initialization function
classname = m.__class__.__name__
if hasattr(m, 'weight') and (classname.find('Conv') != -1 or classname.find('Linear') != -1):
init.normal_(m.weight.data, 0.0, init_gain)
if hasattr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialize_weights(self):\n pass",
"def init_weights(self) -> None:\n nn.init.kaiming_normal_(self._U)\n nn.init.kaiming_normal_(self._W)\n nn.init.kaiming_normal_(self._V)\n\n nn.init.normal_(self._b)",
"def _init_weights(self):\n nn.init.xavier_normal_(self.out.... | [
"0.81939334",
"0.8158301",
"0.8110464",
"0.80753744",
"0.79489106",
"0.791322",
"0.7900379",
"0.78920627",
"0.77977157",
"0.7767634",
"0.7767634",
"0.7767634",
"0.7752601",
"0.7694178",
"0.76760465",
"0.76733345",
"0.7660916",
"0.7644418",
"0.762559",
"0.7623797",
"0.7615727"... | 0.7370748 | 55 |
Create label tensors with the same size as the input. | def get_target_tensor(self, prediction, target_is_real):
if target_is_real:
target_tensor = self.real_label
else:
target_tensor = self.fake_label
return target_tensor.expand_as(prediction) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_labels(n_samples):\n return np.ones([n_samples, 1]), np.zeros([n_samples, 1])",
"def prepare_label(input_batch, new_size, num_classes, one_hot=True, task='seg'):\n with tf.name_scope('label_encode'):\n input_batch = tf.image.resize_nearest_neighbor(input_batch, new_size) # as labels are... | [
"0.7334109",
"0.7140496",
"0.71153593",
"0.7086969",
"0.70147705",
"0.69324046",
"0.6846251",
"0.68401986",
"0.67875797",
"0.6771887",
"0.6746952",
"0.6703911",
"0.6692927",
"0.66772044",
"0.65051234",
"0.6464831",
"0.6432414",
"0.6425861",
"0.64061236",
"0.63710165",
"0.6313... | 0.0 | -1 |
Adds a vertex to the graph | def add_vertex(self, vertex):
self.vertices.append(vertex)
self.vertex_edge[vertex] = [] | {
"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 if vertex.id not in self.vertices.keys():\n self.vertices[vertex.id] = vertex",
"def add_vertex(self, vertex_name: n):\n new_v... | [
"0.8787163",
"0.85861397",
"0.8467963",
"0.8440575",
"0.8350336",
"0.82913667",
"0.82033414",
"0.81121296",
"0.81121296",
"0.8089776",
"0.80505913",
"0.8043786",
"0.7982978",
"0.7977509",
"0.7963215",
"0.7961272",
"0.796055",
"0.79558057",
"0.79527986",
"0.78824633",
"0.78582... | 0.84251016 | 4 |
Adds an edge to the graph | def add_edge(self, source_vertex, destination_vertex):
self.vertex_edge[source_vertex].append(destination_vertex)
new_edge = GraphEdge(source_vertex, destination_vertex)
if destination_vertex not in self.vertex_edge:
self.edges.append(new_edge) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(self, edge):\n if(self.has_edge(edge) == 0):\n self.__graph_dict[edge[0]].append(edge[1])",
"def add_edge(self, edge):\n src = edge.get_source()\n dest = edge.get_destination()\n #weightEdge = WeightedEdge(src, dest, edge.get_total_distance(), edge.get_outdoor_... | [
"0.8500494",
"0.8482894",
"0.8313779",
"0.82899714",
"0.8272254",
"0.82677686",
"0.82669777",
"0.82085985",
"0.8175204",
"0.8161914",
"0.8152684",
"0.8150967",
"0.8071292",
"0.80292875",
"0.8000602",
"0.7971441",
"0.7953097",
"0.7943503",
"0.7910237",
"0.789463",
"0.7860954",... | 0.78532517 | 21 |
Creates a new FFNN model to represent a policy. Implements all needed methods from tf.keras.Model. | def __init__(self, model_path: Path, layer_size: int, learning_rate: float,
hidden_layers_count: int, activation: str="relu"):
super(FeedForwardPolicyGradientModel, self).__init__()
self.model_path = model_path
self.layer_size = layer_size
self.outpu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(self) -> tf.keras.models.Model:\n raise NotImplementedError()",
"def _create_nn(self):\n with tf.name_scope('policy_network'):\n with tf.variable_scope(\"policy_network\"):\n model = tf.keras.Sequential(name='policy_network_model')\n model.add(tf.... | [
"0.69288975",
"0.6927684",
"0.6668381",
"0.656694",
"0.65594894",
"0.6511043",
"0.63573056",
"0.6342833",
"0.6316973",
"0.62949574",
"0.6283353",
"0.62771636",
"0.6260603",
"0.6205826",
"0.620048",
"0.6187116",
"0.6172914",
"0.6167201",
"0.6165835",
"0.6118449",
"0.61008894",... | 0.0 | -1 |
returns true if the cmyk values are between 0 and 255 | def checkValue(c, m, y, k):
MINVAL=0
MAXVAL=255
valueOk=True
for val in c, m, y, k:
if val >=MINVAL and val <=255:
pass
else:
valueOk=False
return valueOk | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_0to255(value):\n return 0 <= value <= 255",
"def inside_gamut(rgb: ndarray) -> bool:\n return all(rgb >= 0)",
"def has_valid_channel_values(rgb_coll):\n return all([is_0to255(c) and is_int(c) for c in rgb_coll])",
"def validate(c_name, val):\n n = 80\n threshold = 4\n while (threshol... | [
"0.7696764",
"0.6565392",
"0.64692634",
"0.63556695",
"0.63285995",
"0.6285347",
"0.6242104",
"0.6236757",
"0.6173846",
"0.6173846",
"0.61536485",
"0.6117954",
"0.60981804",
"0.6077521",
"0.6021677",
"0.60151637",
"0.60123754",
"0.5974014",
"0.5965677",
"0.5964167",
"0.595889... | 0.7365734 | 1 |
Initialiseert een nieuwe hashmap met gegeven grootte n. Type geeft | def __init__(self, type, n):
self.type = type
if type == "sep":
self.items = [LinkedChainTable()]*n # regel waar implementatie van seperate chaining kan verandert worden
else:
self.items = [None]*n
self.n = n | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init___0(self, map):\n super(LongObjectHashMap, self).__init__()\n self.__init__()\n putAll(map)",
"def __init__(self):\n self.map = {}",
"def __init__(self):\n self._map = {}",
"def __init__(self):\n super(LongObjectHashMap, self).__init__()\n initializ... | [
"0.68588626",
"0.6810968",
"0.6698458",
"0.6683915",
"0.6640655",
"0.6640655",
"0.6618927",
"0.65846485",
"0.64746755",
"0.64397156",
"0.63330406",
"0.6309619",
"0.6301957",
"0.6301225",
"0.62196916",
"0.62196916",
"0.61573774",
"0.61573774",
"0.61573774",
"0.61573774",
"0.61... | 0.0 | -1 |
Returns List[Category] List of all categories that could potentially returned by classify() | def categories(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def categories(self) -> List[Category]:\n return list(set(self.mapping.values()))",
"def categories(self):\n game_categories = self.game_categories.all()\n return [ gc.category for gc in game_categories ]",
"def get_list(self):\n categories = []\n for attribut in self.attribu... | [
"0.7509363",
"0.74593574",
"0.7377025",
"0.72826576",
"0.72070694",
"0.7142708",
"0.71337545",
"0.7092652",
"0.7066633",
"0.70282346",
"0.7025826",
"0.6975605",
"0.6932335",
"0.69284004",
"0.6925354",
"0.69179225",
"0.68683857",
"0.68316513",
"0.68314976",
"0.6820639",
"0.681... | 0.6858113 | 17 |
All unique categories used in this classifier | def categories(self) -> List[Category]:
return list(set(self.mapping.values())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def categories(self):\n\t\treturn (sorted(self.dictData.keys()))",
"def categoricals(self):\n return base_64_to_object(self.categorical_hyperparameters_64)",
"def categories(self):\n return self.__categories",
"def getCategories(self):\n return self.categories.keys()",
"def cat... | [
"0.7506106",
"0.73227334",
"0.7208265",
"0.72041124",
"0.72034353",
"0.7166425",
"0.71495",
"0.71364886",
"0.7104631",
"0.7028423",
"0.69927675",
"0.6977006",
"0.696788",
"0.69555587",
"0.6951241",
"0.69501936",
"0.6931314",
"0.6906976",
"0.68834436",
"0.68730456",
"0.6836062... | 0.7444617 | 1 |
Return the dot product of u and v | def dot_prod(u,v):
each_product = []
for i in range(len(u)):
each_product.append(u[i] * v[i])
return sum(each_product) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dot_vectors(u, v):\n return u[0] * v[0] + u[1] * v[1] + u[2] * v[2]",
"def dot_product(u, v):\n ret = 0.0\n for i in range(len(u)):\n ret += float(float(u[i]) * float(v[i]))\n return ret",
"def dotProduct(self, v):\n return self.x * v.x + self.y * v.y + self.z * v.z",
"def vdot(... | [
"0.88434124",
"0.87971246",
"0.84556437",
"0.8388875",
"0.8314668",
"0.82218444",
"0.8206603",
"0.8158425",
"0.8104789",
"0.80998814",
"0.80542636",
"0.8036317",
"0.800122",
"0.800122",
"0.800122",
"0.800122",
"0.800122",
"0.7995578",
"0.79905415",
"0.7988564",
"0.7980413",
... | 0.82813966 | 5 |
Return list of pythagorean triples as nondescending tuples of ints from 1 to n. Assume n is positive. | def pythagorean_triples(n):
triples = []
for i in range(1,n+1):
for j in range(1, n+1):
for k in range(1, n+1):
if i**2 + j**2 == k**2 and i <= j <= k:
triples.append((i,j,k))
return triples | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pythagorean_triples(n):\n l = []\n # loop over all a < b < c <= n\n for c in range(1, n + 1):\n for b in range(1, c):\n for a in range(1, b):\n if a*a + b*b == c*c:\n l.append((a, b, c))\n return l",
"def Pythagorean_Triplets(n):\n for num in... | [
"0.8094776",
"0.72984177",
"0.727847",
"0.7146135",
"0.6965781",
"0.67307967",
"0.66383916",
"0.648162",
"0.6431071",
"0.6350643",
"0.6244063",
"0.6171055",
"0.611668",
"0.6079294",
"0.6068943",
"0.6055166",
"0.604777",
"0.60399395",
"0.602407",
"0.60153395",
"0.6008699",
"... | 0.7996597 | 1 |
Apply the four rules of the game to the current game grid. Creates a new_grid to be manipulated by the rules. Nested forloop runs through the rows and columns of a 2D list. Each neighbor of the cell of interest is identified and neighbor totals are calculated. If statements are used to implement the rules of the game. | def make_move(grid, n_columns, n_rows):
# Generate the game grid to be manipulated
new_grid = [[0] * (n_columns + 1) for i in range(n_rows + 1)]
for i in range(n_rows):
for j in range(n_columns):
upper_left = grid[i-1][j-1] # neighbor to upper left of cell of interest
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_grid(self):\n\n screen.fill(GREY)\n\n for row in self.grid:\n for cell in row:\n if cell.root:\n color = GREEN\n elif cell.goal:\n color = RED\n elif cell.value:\n color = DARK_BL... | [
"0.6495653",
"0.64484656",
"0.642264",
"0.6191768",
"0.6130129",
"0.6080801",
"0.6049253",
"0.59872615",
"0.59566456",
"0.58835655",
"0.5882744",
"0.58461547",
"0.5834441",
"0.57707757",
"0.57700586",
"0.5746112",
"0.57235205",
"0.5721528",
"0.57213503",
"0.57207745",
"0.5719... | 0.6888119 | 0 |
Revert all settings to their defaults. Database settings do not automatically apply to open connections. | def setdefaults(self):
self.config = {
'dbuser': Infopage.DEFAULT_DBUSER,
'dbname': Infopage.DEFAULT_DBNAME,
'dbpassword': Infopage.DEFAULT_DBPASSWORD,
'dbhost': Infopage.DEFAULT_DBHOST
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_settings():\n settings = Settings()\n settings.reset()\n settings.save()",
"def reset(self):\n self.manager.delete_all()\n for name, val in DEFAULT_SETTINGS.items():\n val['name'] = name\n val['default_value'] = val['value']\n self.manager.from_di... | [
"0.74593943",
"0.7051543",
"0.6810418",
"0.67957395",
"0.6638111",
"0.6580477",
"0.64899087",
"0.6472318",
"0.64488715",
"0.64437187",
"0.6438868",
"0.64087504",
"0.6351835",
"0.6312363",
"0.63119817",
"0.6279463",
"0.6278628",
"0.6267052",
"0.6263454",
"0.6231329",
"0.618367... | 0.64831877 | 7 |
Close the open database connection | def close(self):
if self.conn is not None:
self.conn.close()
self.conn = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_db_connection(cls):\n db.close()",
"def close_database(self):\n if self._conn is not None:\n self._conn.close()\n self._conn = None",
"def close(self):\n if self._dbopen:\n self._dbcon.close()",
"def close(self):\n Log.debug('DB -> close'... | [
"0.888187",
"0.86910784",
"0.8661716",
"0.8572991",
"0.8401916",
"0.8352514",
"0.82957244",
"0.8284722",
"0.8247352",
"0.8231512",
"0.8221038",
"0.817572",
"0.8142638",
"0.8135985",
"0.8135985",
"0.8135985",
"0.81020117",
"0.8054716",
"0.80532515",
"0.8031756",
"0.80248314",
... | 0.0 | -1 |
Need this to use == operator | def __eq__(self,other):
if type(other)==type(""):
return self.word == other
return self.word == other.word | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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",
"def __eq__(self,*args):\r\n pass",
"def __eq__(self,*args):\r\n pass",
"def __eq__(self,*args):\r\n pass",
"def... | [
"0.7765659",
"0.7765659",
"0.7765659",
"0.7765659",
"0.7765659",
"0.7765659",
"0.7765659",
"0.7765659",
"0.7765659",
"0.7765659",
"0.7765659",
"0.7765659",
"0.7765659",
"0.7765659",
"0.7765659",
"0.7765659",
"0.7765659",
"0.7765659",
"0.7765659",
"0.7765659",
"0.7722746",
"... | 0.0 | -1 |
Test case for projects_id_comments_patch You can't put the entire List | def test_projects_id_comments_patch(self):
project = Comment()
response = self.client.open('/project-tracker/projects/{id}/comments'.format(id=56),
method='PATCH',
data=json.dumps(project),
conten... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_issue_get_comments(self):\n pass",
"def test_issue_edit_comment(self):\n pass",
"def test_projects_id_comments_post(self):\n project = Comment()\n response = self.client.open('/project-tracker/projects/{id}/comments'.format(id=56),\n metho... | [
"0.7005537",
"0.6911109",
"0.6698229",
"0.66503316",
"0.662829",
"0.6614505",
"0.6596675",
"0.65016913",
"0.6436199",
"0.6340969",
"0.62965775",
"0.62892133",
"0.62499595",
"0.6141073",
"0.6132673",
"0.6094428",
"0.6094136",
"0.60626733",
"0.60514086",
"0.6017415",
"0.6001806... | 0.75987107 | 0 |
Test case for projects_put You shouldn't put the entire List | def test_projects_put(self):
project = Project()
response = self.client.open('/project-tracker/projects',
method='PUT',
data=json.dumps(project),
content_type='application/json')
self.asse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_put_list_replace(self):\n for proj in Project.objects.all():\n ProjectMembership.objects.create(user=self.user,\n project=proj)\n self.user.save()\n self.story.projects.add(*list(Project.objects.filter(projecttranslation__name__in=(\"Finding a Bite: Food ... | [
"0.83744097",
"0.8195241",
"0.8106585",
"0.7228424",
"0.71508354",
"0.7128427",
"0.705452",
"0.67779267",
"0.6715903",
"0.66805834",
"0.6666764",
"0.6637439",
"0.6603797",
"0.66016567",
"0.66016567",
"0.6554031",
"0.65434396",
"0.65143204",
"0.65113086",
"0.6491051",
"0.64766... | 0.70465624 | 7 |
Return the version of the Processing Block Device. | def version(self):
return tango_pb_device_version | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pb_version(self):\n pb = ProcessingBlock(self._pb_id)\n return pb.version",
"def version(self):\n data = self._ftdi.spi_read(self.VERSION_ADDR, len=1, burst='fixed')\n return data[0] & self.VERSION_MASK",
"def get_firmware_version(self):\n request_command = self.parser_in... | [
"0.7834875",
"0.74734384",
"0.7226713",
"0.71845275",
"0.7135659",
"0.7054146",
"0.70400465",
"0.7019371",
"0.698877",
"0.69734764",
"0.69401723",
"0.68796974",
"0.68760043",
"0.6811419",
"0.67835605",
"0.67699826",
"0.6728901",
"0.6724566",
"0.671848",
"0.66900724",
"0.66681... | 0.71394897 | 4 |
Return the Processing block ID for this device. | def pb_id(self):
return self._pb_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sbi_id(self):\n pb = ProcessingBlock(self._pb_id)\n return pb.sbi_id",
"def get_block_id(self):\n return self._block_id",
"def read_ProcessingBlockList(self):\n # PROTECTED REGION ID(SdpMasterLeafNode.ProcessingBlockList_read) ENABLED START #\n return self.attr_map[\"Proc... | [
"0.7039438",
"0.6580052",
"0.65137804",
"0.6424397",
"0.62915796",
"0.62824583",
"0.62824583",
"0.6210337",
"0.6184827",
"0.60902727",
"0.60077965",
"0.5856252",
"0.5838093",
"0.5792409",
"0.5729835",
"0.5678293",
"0.56738454",
"0.56352526",
"0.5625952",
"0.5613813",
"0.55568... | 0.5912305 | 11 |
Set the PB Id for this device. | def pb_id(self, pb_id: str):
# FIXME(BMo) instead of creating the object to check if the PB exists
# use a method on PB List?
# ProcessingBlock(pb_id)
self.set_state(DevState.ON)
self._pb_id = pb_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pb_id(self):\n return self._pb_id",
"def set_id(self, player_id):\n pass",
"def setID(self, idNb):\n self._id = idNb",
"def _set_id(self, value):\n pass",
"def player_b_id(self, player_b_id):\n\n self._player_b_id = player_b_id",
"def id(self, value):\n self.... | [
"0.64966524",
"0.61853826",
"0.6152964",
"0.6044323",
"0.6015985",
"0.6005453",
"0.5963273",
"0.59582216",
"0.58882314",
"0.5859666",
"0.5859666",
"0.5805439",
"0.57847154",
"0.5782313",
"0.57800746",
"0.5720057",
"0.5719524",
"0.57154655",
"0.5713418",
"0.56911194",
"0.55721... | 0.73184115 | 0 |
Return the PB configuration. | def pb_config(self):
pb = ProcessingBlock(self._pb_id)
return json.dumps(pb.config) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configuration(self) -> pulumi.Output['outputs.BrokerConfiguration']:\n return pulumi.get(self, \"configuration\")",
"def get_pb(cls):\n if cls.pb_singleton is None:\n # Init the config by reading conf file.\n with open(gflags.FLAGS.conf, 'r') as conf_file:\n ... | [
"0.76365185",
"0.7633313",
"0.74884564",
"0.7473088",
"0.7473088",
"0.73817724",
"0.7318932",
"0.7239872",
"0.7233952",
"0.72292024",
"0.72205544",
"0.7214669",
"0.7179086",
"0.7162158",
"0.71597296",
"0.71597296",
"0.71597296",
"0.71597296",
"0.71597296",
"0.71597296",
"0.71... | 0.81213135 | 0 |
pick one beyond minimal value in a list. return the index of the element | def pickMinRandomly(a):
listMin = []
m = np.min(a)
for i,e in enumerate(a):
if e == m:
listMin.append(i)
#~ print(m)
#~ listMin = np.where(a==m)[0]
return listMin[random.randint(0,len(listMin)-1)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_min(list):\n return find_value_at(list, -1)",
"def __idx_of_minimum(cls, lst: list) -> int:\n\t\treturn lst.index(min(lst))",
"def smallest_elem_index(input_list):\n if len(input_list) == 0:\n raise Exception(\"List must contain at least 1 element\")\n \n min_index = 0 \n for i i... | [
"0.85527766",
"0.8157126",
"0.76822233",
"0.75406045",
"0.7499388",
"0.7395434",
"0.7367144",
"0.73029804",
"0.72871995",
"0.7240269",
"0.7239049",
"0.72320753",
"0.72235835",
"0.7215573",
"0.7135333",
"0.71179044",
"0.70990556",
"0.7092684",
"0.70821023",
"0.70224696",
"0.70... | 0.62468237 | 86 |
Initialize source loss module. | def __init__(self,
sampling_rate,
hop_size,
fft_size,
f0_floor,
f0_ceil,
uv_threshold=0,
q1=-0.15):
super(SourceLoss, self).__init__()
self.cheaptrick = CheapTrick(sampling_rate=sampl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initLoss(self):\n\n pass",
"def __init__(self, modules, loss_fn):\n\n super().__init__()\n self.modules = modules\n self.loss_fn = loss_fn",
"def __init__(self, source):\n self._source = source",
"def _initLoss(self):\n\n return torch.nn.MSELoss()",
"def __ini... | [
"0.71451145",
"0.6502135",
"0.63599026",
"0.62476224",
"0.6222252",
"0.6204144",
"0.6143606",
"0.6143606",
"0.61238533",
"0.61194986",
"0.6092342",
"0.6028665",
"0.59298074",
"0.59224313",
"0.59224313",
"0.5902171",
"0.5869834",
"0.58684933",
"0.5866831",
"0.58570147",
"0.583... | 0.54401165 | 50 |
Verify that the Unpacker has a reasonable state when it is first constructed. | def test_constructor_state(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
p = Unpacker(config, logger_mock)
assert p.last_work_begin_timestamp is p.last_work_end_timestamp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanity_check(self):\n pass",
"def _check_initialized(self):\n self.assertEquals(0, self._error_count)\n self.assertEquals(0, len(self._error_messages))",
"def check_state(self):\n pass",
"def test_constructor_missing_config():\n with pytest.raises(TypeError):\n Unpac... | [
"0.6263604",
"0.62551486",
"0.6254808",
"0.6216785",
"0.61777383",
"0.61777383",
"0.6158712",
"0.61534536",
"0.61313677",
"0.61311907",
"0.611405",
"0.5982184",
"0.5978936",
"0.5948849",
"0.5830854",
"0.58068204",
"0.57835066",
"0.57656497",
"0.57650167",
"0.5762708",
"0.5758... | 0.6736872 | 0 |
Verify that the Unpacker has no additional state to offer. | def test_do_status(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
p = Unpacker(config, logger_mock)
assert p._do_status() == {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_state(self):\n pass",
"def test_ensure_state_untouched_if_not_necessary(self, setState):\n advisory = errata.Advisory(errata_id=123, errata_state='QE')\n advisory.ensure_state('QE')\n setState.assert_not_called()",
"def test_block_bad_state(self):\n pass",
"def ve... | [
"0.6599915",
"0.6227758",
"0.6219967",
"0.6165108",
"0.6077323",
"0.6067991",
"0.59909546",
"0.5981062",
"0.59618324",
"0.59585756",
"0.5951633",
"0.59358555",
"0.5933014",
"0.5928011",
"0.5909257",
"0.5899416",
"0.589422",
"0.58827335",
"0.58677477",
"0.5838934",
"0.5831037"... | 0.0 | -1 |
Test that _update_bundle_in_lta_db updates the status of the bundle in the LTA DB. | async def test_unpacker_update_bundle_in_lta_db(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
lta_rc_mock = mocker.patch("rest_tools.client.RestClient", new_callable=AsyncMock)
p = Unpacker(config, logger_mock)
assert await p._update_bundle_in_lta_db(lta_rc_mock, {"uuid": "c4b345e4-23... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_bundle_2(self):\n self.bndl.ticket = None\n import_genome.check_bundle(self.bndl,\n ticket_ref=\"ticket\",\n file_ref=\"flat_file\",\n retrieve_ref=\"phagesdb\",\n ... | [
"0.6499748",
"0.6375098",
"0.63195056",
"0.62923455",
"0.62595326",
"0.61508405",
"0.61508405",
"0.61508405",
"0.6130336",
"0.6129345",
"0.60776377",
"0.60384524",
"0.6009847",
"0.6008804",
"0.59955597",
"0.5994568",
"0.59913254",
"0.59864956",
"0.5981181",
"0.593282",
"0.589... | 0.71887296 | 0 |
Test that _delete_manifest_metadata will delete metadata of either version. | def test_unpacker_delete_manifest_metadata_v3(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
p = Unpacker(config, logger_mock)
mock_os_remove = mocker.patch("os.remove")
mock_os_remove.side_effect = [NameError, None]
p._delete_manifest_metadata("0869ea50-e437-443f-8cdb-31a350f88e57... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unpacker_delete_manifest_metadata_unknown(config, mocker, path_map_mock):\n logger_mock = mocker.MagicMock()\n p = Unpacker(config, logger_mock)\n mock_os_remove = mocker.patch(\"os.remove\")\n mock_os_remove.side_effect = [NameError, NameError]\n with pytest.raises(NameError):\n p._... | [
"0.68494916",
"0.6320009",
"0.6316312",
"0.62980163",
"0.6202315",
"0.5990099",
"0.59865844",
"0.59578156",
"0.5951433",
"0.594975",
"0.5945878",
"0.5921927",
"0.5902222",
"0.58407366",
"0.5838764",
"0.583026",
"0.58298224",
"0.58037287",
"0.5794836",
"0.57929486",
"0.579052"... | 0.74787045 | 0 |
Test that _delete_manifest_metadata will throw on an unknown version. | def test_unpacker_delete_manifest_metadata_unknown(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
p = Unpacker(config, logger_mock)
mock_os_remove = mocker.patch("os.remove")
mock_os_remove.side_effect = [NameError, NameError]
with pytest.raises(NameError):
p._delete_manife... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unpacker_delete_manifest_metadata_v3(config, mocker, path_map_mock):\n logger_mock = mocker.MagicMock()\n p = Unpacker(config, logger_mock)\n mock_os_remove = mocker.patch(\"os.remove\")\n mock_os_remove.side_effect = [NameError, None]\n p._delete_manifest_metadata(\"0869ea50-e437-443f-8cdb... | [
"0.7372555",
"0.6441587",
"0.62728256",
"0.6213908",
"0.6173617",
"0.61352557",
"0.6132365",
"0.6121432",
"0.6107993",
"0.61024123",
"0.6098416",
"0.6049859",
"0.60365367",
"0.6020899",
"0.5971693",
"0.59376717",
"0.5902457",
"0.5899617",
"0.589082",
"0.5890105",
"0.58641493"... | 0.7510625 | 0 |
Test that _read_manifest_metadata will throw on an unknown version. | def test_unpacker_read_manifest_metadata_unknown(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
p = Unpacker(config, logger_mock)
mock_v2 = mocker.patch("lta.unpacker.Unpacker._read_manifest_metadata_v2")
mock_v2.side_effect = [None]
mock_v3 = mocker.patch("lta.unpacker.Unpacker._r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unpacker_read_manifest_metadata_v3_no_throw(file_open_mock, config, mocker, path_map_mock):\n logger_mock = mocker.MagicMock()\n file_open_mock.side_effect = NameError\n p = Unpacker(config, logger_mock)\n assert not p._read_manifest_metadata_v3(\"0869ea50-e437-443f-8cdb-31a350f88e57\")",
"d... | [
"0.7169583",
"0.7081144",
"0.6739161",
"0.6642735",
"0.64975154",
"0.6303252",
"0.6300239",
"0.6251104",
"0.62317026",
"0.61887234",
"0.61170816",
"0.61137027",
"0.6109315",
"0.6099843",
"0.60819846",
"0.60760486",
"0.6066707",
"0.6066453",
"0.6053334",
"0.6042419",
"0.604208... | 0.73456854 | 0 |
Test that _read_manifest_metadata_v3 will not throw when unable to read metadata. | def test_unpacker_read_manifest_metadata_v3_no_throw(file_open_mock, config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
file_open_mock.side_effect = NameError
p = Unpacker(config, logger_mock)
assert not p._read_manifest_metadata_v3("0869ea50-e437-443f-8cdb-31a350f88e57") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unpacker_read_manifest_metadata_for_v3(config, mocker, path_map_mock):\n logger_mock = mocker.MagicMock()\n p = Unpacker(config, logger_mock)\n mock_v2 = mocker.patch(\"lta.unpacker.Unpacker._read_manifest_metadata_v2\")\n mock_v2.side_effect = [None]\n mock_v3 = mocker.patch(\"lta.unpacker... | [
"0.6892553",
"0.6883256",
"0.6865995",
"0.65582126",
"0.65180963",
"0.63612777",
"0.6188923",
"0.6170187",
"0.60026217",
"0.59894437",
"0.59743226",
"0.5963816",
"0.59482044",
"0.58974534",
"0.5895962",
"0.5818921",
"0.58149624",
"0.58108026",
"0.5777837",
"0.5769291",
"0.576... | 0.75113803 | 0 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
if normalize:
cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
print("Normalized confusion matrix")
else:
... | {
"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.8194862",
"0.80949175",
"0.8029915",
"0.8019153",
"0.79941195",
"0.7991258",
"0.7980955",
"0.7976606",
"0.79610753",
"0.79590565",
"0.79378676",
"0.7934962",
"0.7934504",
"0.79313844",
"0.7926313",
"0.7924577",
"0.79241234",
"0.7923211",
"0.7923023",
"0.7921931",
"0.791787... | 0.7856715 | 42 |
Returns the Young Modulus of a material in N/m^2 | def YoungModulus(material):
if material == "mild":
return 200e9
else:
if material == "al":
return 69e9
else:
raise ValueError("Invalid material `"+material+"'") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _calc_young_modulus(dataset: np.ndarray) -> YoungModulus:\n segment_x_length: int = len(dataset) // 10\n max_derivative_index = np.argmax([\n dataset[i + segment_x_length][1] - dataset[i][1]\n for i in range(len(dataset) - segment_x_length)\n ])\n first_point = dataset[max_derivative_... | [
"0.67148286",
"0.61187845",
"0.58572924",
"0.5819239",
"0.579422",
"0.5661844",
"0.559946",
"0.5591879",
"0.55850786",
"0.5577663",
"0.5567218",
"0.55623007",
"0.5491746",
"0.5478498",
"0.5471267",
"0.5455068",
"0.54468375",
"0.54108715",
"0.54105854",
"0.5386188",
"0.5383324... | 0.8423878 | 0 |
Returns the density of a material in kg/m^3 | def Density(material):
if material == "mild":
return 7850.0
else:
if material == "al":
return 2700.0
else:
raise ValueError("Invalid material `"+material+"'") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def density(self):\n return (1e-3*self.molar_mass) * self.pressure / (gas_constant * self.temperature) # kg/m^3",
"def density_kg_m3(self):\n return self._density_kg_m3",
"def density_g_cm3(self):\n return self._density_kg_m3 / 1000.0",
"def electron_density_per_m3(self):\n return... | [
"0.78450173",
"0.7577004",
"0.75337845",
"0.75139385",
"0.68572533",
"0.67514986",
"0.6707994",
"0.67074585",
"0.66710615",
"0.6592827",
"0.6582313",
"0.6472921",
"0.6445674",
"0.6445674",
"0.6445674",
"0.6412132",
"0.633474",
"0.63141286",
"0.6308918",
"0.6267133",
"0.623077... | 0.7671926 | 1 |
Returns the deflection of a horizontal cantilever of length L made from the material described by I and E, under a distributed uniform load q. | def BeamDeflection(I, E, L, q):
w = q * L**4 / (8*E*I)
return w | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def EulerBucklingForce(I, E, L):\n # http://en.wikipedia.org/wiki/Buckling\n K = 2.0 # for a vertical cantilever\n F = np.pi**2 * E*I / (K*L)**2\n return F",
"def uelbeam2DU(coord, I, Emod):\r\n vec = coord[1, :] - coord[0, :]\r\n nx = vec[0]/np.linalg.norm(vec)\r\n ny = vec[1]/np.linalg.no... | [
"0.55021435",
"0.53189874",
"0.52113706",
"0.5087749",
"0.50627816",
"0.5025136",
"0.4990624",
"0.4911095",
"0.4907491",
"0.481666",
"0.48159784",
"0.47943085",
"0.47663116",
"0.47565433",
"0.47562125",
"0.4755256",
"0.4752054",
"0.46714708",
"0.46163446",
"0.4614189",
"0.461... | 0.6460688 | 0 |
Return an iterator which schedules after each iteration. This can prevent eventlet thread starvation. | def cooperative_iter(citer):
try:
for chunk in citer:
sleep(0)
yield chunk
except Exception as err:
msg = (_("Error: cooperative_iter exception %(error)s") %
dict(error=err))
LOG.error(msg)
raise | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n while True:\n if self.stop:\n return\n for item in self.get_next_batch():\n yield item",
"def __iter__(self):\n cursor = self.first()\n while cursor is not None:\n yield cursor.element()\n cursor ... | [
"0.6472814",
"0.63899297",
"0.6330288",
"0.6251689",
"0.6220062",
"0.61972934",
"0.61830074",
"0.6165581",
"0.6139348",
"0.60712504",
"0.60712504",
"0.5949444",
"0.5936542",
"0.59117055",
"0.5899739",
"0.58811164",
"0.5871774",
"0.5859907",
"0.5859188",
"0.5843484",
"0.584262... | 0.55949634 | 48 |
Return an iterator to a filelike obj which yields fixed size chunks | def chunkiter(fp, chunk_size=65536):
while True:
chunk = fp.read(chunk_size)
if chunk:
yield chunk
else:
break | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iter_chunks(file: io.BytesIO, chunk_size: int = 64 * 1024):\n while True:\n data = file.read(chunk_size)\n if not data:\n break\n yield data",
"def chunk_reader(fobj, chunk_size=1024):\r\n while True:\r\n chunk = fobj.read(chunk_size)\r\n if not chunk:\r\n ... | [
"0.80395174",
"0.79308766",
"0.79308766",
"0.79298854",
"0.78477174",
"0.78453135",
"0.78411007",
"0.7777719",
"0.77432054",
"0.7733398",
"0.772871",
"0.772871",
"0.772871",
"0.772871",
"0.772837",
"0.77246517",
"0.77110773",
"0.7650436",
"0.7646451",
"0.7521083",
"0.7502705"... | 0.78066623 | 7 |
r""" Calculates a cross product (or vector product) of two vectors in tridimensional Cartesian coordinates. | def cross_product(a, b):
return (a[1]*b[2] - a[2]*b[0],
a[2]*b[0] - a[0]*b[2],
a[0]*b[1] - a[1]*b[0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cross_product(v1, v2):\n return cg3d_vector.CG3dVector(\n v1[1] * v2[2] - v2[1] * v1[2],\n v1[2] * v2[0] - v2[2] * v1[0],\n v1[0] * v2[1] - v2[0] * v1[1]\n )",
"def vector_cross(x, y):\n\n if(len(x) != len(y)):\n raise ValueError(\"vector lengths differ\")\n elif(len(x... | [
"0.80790997",
"0.7866993",
"0.78176665",
"0.7773975",
"0.76691467",
"0.7623997",
"0.7544347",
"0.75053585",
"0.7362339",
"0.7339407",
"0.7335022",
"0.7329031",
"0.72843534",
"0.72762126",
"0.7262948",
"0.72450465",
"0.7104131",
"0.70906115",
"0.70492136",
"0.7021942",
"0.7007... | 0.74273777 | 8 |
Draw detected bounding boxes. | def vis_detections(im, class_name, dets, bord, thet, fp, thresh=0.5):
para_dict={
'left': 20,
'right': -20,
'front': 40,
'back': 0,
'resolution': 0.05
}
inds = np.where(dets[:, -1] >= thresh)[0]
if len(inds) == 0:
return
im = im[:, :, (2, 1, 0)]
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_bounding_boxes(self, bounding_boxes, output):\n for i, bb in enumerate(bounding_boxes):\n\n if bb[2] > output.shape[1] or bb[3] > output.shape[0] or bb[0] < 0 or bb[1] < 0:\n continue\n cv2.rectangle(\n np.asarray(output), (bb[0], bb[1]), (bb[2], ... | [
"0.77598673",
"0.7638101",
"0.7510348",
"0.72977304",
"0.7150563",
"0.7103931",
"0.7101873",
"0.7083905",
"0.7020769",
"0.6993739",
"0.6974172",
"0.69637305",
"0.6859061",
"0.68521667",
"0.68319523",
"0.6830371",
"0.6809837",
"0.6805064",
"0.67750585",
"0.6774759",
"0.6742592... | 0.62219393 | 66 |
Build the inference graph and return a restore function. | def build_graph_from_config(self, model_config, track_config, checkpoint_path):
self.build_model()
ema = tf.train.ExponentialMovingAverage(0)
variables_to_restore = ema.variables_to_restore(moving_avg_variables=[])
# Filter out State variables
variables_to_restore_filterd = {}
for key, val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _restore(self, graph):\n raise NotImplementedError()",
"def restore(self):\n if self._restored_model:\n return\n with self.eval_graph.graph.as_default():\n last_checkpoint = self._find_last_checkpoint()\n # TODO(rbharath): Is setting train=False right here?\n saver = tf.train.Sav... | [
"0.644398",
"0.6046613",
"0.5920403",
"0.5917145",
"0.574831",
"0.57001007",
"0.56683636",
"0.5567141",
"0.55618656",
"0.5517357",
"0.5481409",
"0.54638994",
"0.5452468",
"0.5444272",
"0.54388434",
"0.54125607",
"0.5385506",
"0.53719145",
"0.5359336",
"0.5335948",
"0.5302787"... | 0.5282441 | 25 |
Crop search images from the input image based on the last target position 1. The input image is scaled such that the area of target&context takes up to (scale_factor z_image_size) ^ 2 2. Crop an image patch as large as x_image_size centered at the target center. 3. If the cropped image region is beyond the boundary of ... | def build_search_images(self):
size_z = 127
size_x = 255
context_amount = 0.5
num_scales = 3
scales = np.arange(num_scales) - get_center(num_scales)
assert np.sum(scales) == 0, 'scales should be symmetric'
search_factors = [1.0375 ** x for x in scales]
frame_sz = tf.shape(self.image)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _crop_image_and_paste(self, image, center, size):\n center_y, center_x = center\n target_h, target_w = size\n img_h, img_w, img_c = image.shape\n\n x0 = max(0, center_x - target_w // 2)\n x1 = min(center_x + target_w // 2, img_w)\n y0 = max(0, center_y - target_h // 2)... | [
"0.6662073",
"0.66186655",
"0.65173113",
"0.648923",
"0.63262296",
"0.62926817",
"0.6170863",
"0.6157938",
"0.6146192",
"0.61245394",
"0.61235154",
"0.6109681",
"0.60947025",
"0.609179",
"0.6091693",
"0.6066206",
"0.6057071",
"0.60365117",
"0.5987331",
"0.5971059",
"0.5943617... | 0.0 | -1 |
Test that we can handle invalid credentials. | async def test_form_invalid_auth(hass: HomeAssistant):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
assert result["errors"] == {}
with patch(
"homeassistant.components.jellyfin.client_wra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_validate_credentials(self):\n pass",
"def test_invalid_credentials(self):\n self.user = {\"username\": \"testuserother\", \"password\": \"testpassword\"}\n response = self.app.post(\"/auth/login/\", data=self.user)\n self.assertEqual(response.status_code, 403)\n\n outp... | [
"0.82380414",
"0.7977701",
"0.79609525",
"0.7865408",
"0.7822999",
"0.7789407",
"0.75698763",
"0.75510335",
"0.7486272",
"0.74727374",
"0.73838264",
"0.73685277",
"0.7355993",
"0.7337308",
"0.73361886",
"0.7324551",
"0.7316063",
"0.7306323",
"0.7293369",
"0.72780913",
"0.7266... | 0.0 | -1 |
r"""Test for physical limits on GHI using the QCRad criteria. Test is applied to each GHI value. A GHI value passes if value > lower bound and value < upper bound. Lower bounds are constant for all tests. Upper bounds are calculated as | def check_ghi_limits_qcrad(ghi, solar_zenith, dni_extra, limits=None):
if not limits:
limits = QCRAD_LIMITS
ghi_ub = _qcrad_ub(dni_extra, solar_zenith, limits['ghi_ub'])
ghi_limit_flag = quality.util.check_limits(ghi, limits['ghi_lb'], ghi_ub)
return ghi_limit_flag | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def g_in_bounds(x, lo, hi):\n\n return (x >= lo) and (x <= hi)",
"def toms748_scan(\n data,\n model,\n bounds_low,\n bounds_up,\n level=0.05,\n atol=2e-12,\n rtol=1e-4,\n from_upper_limit_fn=False,\n **hypotest_kwargs,\n):\n cache = {}\n\n def f_cached(poi):\n if poi no... | [
"0.6575862",
"0.6303228",
"0.6134751",
"0.59900814",
"0.5861906",
"0.5856983",
"0.5749124",
"0.5735105",
"0.57121015",
"0.57084155",
"0.57033944",
"0.56618595",
"0.56572485",
"0.5634657",
"0.5609499",
"0.55907905",
"0.55706996",
"0.5570658",
"0.5559892",
"0.5553685",
"0.55536... | 0.5860386 | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.