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
Reads a graph from the given file if the file is in tsv format
def read_graph(filename, node_index_one=0, node_index_two=1): tsv = csv.reader(open(filename), delimiter='\t') return make_graph(tsv, node_index_one, node_index_two)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_graph(filename):\n with open(filename) as f:\n g = eval(f.read())\n return g", "def read_tsv(path):\n return pd.read_csv(path, sep=\"\\t\", index_col=0)", "def _read_tsv(file_path):\n translation_pairs = []\n with file_path.open() as f:\n # Note: the correct way to do this is with...
[ "0.6889733", "0.67498296", "0.6648563", "0.6579418", "0.65128875", "0.6478796", "0.64579785", "0.6354261", "0.6280926", "0.62702507", "0.6206577", "0.6201407", "0.6160795", "0.61534834", "0.61306083", "0.609806", "0.60841817", "0.60741866", "0.6071734", "0.6060427", "0.606042...
0.74473524
0
Returns true if both objects are equal
def __eq__(self, other): if not isinstance(other, GetVariationsResource): 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
Sets the learning rate to the initial LR decayed by 10 every 10 epochs
def adjust_learning_rate(optimizer, epoch): lr = opt.lr * (0.5 ** (epoch // opt.step)) return lr
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def adjust_learning_rate(init_lr, optimizer, epoch, n=100):\n init_lr = init_lr * (0.1 ** (epoch // n))\n print('learning rate : ', init_lr)\n for param_group in optimizer.param_groups:\n param_group['lr'] = init_lr", "def adjust_learning_rate(initial_lr, optimizer, epoch, every_epoch):\n lr = i...
[ "0.77826405", "0.7726553", "0.76498544", "0.76204973", "0.75924313", "0.75924313", "0.7552633", "0.7540706", "0.7510586", "0.7499044", "0.74821043", "0.7476286", "0.7467294", "0.74647075", "0.74576217", "0.74409825", "0.7422623", "0.7421869", "0.7421256", "0.7413597", "0.7411...
0.73674977
28
Upsert organizations for MS Accounts modified in last `since` days. First syncs OrganizationType objects, then Organizations. When `include_aashe_in_website` is true, set the `exclude_from_website` flag on the Organization representing AASHE to False (0, actually). (Added for the Hub project.)
def upsert_organizations_for_recently_modified_accounts( since=7, include_aashe_in_website=False, get_all=False): logger.info('upserting OrganizationTypes') iss.utils.upsert_org_types() logger.info('upserting orgs for accounts modified in last {since} days'. format(since=since)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def throwerOrg_update(self, data, sesh):\n\n\t\t# Verify fields\n\t\ttry: DictHelper.eval(data, ['org'])\n\t\texcept ValueError as e: return Services.Effect(error=(1001, [(f, \"missing\") for f in e.args]))\n\n\t\t# Find the thrower\n\t\toThrower = Thrower.get(sesh['thrower']['_id'])\n\t\tif not oThrower:\n\t\t\tr...
[ "0.47982684", "0.47441787", "0.47376895", "0.47095996", "0.46881175", "0.46528757", "0.4635668", "0.45100293", "0.45009196", "0.44889987", "0.4462659", "0.44369483", "0.44100544", "0.4379162", "0.4183694", "0.4164314", "0.41396382", "0.41286612", "0.41253546", "0.41170245", "...
0.8027636
0
It turns a list of multidimensional arrays into a list of onedimensional arrays
def _serialize(self, data): data = [np.array(j) for j in data] self._data_shape_list = [j.shape for j in data] serialized_data = [j.ravel() for j in data] serialized_data = np.hstack(serialized_data) return serialized_data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def changeArray(array):\r\n\r\n return [[float(array[j][i]) for j in range(len(array))] for i in range(len(array[0]))]", "def flatten_2D_list(list_2d):\n return [item for sub in list_2d for item in sub]", "def listoflistToarray(l):\n max_dim=max([len(c) for c in l])\n all_array=[np.pad(c,(0,max_dim...
[ "0.7067893", "0.68708426", "0.6870687", "0.68324643", "0.6779312", "0.67678887", "0.6582681", "0.6493167", "0.64419013", "0.64406127", "0.643499", "0.6424802", "0.64031535", "0.64000916", "0.63943344", "0.63694435", "0.6361796", "0.6349802", "0.6328203", "0.6301475", "0.62885...
0.0
-1
It turns a list of onedimensional arrays into a list of multidimensional arrays. The multidimensional shape is stored when it is serialized
def _deserialize(self, data): firstInd = 0 deserialized_data = [] for shp in self._data_shape_list: if len(shp) > 1: shift = np.prod(shp) elif len(shp) == 0: shift = 1 else: shift = shp[0] tmp_array ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _serialize(self, data):\n data = [np.array(j) for j in data]\n self._data_shape_list = [j.shape for j in data]\n serialized_data = [j.ravel() for j in data]\n serialized_data = np.hstack(serialized_data)\n return serialized_data", "def _tolist(ndarray):\n elem_li...
[ "0.6564447", "0.64170665", "0.6340522", "0.6318124", "0.6300959", "0.615054", "0.60513264", "0.6044009", "0.60298365", "0.600872", "0.5996113", "0.593637", "0.59048784", "0.5893775", "0.58839184", "0.5877091", "0.5849381", "0.5832247", "0.5824904", "0.58181363", "0.58149743",...
0.65271044
1
return n numbers choiced from a range created with np.linspace from start to end spaced as specified in space [there will be space numbers in range]
def choice_n_rnd_numbers_from_to_linspace(start, end, space, n, integer=False, round=True, round_n=2, seed=None): if seed is not None: np.random.seed(seed) else: np.random.seed() r1 = np.linspace(start, end, space) #keys = np.random.randint(0, len(r1), n) #choices = r1[keys] ch...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rangeLin(min, max, n):\n\n return np.arange( min, max, (max-min)/n )", "def linspace(start, stop, n, istart=True, istop=True):\r\n n = n-1\r\n arr = [start + ((stop-start)/n) * i for i in range(n+1)]\r\n return arr", "def MakeDifficulties(center, width, n):\n low, high = center-width, cent...
[ "0.7594285", "0.7309991", "0.66752625", "0.66534173", "0.6525047", "0.64927685", "0.64666885", "0.6449392", "0.6445412", "0.6439769", "0.64325315", "0.64323", "0.63842696", "0.635264", "0.631086", "0.630086", "0.62920463", "0.6270911", "0.6240599", "0.6219981", "0.6198547", ...
0.72359127
2
Load a JSON document from string `s`, ignoring // comments.
def loads(s, **kwargs): return json.loads(uncomment(s), **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_json(s: str) -> Any:\n try:\n return json.loads(s)\n except json.JSONDecodeError as e:\n raise RuntimeError(f'Failed to parse \"{s}\" as json.')", "def read(s):\n import warnings\n warnings.warn(\"simplejson.loads(s) should be used instead of read(s)\",\n DeprecationWarn...
[ "0.7165797", "0.70200366", "0.68357295", "0.6736215", "0.6720418", "0.65669703", "0.65669703", "0.65123314", "0.64278847", "0.6307222", "0.6293743", "0.62097585", "0.6082742", "0.60576594", "0.6016722", "0.596564", "0.59234065", "0.59081763", "0.590582", "0.58806473", "0.5853...
0.8245589
0
Test the response handler raises PayloadValidationError as expected
def test_handle_initiate_refund_error_validation(order, bambora_provider_base_config): r = {"result": 1, "type": "e-payment", "errors": ["Invalid auth code"]} OrderToken.objects.create( order=order, token="12345", valid_until=now() - relativedelta(days=7) ) order.status = OrderStatus.PAID or...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testNonJSONPayload(self):\n body = 'Invalid JSON'\n headers = Headers({'Content-Length': [str(len(body))],\n 'Content-Type': ['application/json']})\n request = FakeRequest(headers=headers, body=body)\n resource = TestResource(None, None)\n result = y...
[ "0.7131019", "0.6857359", "0.68440163", "0.6813541", "0.679119", "0.6725344", "0.6721056", "0.6714714", "0.6697457", "0.6608114", "0.6583865", "0.65556484", "0.6493652", "0.6493652", "0.6492307", "0.64784425", "0.6473244", "0.64370143", "0.64243793", "0.6421785", "0.63927853"...
0.0
-1
Test request notify helper returns http 204 and order status is correct when successful
def test_handle_notify_request_success( bambora_provider_base_config, order: Order, ): order.order_number = "abc123" order.status = OrderStatus.PAID order.lease.status = LeaseStatus.PAID order.lease.save() order.save() refund = OrderRefundFactory( order=order, refund_id="1234567"...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_notification_batch(self):\n req = '''[{\"jsonrpc\": \"2.0\", \"method\": \"notify_hello\", \"params\": [7]},\n {\"jsonrpc\": \"2.0\", \"method\": \"notify_hello\", \"params\": [7]}\n ]'''\n resp = ''\n status = 204\n r_status, r_resp = self.exec...
[ "0.68232244", "0.6743072", "0.66484594", "0.6455849", "0.6392551", "0.63027185", "0.6243438", "0.6218974", "0.6207664", "0.61809504", "0.6160879", "0.61556864", "0.6150395", "0.6107842", "0.610291", "0.6095113", "0.6087458", "0.60621905", "0.6061636", "0.6052251", "0.6048092"...
0.68013775
1
A `double` value is written as a double precision 64bit IEEE 754 floatingpoint value in littleendian format.
def read_double(stream, writer_schema=None, reader_schema=None): # noqa return unpack('<d', stream.read(8))[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_double(self, f: float) -> None:\n self.write(STRUCT_DOUBLE.pack(f))", "def write_double(self, d):\n if not isinstance(d, float):\n raise TypeError(\"expected a float, got %r\" % (type(d),))\n\n self.write(self._packers[\"d\"].pack(d))", "def read_double(data):\n s_t...
[ "0.69710374", "0.6918615", "0.68319684", "0.6664564", "0.6561981", "0.6561613", "0.6260493", "0.62220556", "0.60137415", "0.59476256", "0.5938401", "0.59219205", "0.58405644", "0.58144796", "0.5795093", "0.5783455", "0.5731249", "0.56560534", "0.564603", "0.564603", "0.563541...
0.6314007
6
A `union` value is written as a `long` indicating the zerobased position of the `value` in the union's schema, immediately followed by the `value`, written per the indicated schema within the union.
def read_union(stream, writer_schema, reader_schema=None): index = read_long(stream) w_schema = writer_schema[index] if reader_schema: # Schema Resolution r_schemas = (reader_schema if isinstance(reader_schema, list) else (reader_schema,)) for r_schema in r_schem...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unionUse(expression, unpack=True, dump=False):\n\n initTechnique(PAYLOAD.TECHNIQUE.UNION)\n\n abortedFlag = False\n count = None\n origExpr = expression\n startLimit = 0\n stopLimit = None\n value = None\n\n width = getConsoleWidth()\n start = time.time()\n\n _, _, _, _, _, expres...
[ "0.56293607", "0.5610543", "0.55431676", "0.5427934", "0.5378995", "0.53786665", "0.5303588", "0.51397955", "0.513819", "0.5099093", "0.508218", "0.50290257", "0.5006728", "0.49570295", "0.494586", "0.49405488", "0.49068135", "0.48725426", "0.48440808", "0.48028952", "0.47717...
0.4982617
13
Reset metrics for reporting loss and perplexity.
def reset_metrics(self): self.metrics['loss'] = 0.0 self.metrics['num_tokens'] = 0 self.metrics['correct_tokens'] = 0 self.metrics['correct_pred'] = 0 self.metrics['pred_count'] = 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset(self):\n self.pred_classes.clear()\n self.gold_classes.clear()\n self.pred_probas.clear()\n self.gold_probas.clear()\n self.loss = 0\n self.nb_batches = 0\n self.prec_rec_f1 = None\n self.acc = None\n self.mcc = None", "def reset(self):\n ...
[ "0.7684946", "0.7572448", "0.73682785", "0.73640347", "0.7288502", "0.7246719", "0.7231809", "0.70769024", "0.7071745", "0.706104", "0.7039328", "0.69755363", "0.69661295", "0.69661295", "0.6961298", "0.6957492", "0.6955037", "0.6945496", "0.6940971", "0.69241685", "0.6918136...
0.8498819
0
Given a document (represented as a string), return a list of all of the words in that document, in order. Process document by coverting all words to lowercase [ .lower() ], and removing any punctuation or English stopwords.
def tokenize(document): words = nltk.word_tokenize(document) # tokenize files into a list of words return [ word.lower() for word in words # filter out all punctuation (import string) and all stopwords if not all(char in string.punctuation for char in word) and word not in n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tokenize(document):\n token = nltk.word_tokenize(document)\n\n output = [word.lower() for word in token if (word not in string.punctuation and word not in nltk.corpus.stopwords.words(\"english\"))]\n\n return output", "def tokenize(document):\n raw_words=[word.lower() for word in nltk.word_tokeni...
[ "0.7965204", "0.7959515", "0.7925936", "0.7797677", "0.77794176", "0.7769059", "0.7455111", "0.74290603", "0.73531395", "0.72335494", "0.7064281", "0.7063237", "0.70553774", "0.70496166", "0.7047174", "0.7047174", "0.70413524", "0.7037253", "0.69820315", "0.6964105", "0.69462...
0.7814547
3
Sets the learning rate to a fixed number
def update_lr(optimizer, lr, epoch, max_epochs, exponent=0.9): optimizer.param_groups[0]['lr'] = lr * (1 - epoch / max_epochs)**exponent
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_learning_rate(self, rate):\n self.SGD.set_learning_rate(rate)", "def assign_learning_rate(session, lr_update, lr_placeholder, new_lr):\n session.run(lr_update, feed_dict={lr_placeholder: new_lr})", "def learning_rate(epoch):\n self.lr = self.lr / 1.00000001\n return self.l...
[ "0.8043176", "0.7587582", "0.7513181", "0.7454164", "0.7432718", "0.7432104", "0.74023783", "0.7395", "0.7395", "0.73941296", "0.7353055", "0.73301977", "0.7327715", "0.72875035", "0.7260839", "0.7259945", "0.7234832", "0.7231998", "0.72272116", "0.7223369", "0.7191072", "0...
0.0
-1
Constructor. mid Message ID (default is for a data message) sid Request session ID (required for data messages) data Message data payload (as a string)
def __init__( self, mid = DATA, sid = None, data = None ): # load arguments into object state self.super_init( vars() )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def message(self, sid):\r\n return Message(self, sid)", "def __init__(self,\n msg_id=0x00,\n payload=b''):\n self.sync = MESSAGE_TX_SYNC\n self._msg_id = msg_id\n\n self.is_extended_message = False\n self.flag_byte = None\n self._extended_...
[ "0.62236077", "0.6223415", "0.6129201", "0.5964861", "0.5938068", "0.5809116", "0.57423437", "0.5722399", "0.5708373", "0.5707353", "0.56657785", "0.5639886", "0.56386524", "0.5612907", "0.559037", "0.55712825", "0.5498323", "0.54910815", "0.5487915", "0.53910494", "0.5387384...
0.6255443
0
Load a YAML file.
def load_yaml(fname: str) -> JSON_TYPE: try: with open(fname, encoding="utf-8") as conf_file: # If configuration file is empty YAML returns None # We convert that to an empty dict return yaml.load(conf_file, Loader=SafeLineLoader) or OrderedDict() except yaml.YAMLErro...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_yaml(file: Text):\n with open(file) as fp:\n return yaml.load(fp, yaml.FullLoader)", "def load_yaml(file_path):\n with open(file_path) as fin:\n content = yaml.load(fin, Loader=yaml.FullLoader)\n return content", "def load_yaml(file):\n with open(file, 'r') as file:\n...
[ "0.806725", "0.7946645", "0.7922366", "0.791808", "0.7902481", "0.78717774", "0.7857945", "0.7782008", "0.7718474", "0.7706223", "0.76773983", "0.76442504", "0.7626985", "0.7571206", "0.75649077", "0.75593185", "0.75539845", "0.7551508", "0.75262004", "0.75253665", "0.7497593...
0.0
-1
Create JWT token that the user can use to verify its account.
def gen_verification_token(user): exp_date = timezone.now() + timedelta(days=3) payload = { 'user': user.username, 'exp': int(exp_date.timestamp()), 'type': 'email_confirmation' } # Generacion del token token = jwt.encode(payload, settings.SECRET_KEY, algorithm='HS256') r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_auth_token():\n data = get_request_data(request)\n address = data.get(\"address\")\n expiration = int(data.get(\"expiration\"))\n\n pk = get_provider_private_key(use_universal_key=True)\n token = jwt.encode({\"exp\": expiration, \"address\": address}, pk, algorithm=\"HS256\")\n token =...
[ "0.8282378", "0.80514276", "0.7851687", "0.7721485", "0.7649764", "0.7649361", "0.7649308", "0.7645845", "0.7607744", "0.76066774", "0.75824034", "0.75423574", "0.7538712", "0.7521649", "0.7513469", "0.75050616", "0.7489892", "0.74733555", "0.74679905", "0.7365179", "0.735080...
0.7283961
23
Control the orientation and the speed of the motor.
def set_throttle(self, val): # Set the motor to stop mode. if val is None: self.in1.off() self.in2.off() self.pwm.value = 1.0 else: # Determine the orientation of the motor. if val > 0.0: self.in1.off() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_param_motor():\n servo.setSpeed(0, 0) # max = 255\n servo.setAccel(0, 0)\n servo.setSpeed(1, 150) # max = 255\n servo.setAccel(1, 150)", "def update_motor_speeds(self, event):\n \n # Determine the time step for differentiation and integration\n current_time = rospy....
[ "0.74563265", "0.7263115", "0.721052", "0.71795785", "0.71598166", "0.71570265", "0.7135227", "0.706117", "0.70251125", "0.6944048", "0.69022876", "0.6813871", "0.68123025", "0.6771719", "0.6759139", "0.6688247", "0.6685665", "0.66231656", "0.6616776", "0.660064", "0.6553431"...
0.59226745
93
Attach a lot of summaries to a Tensor (for TensorBoard visualization).
def variable_summary(var, plot_bool=False): name_var = re.split('/', var.name)[-1] name_var = re.split(':', name_var)[0] with tf.name_scope(name_var): mean = tf.reduce_mean(var) tf.summary.scalar('mean', mean) with tf.name_scope('stddev'): stddev = tf.sqrt(tf.reduce_mean(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_summary(self):\n for k, v in self.metrics.items():\n tf.summary.scalar(k, v)\n \n self.summary_op = tf.summary.merge_all()", "def build_summaries(self):\n\n # Loss summary.\n tf.summary.scalar('loss', self.loss)\n\n merged = tf.summary.merge_all()\n self.summary_op = merged\n ...
[ "0.7071791", "0.6970259", "0.6970259", "0.6800256", "0.67872906", "0.67407334", "0.66669947", "0.66576326", "0.66193783", "0.66085786", "0.6595776", "0.65836215", "0.6581151", "0.655297", "0.6500364", "0.6459978", "0.64145213", "0.6294558", "0.62718755", "0.62713677", "0.6265...
0.0
-1
Test to see if insert_non_balanceed node does not change other node.
def test_insert_non_balance_right_node_None(): from bst import BST bst = BST() bst.insert_non_balance(4) bst.insert_non_balance(2) assert bst.root.right is None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_balance_known_tree_2(known_bst):\n known_bst[0].insert_non_balance(12)\n assert known_bst[0].balance() == known_bst[2] - 1", "def test_tree_2_nodes_left_unbalanced(one_t):\n one_t.insert(9)\n assert one_t.balance() == 1", "def test_insert_non_balance_value():\n from bst import BST\n ...
[ "0.6349039", "0.6263066", "0.62059873", "0.61819524", "0.61696625", "0.61383444", "0.5887701", "0.5868249", "0.58076525", "0.57997304", "0.57605964", "0.57412755", "0.5723468", "0.57089007", "0.5705887", "0.57012975", "0.5689741", "0.5629064", "0.5615577", "0.5611107", "0.560...
0.6103558
6
Check to see if 7 is in the test bst.
def test_coontains(known_bst): assert known_bst[0].contains(7) is True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_seven(k):\n\tif k % 10 == 7:\n\t\treturn True\n\telif k < 10:\n\t\treturn False\n\telse:\n\t\treturn has_seven(k // 10)", "def has_seven(k):\n if k % 10 == 7:\n return True\n elif k < 10:\n return False\n else:\n return has_seven(k // 10)", "def has_seven(k):\n if k % 1...
[ "0.6719693", "0.6651157", "0.6651157", "0.6651157", "0.6566289", "0.65319896", "0.64096725", "0.6037219", "0.5995974", "0.5992181", "0.59530586", "0.58347327", "0.5816576", "0.5721567", "0.568882", "0.5682319", "0.56371766", "0.5622963", "0.5614693", "0.56035024", "0.5556093"...
0.5689429
14
test a balance of a empty tree.
def test_balance_empty(): bst = BST() assert bst.balance() == 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_balance_empty_tree(bst_empty):\n assert bst_empty.balance() == 0", "def test_tree_with_one_node_balance_is_zero(one_t):\n assert one_t.balance() == 0", "def test_balance_balanced_tree(bst_balanced):\n assert bst_balanced.balance() == 0", "def test_empty_tree_balance_returns_message(empty_t)...
[ "0.8921202", "0.8466956", "0.83057916", "0.8248224", "0.8161003", "0.8069403", "0.80139744", "0.78603464", "0.78213596", "0.78008616", "0.77270055", "0.7653182", "0.7351915", "0.73374", "0.7214098", "0.7098416", "0.7084783", "0.7081611", "0.7051181", "0.703207", "0.7021148", ...
0.8409326
2
Scatterplot of a clustering result
def draw_scatterplot(self, canvas, x_label, y_label, flipped): canvas.axes.cla() data_scatter = self.import_scatterdata() canvas.axes.scatter(x=data_scatter.iloc[:, 0], y=data_scatter.iloc[:, 1], s=0, clip_on=False) if flipped: canvas.axes.invert_yaxis() canvas.axes...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cluster_plot(self):\r\n train = StandardScaler().fit_transform(self.X)\r\n pca = PCA(n_components=3)\r\n pca_component = pca.fit_transform(self.X)\r\n fig = plt.figure(figsize=(10,8))\r\n sns.set_palette(sns.color_palette(\"cubehelix\", 8))\r\n ax ...
[ "0.74853593", "0.74453425", "0.74418044", "0.740746", "0.7356099", "0.70657426", "0.70261836", "0.6906845", "0.6866259", "0.6850864", "0.6817082", "0.6760523", "0.6693163", "0.66926146", "0.66664475", "0.66126037", "0.6566679", "0.65238094", "0.65046984", "0.64892095", "0.645...
0.0
-1
Computes IoU between bounding boxes.
def bbox_iou_numpy(box1, box2): area = (box2[:, 2] - box2[:, 0]) * (box2[:, 3] - box2[:, 1]) iw = np.minimum(np.expand_dims(box1[:, 2], axis=1), box2[:, 2]) - np.maximum( np.expand_dims(box1[:, 0], 1), box2[:, 0] ) ih = np.minimum(np.expand_dims(box1[:, 3], axis=1), box2[:, 3]) - np.maxim...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_IoU2d(bbox_gt, bbox_det):\n \n x_center_gt, y_center_gt, width_gt, height_gt, area_gt = bbox_gt\n x_center_det, y_center_det, width_det, height_det, area_det = bbox_det\n \n lt_x_gt, lt_y_gt = x_center_gt - width_gt / 2, y_center_gt - height_gt / 2\n rb_x_gt, rb_y_gt = x_center_gt + w...
[ "0.79318535", "0.7843106", "0.7824524", "0.77228546", "0.7670487", "0.7659547", "0.76554376", "0.76554376", "0.76554376", "0.76328415", "0.7601526", "0.7572093", "0.75197685", "0.7493747", "0.74304223", "0.74286586", "0.73905724", "0.7389893", "0.73665583", "0.73665583", "0.7...
0.690077
49
Returns the IoU of two bounding boxes
def bbox_iou(box1, box2, x1y1x2y2=True): if x1y1x2y2: # Get the coordinates of bounding boxes b1_x1, b1_y1, b1_x2, b1_y2 = box1[:, 0], box1[:, 1], box1[:, 2], box1[:, 3] b2_x1, b2_y1, b2_x2, b2_y2 = box2[:, 0], box2[:, 1], box2[:, 2], box2[:, 3] else: # Transform from cente...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calc_iou(bbox1, bbox2):\n area_1 = (bbox1[2] - bbox1[0] + 1) * (bbox1[3] - bbox1[1])\n area_2 = (bbox2[2] - bbox2[0] + 1) * (bbox2[3] - bbox2[1])\n\n inter_x1 = torch.max(torch.cat([bbox1.new([bbox1[0]]), bbox1.new([bbox2[0]])]))\n inter_x2 = torch.max(torch.cat([bbox1.new([bbox1[1]]), bbox1.new([b...
[ "0.7982936", "0.7919953", "0.7912249", "0.79056466", "0.78252506", "0.78252506", "0.7803906", "0.7728958", "0.7709497", "0.76978576", "0.7653509", "0.7651432", "0.7631874", "0.7616914", "0.7556536", "0.75393015", "0.7538201", "0.75316185", "0.75292873", "0.7504099", "0.750409...
0.6988063
49
Compute the average precision, given the recall and precision curves.
def compute_ap(recall, precision): # correct AP calculation # first append sentinel values at the end mrec = np.concatenate(([0.0], recall, [1.0])) mpre = np.concatenate(([0.0], precision, [0.0])) # compute the precision envelope for i in range(mpre.size - 1, 0, -1): mpre[i - 1]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_average_precision(precision, recall):\n # identical but faster version of new_precision[i] = old_precision[i:].max()\n precision = np.concatenate([[0.0], precision, [0.0]])\n for i in range(len(precision) - 1, 0, -1):\n precision[i - 1] = np.maximum(precision[i - 1], precision[i])\n\n ...
[ "0.836952", "0.81346226", "0.7751113", "0.77245736", "0.7717672", "0.76912516", "0.76490915", "0.76490915", "0.76259345", "0.7558349", "0.75363964", "0.7475437", "0.7272525", "0.7250063", "0.7227905", "0.72088754", "0.7200133", "0.7182856", "0.7160525", "0.7129954", "0.708695...
0.7692633
5
Given a 2d vector of values and a 1d vector of indices we wish to select from each row of the 2d vector.
def demo_select_indexes(): ps = tf.constant([[0.2, 0.8], [0.4, 0.6], [0.25, 0.75]]) idxs = tf.constant([1, 0, 1]) y = tf.gather_nd( ps, tf.transpose(tf.stack([tf.range(idxs.shape[0]), idxs]))) # [[0, 1], [1, 0], [2, 1]] with tf.Session('') ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def select_corners(values, i, j):\n #pylint: disable=invalid-name\n i, j = np.asarray(i, dtype=\"i\"), np.asarray(j, dtype=\"i\")\n\n if isinstance(values, np.ma.MaskedArray):\n array_constructor = np.ma.MaskedArray\n else:\n array_constructor = np.array\n ni = values.shape[0]\n vec...
[ "0.6309791", "0.615523", "0.5970462", "0.5958232", "0.58092934", "0.57378083", "0.57331985", "0.56810117", "0.56416076", "0.5631091", "0.55645746", "0.55297583", "0.5510371", "0.5485236", "0.5470237", "0.5467983", "0.5467983", "0.54143226", "0.53852093", "0.5375575", "0.53745...
0.6184054
1
Given a 2d vector of values and a 1d vector of indices we wish to select from each row of the 2d vector.
def demo_select_indexes_dynamic_dimensions(): ps = tf.placeholder(tf.float32, [None, 2]) idxs = tf.placeholder(tf.int32, [None]) y = tf.gather_nd( ps, tf.transpose(tf.stack([tf.range(tf.shape(idxs)[0]), idxs]))) with tf.Session('') as sess: print(sess.run(y, feed_dict={ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def select_corners(values, i, j):\n #pylint: disable=invalid-name\n i, j = np.asarray(i, dtype=\"i\"), np.asarray(j, dtype=\"i\")\n\n if isinstance(values, np.ma.MaskedArray):\n array_constructor = np.ma.MaskedArray\n else:\n array_constructor = np.array\n ni = values.shape[0]\n vec...
[ "0.6310324", "0.61830235", "0.61537576", "0.59687734", "0.5957756", "0.5807174", "0.57392526", "0.5732011", "0.568112", "0.563957", "0.56292075", "0.5565159", "0.55315965", "0.5508997", "0.54822344", "0.5466126", "0.5466126", "0.5412038", "0.5384872", "0.5374242", "0.5372068"...
0.54687095
15
Sends a timestamp to the client.
def sendTime(self): timestamp = datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M%p") self.send(timestamp)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_time(self, timestamp):\n\n\t\tdata = pack(\"!bL\", 2, timestamp)\n\t\tself._send_message(\"TIME\", data)", "def _send_time(self):\n if 'time' not in self.loopback_guard:\n content = {'time': self.time.isoformat()}\n self.send_action('set_time', content)", "def timestamp(sel...
[ "0.71916145", "0.7004947", "0.67356455", "0.66555524", "0.6634018", "0.65908223", "0.65251696", "0.64826214", "0.6421068", "0.64142483", "0.63581276", "0.632751", "0.632751", "0.632751", "0.632751", "0.632751", "0.632751", "0.632751", "0.62939876", "0.6289815", "0.6234336", ...
0.7723151
0
Returns the ID for a thread.
def getID(self): global COUNT, C_LOCK with C_LOCK: COUNT += 1 return COUNT
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_thread_id() -> int:\n # NOTICE:\n # we do not use threading.get_ident() to identify a thread, as Python recycles these identifiers\n return id(threading.current_thread())", "def thread_id(self):\n return self._thread_id", "def get_id(self):\n if hasattr(self, \"_thre...
[ "0.8642579", "0.84026897", "0.8011434", "0.8011434", "0.7636658", "0.76306593", "0.7419352", "0.73581487", "0.73433894", "0.7260999", "0.70365113", "0.6870103", "0.6840901", "0.68340343", "0.68255347", "0.6677848", "0.6656872", "0.66426075", "0.6524635", "0.65117484", "0.6347...
0.0
-1
Recursively prefetch joins to speed up the database query.
def prefetch(self, queryset: models.QuerySet) -> models.QuerySet: subquery = self.model.objects.all() if self.filters: q = reduce(operator.and_, [f.get() for f in self.filters]) subquery = subquery.filter(q) if self.sort: subquery = subquery....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_eager_loading(cls, queryset):\n queryset = queryset.prefetch_related('keywords_str')\n queryset = queryset.prefetch_related('tags_str')\n # queryset = queryset.prefetch_related('keywords')\n # queryset = queryset.prefetch_related('tags')\n return queryset", "def prefe...
[ "0.6586214", "0.6352628", "0.6320077", "0.6303596", "0.61382556", "0.6113858", "0.5811461", "0.58105814", "0.5778383", "0.5701448", "0.5605635", "0.55841875", "0.55771697", "0.54363424", "0.5422709", "0.53636146", "0.5350461", "0.52470535", "0.52200466", "0.5155413", "0.51184...
0.69297874
0
Enable/Disable secure boot on the server. Resetting the server post updating this settings is needed from the caller side to make this into effect.
def set_secure_boot_mode(self, secure_boot_enable): sushy_system = self._get_sushy_system() try: sushy_system.secure_boot.enable_secure_boot(secure_boot_enable) except exception.InvalidInputError as e: msg = (self._('Invalid input. Error %(error)s') % {...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enable_secure_boot(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"enable_secure_boot\")", "def set_secure_boot_mode(self, secure_boot_enable):\n if self._is_boot_mode_uefi():\n self._change_secure_boot_settings('SecureBootEnable',\n ...
[ "0.73546815", "0.67499995", "0.6705586", "0.6574428", "0.64797515", "0.6466575", "0.6421686", "0.61290723", "0.608807", "0.6039792", "0.5942054", "0.58846796", "0.58261853", "0.57786655", "0.57283723", "0.57097054", "0.57036746", "0.5674365", "0.5644592", "0.5615924", "0.5566...
0.7222683
1
Returns the uri of the given vmedia device
def get_vmedia_device_uri(self, device): try: sushy_system = self._get_sushy_system() uri = utils.get_subresource_path_by(sushy_system, 'VirtualMedia') resp = sushy_system._conn.get(uri) vmedia_resp = json.loads(resp.text) for val in vmedia_resp.get("...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def device_path(self):\n return self._engine.device_path()", "def get_url(self):\n if not self.get_video_id():\n return ''\n \n return 'http://www.dailymotion.com/%s' % self.get_video_id()", "def getParentDeviceUrl(self):\n url = \"\"\n dev = self.device()\n if ...
[ "0.6051921", "0.5776216", "0.57630146", "0.57262486", "0.5671397", "0.56639475", "0.56584483", "0.56198096", "0.55954635", "0.55858", "0.552727", "0.552347", "0.55124736", "0.55118614", "0.55114794", "0.5461846", "0.542601", "0.5401182", "0.5401182", "0.5401182", "0.5401182",...
0.8049047
0
Gets the product name of the server.
def get_product_name(self): sushy_system = self._get_sushy_system() return sushy_system.model
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def product_name(self):\n return self._stub.List(self._message).product_name", "def product_name(self):\n return self._product_name", "def get_product_name(self):\n system = self._get_host_details()\n return system['Model']", "def product_name(self) -> Optional[str]:\n retu...
[ "0.8168809", "0.7893617", "0.7758751", "0.7663046", "0.7437491", "0.7431132", "0.7421063", "0.73016155", "0.73016155", "0.71450585", "0.6981237", "0.6889687", "0.6856621", "0.67716855", "0.6767265", "0.6752493", "0.66959023", "0.66839856", "0.6644297", "0.6551729", "0.6542573...
0.73451436
7
compute the 2's complement of int value val
def twos_comp(val, bits): if (val & (1 << (bits - 1))) != 0: # if sign bit is set e.g., 8bit: 128-255 val = val - (1 << bits) # compute negative value return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ones_complement(val):\n #mask = (1 << val.bit_length()) - 1\n #return int(hex(val ^ mask), 16)\n b = bin(val)\n b = b.replace('0', 'x')\n b = b.replace('1', '0')\n b = b.replace('x', '1')\n b = b.replace('1b', '0b')\n return int(b, 2)", "def invert(val)...
[ "0.7548196", "0.7474319", "0.74621737", "0.7444895", "0.7372613", "0.7227137", "0.7093456", "0.7083535", "0.6965524", "0.69272786", "0.6796253", "0.6767744", "0.6730829", "0.66353106", "0.6527896", "0.64418924", "0.63548034", "0.63548034", "0.6349893", "0.633111", "0.633111",...
0.62485665
27
Initialize default params and save it.
def _use_default_params(self): self.params = { # Desktop window params 'pos': (100, 100), 'lock_pos': False, # Font params 'default_font': 'Sans 9', # Lessons colors 'lecture_color': '#009566660000', 'laboratory_colo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _initialize_defaults(self):\n for key, value in defaults.items():\n if key not in self.source_params:\n self.source_params[key] = value", "def _initialize_defaults(self):\n for key, value in defaults.items():\n if key not in self.source_params:\n ...
[ "0.7565157", "0.7565157", "0.7457092", "0.7390707", "0.7167309", "0.69433814", "0.68717897", "0.6798223", "0.67878556", "0.6785591", "0.67114073", "0.666332", "0.66550595", "0.6640259", "0.6557672", "0.6545346", "0.654076", "0.64463425", "0.6427991", "0.6415848", "0.6415848",...
0.7091283
5
Get scheduler view settings.
def get_view_sch(self): return self.params['view_sch']
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_settings(self):\n return self.settings", "def getSettings(self):\n return self.cfg", "def get_settings(client_id):\n\ttry:\n\t\tsettings = session.query(Settings)\\\n\t\t\t\t.filter(Settings.user_id == client_id)\\\n\t\t\t\t.one()\n\t\treturn DisplayedSettings(settings.time_format,\n\t\t\...
[ "0.6414362", "0.63309354", "0.6139582", "0.61186033", "0.61186033", "0.5955395", "0.5914938", "0.5877596", "0.5875556", "0.5830618", "0.57609874", "0.57609874", "0.5736649", "0.5728508", "0.5711356", "0.56691027", "0.5666654", "0.5666654", "0.56402314", "0.5640005", "0.561413...
0.5558977
30
X = list of (word_indices, word_char_indices) Y = list of tag indices
def get_data_as_indices(self, file_name): X, Y = [],[] org_X, org_Y = [], [] for (words, tags) in read_conll_file(file_name): word_indices, word_char_indices = self.get_features(words) tag_indices = [self.tag2idx.get(tag) for tag in tags] X.append((word_indic...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def analyze_corpus(self,\n x: Union[Tuple[List[List[str]], ...], List[List[str]]],\n y: Union[List[List[Any]], List[Any]]):\n if len(self.processor.token2idx) == 0:\n self._build_token2idx_from_gpt()\n super(GPT2Embedding, self).analyze_corpus(x,...
[ "0.6698782", "0.6478844", "0.6368397", "0.6335209", "0.629045", "0.6275756", "0.62239873", "0.6149047", "0.61374706", "0.6124563", "0.6124556", "0.60996974", "0.5983223", "0.5956739", "0.59561336", "0.5951793", "0.594489", "0.5924066", "0.5918952", "0.5909403", "0.5900194", ...
0.5969337
13
Ensure the generated cusip is of an existing instrument
def cusip_exists(record): cusips = helper.query_db('instruments', 'cusip') assert record['cusip'] in cusips
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_instrument(self):\n assert self.instrument in self.obs_package.INSTRUMENTS, \\\n \"Invalid instrument \" + repr(self.instrument) + \" in \" + repr(self.filename)", "def is_ivi_instrument(self): \n \n return False", "def test_instrument(self, nexus_base):\n as...
[ "0.679839", "0.5958377", "0.58730334", "0.5544878", "0.53002614", "0.5169456", "0.51149416", "0.510501", "0.51008576", "0.5063405", "0.50621146", "0.5057878", "0.50352186", "0.49837187", "0.4934703", "0.49324533", "0.4930831", "0.49290395", "0.49161485", "0.48955062", "0.4894...
0.5380118
4
Ensure that the datetime passed in has a date value that matches the current date in UTC
def correct_datetime(record_datetime): assert record_datetime.date() == datetime.now(timezone.utc).date()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_freeze_with_timezone_aware_datetime_in_utc():\n utc_now = datetime.datetime.utcnow()\n assert utc_now.tzinfo is None", "def test_freeze_with_timezone_aware_datetime_in_non_utc():\n utc_now = datetime.datetime.utcnow()\n assert utc_now.tzinfo is None\n assert utc_now == datetime.datetime(1...
[ "0.7356238", "0.71485275", "0.66523594", "0.6541351", "0.6529816", "0.64570004", "0.6359462", "0.63537574", "0.6276923", "0.62672144", "0.620718", "0.6166882", "0.6139082", "0.6116861", "0.60782737", "0.6065122", "0.6057272", "0.60165864", "0.59800345", "0.597941", "0.5978563...
0.7480017
0
define adadelta optimizer given loss and weights/biases
def run_time_operation(self, learning_option, cluster): # get input loss = self.get_input('loss') # get attr # required field lr = float(self.get_attr('lr', default=None)) if lr is None: raise Exception('[DLMDL ERROR]: {0} in {1} layer must be declare...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_Adam_op(loss, alpha, beta1, beta2, epsilon):\n\n optimizer = tf.train.AdamOptimizer(learning_rate=alpha, beta1=beta1,\n beta2=beta2, epsilon=epsilon)\n train = optimizer.minimize(loss)\n\n return train", "def adam_optimizer(loss, initial_lr, decay_step, d...
[ "0.70636135", "0.70375496", "0.68190414", "0.681262", "0.68023705", "0.6789951", "0.6738914", "0.671566", "0.6651777", "0.6588445", "0.65650874", "0.656376", "0.64882535", "0.64668834", "0.6427307", "0.6414602", "0.6399021", "0.636674", "0.6334719", "0.6334087", "0.6297513", ...
0.0
-1
Determines if there was a game yesterday.
def was_game_yesterday(team_id, date): prev_game_date, prev_game = get_previous_game(team_id) yesterday = date - timedelta(days=1) prev_game_date_dt = parse(prev_game_date) prev_game_yesterday = bool(prev_game_date_dt.date() == yesterday.date()) return prev_game_yesterday, prev_game
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_yesterday(self, dt: datetime.datetime) -> bool:\n return self.is_today(dt - datetime.timedelta(days=1))", "def test_check_yesterday(self):\n \n # the service calendar has two weekdays, back to back\n sc = ServiceCalendar()\n sc.add_period( 0, 3600*24, [\"WKDY\"] )\n s...
[ "0.7253214", "0.65288985", "0.64132243", "0.6371867", "0.62969434", "0.6260945", "0.6231381", "0.61892194", "0.6176855", "0.60915107", "0.6082543", "0.607987", "0.60670835", "0.5986584", "0.5950555", "0.5922569", "0.588863", "0.58419514", "0.5764841", "0.5741818", "0.5728269"...
0.78098494
0
Initialize a policygradient actorlearner.
def __init__(self, model: Module, settings: PGActorSettings) -> None: super().__init__(settings) final_layer, self.network = finalize_module(model, from_numpy(self.state_space.sample()), self._num_policy_params) self.settings.optimizer.add_par...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, num_learners: int):\n self.num_learners = num_learners\n self.learners = []\n self.learner_weights = np.ones(num_learners)", "def __init__(self, requires_grad=False):\n self.requires_grad = requires_grad # whether tensors needs gradient\n self._reset_gradien...
[ "0.672948", "0.6239042", "0.62075555", "0.6074231", "0.60028267", "0.59854907", "0.59627247", "0.5961752", "0.59560364", "0.5940011", "0.5908918", "0.5867507", "0.5855079", "0.5843629", "0.5838547", "0.58337444", "0.5804207", "0.58036983", "0.58011055", "0.5790153", "0.577539...
0.0
-1
Euclidean distance between two points.
def dist2D(a, b): return ((a[0]-b[0])**2 + (a[1]-b[1])**2)**0.5
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def euclidean_distance(point1, point2):\n\n return math.sqrt(sum([(x - y) ** 2 for x, y in zip(point1, point2)]))", "def euclidean_distance(point1, point2):\n return np.linalg.norm(np.array(point1) - np.array(point2))", "def euclidean_distance(point_one, point_two):\n return np.linalg.norm(point_one-p...
[ "0.84279233", "0.83612895", "0.8324174", "0.83092695", "0.8306929", "0.82199126", "0.8209069", "0.82086724", "0.8176723", "0.805556", "0.80503225", "0.8045459", "0.80258095", "0.7958847", "0.7943932", "0.79337907", "0.79223317", "0.78885055", "0.7877786", "0.78511626", "0.784...
0.0
-1
Returns bin_size number of bins each ranging between [0, 1]
def _get_distribution ( bin_size, Flag = 0 ): # Get the step size lower = 0; upper = step = 1/bin_size Dist = {} # make bins while upper <= 1: Dist[Flag] = [ lower, upper ] Flag += 1 lower = upper upper += step return Dist
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bin_width(self):\n return self.bins[2] - self.bins[1]", "def getBinSize(axes, bin_numbers):\n\n size = 1\n for axis, bin_number in zip(axes, bin_numbers):\n if bin_number in (\"underflow\", \"overflow\"):\n continue\n x0, x1 = axis.getBinRange(bin_number)\n size *...
[ "0.7949085", "0.7848623", "0.7463649", "0.7463649", "0.7323575", "0.72100955", "0.71490854", "0.6927804", "0.69052553", "0.69017756", "0.6889671", "0.6886351", "0.68771684", "0.6852", "0.68175805", "0.6745698", "0.67275983", "0.67046046", "0.66795754", "0.66732806", "0.666375...
0.0
-1
Loads dict from json
def _load(self): if self.file_path.exists(): with open(self.file_path) as fid: self.data = json.load(fid)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_json(self):\n\n self.load_json_str(self.get_json_str())", "def load(self):\n with io.open(self.filename, encoding='utf-8') as f:\n self.load_from_dict(json.loads(f.read()))", "def load_json(request, json):\n return json", "def import_json(self) -> dict:\n with open...
[ "0.74605465", "0.7348744", "0.7284966", "0.72409385", "0.7227196", "0.70374835", "0.6965872", "0.6934604", "0.6886127", "0.6861682", "0.68577313", "0.68316627", "0.68298584", "0.6821488", "0.68049204", "0.6792506", "0.67876244", "0.6764379", "0.6759194", "0.67540705", "0.6736...
0.62219846
86
Writes information to json file.
def _save(self): with open(self.file_path, 'w') as fid: json.dump(self.data, fid, indent=4, sort_keys=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(self):\r\n\r\n with open(self.filename + \".json\", mode='w') as json_file:\r\n json.dump(self.data, json_file, separators=(',', ':'))", "def _write_json(self):\n with open(self._file_path, 'w') as f:\n json.dump(self._content, f, indent=4, separators=None,\n ...
[ "0.82632095", "0.80979747", "0.7972736", "0.7955615", "0.78186363", "0.78186363", "0.7568629", "0.7545705", "0.75236243", "0.74942774", "0.7435079", "0.7420979", "0.74058026", "0.73483497", "0.73208094", "0.7304365", "0.72945684", "0.7251182", "0.72107565", "0.7208944", "0.72...
0.7259478
17
Method that contains the LSSM for the exponential window
def exponential_window_lssm(self): self.A = np.array([self.decay]) self.s = np.ones(1) self.C = np.ones(1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gamma_window_lssm(self):\n # sampling frequency\n Fs = 44100.0\n\n A = np.array([[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [0, 0, 0, 1]])\n self.A = self.decay * A\n T_d_1 = np.array([[0, 0, 0, 1], [0, 0, 1, 0], [0, 2, 1, 0], [6, 6, 1, 0]])\n C = np.array([0, 0, 0, np....
[ "0.6833681", "0.6209633", "0.618569", "0.60904783", "0.6013877", "0.5850594", "0.57949615", "0.5756323", "0.5698979", "0.568647", "0.56608003", "0.56519043", "0.5619328", "0.55979764", "0.55921185", "0.55782115", "0.55639917", "0.5520343", "0.5517618", "0.5501403", "0.5484623...
0.8464964
0
Call the parent initialisation, and set the centre variable
def __init__(self, centre): super().__init__() self.centre = centre
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def center(self):\r\n self.centerx = self.screen_rect.centerx \r\n self.centery = self.screen_rect.centery", "def setCenter(self, p):\n self.__center = p", "def setCentreCoordinates(self,xcenter,ycenter):\n self.x = xcenter\n self.y = ycenter", "def GetCenter(self):\n ...
[ "0.70146227", "0.7004427", "0.7003298", "0.69727886", "0.69727886", "0.69727886", "0.69727886", "0.6884419", "0.6857499", "0.6712505", "0.67078954", "0.6658054", "0.6614058", "0.6563238", "0.65030724", "0.6497342", "0.6484851", "0.6459062", "0.64561266", "0.64370704", "0.6419...
0.82500476
0
expand MatrixSymbol as MatrixElement and simplify it >>> from sympy import >>> from symplus.strplus import init_mprinting >>> init_mprinting() >>> A = MatrixSymbol('A', 2, 2) >>> Eq(det(A), 0) 0 == ||A|| >>> with_matsym(matsimp)(_) 0 == A[0, 0]A[1, 1] A[0, 1]A[1, 0] >>> Eq(A.TA, Identity(2)) A'A == I >>> with_matsym(ma...
def with_matsym(*simplifies): from sympy.matrices import MatrixSymbol from symplus.setplus import AbstractSet def simplify_with_matsym(expr, *args, **kwargs): # expand MatrixSymbol as Matrix: A -> [ A[0,0] ,..] mats = list(expr.atoms(MatrixSymbol)) agents = list(Dummy(str(mat)) for m...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def matsimp(expr):\n from sympy.simplify.simplify import bottom_up\n\n # do indexing: [.., aij ,..][i,j] -> aij\n expr = do_indexing(expr)\n # deep doit: Trace([.., aij ,..]) -> ..+ aii +..\n expr = bottom_up(expr, lambda e: e.doit())\n\n def mateq_expand(m1, m2):\n if not is_Matrix(m1) an...
[ "0.66872954", "0.60506874", "0.60032284", "0.5907534", "0.58817136", "0.58813095", "0.5865265", "0.58361614", "0.5781598", "0.57183796", "0.5700911", "0.5671527", "0.557132", "0.55168724", "0.54724246", "0.54454553", "0.54125464", "0.53939754", "0.5365956", "0.5362725", "0.53...
0.788629
0
Return a unique ID to use for this entity.
def unique_id(self): return self.config_entry.entry_id + "stg"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unique_id(self) -> str:\n return self._unique_id", "def unique_id(self) -> str:\n return self._unique_id", "def unique_id(self) -> str:\n return self._unique_id", "def unique_id(self) -> str:\n return self._unique_id", "def unique_id(self) -> str:\n return self._uniqu...
[ "0.84614056", "0.84614056", "0.84614056", "0.84614056", "0.84614056", "0.84614056", "0.84614056", "0.84614056", "0.83561784", "0.8344578", "0.8344578", "0.832443", "0.82223576", "0.82223576", "0.8204842", "0.8204842", "0.8182103", "0.81747264", "0.8151354", "0.81463504", "0.8...
0.0
-1
Return the state attributes.
def extra_state_attributes(self): return { "stage_coct": self.coordinator.data.get("stage"), "stage_eskom": self.coordinator.data.get("stage_eskom"), "coct_area": self.coordinator.data.get("coct_area"), "load_shedding_active": self.coordinator.data.get("load_shedd...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def state_attributes(self):\n return self._attributes", "def state_attributes(self):\n return self._attributes", "def device_state_attributes(self):\r\n return self.attributes", "def device_state_attributes(self):\n return self._state_attrs", "def device_state_attributes(self):\...
[ "0.8953404", "0.8953404", "0.85239846", "0.8366765", "0.8366765", "0.8363429", "0.83362615", "0.8334551", "0.8310377", "0.8292682", "0.8289349", "0.8289349", "0.82871646", "0.82871646", "0.82871646", "0.82871646", "0.82871646", "0.82871646", "0.82871646", "0.82871646", "0.828...
0.7365827
95
Return a unique ID to use for this entity.
def unique_id(self): return self.config_entry.entry_id + "lsa"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unique_id(self) -> str:\n return self._unique_id", "def unique_id(self) -> str:\n return self._unique_id", "def unique_id(self) -> str:\n return self._unique_id", "def unique_id(self) -> str:\n return self._unique_id", "def unique_id(self) -> str:\n return self._uniqu...
[ "0.8460817", "0.8460817", "0.8460817", "0.8460817", "0.8460817", "0.8460817", "0.8460817", "0.8460817", "0.8355675", "0.8343812", "0.8343812", "0.83238506", "0.8221654", "0.8221654", "0.8203365", "0.8203365", "0.81823623", "0.8174053", "0.8151542", "0.8146305", "0.81339616", ...
0.0
-1
Return the state attributes.
def device_state_attributes(self): return { "load_shedding_active": self.coordinator.data.get("load_shedding_active"), }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def state_attributes(self):\n return self._attributes", "def state_attributes(self):\n return self._attributes", "def device_state_attributes(self):\r\n return self.attributes", "def device_state_attributes(self):\n return self._state_attrs", "def device_state_attributes(self):\...
[ "0.8953404", "0.8953404", "0.85239846", "0.8366765", "0.8366765", "0.8363429", "0.83362615", "0.8334551", "0.8310377", "0.8292682", "0.8289349", "0.8289349", "0.82871646", "0.82871646", "0.82871646", "0.82871646", "0.82871646", "0.82871646", "0.82871646", "0.82871646", "0.828...
0.0
-1
Return a unique ID to use for this entity.
def unique_id(self): return self.config_entry.entry_id + "nls"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unique_id(self) -> str:\n return self._unique_id", "def unique_id(self) -> str:\n return self._unique_id", "def unique_id(self) -> str:\n return self._unique_id", "def unique_id(self) -> str:\n return self._unique_id", "def unique_id(self) -> str:\n return self._uniqu...
[ "0.8460817", "0.8460817", "0.8460817", "0.8460817", "0.8460817", "0.8460817", "0.8460817", "0.8460817", "0.8355675", "0.8343812", "0.8343812", "0.83238506", "0.8221654", "0.8221654", "0.8203365", "0.8203365", "0.81823623", "0.8174053", "0.8151542", "0.8146305", "0.81339616", ...
0.0
-1
Return the state attributes.
def device_state_attributes(self): return { "next_load_shedding_slot": self.coordinator.data.get("next_load_shedding_slot"), }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def state_attributes(self):\n return self._attributes", "def state_attributes(self):\n return self._attributes", "def device_state_attributes(self):\r\n return self.attributes", "def device_state_attributes(self):\n return self._state_attrs", "def device_state_attributes(self):\...
[ "0.8953404", "0.8953404", "0.85239846", "0.8366765", "0.8366765", "0.8363429", "0.83362615", "0.8334551", "0.8310377", "0.8292682", "0.8289349", "0.8289349", "0.82871646", "0.82871646", "0.82871646", "0.82871646", "0.82871646", "0.82871646", "0.82871646", "0.82871646", "0.828...
0.0
-1
Moves the item at pos to its correct position deeper in the heap. This heavily borrows from the Python heapq implementation which uses the elegant intuition that items inserted at the root (following extraction) tend to be large. Instead of comparing the new root value, the heap is first restored, successively moving u...
def _siftdown(self, entry, pos=0): heap, imap = self._heap, self._index_map heaplen = len(heap) left = pos * 2 + 1 while left < heaplen: right = left + 1 minpos = left + (right < heaplen and heap[right] < heap[left]) minchild = heap[minpos] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def siftup(self, node, pos):\n p = self.parent(pos)\n while p is not None and self.heap[p].key > node.key:\n self.heap[pos] = self.heap[p]\n self.heap[pos].pos = pos\n pos = p\n p = self.parent(p)\n self.heap[pos] = node\n node.pos = pos", "...
[ "0.7678786", "0.74393314", "0.7112669", "0.69668823", "0.6943382", "0.687917", "0.68531543", "0.6780226", "0.67455554", "0.6643831", "0.66210127", "0.6612947", "0.646162", "0.646162", "0.6460779", "0.6448717", "0.6446476", "0.643973", "0.642797", "0.64198524", "0.64058864", ...
0.63067937
24
Returns an iterator for the heap's valid subheaps.
def __iter__(self): return (heap for heap in self._subheaps if heap.parent is self)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def heap_choices(heaps):\r\n return [index for index, size in enumerate(heaps) if size > 0]", "def __iter__(self):\n for partition in self._partition_set:\n yield partition", "def min_heap(self): \n \n for pos in range(self.size//2, 0, -1): \n self.min_heapify(pos)",...
[ "0.6123324", "0.5894165", "0.5681033", "0.56762046", "0.5614078", "0.5465425", "0.54247373", "0.53931636", "0.53857946", "0.53711873", "0.5334493", "0.52940154", "0.52848035", "0.526758", "0.5265981", "0.5236723", "0.52137214", "0.5204714", "0.5192011", "0.51870966", "0.51588...
0.7867703
0
Toggle user admin status endpoint To toggle, access token and admin permissions are required
def post(self, user_id): user = User.query.get(user_id) if user is None: return mk_response("User does not exist", 422) """ check if user's the only admin if it's an admin """ admins = User.query.filter_by(admin=True).all() if user.admin and len(admins) == 1: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def admin_required(handler):\n def admin_login(self, *args, **kwargs):\n auth = self.auth\n if not auth.get_user_by_session():\n self.redirect('/auth/login', abort=True)\n \n user = auth.get_user_by_session()\n queried_entity = User.get_by_id(user['user_id'])\n ...
[ "0.64530903", "0.63205475", "0.626141", "0.62442017", "0.62240565", "0.62228924", "0.6206753", "0.61810523", "0.61810523", "0.6179652", "0.6177919", "0.6082303", "0.6078702", "0.607789", "0.60211396", "0.6020937", "0.6014154", "0.6006011", "0.59898394", "0.59878695", "0.59601...
0.0
-1
Should return an http status 404 and an error message.
def test_list_figures_project_not_found(self): project_id = "unk" deployment_id = util.MOCK_UUID_1 monitoring_id = util.MOCK_UUID_1 rv = TEST_CLIENT.get( f"/projects/{project_id}/deployments/{deployment_id}/monitorings/{monitoring_id}/figures" ) result = rv.j...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def not_found():\n return HttpError(404)", "def not_found(self, error):\n return jsonify({'error': 'NOT FOUND'}), 404", "def not_found(error): # pylint: disable=unused-argument\n response = jsonify(\n {\"success\": False, \"error_code\": 404, \"message\": \"Not Found\"}\n )\n return resp...
[ "0.8602346", "0.82621646", "0.8238469", "0.8209371", "0.8153551", "0.81376755", "0.8080629", "0.80714786", "0.8064836", "0.80427784", "0.8024149", "0.799469", "0.7963838", "0.79292715", "0.7915635", "0.79155046", "0.78884137", "0.7877857", "0.78743315", "0.7864041", "0.786203...
0.0
-1
Should return an http status 404 and an error message.
def test_list_figures_deployment_not_found(self): project_id = util.MOCK_UUID_1 deployment_id = "unk" monitoring_id = util.MOCK_UUID_1 rv = TEST_CLIENT.get( f"/projects/{project_id}/deployments/{deployment_id}/monitorings/{monitoring_id}/figures" ) result = r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def not_found():\n return HttpError(404)", "def not_found(self, error):\n return jsonify({'error': 'NOT FOUND'}), 404", "def not_found(error): # pylint: disable=unused-argument\n response = jsonify(\n {\"success\": False, \"error_code\": 404, \"message\": \"Not Found\"}\n )\n return resp...
[ "0.8601373", "0.82612085", "0.8237346", "0.8210479", "0.8152887", "0.81378824", "0.8080897", "0.80714935", "0.8064683", "0.80421686", "0.8023202", "0.79937464", "0.7961655", "0.7928829", "0.7915655", "0.79152226", "0.78884727", "0.7876903", "0.78733194", "0.7863459", "0.78610...
0.0
-1
Should return an http status 404 and an error message.
def test_list_figures_monitoring_not_found(self): project_id = util.MOCK_UUID_1 deployment_id = util.MOCK_UUID_1 monitoring_id = "unk" rv = TEST_CLIENT.get( f"/projects/{project_id}/deployments/{deployment_id}/monitorings/{monitoring_id}/figures" ) result = r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def not_found():\n return HttpError(404)", "def not_found(self, error):\n return jsonify({'error': 'NOT FOUND'}), 404", "def not_found(error): # pylint: disable=unused-argument\n response = jsonify(\n {\"success\": False, \"error_code\": 404, \"message\": \"Not Found\"}\n )\n return resp...
[ "0.8601373", "0.82612085", "0.8237346", "0.8210479", "0.8152887", "0.81378824", "0.8080897", "0.80714935", "0.8064683", "0.80421686", "0.8023202", "0.79937464", "0.7961655", "0.7928829", "0.7915655", "0.79152226", "0.78884727", "0.7876903", "0.78733194", "0.7863459", "0.78610...
0.0
-1
Workaround to compare objects in transient state.
def __eq__(self, other): comparable_fields = ['uuid', 'name', 'email'] return all([getattr(self, field) == getattr(other, field) for field in comparable_fields])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_compare() -> None:\n\n obj = SpecificLocation()\n obj2 = SpecificLocation()\n\n assert obj != obj2\n\n obj._id = obj2.id\n\n assert obj == obj2", "def deep_cmp(obj1, obj2):\n pass", "def pickling_check(instance):\n pkled_instance = pickle.loads(pickle.dumps(instance))\n equalit...
[ "0.65634394", "0.6515314", "0.6444857", "0.6408659", "0.6392005", "0.6391554", "0.63740474", "0.63363266", "0.63358706", "0.62294203", "0.6220161", "0.6209158", "0.61927354", "0.61890733", "0.6175497", "0.6149843", "0.61494845", "0.6107647", "0.6107647", "0.6107647", "0.61076...
0.0
-1
Compute softmax values for each sets of scores in x.
def softmax(x): e_x = np.exp(x - np.max(x)) return e_x / e_x.sum(axis=0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def softmax(self, scores):\n\n\n # for each sample, for each class ,caclulate\n # np.exp(scores) : still (n_samples, n_classes)\n\n # axis = 1\n # a00, a01, a02 as a sinlge one to perfrom np_sum\n # which is the same sample \n # sum_exp : still (n_samples, 1)\n\n # ...
[ "0.7796294", "0.7760558", "0.7759004", "0.77567077", "0.76577055", "0.76577055", "0.76577055", "0.76577055", "0.7585655", "0.743143", "0.7407772", "0.73941606", "0.7358175", "0.73174125", "0.72689486", "0.72623265", "0.72614294", "0.7256868", "0.723019", "0.7214918", "0.72017...
0.7061677
63
Gets and cleans product price from Amazon page. If HTML attribute priceblock_ourprice or priceblock_dealprice is absent, the price is marked as Not Available.
def get_product_price(self, url): self.driver.get(url) try: price = self.driver.find_element_by_id("priceblock_ourprice").text except: pass try: price = self.driver.find_element_by_id("priceblock_dealprice").text except: pass ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def priceGetSome(soup):\n price = soup.find('span', id='priceblock_ourprice', class_='a-size-medium a-color-price')\n price = price.text\n price = price.strip()\n price = price.lstrip('$')\n price = float(price)\n\n return price", "def get_product_price(self):\n\n price = \"0.0000\"\n\n ...
[ "0.72817224", "0.72535336", "0.718885", "0.71553606", "0.7120282", "0.6966835", "0.69027257", "0.67992544", "0.6774249", "0.66992074", "0.6628084", "0.6557547", "0.65276474", "0.65175027", "0.64088476", "0.6405684", "0.6308108", "0.6272755", "0.6236634", "0.6218563", "0.62002...
0.8162164
0
Serializes an object as YAML. Optionally given keyword arguments are passed to yaml.dumps(), ensure_ascii however defaults to False.
def json_to_yaml(value): return yaml.safe_dump(json.loads(value))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toYAML(cls, obj):\n if isinstance(obj, dict):\n return yaml.dump(obj, default_flow_style=False)\n else:\n return yaml.dump_all(obj, default_flow_style=False)", "def dump(arg):\n return yaml.safe_dump_all(\n arg,\n allow_unicode=True,\n default_flow_...
[ "0.69628125", "0.6799648", "0.67767394", "0.66111696", "0.64905745", "0.6463696", "0.64564383", "0.64351296", "0.6363014", "0.6335967", "0.6304855", "0.62596315", "0.6225133", "0.617165", "0.6088122", "0.60674834", "0.6042777", "0.59880435", "0.5967196", "0.5957767", "0.59340...
0.0
-1
Serializes an object as YAML. Optionally given keyword arguments are passed to yaml.dumps(), ensure_ascii however defaults to False.
def yaml_dumps(value): return yaml.dump(value, default_flow_style=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toYAML(cls, obj):\n if isinstance(obj, dict):\n return yaml.dump(obj, default_flow_style=False)\n else:\n return yaml.dump_all(obj, default_flow_style=False)", "def dump(arg):\n return yaml.safe_dump_all(\n arg,\n allow_unicode=True,\n default_flow_...
[ "0.69641715", "0.6802888", "0.6780608", "0.6612835", "0.6491819", "0.6463414", "0.64594793", "0.6434951", "0.6364055", "0.6338956", "0.63073325", "0.62635374", "0.62288934", "0.6175655", "0.60895646", "0.6070342", "0.6046534", "0.59906334", "0.596918", "0.5938119", "0.5927328...
0.59616405
19
Covariances of this model. Computed lazily, if required.
def covar(self) -> np.ndarray: if self._covar is None: self._covar = batched_inv_spd(batched_cholesky(self._inv_covar)) return self._covar
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_covariance(self):\n ...", "def covariance(self):\n return self._covariance", "def get_covariance_copy(self):\n return copy.deepcopy(self._covariance)", "def belief_covariance(self) -> types.CovarianceTorch:\n return self._belief_covariance", "def measurement_covariance(s...
[ "0.7853934", "0.7317019", "0.6865522", "0.68213034", "0.6585484", "0.65652466", "0.65423226", "0.6495284", "0.64223224", "0.63800967", "0.62530583", "0.61616945", "0.5982438", "0.5874972", "0.5852527", "0.57854223", "0.57325244", "0.56832945", "0.5674666", "0.5671766", "0.567...
0.46871507
99
Set seed for all random number generators.
def set_seed(seed: int = 42) -> None: np.random.seed(seed) torch.manual_seed(seed) if torch.cuda.is_available: torch.cuda.manual_seed_all(seed) # type:ignore
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_seed(cls, seed: Any) -> None:\n cls.rand = Random(seed)", "def set_seed(self):\n self.set_scikit_learn_seed()\n self.set_torch_seed()\n self.set_python_random_seed()", "def seed(self, seed=None):\n if seed is not None:\n self._rng.seed(seed)", "def _set_s...
[ "0.8354558", "0.82036304", "0.81374943", "0.8135785", "0.8114274", "0.8108064", "0.8052954", "0.79987645", "0.7995255", "0.7949692", "0.79144025", "0.79144025", "0.7912484", "0.7909762", "0.7861519", "0.7841465", "0.784056", "0.7794522", "0.77884734", "0.7771751", "0.77587694...
0.7383693
77
Returns the unit vector of the vector
def _get_unit_vector(self, v): return v / np.linalg.norm(v)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unit_vector(vector):\n #print 'unit_vector'\n #print vector\n #print type(vector)\n #npvector = np.array(vector)\n return vector / np.linalg.norm(vector)", "def unit_vector(self,vector):\n return vector / np.linalg.norm(vector)", "def unit_vector(vector):\n return vector / np.l...
[ "0.8538314", "0.8460516", "0.84529936", "0.8424554", "0.8424554", "0.8424554", "0.84148395", "0.83911633", "0.836671", "0.835637", "0.83531153", "0.83531153", "0.83531153", "0.83531153", "0.83531153", "0.83531153", "0.83531153", "0.83531153", "0.83531153", "0.83531153", "0.83...
0.8499301
1
Returns the trajectory calculated with given coefficients
def _get_trajectory(self, coeff_S, coeff_D): # Create trajectory trajectory = Trajectory(self.deltaT, self.dt, self.t_steps) coeff = np.array([coeff_S, coeff_D]).T p_array = self.helper_p.dot(coeff) v_array = self.helper_v.dot(coeff) a_array = self.helper_a.dot(coeff) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_coefficients(self, start, end):\n A = np.array([\n [self.deltaT**3, self.deltaT**4, self.deltaT**5],\n [3 * self.deltaT**2, 4 * self.deltaT**3, 5 * self.deltaT**4],\n [6 * self.deltaT, 12 * self.deltaT**2, 20 * self.deltaT**3],\n ])\n\n a_0, a_1, ...
[ "0.68109334", "0.6650603", "0.65509325", "0.65509325", "0.65180016", "0.64657336", "0.63869715", "0.62912416", "0.6283986", "0.62292403", "0.6225533", "0.6190745", "0.6110645", "0.60959363", "0.60959363", "0.6082813", "0.60781837", "0.60381794", "0.5973372", "0.59707844", "0....
0.6849225
0
Returns the home page.
def home(): string = open('Tinder/static/data/data.json').read() json_data = json.loads(string) return flask.render_template('tinder.html', json_data=json_data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def home_page(self) -> str:\n return self._home_page", "def home() -> Any:\n return home_page()", "def home():\n\n\treturn render_template('index.html', title='Home Page',\n\t\t\t\t\t\t year=datetime.now().year)", "def home():\n\n return render_template('home_page.html')", "def homepage():\n...
[ "0.84712803", "0.8365871", "0.83411855", "0.83378404", "0.8262674", "0.82501084", "0.81962675", "0.8184743", "0.8147923", "0.81414473", "0.8131482", "0.81293994", "0.81233937", "0.8122301", "0.8079399", "0.8079399", "0.8079399", "0.8079399", "0.8079399", "0.8079399", "0.80793...
0.0
-1
Renders the home page.
def home(): return render_template('index.html', year=datetime.now().year)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_home():\r\n\treturn render_template(\"index.html\")", "def home():\n\n return render_template('home_page.html')", "def home():\n\n return render_template(\"home.html\")", "def home():\n return render_template('home.html')", "def home():\n return render_template('home.html')", "def ...
[ "0.85574406", "0.853399", "0.8351404", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.827363", "...
0.0
-1
Test user cannot login twitter with wrong token.
def test_twitter_login_fail(self, VerifyCredentials): # note no mock return value assignment(leads to invalid token) response=self.client.post(self.twitter_url, self.twitter_token, format="json") self.assertEqual(response.status_code, 400)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_specific_token_anonymous_user(self):\r\n\r\n res = self.app.get('/api/token/twitter')\r\n err = json.loads(res.data)\r\n\r\n assert res.status_code == 401, err\r\n assert err['status'] == 'failed', err\r\n assert err['status_code'] == 401, err\r\n assert err['...
[ "0.7329248", "0.7300614", "0.72259414", "0.7126919", "0.7037497", "0.6966542", "0.6963945", "0.6957682", "0.69520885", "0.6941833", "0.69313467", "0.6927337", "0.6924932", "0.69152975", "0.6907642", "0.6899966", "0.68974435", "0.683268", "0.6810077", "0.68014824", "0.67959493...
0.78249633
0
Construct a button that runs the simulation
def make_run_button(self): run_button = Button( self.master, text="Run", command=self.run_simulator) run_button.grid(row=6, column=1) return run_button
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_button(self):\r\n self.step = False # Clear step command\r\n self.is_pause = False\r\n self.run_command()", "def on_run_button(self, event):\n text = _(u\"Run button pressed.\")\n if self.state == 0:\n self.canvas_2d.render(text)\n else:\n ...
[ "0.6930561", "0.6879601", "0.67155194", "0.66827357", "0.6550657", "0.65298927", "0.6500178", "0.64281225", "0.6392338", "0.63670987", "0.6364022", "0.6364022", "0.63245595", "0.62719476", "0.6184198", "0.61411166", "0.61275625", "0.6121942", "0.60799843", "0.6062887", "0.606...
0.85459125
0
Construct an input field for the balance value
def make_balance_input(self): balance_label = Label(self.master, text="Balance:") balance_label.grid(row=0, column=0) balance_str = StringVar() balance_str.set(str(self.sim.account.get_balance())) balance_input = Entry(self.master, textvariable=balance_str) balance_inp...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_base_bet_input(self):\n\n base_bet_label = Label(self.master, text=\"Base bet:\")\n base_bet_label.grid(row=1, column=0)\n\n base_bet_str = StringVar()\n base_bet_str.set(str(self.sim.config.get_base_bet()))\n\n base_bet_input = Entry(self.master, textvariable=base_bet_s...
[ "0.64789087", "0.5784496", "0.56802756", "0.56057316", "0.55910987", "0.55885535", "0.5555302", "0.5371452", "0.53509784", "0.5342053", "0.5325071", "0.5321194", "0.53063375", "0.5304961", "0.5283132", "0.52778697", "0.5260979", "0.52595615", "0.5235181", "0.52141076", "0.520...
0.799825
0
Obtains SQLAlchemy experiment object from DB.
def _get_experiment_sqa(experiment_name: str, decoder: Decoder) -> SQAExperiment: exp_sqa_class = decoder.config.class_to_sqa_class[Experiment] with session_scope() as session: sqa_experiment = ( session.query(exp_sqa_class).filter_by(name=experiment_name).one_or_none() ) if ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_database(cls, expt_class=ImagingExperiment,\n name='unnamed', parallelize=False, **db_kwargs):\n trial_ids = fetch_trials(**db_kwargs)\n return cls.from_trial_ids(trial_ids, expt_class=expt_class,\n name=name, parallelize=parallelize)", ...
[ "0.6730283", "0.6042997", "0.6019817", "0.58294785", "0.5797277", "0.57750803", "0.5773431", "0.5726875", "0.56786275", "0.56471145", "0.5634816", "0.5604306", "0.56035626", "0.5603337", "0.5602047", "0.5601864", "0.5600658", "0.5591238", "0.5567835", "0.5563745", "0.5555234"...
0.6244126
1
Obtains most of the SQLAlchemy experiment object from DB, with some attributes (model state on generator runs, abandoned arms) omitted. Used for loading large experiments, in cases where model state history is not required.
def _get_experiment_sqa_reduced_state( experiment_name: str, decoder: Decoder ) -> SQAExperiment: exp_sqa_class = cast( Type[SQAExperiment], decoder.config.class_to_sqa_class[Experiment] ) with session_scope() as session: sqa_experiment = ( session.query(exp_sqa_class) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __getstate__(self):\n state = self.__dict__.copy()\n state['_id'] = self._experiment.id if self._experiment is not None else None\n state['_experiment'] = None\n return state", "def _load_experiment(\n experiment_name: str, decoder: Decoder, reduced_state: bool = False\n) -> Ex...
[ "0.5815994", "0.5739301", "0.5630806", "0.5560501", "0.540692", "0.53512216", "0.53100777", "0.5202098", "0.5194674", "0.5174954", "0.5150488", "0.51282644", "0.512184", "0.50961274", "0.5092922", "0.50873977", "0.5077158", "0.5049462", "0.5024376", "0.5003553", "0.49533322",...
0.59372455
0
Get DB ID of the generation strategy, associated with the experiment with the given name if its in DB, return None otherwise.
def _get_generation_strategy_id( experiment_name: str, decoder: Decoder ) -> Optional[int]: exp_sqa_class = decoder.config.class_to_sqa_class[Experiment] gs_sqa_class = decoder.config.class_to_sqa_class[GenerationStrategy] with session_scope() as session: sqa_gs_id = ( session.query(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_experiment_id(experiment_name: str, config: SQAConfig) -> Optional[int]:\n exp_sqa_class = config.class_to_sqa_class[Experiment]\n with session_scope() as session:\n sqa_experiment_id = (\n session.query(exp_sqa_class.id) # pyre-ignore\n .filter_by(name=experiment_name)...
[ "0.6806621", "0.6675364", "0.6665144", "0.611162", "0.6093508", "0.5931719", "0.5883166", "0.5838099", "0.5785762", "0.5754407", "0.5688616", "0.56721544", "0.5619514", "0.5609707", "0.55512476", "0.5548019", "0.5547595", "0.5524033", "0.5494777", "0.54553217", "0.5441361", ...
0.8011542
0
Obtains most of the SQLAlchemy experiment object from DB.
def _get_generation_strategy_sqa( gs_id: int, decoder: Decoder, reduced_state: bool = False ) -> SQAGenerationStrategy: gs_sqa_class = cast( Type[SQAGenerationStrategy], decoder.config.class_to_sqa_class[GenerationStrategy], ) gr_sqa_class = cast( Type[SQAGeneratorRun], d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def db(cls):\n return getattr(db, cls.__name__)", "def _get_db(self):\n gt_db = ...\n return gt_db", "def get_instance():\n \"\"\"Add more judgement for selecting more database backend\"\"\"\n return IMPL", "def from_database(cls, expt_class=ImagingExperiment,\n ...
[ "0.6286941", "0.61117923", "0.6075601", "0.6073055", "0.59905684", "0.5873077", "0.5829256", "0.58258176", "0.5809337", "0.57502925", "0.5719336", "0.57000643", "0.5646814", "0.56080484", "0.55924577", "0.5585477", "0.55759007", "0.5569398", "0.5566943", "0.5560093", "0.55407...
0.0
-1
Write the code for softmax activation function that takes in a numpy array and returns a numpy array.
def softmax(x): output = np.exp(x) return output / np.sum(output, axis=1, keepdims=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def softmax(x):\n return np.exp(x) / np.sum(np.exp(x), axis=1, keepdims=True)", "def softmax(x):\n # (n_samples, n_classes)\n if len(x.shape) == 2:\n row_max = np.max(x, axis=1)\n x -= row_max.reshape((x.shape[0], 1))\n x = np.exp(x)\n row_sum = np.sum(x, axis=1)\n x /= row_sum.reshape((x.shape...
[ "0.7772168", "0.77613497", "0.77422917", "0.77412444", "0.7679111", "0.7661039", "0.76461667", "0.75746185", "0.756431", "0.756431", "0.756431", "0.756431", "0.756431", "0.756431", "0.756431", "0.756431", "0.75591016", "0.7557847", "0.752849", "0.752849", "0.75131965", "0.7...
0.7722753
4
Write the code for sigmoid activation function that takes in a numpy array and returns a numpy array.
def sigmoid(self, x): self.x = x return 1 / (1 + np.exp(-x))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sigmoid(x: np.ndarray \n ) -> np.ndarray:\n return 1/(1+np.exp(-x))", "def sigmoid_activation(x):\n return 1.0 / (1 + np.exp(-x))", "def sigmoid_array(x):\n for l in range(len(x)):\n x[l] = 1/(1 + math.exp(-x[l]))\n return x", "def sigmoid(X,W,b):\n preActivation = ...
[ "0.83350056", "0.7849035", "0.77879715", "0.77802", "0.77621", "0.77297974", "0.77297974", "0.77016187", "0.76913816", "0.76913816", "0.76913816", "0.76913816", "0.76913816", "0.76913816", "0.7684545", "0.7675192", "0.766889", "0.7659026", "0.7653707", "0.7652214", "0.7597954...
0.67885864
91
Write the code for ReLU activation function that takes in a numpy array and returns a numpy array.
def ReLU(self, x): self.x = x return np.maximum(x, 0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ReLU(self, x):\n self.x = x\n output = np.maximum(0, x)\n return output", "def grad_ReLU(self):\n y = self.x\n y[y<=0] = 0\n y[y>0] = 1\n return y\n raise NotImplementedError(\"ReLU gradient not implemented\")", "def relu(X):\n return np.maximum(0, X)", "def...
[ "0.6844538", "0.67266315", "0.6524722", "0.64370054", "0.6422668", "0.6317926", "0.63149077", "0.6290122", "0.6275855", "0.6264576", "0.62606055", "0.62558883", "0.625154", "0.62123823", "0.62123823", "0.61985254", "0.6169163", "0.61647266", "0.6152718", "0.6120387", "0.61203...
0.6518395
3
Write the code for gradient through sigmoid activation function that takes in a numpy array and returns a numpy array.
def grad_sigmoid(self): return self.sigmoid(self.x) * (1 - self.sigmoid(self.x))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sigmoid_grad(x):\n sig = sigmoid(x)\n return np.multiply(sig, 1 - sig)", "def sigmoid(x: np.ndarray \n ) -> np.ndarray:\n return 1/(1+np.exp(-x))", "def sigmoid_grad(self, X):\n var=self.sigmoid(X)\n return var*(1-var)", "def sigmoid_gradient(z):\n #derivative o...
[ "0.7845813", "0.75411314", "0.73966813", "0.7298714", "0.7277141", "0.7274156", "0.7262134", "0.72579235", "0.72251576", "0.7161289", "0.71042675", "0.71008086", "0.7073054", "0.7071549", "0.7066588", "0.7066588", "0.70510864", "0.7029671", "0.7007337", "0.6989882", "0.697607...
0.6936596
24
Return a list of all interactive variables.
def magic_who_ls(self, parameter_s=''): out = [] for i in self.user_ns.keys(): if not (i.startswith('_') or i.startswith('_i')) \ and not (self.internal_ns.has_key(i) or self.user_config_ns.has_key(i)): out.append(i) # FI...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_variables(self):\n return []", "def get_all_variables(self):\n return self.item.get_all_variables()", "def get_all_variables(self):\n return [self.item]", "def variable_names(self):\n\n status, stdout, stderr = self.__xcall__(['--print-variables'])\n\n if status != 0:\n...
[ "0.76425534", "0.75366694", "0.7432569", "0.7261557", "0.7240642", "0.7236376", "0.7112475", "0.7061356", "0.70374787", "0.6996362", "0.6991252", "0.69821805", "0.69785535", "0.6950035", "0.6950035", "0.6950035", "0.6921689", "0.6839596", "0.68128425", "0.6775395", "0.6771257...
0.0
-1
x.__nonzero__() x != 0
def __nonzero__(self): # real signature unknown; restored from __doc__ pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __nonzero__(self):\n for e in self:\n if e != 0:\n return True\n return False", "def __nonzero__(self):\n return self.value.__nonzero__()", "def __nonzero__(self):\n return self.__nonzero", "def __nonzero__(self):\n return self.__nonzero", "def _...
[ "0.77507436", "0.76362675", "0.74977964", "0.74977964", "0.749715", "0.7277969", "0.71057385", "0.70980686", "0.7076215", "0.7038673", "0.7013006", "0.69773006", "0.6971467", "0.69356734", "0.6927782", "0.6920768", "0.690163", "0.6892301", "0.6864851", "0.6852248", "0.6836008...
0.61815006
77
Compute mean IoU for binary scenario (sum all foreground classes as one class)
def get_mIoU_binary(self, n_scan=None): # Sum TP, FP, FN statistic of all samples if n_scan is None: tp_sum = [np.nansum(np.vstack(self.tp_lst[_scan]), axis=0) for _scan in range(self.n_scans)] fp_sum = [np.nansum(np.vstack(self.fp_lst[_scan]), axis=0) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def avg_iou(self):\n return np.mean(self.ious_[np.arange(len(self.labels_)), self.labels_])", "def get_mean_iou(y_true, y_pred):\n \n threshold = tf.math.reduce_max(y_pred, axis=-1, keepdims=True)\n # make sure [0, 0, 0] doesn't become [1, 1, 1]\n # Use abs(x) > eps, instead of x != 0 to check ...
[ "0.7798098", "0.7527955", "0.7453216", "0.7328945", "0.72997296", "0.7180192", "0.70907956", "0.70438594", "0.70094216", "0.6952642", "0.68715245", "0.6833032", "0.6699388", "0.6664794", "0.65296507", "0.65126544", "0.64393747", "0.6357762", "0.63221437", "0.6239058", "0.6206...
0.6858342
11
Creates dataloaders for training, validation and testing.
def get_loader(data_list, config, train=True): with open(config["label_map"], "r") as f: label_map = json.load(f) dataset = GoogleSpeechDataset( data_list=data_list, label_map=label_map, audio_settings=config["hparams"]["audio"], aug_settings=config["hparams"]["augm...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_dataloaders(params):\r\n transform_train = transforms.Compose([transforms.RandomCrop(32, padding=4),\r\n transforms.RandomHorizontalFlip(),\r\n transforms.ToTensor(),\r\n transform...
[ "0.79708993", "0.76481104", "0.76111794", "0.7594412", "0.7436282", "0.7430836", "0.7401107", "0.737089", "0.73430413", "0.7326213", "0.7312644", "0.7281943", "0.722491", "0.7216082", "0.7180367", "0.7171219", "0.71455145", "0.71309346", "0.7091439", "0.70869946", "0.7057379"...
0.6154461
99
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`.
def plot_confusion_matrix(cm, classes, normalize=False, title='Confusion matrix', cmap=plt.cm.Blues): if normalize: cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis] # print("Normalized confusion matrix") else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n...
[ "0.8194862", "0.80949175", "0.8029915", "0.8019153", "0.79941195", "0.7991258", "0.7980955", "0.7976606", "0.79610753", "0.79590565", "0.79378676", "0.7934962", "0.7934504", "0.79313844", "0.7926313", "0.7924577", "0.79241234", "0.7923211", "0.7923023", "0.7921931", "0.791787...
0.0
-1
Resize (plane, row, column, channel) image such that the max size in any dimension is max_dim
def _resize(img, max_dim=128): if max(img.shape[:3]) <= max_dim: return img else: new_size = [max_dim / s if s >= max_dim else 1.0 for s in img.shape[:3]] new_size.append(1.0) # for channel return scipy.ndimage.zoom(img, new_size, order=2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resize(im, target_size, max_size):\n im_shape = im.shape\n im_size_min = np.min(im_shape[0:2])\n im_size_max = np.max(im_shape[0:2])\n im_scale = float(target_size) / float(im_size_min)\n # prevent bigger axis from being more than max_size:\n if np.round(im_scale * im_size_max) > max_size:\n ...
[ "0.6864907", "0.6711969", "0.66751033", "0.66631144", "0.66373366", "0.6537404", "0.6434652", "0.6376039", "0.63438326", "0.6214031", "0.6208876", "0.61779934", "0.61622405", "0.61197174", "0.6104307", "0.60407263", "0.60404575", "0.60056305", "0.5970839", "0.59686047", "0.59...
0.7614025
0
Compute the IOUs between the two sets of boxes.
def bbox_overlaps(boxes1, boxes2): # Compute the areas of `boxes1` and `boxes2`. area1 = (boxes1[:, 2] - boxes1[:, 0] + 1) * (boxes1[:, 3] - boxes1[:, 1] + 1) # [num_boxes1] area2 = (boxes2[:, 2] - boxes2[:, 0] + 1) * (boxes2[:, 3] - boxes2[:, 1] + 1) # [num_boxes2] # Compute the areas of the interse...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bboxes_iou(boxes1, boxes2):\n boxes1 = np.array(boxes1)\n boxes2 = np.array(boxes2)\n boxes1_area = (boxes1[..., 2] - boxes1[..., 0]) * (boxes1[..., 3] - boxes1[..., 1])\n boxes2_area = (boxes2[..., 2] - boxes2[..., 0]) * (boxes2[..., 3] - boxes2[..., 1])\n left_up = np.maxim...
[ "0.78598887", "0.77647895", "0.7741057", "0.7633229", "0.7599868", "0.75095075", "0.7490567", "0.7483238", "0.74311185", "0.73746234", "0.7333854", "0.7316212", "0.73139983", "0.73103863", "0.730166", "0.73004466", "0.7294414", "0.7288208", "0.7288208", "0.7285001", "0.720981...
0.0
-1
Convert or unpack any iterable into a list, with the exception of mappings. If the passed value is either a mapping or not an iterable, it is returned wrapped in a list.
def ensure_list(value: Any) -> List[Any]: if isinstance(value, (Mapping, str)): # do not unpack dictionaries return [value] elif isinstance(value, Iterable): return list(value) else: return [value]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cast_to_list(value):\n if isinstance(value, str):\n value = cast_to_jdict(value)\n assert isinstance(value, list)\n return value\n elif hasattr(value, 'tolist'): # meant for numpy arrays\n # what other potential attributes to check for?\n return value.tolist()\n els...
[ "0.7218612", "0.71349275", "0.68929404", "0.6677411", "0.6598462", "0.65818167", "0.65492785", "0.6490194", "0.6452184", "0.6452184", "0.6296064", "0.62819916", "0.61536384", "0.61068815", "0.6103074", "0.6001308", "0.599657", "0.59871733", "0.5893355", "0.5892805", "0.587362...
0.77009857
0
Reduce an iterable to a scalar if length is 1. Returns None if iterable is empty.
def reduce(values: Iterable) -> Union[Iterable, Any]: try: while isinstance(values, Iterable) and not isinstance(values, (Mapping, str)): values = list(values) if len(values) <= 1: values = values[0] else: break return values ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce(function, iterable, initializer=Missing):\n if initializer is Missing:\n accum_value = function() # 0 arity initializer.\n else:\n accum_value = initializer\n\n for x in iterable:\n accum_value = function(accum_value, x)\n if isinstance(accum_value, Reduced): # <-- h...
[ "0.63383085", "0.6197879", "0.60860777", "0.5876279", "0.58509356", "0.58509356", "0.58509356", "0.5823015", "0.58189374", "0.5805962", "0.5751366", "0.5744737", "0.5668511", "0.5642797", "0.56005114", "0.5599339", "0.55695194", "0.55695194", "0.5551931", "0.5545552", "0.5528...
0.6443263
0
Slice and unpack a nested iterable into a flat iterable containing a maximum of n elements.
def chunks(iterable: Iterable, n: int = 1000, cls: Type = list) -> Generator: it = iter(iterable) while True: chunked = itertools.islice(it, n) try: first_element = next(chunked) except StopIteration: return yield cls(itertools.chain((first_element,), chu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def take(n, iterable):\n return list(itertools.islice(iterable, n))", "def take(n, iterable):\n return list(itertools.islice(iterable, n))", "def take(n, iterable):\n return list(islice(iterable, n))", "def take(n, iterable):\n return list(islice(iterable, n))", "def grouper(n, iterable):\n ...
[ "0.70672953", "0.70672953", "0.69825137", "0.69825137", "0.69418126", "0.6925353", "0.6921387", "0.690624", "0.6850442", "0.6787696", "0.6782367", "0.67823285", "0.670789", "0.6668036", "0.66304344", "0.65792453", "0.65497494", "0.6538268", "0.65359235", "0.6516879", "0.64924...
0.63855106
27
Duplicate usernames are not permitted.
def test_duplicate_user(self): # print(User.get()) user1 = User(username="duplicate-user", email="unique@org.org") user1.save() user2 = User(username="duplicate-user", email="something-else@org.org") self.assertRaises(IntegrityError, user2.save) session.session.remove()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_registeration_duplicate_username(self):\n self.signup_a_user(self.user_data)\n response_duplicate = self.signup_a_user(\n self.user_data_duplicate_username)\n self.assertEqual(response_duplicate.status_code,\n status.HTTP_400_BAD_REQUEST)\n se...
[ "0.7104895", "0.68731886", "0.66954917", "0.66947454", "0.6651925", "0.6643407", "0.66182154", "0.6574557", "0.6574557", "0.6476506", "0.64084625", "0.64059085", "0.6369118", "0.6367755", "0.6357362", "0.6352171", "0.6340015", "0.6309582", "0.6291115", "0.62820756", "0.626474...
0.0
-1
Returns a random index from the set of argmax indices of an array (when there are ex aequo).
def custom_argmax(arr): return np.random.choice(np.flatnonzero(arr == arr.max()))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def random_argmax(x: np.ndarray) -> int:\n indices = all_argmax(x)\n return np.random.choice(indices)", "def argmax(values):\n\tvalues = np.array(values)\n\tmx = np.max(values)\n\tval = np.where(values==mx)[0]\n\treturn np.random.choice(val)", "def get_max_index(a):\n return a.argmax()", "def get_ma...
[ "0.85278744", "0.7938922", "0.747749", "0.747749", "0.747749", "0.68978614", "0.682284", "0.6623773", "0.6465227", "0.6430147", "0.6334985", "0.6288352", "0.626813", "0.6223054", "0.6169712", "0.6159231", "0.6145628", "0.6096323", "0.60825604", "0.60153943", "0.59732264", "...
0.82686186
1
Returns a random index from the set of argmin indices of an array (when there are ex aequo).
def custom_argmin(arr): return np.random.choice(np.flatnonzero(arr == arr.min()))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pickMinRandomly(a):\n listMin = []\n m = np.min(a)\n for i,e in enumerate(a):\n if e == m:\n listMin.append(i)\n \n #~ print(m)\n #~ listMin = np.where(a==m)[0]\n return listMin[random.randint(0,len(listMin)-1)]", "def argmin(self, array):\n minvalue = inf\n ...
[ "0.7109107", "0.6985956", "0.6169122", "0.6145225", "0.6119874", "0.6064569", "0.6048049", "0.60297704", "0.59857684", "0.5984071", "0.5900611", "0.5781599", "0.5779667", "0.57794595", "0.5773444", "0.5743256", "0.57411706", "0.57281977", "0.5697986", "0.56850857", "0.5679007...
0.82033235
0
Create dictionary to temporarily store experimental results.
def create_verbose_dico(review_strats_w_noreview, item_strategies): verbose_dico = {} for item_strat in item_strategies: verbose_dico[item_strat]={} for strat_name in review_strats_w_noreview.keys(): verbose_dico[item_strat][strat_name] = {} for param_value in review_stra...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cache(self):\n return {'output': self.output, 'series': self.series}", "def prepare_results(self) -> dict:\n if not hasattr(self, \"results\"):\n raise AttributeError(\n \"Results have not been finalized. Please call \"\n \"finalize_results() before savi...
[ "0.6475925", "0.6417913", "0.64021754", "0.60950375", "0.6080533", "0.6050422", "0.6013506", "0.6009287", "0.60046715", "0.600222", "0.60005474", "0.5991542", "0.5921354", "0.59183705", "0.5918287", "0.59086764", "0.58668864", "0.5866337", "0.5776814", "0.5755819", "0.5751951...
0.0
-1