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
Finds the relative color of a companded sRGB color, where white is the D65 white point. `x` > 3item list or tuple of a companded sRGB color.
def sRGBLuminance(x): lin=linearFromsRGB3(x) return lin[0]*0.2126+lin[1]*0.7152+lin[2]*0.0722
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_color(self, c, x, max_num):\n\n ratio = 5*(float(x)/max_num)\n i = int(math.floor(ratio))\n j = int(math.ceil(ratio))\n ratio -= i\n r = (1 - ratio) * self._colors[i][c] + ratio*self._colors[j][c]\n return int(255*r)", "def getRGBFromXYAndBrightness(self, x, y, ...
[ "0.6774189", "0.63662654", "0.6165092", "0.6053773", "0.6039496", "0.60279906", "0.6007814", "0.59776926", "0.59316194", "0.590671", "0.5894798", "0.58678293", "0.5860342", "0.58495414", "0.584435", "0.5810694", "0.5795488", "0.5790412", "0.5787023", "0.5780985", "0.5724453",...
0.6293169
2
Test base model instance None
def test_basemodel_basic_instance_none(self): with self.assertRaises(TypeError): BaseModel(None)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_noarguments(self):\n self.assertEqual(BaseModel, type(BaseModel()))", "def test_instance(self):\n self.assertIsInstance(self.test1, BaseModel)", "def test_instance_BaseModel(self):\n self.assertTrue(isinstance(self.my_object, BaseModel))", "def test_basemodel_basic_instance(self...
[ "0.80231947", "0.79989123", "0.7941508", "0.7813731", "0.7544405", "0.74999666", "0.7452782", "0.7351618", "0.7337447", "0.72895074", "0.7280447", "0.72775495", "0.7277241", "0.72593814", "0.72263646", "0.7222089", "0.72038734", "0.72015023", "0.717199", "0.7169258", "0.71668...
0.8098113
0
Render index.html and return a list of all genres in the database
def index(): return render_template("index.html", genres=mongo.db.genres.find())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def genres(request):\n\n genre_list = Genres.objects.all()\n template = 'genres.html'\n context = {'genre_list': genre_list, }\n\n return render(request, template, context)", "def book_genre_list(request):\n genres = Genre.objects.all().order_by('-name')\n return render(request, 'library/book_g...
[ "0.78544897", "0.7411427", "0.71637625", "0.7032562", "0.6912489", "0.6703285", "0.6597688", "0.65362465", "0.6515454", "0.65054166", "0.6504956", "0.64526534", "0.64524806", "0.64430505", "0.64412606", "0.6438455", "0.63923275", "0.636675", "0.6349975", "0.63493997", "0.6332...
0.8579369
0
Find a book, return all reviews and update the book review with form data.
def leave_review(book_id): if request.method == 'POST': mongo.db.books.find_one_and_update( {"_id": ObjectId(book_id)}, {"$push": {"reviews": request.form.to_dict()['reviews']} } ) return redirect(url_for('library')) else: return render_template...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def review(book_id):\n\n # User id from current session\n user_id = session[\"user_id\"]\n # Form data\n try:\n rating = request.form.get('rating')\n text = request.form.get('review-text')\n except ValueError:\n return error('Something went wrong with submission.', 400)\n\n #...
[ "0.7074716", "0.7001833", "0.6901512", "0.6462823", "0.6442863", "0.62262726", "0.62024945", "0.6140798", "0.6126515", "0.60852975", "0.6026697", "0.59292054", "0.59257895", "0.5876543", "0.5862409", "0.5848849", "0.5817138", "0.57618445", "0.57392174", "0.56552154", "0.55964...
0.6707456
3
Remove a book to user's book collection.
def remove_collection(book_id): if 'username' in session: mongo.db.users.update_one( {'username' : session['username']}, {'$pull' : {'book_collection': ObjectId(book_id)}} ) return redirect(url_for('user', user_id=session['username']))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_book(self, book):\n if self.has_book(book):\n self.books.remove(book)\n if self.owner.lists_with_book_count(book) <= 1:\n self.owner.remove_book(book)\n return self", "def remove_book(self, book):\n if self.has_book(book):\n self...
[ "0.80136096", "0.78585315", "0.75852716", "0.7238311", "0.7016101", "0.70006436", "0.6723079", "0.67099124", "0.66443354", "0.6585086", "0.6554451", "0.64218336", "0.6200322", "0.6104956", "0.6100536", "0.6099474", "0.60963315", "0.6024604", "0.5997149", "0.59902793", "0.5888...
0.7002449
5
Convenience layer that perorms an affine transform followed by a ReLU
def affine_relu_forward(x, w, b): a, fc_cache = affine_forward(x, w, b) out, relu_cache = relu_forward(a) cache = (fc_cache, relu_cache) return out, cache
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def affine_layernorm_relu_forward(x, w, b, gamma, beta, ln_param):\n fc_out, fc_cache = affine_forward(x, w, b)\n norm_out, norm_cache = layernorm_forward(fc_out, gamma, beta, ln_param)\n out, relu_cache = relu_forward(norm_out)\n cache = (fc_cache, norm_cache, relu_cache)\n return out, cache", "def affineT...
[ "0.69867504", "0.6572268", "0.6439855", "0.6433597", "0.6433597", "0.6433597", "0.6433597", "0.642217", "0.6333756", "0.6289237", "0.62431914", "0.62354267", "0.62161696", "0.6189127", "0.6136317", "0.6120578", "0.6056729", "0.60451454", "0.6031833", "0.60112923", "0.6002554"...
0.71841645
2
Forward pass for the affinebatchnormrelu convenience layer
def affine_bn_relu_forward(x, w, b, gamma, beta, bn_param): a, fc_cache = affine_forward(x, w, b) an, bn_cache = batchnorm_forward(a, gamma, beta, bn_param) out, relu_cache = relu_forward(an) cache = (fc_cache, bn_cache, relu_cache) return out, cache
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def affine_batchnorm_relu_forward(x, w, b, gamma, beta, bn_param):\n fc_out, fc_cache = affine_forward(x, w, b)\n norm_out, norm_cache = batchnorm_forward(fc_out, gamma, beta, bn_param)\n out, relu_cache = relu_forward(norm_out)\n cache = (fc_cache, norm_cache, relu_cache)\n return out, cache", "def affine_...
[ "0.79018676", "0.77066606", "0.7054248", "0.699916", "0.69421965", "0.69206274", "0.6888592", "0.68694115", "0.6762852", "0.6748065", "0.670639", "0.670639", "0.6693821", "0.6693821", "0.6693821", "0.6693821", "0.6659797", "0.66587037", "0.6654921", "0.6628577", "0.6628577", ...
0.68866247
7
Backward pass for the affinebatchnormrelu convenience layer
def affine_bn_relu_backward(dout, cache): fc_cache, bn_cache, relu_cache = cache da = relu_backward(dout, relu_cache) dan, dgamma, dbeta = batchnorm_backward(da, bn_cache) dx, dw, db = affine_backward(dan, fc_cache) return dx, dw, db, dgamma, dbeta
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def affine_batchnorm_relu_backward(dout, cache):\n fc_cache, norm_cache, relu_cache = cache\n d_norm_out = relu_backward(dout, relu_cache)\n d_affine_out, dgamma, dbeta = batchnorm_backward_alt(d_norm_out, norm_cache)\n dx, dw, db = affine_backward(d_affine_out, fc_cache)\n return dx, dw, db, dgamma, dbeta", ...
[ "0.7655102", "0.758219", "0.7579185", "0.74714565", "0.70438194", "0.70393753", "0.70271826", "0.69933707", "0.6937926", "0.6911695", "0.6853179", "0.6847639", "0.68472373", "0.68472373", "0.68370694", "0.68370694", "0.68370694", "0.68370694", "0.68253684", "0.68253684", "0.6...
0.72211415
4
Returns true if both objects are equal
def __eq__(self, other): if not isinstance(other, GlanceCreateImageMetadataResponse): return False return self.__dict__ == other.__dict__
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False", "def __eq__(self, other):\n if i...
[ "0.8088463", "0.8088463", "0.80553037", "0.7983272", "0.7966844", "0.7966844", "0.7966844", "0.7966844", "0.7966844", "0.7966844", "0.7966844", "0.7966844", "0.7966844", "0.7966844", "0.7966844", "0.7966844", "0.7966844", "0.7966844", "0.7966844", "0.7966844", "0.7966844", ...
0.0
-1
Returns true if both objects are not equal
def __ne__(self, other): return not self == other
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True", "def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)", "def __ne__(self, other) -> bool:\n return not self.__eq__(other)", "def __eq__(self, other):\n ...
[ "0.845611", "0.8391477", "0.8144138", "0.81410587", "0.8132492", "0.8093973", "0.80920255", "0.80920255", "0.80920255", "0.8085325", "0.8085325", "0.8076365", "0.8076365", "0.8065748" ]
0.0
-1
References may be compared for equality.
def __ne__(self, v): return not (self == v)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n if not isinstance(other, LineItemReference):\n return False\n\n return self.__dict__ == other.__dict__", "def testEquality(self):\n pass", "def __eq__(self,other):\n try: \n if not self.size == other.size and self.reference == other.r...
[ "0.70439565", "0.6973399", "0.6865347", "0.67290837", "0.672133", "0.6677314", "0.66354334", "0.66354334", "0.66354334", "0.66354334", "0.66354334", "0.66354334", "0.66354334", "0.66354334", "0.66354334", "0.66354334", "0.66354334", "0.66354334", "0.66354334", "0.66354334", "...
0.0
-1
References may be compared for equality.
def __eq__(self, v): return self is v or (self.__class__ == v.__class__ and self.AEM_comparable() == v.AEM_comparable())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n if not isinstance(other, LineItemReference):\n return False\n\n return self.__dict__ == other.__dict__", "def testEquality(self):\n pass", "def __eq__(self,other):\n try: \n if not self.size == other.size and self.reference == other.r...
[ "0.7044891", "0.69766766", "0.6866396", "0.67298496", "0.6721524", "0.66790557", "0.663721", "0.663721", "0.663721", "0.663721", "0.663721", "0.663721", "0.663721", "0.663721", "0.663721", "0.663721", "0.663721", "0.663721", "0.663721", "0.663721", "0.663721", "0.663721", ...
0.0
-1
ne(anything) > does not equal test
def ne(self, val): return NotEquals(self, val)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_not_equal(self):\n utils.compare_tracing_methods(\n SimpleCompareOpsModule(\"notEqual\"),\n torch.randn(3, 4, 5),\n torch.randn(3, 4, 5),\n fusible_ops={\"aten::ne\"},\n )", "def __ne__(self, rhs):\n return not self.__eq__(rhs)", "def __...
[ "0.76794857", "0.7646952", "0.7624771", "0.7618851", "0.76152855", "0.7575103", "0.7551571", "0.752134", "0.7474319", "0.7470581", "0.7465002", "0.7449085", "0.74459475", "0.7445002", "0.7436726", "0.74279624", "0.74279624", "0.74244225", "0.7417717", "0.7417717", "0.74144965...
0.73761225
28
Test the setDirection() and getDirection() methods.
def test_direction(self): # Default initialized direction is forward. self.assertEqual(self.group_tr.getDirection(), OCIO.TRANSFORM_DIR_FORWARD) for direction in OCIO.TransformDirection.__members__.values(): self.group_tr.setDirection(direction) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def test_set_direction(hass: HomeAssistant, calls) -> None:\n await _register_components(hass)\n expected_calls = 0\n\n await common.async_turn_on(hass, _TEST_FAN)\n expected_calls += 1\n for cmd in [DIRECTION_FORWARD, DIRECTION_REVERSE]:\n await common.async_set_direction(hass, _TEST_F...
[ "0.7145497", "0.7121669", "0.6851404", "0.66780984", "0.6673258", "0.666593", "0.6592404", "0.63893515", "0.63365847", "0.63028646", "0.6277874", "0.6252377", "0.61980975", "0.6173451", "0.614588", "0.61166686", "0.60882276", "0.60839725", "0.6066155", "0.60179055", "0.600951...
0.8282881
0
Returns filtered segments belonging to a specified file.
async def get_segments_for_file( file_name: str, page: int = 0, score: int = 0, par_length: int = 0, co_occ: int = 0, limit_collection: List[str] = Query([]), folio: str = "", ): language = get_language_from_filename(file_name) limitcollection_positive, limitcollection_negative = get...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_segments(edfFiles):\n\n segments = []\n preprocessor = Preprocessor(config_startShift,\n config_endShift,\n config_powerLineFreq,\n config_bandLowCut,\n config_bandHighCut)\...
[ "0.62946147", "0.62885654", "0.61816967", "0.6112191", "0.5847772", "0.5818864", "0.56699187", "0.5444992", "0.5440816", "0.543574", "0.5435727", "0.540324", "0.53578675", "0.5318706", "0.5264703", "0.5240469", "0.5224177", "0.52083683", "0.5208033", "0.5202241", "0.5154116",...
0.5929332
4
Returns the displayName for a segmentnr.
async def get_displayname(segmentnr: str): lang = get_language_from_filename(segmentnr) filename = segmentnr.split(':')[0] if lang == "chn": filename = re.sub(r"_[0-9]+", "", filename) database = get_db() query_displayname = database.AQLQuery( query=main_queries.QUERY_DISPLAYNAME, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_display_name(record):\n return record[\"InstanceProfileName\"]", "def display_name(self):\n return self.properties.get(\"displayName\", None)", "def get_display_name(self):\n return self.get_property(dav.DisplayName())", "def display_name(self):\n return self.settings['display...
[ "0.68661433", "0.6769828", "0.66963017", "0.6691317", "0.6658782", "0.6635132", "0.6580928", "0.6580928", "0.6580928", "0.6580928", "0.6580928", "0.65756917", "0.6521884", "0.6521884", "0.6521884", "0.6521884", "0.6521884", "0.6521884", "0.6521884", "0.6521884", "0.6521884", ...
0.702293
0
Returns the displayName for a segmentnr.
async def get_multilingual(filename: str): query_result = {"langList": []} database = get_db() query_displayname = database.AQLQuery( query=main_queries.QUERY_MULTILINGUAL_LANGS, bindVars={ "filename": filename }, rawResults=True ) query_result = {"lan...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def get_displayname(segmentnr: str):\n lang = get_language_from_filename(segmentnr)\n filename = segmentnr.split(':')[0]\n if lang == \"chn\":\n filename = re.sub(r\"_[0-9]+\", \"\", filename)\n database = get_db()\n query_displayname = database.AQLQuery(\n query=main_queries.QUE...
[ "0.7022871", "0.68670315", "0.6770365", "0.6697097", "0.66918707", "0.6660152", "0.6636053", "0.6581341", "0.6581341", "0.6581341", "0.6581341", "0.6581341", "0.65761983", "0.652306", "0.652306", "0.652306", "0.652306", "0.652306", "0.652306", "0.652306", "0.652306", "0.652...
0.0
-1
Returns the best Action
def bestAction(self, state): action = self.q_network.chooseBestAction(state) V = max(self.q_network.qValues(state)) return action, V
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_best_action(self):\n if self.bestAction is None:\n self.calculate_best_action()\n return self.bestAction", "def act(self):\n action = self.best_action()\n return action", "def _best_action(self, state):\n actions_rewards = list(self.Q[state].items())\n ...
[ "0.9061267", "0.8763294", "0.81735426", "0.80723083", "0.80659574", "0.80254227", "0.8009562", "0.79923254", "0.79643923", "0.7830964", "0.78182834", "0.7756368", "0.77301204", "0.7713598", "0.7688321", "0.76736903", "0.76577526", "0.76307034", "0.7617552", "0.7592945", "0.75...
0.764178
17
Whether to use L2 weight decay for `param_name`.
def _do_use_weight_decay(self, param_name): if not self.weight_decay_rate: return False if self.exclude_from_weight_decay: for r in self.exclude_from_weight_decay: if re.search(r, param_name) is not None: return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _do_use_weight_decay(self, param_name):\n if not self.weight_decay_rate:\n return False\n if self.exclude_from_weight_decay:\n for r in self.exclude_from_weight_decay:\n if re.search(r, param_name) is not None:\n return False\n return True", "def _do_use_weight_decay(self, ...
[ "0.7058274", "0.7058274", "0.7058274", "0.7058274", "0.7058274", "0.7042912", "0.7037783", "0.6148344", "0.6116324", "0.60738724", "0.58761394", "0.5731123", "0.56879544", "0.5607771", "0.55421853", "0.5533301", "0.5528204", "0.5493097", "0.54622954", "0.54472876", "0.5446343...
0.69730985
8
Whether to use L2 weight decay for `param_name`.
def _do_use_weight_decay(self, param_name): if not self.weight_decay_rate: return False if self.exclude_from_weight_decay: for r in self.exclude_from_weight_decay: if re.search(r, param_name) is not None: return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _do_use_weight_decay(self, param_name):\n if not self.weight_decay_rate:\n return False\n if self.exclude_from_weight_decay:\n for r in self.exclude_from_weight_decay:\n if re.search(r, param_name) is not None:\n return False\n return True", "def _do_use_weight_decay(self, ...
[ "0.7058274", "0.7058274", "0.7058274", "0.7058274", "0.7058274", "0.7042912", "0.7037783", "0.6148344", "0.6116324", "0.60738724", "0.58761394", "0.5731123", "0.56879544", "0.5607771", "0.55421853", "0.5533301", "0.5528204", "0.5493097", "0.54622954", "0.54472876", "0.5446343...
0.69730985
9
Whether to do layerwise learning rate adaptation for `param_name`.
def _do_layer_adaptation(self, param_name): if self.exclude_from_layer_adaptation: for r in self.exclude_from_layer_adaptation: if re.search(r, param_name) is not None: return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _do_use_weight_decay(self, param_name):\n if not self.weight_decay_rate:\n return False\n if self.exclude_from_weight_decay:\n for r in self.exclude_from_weight_decay:\n if re.search(r, param_name) is not None:\n return False\n return True", "def _do_use_weight_decay(self, ...
[ "0.728557", "0.728557", "0.728557", "0.728557", "0.728557", "0.714325", "0.714325", "0.714325", "0.714325", "0.7100122", "0.70338655", "0.66027194", "0.6597934", "0.6561045", "0.65270674", "0.6521741", "0.65065384", "0.64637876", "0.64630455", "0.64630455", "0.64630455", "0...
0.69685507
11
Returns the employee home page.
def employee(): return Response(render_template('employee/employee.html'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def employee_home(cls):\n return cls.__home(cls._logger)", "def home_page(self) -> str:\n return self._home_page", "def personal_home_page(self) -> str:\n return self._personal_home_page", "def homepage():\n\treturn render_template(\"home/a_homepage.html\", title=\"Welcome\")", "def ho...
[ "0.7884416", "0.75349647", "0.7347782", "0.7281752", "0.72741693", "0.7154845", "0.7153947", "0.71193093", "0.7106191", "0.70715547", "0.7046188", "0.70405316", "0.70185184", "0.69691277", "0.69671506", "0.6944817", "0.69183534", "0.6917072", "0.6917072", "0.6917072", "0.6917...
0.6510263
81
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
Fetch the latest yaml configuration for an integration.
async def async_integration_yaml_config( opp: OpenPeerPower, integration_name: str ) -> ConfigType | None: integration = await async_get_integration(opp, integration_name) return await conf_util.async_process_component_config( opp, await conf_util.async_opp_config_yaml(opp), integration )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def async_integration_yaml_config(\n hass: HomeAssistant, integration_name: str\n) -> ConfigType | None:\n integration = await async_get_integration(hass, integration_name)\n\n return await conf_util.async_process_component_config(\n hass, await conf_util.async_hass_config_yaml(hass), integra...
[ "0.6813492", "0.6743552", "0.64173716", "0.62785614", "0.6152126", "0.6135238", "0.61309814", "0.61097306", "0.61047447", "0.6104074", "0.604214", "0.6037852", "0.60316753", "0.60095185", "0.599183", "0.59627116", "0.59585446", "0.5957831", "0.5944566", "0.59428513", "0.59407...
0.66172695
2
Creates a singular name string by combining first and last name
def parse_name(first_name, last_name): return first_name + " " + last_name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_formated_name(first_name,last_name):\n\tfull_name = first_name + '' + last_name\n\treturn full_name.title()", "def make_full_name(first_name, last_name, middle_initial=\"\"):\n if middle_initial:\n return f\"{first_name} {middle_initial[0:1]}. {last_name}\"\n else:\n return f\"{first_...
[ "0.7938396", "0.79240555", "0.7851024", "0.78010374", "0.77954876", "0.779184", "0.7788236", "0.77865845", "0.77760607", "0.77143985", "0.7704728", "0.76981026", "0.76968825", "0.76944816", "0.76944816", "0.76944816", "0.768721", "0.7684031", "0.7684031", "0.7684031", "0.7679...
0.0
-1
Apply the standard template to some more HTML. This method is used in the creation of most pages title The page title (in the header) text The page content
def render_html(title, text, is_test=False): template = open(resolve("html/page.mustache")).read() return pystache.render(template, {'title': title, 'content': text, 'app_title': DISPLAY_NAME, 'context': CONTEXT, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def define_content(self, html):\n self.html_template(html, lang=\"en\")\n self.add_language(\"en\")", "def get_content(self, default=None):\n\n tree = parse_string(self.book.get_template(self._template_name))\n tree_root = tree.getroot()\n\n tree_root.set('lang', self.lang or s...
[ "0.6389394", "0.6216893", "0.620742", "0.6187255", "0.609868", "0.602595", "0.5982625", "0.5910555", "0.5860774", "0.5829621", "0.58202815", "0.58085954", "0.5789463", "0.57796603", "0.5754765", "0.56842643", "0.5676206", "0.5655952", "0.5643539", "0.56402767", "0.5639693", ...
0.6092565
5
Send a 404 not found start_response The response object
def send404(start_response): start_response('404 Not Found', [('Content-type', 'text/html; charset=utf-8')]) return [RDFServer.render_html(YZ_NOT_FOUND_TITLE, YZ_NOT_FOUND_PAGE).encode('utf-8')]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def not_found(environ, start_response):\n start_response('404 NOT FOUND', [('Content-Type', 'text/plain')])\n return [str.enocde('Not Found')]", "def not_found(environ, start_response):\n start_response('404 Empty WPP request msg!', [('Content-Type', 'text/plain')])\n return ['Empty WPP request msg!\...
[ "0.8237397", "0.7933496", "0.7789341", "0.7781334", "0.7660513", "0.7531275", "0.75295776", "0.75204694", "0.7490554", "0.74848807", "0.7413102", "0.73565924", "0.73314077", "0.7326615", "0.7323068", "0.7301029", "0.7283452", "0.72760576", "0.72760576", "0.72397757", "0.72353...
0.7931079
2
Assigns field to buzzerrooms.
def schedulebuzzerrooms(self, field): divisions = ['8', '7', 'Elementary'] field = list(filter(lambda stu: stu.bee, field)) for player in field: player.schedule = list(sorted(player.schedule, key=itemgetter(1))) # create a list of players in each round (1 - 16) playe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def booking(self, customer, room):\n self.room[room] = customer\n return True", "def setRoomList(self,roomList):\n self.roomList = roomList", "def setRoomList(self,roomList):\n self.roomList = roomList", "def rooms(self, rooms):\n\n self._rooms = rooms", "def __init__(sel...
[ "0.62463576", "0.6233621", "0.6233621", "0.59965897", "0.58163726", "0.5702544", "0.568325", "0.5620691", "0.5620506", "0.5511594", "0.54238725", "0.5403611", "0.5309989", "0.53049", "0.5277939", "0.5248739", "0.5191165", "0.51901656", "0.51830745", "0.51732373", "0.51644504"...
0.5435831
10
Hash password before saving.
def set_password(self, password): self.password = generate_password_hash(password)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash_password(self):\n self.__password = self.str_to_hash(self.__password)", "def hash_password(self, password):\n self.password_hash = generate_password_hash(password)", "def hash_password(self, password):\n self.password = pwd_context.encrypt(password)", "def hash_password(self, or...
[ "0.81892926", "0.79767346", "0.7861677", "0.77282685", "0.7631551", "0.7624802", "0.74794847", "0.7420639", "0.7324399", "0.728064", "0.7228339", "0.7228339", "0.7228339", "0.7228339", "0.7225862", "0.7187474", "0.7139251", "0.7115133", "0.7102463", "0.7087808", "0.7068659", ...
0.67335445
50
Check password hash against a pwd provided by user.
def check_password(self, password): return check_password_hash(self.password, password)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkPassword(self, unhashPass):\n\t\treturn check_password_hash(self.passHash, unhashPass)", "def valid_pwd(name, password, h):\n salt = h.split(',')[0]\n return h == make_pwd_hash(name, password, salt)", "def checkPassword(self, password):\n # get the hash\n pswFile = os.path.join(os....
[ "0.7540943", "0.7505496", "0.7329342", "0.72880447", "0.7241134", "0.72142076", "0.72111917", "0.7203458", "0.7200366", "0.719823", "0.7181897", "0.71716213", "0.71501374", "0.71501374", "0.71501374", "0.71501374", "0.71349406", "0.7119356", "0.7105546", "0.70869344", "0.7073...
0.71753347
11
Retrieve the mountpoint under a file
def get_mountpoint(host, fqpath): command = "df -P %s | awk 'END{print $NF}'" % fqpath rcode, rout, rerr = g.run(host, command) if rcode == 0: return rout.strip() g.log.error("Get mountpoint failed: %s" % rerr) return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mountpoint(self):\n return self._properties.get('mountpoint')", "def get_disk_by_mountpoint(mnt_point):\n diskparts = psutil.disk_partitions()\n for item in diskparts:\n if item.mountpoint == mnt_point:\n return realpath(item.device)\n return None", "def fsmounted(mountpoi...
[ "0.77689135", "0.7064576", "0.6981762", "0.6934608", "0.6695603", "0.648559", "0.6450375", "0.6433785", "0.6357996", "0.6355451", "0.63459533", "0.63377875", "0.63245195", "0.61639154", "0.6149914", "0.605027", "0.6043915", "0.6016457", "0.5983911", "0.59671116", "0.59671116"...
0.73824847
1
Get the xattr for the file instance.
def get_xattr(self, xattr): return get_fattr(self._host, self._fqpath, xattr)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getxattr(pathname, attr):\n if attr in xattr.listxattr(pathname):\n return xattr.getxattr(pathname, attr)\n else:\n return None", "def _get_attr(self, attr, root=None):\n with self._h5file('r') as h5file:\n if root is None:\n obj = h5file\n else...
[ "0.68741703", "0.61961746", "0.60997534", "0.604604", "0.59459674", "0.5782565", "0.57605594", "0.57089293", "0.5689203", "0.56089175", "0.5587231", "0.55533874", "0.55171597", "0.5499459", "0.5486242", "0.5476765", "0.5449688", "0.53918236", "0.53777164", "0.53624433", "0.53...
0.7778568
0
Get timestamp from tweet id
def get_tweet_timestamp(tid): offset = 1288834974657 tstamp = (tid >> 22) + offset return math.floor(tstamp/1000)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_timestamp(tweet):\n\n if 'timestamp_ms' in tweet:\n timestamp_ms = int(tweet[\"timestamp_ms\"])\n timestamp_ms = timestamp_ms - timestamp_ms % 1000\n return timestamp_ms / 1000.\n elif 'created_at' in tweet:\n return parse(tweet['created_at']).timestamp()\n\n raise ...
[ "0.7752677", "0.759698", "0.69382507", "0.6797679", "0.6662933", "0.6579704", "0.65106815", "0.6442436", "0.64221776", "0.6421252", "0.6394101", "0.6345774", "0.6306192", "0.62966603", "0.62829405", "0.62200916", "0.6191024", "0.6183969", "0.61559373", "0.61379576", "0.612409...
0.78979266
0
Convert timestamp to timestamponly tweet id
def ts_to_tid(tstamp): offset = 1288834974657 return (tstamp*1000 - offset) << 22
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_tweet_timestamp(tid):\n offset = 1288834974657\n tstamp = (tid >> 22) + offset\n return math.floor(tstamp/1000)", "def extract_timestamp(tweet):\n\n if 'timestamp_ms' in tweet:\n timestamp_ms = int(tweet[\"timestamp_ms\"])\n timestamp_ms = timestamp_ms - timestamp_ms % 1000\n ...
[ "0.7285081", "0.69341433", "0.6916905", "0.68557876", "0.67509687", "0.6709116", "0.66192627", "0.6474197", "0.6375429", "0.62828374", "0.62692636", "0.6205269", "0.6193097", "0.619257", "0.6164524", "0.6154402", "0.61530477", "0.6141056", "0.61285704", "0.6126497", "0.611513...
0.67924047
4
Initializes a clause. Here, the input clause is either a list or set of integers, or is an instance of Clause; in the latter case, a shallow copy is made, so that one can modify this clause without modifying the original clause.
def __init__(self, clause): if isinstance(clause, Clause): # We use frozenset here, so that clauses are not modifiable. # This ensures that two equal clauses always have the same hash, # due also to our definition of the __hash__ method. self.literals = frozenset(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, clause_list):\n raw_clauses = {Clause(c) for c in clause_list}\n # We do some initial sanity checking. \n # If a clause is empty, then it\n # cannot be satisfied, and the entire problem is False.\n # If a clause is true, it can be dropped. \n self.claus...
[ "0.650933", "0.59525424", "0.593376", "0.5478546", "0.5431269", "0.5244287", "0.51739204", "0.5156626", "0.5074115", "0.5069725", "0.506462", "0.5061173", "0.5056712", "0.50069165", "0.4978111", "0.49681395", "0.49034697", "0.48363853", "0.48253945", "0.4784638", "0.47787258"...
0.81750333
0
Convert a sudoku grid into a dict with '0' or '.' chars for empty values.
def grid_values(self, grid): chars = [col for col in grid if col in self.digits or col in '0.'] assert len(chars) == 81 return dict(zip(self.squares, chars))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_grid_values(self):\n sudoku_grid = '..3.2.6..9..3.5..1..18.64....81.29..7.......8..67.82....26.95..8..2.3..9..5.1.3..'\n sudoku_dict = {'C7': '4', 'I6': '123456789', 'E7': '123456789', 'E6': '123456789',\n 'F6': '8', 'H6': '3', 'C9': '123456789', 'E4': '123456789', 'E9'...
[ "0.6910479", "0.67018765", "0.6563154", "0.61465", "0.59778345", "0.59628564", "0.5937581", "0.5926858", "0.58715427", "0.58365506", "0.56829625", "0.5664944", "0.55299735", "0.54854554", "0.5480748", "0.54610455", "0.54581344", "0.54571784", "0.54326534", "0.5398145", "0.535...
0.7828931
0
This method parse the manifest file and return a dictionary of activities names
def get_activities_dictionary(self): activities_dict_list = list() activities = self.get_specific_node_list('activity') for activity in activities: activities_dict = dict() activity_name = None category = None for key, val in activity.attrib...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_file_manifest(in_stream):\n count = struct.unpack(COUNT_FMT, checked_read(in_stream, COUNT_LEN))[0]\n name_map = {}\n for dummy in range(0, count):\n length, file_sha, history_sha = \\\n struct.unpack(MANIFEST_ENTRY_HDR_FMT,\n checked_read(in_str...
[ "0.66667044", "0.65207", "0.6505412", "0.64356816", "0.63779986", "0.63779986", "0.63068473", "0.6226707", "0.6213305", "0.6132024", "0.6062842", "0.59646606", "0.5918902", "0.59096247", "0.58729666", "0.5865666", "0.5792879", "0.5728339", "0.5694827", "0.5675231", "0.5673349...
0.66049016
1
Return a new NamedSettingsDict corresponding to the given name.
def __init__(self, name): if name.endswith('.sublime-settings'): self.name = name[:-17] else: self.name = name super().__init__(sublime.load_settings(self.file_name))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def LoadSettings(self, name):\n file_path = os.path.join(self._root, Storage._SETTINGS_FILE % name)\n if not os.path.exists(file_path):\n return {}\n with open(file_path) as f:\n return json.load(f)", "def upgrade_state_dict_named(self, state_dict, name):\n return state_dict", "def __...
[ "0.60476655", "0.5927722", "0.5643837", "0.56061804", "0.5393393", "0.5387126", "0.5294058", "0.52648467", "0.5247465", "0.5164386", "0.5162726", "0.51561636", "0.5155647", "0.5155311", "0.51550025", "0.5148", "0.51339036", "0.5116907", "0.51028895", "0.5084978", "0.5084312",...
0.46622956
57
The service name. This string is how a service is referenced and can be passed to win_service_get() to get a new WindowsService instance.
def name(self): return self._name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def service_name(self):\n return self._service_name", "def service_name(self) -> str:\n return pulumi.get(self, \"service_name\")", "def service_name(self) -> str:\n return pulumi.get(self, \"service_name\")", "def SERVICE_NAME(default=None):\n return ParamStore.get('SERVICE_NAME'...
[ "0.804075", "0.7997186", "0.7997186", "0.7809816", "0.7764362", "0.7764362", "0.7764362", "0.75507903", "0.75507903", "0.75507903", "0.75155205", "0.75155205", "0.75155205", "0.7221105", "0.71536344", "0.7042482", "0.68764967", "0.68425196", "0.6780238", "0.6741953", "0.66981...
0.0
-1
The service display name. The value is cached when this class is instantiated.
def display_name(self): return self._display_name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def service_name(self) -> str:\n return pulumi.get(self, \"service_name\")", "def service_name(self) -> str:\n return pulumi.get(self, \"service_name\")", "def display_name(self) -> str:\n return pulumi.get(self, \"display_name\")", "def display_name(self) -> str:\n return pulumi....
[ "0.7973046", "0.7973046", "0.7898421", "0.7898421", "0.7898421", "0.7898421", "0.7898421", "0.7898421", "0.7898421", "0.7898421", "0.7898421", "0.7898421", "0.7898421", "0.7898421", "0.78433675", "0.7816541", "0.7787969", "0.7786229", "0.7786229", "0.7786229", "0.77599514", ...
0.775978
28
Service status as a string.
def status(self): return self._query_status()['status']
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_status_string(self, instance):\n return instance.get_status_string()", "def get_status_as_string(self):\n if self.downloaded == 0:\n return \"[Starting... ]\"\n return \"[%s, %s, %s]\" % self.get_status()", "def _get_status(self):\n return u'%s' % (self.get_status...
[ "0.80052143", "0.78648233", "0.7779186", "0.76995057", "0.76995057", "0.76995057", "0.76995057", "0.76995057", "0.76995057", "0.76995057", "0.76995057", "0.76995057", "0.76995057", "0.76995057", "0.76995057", "0.76995057", "0.76995057", "0.76995057", "0.76995057", "0.76995057",...
0.0
-1
Whether the latest rate limit update is older than the maximum allowed age specified in the config file.
def is_rate_limit_status_stale(self): if self._rate_limit_status is None: self.update_rate_limit_status() max_age_sec = consts.RATE_LIMIT_MAX_AGE_SEC return (round(time.time()) - self._rate_limit_status["last_update"]) > max_age_sec
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_age(self):\n return 120 if self.realtime else 1800", "def get_access_control_max_age(self):\n return self.access_control_max_age", "def is_older_than_30(self):\n older = self.age >= 30\n return older", "def extended(self):\n if self.expires_at:\n return s...
[ "0.69649273", "0.67634785", "0.6603106", "0.64910936", "0.64871645", "0.64871645", "0.6426875", "0.64044267", "0.63085955", "0.62778777", "0.62716424", "0.62035686", "0.6112259", "0.6053784", "0.601286", "0.60107034", "0.59689564", "0.5968755", "0.59468865", "0.5918833", "0.5...
0.6904237
1
Whether the authenticated user is currently blocked by rate limitation.
def is_rate_limited(self, force_update=False, ignore_stale=False): status = self.request_rate_limit_status(force_update, ignore_stale) return status["remaining"] <= 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def blocked(self) -> bool:\n return pulumi.get(self, \"blocked\")", "def check_rate_limit(self):\n # Already received 429 from server\n if self.rate_limit_sleep:\n msg = f\"请求过于频繁,已被BitMEX限制,请等待{self.rate_limit_sleep}秒后再试\"\n self.gateway.write_log(msg)\n ret...
[ "0.73950404", "0.68803215", "0.65682876", "0.6542018", "0.63924646", "0.6369933", "0.635768", "0.63198876", "0.6274557", "0.6243277", "0.6243277", "0.6243277", "0.6213224", "0.62000203", "0.62000203", "0.6193149", "0.6190315", "0.6153055", "0.61509573", "0.6131337", "0.612554...
0.7144611
1
load networks and optimizer paramters from checkpoint_path if checkpoint_path is None, use the latest created path from checkpoint_dir
def load_checkpoint(self, checkpoint_path=None): if checkpoint_path is None: checkpoint_path = self.get_latest_path() if os.path.isfile(checkpoint_path): key = 'cuda' if torch.cuda.is_available() else 'cpu' checkpoint = torch.load(checkpoint_path, map_location=key) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_checkpoint(path, model, optimizer=None, reset_optimizer=True):\n print(\"Load checkpoint from: {}\".format(path))\n state_dict, optimizer_state = _load(path)\n\n model.load_dict(state_dict)\n if not reset_optimizer and optimizer is not None:\n if optimizer_state is not None:\n ...
[ "0.7546553", "0.74854255", "0.74183464", "0.74064326", "0.7385257", "0.7361709", "0.7328672", "0.7298083", "0.7295632", "0.726133", "0.7203486", "0.7201959", "0.7154857", "0.7154551", "0.7151866", "0.71383786", "0.7126096", "0.70818895", "0.7055671", "0.70248204", "0.7015447"...
0.75682735
0
Return the number of tenpairs within positive integer n. >>> ten_pairs(7823952) 3 >>> ten_pairs(55055) 6 >>> ten_pairs(9641469) 6
def ten_pairs(n): def digit_in_n(num, i): if num < 10: return 1 if num == i else 0 else: if num % 10 == i: return 1 + digit_in_n(num // 10, i) else: return digit_in_n(num // 10, i) def pairs_calc(num): if num <= 0: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ten_pairs(n):\n def counter(x, n):\n if n == 0:\n return 0\n else:\n if x == n % 10:\n return 1 + counter(x, n // 10)\n else:\n return counter(x, n // 10)\n def one_to_five(k):\n if k == 5:\n return round(count...
[ "0.802376", "0.7577683", "0.66532683", "0.6543198", "0.63087475", "0.61719275", "0.61575025", "0.61553824", "0.6151965", "0.6029092", "0.59617597", "0.59297264", "0.5842583", "0.58412814", "0.5836359", "0.58314747", "0.5806533", "0.57904756", "0.57579", "0.575229", "0.5693340...
0.79459846
1
Efficient version of torch.cat that avoids a copy if there is only a single element in a list
def cat(tensors, dim=0): assert isinstance(tensors, (list, tuple)) if len(tensors) == 1: return tensors[0] return torch.cat(tensors, dim)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_cat(args, dim=-1):\n return [torch.cat(x, dim=dim) for x in zip(*args)]", "def concat(a, b):\n return torch.cat((a, b), 1)", "def dim_zero_cat(x: Union[Tensor, List[Tensor]]) ->Tensor:\n x = x if isinstance(x, (list, tuple)) else [x]\n x = [(y.unsqueeze(0) if y.numel() == 1 and y.ndim == 0...
[ "0.6819189", "0.66446334", "0.64845526", "0.64733356", "0.62033004", "0.6057658", "0.60194373", "0.596737", "0.592376", "0.59082305", "0.59036916", "0.58742404", "0.58368826", "0.5834499", "0.5820864", "0.5820569", "0.58196753", "0.5815302", "0.57852066", "0.5781512", "0.5749...
0.6803915
2
ensure TypeError raised if bad track format provided
def test_track_shape_error(): track = np.random.randn(50,1) try: bad_arm = survey.get_spiral_slice(track = track) except TypeError: assert True else: assert False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testBadTrackType(self):\n\n self.assertRaises(\n ValueError,\n tools._trackInfo,\n 'Track ID 5: telepathic (junk for the rest'\n )", "def _parse_track_line(self, inp):\n self.metadata = {}\n ltmp = shlex.split(inp.strip(\"\\n\"))\n for item ...
[ "0.7379462", "0.64195806", "0.6245985", "0.62185216", "0.60319483", "0.60155916", "0.5975581", "0.58395606", "0.5764234", "0.5748249", "0.5745362", "0.57157195", "0.5647919", "0.56259984", "0.56225663", "0.5617027", "0.56084853", "0.55884296", "0.5540927", "0.55244374", "0.55...
0.54813325
23
Return true if this battle has a prop buffing it.
def __checkPropBonus(self, track): result = False if self.battle.getInteractivePropTrackBonus() == track: result = True return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_buff(self, buff):\n assert isinstance(buff, BuffId)\n return buff.value in self.proto.buff_ids", "def hasPokemon(self):\r\n return self.trainer.hasPokemon()", "def have_pump(self, pump):\n if pump > MAX_PUMPS:\n return False\n return bool(self.pump_array[pu...
[ "0.631334", "0.6253141", "0.6243663", "0.62090474", "0.61014867", "0.60575736", "0.60503316", "0.5982553", "0.5932516", "0.59265876", "0.59114945", "0.5899399", "0.5898618", "0.5885047", "0.5872705", "0.5856941", "0.5842111", "0.58084947", "0.5800105", "0.57981575", "0.578234...
0.65199304
0
tgt, the target (in this case a suit) lastAtk, an attack that might have killed the 'tgt' currAtk, an attack that should flag 'tgt' killed if necessary Check to see if the suit died flag for 'lastAtk' should be cleared. This can happen if 'lastAtk' killed the suit, but 'currAtk', which happened right after 'lastAtk', i...
def __clearTgtDied(self, tgt, lastAtk, currAtk): position = self.battle.activeSuits.index(tgt) currAtkTrack = self.__getActualTrack(currAtk) lastAtkTrack = self.__getActualTrack(lastAtk) if currAtkTrack == lastAtkTrack and \ lastAtk[SUIT_DIED_COL] & (1 << position) and \ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __prevAtkTrack(self, attackerId, toon=1):\n if toon:\n prevAtkIdx = self.toonAtkOrder.index(attackerId) - 1\n if prevAtkIdx >= 0:\n prevAttackerId = self.toonAtkOrder[prevAtkIdx]\n attack = self.battle.toonAttacks[prevAttackerId]\n retur...
[ "0.598517", "0.5974699", "0.5852701", "0.5785423", "0.5661788", "0.56065154", "0.5484903", "0.5473535", "0.5470061", "0.5447276", "0.5425377", "0.5413967", "0.5397414", "0.53921294", "0.5290287", "0.52901095", "0.5283121", "0.5283121", "0.5259553", "0.5240435", "0.5223457", ...
0.8009515
0
toonId, the attack to wake suits up from kbBonusReq, 1 if a knockback bonus on the suit is required for the suit to become unlured, 0 if no knockback bonus is needed Wake up all suits which have been hit by the specified toon attack
def __clearLuredSuitsByAttack(self, toonId, kbBonusReq=0, targetId=-1): if self.notify.getDebug(): self.notify.debug("__clearLuredSuitsByAttack") if targetId != -1 and \ self.__suitIsLured(t.getDoId()): self.__removeLured(t.getDoId()) else: tgtList ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __applyToonAttackDamages(self, toonId, hpbonus=0, kbbonus=0):\n # now be sure to adjust the damage to the suit, but only\n # if the track of the attack is not 0, meaning it is not\n # a heal, if it's a heal, then the damage is applied as\n # a plus to the target's health and we don'...
[ "0.6493317", "0.62998986", "0.60501176", "0.6020419", "0.6006825", "0.5972982", "0.5825091", "0.55868196", "0.54445934", "0.5411383", "0.53446424", "0.5286513", "0.52760273", "0.5213654", "0.5170754", "0.5150872", "0.51286346", "0.51173306", "0.50354517", "0.50299513", "0.496...
0.6887736
0
toonId, the attack to wake suits up from kbBonusReq, 1 if a knockback bonus on the suit is required for the suit to become unlured, 0 if no knockback bonus is needed Wke up all suits which have been hit by the specified toon attack
def __clearLuredSuitsDelayed(self): if self.notify.getDebug(): self.notify.debug("__clearLuredSuitsDelayed") for t in self.delayedUnlures: # for all targets of this attack, if any have received a # knockback bonus and are currently lured, wake them up if s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __clearLuredSuitsByAttack(self, toonId, kbBonusReq=0, targetId=-1):\n if self.notify.getDebug():\n self.notify.debug(\"__clearLuredSuitsByAttack\")\n if targetId != -1 and \\\n self.__suitIsLured(t.getDoId()):\n self.__removeLured(t.getDoId())\n else:\n ...
[ "0.69368184", "0.67075634", "0.6387855", "0.61469966", "0.6144112", "0.6107178", "0.6033393", "0.5985751", "0.57929665", "0.56713283", "0.56618774", "0.55224794", "0.53417385", "0.5326139", "0.5271027", "0.5259224", "0.52427715", "0.5211329", "0.5200238", "0.5117381", "0.5060...
0.0
-1
For each toon attack in the toonAttacks list, calculate and fill in appropriate damage, accuracyBonus, and HPBonus values
def __calculateToonAttacks(self): # a list of suits, and any knockback bonuses that are applied # to them, each sublist corresponds to each entry in battle.suits # the first value in the each sublist is the total knockback # bonus damage done to that suit, while the second value in each ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __applyToonAttackDamages(self, toonId, hpbonus=0, kbbonus=0):\n # now be sure to adjust the damage to the suit, but only\n # if the track of the attack is not 0, meaning it is not\n # a heal, if it's a heal, then the damage is applied as\n # a plus to the target's health and we don'...
[ "0.741983", "0.705281", "0.70327556", "0.6763573", "0.67306995", "0.6712482", "0.6653256", "0.66477716", "0.6587766", "0.6462124", "0.6437446", "0.63767576", "0.6308153", "0.6178584", "0.6028461", "0.59619147", "0.59122634", "0.5878387", "0.5855052", "0.5826932", "0.5790384",...
0.72567874
1
Check all lured suits and see if the lure has expired also randomly unlure suits
def __updateLureTimeouts(self): # check for lured suits and determine which should no longer be # lured if self.notify.getDebug(): self.notify.debug("__updateLureTimeouts()") self.notify.debug("Lured suits: " + str(self.currentlyLuredSuits)) noLongerLured = [] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __luredWakeupTime(self, suitId):\n return self.__suitIsLured(suitId) and \\\n self.currentlyLuredSuits[suitId][0] > 0 and \\\n random.randint(0, 99) < \\\n self.currentlyLuredSuits[suitId][2]", "def __clearLuredSuitsDelayed(self):\n if self.notify.getDe...
[ "0.6164725", "0.610967", "0.59160125", "0.56781894", "0.56397796", "0.5626918", "0.56039464", "0.55455685", "0.54669297", "0.5466615", "0.5373111", "0.5373111", "0.5373111", "0.53681964", "0.53646827", "0.53471905", "0.53407794", "0.5320498", "0.5307309", "0.52980405", "0.529...
0.6932608
0
This returns true if a toon will gain credit for using this item in this particular battle, false otherwise. This is based on the credit level computed at the beginning of __calculateToonAttacks.
def itemIsCredit(self, track, level): if (track == PETSOS): return 0 return level < self.creditLevel
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_attacking(self) -> bool:\n return self.orders and self.orders[0].ability.id in (\n AbilityId.ATTACK,\n AbilityId.ATTACK_ATTACK,\n AbilityId.ATTACK_ATTACKTOWARDS,\n AbilityId.ATTACK_ATTACKBARRAGE,\n AbilityId.SCAN_MOVE,\n )", "def can_tak...
[ "0.666303", "0.659887", "0.65605307", "0.65568036", "0.6533572", "0.64593047", "0.6432116", "0.6280954", "0.6158226", "0.6147137", "0.6087242", "0.6061372", "0.6051988", "0.6051988", "0.60469633", "0.60105354", "0.60051966", "0.5999336", "0.59954756", "0.595975", "0.5945721",...
0.62877744
7
Turns the robot to the left and changes the state to follow.
def left(cargo): # When the robot has turned left change state to follow line_follower.turn_left() #print("Turning left") # return new_state = "follow" txt = "follow line.." return (new_state, txt)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def go_left(self):\n self.change_x = -6\n self.direction = \"L\"", "def move_left(self):\n self.yaw_motor.step_backward()", "def turn_left(self):\n self.facing_direction -= self.config\n if self.facing_direction < 0:\n self.facing_direction += 8\n self.x, se...
[ "0.8070071", "0.80674684", "0.8044708", "0.7854896", "0.7719246", "0.76795363", "0.7678348", "0.7661182", "0.76416725", "0.7635445", "0.76121175", "0.75864094", "0.7579163", "0.7544379", "0.75394875", "0.75333554", "0.7519345", "0.7476809", "0.74731493", "0.74007666", "0.7400...
0.7104588
34
Turns the robot to the right and changes the state to follow.
def right(cargo): # When the robot has turned right change state to forward line_follower.turn_right() #print("Turning right") # return new_state = "follow" txt = "follow line.." return (new_state, txt)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_right(self):\n self.yaw_motor.step_forward()", "def turn_right(self):\n self.facing_direction += self.config\n if self.facing_direction > 7:\n self.facing_direction -= 8\n self.x, self.y = self.compute_positions()", "def go_right(self):\n self.change_x = 6...
[ "0.7897611", "0.7585429", "0.7581828", "0.74656385", "0.7394653", "0.73612714", "0.7243653", "0.72246015", "0.72196674", "0.7213382", "0.72075266", "0.71376", "0.7091153", "0.70224255", "0.6953188", "0.6944379", "0.6905491", "0.6900412", "0.6883804", "0.6876622", "0.6842383",...
0.7340969
6
Compute precision for each of the provided cutoffs
def precision_at( ks: torch.Tensor, scores: torch.Tensor, labels: torch.Tensor ) -> torch.Tensor: ks, scores, labels = _check_inputs(ks, scores, labels) _, _, topk_labels = _extract_topk(ks, scores, labels) precisions = _create_output_placeholder(scores, ks) for index, k in enumerate(ks): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def precision(y_true, y_pred):\n true_positives = bk.sum(bk.round(bk.clip(y_true * y_pred, 0, 1)))\n predicted_positives = bk.sum(bk.round(bk.clip(y_pred, 0, 1)))\n precision = true_positives / (predicted_positives + bk.epsilon())\n return precision", "def precision(gr...
[ "0.7087553", "0.70232457", "0.6989542", "0.69123226", "0.6888049", "0.6888049", "0.6888049", "0.6888049", "0.6888049", "0.6888049", "0.6888049", "0.6888049", "0.6888049", "0.68858355", "0.6883725", "0.6883725", "0.6883725", "0.6883725", "0.6883725", "0.6883725", "0.68691623",...
0.61008084
74
Compute recall for each of the provided cutoffs
def recall_at( ks: torch.Tensor, scores: torch.Tensor, labels: torch.Tensor ) -> torch.Tensor: ks, scores, labels = _check_inputs(ks, scores, labels) _, _, topk_labels = _extract_topk(ks, scores, labels) recalls = _create_output_placeholder(scores, ks) # Compute recalls at K num_relevant = tor...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recall(y_true, y_pred):\n true_positives = bk.sum(bk.round(bk.clip(y_true * y_pred, 0, 1)))\n possible_positives = bk.sum(bk.round(bk.clip(y_true, 0, 1)))\n recall = true_positives / (possible_positives + bk.epsilon())\n return recall", "def recall(y_true, y_pred):...
[ "0.70595795", "0.6988666", "0.6928547", "0.69014645", "0.6888264", "0.6875284", "0.6875284", "0.6875284", "0.6875284", "0.6875284", "0.6875284", "0.686552", "0.6857851", "0.6857851", "0.6857851", "0.6857851", "0.6857851", "0.6857851", "0.6857851", "0.6857851", "0.6857851", ...
0.59931934
69
Compute the sigmoid of z
def sigmoid(z): ### START CODE HERE ### (≈ 1 line of code) s = 1 / (1 + np.exp(-z)) ### END CODE HERE ### return s
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sigmoid(z):\r\n \r\n return vSigmoid(z);", "def sigmoid(z): \n return 1/(1 + np.e**(-z))", "def sigmoid(z):\r\n \r\n return 1.0 / (1.0+np.exp(-z))", "def sigmoid(z):\n return 1 / (1 + e ** -z)", "def sigmoid(z):\n return 1 / (1 + np.exp(-1 * z))", "def sigmoid(self, z):\n ...
[ "0.9236619", "0.91155094", "0.9034886", "0.9032656", "0.8983236", "0.8982324", "0.89819604", "0.8958828", "0.8936817", "0.89279467", "0.8925133", "0.8906126", "0.8891459", "0.88882077", "0.8875157", "0.8872043", "0.88688284", "0.886221", "0.8861199", "0.8856525", "0.8849176",...
0.8420076
32
This function creates a vector of zeros of shape (dim, 1) for w and initializes b to 0.
def initialize_with_zeros(dim): ### START CODE HERE ### (≈ 1 line of code) w = np.zeros(shape=(dim, 1)) b = 0 ### END CODE HERE ### assert (w.shape == (dim, 1)) assert (isinstance(b, float) or isinstance(b, int)) return w, b
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize_with_zeros(dim):\n\n w = np.zeros((dim, 1))\n b = 0\n\n return w, b", "def initialize_with_zeros(dim):\n \n w = np.zeros([dim, 1])\n b = 0;\n\n assert(w.shape == (dim, 1))\n assert(isinstance(b, float) or isinstance(b, int));\n \n return w,b;", "def initialize_with_...
[ "0.7801021", "0.7477936", "0.73508734", "0.7131797", "0.6638015", "0.66138625", "0.6566842", "0.6530196", "0.65089864", "0.6427708", "0.6408813", "0.638868", "0.6381563", "0.633592", "0.6272247", "0.6272247", "0.6272247", "0.62344176", "0.62181735", "0.6201392", "0.6191589", ...
0.72403485
3
Find all subclasses of a given class
def all_subclasses(cls): return cls.__subclasses__() + [g for s in cls.__subclasses__() for g in all_subclasses(s)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Subclass_finder(cls):\n\n subclasses = [] # Create a list to deposit subclasses\n\n for subclass in cls.__subclasses__():\n subclasses.append(subclass) # Add founded subclass\n subclasses.extend(Subclass_finder(subclass)) # Check if there is a subclass\n ...
[ "0.8172433", "0.780109", "0.7674884", "0.7580169", "0.7580169", "0.7515398", "0.74849594", "0.74814093", "0.7471728", "0.7454161", "0.74444854", "0.7415641", "0.738507", "0.72913605", "0.72748137", "0.72664064", "0.72400504", "0.71437126", "0.7143012", "0.7139842", "0.7100506...
0.69416714
31
Builds a finetuning dataloader for training or evaluating.
def build_finetuning_dataloader(cfg: DictConfig, tokenizer: PreTrainedTokenizerBase, device_batch_size: int) -> DataLoader: _validate_config(cfg.dataset) # Use EOS as the pad token if none exists if tokenizer.pad_token is None: # type: ignore...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_training_data_loader(self) -> DataLoader:\n pass", "def dataloader(self):\n\n # load / split data\n train_data = self.data.get_train_data()\n if self.args.use_dev:\n train_data, dev_data = self.data.split_data(train_data)\n test_data = self.data.get_test_da...
[ "0.75692147", "0.7343005", "0.69351757", "0.67658263", "0.6735763", "0.6676411", "0.666284", "0.6662131", "0.66256243", "0.65740573", "0.6562627", "0.6529676", "0.6527331", "0.64904666", "0.64832574", "0.646617", "0.6452471", "0.64508325", "0.64124936", "0.63939", "0.6370264"...
0.7688224
0
Builds a dataset from a remote object store. This function supports 'jsonl', 'csv', and 'parquet' file formats for the dataset. It will attempt to download the dataset, then once it is downloaded, convert it into HuggingFace ``datasets`` format, and then return this dataset. The function also ensures synchronicity acro...
def _build_hf_dataset_from_remote( cfg: DictConfig, tokenizer: PreTrainedTokenizerBase ) -> Union[hf_datasets.DatasetDict, hf_datasets.Dataset, hf_datasets.IterableDatasetDict, hf_datasets.IterableDataset]: supported_extensions = ['jsonl', 'csv', 'parquet'] finetune_dir = os.path.join( os...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_dataset(\n self, datastore, filestore, file_id=None, url=None,\n detect_headers=True, infer_types=None, load_format='csv', options=[],\n username=None, password=None, resources=None, reload=False,\n human_readable_name=None\n ):\n dataset = None\n file_handle =...
[ "0.6575908", "0.62878567", "0.6272358", "0.6238716", "0.6044357", "0.59407175", "0.59343", "0.5923842", "0.5838245", "0.57652354", "0.5754219", "0.5706753", "0.56975925", "0.5683073", "0.56655884", "0.5655984", "0.5644313", "0.5643489", "0.56327087", "0.560831", "0.560667", ...
0.65556467
1
The Amazon Resource Name (ARN) of the parameter group.
def arn(self) -> Optional[str]: return pulumi.get(self, "arn")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def group_arn(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"group_arn\")", "def parameter_group_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"parameter_group_name\")", "def parameter_group_name(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"par...
[ "0.76403", "0.7284272", "0.71811014", "0.7171272", "0.68828434", "0.6817659", "0.6817659", "0.6817659", "0.6817659", "0.6729742", "0.6729742", "0.6729742", "0.6729742", "0.6729742", "0.6729742", "0.6729742", "0.6729742", "0.6729742", "0.6729742", "0.6729742", "0.6729742", "...
0.0
-1
Format an address to string, aligned to the given architecture
def format_address(addr: int, arch: Optional[cemu.arch.Architecture] = None) -> str: if arch is None: arch = cemu.core.context.architecture if arch.ptrsize == 2: return f"{addr:#04x}" elif arch.ptrsize == 4: return f"{addr:#08x}" elif arch.ptrsize == 8: return f"{addr:#0...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _format_architecture(architecture):\n return f\"{architecture} architecture\"", "def format_address(value):\n if type(value) in (tuple, list):\n return ', '.join([format_address(v) for v in value])\n name, addr = parseaddr(value)\n return formataddr((encode_header(name), addr.encode('ascii...
[ "0.7025737", "0.6702889", "0.6427396", "0.640924", "0.63837", "0.6380178", "0.6215458", "0.5982466", "0.5982466", "0.5982466", "0.5982466", "0.5898666", "0.5898666", "0.5883418", "0.58436966", "0.581971", "0.5793493", "0.57907534", "0.57650733", "0.57145584", "0.5705159", "...
0.82092696
0
Returns a random string
def generate_random_string(length: int) -> str: charset = string.ascii_letters + string.digits return "".join(random.choice(charset) for _ in range(length))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generateRandomString():\n return ''.join(b64encode(urandom(32)).decode('utf-8'))", "def generate_random_string():\n return \"\".join(random.choice(string.ascii_lowercase + string.digits) for _ in range(16)) # nosec", "def randomstr(ctx, nbytes=\"\"):\n # deprecated function\n logger.info(\"Dep...
[ "0.82806224", "0.8130788", "0.8050951", "0.7993263", "0.7954804", "0.7896301", "0.7890371", "0.78023106", "0.7801216", "0.7794588", "0.7778455", "0.77663887", "0.7743764", "0.7719187", "0.7717533", "0.7708271", "0.7701349", "0.7684879", "0.7663948", "0.7655649", "0.7625446", ...
0.7336862
56
Tests _retrieve gets all projects' merged audit configs.
def test_retrieve(self): iam_resources = _create_list_of_mock_iam_resources() mock_data_access = mock.MagicMock() mock_data_access.scanner_iter.return_value = iam_resources mock_service_config = mock.MagicMock() mock_service_config.model_manager = mock.MagicMock() mock_se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_project_records():\r\n records = flask.request.db_api.get_all_project_record()\r\n return flask.jsonify(records=records)", "def test_get_projects(self):\n pass", "def get_all_projects():\n return jsonify(admin.get_all_projects(current_app.scoped_session()))", "def get_projects(sel...
[ "0.609209", "0.59704125", "0.5869138", "0.58548677", "0.5802502", "0.5746501", "0.56826156", "0.56467366", "0.5597494", "0.55794966", "0.5562809", "0.5559444", "0.55544186", "0.55544186", "0.55452454", "0.5507187", "0.5495196", "0.547791", "0.54552", "0.54000217", "0.5394479"...
0.6720298
0
Construct an LayerNorm object.
def __init__(self, nout, dim=-1): super(LayerNorm, self).__init__(nout, eps=1e-12) self.dim = dim
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_norm_layer():\n norm_layer = functools.partial(nn.InstanceNorm2d, affine=False, track_running_stats=False)\n return norm_layer", "def layernorm(w_in):\n return nn.LayerNorm(w_in, eps=cfg.LN.EPS)", "def layer_norm(input, normalized_shape, weight, bias, eps=1e-5):\n return FunctionLib.apply(\...
[ "0.6417725", "0.6159931", "0.60568386", "0.6010308", "0.5939424", "0.5925004", "0.59041643", "0.577654", "0.57746017", "0.5758614", "0.57477224", "0.5731986", "0.5727288", "0.57038754", "0.56981486", "0.5677127", "0.5673824", "0.564988", "0.56143343", "0.5547716", "0.5547716"...
0.6631577
0
Initilize duration predictor module.
def __init__(self, idim, n_layers=2, n_chans=384, kernel_size=3, dropout_rate=0.1, offset=1.0, padding='SAME', dur_loss='mse'): super(DurationPredictor, self).__init__() self.offset = offset self.conv = torch.nn.ModuleList() self.kernel_size = kernel_size self.padding = padding ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n super().__init__()\n self.dynamic = True # from base class, indicates time-dependence is handled internally\n self.numBins = None # integer number of bins to use in creating the duration curve. TODO default?\n self.targets = None # list of strings, variables to apply postprocessor...
[ "0.69967747", "0.6116887", "0.6071434", "0.606084", "0.60207707", "0.60128325", "0.5994014", "0.5994014", "0.59522986", "0.59372646", "0.593415", "0.5924272", "0.5914327", "0.5914129", "0.5904202", "0.58114356", "0.58114356", "0.57932585", "0.5792656", "0.57591134", "0.575395...
0.6040176
4
Creates a URL safe slug automatically when a new a playlist is created.
def save(self, *args, **kwargs): if not self.pk: self.slug = slugify(self.playlist_name, allow_unicode=True) # Call save on the superclass. return super(Playlist, self).save(*args, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_slug(self):\n slug = slugify(self.title)\n new_slug = slug\n n = 1\n while Article.objects.filter(slug=new_slug).exists():\n new_slug = '{}-{}'.format(slug, n)\n n += 1\n\n return new_slug", "def create_slug(val):\n slug = slugify(unidecode(v...
[ "0.72830945", "0.69432545", "0.6900598", "0.68737316", "0.67953086", "0.6793334", "0.6668365", "0.6601068", "0.6591085", "0.65859586", "0.65716815", "0.6556059", "0.6553092", "0.6553092", "0.65325284", "0.64253896", "0.64214975", "0.64103854", "0.63411963", "0.63260573", "0.6...
0.7397025
0
Take rule from configuration value
def getRole(self, desired=None): return {"roleName":"hasici", "roleTitle":"Soptici"}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_rule(self, rule):\n for kbrule in self.rules:\n if rule == kbrule:\n return kbrule", "def _get_rule(self, rule):\n for kbrule in self.rules:\n if rule == kbrule:\n return kbrule", "def _get_rule(self, rule):\n for kbrule in self....
[ "0.71305686", "0.71305686", "0.71305686", "0.68413407", "0.68413407", "0.68413407", "0.65716726", "0.65716726", "0.65716726", "0.65716726", "0.65716726", "0.65716726", "0.65716726", "0.6102921", "0.6093363", "0.60735893", "0.6071056", "0.5991717", "0.5861347", "0.5851954", "0...
0.0
-1
Take rule from configuration value
def getRoles(self): return [self.getRole(), {"roleName":"policajti", "roleTitle":"Svestky"}]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_rule(self, rule):\n for kbrule in self.rules:\n if rule == kbrule:\n return kbrule", "def _get_rule(self, rule):\n for kbrule in self.rules:\n if rule == kbrule:\n return kbrule", "def _get_rule(self, rule):\n for kbrule in self....
[ "0.7129508", "0.7129508", "0.7129508", "0.68408585", "0.68408585", "0.68408585", "0.657088", "0.657088", "0.657088", "0.657088", "0.657088", "0.657088", "0.657088", "0.6101231", "0.60920256", "0.6072495", "0.60712457", "0.5991088", "0.5859912", "0.58492255", "0.58492255", "...
0.0
-1
evaluation function takes in the current and proposed successor GameStates(from pacman.py) and returns a number, where higher numbers are better.
def evaluationFunction(self, currentGameState, action): # getting successor GameSate needed info successorGameState = currentGameState.generatePacmanSuccessor(action) # successor newPos = successorGameState.getPacmanPosition() # Ms. Pacman position newFoodGrid = successorGameState.getFoo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def betterEvaluationFunction(currentGameState):\n\t\"*** YOUR CODE HERE ***\"\n\tres = currentGameState.getScore()\n\tcur_food_list = currentGameState.getFood().asList()\n\tcur_pacman_pos = currentGameState.getPacmanPosition()\n\tcur_ghost_states = currentGameState.getGhostStates()\n\tcur_scared_times = [ghostStat...
[ "0.76831955", "0.76502645", "0.7541777", "0.75395733", "0.7535079", "0.751071", "0.74914724", "0.7477093", "0.744562", "0.7441441", "0.74404657", "0.74390864", "0.7428105", "0.740881", "0.7382483", "0.7374679", "0.7354751", "0.73455083", "0.73454976", "0.7333668", "0.73101693...
0.7271959
26
A decorator to add a static variable to a function. Inside the decorated function, the variable can be accessed like `funcname.foovar`.
def static_variable(variable_name: str, initial_value: Any) -> Callable[[Callable], Callable]: def decorator(function): setattr(function, variable_name, initial_value) return function return decorator
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def static_var(varname, value):\n def decorate(func):\n setattr(func, varname, value)\n return func\n return decorate", "def static_var(**kwargs):\n def decorate(func):\n for k in kwargs:\n setattr(func, k, kwargs[k])\n return func\n return decorate", "def sta...
[ "0.82796407", "0.7524129", "0.72036564", "0.6951949", "0.5921421", "0.57414013", "0.56274104", "0.56274104", "0.5341875", "0.52864546", "0.51409584", "0.5129167", "0.5083505", "0.505809", "0.50511575", "0.49889112", "0.49889112", "0.49512202", "0.49435556", "0.4941172", "0.49...
0.7436739
2
Returns True if the host in the web address starts with
def is_localhost() -> bool: if not has_request_context(): return True host = request.headers.get("Host", "") return host.startswith(("localhost:", "127.0.0.1:", "0.0.0.0:"))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _match(cls, url, **kwargs):\n return url.scheme.startswith('http')", "def matches(self, url):\n split = urlparse.urlsplit(url)\n return self.host == split.hostname", "def matches_host(self, host: str, requires_data_uri: bool = False) -> bool:\n return (\n self.url\n ...
[ "0.7012713", "0.6916655", "0.68736744", "0.67831594", "0.67087", "0.665796", "0.6628359", "0.65655935", "0.65627193", "0.6527216", "0.6496239", "0.64690983", "0.64210063", "0.635671", "0.63421917", "0.63380384", "0.63281035", "0.63260233", "0.6322511", "0.6272828", "0.6264701...
0.6123011
33
Get the api key that belongs to the current user If running on localhost, api key is obtained from the environment variable MP_API_KEY
def get_user_api_key(consumer=None) -> str | None: if not consumer: consumer = get_consumer() if is_localhost(): return SETTINGS.API_KEY elif is_logged_in_user(consumer): return consumer["X-Consumer-Custom-Id"] else: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_api_key(self):\r\n url = '{0}/{1}'.format(self.get_url(), 'api_key')\r\n\r\n return http.Request('GET', url), parsers.parse_json", "def _get_api_key(self):\n self.api.apikey = self.api.action.user_show(id=self.username)['apikey']", "def _get_api_key():\n if not os.getenv(\"S...
[ "0.8213145", "0.81916946", "0.8109363", "0.7861162", "0.77677387", "0.7746433", "0.77437836", "0.7730946", "0.7727143", "0.7726606", "0.77076614", "0.77076614", "0.77076614", "0.77076614", "0.76982087", "0.76982087", "0.767847", "0.76398945", "0.760045", "0.7577182", "0.75269...
0.71091044
31
Get an instance of the MPContribsClient that will work in either production or a dev environment. Client uses MPCONTRIBS_API_HOST by default.
def get_contribs_client(): from mpcontribs.client import Client headers = get_consumer() if is_localhost(): return Client(apikey=get_user_api_key()) else: return Client(headers=headers)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_client(httpx_settings: Optional[dict] = None) -> \"PrefectClient\":\n ctx = prefect.context.get_settings_context()\n api = PREFECT_API_URL.value()\n\n if not api:\n # create an ephemeral API if none was provided\n from prefect.server.api.server import create_app\n\n api = crea...
[ "0.6298783", "0.5332566", "0.51578116", "0.5099357", "0.5095646", "0.5039207", "0.50320953", "0.50247", "0.50153434", "0.5012056", "0.49813688", "0.49738854", "0.4938187", "0.49197465", "0.4894062", "0.48849285", "0.48849285", "0.48834327", "0.48825872", "0.48752582", "0.4857...
0.72025865
0
Returns a nicely styled DataTable with sensible defaults for reuse.
def get_data_table( df=None, virtualized=True, columns=None, column_widths=None, **kwargs ): datatable_kwargs = dict( sort_action="native", row_selectable="single", style_as_list_view=True, # style_table={"width": "800px"}, style_cell={ "fontFamily": "Helveti...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new(headings: Optional[List[Any]] = None,\n data: Optional[List[List[Any]]] = None,\n style: Text = 'default',\n align: Text = None,\n device: Text = 'stdout',\n dataframe=None) -> TableD: # mypy: ignore\n\n if dataframe is not None:\n headings = list(dataframe.col...
[ "0.6891989", "0.64900285", "0.6405003", "0.61437035", "0.60903734", "0.6069421", "0.59286547", "0.58621913", "0.5832146", "0.5831438", "0.5786531", "0.5778875", "0.57785875", "0.5736635", "0.5735365", "0.5717534", "0.5689248", "0.56869274", "0.56751406", "0.5668884", "0.56462...
0.6825049
1
Returns a string for use in mpc.Markdown() to render a matrix or vector.
def get_matrix_string(matrix, variable_name=None, decimals=4): if decimals: matrix = np.round(matrix, decimals=decimals) + 0 else: matrix = np.array(matrix) header = "$$\n" if variable_name: header += f"{variable_name} = \\begin{{bmatrix}}\n" else: header += "\\begi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __repr__(self):\n return self.matrix and '\\n'.join([\"|%s|\" % s for s in [' '.join([\"%-6.3f\" % e for e in w]) for w in self.matrix]]) or \"<pusta macierz>\"", "def _repr_latex_(self):\n if len(self.shape) > 2:\n raise ValueError(\"bmatrix can at most display two dimensions\")\n\n...
[ "0.7383598", "0.7108758", "0.6749569", "0.6715628", "0.67057943", "0.6644011", "0.65047073", "0.6478859", "0.6476085", "0.64556503", "0.64111507", "0.63904965", "0.63793623", "0.63732594", "0.6336498", "0.6334333", "0.62667745", "0.6257158", "0.62316585", "0.62299895", "0.621...
0.6610932
6
Provide tile location (upper left corner of tile) in nanometres.
def get_tile_coordinates_for_registration(self, grid_number, tile_number): dx, dy = self.get_tile_coordinates_d(grid_number, tile_number) width_d = self.get_tile_width_d(grid_number) height_d = self.get_tile_height_d(grid_number) return int((dx - width_d/2) * 1000), int((dy - height_d/2)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def northing(self):\r\n x, y = self.lonlat2xy(self.longitude, self.latitude)\r\n return y", "def get_tile_location(self):\n if self.rect.x == 0:\n tile_x = 0\n elif self.rect.x % 32 == 0:\n tile_x = (self.rect.x / 32)\n else:\n tile_x = 0\n\n ...
[ "0.69824326", "0.6949951", "0.6506156", "0.6442526", "0.63840777", "0.63380224", "0.63071394", "0.630412", "0.6281366", "0.6255272", "0.6230896", "0.6218979", "0.6199323", "0.6195288", "0.61910176", "0.6180585", "0.61670285", "0.6161853", "0.6139104", "0.61352193", "0.6107923...
0.6316637
6
Performs forward pass of the input. Here an input tensor x is transformed through several layer transformations.
def forward(self, x): ######################## # PUT YOUR CODE HERE # ####################### for l in range(len(self.layers)): if l == 0: z = self.layers[l].forward(x) else: z = self.layers[l].forward(a) a = self.activations[l].forward(z) # output from softmax l...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self, x_in):\r\n # x_out = torch.zeros_like(x_in)\r\n\r\n for layer in self.layers: #Call forward function of each layer in order\r\n x_out = layer.forward(x_in)\r\n # print(\"Forward pass Seq: \", layer, x_in, x_out)\r\n x_in = x_out ...
[ "0.8100585", "0.78592265", "0.781218", "0.780231", "0.7764269", "0.77563226", "0.7741146", "0.77348596", "0.77293", "0.7700638", "0.76963764", "0.76776093", "0.76748264", "0.76373404", "0.76264703", "0.7609787", "0.7593594", "0.7579113", "0.75505877", "0.7541774", "0.754019",...
0.74987984
24
Creates a TensorFlow variable using given initial value. Note that this function saves the created variable to `self._tls._embed_variables`.
def _create_embedding_variable(self, name, initial_value): if name not in self._tls._embed_variables: embed_var = tf.Variable( initial_value, name=name + str(threading.get_ident()), shape=(None, None), dtype=tf.float32, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_var_with_large_initial_value(initial_value: np.ndarray, *args, **kwargs):\r\n assert isinstance(initial_value, np.ndarray)\r\n zeros = tf.zeros(initial_value.shape, initial_value.dtype)\r\n var = tf.Variable(zeros, *args, **kwargs)\r\n # Onrolux.set_vars({var: initial_value})...
[ "0.74373466", "0.6830368", "0.6520404", "0.6321912", "0.62276006", "0.6206064", "0.6206064", "0.616734", "0.60653645", "0.6058866", "0.6052092", "0.60213", "0.600679", "0.59797984", "0.5969599", "0.5966226", "0.59491664", "0.591467", "0.58837134", "0.5860128", "0.58585757", ...
0.8361567
0
Get the variable for the specified ElasticDL embedding layer.
def _get_embedding_variable(self, layer_name): return self._tls._embed_variables.get(layer_name, None)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_embedding_layer_name_from_var(var):\n # Assumes that for ElasticDL embedding layer, variable will be a\n # string representing its layer name\n if isinstance(var, str):\n return var\n return None", "def get_embed(input_data, vocab_size, embed_dim):\n embedding = tf.Variable(tf.rand...
[ "0.6743214", "0.63091016", "0.6283216", "0.6108311", "0.6108311", "0.6108311", "0.6084474", "0.60842997", "0.59954244", "0.5964092", "0.59291476", "0.59087086", "0.5860784", "0.5839625", "0.5818966", "0.58174425", "0.57583433", "0.5741345", "0.57331795", "0.573289", "0.573247...
0.8319732
0
Clear the slots and weights in the optimizer according to Embedding layers.
def _delete_slots_and_weights_in_optimizer(self): for layer_name, slots in self._tls._slot_variables.items(): embed_var = self._get_embedding_variable(layer_name) embed_var_key = _var_key(embed_var) if embed_var_key in self._opt._slots: del self._opt._slots[em...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_prompt_embedding_weights(self,):\n self.prompt_embeddings.weight.fill_(0.0)", "def reset(self):\n self._weights.clear()", "def reset_parameters(self):\n logger.info('===== Initialize %s =====' % self.__class__.__name__)\n nn.init.normal_(self.embed.weight, mean=0.0, std=se...
[ "0.6725236", "0.6724402", "0.67240566", "0.6673172", "0.6622231", "0.6536576", "0.6521717", "0.65087134", "0.6484279", "0.64576614", "0.64538854", "0.6402418", "0.6371955", "0.6306975", "0.62614024", "0.6255943", "0.6226978", "0.62221205", "0.62213993", "0.61776865", "0.61776...
0.7387308
0
Gets the median of a list of values
def find_median(values): midpoint = int(len(values) / 2) if len(values) % 2 == 0: median = (values[midpoint - 1] + values[midpoint]) / 2 else: median = values[midpoint] return median
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_median(numlist):\n return np.median(numlist)", "def median(v: List[float]) -> float:\n return _median_even(v) if len(v) % 2 == 0 else _median_odd(v)", "def median(values):\n # Write the median() function\n midpoint = int(len(values) / 2)\n if len(values) % 2 == 0:\n median = (values[midpoin...
[ "0.85748947", "0.83829796", "0.8311173", "0.82589555", "0.8222346", "0.81842107", "0.81027406", "0.8075546", "0.8068739", "0.79999703", "0.7880431", "0.78548086", "0.78201586", "0.7791548", "0.7739428", "0.7699509", "0.7699283", "0.7688011", "0.7679814", "0.7627588", "0.75781...
0.81193554
6
MillerRabin primality test for n < 2 64
def is_prime(n): test_vals = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37] if n in test_vals: return True d = n - 1 s = 0 while not d & 1: d = d >> 1 s += 1 for a in test_vals: for r in range(0, s): if (a ** (d * (1 << r))) % n != (n - 1) \ and (a ** d) % n != 1: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def miller_rabin(n):\n assert(n >= 1)\n if n == 2:\n return True\n if n <= 1 or not n & 1:\n return False\n\n primes = [2, 3, 5, 7, 11, 13, 17, 19, 23]\n\n d = n - 1\n s = 0\n while not d & 1:\n d >>= 1\n s += 1\n\n for prime in primes:\n if prime >= n:\n ...
[ "0.8272356", "0.8147638", "0.8147638", "0.78105867", "0.77271765", "0.76982826", "0.76699215", "0.7629885", "0.7616009", "0.7396357", "0.73662406", "0.7359161", "0.7331089", "0.73296785", "0.726059", "0.7253802", "0.71390456", "0.70460534", "0.6992279", "0.6938401", "0.690631...
0.6796784
31
Get a prime number larger than n Not guaranteed to be the next prime
def get_larger_prime(n): result = n + (1 if n % 2 == 0 else 2) while not is_prime(result): result += 2 return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_prime(n):\n i = n + 1\n while not is_prime(i):\n i += 1\n return i", "def nth_prime(n):\n # Tweaked version of the itertools nth recipe\n return next(islice(generate_primes(), n-1, None), None)", "def is_prime(n):\n return mr_prime(n)", "def nth_prime(n: int) -> int:\n la...
[ "0.82137835", "0.8201824", "0.8157683", "0.80231524", "0.79650825", "0.7892381", "0.7852389", "0.78492236", "0.779757", "0.77452135", "0.77441525", "0.7719324", "0.77051294", "0.76462847", "0.76133084", "0.75309426", "0.74999046", "0.74076384", "0.73986924", "0.73933405", "0....
0.83887327
0
Constructeur to set the parameters of the density.
def __init__(self, alpha0, alpha1, beta, EPS=1E-8, discretization=100): LoiAPriori.__init__(self, EPS=EPS, discretization=discretization) self.__alpha0 = alpha0 self.__alpha1 = alpha1 self.__beta = beta self.__eta = 3./8.*(1. - self.__alpha0 - self.__alpha1 - 2.*self.__beta) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_density_params(self, theta, scale=None):\n self.density.loc = self.mean(theta)\n if scale is not None:\n self.density.scale = scale", "def density(self, density):\n\n self._density = density", "def set_density(self, theta, scale):\n self.density = Normal(self.mean...
[ "0.6944613", "0.69130623", "0.6854342", "0.6680744", "0.660867", "0.65039307", "0.6495796", "0.64872825", "0.6480063", "0.6416365", "0.6389142", "0.6388913", "0.6377092", "0.63707685", "0.63665646", "0.6358948", "0.6357998", "0.63351107", "0.63284504", "0.6328399", "0.6316728...
0.0
-1
Return the joint proba at r1, r2.
def probaR1R2(self, r1, r2): if r1 == 0.: if r2 == 0.: return self.__alpha0 elif r2 == 1.: return self.__beta else: return self.__eta * (1. - r2) if r1 == 1.: if r2 == 0.: return self.__bet...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def joint_pairs(self):\n return ((1, 4), (2, 5), (3, 6), (14, 11), (15, 12), (16, 13))", "def joint_proba(self, X):\n return self.weights * self._bernoulli(X)", "def probaR2CondR1(self, r1, r2):\n\n if r1 == 0.0:\n if r2 == 0.0:\n return self.__alpha0 / s...
[ "0.6219277", "0.61670285", "0.61366516", "0.6005037", "0.5808568", "0.56800926", "0.5561546", "0.55009794", "0.54992795", "0.5447199", "0.5431401", "0.54246116", "0.54233605", "0.54017335", "0.5359065", "0.5324804", "0.5323142", "0.52881074", "0.52518237", "0.5247377", "0.524...
0.65843827
0
Return the marginal proba at r.
def probaR(self, r): if r == 0.: return self.__alpha0 + self.__beta + self.__eta / 2. if r == 1.: return self.__alpha1 + self.__beta + self.__eta / 2. return self.__eta * (3./2. + r - r*r)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def marginal(self):\n m = np.zeros(len(self.domain))\n for fnode in self.neighbors:\n m += self.received[fnode]\n return np.exp(normalize(m))", "def marginalDistribution(self, x, variable):\n return self._distribution.marginal(x, variable)", "def calculate_marginal(self):\n ...
[ "0.6157373", "0.6125072", "0.6066535", "0.6058912", "0.5944578", "0.59029824", "0.5808245", "0.57462287", "0.5690898", "0.5666928", "0.5655451", "0.5595766", "0.55798787", "0.55728155", "0.55728155", "0.5522183", "0.55125934", "0.5512489", "0.5484048", "0.54618627", "0.544234...
0.68406016
0
generate a random string of alpha + spaces equal to length
def generate(length): alpha = map(chr, range(97, 123)) alpha.append(' ') result = "" for x in range(length): result += alpha[random.randrange(0,27)] return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def RandomAlphaNumWord(length):\n return ''.join([RandomAlphaNumChar() for _ in range(0, length)])", "def random_str(length=8, letters=string.ascii_letters + string.digits):\r\n return \"\".join(random.choice(letters) for x in range(length))", "def random_string(length=25):\n return ''.join(random.choic...
[ "0.8442623", "0.83673245", "0.82823306", "0.82814884", "0.82244056", "0.82085603", "0.82072", "0.81841785", "0.81750053", "0.80985534", "0.80796605", "0.80747044", "0.80681646", "0.80655473", "0.8038588", "0.8022799", "0.8020795", "0.8008102", "0.8005021", "0.7993443", "0.798...
0.85462075
0
Reset the drift detector. Resets the DDM Drift detector. This should be called after `detect()` returns True to reset internal parameters.
def reset(self,): self.i = 0 self.pi = 1.0 self.si = 0.0 self.pi_min = float("inf") self.si_min = float("inf")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Reset(self, ResetD = False):\n if ResetD: self.D = self.DInit\n self.NAcc = 0.\n self.NAtt = 0.", "def resetDetector (self):\n self.mpr121._reset ()", "def reset(self):\n self.num_frames = 0\n self.nbin = self.nfft // 2 + 1\n\n if self.D==1:\n self.fft_in_buf...
[ "0.68778163", "0.65773445", "0.6443813", "0.62938493", "0.61762637", "0.6095777", "0.604903", "0.60315496", "0.60047203", "0.592436", "0.5831448", "0.5789184", "0.5780796", "0.5773765", "0.5739929", "0.5707811", "0.56759995", "0.56634724", "0.56376356", "0.5634935", "0.562867...
0.0
-1
Applies word dropout to an input Variable. Dropout isn't constant across batch examples. This is only to be used to drop input symbols (i.e. before the embedding layer)
def word_dropout(inp, target, p=0.0, training=True, reserved_codes=()): if not training or p == 0: return inp mask = word_dropout_mask(inp.data, p, reserved_codes=reserved_codes) return inp.masked_fill(Variable(mask), target)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __call__(self,\n input_word,\n input_word_mask):\n with tf.variable_scope(self.scope, reuse=tf.AUTO_REUSE):\n input_word_embedding_mask = input_word_mask\n input_word_embedding = tf.squeeze(self.embedding_layer(input_word), axis=-2)\n \n ...
[ "0.7276263", "0.720548", "0.6847571", "0.6613133", "0.6469184", "0.64488655", "0.6399754", "0.6389784", "0.625298", "0.5954456", "0.59279144", "0.59155816", "0.5870367", "0.5782119", "0.5735164", "0.5715335", "0.5670086", "0.55773854", "0.55761707", "0.5572221", "0.55694693",...
0.73293495
0
Instantiate an Embedding module from a fitted Dict.
def from_dict(cls, d, emb_dim, p=0.0, add_positional=False, max_len=5000, padding_idx=None, **kwargs): if p > 0.0 and d.get_unk() is None: raise ValueError("Word dropout requires unknown token") inst = cls(len(d), emb_dim, padding_idx=d.get_pad(), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_dictionary(cls,\n dictionary):\n if dictionary is None:\n return None\n\n # Extract variables from the dictionary\n enable_worm_on_external_target = dictionary.get('enableWormOnExternalTarget')\n policy_type = dictionary.get('policyType')\n ...
[ "0.61104006", "0.6067204", "0.6003864", "0.5935257", "0.5893066", "0.5861109", "0.5850618", "0.58429676", "0.5842839", "0.5830996", "0.5807956", "0.5787398", "0.5763948", "0.5730169", "0.5719661", "0.5708326", "0.57009053", "0.5690724", "0.5651717", "0.5631666", "0.56305486",...
0.620632
0
Load embeddings from a weight matrix with words `words` as rows.
def init_embeddings(self, weight, words): # wrap in tensor if isinstance(weight, list): weight = torch.Tensor(weight).float() if isinstance(weight, np.ndarray): weight = torch.from_numpy(weight).float() # check embedding size if weight.size(1) != self.embe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_embedding_weights(self, weights):\n assert self.model is not None, (\n \"Cannot assign weights, apply build() before trying to \" \"loading embedding weights \"\n )\n emb_layer = self.model.get_layer(name=\"word_embedding\")\n assert emb_layer.output_dim == weights.s...
[ "0.7391219", "0.7092202", "0.70468843", "0.70298856", "0.6873526", "0.67775095", "0.6692423", "0.6606134", "0.6536549", "0.6517945", "0.6499557", "0.6477148", "0.6411822", "0.64050263", "0.63866097", "0.6371233", "0.6343471", "0.63424593", "0.633308", "0.6312807", "0.6295333"...
0.7301505
1
calculate the parity (sum(it)%2) of the iterable
def parity(it): return sum(it)%2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parity(n):\n # bin(n) returns 0b.... \n # bin(n)[2:] trims \"ob\"\n return sum(int(x) for x in bin(n)[2:]) % 2", "def parity(p):\n\n f = dict(zip(sorted(p), p))\n seen, neven = set(), 0\n\n for x in p:\n if x in seen:\n continue\n\n c, l = x, 0\n while c not in see...
[ "0.78136903", "0.7612799", "0.71205205", "0.6951747", "0.69468606", "0.69354695", "0.6888333", "0.6780914", "0.6501096", "0.6481943", "0.6466265", "0.63605976", "0.63197446", "0.6310321", "0.6281249", "0.6269732", "0.6263378", "0.6141122", "0.6112712", "0.61013824", "0.608394...
0.91763633
0
Apply action to environment, then return observation and reward.
def step(self, action): self.steps += 1 self.robots[0].setAction(action) for i in range(self.num_agents): if i != 0 and self.policies[i:i+1]: # self.policies[0] is dummy self.robots[i].setAction(self.policies[i](self.robots[i].getObservation())) # rewards = [ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_action(self, action):\n return self.__environment.step(action)", "def run_one_step(self):\n # Get the current state, action and initialise the reward\n state = copy.copy(self.env.get_state())\n action = self.agent.get_action(state)\n reward = 0.0\n # Check if the e...
[ "0.77125806", "0.7108414", "0.7067796", "0.6913966", "0.68721795", "0.6863198", "0.6860378", "0.68041855", "0.6801775", "0.6743534", "0.67350036", "0.67293054", "0.67291236", "0.6707606", "0.6702209", "0.6695293", "0.66895103", "0.66783965", "0.6662368", "0.6662368", "0.66623...
0.61794937
64
returns True when the values of ndarray `a` are small.
def verySmall(a, delta=1e-30): # used when we really want the values to be 0, but this # can't be guaranteed due to floating errors. return np.average(a*a) <= delta
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isSmall(number):\n return abs(number) < epsilon", "def is1d(a):\n return np.sum(asarray(asarray(a).shape) > 1) <= 1", "def is_array(a):\n try:\n shape = a.shape\n return len(shape) >= 1\n except AttributeError:\n return False", "def test_constructed_is_small(self):\n ...
[ "0.66593975", "0.66150355", "0.648106", "0.6176655", "0.6168032", "0.6123765", "0.60556716", "0.59781396", "0.5901164", "0.5811848", "0.58041716", "0.5748773", "0.5708647", "0.5695639", "0.5548588", "0.5494029", "0.5474237", "0.5472861", "0.54479855", "0.54377204", "0.5431104...
0.74111456
0
Initialize the weigths according to the type of activation function.
def XavierInit(self): raw_std = (2 / (self.num_input + self.num_output))**0.5 if 'relu' == self.act_function: init_std = raw_std * (2**0.5) elif 'sigmoid' == self.act_function: init_std = raw_std else: init_std = raw_std # * 4 self.W = np.ran...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_weights(self):\n self.transformer.init_weights()\n if self.loss_cls.use_sigmoid:\n bias_init = bias_init_with_prob(0.01)\n for m in self.cls_branches:\n nn.init.constant_(m[-1].bias, bias_init)", "def initialise_weights(self): \n \n ...
[ "0.7108541", "0.7098255", "0.7088407", "0.70576185", "0.7041271", "0.69761795", "0.6954065", "0.6946985", "0.68991065", "0.68937653", "0.68890935", "0.6874208", "0.6831622", "0.6829417", "0.6829417", "0.6829417", "0.6824331", "0.6802368", "0.6792842", "0.6770777", "0.6762865"...
0.66079843
31
The identity block is the block that has no conv layer at shortcut. Arguments
def identity_block(input_tensor, kernel_size, filters, stage, block): filters1, filters2, filters3 = filters if K.image_data_format() == 'channels_last': _bn_axis = 3 else: _bn_axis = 1 conv_name_base = 'res' + str(stage) + block + '_branch...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def identity_block(self, input_tensor, filters, activation, stage, block, start_with_batch_norm = True):\n\n # Set the naming convention\n conv_name_base = 'res' + str(stage) + block + '_branch'\n batch_norm_name_base = 'batch_norm' + str(stage) + block + '_branch'\n\n x_shortcut = inpu...
[ "0.7128075", "0.7022187", "0.69112873", "0.6884249", "0.6850563", "0.6846568", "0.6822699", "0.6821866", "0.6803595", "0.6800122", "0.6784813", "0.6770751", "0.6714853", "0.67141736", "0.6663679", "0.66245866", "0.66224706", "0.66224706", "0.66083175", "0.65988076", "0.654811...
0.67161965
12