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
Check correct and incorrect slug product. If correct get 200. Else 404.
def test_product_slug(self): client = Client() slug = ['bryan-fox-snowboard-2017', 'some_slug'] # Correct and incorrect slug response = client.get('/products/{0}/'.format(slug[0])) self.assertEqual(response.status_code, 200) response = client.get('/products/{0}/'.format(slug[1]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_product_not_found(self):\n resp = self.app.get(\"/products/0\")\n self.assertEqual(resp.status_code, status.HTTP_404_NOT_FOUND)", "def test_handle_slug(self):\n with self.assertRaises(Resolver404):\n self.handler.handle(self.request, '/slug/')\n\n self.assertFa...
[ "0.658921", "0.6196541", "0.61412746", "0.60980344", "0.60805756", "0.60576993", "0.603319", "0.59828234", "0.5894423", "0.58910614", "0.58845127", "0.5844237", "0.5821877", "0.5821755", "0.5818993", "0.57686484", "0.5762091", "0.57581866", "0.5754918", "0.5736651", "0.573498...
0.7454123
0
Test getting the access token from the environment.
def test_env_access_token(context): os.environ[config.FLOWSERV_ACCESS_TOKEN] = '0001' assert context.access_token() == '0001' del os.environ[config.FLOWSERV_ACCESS_TOKEN] with pytest.raises(err.MissingConfigurationError): context.access_token()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_access_token_get(self):\n client = oauth.Client(self.consumer, None)\n resp, content = client.request(self._uri('request_token'), \"GET\")\n\n self.assertEqual(int(resp['status']), 200)", "def test_read_o_auth_access_token(self):\n pass", "def test_get_token(self):\n ...
[ "0.80234176", "0.8022443", "0.7518271", "0.74076235", "0.737169", "0.73325205", "0.7262664", "0.7193651", "0.7057185", "0.70393527", "0.70192176", "0.690629", "0.6881865", "0.6870095", "0.68644893", "0.6825018", "0.6789461", "0.67850584", "0.6780082", "0.67598647", "0.6752786...
0.75546944
2
calculate critical depth for channel
def critical_depth(self): crit_depth = math.pow((self.flow**2 / (self.width ** 2 * Channel.g)), (1/3)) return crit_depth
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getNoiseCancellationDepth(self, channel, group, unitCode=0):\n resp = self.XAPCommand('NCD', channel, group, unitCode=unitCode)\n return int(resp)", "def _do_get_level(self):\n logging.info(__name__ + ' : Read level of channel 1')\n result = self._execute('R1')\n return flo...
[ "0.62901497", "0.5909403", "0.5887863", "0.58119416", "0.57355464", "0.5699805", "0.56976295", "0.56908923", "0.5687975", "0.56634575", "0.5635147", "0.55939525", "0.5587108", "0.55854046", "0.5577045", "0.55746067", "0.5553643", "0.554123", "0.5517815", "0.54679245", "0.5450...
0.81144476
0
Return list of elements that match xpath selection
def elements(xpath_selection): driver = Driver().connect() return driver.find_elements_by_xpath(xpath_selection)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_elements(self, xpath:str):\n try:\n elements = self.driver.find_elements_by_xpath(xpath)\n \n except NoSuchElementException:\n elements = []\n \n return elements", "def check_and_get_all_elements_by_xpath(element, xpath):\r\n if element is ...
[ "0.72632265", "0.7032163", "0.6960781", "0.69426626", "0.66700983", "0.6572906", "0.65606785", "0.65600246", "0.6530396", "0.65061295", "0.6429806", "0.63339", "0.6318415", "0.6274125", "0.62648416", "0.625509", "0.6239202", "0.6146674", "0.61400735", "0.6135537", "0.6130235"...
0.8069866
0
Uniformly samples a probability vector from a simplex of dimension dim.
def sample_from_simplex(rng, dim): alpha = [1] * dim return rng.dirichlet(alpha)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uniform_sample(x):\n return np.random.choice(x)", "def sample_from_unit_ball(rng, dim):\n vec = rng.randn(dim)\n return vec / np.sqrt(np.sum(vec**2))", "def sample(probs):\n\n probs = probs / probs.sum()\n return np.random.choice(np.arange(len(probs)), p=probs.flatten())", "def sample_matrix(d...
[ "0.6513737", "0.64060307", "0.6203046", "0.6202805", "0.61577624", "0.61224073", "0.6090636", "0.6066158", "0.603131", "0.6016638", "0.5995204", "0.5994199", "0.59835684", "0.59835684", "0.5961476", "0.59314007", "0.59107697", "0.59033054", "0.58929074", "0.58718824", "0.5863...
0.74791205
0
>>> theoreticalMeanQueueLength(10, 2) 0.25 >>> theoreticalMeanQueueLength(5, 1) 0.25 >>> theoreticalMeanQueueLength(4, 2) 1.0 >>> theoreticalMeanQueueLength(5.5, 1.3) 0.3095238095238095 >>> theoreticalMeanQueueLength(5.5, 0) 0.0 >>> theoreticalMeanQueueLength(2, 1) 1.0 >>> type(theoreticalMeanQueueLength(10, 2))
def theoreticalMeanQueueLength(alpha, beta): # Returns float # Could create a float here to store b/a but that's a memory allocation that's probably worse than a 2nd division beta = float(beta) alpha = float(alpha) return (beta / alpha) / (1 - (beta / alpha))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_size_stays_same_with_peak():\n queue = Queue()\n queue.enqueue('val')\n assert queue.size() == 1\n queue.peak()\n assert queue.size() == 1", "def test_the_queue_size(the_queue):\n the_queue.enqueue(1)\n the_queue.enqueue(2)\n the_queue.enqueue(3)\n assert the_queue.size() == 3...
[ "0.58651394", "0.5854571", "0.55591404", "0.5519332", "0.5490667", "0.54316324", "0.5413617", "0.5374052", "0.53539133", "0.53103864", "0.5306466", "0.5282338", "0.5240975", "0.52187246", "0.5214034", "0.5208168", "0.51791215", "0.5176192", "0.51711935", "0.51706225", "0.5149...
0.6879336
0
>>> random.seed(57) >>> singleQueue(10, 3, 480) 3 >>> random.seed(101) >>> singleQueue(5, 3, 480) 6 >>> random.seed(101) >>> singleQueue(5, 3) 6 >>> random.seed(935) >>> singleQueue(10, 9, 280) 10 >>> type(singleQueue(10, 9, 280))
def singleQueue(alpha, beta, time=480): # Implement algorithm above in PDF, takes parameters, and returns the MAX queue length # ta : time to next customer arrival # ts : time until customer is finished with teller # c : current time # Q : current queue length # maxQ : the size of the longe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def small_queue():\n que = Queue()\n que.enqueue(1)\n que.enqueue(2)\n que.enqueue(3)\n que.enqueue(4)\n que.enqueue(5)\n return que", "def small_queue():\n queue = Queue()\n queue.enqueue(1)\n queue.enqueue(2)\n queue.enqueue(3)\n queue.enqueue(4)\n return queue", "def t...
[ "0.6827738", "0.6748132", "0.63704234", "0.63005215", "0.6297553", "0.6191212", "0.6153285", "0.61418706", "0.6133637", "0.6117563", "0.60782677", "0.6054516", "0.603271", "0.6024135", "0.60102314", "0.5979857", "0.59460694", "0.5944469", "0.59218574", "0.5913137", "0.5912773...
0.54482645
59
View function for home page of site
def index(request): teams = Team.objects.all().order_by('team_code') team_dictionary = {} for team in teams: if not team.eliminated: percentage_change = percentage_change_string(share_price_change(team)) team_dictionary[team.team_code] = [team.image, round(team.current_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def home(request):\n\treturn render(request, \"compta/home.html\")", "def home_page(request):\r\n return render(request, 'ez_main/home_page.html')", "def home(request):\r\n return render(request, 'home.html')", "def homepage(request):\n\treturn render(request, 'core/homepage.html')", "def home(request...
[ "0.85561705", "0.8463156", "0.8426648", "0.8388098", "0.8337306", "0.83208233", "0.8319217", "0.8253385", "0.8186879", "0.8180329", "0.8155009", "0.81181335", "0.8090556", "0.80876964", "0.80813605", "0.80692863", "0.80689037", "0.80665994", "0.80665994", "0.80665994", "0.806...
0.0
-1
This function finds the first row number (or cell number) in the array yxCells for which the y coordinate of the cell is equal to yi.
def findy1(yxCells,yi,numCells): yit = 0 found = False while (not found) and (yit<numCells): if int(yxCells[yit,0]) == yi: found = True else: yit = yit + 1 if found: y1 = yit else: y1 = -1 return y1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def findy2(yxCells,yi1,numCells):\r\n y = yxCells[yi1,0]\r\n yit = yi1 + 1\r\n found = True\r\n while (found) and (yit<numCells):\r\n if int(yxCells[yit,0]) != y:\r\n found = False\r\n else:\r\n yit = yit + 1\r\n if not found:\r\n y2 = yit - 1\r\n else:\...
[ "0.75829273", "0.65155596", "0.6378218", "0.6313116", "0.630849", "0.62761545", "0.6257664", "0.61946595", "0.61946595", "0.60901177", "0.60390794", "0.60261345", "0.5992114", "0.59424305", "0.59417045", "0.5941444", "0.5924897", "0.5921313", "0.5908533", "0.5894244", "0.5881...
0.8178398
0
This function finds the second row number (or cell number) in the array yxCells for which the y coordinate of the cell is equal to yxCells[yi1,0].
def findy2(yxCells,yi1,numCells): y = yxCells[yi1,0] yit = yi1 + 1 found = True while (found) and (yit<numCells): if int(yxCells[yit,0]) != y: found = False else: yit = yit + 1 if not found: y2 = yit - 1 else: y2 = -1 retur...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def findy1(yxCells,yi,numCells):\r\n yit = 0\r\n found = False\r\n while (not found) and (yit<numCells):\r\n if int(yxCells[yit,0]) == yi:\r\n found = True\r\n else:\r\n yit = yit + 1\r\n if found:\r\n y1 = yit\r\n else:\r\n y1 = -1\r\n return y1"...
[ "0.8289633", "0.67132616", "0.65982705", "0.6532075", "0.6490083", "0.63672096", "0.6359719", "0.6287355", "0.62455004", "0.6204707", "0.6198614", "0.61552215", "0.6106332", "0.60795254", "0.60577744", "0.60274446", "0.60160166", "0.5994412", "0.5986727", "0.59790486", "0.596...
0.84398085
0
Return a string representation of the Article.
def __str__(self): return self.title
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __repr__(self):\n\n return \"<Art art_id={} title={}>\".format(self.art_id, self.title)", "def __repr__(self):\r\n\r\n return f\"<News: id = {self.news_id}, title = {self.title} summary = {self.summary}>\"", "def __repr__(self):\n return '<HelpArticle(title=%r, description=%r, body=%r)...
[ "0.667174", "0.65628564", "0.65542156", "0.6475602", "0.63945377", "0.63559824", "0.6350579", "0.6313081", "0.6306545", "0.6305313", "0.62987596", "0.6284053", "0.6272784", "0.62485605", "0.62356454", "0.62318623", "0.6231384", "0.6226829", "0.62054044", "0.6201455", "0.61901...
0.0
-1
Get |Topics| associated with the Article. Returns |QuerySet| of |Topics| The |Topics| associated with the Article's |Tags|.
def topics(self): # use get_model to avoid circular dependency topic_model = apps.get_model('tags', 'Topic') return topic_model.objects.filter(tag__in=self.tags.all()).distinct()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_topics(self, tags=None):\r\n params = {}\r\n if tags:\r\n params['tags'] = ','.join(tags)\r\n resp = self._make_request('get', 'topics', params=params)\r\n return resp.json()", "def topics(self):\n return topics.Topics(self)", "def topics(self):\r\n ...
[ "0.7411521", "0.65844864", "0.6447787", "0.63479364", "0.62560713", "0.6235867", "0.61804545", "0.61067253", "0.5925587", "0.59224683", "0.5875778", "0.57284695", "0.5685424", "0.5603984", "0.5523092", "0.55012614", "0.5440436", "0.5358571", "0.5335155", "0.5321636", "0.52847...
0.7547527
0
Return a (copy) python dict of attrs.
def get_attrs(self): req_attrv = self._ptr.contents.attrv attrs = {} if bool(req_attrv): i = 0 while 1: s = bytestostr(req_attrv[i]) i += 1 if s == None: break try: k, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attrs_to_dict(self, attrs):\n return {k: v for k, v in attrs}", "def GetAttributes(self):\n return dict(self._attrs)", "def convert_attributes(cls, attrs):\n return {}", "def _get_attribute_dic(self, attrs):\n attr_dic = {}\n for attr_pair in attrs:\n attr_di...
[ "0.81931955", "0.79099655", "0.7744149", "0.752881", "0.75230014", "0.7422697", "0.7421758", "0.7421747", "0.7421747", "0.7421747", "0.74175173", "0.7390118", "0.7384318", "0.73829633", "0.7380286", "0.7378241", "0.73328716", "0.73306566", "0.73155016", "0.72860557", "0.72644...
0.7040285
35
Free underlying connection object.
def free(self): libruss.russ_cconn_free(self._ptr) self._ptr = None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _close_connection(self):\n if self.connection:\n self.connection.destroy()\n self.connection = None", "def __del__(self):\n _free_cached_connection(self._connection_hash)", "def close(self):\n self.connection = None", "def free(self):\n libruss.russ_sconn...
[ "0.80098855", "0.7978816", "0.791133", "0.7877168", "0.78292173", "0.7819141", "0.7718651", "0.7716362", "0.77008814", "0.7619638", "0.7603113", "0.7518174", "0.7501588", "0.7471634", "0.7471634", "0.7455288", "0.7453887", "0.74274457", "0.73892033", "0.7370736", "0.7354472",...
0.8000046
1
Free underlying connection object.
def free(self): libruss.russ_sconn_free(self._ptr) self._ptr = None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _close_connection(self):\n if self.connection:\n self.connection.destroy()\n self.connection = None", "def free(self):\n libruss.russ_cconn_free(self._ptr)\n self._ptr = None", "def __del__(self):\n _free_cached_connection(self._connection_hash)", "def cl...
[ "0.80098855", "0.8000046", "0.7978816", "0.791133", "0.78292173", "0.7819141", "0.7718651", "0.7716362", "0.77008814", "0.7619638", "0.7603113", "0.7518174", "0.7501588", "0.7471634", "0.7471634", "0.7455288", "0.7453887", "0.74274457", "0.73892033", "0.7370736", "0.7354472",...
0.7877168
4
Close current session, and return it to the pool.
def close_db_session(self, session): session.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close_session(self):\n self.pool.add_connection(self)", "def close_session(self):\n self.sess.close()", "def close(self):\n self.session.close()\n self.session = None", "def close(self):\n self.__session.close()", "def close(self):\n self.__session.close()", ...
[ "0.8009916", "0.78669214", "0.7533518", "0.7519176", "0.7519176", "0.7519176", "0.7519176", "0.7519176", "0.7519176", "0.74962586", "0.7490354", "0.74861366", "0.7386012", "0.73398507", "0.73393935", "0.7318495", "0.7289017", "0.7272693", "0.7272693", "0.7272693", "0.72644824...
0.7274848
17
Return boolean True or False if a given time (in minutes) is a sanctioned working day minute.
def is_sanctioned_time(self, minute): return ((minute - self.day_start) % self.minutes_in_24h) < (self.hours_per_day * 60)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_lunchtime(hour, is_am):\n if (hour > 1) and (hour <= 12):\n if (hour == 11) and (is_am == True):\n return True\n elif (hour == 12) and (is_am == False):\n return True\n else:\n return False", "def is_lunch_hour(self, time_of_day):\n return (t...
[ "0.7060585", "0.6823435", "0.67599636", "0.66870034", "0.6581888", "0.6580794", "0.6580794", "0.65155804", "0.642645", "0.634478", "0.6308255", "0.6298105", "0.6254725", "0.60870916", "0.60259885", "0.5977793", "0.5957705", "0.5954107", "0.5928117", "0.58956987", "0.58809566"...
0.7972499
0
Calculate learning rate alpha with 0 <= alpha <= 1.
def _calc_learning_rate(self, curr_it: int, mode: str) -> float: return decreasing_rate( self.learning_rate_start, self.learning_rate_end, iteration_max=self.max_iterations_, iteration=curr_it, mode=mode, )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def learning_rate(epoch):\n return alpha / (1 + decay_rate * epoch)", "def learning_rate(epoch):\n return alpha / (1 + decay_rate * epoch)", "def learning_rate_decay(alpha, decay_rate, global_step, decay_step):\n epoc_number = int(global_step / decay_step)\n alpha /= (1 + decay_rate * epoc_...
[ "0.8127594", "0.8127594", "0.7562064", "0.725726", "0.7219325", "0.7142297", "0.70208716", "0.7014866", "0.69735557", "0.6944943", "0.68474543", "0.68350697", "0.6824941", "0.6792757", "0.6730715", "0.6680231", "0.6656898", "0.6645465", "0.6629446", "0.6626984", "0.66142786",...
0.0
-1
Get best matching unit (BMU) for datapoint.
def get_bmu( self, datapoint: np.ndarray, som_array: np.ndarray ) -> Tuple[int, int]: a = self._get_node_distance_matrix( datapoint.astype(np.float64), som_array ) return np.argwhere(a == np.min(a))[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_BMU(self, data_axis):\n distSq = (np.square(self.weights - data_axis)).sum(axis=2)\n return np.unravel_index(np.argmin(distSq, axis=None), distSq.shape)", "def calculate_bmu(self, input):\n result = 0\n\n if len(input) > self.som.input_count:\n raise Exception(\n ...
[ "0.64036876", "0.6018956", "0.582215", "0.5670958", "0.5578566", "0.55344296", "0.5532412", "0.54925793", "0.54270715", "0.54244936", "0.5421139", "0.54158753", "0.53563285", "0.5346828", "0.53390944", "0.5314493", "0.5313669", "0.5284438", "0.528263", "0.5265581", "0.5264813...
0.6376203
1
Get distance of datapoint and node using Euclidean distance.
def _get_node_distance_matrix( self, datapoint: np.ndarray, som_array: np.ndarray ) -> np.ndarray: # algorithms on the full matrix if self.distance_metric == "euclidean": return np.linalg.norm(som_array - datapoint, axis=2) # node-by-node algorithms distmat = np....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dist(self, node_0, node_1):\n coord_0, coord_1 = self.coords[node_0], self.coords[node_1]\n return math.sqrt((coord_0[0] - coord_1[0]) ** 2 + (coord_0[1] - coord_1[1]) ** 2)", "def get_distance(self, node):\n return np.sqrt(\n (self.x - node.x) ** 2 +\n (self.y - no...
[ "0.79328066", "0.77566135", "0.77422273", "0.7349354", "0.7150661", "0.71258956", "0.71257883", "0.7101896", "0.7101896", "0.69843704", "0.6973574", "0.6970537", "0.6951986", "0.69121814", "0.6908583", "0.68991184", "0.68464375", "0.68453586", "0.6833757", "0.6822348", "0.681...
0.0
-1
Get quantization error for `X` (or the training data).
def get_quantization_error(self, X: Optional[Sequence] = None) -> float: if not self.fitted_: raise RuntimeError("SOM is not fitted!") if X is None: X = self.X_ weights_per_datapoint = self._get_weights_per_datapoint(X) quantization_errors = np.linalg.norm( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quantization_error(self, data):\n self._check_input_len(data)\n return norm(data-self.quantization(data), axis=1).mean()", "def quantization_error(self, some_tensor, bits=32):\n quantized_obj = self.quantize(some_tensor, bits=bits)\n return np.linalg.norm(np.reshape(some_tensor, [...
[ "0.7647612", "0.6465805", "0.6364655", "0.62212306", "0.6207699", "0.617651", "0.61502934", "0.6015857", "0.5998304", "0.594391", "0.5933904", "0.5909131", "0.5877151", "0.58709615", "0.5862655", "0.5855851", "0.5838503", "0.583521", "0.5835065", "0.5813866", "0.58003026", ...
0.7857711
0
A context manager to load JSON from a file and write back when done.
def editing_file(jsonfile, *, _open=open, _edit=(lambda f: _edit_file(f)), ): if isinstance(jsonfile, str): filename = jsonfile with _open(filename, 'r+') as jsonfile: yield from _editing_file(jsonfile) else: yield from _edit...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load(self):\n if not self.exist:\n self.create()\n\n with open(self.file_path, encoding=Config.ENCODING) as file:\n self.data = json.load(file)", "def _load(self):\n if self.file_path.exists():\n with open(self.file_path) as fid:\n self.dat...
[ "0.68749166", "0.659549", "0.6461662", "0.6408422", "0.63778174", "0.6321314", "0.6296277", "0.62610817", "0.62610817", "0.62231725", "0.62071353", "0.62033045", "0.61805916", "0.6174645", "0.61636305", "0.6156551", "0.6142511", "0.61319745", "0.61271197", "0.61178863", "0.60...
0.6014537
29
Tokenize text into token sequence
def tokenize(text: str): result = [] for s in text: result.append(s) return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tokenize(text):\n sentence = Sentence(text)\n return sentence.tokens()", "def identity_tokenizer(text):\n return text", "def tokenize(text):\n return tokens_re.findall(text)", "def tokenize(text, token):\n text = [token(x) for x in text]\n return text", "def tokenize(text):\n return t...
[ "0.8072262", "0.78360075", "0.7814808", "0.77317435", "0.7726369", "0.7644835", "0.7638013", "0.7591691", "0.7535324", "0.75221825", "0.75103766", "0.75021714", "0.74881697", "0.7450038", "0.7413048", "0.74124503", "0.7394922", "0.7383691", "0.73826504", "0.7380765", "0.73708...
0.7205615
29
Opens a new database connection if there is none yet for the current application context.
def connect_db(): top = _app_ctx_stack.top if not hasattr(top, 'sqlite_db'): top.sqlite_db = sqlite3.dbapi2.connect( app.config['DATABASE'], detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES,) return top.sqlite_db
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def db_open():\n if not hasattr(g, 'sqlite_db'):\n g.sqlite_db = db_connect()\n return g.sqlite_db", "def open_database(self):\n if self._conn is None:\n self._conn = sqlite3.connect(self._db_path)", "def open_db(db_name: str = DB_NAME) -> DBConnection:\n return sqlite3.connec...
[ "0.77395326", "0.75841486", "0.73192275", "0.71692723", "0.70234054", "0.6968623", "0.69559854", "0.6949747", "0.6898825", "0.68432045", "0.6830968", "0.68195665", "0.6806175", "0.6796217", "0.6769638", "0.6761663", "0.67513704", "0.6748013", "0.67330843", "0.6701283", "0.668...
0.6657254
29
Get recipes. Return recipes given list of ingredients and/or keywords.
def getRecipes(self, keywords=[], all_ingredients={}, include_ingredients={}, exclude_ingredients={}, sortby=["relevance", "popular"], cols=None, per_page=None, page=None): include_ingredients = dict([(k, [w.lower() for w in v]) \ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_recipe(ingredients):\n\n params = '+'.join(ingredients.split())\n url_search = SEARCH_URL.format(params)\n response = req.get(url_search)\n\n return response.content", "def list_recipes(environ, start_response):\n return list_entities(environ, start_response, 'list_recipes')", "def li...
[ "0.7190902", "0.6945271", "0.68375164", "0.67425925", "0.6740046", "0.6690002", "0.62305725", "0.616229", "0.6099011", "0.6023986", "0.60045105", "0.5996627", "0.59668255", "0.590135", "0.5862542", "0.58604926", "0.58584476", "0.58535707", "0.58304", "0.58194274", "0.5786319"...
0.68493795
2
Prime of Relu function Relu'(x) = 1, if x>0 = 0, if x<=0
def __Relu_prime(self, x): return x/x
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def relu_prime(z: float) -> float:\n return 1.0 if z > 0 else 0.0", "def relu_prime(h):\n return_value = h\n return_value[return_value <= 0] = 0\n return_value[return_value > 0 ] = 1\n return return_value", "def p(x):\n if x<0 or x>1:\n return 0\n else:\n return 1", "de...
[ "0.7190495", "0.6832396", "0.66626394", "0.6316759", "0.6241656", "0.6214419", "0.6214419", "0.6074705", "0.6001567", "0.59715545", "0.59545225", "0.5903969", "0.5843263", "0.58146197", "0.5786263", "0.5772568", "0.57677054", "0.57636863", "0.57632124", "0.5758197", "0.575307...
0.73655725
0
Adapt learning rate with O(1/t) schedule where lr = lr0s/max{epoch, s}. Learning rate stays as a constant during the first 's' epoch
def __learning_rate(self, lr0, epoch): """ Dan's Methos """ lrs = lr0 * 0.001 c = np.power((lrs/lr0), 1.0/self.__maxEpoch) return lr0*np.power(c, epoch)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def adjust_learning_rate_SR(optimizer, epoch):\r\n lr = opt.lr * (0.1 ** (epoch // opt.step))\r\n return lr", "def adjust_learning_rate(optimizer, epoch):\n lr = opt.lr * (0.5 ** (epoch // opt.step))\n return lr", "def adjust_learning_rate(optimizer, epoch, args):\n lr = args.lr\n if args.co...
[ "0.82340795", "0.7997043", "0.78773576", "0.7858402", "0.7856574", "0.781631", "0.7803528", "0.7791278", "0.7787144", "0.77822644", "0.7781637", "0.77344096", "0.77099586", "0.7700821", "0.76947147", "0.76938796", "0.76922023", "0.7691837", "0.7691822", "0.76892585", "0.76863...
0.7563922
64
Generates the box location encoding predictions and box class score predictions. Each tensor in the output list `box_encoding_predictions_list` and `class_score_predictions_list` corresponds to a tensor in the input `feature_map_tensor_list`.
def _predict(self, feature_map_tensor_list): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _predict(self, feature_map_tensor_list):\n box_encoding_predictions_list = []\n class_score_predictions_list = []\n num_class_slots = self._num_classes + 1\n box_code_size = self._box_code_size\n\n box_predictor_scopes = [misc_utils.IdentityContextManager()]\n if len(feature_map_tensor_list) ...
[ "0.84342855", "0.76772094", "0.7580443", "0.74225134", "0.6450012", "0.62850994", "0.614598", "0.6009263", "0.5973863", "0.59000057", "0.58550006", "0.58293456", "0.58067447", "0.5757097", "0.5726913", "0.56904376", "0.5668122", "0.56402946", "0.56331694", "0.56111604", "0.56...
0.5629149
19
Generates the box location encoding predictions and box class score predictions. Each tensor in the output list `box_encoding_predictions_list` and `class_score_predictions_list` corresponds to a tensor in the input `feature_map_tensor_list`, and the num of anchors generated for `i`th feature map, `num_anchors_i = heig...
def _predict(self, feature_map_tensor_list): box_encoding_predictions_list = [] class_score_predictions_list = [] num_class_slots = self._num_classes + 1 box_code_size = self._box_code_size box_predictor_scopes = [misc_utils.IdentityContextManager()] if len(feature_map_tensor_list) > 1: b...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _predict_boxes_and_classes(self, feature_map):\n\n spatial_averaged_feature_map = tf.reduce_mean(\n feature_map, [1, 2], keepdims=True, name='AvgPool')\n\n flattened_feature_map = tf.squeeze(spatial_averaged_feature_map)\n with slim.arg_scope(self._fc_hyperparams_fn()):\n box_encodings = s...
[ "0.735801", "0.7195622", "0.7004967", "0.6807966", "0.6314374", "0.6109698", "0.6091003", "0.6087418", "0.60706794", "0.60416335", "0.59818774", "0.5927754", "0.5884162", "0.5879677", "0.5875719", "0.5843859", "0.5830364", "0.582641", "0.5825551", "0.58097345", "0.57890266", ...
0.8090409
0
Only initialize the weights that have not yet been initialized by other means, such as importing a metagraph and a checkpoint. It's useful when extending an existing model.
def initialize_uninitialized_variables(sess): uninit_vars = [] uninit_tensors = [] for var in tf.global_variables(): uninit_vars.append(var) uninit_tensors.append(tf.is_variable_initialized(var)) uninit_bools = sess.run(uninit_tensors) uninit = zip(uninit_bools, uninit_vars) u...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _initialize_weights(self):\n pass", "def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)\n # Tie weights if needed\n self.tie_weights()", "def initialize_weights(self):\n weights_initializer.WeightsInitializer.initialize_layer_or_model(\n ...
[ "0.89088494", "0.85262924", "0.8505632", "0.84584665", "0.8366426", "0.8341837", "0.8324054", "0.81215197", "0.8059524", "0.80433196", "0.8019694", "0.7989823", "0.79871625", "0.79512954", "0.7946513", "0.7918236", "0.7876699", "0.7781223", "0.77741396", "0.77741396", "0.7770...
0.0
-1
Computes the partial derivatives needed for taylor expansion of a given formula
def compParDerivs(f:sy.Matrix, fStr:str, q:sy.Symbol, isMat:bool, maxPDerivDeg:int, repr:polynomialRepr)->dict: if __debug__: assert repr.nDims == q.shape[0]*q.shape[1] #Definitions # array2mat = [{'ImmutableDenseMatrix':np.matrix},'numpy'] array2mat = [{'ImmutableDenseMatrix': np.array}, 'nump...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def taylor_expansion(self,g_temp,g_step,var):\n A=np.zeros([self.n+1,self.n])\n for i in range(self.n):\n A[self.n][i]=1\n for j in range(self.n):\n if(i==j): A[i][j]=2.*var[i]+2.+g_temp*np.sum([self.XXZ.Z(k,i) for k in range(self.n) if k!=i])\n else: A[i][j]=-g_temp*self.XXZ.Z(j,i)\n...
[ "0.6768053", "0.6687769", "0.66114706", "0.65666795", "0.62205935", "0.61868376", "0.6186256", "0.6170451", "0.60326946", "0.59284925", "0.59212565", "0.58489406", "0.581116", "0.5807021", "0.57612294", "0.5747644", "0.57063293", "0.56821346", "0.5658252", "0.5589422", "0.557...
0.0
-1
Flatpak builds have no user Dockerfiles, dockefile check must be skipped
def test_flatpak_skip_dockerfile_check(self, tmpdir, docker_tasker, caplog): runner = mock_env(tmpdir, docker_tasker, flatpak=True) runner.run() assert 'Skipping Dockerfile checks' in caplog.text
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def docker_allow_fallback():\n return False", "def req_build(container):\n try:\n return 'dockerfile' in self.kard.env.get_container(container)\n except KeyError:\n return False", "def test_docker_args_not_set(self):\n with open(\".scuba.yml\", \"w\...
[ "0.62517756", "0.61374396", "0.5804813", "0.57913285", "0.5721764", "0.5684935", "0.5643532", "0.56358886", "0.5592312", "0.5540121", "0.55232626", "0.5515189", "0.55061966", "0.5475223", "0.54118997", "0.5399752", "0.538652", "0.5352851", "0.5345618", "0.5331039", "0.5330214...
0.72279686
0
Returns a string containing the atom type index of all nonshell atoms.
def type_core(self): type_core = ' '.join(['{}'.format(atom.atom_type_index) for atom in self.atom_types if 'shell' not in atom.label]) return type_core
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def type_shell(self):\n type_shell = ' '.join(['{}'.format(atom.atom_type_index) for atom in self.atom_types\n if 'shell' in atom.label])\n return type_shell", "def getAtomTypes(self):\n return self._raw_data['AMBER_ATOM_TYPE']", "def atomIndex(molecule):\n ...
[ "0.66035914", "0.61931145", "0.5880314", "0.5821177", "0.58102995", "0.57999057", "0.57632035", "0.56780046", "0.55700916", "0.54172486", "0.5385699", "0.5336651", "0.53228617", "0.5299866", "0.52869755", "0.5205435", "0.51969427", "0.51744175", "0.5169515", "0.51487714", "0....
0.7056356
0
Test exception on missing observation_type `name`.
def test_name_missing(self) -> None: with pytest.raises(NotFound): ObservationType.from_name('Missing ObservationType Name')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_name_already_exists(self) -> None:\n with pytest.raises(IntegrityError):\n ObservationType.add({'name': 'clear', 'units': 'mag',\n 'description': 'Un-filtered apparent magnitude.'})", "def test_from_name(self, testdata: TestData) -> None:\n for re...
[ "0.714681", "0.6797316", "0.6637088", "0.65174526", "0.6463375", "0.63962173", "0.6394298", "0.6307643", "0.6269365", "0.62532055", "0.6207187", "0.6199122", "0.6193437", "0.6178129", "0.6132955", "0.61257845", "0.60882986", "0.6046934", "0.60154575", "0.5983846", "0.5973622"...
0.826112
0
Computes the precision for the specified values of k
def num_correct(output, target, topk=(1,)): with torch.no_grad(): maxk = max(topk) batch_size = target.size(0) _, pred = output.topk(maxk, 1, True, True) pred = pred.t() correct = pred.eq(target.view(1, -1).expand_as(pred)) res = [] for k in topk: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den", "def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\...
[ "0.76427615", "0.74189496", "0.7418079", "0.72710466", "0.72456723", "0.72446615", "0.7237539", "0.72213703", "0.7210107", "0.7058935", "0.6852219", "0.6786084", "0.67836976", "0.6768417", "0.67273885", "0.67181736", "0.67181736", "0.67181736", "0.67181736", "0.67181736", "0....
0.0
-1
Gets the max_unavailable of this V1RollingUpdateDaemonSet.
def max_unavailable(self): return self._max_unavailable
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_unavailable(self) -> Optional[pulumi.Input[int]]:\n return pulumi.get(self, \"max_unavailable\")", "def max_unavailable(self) -> Optional[pulumi.Input[Union[int, str]]]:\n return pulumi.get(self, \"max_unavailable\")", "def max_unavailable(self) -> Optional[pulumi.Input[Union[int, str]]]:...
[ "0.73216414", "0.7141592", "0.7141592", "0.6619507", "0.5736082", "0.5640713", "0.55142033", "0.5432947", "0.53619117", "0.53495646", "0.52771425", "0.5263266", "0.5251003", "0.52393997", "0.52380157", "0.520907", "0.51927626", "0.51927626", "0.51904047", "0.5182815", "0.5180...
0.7717539
0
Sets the max_unavailable of this V1RollingUpdateDaemonSet.
def max_unavailable(self, max_unavailable): self._max_unavailable = max_unavailable
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_unavailable(self):\n return self._max_unavailable", "def max_unavailable(self) -> Optional[pulumi.Input[int]]:\n return pulumi.get(self, \"max_unavailable\")", "def max_unavailable(self) -> Optional[pulumi.Input[Union[int, str]]]:\n return pulumi.get(self, \"max_unavailable\")", ...
[ "0.6807201", "0.6430218", "0.62755066", "0.62755066", "0.5747988", "0.56941354", "0.5592315", "0.53425264", "0.53226036", "0.5228928", "0.51575124", "0.51575124", "0.50690466", "0.5063536", "0.49613446", "0.492695", "0.4902699", "0.48940057", "0.48858243", "0.48731622", "0.48...
0.8038761
0
Returns true if both objects are equal
def __eq__(self, other): if not isinstance(other, V1RollingUpdateDaemonSet): 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.8088132", "0.8088132", "0.8054589", "0.7982687", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", ...
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
Unit test to test addition function from the "Calculator" program The unit test tests output for both positive and negative int and float inputs
def test_addition(): assert calculator.add(7, 3) == 10 assert calculator.add(7.0, 3.0) == 10.0 assert calculator.add(7, -3) == 4 assert calculator.add(7.0, -3.0) == 4.0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_add_floats(self):\n print(\"---running test_add_floats\")\n result = some_math.add(10.5, 2)\n assert result == 12.5", "def test_add_returns_correct_result(self):\n result = self.calc.add(2, 2)\n self.assertEqual(4, result)", "def test_add_integers(self):\n pri...
[ "0.7821363", "0.76803166", "0.7525896", "0.7504049", "0.7504049", "0.7504049", "0.74906284", "0.7486339", "0.7455046", "0.7433606", "0.73653966", "0.7306822", "0.7298829", "0.7242824", "0.7218394", "0.7205552", "0.7195326", "0.71761835", "0.71430194", "0.7137453", "0.71317244...
0.85931945
0
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`.
def plot_confusion_matrix(y_true, y_pred, classes, normalize=False, title=None, cmap=plt.cm.Blues): if not title: if normalize: title = 'Normalized confusion matrix' else: title = 'Confusion matrix,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n...
[ "0.8194862", "0.80949175", "0.8029915", "0.8019153", "0.79941195", "0.7991258", "0.7980955", "0.7976606", "0.79610753", "0.79590565", "0.79378676", "0.7934962", "0.7934504", "0.79313844", "0.7926313", "0.7924577", "0.79241234", "0.7923211", "0.7923023", "0.7921931", "0.791787...
0.0
-1
Set weights of target model to the training model
def update_target_model(self): self.target_model.set_weights(self.model.get_weights())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _update_target_model(self):\n self.target_network.model.set_weights(self.policy_network.model.get_weights())", "def set_weights(self, weights):\n self.model.set_weights(weights)", "def update_target_network(self):\n self.target.set_weights(self.policy.get_weights()) # Update weights of...
[ "0.81758267", "0.7631681", "0.73449963", "0.7342966", "0.71622074", "0.7142081", "0.71329087", "0.708623", "0.7056338", "0.7013608", "0.7011287", "0.6967396", "0.69467306", "0.69372404", "0.6880636", "0.68579113", "0.6838431", "0.6817836", "0.678626", "0.67805785", "0.6765741...
0.8565081
1
2D gaussian mask should give the same result as MATLAB's fspecial('gaussian',[shape],[sigma])
def matlab_style_gauss2D(shape=(3, 3), sigma=0.5): m, n = [(ss - 1.) / 2. for ss in shape] y, x = np.ogrid[-m:m + 1, -n:n + 1] h = np.exp(-(x * x + y * y) / (2. * sigma * sigma)) h[h < np.finfo(h.dtype).eps * h.max()] = 0 sumh = h.sum() if sumh != 0: h /= sumh return h
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gaussian(size,sigma):\n a,b=np.ogrid[-size/2:size/2,-size/2:size/2]\n mask = a**2+b**2\n mask = np.exp(-mask.astype('float')/(2*float(sigma**2)))\n return mask", "def fspecial_gaussian(shape=(3, 3), sigma=0.5):\n m, n = [(ss - 1.) / 2. for ss in shape]\n y, x = np.ogrid[-m:m + 1, -n:n + 1]\...
[ "0.7829996", "0.7562562", "0.7226179", "0.7155936", "0.69486", "0.6848839", "0.67880386", "0.67694354", "0.6750549", "0.6750549", "0.6715692", "0.67122644", "0.66872513", "0.6681216", "0.6641507", "0.6611443", "0.65841174", "0.6566251", "0.65596884", "0.6504947", "0.650428", ...
0.667548
14
Called when the user specifies an intent for this skill
def on_intent(intent_request, session): intent = intent_request['intent'] intent_name = intent_request['intent']['name'] # Dispatch to your skill's intent handlers if intent_name == "test": return get_test_response() elif intent_name == "AMAZON.HelpIntent": return get_welcome_respon...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_intent(intent_request, session):\n\n intent = intent_request['intent']\n intent_name = intent_request['intent']['name']\n\n # Dispatch to your skill's intent handlers\n\n if intent_name not in skillmap:\n intent_name = \"NullSkill\"\n\n if intent_name in skillmap:\n try:\n ...
[ "0.7143966", "0.6956116", "0.6949057", "0.6905333", "0.68928874", "0.67641324", "0.6754843", "0.6722764", "0.6720773", "0.67161995", "0.6699252", "0.6691263", "0.6670276", "0.6645522", "0.6642719", "0.6638686", "0.6607724", "0.6594981", "0.6575682", "0.6570076", "0.65620786",...
0.6319344
36
The shelf id switch setting. This is the shelf id switch that is used to uniquely identify the shelf on the filer node.
def shelf_id(self): return self._shelf_id
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unique_id(self):\n return self.heater.id + \"_switch\"", "def shelf_uid(self):\n return self._shelf_uid", "def unique_id(self) -> str:\n return f\"{self._inst.lower()}-{self._sid_data['sid']}_switch-{self._data[self._sid_data['sid_ref']]}\"", "def unique_id(self):\n return f\"...
[ "0.6780022", "0.61002606", "0.5890775", "0.5766458", "0.5751767", "0.563422", "0.563422", "0.563422", "0.563422", "0.55570716", "0.5530996", "0.5457246", "0.5457246", "0.5457246", "0.5424933", "0.5226827", "0.5211649", "0.5211649", "0.5211649", "0.5193464", "0.5171958", "0....
0.71806484
0
Get the desired action from the config.
def from_config(self, type, index): config = self.config[type] return config[min(index, len(config) - 1)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def action(self) -> Optional[str]:\n return pulumi.get(self, \"action\")", "def action(self) -> Optional[str]:\n return pulumi.get(self, \"action\")", "def action(self) -> Optional[str]:\n return pulumi.get(self, \"action\")", "def get_action(self):\n return self.__action", "def...
[ "0.70547515", "0.70547515", "0.70547515", "0.6954523", "0.6915554", "0.6896", "0.68683064", "0.68252563", "0.6821224", "0.68155617", "0.67327374", "0.6709112", "0.6709112", "0.6701362", "0.66914433", "0.6685921", "0.6669831", "0.66627884", "0.66574436", "0.65224886", "0.65224...
0.0
-1
Entropy from fraction of particles in a box
def calc_ent_norm(a): return - 1.0 - ( a*np.log(a) + (1-a)*np.log(1-a) ) / np.log(2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def entropy(data):\n e = 0\n\n counter = collections.Counter(data)\n l = len(data)\n for count in counter.values():\n p_x = count / l\n e += - p_x * math.log2(p_x)\n\n return e", "def entropy(self):\n Z = self.sum()\n assert (Z > 0), 'Non-normalizabl...
[ "0.69334984", "0.6812961", "0.6742022", "0.6672168", "0.66648734", "0.6660434", "0.66408885", "0.66271585", "0.65934527", "0.65637594", "0.6560883", "0.6544813", "0.6532814", "0.6525367", "0.64682394", "0.64628756", "0.64365166", "0.64049244", "0.63879776", "0.63538146", "0.6...
0.0
-1
VGG 16layer model (configuration "D")
def model(pretrained=False, **kwargs): layers = make_layers(cfg['O'], dilation=dilation['D1']) cnv = np.cumsum(cnvs['OI']) if kwargs['args'].IN or kwargs['args'].INL else np.cumsum(cnvs['O']) model = VGG(layers, cnvs=cnv, **kwargs) if pretrained: pre2local_keymap = [('features.{}.weight'....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vgg16(pretrained=False, **kwargs):\n if pretrained:\n kwargs['init_weights'] = False\n model = VGG(make_layers(cfg['D']), **kwargs)\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['vgg16']), strict=False)\n return model", "def vgg16(pretrained=False, **kwargs)...
[ "0.7896579", "0.7813053", "0.761893", "0.7582476", "0.74899364", "0.74295044", "0.7400541", "0.73811644", "0.7257291", "0.7233009", "0.7170191", "0.71655226", "0.7116012", "0.710491", "0.71014565", "0.7095213", "0.705962", "0.703168", "0.7015972", "0.7006458", "0.6923585", ...
0.6612827
35
This method search for elem in lst using binary search. The elements of lst are compared using function compare. Returns the position of the first (leftmost) match for elem in lst. If elem does not exist in lst, then return 1.
def mybinsearch(lst: List[T], elem: S, compare: Callable[[T, S], int]) -> int: def binsearch(ar, targ, start, end): if start > end: return -1 mid = (start + end) // 2 if compare(ar[mid], targ) == 0: return mid if compare(ar[mid], targ) == 1: retu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def binary_search(element: int, my_list: list) -> int:\n print(element, my_list)\n return -1", "def linear_search(lst, value):\n i = 0\n while i != len(lst) and lst[i] != value:\n i = i + 1\n if i == len(lst):\n return -1\n else:\n return i", "def binary_search(list, elem...
[ "0.7302107", "0.7248753", "0.72397506", "0.7098562", "0.7072987", "0.7062549", "0.7043936", "0.69671535", "0.69577587", "0.6939207", "0.6926954", "0.6908609", "0.68655515", "0.683833", "0.68152875", "0.676924", "0.67683625", "0.6717923", "0.6709569", "0.66375935", "0.66332704...
0.78895795
0
Initializes a prefix searcher using a document and a maximum search string length k.
def __init__(self, document, k): self.strings = [] for x in range(0, len(document) - 1): if x + k < len(document): self.strings.append(document[x: x + k]) else: self.strings.append(document[x: len(document)]) comp = lambda x,y: 0 if len(x...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, document, k):\n doc = document\n self.n = k\n lst = []\n for l in range(1, self.n+1): #loops through every substring up to n\n for i in range(0, len(doc)-l): #loops through each index up to the length - l because that's where we need to start chopping up\n ...
[ "0.66172194", "0.5833021", "0.56878376", "0.55730796", "0.5547935", "0.5469905", "0.5431399", "0.53436875", "0.51773244", "0.51680183", "0.51125956", "0.51122963", "0.50885487", "0.5067106", "0.5054055", "0.5045307", "0.50377303", "0.5020344", "0.49801317", "0.4976014", "0.49...
0.6886835
0
This function prints and plots the confusion matrix.
def plot_confusion_matrix(cm, classes, title='Confusion matrix', cmap=plt.cm.jet): cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis] plt.imshow(cm, interpolation='nearest', cmap=cmap) plt.title(title) plt.colorbar() tick_marks = np.ara...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_confusion_matrix(self):\r\n interp = ClassificationInterpretation.from_learner(self.learn)\r\n interp.plot_confusion_matrix()", "def showConfusionMatrix(self): \r\n sn.heatmap(self.conf_matrix, annot=True)\r\n plt.plot( label=\"Accuracy\")\r\n plt.plot( label=\"Error\"...
[ "0.80894613", "0.80770946", "0.79976976", "0.7946727", "0.7921785", "0.78448296", "0.7833224", "0.7781221", "0.7775631", "0.77574563", "0.77061635", "0.77016985", "0.7692213", "0.76785815", "0.76588994", "0.7641414", "0.7622791", "0.7611233", "0.7610989", "0.7598244", "0.7587...
0.0
-1
Get the relative path. Overwritten to handle the versioned path.
def get_relative_path(self, file_path): file_path = os.path.abspath(file_path) if self.base_dir is not None: file_path = file_path.replace(os.path.abspath(self.base_dir), "") assert file_path[0] == "/" file_path = file_path[1:] return file_path
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_relative_path(self):\n if self.dip or self.sip or self.replica:\n raise PackageError(\n \"Get relative path for sip or replica packages not yet implemented\"\n )\n if self.deleted:\n raise PackageError(\"There are no relative paths for deleted p...
[ "0.76572126", "0.7633223", "0.7633223", "0.7633223", "0.7633223", "0.7633223", "0.7552634", "0.74843055", "0.74107885", "0.73378545", "0.7311077", "0.7275594", "0.72308546", "0.7204898", "0.71496946", "0.7126699", "0.7094854", "0.7079332", "0.70746374", "0.7052549", "0.704027...
0.7549298
7
Test normalized email while creating user
def test_normalized_email(self): email = "test123@Gmail.com" user = get_user_model().objects.create_user( email=email, password="Test123" ) self.assertEqual(user.email, email.lower())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_new_user_email_normalize(self):\n email = \"test@TadfhaafGRGS.pl\"\n user = get_user_model().objects.create_user(email, \"test123123123123\")\n\n self.assertEqual(email.lower(), user.email)", "def test_new_email_normalised(self):\n\n email = \"test@RANDOMEMAIL.org\"\n ...
[ "0.8341045", "0.83035636", "0.82415813", "0.8202913", "0.8202613", "0.8201391", "0.8198355", "0.81972015", "0.81972015", "0.81972015", "0.8189008", "0.81888413", "0.8158565", "0.81516916", "0.8145338", "0.81316495", "0.80350405", "0.79448897", "0.7930462", "0.7393197", "0.737...
0.81883854
12
Test creating a new user without email should raise error
def test_creating_a_new_user_without_email(self): with self.assertRaises(ValueError): get_user_model().objects.create_user(None, "Test1234")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_new_user_invalid_email(self):\n with self.assertRaises(ValueError):\n get_user_model().objects.create_user(None, '123')", "def test_new_user_invalid_email(self):\n\n with self.assertRaises(ValueError):\n get_user_model().objects.create_user(None, 'test1234')", "def ...
[ "0.90302485", "0.90190315", "0.90135926", "0.9011493", "0.9011493", "0.9011493", "0.9011493", "0.9011493", "0.9008369", "0.8999103", "0.8994008", "0.89730537", "0.895266", "0.8922476", "0.8919326", "0.8860915", "0.8858906", "0.8853876", "0.88159794", "0.8811944", "0.8762586",...
0.9150108
0
Draws a series of connected lines on a image, with the vertices specified by points. This does not draw any sort of end caps on lines.
def draw_lines(self, color, points, width=1, closed=False): if width == 1: pygame.draw.aalines(self._surf, color, closed, points) else: pygame.draw.lines(self._surf, color, closed, points, width) self._version += 1 spyral.util.scale_surface.clear(self._surf) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_lines(img, lines):\n for l in lines:\n rr, cc, val = line_aa(l[0][1], l[0][0], l[1][1], l[1][0])\n img[rr, cc] = 1\n\n return img", "def draw_lines(img, boxes):\n draw_img = img.copy()\n for i in range(len(boxes)):\n for j in range(i + 1, len(boxes)):\n d1, d2...
[ "0.75239336", "0.74215806", "0.7388109", "0.7086611", "0.70716584", "0.70207554", "0.7014612", "0.70135105", "0.7010646", "0.7010632", "0.70010805", "0.6951104", "0.692529", "0.6924731", "0.6917166", "0.68847525", "0.68500406", "0.6779219", "0.6771237", "0.67286706", "0.67130...
0.6816978
17
Draws an ellipse on this image.
def draw_ellipse(self, color, position, size=None, border_width=0, anchor='topleft'): if size is None: rect = spyral.Rect(position) else: rect = spyral.Rect(position, size) offset = self._calculate_offset(anchor, rect.size) pygame.draw.ellipse...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ellipse(self):\n f = self.img\n x = self.x\n y = self.y\n x2 = self.x2\n y2 = self.y2\n xy = self.xy\n self.a2 = (x2+y2) + sqrt(((x2-y2)/2.)**2 + xy**2)\n self.b2 = (x2+y2) - sqrt(((x2-y2)/2.)**2 + xy**2)\n self.a = sqrt(self.a2)\n self.b = sqrt(self....
[ "0.7911643", "0.7843069", "0.75425315", "0.75194204", "0.7435139", "0.74213874", "0.7369545", "0.7246259", "0.72387445", "0.72191274", "0.71495944", "0.7076094", "0.6987633", "0.69336295", "0.6840747", "0.6833428", "0.6813167", "0.6786314", "0.6780639", "0.67783445", "0.67777...
0.7416175
6
Draws an elliptical arc on this image.
def draw_arc(self, color, start_angle, end_angle, position, size=None, border_width=0, anchor='topleft'): if size is None: rect = spyral.Rect(position) else: rect = spyral.Rect(position, size) offset = self._calculate_offset(anchor, rect.size) pyg...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DrawEllipticArc(*args, **kwargs):\n return _gdi_.DC_DrawEllipticArc(*args, **kwargs)", "def DrawEllipticArc(*args, **kwargs):\n return _gdi_.PseudoDC_DrawEllipticArc(*args, **kwargs)", "def drawEllipse(img, center, axes, angle, startAngle=0, endAngle=360, color = (0,0,255), fill = -1):\n\tcv2...
[ "0.7570035", "0.7552482", "0.70011437", "0.6922151", "0.66973424", "0.66212696", "0.65673524", "0.6555791", "0.65090114", "0.6496401", "0.6452123", "0.64261365", "0.64247257", "0.6394922", "0.6338642", "0.6315911", "0.6252889", "0.62354124", "0.6205368", "0.6200125", "0.61958...
0.63891685
14
Return 18 for security rating. 1 = not secure 8 = high secure
def rating_security(addon: AddonModel) -> int: rating = 5 # AppArmor if addon.apparmor == SECURITY_DISABLE: rating += -1 elif addon.apparmor == SECURITY_PROFILE: rating += 1 # Home Assistant Login & Ingress if addon.with_ingress: rating += 2 elif addon.access_auth_a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def k(rating):\n if rating < 100: return 40\n if rating < 200: return 20\n return 10", "def PrivacyChoiceStrength(privacy):\n if privacy == 'public-contact-data':\n return 0\n if privacy == 'redacted-contact-data':\n return 1\n if privacy == 'private-contact-data':\n return 2", "def get_ra...
[ "0.65946627", "0.6591226", "0.62030643", "0.613479", "0.60757846", "0.59992975", "0.59674454", "0.593957", "0.5909101", "0.5900711", "0.5825526", "0.5822799", "0.5822794", "0.5815042", "0.5810201", "0.5775143", "0.5752853", "0.57462305", "0.5736913", "0.57330847", "0.57158506...
0.74332327
0
Called after every individual test, except DEBUG==True
def cleanUp(self): import evoware.fileutil as F F.tryRemove(self.f_project, verbose=(self.VERBOSITY>1), tree=1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_test(self, test_results):\n pass", "def debug(self):\r\n self.setUp()\r\n getattr(self, self._testMethodName)()\r\n self.tearDown()\r\n while self._cleanups:\r\n function, args, kwargs = self._cleanups.pop(-1)\r\n function(*args, **kwargs)", "d...
[ "0.76090175", "0.7601853", "0.75490505", "0.7403528", "0.7385698", "0.73744786", "0.7346671", "0.7346671", "0.7346671", "0.7346671", "0.7346671", "0.7346671", "0.7346671", "0.7346671", "0.7346671", "0.7346671", "0.7346671", "0.7346671", "0.7346671", "0.7346671", "0.7346671", ...
0.0
-1
Sets employee name and id
def __init__(self, eid: str, name: str): self.eid = eid self.name = name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def employee(self, employee: object):\n\n self._employee = employee", "def setEmployees(self, employees):\n self.employees = employees", "def change_employee(self, employee):\n cursor = self.dbconnect.get_cursor()\n try:\n if employee.id == None:\n raise Ex...
[ "0.7190012", "0.71477526", "0.70488626", "0.6793493", "0.6628336", "0.6502915", "0.64566565", "0.6360403", "0.6239083", "0.6161684", "0.6042879", "0.6028673", "0.60008234", "0.59587437", "0.5950456", "0.59398615", "0.59107935", "0.5901975", "0.5865393", "0.5863349", "0.580521...
0.5786157
21
Sets HourlyPolicy and employee name and id
def __init__(self, eid: str, name: str, hours_worked: int, hours_rate: int): pay.HourlyPolicy.__init__(self, hours_worked, hours_rate) super().__init__(eid, name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_hourly(self,rate,name):\n id = self.find_employee_id(name)\n if id in self.clsf:\n self.emp_dict[id][5] = \"1\"\n print(\"{}{}\".format(name,\" was successfully changed to be an hourly employee\"))\n self.emp_dict[id][8] = rate\n self.classificatio...
[ "0.68262535", "0.5858461", "0.5621912", "0.5620184", "0.5386408", "0.5379286", "0.5377986", "0.53100616", "0.53043705", "0.52657413", "0.5233793", "0.5216047", "0.5212972", "0.51323974", "0.51157224", "0.51044023", "0.50817764", "0.5065556", "0.50573653", "0.5037977", "0.4999...
0.68868387
0
Convert class labels from scalars to onehot vectors.
def dense_to_one_hot(labels_dense, num_classes=10): num_labels = labels_dense.shape[0] index_offset = numpy.arange(num_labels) * num_classes labels_one_hot = numpy.zeros((num_labels, num_classes)) labels_one_hot.flat[index_offset + labels_dense.ravel()] = 1 return labels_one_hot
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def one_hot(labels, classes=None):\n return K.utils.to_categorical(labels, classes)", "def one_hot(labels, classes=None):\n\n one_hot_ = K.utils.to_categorical(labels, classes)\n return(one_hot_)", "def to_onehot(labels: torch.Tensor, num_classes: int) -> torch.Tensor:\n if len(labels.size()) == 1:...
[ "0.8250402", "0.807683", "0.80523187", "0.7977843", "0.7908335", "0.7900327", "0.7892233", "0.7869711", "0.7849721", "0.7849721", "0.7826951", "0.7826122", "0.77677035", "0.7765413", "0.77540547", "0.77540547", "0.77540547", "0.77489346", "0.7742955", "0.7737176", "0.77226317...
0.7587813
43
Plot crosscorrelations Data in format ( samples x dimensions)
def plot_correlations(X, netvars, colorbar = False): C = np.corrcoef(X, rowvar = False) * 100 C[np.abs(C) < 0.5] = 0 # round near zero to 0 N = np.ceil(C.shape[0]/3) fig,ax = plt.subplots(1,1,figsize=(N,N)) ax.imshow(C) ax = annotate_heatmap(X = C, ax = ax, xlabels = netvars, ylab...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_correlations(data):\n\n from matplotlib import cm\n \n cols = data.columns.tolist()\n fig = plt.figure(figsize=(12,12))\n ax = fig.add_subplot(111)\n \n # Plot absolute value of pairwise correlations since we don't\n # particularly care about the direction of the relationship,\n ...
[ "0.7988087", "0.768463", "0.74632806", "0.7392325", "0.69984", "0.68876964", "0.6875198", "0.6875198", "0.6832547", "0.67812514", "0.6775251", "0.6771185", "0.67029625", "0.6609104", "0.65961546", "0.6573808", "0.65725255", "0.65488565", "0.6539359", "0.65078115", "0.64775336...
0.7176157
4
Returns a JSONencoded string describing this object.
def to_json(self): return json.dumps(self._asdict())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serialize(self) -> str:\n return json.dumps(self.__dict__)", "def __repr__(self):\n return json.dumps(self.__dict__)", "def __str__(self):\n return json.dumps(self.__dict__, indent=4, separators=(',', ': ')).encode()", "def serialize(self):\r\n return json.dumps({\r\n ...
[ "0.82153666", "0.8214961", "0.79991686", "0.79417026", "0.7910669", "0.78364784", "0.78350806", "0.78350806", "0.78350806", "0.78350806", "0.78350806", "0.78350806", "0.78350806", "0.78350806", "0.78350806", "0.78350806", "0.78350806", "0.78350806", "0.78350806", "0.78350806", ...
0.0
-1
This function returns a standard list of values of descriptive metrics, given an input model, features and target.
def generate_comparison_metrics(model: sklearn.linear_model, x_test: pd.DataFrame, y_test: pd.DataFrame, y_predictions: pd.DataFrame = None): if y_predictions is not None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_metrics(model, test_data):\n feats = test_data[:, :-1]\n gold_labels = test_data[:, -1]\n preds = model.predict_y(feats)\n preds_mean = preds[0].flatten()\n preds_var = preds[1]\n #print preds_mean[:10]\n #print gold_labels[:10]\n mae = MAE(preds_mean, gold_labels)\n rmse = np.sq...
[ "0.6853907", "0.6279296", "0.61465895", "0.6031913", "0.5970309", "0.59416664", "0.59034634", "0.58818555", "0.5878649", "0.5875332", "0.58522874", "0.584605", "0.58392906", "0.5810457", "0.58035815", "0.5785831", "0.57154745", "0.5709262", "0.5658308", "0.5643818", "0.564232...
0.61115545
3
Returns a User from a json/dictionary
def from_dict(cls, json, user=None): if user is None: user = cls() user.username = json['username'] user.first_name = json['first_name'] user.last_name = json['last_name'] user.password = json['password'] return user
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_dict(user_json):\n user = User()\n user.id = user_json['id']\n user.first_name = user_json['first_name']\n user.surname = user_json['surname']\n user.full_name = \"{} {}\".format(user.first_name, user.surname)\n user.email = user_json['email']\n user.organi...
[ "0.75416964", "0.721473", "0.7038975", "0.6941882", "0.6762321", "0.6637971", "0.6632183", "0.6630622", "0.6614993", "0.66123915", "0.66094935", "0.66072327", "0.6597861", "0.65895784", "0.65875614", "0.6577935", "0.6527504", "0.6503332", "0.64956117", "0.645948", "0.64501226...
0.75484157
0
take a binary array and return a list of tuples representing the first and last position(included) of continuous positive period
def get_continous_time_periods(binary_array): binary_array = np.copy(binary_array).astype("int8") n_times = len(binary_array) d_times = np.diff(binary_array) # show the +1 and -1 edges pos = np.where(d_times == 1)[0] + 1 neg = np.where(d_times == -1)[0] + 1 if (pos.size == 0) and (neg.size ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split_bits_bit_array(x, bit_array):\n\n mask = bit_array - 1\n\n lower = x & mask\n upper = x & ~mask\n\n return lower, upper", "def find_zero_points(DataSeries, column):\n\n wave_list = np.array(DataSeries[column])\n zero_indexes = np.where(abs(wave_list[:-1] - wave_list[1:]) > abs(wave_li...
[ "0.60975724", "0.6058324", "0.5904377", "0.5870174", "0.5865333", "0.58568066", "0.58377826", "0.5790501", "0.57266426", "0.5715733", "0.57086086", "0.57047814", "0.5699245", "0.5665293", "0.5587967", "0.55870336", "0.55366987", "0.5534478", "0.55285466", "0.55268043", "0.547...
0.7539885
0
Transform the string representing a class_name, by removing the upper case letters, and inserting before them an underscore if 2 upper case letters don't follow. Underscore are also inserted before numbers
def class_name_to_file_name(class_name): if len(class_name) == 1: return class_name.lower() new_class_name = class_name[0] for index in range(1, len(class_name)): letter = class_name[index] if letter.isdigit(): # first we check if the previous letter was not a digit ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _mapToRestClass(self, rest_class):\n # Don't parse words that already have an underscore or those that don't need underscores\n if '_' in rest_class or sum(rc.isupper() for rc in rest_class) == 1:\n return rest_class\n underscore_str = rest_class[0]\n for rc in rest_class...
[ "0.77247775", "0.75206923", "0.7306295", "0.70138973", "0.69155306", "0.68170756", "0.6815968", "0.6807682", "0.66968375", "0.6670888", "0.6646689", "0.65508074", "0.6548746", "0.6529719", "0.65259945", "0.651811", "0.6500515", "0.648814", "0.6478519", "0.6410965", "0.6391358...
0.7421777
2
Creates an instance of this model from a dictionary
def from_dictionary(cls, dictionary): if dictionary is None: return None # Extract variables from the dictionary height = awsecommerceservice.models.decimal_with_units.DecimalWithUnits.from_dictionary(dictionary.get('Height')) if dictionary.get('Height') else...
{ "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 id = dictionary.get('id')\n name = dictionary.get('name')\n mtype = dictionary.get('type')\n usage_bytes = diction...
[ "0.83180064", "0.81692255", "0.81692255", "0.81188524", "0.8089153", "0.7978471", "0.7949498", "0.7922631", "0.78985846", "0.7894865", "0.78879577", "0.78826904", "0.78814775", "0.78771174", "0.78584737", "0.78399473", "0.7803621", "0.7803621", "0.7803621", "0.7803621", "0.78...
0.77816397
61
Initialize a ThreadedRunner object.
def __init__(self, agent, environment, repeat_actions=1, save_path=None, save_episodes=None, save_frequency=None, save_frequency_unit=None, agents=None, environments=None): if agents is not None: warnings.warn("WARNING: `agents` parameter is deprecated, use `agent` instead.", ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, runner):\n self.__runner = runner\n self.__wait_time = 1800.0\n\n self.__condition = threading.Condition()\n self.__running = False\n self.__stopping = False\n self.__ready = False\n self.__run = None\n\n self.__thread = threading.Thread(ta...
[ "0.68468106", "0.65513384", "0.6447833", "0.6370974", "0.63703233", "0.63669306", "0.63585097", "0.6290161", "0.6284442", "0.62678087", "0.6256419", "0.6228157", "0.6210646", "0.6159234", "0.61298627", "0.60926026", "0.6086183", "0.6081631", "0.60777766", "0.6050942", "0.5985...
0.597258
21
Executes this runner by starting all Agents in parallel (each one in one thread).
def run( self, num_episodes=-1, max_episode_timesteps=-1, episode_finished=None, summary_report=None, summary_interval=0, num_timesteps=None, deterministic=False, episodes=None, max_timesteps=None, testing=False, sleep=None ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self):\n for worker in self.simulation_workers:\n worker.start()", "def run(self):\n LOGGER.info(\n SVC_START_MSG.format(\n datetime.datetime.now()\n )\n )\n\n LOGGER.info('Running active agents.')\n\n while True:\...
[ "0.65909696", "0.6577225", "0.64552575", "0.6451401", "0.63869375", "0.6364465", "0.6361913", "0.63477504", "0.6336415", "0.62869614", "0.6170534", "0.6169768", "0.6169721", "0.61428726", "0.6136873", "0.6136086", "0.6106769", "0.60957164", "0.60949296", "0.6058082", "0.60557...
0.0
-1
Test we handle broken json in state attributes.
def test_handling_broken_json_state_attributes( caplog: pytest.LogCaptureFixture, ) -> None: state_attributes = StateAttributes( attributes_id=444, hash=1234, shared_attrs="{NOT_PARSE}" ) assert state_attributes.to_native() == {} assert "Error converting row to state attributes" in caplog.te...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def test_lazy_state_handles_include_json(\n caplog: pytest.LogCaptureFixture,\n) -> None:\n row = PropertyMock(\n entity_id=\"sensor.invalid\",\n shared_attrs=\"{INVALID_JSON}\",\n )\n assert LazyState(row, {}, None, row.entity_id, \"\", 1, False).attributes == {}\n assert \"Erro...
[ "0.7503188", "0.7066574", "0.69211257", "0.69175273", "0.66143507", "0.66140294", "0.659272", "0.65683794", "0.6494376", "0.64275765", "0.63859487", "0.6376468", "0.6349513", "0.6343535", "0.63400364", "0.63129336", "0.6247927", "0.62421966", "0.6217583", "0.62146693", "0.620...
0.8331398
0
Test processing time stamp to UTC.
async def test_process_timestamp() -> None: datetime_with_tzinfo = datetime(2016, 7, 9, 11, 0, 0, tzinfo=dt_util.UTC) datetime_without_tzinfo = datetime(2016, 7, 9, 11, 0, 0) est = dt_util.get_time_zone("US/Eastern") datetime_est_timezone = datetime(2016, 7, 9, 11, 0, 0, tzinfo=est) nst = dt_util.ge...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_process_datetime_to_timestamp(time_zone, hass: HomeAssistant) -> None:\n hass.config.set_time_zone(time_zone)\n utc_now = dt_util.utcnow()\n assert process_datetime_to_timestamp(utc_now) == utc_now.timestamp()\n now = dt_util.now()\n assert process_datetime_to_timestamp(now) == now.timestam...
[ "0.70563513", "0.678765", "0.6588158", "0.65667456", "0.6543733", "0.653408", "0.64115816", "0.6372206", "0.6352943", "0.61434484", "0.6073645", "0.60725546", "0.6054885", "0.6054885", "0.6054885", "0.6054885", "0.6054885", "0.6054885", "0.6054885", "0.6054885", "0.6054885", ...
0.68203837
1
Given a string, replaces doublequotes and other troublesome characters so the string can be used in a form.
def formClean(s): s = s.replace('"',"'") s = s.replace("\n"," ") return s
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cleanquotes(string):\n return string.replace(\"\\\"\", \"\\\\\\\"\")", "def quot(string):\r\n return string.replace('\"', \"'\")", "def _escape_string(s, surrounding_quote='\"'):\n s = s.replace('\\\\', '\\\\\\\\')\n if surrounding_quote == '\"':\n s = s.replace('\"', r'\\\"')\n ...
[ "0.77267176", "0.75843036", "0.7371329", "0.735216", "0.734986", "0.72828263", "0.72612053", "0.7185764", "0.71271706", "0.7078575", "0.7071713", "0.7014029", "0.6988463", "0.6984911", "0.69579625", "0.69579625", "0.69579625", "0.6957126", "0.69440055", "0.69440055", "0.69440...
0.7331922
5
Recall metric. Only computes a batchwise average of recall. Computes the recall, a metric for multilabel classification of how many relevant items are selected.
def recall(y_true, y_pred): true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1))) possible_positives = K.sum(K.round(K.clip(y_true, 0, 1))) recall = true_positives / (possible_positives + K.epsilon()) return recall
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recall(y_true, y_pred, average, labels):\n\n y_true, y_pred = check_metric_args(y_true, y_pred, average, labels)\n\n result = None\n\n m = len(y_true)\n n = len(labels)\n\n confusion_matrix = get_confusion_matrix(y_true, y_pred, labels).T\n\n if average == \"micro\":\n numerator = np.t...
[ "0.7605524", "0.74488467", "0.7404089", "0.7280915", "0.72097343", "0.7157609", "0.7145226", "0.7145226", "0.7145226", "0.7145226", "0.7145226", "0.7145226", "0.71317255", "0.71007556", "0.70970625", "0.70970625", "0.70970625", "0.70970625", "0.70970625", "0.70970625", "0.709...
0.7165874
5
Precision metric. Only computes a batchwise average of precision. Computes the precision, a metric for multilabel classification of how many selected items are relevant.
def precision(y_true, y_pred): true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1))) predicted_positives = K.sum(K.round(K.clip(y_pred, 0, 1))) precision = true_positives / (predicted_positives + K.epsilon()) return precision
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def precision(self):\n self.overall_precision = precision_score(\n self.y_true, self.y_pred, average = self.average_type).round(self.digits_count_fp)\n self.classes_precision = precision_score(\n self.y_true, self.y_pred, average = None).round(self.digits_count_fp)", "def comp...
[ "0.7490801", "0.7288073", "0.71588075", "0.7153132", "0.7066247", "0.6985392", "0.6966561", "0.6955553", "0.69132614", "0.6832886", "0.6818762", "0.680567", "0.680567", "0.680567", "0.680567", "0.680567", "0.680567", "0.6786287", "0.67582464", "0.67582464", "0.67582464", "0...
0.68100244
11
This function construct PCL_C3D_Flat objects which is transformed to the adjacent frame. It assumes that a batch includes one or more rotating groups. For example, when seq_n=3, batch_n=6, it means a batch [a0, a1, a2, b0, b1, b2], where a0, a1, a2 are 3 sequential frames, and b0, b1, b2 are 3 sequential frames. After ...
def transform_pc3d(pcl_c3d, Ts, seq_n, K_cur, batch_n): ## need to transform: flat.uvb, flat.feature['xyz'], flat.feature['normal'] ## no need to transform grid features assert batch_n % seq_n == 0 # mode==0 n_group = batch_n // seq_n ## get relative pose T, R, t, target_id = relative_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flow_pc3d(pcl_c3d, flow_grid, flow_mask_grid, K_cur, feat_comm_keys, use_normal, sparse_nml_opts=None, return_stat=False, timer=None):\n if timer is not None:\n timer.log(\"flow_pc3d start\", 1, True)\n\n batch_size = flow_grid.shape[0]\n\n ### compose the flow to xyz\n xyz_grid = pcl_c3d.gr...
[ "0.60177255", "0.58820754", "0.5672602", "0.56098616", "0.5538228", "0.55124354", "0.55124354", "0.54567397", "0.5449514", "0.5444622", "0.54420555", "0.54420555", "0.54420555", "0.5438656", "0.5403029", "0.5388566", "0.5348811", "0.51593536", "0.5139638", "0.510053", "0.5080...
0.7151638
0
This function construct PCL_C3D_Flat objects which is transformed by the 3D scene flow.
def flow_pc3d(pcl_c3d, flow_grid, flow_mask_grid, K_cur, feat_comm_keys, use_normal, sparse_nml_opts=None, return_stat=False, timer=None): if timer is not None: timer.log("flow_pc3d start", 1, True) batch_size = flow_grid.shape[0] ### compose the flow to xyz xyz_grid = pcl_c3d.grid.feature['xy...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_simp_pc3d(pcl_c3d, mask_grid, uvb_flat, feat_grid, feat_flat):\n batch_size = mask_grid.shape[0]\n\n ## grid features\n pcl_c3d.grid.mask = mask_grid\n for feat in feat_grid:\n pcl_c3d.grid.feature[feat] = feat_grid[feat] # B*C*H*W\n\n ## flat features\n pcl_c3d.flat.uvb = []\n ...
[ "0.6749971", "0.6531655", "0.6155746", "0.58242995", "0.5822694", "0.5819806", "0.57758296", "0.5768318", "0.5757686", "0.5757302", "0.5732596", "0.56923026", "0.564251", "0.5627106", "0.5575794", "0.55667776", "0.55565876", "0.5535643", "0.55315316", "0.55298793", "0.5514658...
0.62645173
2
Gets the label of this AggregationEntry. The label value for this aggregation entry.
def label(self): return self._label
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_label(self):\n\n return self._label", "def get_label(self):\n return self._label", "def GetLabel(self):\n \n return self.label_str", "def GetLabel(self):\r\n\r\n return self._label", "def GetLabel(self) -> str:\n return self._label", "def get_label(self, ...
[ "0.7848208", "0.7738067", "0.7726862", "0.7679542", "0.763361", "0.76126844", "0.76031303", "0.7494204", "0.7494204", "0.7494204", "0.7494204", "0.7476301", "0.7476301", "0.7466111", "0.7435836", "0.74153847", "0.74153847", "0.74153847", "0.74153847", "0.74153847", "0.7415384...
0.75471437
12
Gets the status_counts of this AggregationEntry.
def status_counts(self): return self._status_counts
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def counts(self):\n counts = {\n 'total': self.app.db.jobs.count(),\n 'failed': self.app.db.jobs.find({'status': 'failed'}).count(),\n 'pending': self.app.db.jobs.find({'status': 'pending'}).count(),\n 'done': self.app.db.jobs.find({'status': 'done'}).count(),\n ...
[ "0.6533154", "0.64717585", "0.64489174", "0.64048594", "0.630832", "0.6307292", "0.6304693", "0.6250996", "0.621803", "0.61682457", "0.613129", "0.6130501", "0.611221", "0.61027944", "0.61013347", "0.6092686", "0.60474205", "0.6037071", "0.6025474", "0.6025474", "0.6025474", ...
0.8215648
0
Sets the status_counts of this AggregationEntry.
def status_counts(self, status_counts): self._status_counts = status_counts
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def status_counts(self):\n return self._status_counts", "def status_ids(self, status_ids):\n\n self._status_ids = status_ids", "def set_statuses(self, statuses):\n if not all((s in USBDeviceQuery.VALID_STATUSES) for s in statuses):\n raise ApiError(\"One or more invalid status v...
[ "0.5891494", "0.5764399", "0.57072854", "0.5574125", "0.5574125", "0.5574125", "0.5574125", "0.5574125", "0.5574125", "0.5574125", "0.5574125", "0.5574125", "0.5574125", "0.5574125", "0.5574125", "0.5574125", "0.5574125", "0.5574125", "0.5574125", "0.5574125", "0.5574125", ...
0.840326
0
Constructor. Any message fields that are implicitly/explicitly set to None will be assigned a default value. The recommend use is keyword arguments as this is more robust to future message changes. You cannot mix inorder arguments and keyword arguments.
def __init__(self, *args, **kwds): if args or kwds: super(ConductorGraph, self).__init__(*args, **kwds) #message fields cannot be None, assign default values for those that are if self.pending is None: self.pending = [] if self.available is None: self.available = [] if ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, *args, **kwds):\n if args or kwds:\n super(KomodoSpeechRecCommand, self).__init__(*args, **kwds)\n #message fields cannot be None, assign default values for those that are\n if self.header is None:\n self.header = std_msgs.msg.Header()\n if self.cmd is None:\n ...
[ "0.77936935", "0.77195734", "0.77195734", "0.76861507", "0.76260346", "0.7563092", "0.7439089", "0.74163747", "0.73512906", "0.73076564", "0.72798854", "0.72372425", "0.7226609", "0.7223668", "0.7223668", "0.7218618", "0.7210883", "0.7210883", "0.7210883", "0.7210883", "0.721...
0.6858245
56
It computes average precision based on the definition of Pascal Competition. It computes the under curve area of precision and recall. Recall follows the normal definition. Precision is a variant.
def compute_average_precision(precision, recall): # identical but faster version of new_precision[i] = old_precision[i:].max() precision = np.concatenate([[0.0], precision, [0.0]]) for i in range(len(precision) - 1, 0, -1): precision[i - 1] = np.maximum(precision[i - 1], precision[i]) # find th...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eval_pascal(pascal, detections):\n ap = 0.0 \n for i in range(pascal_num_class-1):\n ap += eval_pascal_one_class(pascal, detections, i)\n ap = ap / (pascal_num_class-1)\n print('mean average precision = %f' %ap)\n return ap", "def compute_ap(recall, precision):\r\n # correct AP calcu...
[ "0.8143044", "0.752994", "0.75244915", "0.75153536", "0.75058794", "0.75058794", "0.74942636", "0.73350745", "0.7311527", "0.7292531", "0.7268786", "0.72563195", "0.72065026", "0.71998364", "0.7192353", "0.7127805", "0.71270084", "0.71170104", "0.71163565", "0.7102406", "0.70...
0.735953
7
The timestamp property name. Represents the time when the interaction or profile update happened.
def timestamp_field_name(self) -> Optional[str]: return pulumi.get(self, "timestamp_field_name")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def timestamp(self) -> str:\n return self._event.get('timestamp')", "def timestamp(self) -> str:\n return pulumi.get(self, \"timestamp\")", "def timestamp(self) -> str:\n return self._timestamp", "def timestamp(self) -> str:\n return self[\"Sns\"][\"Timestamp\"]", "def timestamp...
[ "0.7730717", "0.7512179", "0.75018185", "0.7263251", "0.7184671", "0.71573627", "0.71344787", "0.71344787", "0.71344787", "0.71344787", "0.71344787", "0.71344787", "0.71344787", "0.7101167", "0.71007097", "0.70892066", "0.70677483", "0.705633", "0.6935106", "0.6932678", "0.68...
0.7546739
1
The name of the entity.
def type_name(self) -> Optional[str]: return pulumi.get(self, "type_name")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def entity_name(self):\n return self.__entity_name", "def entity_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"entity_name\")", "def entity_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"entity_name\")", "def name(self):\n return \"{} {}\".format(self....
[ "0.9201169", "0.8544822", "0.8544822", "0.8255243", "0.8139806", "0.7706495", "0.7700186", "0.76804334", "0.7679718", "0.76787007", "0.76787007", "0.76787007", "0.76443905", "0.76401955", "0.7631287", "0.7627152", "0.7627152", "0.7627152", "0.7627152", "0.7627152", "0.7627152...
0.0
-1
Gets unique words from sentence (removing the \W symbols)
def _get_words(self, sentence): _uniq_words = set() for word in sentence.split(): word = normed_word(re.sub("\W", "", word)).lower() _uniq_words.add(word) return _uniq_words
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_words(sentence):\n\n # Remove punctuation and make all letters lowercase.\n # Autograder didn't like translate: almost_clean_sentence = sentence.translate(None, string.punctuation)\n exclude = set(string.punctuation)\n almost_clean_sentence = ''.join(jot for jot in sentence if jot not in exclud...
[ "0.7506072", "0.7363143", "0.72854334", "0.70240694", "0.7011218", "0.7008331", "0.69059604", "0.6876447", "0.68740547", "0.67445457", "0.6735056", "0.67294", "0.66778284", "0.6645133", "0.6641124", "0.6629804", "0.6624847", "0.65932417", "0.6577326", "0.6571555", "0.6570233"...
0.8134854
0
Mock the Plugwise Smile server failure for Home Assistant.
def mock_smile_error(aioclient_mock: AiohttpClientMocker) -> None: aioclient_mock.get(re.compile(".*"), status=500) aioclient_mock.put(re.compile(".*"), status=500)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mock_smile_notconnect():\n with patch(\"homeassistant.components.plugwise.gateway.Smile\") as smile_mock:\n smile_mock.InvalidAuthentication = InvalidAuthentication\n smile_mock.ConnectionFailedError = ConnectionFailedError\n smile_mock.PlugwiseException = PlugwiseException\n smi...
[ "0.63782865", "0.6335186", "0.62846506", "0.6253282", "0.61579186", "0.6002375", "0.599098", "0.5974341", "0.5954845", "0.59236604", "0.591163", "0.5893348", "0.58923316", "0.5859947", "0.58158785", "0.5800793", "0.5781863", "0.5776239", "0.5770395", "0.5760094", "0.5758548",...
0.65957355
0
Create a Mock Anna environment for testing exceptions.
def mock_smile_anna(): chosen_env = "anna_heatpump" with patch("homeassistant.components.plugwise.gateway.Smile") as smile_mock: smile_mock.InvalidAuthentication = InvalidAuthentication smile_mock.ConnectionFailedError = ConnectionFailedError smile_mock.XMLDataMissingError = XMLDataMissi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_env_with_mamba(monkeypatch):\n\n def exec_cmd_mock(cmd, *args, **kwargs): # pylint: disable=unused-argument\n if cmd[-1] == \"--json\":\n # We are supposed to list environments in JSON format\n return subprocess.CompletedProcess(\n cmd, 0, json.dumps(...
[ "0.6420437", "0.63072354", "0.61038435", "0.60370094", "0.590919", "0.5749595", "0.5741525", "0.56861496", "0.5624535", "0.5601072", "0.5588404", "0.55456394", "0.55117965", "0.5492086", "0.5490637", "0.5467052", "0.54665804", "0.5454819", "0.54464173", "0.54462636", "0.54457...
0.0
-1
Create a Mock P1 DSMR environment for testing exceptions.
def mock_smile_p1(): chosen_env = "p1v3_full_option" with patch("homeassistant.components.plugwise.gateway.Smile") as smile_mock: smile_mock.InvalidAuthentication = InvalidAuthentication smile_mock.ConnectionFailedError = ConnectionFailedError smile_mock.XMLDataMissingError = XMLDataMiss...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_environment(seed, task_horizon):\n # Load the gym environment.\n environment = CartPoleEnv()\n environment = gym_wrappers.TimeLimit(environment, task_horizon)\n environment.seed(seed)\n environment = wrappers.GymWrapper(environment)\n environment = wrappers.SinglePrecisionWrapper(environ...
[ "0.5997795", "0.5929752", "0.58842224", "0.58233076", "0.5787175", "0.5699199", "0.5660129", "0.56567466", "0.5634181", "0.5634181", "0.5628539", "0.56226075", "0.5598076", "0.5587385", "0.5564529", "0.5552976", "0.55442667", "0.55442667", "0.55442667", "0.55442667", "0.55442...
0.0
-1
Create a Mock Stretch environment for testing exceptions.
def mock_stretch(): chosen_env = "stretch_v31" with patch("homeassistant.components.plugwise.gateway.Smile") as smile_mock: smile_mock.InvalidAuthentication = InvalidAuthentication smile_mock.ConnectionFailedError = ConnectionFailedError smile_mock.XMLDataMissingError = XMLDataMissingErr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_environment(seed, task_horizon):\n # Load the gym environment.\n environment = CartPoleEnv()\n environment = gym_wrappers.TimeLimit(environment, task_horizon)\n environment.seed(seed)\n environment = wrappers.GymWrapper(environment)\n environment = wrappers.SinglePrecisionWrapper(environ...
[ "0.615783", "0.6109793", "0.595631", "0.5944956", "0.5931876", "0.59267294", "0.5923661", "0.5921469", "0.59127885", "0.5912033", "0.5910561", "0.5886601", "0.58835834", "0.5883411", "0.5867068", "0.58601403", "0.58578247", "0.5855565", "0.58543754", "0.58509755", "0.58382916...
0.5796774
22
Get the height of the board.
def get_grid_height(self): # replace with your code return self._grid_height
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def height(self):\n return self.board.shape[0]", "def getHeight(self):\n return self.height", "def getHeight(self):\n return self.height", "def getHeight(self):\n return self._height", "def get_grid_height(self):\n return self._height", "def get_grid_height(self):\n ...
[ "0.8506178", "0.7828281", "0.7828281", "0.7792005", "0.7788401", "0.7788401", "0.77683884", "0.77683884", "0.77683884", "0.77683884", "0.77662206", "0.7763028", "0.776071", "0.77545404", "0.7742475", "0.77377915", "0.7721646", "0.769687", "0.76945823", "0.76945823", "0.769458...
0.74190307
74
Exiting the context. Exceptions are not propagated. Traceback is printed to default stream.
def __exit__( self, etype: Optional[Exception] = None, value: Optional[str] = None, tb: Any = None ) -> bool: if tb is not None: traceback.print_exception(etype, value, tb) # That is the return True part that tell Python that exceptions are...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exit(self):\n logger.debug(\"EXIT\")", "def __exit__(self, _type, value, traceback):\n if traceback is not None:\n # Exception occurred:\n logging.error('Exiting with statement with exception %s' % traceback)\n\n self.cleanup()", "def __exit__(self, exception, val...
[ "0.73812747", "0.73534936", "0.7304585", "0.7226286", "0.7208442", "0.71630245", "0.7137444", "0.7129783", "0.7129783", "0.7129783", "0.70772696", "0.70721346", "0.7058293", "0.7047492", "0.70326567", "0.70289946", "0.7017922", "0.70037925", "0.698439", "0.6984267", "0.698426...
0.6409973
79
Initialize weight of provided module Initialize the weight of linear layers with Kaiming uniform.
def weight_initialization(m: nn.Module) -> None: if type(m) == nn.Linear: # nn.init.xavier_uniform_(m.weight, np.sqrt(2.)) # gain is sqrt(2) because we use ReLU nn.init.kaiming_uniform_(m.weight, a=np.sqrt(5)) # nn.init.uniform(m.weight, 0., 0.)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_weights(module, negative_slope=0):\n if isinstance(module, (nn.Conv2d, nn.ConvTranspose2d)):\n nn.init.kaiming_normal_(module.weight.data, negative_slope)\n module.bias.data.zero_()", "def init_weights(self, module):\n if isinstance(module, (torch.nn.Linear, torch.nn.Embedding, t...
[ "0.73736274", "0.72804904", "0.72008306", "0.71706355", "0.7163317", "0.7122346", "0.70997775", "0.70835066", "0.7081181", "0.70699215", "0.70421165", "0.7035755", "0.700843", "0.6936024", "0.69153655", "0.6772879", "0.6752875", "0.6737584", "0.67273057", "0.67258435", "0.671...
0.7600478
0
This function creates a CNN model based on the provided hyperparameters. This will be useful to make hyperparameter optimization later.
def build_neuron_network(nb_features_map: Union[Sequence[int], None] = None, size_linear_layers: Union[Sequence[int], None] = None, dropout_rate: Union[Tuple[float, float], float] = 0.3, conv_kernel_size: Union[Sequence[int], int] = 3, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_model(hyperparameters):\r\n model = keras.Sequential()\r\n\r\n model.add(layers.BatchNormalization(input_shape=[hyperparameters['input_size']]))\r\n model.add(layers.Dense(hyperparameters['nodes'], activation='relu'))\r\n model.add(layers.BatchNormalization())\r\n model.add(layers.Dropout(...
[ "0.7366557", "0.7274422", "0.7246417", "0.7233825", "0.7204447", "0.7178976", "0.71666753", "0.71653205", "0.7133543", "0.7067387", "0.70542425", "0.70447755", "0.7025954", "0.7004585", "0.69863576", "0.6943518", "0.6931993", "0.68876666", "0.68454903", "0.67293924", "0.67201...
0.0
-1
Get model initializations Returns ndarray Return the initialization variables.
def get_model_init(self) -> ndarray: beta = np.zeros(self.fevar.size) gamma = np.zeros(self.revar.size) var = np.hstack([beta, gamma]) grad_beta = self.gradient(var)[:self.fevar.size] hess_beta = self.hessian(var)[:self.fevar.size, :self.feva...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initial_parameters(self):\n return self._initial_parameters", "def get_initializers(self):\n return self._initializers", "def get_variables(self) -> np.array:\n pass", "def initialize_model_params():\n beta_0 = np.array([0., 0.])\n mu_0 = 0.\n return beta_0, mu_0", "def get_in...
[ "0.6138706", "0.6106443", "0.6053949", "0.60476583", "0.60476047", "0.6045924", "0.59372574", "0.58524555", "0.57937634", "0.5787725", "0.57819766", "0.57612747", "0.5752308", "0.5732125", "0.56896883", "0.5684758", "0.5671491", "0.56605434", "0.56446075", "0.5639821", "0.563...
0.64049065
0
Check if a param exists
def has(self, param): if param in self.params: return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_parameter(self, name):\n for par in self.params:\n if par.name == name:\n return True\n return False", "def has_param_with_name(self, param_name):\n return param_name in self.params", "def json_param_exists(param_name, json_root=-1):\n if json_root == -...
[ "0.7966338", "0.7913115", "0.7744102", "0.74150294", "0.7284562", "0.72242", "0.7121739", "0.70907086", "0.7072285", "0.7018741", "0.69093513", "0.6785423", "0.67659754", "0.6753651", "0.6747817", "0.67348915", "0.6721521", "0.660888", "0.653616", "0.64750504", "0.64371556", ...
0.83384234
0
Checks that the border is of adequate size and color There don't seem to be hard guidelines for the outline, just that it is visible.
def get_style_info(self, el): # Set up our styling info, what is the information someone would need to determine if this was accessible? style_info = { "border-style": None, "outline-style": None, "el-color": None, "el-background": None, "pare...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_border(self):\n return self._border_actor is not None", "def HasBorder(self):\r\n \r\n return self.HasFlag(self.optionPaneBorder)", "def has_border(self, x, y, border):\n return self.__board[y][x] & self.BORDERS[border]", "def is_border(self, threshold):\n\n def dis...
[ "0.6858202", "0.6695931", "0.64151096", "0.6343462", "0.6341051", "0.6182822", "0.6181111", "0.61801904", "0.6159704", "0.6097302", "0.60294515", "0.599138", "0.595755", "0.59485364", "0.59390604", "0.5925418", "0.58675295", "0.5857614", "0.5857614", "0.5850384", "0.58434266"...
0.0
-1
Initialize the test image, with an nx/ny size zero image.
def __init__(self, nx=1000, ny=1000, shift=True): # Note that numpy array translate to images in [y][x] order! self.nx = int(nx) self.ny = int(ny) self.image = numpy.zeros((self.ny, self.nx), 'float') self.yy, self.xx = numpy.indices(self.image.shape) self.padx = 0.0 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setUp(self):\n self.image = np.random.randint(\n 0, 256, size=(10, 10, 3)).astype('uint8')", "def setUp(self):\n self.gray_image = np.ndarray((100, 200), dtype=np.uint8)\n self.rgb_image = np.ndarray((100, 200, 3), dtype=np.uint8)", "def setUp(self) -> None:\r\n self....
[ "0.72379076", "0.7069288", "0.64979184", "0.6423246", "0.6408669", "0.63167983", "0.63163424", "0.63163424", "0.63163424", "0.63163424", "0.63163424", "0.61951065", "0.61899114", "0.61542076", "0.6146064", "0.61051977", "0.6104471", "0.61032563", "0.6074153", "0.6043564", "0....
0.59492064
22
Add a 2d gaussian to the image with widths xwidth/ywidth. Can specify xcen/ycen (default=Center of image) and peak value of gaussian.
def addGaussian(self, xwidth=100., ywidth=100., xcen=None, ycen=None, value=1.0): if xcen == None: xcen = self.nx/2.0 if ycen == None: ycen = self.ny/2.0 self.fimage = None gaussian = numpy.exp(-(self.xx-xcen)**2/(2.0*xwidth**2) - (self.yy-ycen)**2/(2.0*ywidth**2)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gaussian(height, center_x, center_y, width_x, width_y):\n width_x = float(width_x)\n width_y = float(width_y)\n return lambda x,y: height*np.exp(\n -(((center_x-x)/width_x)**2+((center_y-y)/width_y)**2)/2)", "def gaussian(height, center_x, center_y, width_x, width_y):\n width_x = f...
[ "0.6781955", "0.6781955", "0.6781955", "0.67461425", "0.6736675", "0.67337906", "0.6721126", "0.6521028", "0.647676", "0.6476267", "0.62554365", "0.62014943", "0.6191914", "0.61789876", "0.61776245", "0.61633694", "0.614897", "0.61325586", "0.60998356", "0.6090473", "0.608060...
0.7957787
0
Add ellipses to the image on a regular grid with gridX/gridY spacing, at either random position angles (angle=None), or at a consistent angle. SemiX and SemiY describe the 'x' and 'y' length of the ellipse.
def addEllipseGrid(self, gridX=50, gridY=50, angle=None, semiX=5.0, semiY=2.0, value=1.0): self.fimage = None gridx = numpy.arange(0, self.nx+gridX, gridX) gridy = numpy.arange(0, self.ny+gridY, gridY) if angle != None: angles = numpy.zeros(len(gridx)*len(gridy), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addEllipseRandom(self, nEllipse=50, angle=None, semiX=None, semiY=None, value=1.0):\n self.fimage = None\n gridx = numpy.random.uniform(low=0, high=self.nx, size=nEllipse)\n gridy = numpy.random.uniform(low=0, high=self.ny, size=nEllipse)\n if angle != None: \n ...
[ "0.7185727", "0.6467214", "0.6425237", "0.6341949", "0.611951", "0.6105244", "0.6071278", "0.603923", "0.60160255", "0.5920621", "0.58372456", "0.5825862", "0.5821993", "0.58187056", "0.58180225", "0.57986814", "0.5768835", "0.5765448", "0.5742737", "0.57024896", "0.56845415"...
0.78659356
0