query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Modify a context to allow startcase boolean representations. | def startcase_booleans(context_class):
context_class._convert_bool_to_str = _convert_to_str
return context_class | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lowercase_booleans(context_class):\n context_class._convert_bool_to_str = _convert_to_lowercase_str\n return context_class",
"def _set_bool(name, value, context):\n if name in os.environ:\n envval = os.environ.get(name).lower()\n if envval in [\"1\", \"true\", \"y\", \"yes\"]:\n ... | [
"0.708648",
"0.60394466",
"0.5391676",
"0.5367538",
"0.53071034",
"0.5305611",
"0.5247369",
"0.5187181",
"0.514308",
"0.5142465",
"0.5080693",
"0.50760305",
"0.50713897",
"0.5069089",
"0.50475407",
"0.5033341",
"0.50312597",
"0.5011229",
"0.5008267",
"0.49925774",
"0.49824417... | 0.78109324 | 0 |
gets kid value to be used in token header for this handler. it must be unique for each handler. | def get_kid(self):
return 'f825ccd5-9b4a-476f-ae12-c1c1ea99e6b2' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_kid_from_jwe_header(token: str) -> Optional[str]:\n import base64\n import json\n\n header = token.split(\".\")[0]\n deserialized_header = base64.urlsafe_b64decode(header + \"===\")\n jose_header = json.loads(deserialized_header)\n\n return jose_header.get(\"kid\")",
"def _get_kid(messa... | [
"0.70360565",
"0.66597205",
"0.57830864",
"0.5602095",
"0.5457416",
"0.5443089",
"0.53873295",
"0.5355741",
"0.53556186",
"0.5337027",
"0.532609",
"0.5317285",
"0.5314371",
"0.5287662",
"0.5271824",
"0.5269629",
"0.52666974",
"0.5262292",
"0.5250077",
"0.5250077",
"0.52417606... | 0.6909571 | 1 |
Analyze simulated random walks on BarabasiAlbert graphs. Modify input and output as needed. | def rwgraph_analyze1(input=(None)):
#generates graph
n=2000
m=4
G=nx.barabasi_albert_graph(n, m, seed=5)
Nt=100
M=20000
#finds max degree of graph and stores list of degrees of nodes
maxdeg=0
degree_dist=[]
for i in range(0,n):
degree_dist.append(G.degree[i])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run():\n\n # Set up environment and agent\n e = Environment() # create environment (also adds some dummy traffic)\n a = e.create_agent(LearningAgent) # create learning agent\n # a = e.create_agent(RandomAgent) # create random agent\n e.set_primary_agent(a, enforce_deadline=True) # set agent ... | [
"0.56036776",
"0.5418923",
"0.54050314",
"0.53924143",
"0.5367906",
"0.5306896",
"0.52951884",
"0.52781194",
"0.5248882",
"0.52286494",
"0.52176565",
"0.5212118",
"0.5211001",
"0.52091",
"0.5207191",
"0.51686174",
"0.51607203",
"0.51577896",
"0.5156206",
"0.5151868",
"0.51253... | 0.54888535 | 1 |
Compute RHS of modelA at time t | def RHS(y,t):
return np.multiply(A.dot(y),ones-y)-beta*y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model(self, t):\n return self.traits['A'] * np.sin(2 * np.pi * (t - self.traits['E']) / self.traits['P'])",
"def model(a, t, D, m):\n xprime = a[1] # x' = v\n vprime = -D*a[0]/m # v' = -D*x/m\n return [xprime, vprime]",
"def a(self, x, t0):\n dummy = 0.0 * t0\n x_1 = x[0]\n ... | [
"0.6416926",
"0.6258128",
"0.6244217",
"0.6219615",
"0.61625826",
"0.6149268",
"0.6111405",
"0.6107605",
"0.609902",
"0.60725325",
"0.6055627",
"0.6053448",
"0.6015801",
"0.6008567",
"0.6007099",
"0.59701043",
"0.5962164",
"0.593483",
"0.5931654",
"0.5921712",
"0.5919895",
... | 0.71157587 | 0 |
Analyze transport processes (model A, model B, linear diffusion) on BarabasiAlbert graphs. Modify input and output as needed. | def transport(input=(None)):
n=100
m=5
G=nx.barabasi_albert_graph(n, m, seed=5)
maxdeg=0
degree_dist=[]
for i in range(0,n):
degree_dist.append(G.degree[i])
if G.degree[i]>maxdeg:
maxdeg=G.degree[i]
j=i
tf,tfa,tfb=10,20,1000
Nt=10000
iarray=Li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bert_module_fn(is_training):\n\n input_ids = tf.compat.v1.placeholder(shape=[None, None], dtype=tf.int32, name=\"input_ids\")\n input_mask = tf.compat.v1.placeholder(shape=[None, None], dtype=tf.int32, name=\"input_mask\")\n token_type = tf.compat.v1.placeholder(shape=[None, None], dtype=t... | [
"0.56914574",
"0.5504473",
"0.5404608",
"0.52371424",
"0.5136819",
"0.50922596",
"0.5070473",
"0.4993317",
"0.49904677",
"0.49719086",
"0.49631143",
"0.49408865",
"0.49349648",
"0.49195486",
"0.48649365",
"0.48622385",
"0.48500225",
"0.48488343",
"0.4847742",
"0.48362046",
"0... | 0.71537685 | 0 |
used to count frequency of results in a list, returning dictionaary | def CountFrequency(my_list):
# Creating an empty dictionary
freq = {}
for item in my_list:
if (item in freq):
freq[item] += 1
else:
freq[item] = 1
return freq | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count(freq_list: list[str]) -> dict[str, int]:\n returned_dict: dict[str, int] = {}\n for item in freq_list:\n if item in returned_dict.keys():\n # increase the value associated with that key \n returned_dict[item] += 1\n else:\n # assign that key the value ... | [
"0.8195011",
"0.8185501",
"0.80188507",
"0.8011016",
"0.7753846",
"0.76451635",
"0.73659384",
"0.73326683",
"0.73188984",
"0.72865754",
"0.72838765",
"0.72762924",
"0.72522473",
"0.72518456",
"0.722965",
"0.72236264",
"0.72004676",
"0.71779644",
"0.71361697",
"0.71243215",
"0... | 0.8210879 | 0 |
Get the latest trades that have occured for a specific market. | def public_market_history(self, market_symbol):
return self.get(f'markets/{market_symbol}/trades') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_mytrades(self, symbol):\r\n param = {}\r\n param['symbol'] = self.__transfer_symbol(symbol)\r\n param['appid'] = self.apiKey\r\n param['nonce'] = int(time.time() * 1000)\r\n param['timestamp'] = int(time.time())\r\n return self.__signed_GET('/api/v1/history-order... | [
"0.65934575",
"0.64599925",
"0.6330147",
"0.6324947",
"0.630509",
"0.628073",
"0.6178016",
"0.6147427",
"0.60577464",
"0.60470587",
"0.60470587",
"0.59924877",
"0.59791535",
"0.597466",
"0.59554976",
"0.5939027",
"0.5874146",
"0.5853247",
"0.5833754",
"0.57954925",
"0.578244"... | 0.70258033 | 0 |
Get the balance from your account for a specific currency. | def account_balance(self, currency_symbol):
return self.get(f'balances/{currency_symbol}', auth=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_balance(self, currency=None):\n if currency:\n return self.__call__('balance', 'getbalance',\n {'currencyname': currency})\n return self.__call__('balance', 'getbalances')",
"def getBalance(self, currency=''):\n\n if self.app.getExchange() =... | [
"0.8360675",
"0.8266783",
"0.7911432",
"0.7850472",
"0.7594469",
"0.75444335",
"0.7526113",
"0.7363458",
"0.7354129",
"0.7344984",
"0.731404",
"0.72621316",
"0.7212807",
"0.71113855",
"0.7090096",
"0.708783",
"0.70214397",
"0.6956173",
"0.6894783",
"0.6855522",
"0.6837875",
... | 0.8442685 | 0 |
Construct and send a HTTP request to the Bittrex API. | def send_request(self, method, uri, values=None, headers=None, auth=False):
url = BittrexAutoTraderRequest.BASE_URL + '/' + uri
data = ''
if method == 'GET':
if values:
url += BittrexAutoTraderRequest._create_query_str(values)
else:
data = json.d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _request(http, project, method, data, base_url, client_info):\n user_agent = client_info.to_user_agent()\n headers = {\n \"Content-Type\": \"application/x-protobuf\",\n \"User-Agent\": user_agent,\n connection_module.CLIENT_INFO_HEADER: user_agent,\n }\n api_url = build_api_url... | [
"0.6721595",
"0.6096072",
"0.6095601",
"0.60827345",
"0.60781235",
"0.6015352",
"0.5985145",
"0.59460795",
"0.5938586",
"0.5925046",
"0.5918472",
"0.5911465",
"0.5895516",
"0.5888817",
"0.5880682",
"0.5820867",
"0.5807918",
"0.57948893",
"0.57811356",
"0.5774148",
"0.5771573"... | 0.6212627 | 1 |
Returns a query string of name/value pairs. | def _create_query_str(data):
params = []
for name, value in data.items():
params.append(name + '=' + str(value))
return '?' + '&'.join(params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_query_string(self):\n \n query_items = {}\n \n for key, val in self.__dict__.iteritems():\n if not key.startswith('_'):\n query_items[key] = val.encode('utf-8')\n \n return urllib.urlencode(query_items)",
"def get_query_string(self... | [
"0.6976844",
"0.67801315",
"0.6587585",
"0.6399101",
"0.63933206",
"0.6382786",
"0.6369876",
"0.6252732",
"0.6232739",
"0.6229379",
"0.62207365",
"0.620232",
"0.6188986",
"0.6145918",
"0.6139969",
"0.6119223",
"0.61142987",
"0.6113928",
"0.6108501",
"0.60919887",
"0.60715574"... | 0.7345456 | 0 |
Returns signed request using the HMAC SHA512 algorithm. | def _sign_request(secret, method, url, timestamp, content_hash=None):
message = f'{timestamp}{url}{method}{content_hash}'
return hmac.new(secret.encode('utf-8'), message.encode('utf-8'), hashlib.sha512).hexdigest() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign_hmac_sha1(client, request):\n base_string = generate_signature_base_string(request)\n return hmac_sha1_signature(\n base_string, client.client_secret, client.token_secret)",
"def HmacSha512(key: Union[bytes, str],\n data: Union[bytes, str]) -> bytes:\n return hmac.n... | [
"0.6270291",
"0.6157462",
"0.59586555",
"0.59178203",
"0.5838815",
"0.5823104",
"0.5810403",
"0.57807946",
"0.57741207",
"0.5754222",
"0.57061774",
"0.56298774",
"0.5580467",
"0.55793107",
"0.5564648",
"0.5523409",
"0.5509964",
"0.54881704",
"0.54717016",
"0.5429446",
"0.5428... | 0.6462081 | 0 |
Sort any lists in an IAM JSON policy so that comparison of two policies with identical values but different orders will return true | def sort_json_policy_dict(policy_dict):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_list_ikepolicy_sort(self):\r\n resources = \"ikepolicies\"\r\n cmd = ikepolicy.ListIKEPolicy(test_cli20.MyApp(sys.stdout), None)\r\n self._test_list_resources(resources, cmd,\r\n sort_key=[\"name\", \"id\"],\r\n sort_di... | [
"0.61905175",
"0.6146387",
"0.5959015",
"0.5510478",
"0.54657024",
"0.5459662",
"0.5401011",
"0.5387481",
"0.5371819",
"0.53341407",
"0.5314138",
"0.53106123",
"0.5293855",
"0.5270968",
"0.5247466",
"0.5171823",
"0.51387554",
"0.5132049",
"0.5127369",
"0.5119485",
"0.5113474"... | 0.79705065 | 0 |
Rainbow movie theater light style chaser animation. | def theaterChaseRainbow(strip, wait_ms=30):
for j in range(256):
for q in range(3):
for i in range(0, strip.numPixels(), 3):
strip.setPixelColor(i+q, wheel((i+j) % 255))
strip.show()
time.sleep(wait_ms/1000.0)
for i in range(0, strip.numPixels(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def theaterChaseRainbow(strip, wait_ms=50):\n\tfor j in range(256):\n\t\tfor q in range(3):\n\t\t\tfor i in range(0, strip.numPixels(), 3):\n\t\t\t\tstrip.setPixelColor(i+q, wheel((i+j) % 255))\n\t\t\tstrip.show()\n\t\t\ttime.sleep(wait_ms/1000.0)\n\t\t\tfor i in range(0, strip.numPixels(), 3):\n\t\t\t\tstrip.setP... | [
"0.76151276",
"0.7562134",
"0.73810625",
"0.7269356",
"0.70212775",
"0.6984534",
"0.6916089",
"0.68641406",
"0.68477833",
"0.68404734",
"0.68403065",
"0.6827585",
"0.68145055",
"0.6809809",
"0.67955655",
"0.6782512",
"0.6765697",
"0.66468316",
"0.6621634",
"0.65628374",
"0.65... | 0.7606191 | 1 |
List png frame files for a video. | def list_pngs(video_title: str) -> list:
path_to_pngs = os.path.join('frames', video_title)
files = os.listdir(path_to_pngs)
png_files = [f for f in files if os.path.splitext(f)[1] == '.png']
png_files = sorted(png_files, key=lambda s: int(s[5:-4]))
return png_files | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_video_frames(self):\r\n\r\n vid_dir = self._video_dir\r\n vid_frames = [str(img_path) for img_path in\r\n Path(vid_dir).glob('*.jpg')]\r\n if len(vid_frames) == 0:\r\n vid_frames = [str(img_path) for img_path in\r\n Path(vid_dir)... | [
"0.74903274",
"0.71694463",
"0.69626606",
"0.68849015",
"0.68159395",
"0.6740354",
"0.6646834",
"0.6427418",
"0.63983107",
"0.63968563",
"0.6384971",
"0.63526756",
"0.6332228",
"0.6303974",
"0.62948906",
"0.6294262",
"0.6242945",
"0.6242945",
"0.6237558",
"0.6229151",
"0.6218... | 0.7672686 | 0 |
Test that update_blocks creates 10 blocks | def test_update_blocks(path_last_block, path_get_blocks_iterator, mocked_logger):
# Method to test
created_id = BlockchainEthService.update_blocks()
assert Block.objects.count() == 10
assert len(created_id) == 10
mocked_logger.info.assert_called_once_with("10 new blocks created.") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_block_batches_order(self):\n pass",
"def test_update_library_blocks(self):\n def commit_library_and_verify(library_key):\n \"\"\"\n Commit library changes, and verify that there are no uncommited changes anymore\n \"\"\"\n last_published = Conten... | [
"0.6776867",
"0.67313904",
"0.6672238",
"0.66562814",
"0.6521418",
"0.6519071",
"0.65140855",
"0.65059924",
"0.6473834",
"0.63975424",
"0.6349964",
"0.6346332",
"0.6339556",
"0.62601537",
"0.61715144",
"0.6147653",
"0.613493",
"0.60646725",
"0.6061347",
"0.60496294",
"0.60469... | 0.77074355 | 0 |
bind all controls with facade | def bind_controls(self):
self.add_comment_button.Bind(wx.EVT_BUTTON, self.add_comment)
self.del_comment_button.Bind(wx.EVT_BUTTON, self.remove_comment)
self.upload_button.Bind(wx.EVT_BUTTON, self.upload_change)
self.Bind(wx.EVT_CLOSE, self.on_close) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _bind(self):\n\n pass",
"def bind(self):\n super(QtBaseWidgetComponent, self).bind()",
"def bindControlMenu(self):\r\n self.frames[\"ControlMenu\"].unitBut.configure(\r\n command=self.changeUnits)\r\n self.frames[\"ControlMenu\"].bind(\r\n self.controlKeys[... | [
"0.6240202",
"0.6223124",
"0.6148494",
"0.6035581",
"0.59745187",
"0.586234",
"0.5814697",
"0.5779209",
"0.5718157",
"0.569714",
"0.5687127",
"0.56239295",
"0.5562846",
"0.55018246",
"0.5459139",
"0.54509723",
"0.5446135",
"0.5402932",
"0.5399839",
"0.537862",
"0.5360238",
... | 0.66183096 | 0 |
Evaluate the population with respect to input data X and expected output. | def _evaluate(self, X, Y):
# evaluate all networks
#
# evaluations = torch.zeros(self.population_size, device=self.device)
evaluations = torch.zeros(self.population_size, device=self.device)
for i in range(self.population_size):
selected_pheno = self.population[i].cp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(self, X):\n\n raise NotImplementedError(\"not implemented!\")",
"def evaluate(self, X):\n\n\t\tpass",
"def evaluate(self, dataset):\n return self.model.evaluate(dataset.X_val, dataset.y_val)",
"def evaluate(population, context=None):\n for individual in population:\n indi... | [
"0.7122433",
"0.68909365",
"0.65685827",
"0.6454497",
"0.6450034",
"0.64358103",
"0.63450545",
"0.63008964",
"0.62551874",
"0.6255135",
"0.6235048",
"0.62307996",
"0.61885816",
"0.61829305",
"0.61514705",
"0.6123133",
"0.61000067",
"0.6092697",
"0.6065284",
"0.6055261",
"0.60... | 0.71402115 | 0 |
given a list of evaluation scores, selects best_rate percentage of individuals by applying one of selection methods passed as parameter | def _selection(self, evaluations, selection, method="truncated", best_rate=0.2):
if selection:
end_range_for_parents = max(1, int(self.population_size * best_rate))
evaluations_sorted = torch.sort(evaluations)
population_sorted = self.population[evaluations_sorted[1]]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def best_percentile_selector(train_features, test_features, train_similarity_target, test_similarity_target, regressor):\n\tpercentile_score = 0\n\tpercentiles = [25, 35, 45, 50, 55, 65, 75]\n\t# percentiles = [45]\n\tpercentile_selector = None\n\tpercentile_train_features_selected = None\n\tpercentile_test_featur... | [
"0.626115",
"0.6206762",
"0.6100408",
"0.6076012",
"0.6060828",
"0.60530967",
"0.6026658",
"0.59901446",
"0.5987794",
"0.5902537",
"0.5900069",
"0.5790178",
"0.5772556",
"0.5743284",
"0.5731502",
"0.5718924",
"0.5696296",
"0.56870556",
"0.5678375",
"0.56745076",
"0.56602734",... | 0.7054224 | 0 |
given best population applies crossover with given probability, method and parents number | def _crossover(self, best_population, crossover, n_parents=2, method="uniform_swap"):
if crossover:
# randomly select parents
parents_indexes = torch.randint(0, len(best_population), (self.population_size, n_parents),
device=self.device)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def selection(self,parents,popSize):\n for i in range(popSize):\n idx1 = np.random.randint(0,popSize)\n idx2 = np.random.randint(0,popSize)\n if parents.individuals[idx1].violationSum < parents.individuals[idx2].violationSum:\n self.individuals[i] = parents.in... | [
"0.67263",
"0.67171764",
"0.66393787",
"0.6588233",
"0.65817004",
"0.6564607",
"0.6547238",
"0.65291065",
"0.6482871",
"0.6474727",
"0.64088905",
"0.6387641",
"0.6386324",
"0.6346811",
"0.63191617",
"0.63031244",
"0.6301391",
"0.6278659",
"0.6244412",
"0.6227246",
"0.62252873... | 0.7517525 | 0 |
Returns a dict of reasonable random parameters that can be used to do parameter search. | def random_parameters():
res = dict()
res["population_size"] = random.randrange(2, 21)
res["mutation_prob"] = random.choice([0.02, 0.05, 0.10, 0.20, 0.30, 0.40, 0.50])
res["crossover"] = random.choice([True, False])
res["selection"] = random.choice([True, False])
res["sig... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_params(self, randomize=True):\n pass",
"def set_rand_params(self) -> Dict:\n new_params: Dict = self.gen_params()\n self.set_params(new_params)\n return new_params",
"def random():\n pars = dict(\n scale=10**np.random.uniform(1, 3),\n gamma=np.random.un... | [
"0.70701885",
"0.706165",
"0.7013774",
"0.6762008",
"0.6735659",
"0.6637217",
"0.6519411",
"0.6440548",
"0.63888425",
"0.6324186",
"0.63205343",
"0.63086057",
"0.62929904",
"0.6286846",
"0.6242564",
"0.6231981",
"0.6220546",
"0.6217865",
"0.6199372",
"0.61903065",
"0.6187879"... | 0.8022944 | 0 |
This function takes two equal sized sets and returns a set of tupples. Each tuple is made out of the one element of each two starting sets. >>> male={'mgerbil1','mgerbil2','mgerbil3','mgerbil4','mgerbil5'} >>> female={'fgerbil1','fgerbil2','fgerbil3','fgerbil4','fgerbil5'} >>> mating_pairs(male, female) {('mgerbil2', '... | def mating_pairs(male: set, female: set) -> Compoundset:
set_of_pairs=set()
found =True
while found:
if len(male)>0 and len(female)>0:
malegerbil=male.pop()
femalegerbil=female.pop()
pairs=(malegerbil,femalegerbil)
set_of_pairs.add(pairs)
else... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def friend_pairs_and_other_friends(friend_tuple): \n x=friend_tuple[0]\n y=friend_tuple[1]\n def auxfun(w):\n return (frozenset({x,w}),y)\n return list(map(auxfun,y))#returns [({x,y[0]},y),...]",
"def create_pairs(listA, listB):\n\n pairs = []\n labels = []\n for i in range(0,len(list... | [
"0.62168926",
"0.5791811",
"0.57299113",
"0.5724014",
"0.56990707",
"0.56952417",
"0.56083345",
"0.55963457",
"0.55837464",
"0.54992604",
"0.5494936",
"0.54810447",
"0.54719776",
"0.5393596",
"0.5345833",
"0.5294748",
"0.5250942",
"0.5230622",
"0.5226189",
"0.51821125",
"0.51... | 0.78777766 | 0 |
This method will update attributes of the model passed by kwargs. | def update(self, **kwargs):
print("Updating model")
print(kwargs)
for key in kwargs:
setattr(self, key, kwargs[key]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, model, **kwargs):\n self._isinstance(model)\n for k, v in self._preprocess_params(kwargs).items():\n setattr(model, k, v)\n self.save(model)\n return model",
"def update(self, datastore, model, **kwargs):\n for k, v in self._preprocess_params(kwargs)... | [
"0.8240944",
"0.80810755",
"0.7585011",
"0.7517154",
"0.748801",
"0.7450906",
"0.7448534",
"0.7121363",
"0.71153945",
"0.71095514",
"0.7042544",
"0.7042544",
"0.7035119",
"0.70347744",
"0.70154786",
"0.6976838",
"0.69683146",
"0.69545335",
"0.6943849",
"0.6943849",
"0.6943849... | 0.8798378 | 0 |
Extracts features from chunk, concatenates feature_train (onpower_train, offpower_train and duration_train) with new features and retrains feature models. Updates stats attribute. | def train_on_chunk(self, chunk, meter):
# EXTRACT FEATURES:
# find units:
self.__setattr__('units', chunk.columns[0])
# Loading treshold for getting events:
thDelta = getattr(self, 'thDelta')
chunk.index.name = 'date_time'
# To prevent learning many samples at the... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(self, metergroup):\n # Inizialise stats and training data:\n self.stats = []\n self.onpower_train = pd.DataFrame(columns=['onpower'])\n self.offpower_train = pd.DataFrame(columns=['offpower'])\n self.duration_train = pd.DataFrame(columns=['duration'])\n\n # Calli... | [
"0.5968119",
"0.5825508",
"0.5797949",
"0.57781553",
"0.57452273",
"0.56985676",
"0.5671647",
"0.56669515",
"0.56569123",
"0.56368",
"0.56169164",
"0.56151366",
"0.56011236",
"0.55730826",
"0.5531826",
"0.55290115",
"0.54975414",
"0.5486447",
"0.5474995",
"0.5474167",
"0.5437... | 0.64443403 | 0 |
Passes each chunk from mains generator to disaggregate_chunk() and passes the output to _write_disaggregated_chunk_to_datastore() Will have a default implementation in super class. Can be overridden for more simple inmemory disaggregation, or more complex outofcore disaggregation. | def disaggregate(self, mains, output_datastore):
building_path = '/building{}'.format(mains.building())
# only writes one appliance and meter per building
meter_instance = 2
mains_data_location = '{}/elec/meter1'.format(building_path)
#dis_main = pd.DataFrame()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disaggregate_chunk(self, test_mains):\n raise NotImplementedError()",
"def in_memory_rechunk(\n inputs: List[Tuple[core.ChunkKey, xarray.Dataset]],\n target_chunks: Mapping[str, int],\n) -> Iterator[Tuple[core.ChunkKey, xarray.Dataset]]:\n key, dataset = consolidate_chunks(inputs)\n yield from... | [
"0.66142166",
"0.5519045",
"0.5402537",
"0.5224618",
"0.5013061",
"0.5001216",
"0.49794587",
"0.49451426",
"0.49277872",
"0.49046662",
"0.49005345",
"0.48834217",
"0.4878524",
"0.48638603",
"0.4815047",
"0.4813966",
"0.47849753",
"0.47823474",
"0.4755759",
"0.47323096",
"0.47... | 0.7225137 | 0 |
Checks units. Disaggregates "chunk" with MaximumLikelihood algorithm. | def disaggregate_chunk(self, chunk):
# An resistive element has active power equal to apparent power.
# Checking power units.
units = self.__physical_quantity(chunk)
# EVENTS OUT OF THE CHUNK:
# Delta values:
column_name = 'diff_' + units[1]
chunk[column_name] =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def consume_units(self, units):\n pass",
"def consume_units_unconditionally(self, units):\n pass",
"def try_consume_units(self, units):\n pass",
"def disaggregate_chunk(self, test_mains):\n raise NotImplementedError()",
"def test_process_chunk_trimmed(self):\n foo = None\... | [
"0.5595163",
"0.55166554",
"0.5493909",
"0.54604405",
"0.5417519",
"0.53858703",
"0.5327096",
"0.52271676",
"0.52093446",
"0.52073175",
"0.5189472",
"0.518666",
"0.51688814",
"0.5151618",
"0.51342285",
"0.5129267",
"0.50638485",
"0.5045443",
"0.5035866",
"0.5003558",
"0.49689... | 0.5635728 | 0 |
Crops feature_train(onpower_train, offpower_train and duration_train) to get same samples from different appliances(same modelappliance) and avoids overfittings to a many samples appliance. Updates stats attribute. Does the retraining. | def no_overfitting(self):
# Instance with minimun length should be the maximum length
train_len = []
[train_len.append(st['Nevents']) for st in self.stats]
train_len = np.array(train_len)
max_len = train_len[train_len != 0].min()
# CROPS FEATURE SAMPLES
onpower_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __train__(self):\n if (self.type_camf == 'CAMF_CI'):\n #users, items, context, ratings\n ci = camf_ci.CI_class(self.__users_array__, self.__items_array__, self.__context_array__, self.__ratings__, self.fold, self.lr, self.factors)\n predictions, losses = ci.fit()\n ... | [
"0.6257319",
"0.6156836",
"0.6149533",
"0.61292195",
"0.6066113",
"0.60474396",
"0.5980389",
"0.59172255",
"0.58837765",
"0.58806056",
"0.5880044",
"0.5877682",
"0.58746827",
"0.587393",
"0.58707666",
"0.5865389",
"0.5858618",
"0.5855791",
"0.58530575",
"0.58465743",
"0.58410... | 0.7580361 | 0 |
Cheks integrity of feature model distributions. CDF has to be bounded by one. | def check_cdfIntegrity(self, step):
# Selecting bins automatically:
x_max = self.onpower_train.max().values[0]
x_min = 0
step = 1
x_onpower = np.arange(x_min, x_max, step).reshape(-1, 1)
x_max = 0
x_min = self.offpower_train.min().values[0]
step = 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def part1c_0():\n xs = exampleInput\n T = submission.computeEdgeMarginals(simpleCRF, xs)\n for t in T:\n grader.requireIsEqual( 1.0, sum(t.values()) )",
"def initialize_cdesf(self) -> None:\n self.nyquist = self.check_point_cases * 2\n # initialize PMG\n self.process_model_gr... | [
"0.55498654",
"0.52209383",
"0.51860523",
"0.5153627",
"0.5109204",
"0.51061743",
"0.504352",
"0.5028017",
"0.49969104",
"0.4995817",
"0.49739793",
"0.49615988",
"0.49461237",
"0.49342352",
"0.48906568",
"0.4873443",
"0.48696098",
"0.48662293",
"0.48627234",
"0.48428598",
"0.... | 0.5273454 | 1 |
Request File Path from user input import data to employees.csv | def emp_import():
while True:
try:
file_path = input("Enter the path of your file or enter 'quit' to go back to menu.\n File Path: ")
except FileNotFoundError:
print("File Not Found Error.")
continue
if file_path == "quit":
return
elif not os.path.exists(file_path) and not os.path.isfile(file_path)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_input_file():\n\n filename = input('Input the file name to save data to: ') + '.csv'\n return filename",
"def file_from_user():\n try:\n file = get_input(\"Please enter name of the file to get data from. For exit press 0: \")\n if file == \"0\":\n sys.exit()\n Lo... | [
"0.671666",
"0.6316371",
"0.62783736",
"0.6256375",
"0.6097976",
"0.6014507",
"0.6010938",
"0.5962907",
"0.5962493",
"0.5878151",
"0.58474374",
"0.58217865",
"0.581936",
"0.5810715",
"0.57662374",
"0.5760681",
"0.5747308",
"0.5692834",
"0.5593718",
"0.55768937",
"0.5554444",
... | 0.6647591 | 1 |
Request File Path from user input and Removes listed data from employees.csv | def path_delete_emp():
while True:
try:
file_path = input("Enter the path of your file or enter 'quit' to go back to menu.\n File Path: ")
except FileNotFoundError:
print("File Not Found Error.")
continue
if file_path == "quit":
return
elif not os.path.exists(file_path) and not os.path.isfile(file_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emp_import():\n\twhile True:\n\t\ttry:\n\t\t\tfile_path = input(\"Enter the path of your file or enter 'quit' to go back to menu.\\n File Path: \")\n\t\texcept FileNotFoundError:\n\t\t\tprint(\"File Not Found Error.\")\n\t\t\tcontinue\n\t\tif file_path == \"quit\":\n\t\t\treturn\n\t\telif not os.path.exists(fi... | [
"0.66964155",
"0.597888",
"0.5884179",
"0.58648145",
"0.57086045",
"0.57040673",
"0.55802935",
"0.5552325",
"0.55478776",
"0.54975176",
"0.5481775",
"0.54157984",
"0.5387137",
"0.5362531",
"0.5275203",
"0.52694577",
"0.5268417",
"0.5261648",
"0.52415246",
"0.5194671",
"0.5168... | 0.77248025 | 0 |
Separate out positive and negative attributes in the dataframe with attributes. Outputs two separated dataframes | def separate_pos_neg(attribution):
attribution_pos_val = attribution*(attribution >= 0)
attribution_neg_val = attribution*~(attribution >= 0)
return attribution_pos_val, attribution_neg_val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_negative_data(self):\n negative_df = pd.DataFrame(columns=HeatStrokeDataFiller.important_features, index=np.arange(self.num_negative))\n for field in negative_df.columns:\n parameter_distribution = HeatStrokeDataFiller.negative_default[field]\n negative_df[field].loc[:] ... | [
"0.6133841",
"0.5794669",
"0.57934856",
"0.567667",
"0.5615256",
"0.55364317",
"0.5506884",
"0.54435396",
"0.5381989",
"0.5325307",
"0.53219056",
"0.5312544",
"0.5293739",
"0.5288366",
"0.52574766",
"0.5235385",
"0.51943",
"0.5193476",
"0.51709604",
"0.51699626",
"0.51690656"... | 0.58671474 | 1 |
Make a url for download. This will call safe_url_string and then strip the fragment, if one exists. The path will be normalised. If the path is outside the document root, it will be changed to be within the document root. | def safe_download_url(url, encoding='utf8', path_encoding='utf8'):
safe_url = safe_url_string(url, encoding, path_encoding)
scheme, netloc, path, query, _ = urlsplit(safe_url)
if path:
path = _parent_dirs.sub('', posixpath.normpath(path))
if safe_url.endswith('/') and not path.endswith('/'):... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _convert_file_to_url(filename, no_file_check = False):\n if no_file_check: # We already a priori know that the path is\n # correct and in its final form.\n return filename\n relpath = os.path.relpath(filename, settings.SENDFILE_ROOT)\n\n url = [settings.SENDFILE_URL]\n\n ... | [
"0.6344203",
"0.6195235",
"0.6166916",
"0.60148406",
"0.60115445",
"0.59931517",
"0.5974618",
"0.596129",
"0.5951785",
"0.594464",
"0.5894027",
"0.587222",
"0.5842856",
"0.57147574",
"0.55796796",
"0.5578619",
"0.55382127",
"0.55297405",
"0.5521063",
"0.5509687",
"0.5499138",... | 0.65303683 | 0 |
Clean URL arguments leaving only those passed in the parameterlist keeping order >>> import w3lib.url >>> w3lib.url.url_query_cleaner("product.html?id=200&foo=bar&name=wired", ('id',)) 'product.html?id=200' >>> w3lib.url.url_query_cleaner("product.html?id=200&foo=bar&name=wired", ['id', 'name']) 'product.html?id=200&na... | def url_query_cleaner(url, parameterlist=(), sep='&', kvsep='=', remove=False, unique=True, keep_fragments=False):
if isinstance(parameterlist, (six.text_type, bytes)):
parameterlist = [parameterlist]
url, fragment = urldefrag(url)
base, _, query = url.partition('?')
seen = set()
querylist ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_remove_with_multiple_removes(self):\n rendered_result = self._render_tag(\n tag='{% querystring \"remove\" \"foo\" \"bar\" \"baz=1\" %}',\n query_str='foo=foo&bar=bar&foo=&baz=1&qux=qux')\n\n self.assertTrue(rendered_result.startswith('?'))\n self.assertEqual(Que... | [
"0.60887784",
"0.59742236",
"0.586768",
"0.5849657",
"0.5837156",
"0.57429856",
"0.5674179",
"0.56159896",
"0.55954355",
"0.5503327",
"0.54211736",
"0.5406335",
"0.5371822",
"0.53556895",
"0.5342783",
"0.5247226",
"0.52447885",
"0.5231707",
"0.5206317",
"0.5175111",
"0.514468... | 0.80487144 | 0 |
Add or remove a parameter to a given url >>> import w3lib.url | def add_or_replace_parameter(url, name, new_value):
return _add_or_replace_parameters(url, {name: new_value}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_query_parameter(url, param_name, param_value):\n scheme, netloc, path, query_string, fragment = urlsplit(url)\n query_params = parse_qs(query_string)\n\n deleted = False\n for _, value in query_params.items():\n if param_value in value:\n deleted = True\n\n if deleted:\n ... | [
"0.6787713",
"0.6758425",
"0.67240405",
"0.6605619",
"0.64564407",
"0.639294",
"0.63426834",
"0.6334928",
"0.63221145",
"0.62897855",
"0.6280858",
"0.6114451",
"0.6068753",
"0.60241115",
"0.6005309",
"0.5964446",
"0.5886868",
"0.588532",
"0.5874374",
"0.5850072",
"0.5789708",... | 0.73892564 | 0 |
Add or remove a parameters to a given url >>> import w3lib.url | def add_or_replace_parameters(url, new_parameters):
return _add_or_replace_parameters(url, new_parameters) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _extend_url(self, url, params):\n # filter out None parameters\n params = {k:v for k,v in params.items() if v is not None}\n for key in params:\n url = url + \"&{}={}\".format(key, params[key])\n return url",
"def add_or_replace_parameter(url, name, new_value):\n ret... | [
"0.7262166",
"0.6983453",
"0.6931309",
"0.6851787",
"0.670423",
"0.6686313",
"0.6619075",
"0.66121083",
"0.6594955",
"0.655649",
"0.6538528",
"0.6431628",
"0.64223516",
"0.6336409",
"0.6336409",
"0.63182306",
"0.63001937",
"0.62852514",
"0.62325287",
"0.62116474",
"0.6195118"... | 0.70467913 | 1 |
If given a path name, return its File URI, otherwise return it unmodified | def any_to_uri(uri_or_path):
if os.path.splitdrive(uri_or_path)[0]:
return path_to_file_uri(uri_or_path)
u = urlparse(uri_or_path)
return uri_or_path if u.scheme else path_to_file_uri(uri_or_path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_file_uri(path):\n p = urlparse.urlparse(path)\n\n if p.scheme in [\"https\", \"http\"]:\n return True, path\n elif p.scheme == \"file\":\n # url to path name, i.e: convert %20 to space\n path = urllib.url2pathname(p.path)\n return False, os.path.abspath(os.path.join(p... | [
"0.67616785",
"0.643403",
"0.64174753",
"0.62495047",
"0.6189978",
"0.6108651",
"0.6086867",
"0.60460186",
"0.60352784",
"0.59979",
"0.5986743",
"0.5967465",
"0.59603",
"0.59325385",
"0.5932342",
"0.59256554",
"0.5908476",
"0.58884764",
"0.58875656",
"0.58660144",
"0.58607817... | 0.7083271 | 0 |
Checks value is a positive integer, returns True if so, else raise error. | def check_positive(value):
try:
ivalue = int(value)
if ivalue <= 0:
# is int but non-positive
raise argparse.ArgumentTypeError(
'{} is an invalid positive integer value'.format(value))
return ivalue
except ValueError:
# not int
rais... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_positive_int(item):\n if not isinstance(item, int):\n return False\n return item > 0",
"def _is_non_negative_int(item):\n if not isinstance(item, int):\n return False\n return item >= 0",
"def check_positive(value):\n ivalue = int(value)\n if ivalue <= 0:\n raise ... | [
"0.80366474",
"0.79576945",
"0.7938288",
"0.79097056",
"0.7845891",
"0.7826583",
"0.76731074",
"0.76619655",
"0.75931734",
"0.758719",
"0.74770504",
"0.74770504",
"0.7437898",
"0.74136573",
"0.74024177",
"0.73540705",
"0.73346096",
"0.73321503",
"0.72591674",
"0.7258475",
"0.... | 0.7988756 | 1 |
Counts how many kmers exists in a given file | def count_kmers(file_name, k, verbose=False):
if verbose:
start = time.time()
print('Counting kmers in {}'.format(file_name))
total_kmers = 0
with open(file_name, 'r') as f:
line_num = 0
for line in f:
if line_num % 4 == 1: # dna sequence
total_km... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_counts(filename, alphabet, kmin, kmax):\n # get the list of kmers to count with length between kmin and kmax\n kmers_list = get_all_possible_kmers(alphabet, kmin, kmax)\n # initialyze the counter with all possible kmer with length\n # between kmin and kmax with zero counts\n counter = Counte... | [
"0.73698807",
"0.69172156",
"0.6849723",
"0.6753836",
"0.6691487",
"0.66859126",
"0.6676495",
"0.6538376",
"0.6530189",
"0.6526704",
"0.646393",
"0.6354559",
"0.62536365",
"0.6241987",
"0.620828",
"0.61729515",
"0.6157252",
"0.6145035",
"0.6124907",
"0.61203504",
"0.6100982",... | 0.78231025 | 0 |
Implementation of DSK, kmer counting with very low memory algorithm Hashes each kmer and puts them into different files according to their hash values. By using target disk and memory spaces, determines how many distinct files should be used and in how many iterations the program needs to perform. | def dsk(file_name, k, n, capacity, error_rate, iters, parts, verbose=False):
if verbose:
start = time.time()
# Assign functions to local variables for performance improvement
hash_function = mmh3.hash
heap_pushpop = heapq.heappushpop
CHUNK_LIMIT = math.floor(capacity / 10) # write approxi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bf_counter(file_name, k, n, capacity, error_rate, verbose=False):\n if verbose:\n start = time.time()\n print('BFCounter started.')\n\n heap = []\n for i in range(n):\n heap.append((0, ''))\n\n bf = BloomFilter(capacity, error_rate, 'kmer_bf')\n\n kmer_counter = defaultdict(... | [
"0.59754854",
"0.5919573",
"0.57606095",
"0.5759139",
"0.5740336",
"0.56900924",
"0.5643245",
"0.562379",
"0.5617651",
"0.5582634",
"0.55727494",
"0.5527192",
"0.5526655",
"0.55222845",
"0.54942554",
"0.54903567",
"0.54834044",
"0.5477402",
"0.54609895",
"0.54141855",
"0.5397... | 0.7018501 | 0 |
Implementation of Bloom Filter kmer Counting algorithm Creates a Bloom Filter and check the kmer is previously encountered or not. Only previously encountered kmers are added to the Hash Table, which drastically reduced the size of the Hash Table. | def bf_counter(file_name, k, n, capacity, error_rate, verbose=False):
if verbose:
start = time.time()
print('BFCounter started.')
heap = []
for i in range(n):
heap.append((0, ''))
bf = BloomFilter(capacity, error_rate, 'kmer_bf')
kmer_counter = defaultdict(lambda: 1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, n, m, k=2):\n # expecting to hold n elements\n self.n = n\n if m%4: m += (4-m%4)\n self.m = m*8\n print \"bit map size set to %d (%d bytes)after round up to 32bits\"%(self.m, self.m/8)\n self.bm = BitVector(size=self.m, intVal=0)\n if k in BloomFilter.KRange:\n self.k =... | [
"0.61989313",
"0.5929431",
"0.561827",
"0.56155145",
"0.5550853",
"0.5537526",
"0.55260515",
"0.5457855",
"0.5456327",
"0.54321456",
"0.54122543",
"0.53974813",
"0.5378987",
"0.53754586",
"0.5350419",
"0.53478485",
"0.53310055",
"0.5256477",
"0.5185556",
"0.51369804",
"0.5129... | 0.6309868 | 0 |
Test the DefaultDialogues class. | def test_default_dialogues(self):
_, dialogue = self.default_dialogues.create(
counterparty=COUNTERPARTY_AGENT_ADDRESS,
performative=DefaultMessage.Performative.BYTES,
content=b"some_content",
)
assert dialogue.role == DefaultDialogue.Role.AGENT
assert... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_default(self, dm):\n request = create_request(\"other\", \"other\")\n result = await dm.apply_handler(request, create_responder(request))\n assert result.dialogue_state == \"default\"",
"def test_default(self):\r\n self.assertEqual(self.option.default, 'testing')",
"d... | [
"0.6822309",
"0.6626286",
"0.660622",
"0.6486287",
"0.6461427",
"0.64539313",
"0.6384414",
"0.6358669",
"0.627209",
"0.62540084",
"0.6202093",
"0.619923",
"0.6177934",
"0.6042947",
"0.60372436",
"0.6017006",
"0.5988623",
"0.5987767",
"0.596759",
"0.5953054",
"0.5951422",
"0... | 0.8006611 | 0 |
Test the OefSearchDialogues class. | def test_oef_search_dialogues(self):
_, dialogue = self.oef_search_dialogues.create(
counterparty=COUNTERPARTY_AGENT_ADDRESS,
performative=OefSearchMessage.Performative.SEARCH_SERVICES,
query="some_query",
)
assert dialogue.role == OefSearchDialogue.Role.AGENT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_search(self):\n pass",
"def test_search(self):\n pass",
"def test_search(self):\n pass",
"def test_search_4(self):\n\n # search for \"cheese\"\n form = FrontSearchForm()\n form.search_box.set_value('cheese')\n form.submit.click()\n\n # check th... | [
"0.75819606",
"0.75819606",
"0.75819606",
"0.70504874",
"0.69273454",
"0.6920223",
"0.68934745",
"0.67331684",
"0.6732177",
"0.6622524",
"0.6607059",
"0.6467548",
"0.64579827",
"0.64343286",
"0.6417334",
"0.64078",
"0.63583404",
"0.6355816",
"0.6352986",
"0.62550294",
"0.6225... | 0.78425246 | 0 |
Test the TacDialogues class. | def test_tac_dialogues(self):
_, dialogue = self.tac_dialogues.create(
counterparty=COUNTERPARTY_AGENT_ADDRESS,
performative=TacMessage.Performative.REGISTER,
agent_name="some_agent_name",
)
assert dialogue.role == TacDialogue.Role.CONTROLLER
assert di... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_win(self):\n self.T.board[0] = ['x']*3\n assert self.T.tic_tac_toe(self.T.board)",
"def test_play_game(self):\r\n\r\n \r\n a_players = [RandomPlayer(1), RandomPlayer(2)]\r\n a_x_dist = 3\r\n a_y_dist = 3\r\n a_num_to_win = 1\r\n a_game = Game(a_players, a_x_dist, a_y_dist... | [
"0.7204975",
"0.639281",
"0.63556343",
"0.62928545",
"0.62355614",
"0.6217936",
"0.61023337",
"0.6055885",
"0.59701693",
"0.5949051",
"0.5938375",
"0.59304994",
"0.59215665",
"0.58301795",
"0.5829346",
"0.58051157",
"0.5797176",
"0.578909",
"0.5774417",
"0.57690454",
"0.57510... | 0.7255627 | 0 |
Checks if a is valid point. Points are tuples with two elements wich are integer coordinates | def is_point(a):
return isinstance(a, tuple) and isinstance(a[0], int) and isinstance(a[1], int) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate_point(self, value):\n if not isinstance(value, (list, tuple)):\n return \"Points must be a list of coordinate pairs\"\n elif not len(value) == 2:\n return \"Value (%s) must be a two-dimensional point\" % repr(value)\n elif not isinstance(value[0], (float, in... | [
"0.78360605",
"0.77310133",
"0.75255525",
"0.66908485",
"0.6647603",
"0.66428196",
"0.66331434",
"0.66331434",
"0.6566558",
"0.6560455",
"0.6509387",
"0.64592165",
"0.6357859",
"0.6274078",
"0.62555736",
"0.6234108",
"0.61824715",
"0.61678946",
"0.6166192",
"0.61394876",
"0.6... | 0.84881026 | 0 |
Return distance betwen a and b. | def distance(a, b):
ax, ay = a
bx, by = b
dx = bx - ax
dy = by - ay
return (abs(dx) + abs(dy) + abs(dx - dy)) / 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_distance(a, b):\n return np.sqrt(np.sum((a - b) ** 2))",
"def dist(a, b):\n return math.sqrt(pow(a[0] - b[0], 2) + pow(a[1] - b[1], 2))",
"def distance(a, b):\n return (np.sum((a - b)**2))**0.5",
"def distance(self, a, b):\n raise NotImplementedError()",
"def distance(self, a, ... | [
"0.84512717",
"0.8359271",
"0.82396984",
"0.8216251",
"0.82030517",
"0.82030517",
"0.81532663",
"0.8082506",
"0.8056524",
"0.80535",
"0.80527997",
"0.8037395",
"0.80054075",
"0.7997625",
"0.7989338",
"0.7966094",
"0.7966094",
"0.79631495",
"0.79503185",
"0.78624356",
"0.78066... | 0.8451247 | 1 |
Checks if a and b are in given distance d | def in_distance(a, b, d):
return distance(a, b) <= d | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(self, a, b):\n if not (a in self and b in self):\n raise RuntimeError(\n \"Can only compute distance for values within \"\n \"the space, not {} and {}.\".format(a, b)\n )\n return 1 if a != b else 0",
"def dwithin(a, b, distance, **kw... | [
"0.7185901",
"0.7166674",
"0.6720538",
"0.6656798",
"0.6656798",
"0.6601606",
"0.6598739",
"0.65757394",
"0.65753025",
"0.65734214",
"0.65687853",
"0.6567245",
"0.6496106",
"0.6494706",
"0.6463152",
"0.6428333",
"0.64235395",
"0.64084",
"0.63912725",
"0.63847333",
"0.63520175... | 0.88950545 | 0 |
Calculates how many points lies in circle in d distance | def num_points_in_circle(d):
return 6 * d if d > 0 else 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_points_in_distance(d):\n return 1 + 3 * d * (d + 1)",
"def points_in_distance(c, d):\n points = set()\n for i in range(0, d + 1):\n points = points | points_in_circle(c, i)\n return points",
"def getCircleDiameter(self):\n segments = []\n for (i, p1) in enumerate(self.p... | [
"0.82408607",
"0.7174484",
"0.68130255",
"0.65756804",
"0.6550924",
"0.6432983",
"0.63694406",
"0.62871903",
"0.6249227",
"0.620468",
"0.62038755",
"0.6202209",
"0.6198283",
"0.6193179",
"0.6191535",
"0.6151975",
"0.6101965",
"0.60924065",
"0.6084547",
"0.6073051",
"0.6063643... | 0.8592174 | 0 |
Calculates how many points lies in given distance | def num_points_in_distance(d):
return 1 + 3 * d * (d + 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_points_in_circle(d):\n return 6 * d if d > 0 else 1",
"def length(self):\n points = [Point(v, crs=self.crs) for v in self.vertices]\n distances = [a.distance(b) for a, b in zip(points[:-1], points[1:])]\n return sum(distances)",
"def __get_distance(point1: np.ndarray, point2: np... | [
"0.6829636",
"0.67380637",
"0.6653657",
"0.65781885",
"0.64964586",
"0.64594823",
"0.6406789",
"0.63200027",
"0.6301598",
"0.62999535",
"0.6289167",
"0.6283409",
"0.6279848",
"0.6279096",
"0.6256218",
"0.6254257",
"0.6254257",
"0.62347174",
"0.622541",
"0.6223266",
"0.6196775... | 0.8255963 | 0 |
Return a modelled PSF for the given model | def model_psf(self):
return self.model()(self._XGrid, self._YGrid) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_SF_model(model_type):\n if model_type == \"BiLSTM\":\n return keras.models.load_model(SF_BiLSTM_model_path)\n elif model_type == \"MLP\":\n SF_model = SF_module().to(DEVICE)\n SF_model.load_state_dict(torch.load(SF_MLP_model_path))\n return SF_model",
"def get_model():\n... | [
"0.70333433",
"0.6461371",
"0.63930553",
"0.62396306",
"0.6135629",
"0.6135161",
"0.610893",
"0.6049868",
"0.6015454",
"0.59949577",
"0.5974333",
"0.5963697",
"0.5957364",
"0.59512144",
"0.59200984",
"0.5866675",
"0.5854476",
"0.5829802",
"0.57794815",
"0.57694125",
"0.575904... | 0.673051 | 1 |
Extract the FWHM from the model of the star. The FWHM needs to be calculated for each model. For the Moffat, the FWHM is a function of the gamma and alpha parameters (in other words, the scaling factor and the exponent of the expression), while for a Gaussian FWHM = 2.3548 sigma. Unfortunately, our case is a 2D Gaussia... | def fwhm(self):
model_dict = dict(zip(self.model().param_names, self.model().parameters))
if self.model_type == self._MOFFAT2D:
gamma, alpha = [model_dict[ii] for ii in ("gamma_0", "alpha_0")]
FWHM = 2.0 * gamma * np.sqrt(2 ** (1 / alpha) - 1)
FWHM_x, FWHM_y = None, N... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_psf_fwhm_inpix_gaussian(arr):\n\tmodel = fit_gaussian(arr)\n\n\tsigma = max(model.y_stddev, model.x_stddev)\n\tfwhm = 2.355 * sigma\n\n\treturn fwhm",
"def FWHM(self):\n # The width of the Lorentz profile\n fl = 2.0 * self[\"al\"]\n # Width of the Gaussian [2.35 = 2*sigma*sqrt(2*ln(... | [
"0.7319097",
"0.71567017",
"0.7058549",
"0.70203537",
"0.6777484",
"0.67330366",
"0.65833426",
"0.6531526",
"0.651764",
"0.6465564",
"0.6410498",
"0.63757175",
"0.63664764",
"0.6298521",
"0.6227312",
"0.62063545",
"0.6195452",
"0.6123725",
"0.6082363",
"0.60621554",
"0.603068... | 0.7796027 | 0 |
Initialize a model with first guesses for the parameters. The user can select between several astropy models, e.g., 'Gaussian2D', 'Moffat2D'. We will use the data to get the first estimates of the parameters of each model. Finally, a Constant2D model is added to account for the background or sky level around the star. | def _initialize_model(self):
max_value = self.data.max()
if self.model_type == self._GAUSSIAN2D:
model = models.Gaussian2D(
x_mean=self.x, y_mean=self.y, x_stddev=1, y_stddev=1
)
model.amplitude = max_value
# Establish reasonable bounds f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_model(self):\n # n_dims == n_hparams\n n_dims = len(self.searchspace.keys())\n\n if self.interim_results:\n n_dims += 1 # add one dim for augumented budget\n\n cov_amplitude = ConstantKernel(1.0, (0.01, 1000.0))\n\n other_kernel = Matern(\n length_... | [
"0.6551731",
"0.6463214",
"0.6463214",
"0.635312",
"0.6221765",
"0.6221027",
"0.6211802",
"0.6145611",
"0.61099744",
"0.6089215",
"0.60518026",
"0.6050148",
"0.60214335",
"0.6004301",
"0.6001939",
"0.5985846",
"0.59553504",
"0.5951064",
"0.5933379",
"0.5914137",
"0.590727",
... | 0.75738263 | 0 |
Fit the sky using a Ring2D model in which all parameters but the amplitude are fixed. | def fit_sky(self):
min_value = self.data.min()
ring_model = models.Ring2D(
min_value, self.x, self.y, self._box * 0.4, width=self._box * 0.4
)
ring_model.r_in.fixed = True
ring_model.width.fixed = True
ring_model.x_0.fixed = True
ring_model.y_0.fixed =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_linear_fit_2d_model_set_fixed_parameters(self):\n init_model = models.Polynomial2D(\n degree=2,\n c1_0=[1, 2],\n c0_1=[-0.5, 1],\n n_models=2,\n fixed={\"c1_0\": True, \"c0_1\": True},\n )\n\n x, y = np.mgrid[0:5, 0:5]\n zz... | [
"0.6069153",
"0.6029275",
"0.59248644",
"0.5835233",
"0.5779711",
"0.56909484",
"0.5657765",
"0.56360203",
"0.55903643",
"0.5554314",
"0.553601",
"0.55332834",
"0.5531295",
"0.55231124",
"0.5509397",
"0.5460297",
"0.5444665",
"0.5421841",
"0.5399147",
"0.5375256",
"0.5364925"... | 0.7843751 | 0 |
Creates a dynamic environment given a json_path to an environment file, using property_name as the initial node to start reading, validating against a json schema file if given any | def set_env_from_json_file(json_path, property_name=None, schema_path=None):
if schema_path: # if schema_path is provided
with open(schema_path, 'r') as schema_file:
json_schema = json.load(schema_file)
else:
json_schema = None
with open(json_path, 'r') as data:
if pro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_env_from_json(json_object, json_schema=None):\n if json_schema:\n validate(json_object, json_schema)\n\n environment = json_object\n\n # Prepend the command \"source\" to each one of the commands defined in the\n # command_prefixes property of the json file.\n prefixes = environment.p... | [
"0.62821966",
"0.6093502",
"0.58737135",
"0.57207036",
"0.56639695",
"0.55425805",
"0.54886854",
"0.54484504",
"0.5266997",
"0.5259031",
"0.5169255",
"0.5167175",
"0.51394403",
"0.51284474",
"0.5121911",
"0.51147294",
"0.5093304",
"0.5088686",
"0.508787",
"0.5087083",
"0.5083... | 0.790252 | 0 |
Creates a dynamic environment based on the contents of the given json_object and validates againts a json_schema object if given any. If 'command_prefixes' is available it adds it to the environment prepending 'source' to the given paths. fabfile.py from fabric.api import task from fabutils.env import set_env_from_json | def set_env_from_json(json_object, json_schema=None):
if json_schema:
validate(json_object, json_schema)
environment = json_object
# Prepend the command "source" to each one of the commands defined in the
# command_prefixes property of the json file.
prefixes = environment.pop('command_pre... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_env_from_json_file(json_path, property_name=None, schema_path=None):\n if schema_path: # if schema_path is provided\n with open(schema_path, 'r') as schema_file:\n json_schema = json.load(schema_file)\n else:\n json_schema = None\n\n with open(json_path, 'r') as data:\n\n... | [
"0.5949223",
"0.55071974",
"0.50784063",
"0.5027287",
"0.48285085",
"0.4828165",
"0.48247337",
"0.4818228",
"0.47885552",
"0.47781834",
"0.46954954",
"0.46735176",
"0.46518135",
"0.46491793",
"0.46348986",
"0.4574233",
"0.45632145",
"0.45630446",
"0.45593148",
"0.45418176",
"... | 0.82398796 | 0 |
The POST on `/institution` should create an institution | def test_create(self, mock_decorator):
response = self.client.post(
'/api/bce_institutions/0802145Y',
content_type='application/json',
headers={'Authorization': 'Bearer token'},
data=json.dumps({
'is_institution': True
}))
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(uai, is_institution=True):\n institution = BceInstitution(\n uai=uai,\n is_institution=is_institution)\n\n return institution.save()",
"def test_perform_create(self):\n\n response = self.client.post(reverse('action-list'), data=self.data)\n self.assert... | [
"0.6681688",
"0.6539136",
"0.64875925",
"0.6482373",
"0.6411193",
"0.6297357",
"0.59500855",
"0.58625144",
"0.578303",
"0.5740273",
"0.56996286",
"0.56490153",
"0.5545814",
"0.55356705",
"0.549819",
"0.5479565",
"0.54430705",
"0.5442307",
"0.54372895",
"0.54182273",
"0.538496... | 0.6618002 | 1 |
The PUT on `/institution` should update an institution's status if it is updated from False to True | def test_update_true(self, mock_decorator):
BceInstitutionRepository.create(
uai='0802145Z', is_institution=False)
response = self.client.put(
'/api/bce_institutions/0802145Z',
content_type='application/json',
headers={'Authorization': 'Bearer token'},
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_false_success(self, mock_decorator, mock_request):\n BceInstitutionRepository.create(\n uai='0802145Z', is_institution=True)\n headers = {'Authorization': 'Bearer token'}\n response = self.client.put(\n '/api/bce_institutions/0802145Z',\n conten... | [
"0.68200177",
"0.6680396",
"0.65138537",
"0.58143884",
"0.57722396",
"0.569369",
"0.55494267",
"0.55452234",
"0.5404221",
"0.5379043",
"0.5347192",
"0.53412354",
"0.5306662",
"0.52892303",
"0.528411",
"0.5245017",
"0.5228866",
"0.52209485",
"0.52191067",
"0.52098113",
"0.5202... | 0.7161717 | 0 |
Overwrite the network's weights with a specified list of tensors or change weights along directions with a step size. | def set_weights(net, weights, directions=None, step=None):
if directions is None:
# You cannot specify a step length without a direction.
for (p, w) in zip(net.parameters(), weights):
p.data.copy_(w.type(type(p.data)))
else:
assert step is not None, 'If a direction is specifi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_weights(self, weights):\n tuples = []\n for layer in self.layers:\n num_param = len(layer.weights)\n layer_weights = weights[:num_param]\n for sw, w in zip(layer.weights, layer_weights):\n tuples.append((sw, w))\n weights = weights[num_param:]\n K.batch_set_value(tuples)... | [
"0.70630175",
"0.67701286",
"0.6765941",
"0.6713401",
"0.6688865",
"0.6647569",
"0.66165936",
"0.65347296",
"0.6495384",
"0.6468586",
"0.6456321",
"0.63830173",
"0.63485736",
"0.63249886",
"0.6295442",
"0.62903076",
"0.62822104",
"0.62651116",
"0.62480175",
"0.62394434",
"0.6... | 0.71305776 | 0 |
Overwrite the network's state_dict or change it along directions with a step size. | def set_states(net, states, directions=None, step=None):
if directions is None:
net.load_state_dict(states)
else:
assert step is not None, 'If direction is provided then the step must be specified as well'
if len(directions) == 2:
dx = directions[0]
dy = direction... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateSimState(self):\n self.sim_state = {k: v for k,v in self.state.iteritems()}",
"def setStepSize(self, step_size):\n assert isinstance(step_size, int)\n self.step_size = step_size\n self.step_directions = [np.array([i[0], i[1]]) for i in [(0,0),\n ... | [
"0.62555414",
"0.5988356",
"0.59602517",
"0.58462554",
"0.5836205",
"0.57758117",
"0.5772188",
"0.5750633",
"0.5728731",
"0.57174855",
"0.5712029",
"0.5693783",
"0.5693783",
"0.56853724",
"0.5677654",
"0.56629467",
"0.56623954",
"0.56580573",
"0.5647897",
"0.5638729",
"0.5623... | 0.6162025 | 1 |
Produce a direction from 'weights' to 'weights2'. | def get_diff_weights(weights, weights2):
return [w2 - w for (w, w2) in zip(weights, weights2)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_target_direction(net, net2, dir_type='states'):\n\n assert (net2 is not None)\n # direction between net2 and net\n if dir_type == 'weights':\n w = get_weights(net)\n w2 = get_weights(net2)\n direction = get_diff_weights(w, w2)\n elif dir_type == 'states':\n s = ne... | [
"0.607518",
"0.6047125",
"0.60434145",
"0.5932767",
"0.5829164",
"0.5781955",
"0.57382554",
"0.5580101",
"0.55623007",
"0.5560823",
"0.5552634",
"0.5545572",
"0.5509103",
"0.54875374",
"0.54456526",
"0.5415965",
"0.54091614",
"0.53876656",
"0.5335502",
"0.52996564",
"0.529960... | 0.63707787 | 0 |
Rescale the direction so that it has similar norm as their corresponding model in different levels. | def normalize_direction(direction, weights, norm='filter'):
if norm == 'filter':
# Rescale the filters (weights in group) in 'direction' so that each
# filter has the same norm as its corresponding filter in 'weights'.
for d, w in zip(direction, weights):
d.mul_(w.norm()/(d.norm(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def norm(self):\r\n old_origin = np.array(self.origin)\r\n self.origin = [0, 0, 0]\r\n old_origin[0] = old_origin[0] / self.x[0]\r\n old_origin[1] = old_origin[1] / self.y[1]\r\n old_origin[2] = old_origin[2] / self.z[2]\r\n self.data = ndimage.shift(self.data, -old_origin... | [
"0.6777673",
"0.66808975",
"0.65217906",
"0.64889526",
"0.6374746",
"0.6235027",
"0.6218624",
"0.61755383",
"0.61742705",
"0.61604995",
"0.61592346",
"0.61486703",
"0.61451757",
"0.61233693",
"0.61096954",
"0.6099822",
"0.60399234",
"0.6030842",
"0.60131377",
"0.60000825",
"0... | 0.69959813 | 0 |
Setup the h5 file to store the directions. | def setup_direction(args, dir_file, net):
print('-------------------------------------------------------------------')
print('setup_direction')
print('-------------------------------------------------------------------')
# Setup env for preventing lock on h5py file for newer h5py versions
os.en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup(self):\n print(\"Looking for \", self.filename)\n if os.path.exists(self.filename):\n n, ext = os.path.splitext(self.filename)[:2]\n if ext == \".h5\" or ext == \".hdf5\":\n with h5py.File(self.filename, \"r\") as file:\n keys = list(f... | [
"0.66554785",
"0.5904285",
"0.58772445",
"0.5786827",
"0.57170254",
"0.5689569",
"0.56485534",
"0.56033355",
"0.5592535",
"0.55645245",
"0.5550623",
"0.5537372",
"0.55245066",
"0.552284",
"0.54868084",
"0.545466",
"0.5440785",
"0.5435956",
"0.541684",
"0.5396151",
"0.5393677"... | 0.6418381 | 1 |
Name the direction file that stores the random directions. | def name_direction_file(args):
if args.dir_file:
assert exists(args.dir_file), "%s does not exist!" % args.dir_file
return args.dir_file
dir_file = ""
file1, file2, file3 = args.model_file, args.model_file2, args.model_file3
# name for xdirection
if file2:
# 1D linear int... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_file_name(name: types.TSeedName) -> str:\n return f\"{name}.yml\"",
"def filename(self):\n translator = {ord(\" \"): \"_\", ord(\",\"): None}\n return f'{self._full_name.translate(translator)}.txt'",
"def generate_name():\n return random.choice(ADJECTIVES) + \"_\" + random.choi... | [
"0.60667473",
"0.60138476",
"0.59846383",
"0.59264207",
"0.5895491",
"0.5847575",
"0.5836146",
"0.58264697",
"0.58220315",
"0.57896686",
"0.5780307",
"0.57518154",
"0.57518154",
"0.57246995",
"0.57121605",
"0.5672118",
"0.5657772",
"0.56308764",
"0.56201655",
"0.56112003",
"0... | 0.64361393 | 0 |
Load direction(s) from the direction file. | def load_directions(dir_file):
f = h5py.File(dir_file, 'r')
if 'ydirection' in f.keys(): # If this is a 2D plot
xdirection = h5_util.read_list(f, 'xdirection')
ydirection = h5_util.read_list(f, 'ydirection')
directions = [xdirection, ydirection]
else:
directions = [h5_util.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_directions(dir_file):\n\n xdirection = h5_util.read_list(f, 'xdirection')\n ydirection = h5_util.read_list(f, 'ydirection')\n directions = [xdirection, ydirection]\n\n return directions",
"def load_full(self):\n\t\tfor filename in self.FILENAMES:\n\t\t\tself.load(filename)\n\t\tself.reverse_... | [
"0.73147833",
"0.5536552",
"0.55358",
"0.53545064",
"0.5216563",
"0.51911306",
"0.51911306",
"0.5178756",
"0.51715374",
"0.51498336",
"0.5132414",
"0.51317346",
"0.5125808",
"0.5114883",
"0.51074964",
"0.5095933",
"0.5092058",
"0.50822014",
"0.5078533",
"0.50670224",
"0.50472... | 0.67186105 | 1 |
Simulates the game compute_func takes a board and a list of legal moves s and returns a move | def start(compute_func):
board = gen_board()
turn = 1
while True:
print("\nTurn:", turn)
print_board(board)
lm = legal_moves(board)
print("Legal: ", *[DIRECTIONS[i] for i in lm])
chosen_move = compute_func(board,lm)
print("Chosen: " + DIRECTIONS[chosen_move... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def computer_move(board,move,player):\r\n com_execution(board, move, player)",
"def mm_move(board, player):\n moves = []\n results = []\n best_score = None\n best_move = None\n \n opponet = op_player(player)\n \n if board.check_win() != None:\n \n if board.check_win() == ... | [
"0.6738075",
"0.6715203",
"0.6689361",
"0.66600084",
"0.6643982",
"0.65430266",
"0.64409846",
"0.64409846",
"0.64409846",
"0.64378023",
"0.643162",
"0.6431567",
"0.63864464",
"0.63557446",
"0.6352269",
"0.6314513",
"0.6314211",
"0.6296794",
"0.629567",
"0.62893003",
"0.628532... | 0.6749187 | 0 |
Set an instance attribute indicating the device's pairing status | def _get_pairing_status(self):
try:
self.is_paired = is_paired(ignore_errors=False)
except BackendDown:
LOG.error('Cannot complete device updates due to backend issues.')
self.backend_down = True
if self.is_paired:
LOG.info('Device is paired') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_device_attributes_on_backend(self):\n if self.is_paired:\n LOG.info('Sending updated device attributes to the backend...')\n try:\n api = DeviceApi()\n api.update_version()\n except Exception:\n self._notify_backend_do... | [
"0.5751612",
"0.56873393",
"0.56726533",
"0.56146926",
"0.5601535",
"0.5590141",
"0.54604495",
"0.5445805",
"0.54274327",
"0.5426972",
"0.5362671",
"0.5336365",
"0.53292793",
"0.53007454",
"0.5300508",
"0.52943027",
"0.5283178",
"0.5253588",
"0.5251245",
"0.52454257",
"0.5233... | 0.64097786 | 0 |
Force a sync of the local clock with the Network Time Protocol. The NTP sync is only forced on Raspberry Pi based devices. The assumption being that these devices are only running Mycroft services. We don't want to sync the time on a Linux desktop device, for example, because it could have a negative impact on other so... | def _update_system_clock(self):
if self.platform in RASPBERRY_PI_PLATFORMS:
LOG.info('Updating the system clock via NTP...')
if self.is_paired:
# Only display time sync message when paired because the prompt
# to go to home.mycroft.ai will be displayed by ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateRTCFromNTP(strip, start = False):\r\n wifi = connectToWifi(strip, start)\r\n try:\r\n ntptime.settime()\r\n except OSError:\r\n for i in range(0, 3):\r\n ledFlash(strip, LED_COLOR_RED, 0.5)\r\n print(\"Can not connect to NTP server\")\r\n machine.reset()\r\... | [
"0.72237253",
"0.6886432",
"0.66464496",
"0.6514424",
"0.65060776",
"0.6419905",
"0.6269265",
"0.62354267",
"0.6102252",
"0.60891914",
"0.60587496",
"0.5958736",
"0.5929074",
"0.59208417",
"0.5900496",
"0.58931005",
"0.5816147",
"0.5742855",
"0.57249767",
"0.57112616",
"0.570... | 0.7669739 | 0 |
Indicate to the user that skills are being loaded. | def _display_skill_loading_notification(self):
self.enclosure.eyes_color(189, 183, 107) # dark khaki
self.enclosure.mouth_text(dialog.get("message_loading.skills")) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadallskills(self):\r\n for skill in os.listdir( os.path.join( es.getAddonPath( info.basename ), \"skills\" )):\r\n es.load(\"%s/skills/%s\" % (info.basename, skill))",
"def required_skills(self, required_skills):\n\n self._required_skills = required_skills",
"def load_skill_list(... | [
"0.6233247",
"0.6201158",
"0.6122491",
"0.60886675",
"0.60022455",
"0.5993554",
"0.59113675",
"0.58863217",
"0.5861418",
"0.57072824",
"0.561377",
"0.55963355",
"0.5585389",
"0.5585389",
"0.5572549",
"0.55570704",
"0.5554645",
"0.5545811",
"0.5543801",
"0.5529301",
"0.5514039... | 0.68717 | 0 |
Determine if device is paired, if not automatically start pairing. Pairing cannot be performed if there is no connection to the back end. So skip pairing if the backend is down. | def _ensure_device_is_paired(self):
if not self.is_paired and not self.backend_down:
LOG.info('Device not paired, invoking the pairing skill')
payload = dict(utterances=["pair my device"], lang="en-us")
self.bus.emit(Message("recognizer_loop:utterance", payload)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_pairing_status(self):\n try:\n self.is_paired = is_paired(ignore_errors=False)\n except BackendDown:\n LOG.error('Cannot complete device updates due to backend issues.')\n self.backend_down = True\n\n if self.is_paired:\n LOG.info('Device is... | [
"0.8065884",
"0.7769401",
"0.77569914",
"0.7557578",
"0.74007684",
"0.6839915",
"0.6752682",
"0.6557243",
"0.62115335",
"0.6207546",
"0.6190262",
"0.61526656",
"0.61224526",
"0.6051847",
"0.6030277",
"0.59858686",
"0.5979463",
"0.5896",
"0.58188164",
"0.5776929",
"0.57743293"... | 0.8198503 | 0 |
Initialize trainable variables randomly or from the given checkpoint. | def _initialize_variables(self, finetune: str=None, **kwargs) -> None:
if finetune is None:
super()._initialize_variables(**kwargs) # default initialization
else:
self._saver = tf.train.Saver(max_to_keep=100000000)
logging.info('Restoring variables from `%s`', finetu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resnet_init_from_checkpoint_fn(checkpoint):\n logging.info('Initializing model weights from %s', checkpoint)\n assignment_map = {}\n resnet_scope = _get_resnet_scope()\n for var in contrib_framework.get_variables(\n scope=resnet_scope, collection=tf.GraphKeys.TRAINABLE_VARIABLES):\n if 'dense' not ... | [
"0.7199187",
"0.68767375",
"0.68545914",
"0.67681926",
"0.67573655",
"0.67527646",
"0.67527646",
"0.67527646",
"0.67527646",
"0.67527646",
"0.6746362",
"0.67407686",
"0.66633236",
"0.6610265",
"0.66059613",
"0.6599223",
"0.6592673",
"0.6522299",
"0.6428225",
"0.6428225",
"0.6... | 0.6975668 | 1 |
Write Elasticluster configuration file with user and security information. | def _write_elasticluster_config(config, out_file):
orig_file = os.path.join(sys.prefix, "share", "bcbio-vm", "elasticluster", "config")
if not os.path.exists(os.path.dirname(out_file)):
os.makedirs(os.path.dirname(out_file))
if os.path.exists(out_file):
bak_file = out_file + ".bak%s" % datet... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_config(self, filename=None):\n if filename is None:\n filename = f\"{self._nginx_path}/conf/nginx.conf\"\n self.dump_config(self._nodeconfig)\n cmd = f\"echo \\\"{self._nginx_config}\\\" | sudo tee {filename}\"\n exec_cmd_no_error(\n self._node, cmd, mess... | [
"0.62820524",
"0.62570614",
"0.62143034",
"0.62114924",
"0.6193832",
"0.6069943",
"0.599572",
"0.5991819",
"0.5979662",
"0.5961469",
"0.5899129",
"0.5884886",
"0.5874607",
"0.5871666",
"0.58647877",
"0.5844628",
"0.58071727",
"0.57967025",
"0.57941467",
"0.5790304",
"0.578512... | 0.66994685 | 0 |
Create a bcbio keypair and import to ec2. Gives us access to keypair locally and at AWS. | def create_keypair(econfig_file=None, region=None, keyname="bcbio"):
import boto
import boto.ec2
if econfig_file:
keypair_dir = os.path.dirname(econfig_file).replace("elasticluster", "aws_keypairs")
else:
keypair_dir = os.path.join(os.getcwd(), "aws_keypairs")
if not os.path.exists(k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_keypair(ec2):\n # call the boto ec2 function to create a key pair\n key_pair = ec2.create_key_pair(KeyName=KEY_PAIR_NAME)\n print(\"\\n===Created a new key pair in AWS.\")\n\n # capture the key and store it in a file\n KeyPairOut = str(key_pair.key_material)\n\n # create a file to store t... | [
"0.73303676",
"0.6833116",
"0.6639188",
"0.65754193",
"0.6572603",
"0.6434263",
"0.6376655",
"0.6371478",
"0.62773746",
"0.62645876",
"0.6253658",
"0.6243391",
"0.62319267",
"0.61779505",
"0.616518",
"0.61117303",
"0.60635716",
"0.602635",
"0.5972846",
"0.595534",
"0.5942674"... | 0.7892392 | 0 |
Create a bcbio IAM user account with full access permissions. | def _bcbio_iam_user(conn, args):
import boto
name = "bcbio"
access_key_name = "full_admin_access"
if args.nocreate:
need_creds = False
else:
try:
conn.get_user(name)
if args.recreate:
keys = conn.get_all_access_keys(name)
for ac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_account(self, user):\n tx = self.iroha.transaction(\n [\n self.iroha.command(\n \"CreateAccount\",\n account_name=user.gov_id,\n domain_id=\"afyamkononi\",\n public_key=user.public_key,\n ... | [
"0.64758754",
"0.6371347",
"0.62785226",
"0.62672675",
"0.6244346",
"0.61853546",
"0.6175834",
"0.61129385",
"0.6081883",
"0.6014631",
"0.59924346",
"0.5924464",
"0.58846915",
"0.58055896",
"0.57954687",
"0.5793468",
"0.5780767",
"0.57705027",
"0.57041115",
"0.5681222",
"0.56... | 0.75444907 | 0 |
Create an IAM instance profile with temporary S3 access to be applied to launched machines. | def bcbio_s3_instance_profile(conn, args):
import boto
if hasattr(args, "nocreate") and args.nocreate:
return {"instance_profile": ""}
base_name = args.cluster if hasattr(args, "cluster") and args.cluster else "bcbio"
name = "%s_full_s3_access" % (base_name)
try:
ip = conn.get_instan... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(profile, name):\n client = boto3client.get(\"iam\", profile)\n params = {}\n params[\"InstanceProfileName\"] = name\n return client.create_instance_profile(**params)",
"def test_instance_profile_exists(self) -> None:\n self.assertTrue(self.validate_instance_profile('s3-access-role',... | [
"0.7128096",
"0.60106343",
"0.59777516",
"0.5973521",
"0.594296",
"0.5929832",
"0.57960683",
"0.5742524",
"0.57358336",
"0.57317406",
"0.5709242",
"0.5685809",
"0.5625889",
"0.5614665",
"0.5586729",
"0.55047476",
"0.54935837",
"0.54734963",
"0.54473054",
"0.54275876",
"0.5404... | 0.72730076 | 0 |
Parse the parsers in the given list one after another, then expect the end of the input. | def whole(parsers):
if len(parsers) == 0:
return finished >> (lambda x: [])
if len(parsers) == 1:
return parsers[0] + finished >> (lambda x: x[:-1])
return reduce(add, parsers) + skip(finished) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def at_end():\n def run(chunk, last):\n if chunk:\n return ParserResult.from_done(False, chunk, last)\n elif last:\n return ParserResult.from_done(True, chunk, last)\n else:\n return ParserResult.from_partial(Parser(run))\n return Parser(run)",
"def tes... | [
"0.5791424",
"0.5646095",
"0.5645046",
"0.5396733",
"0.5381657",
"0.53701615",
"0.5365384",
"0.53398365",
"0.52898455",
"0.5230443",
"0.5213715",
"0.5188441",
"0.51719886",
"0.5169891",
"0.51469034",
"0.514417",
"0.5139918",
"0.51322347",
"0.5127973",
"0.5121833",
"0.5117573"... | 0.70667577 | 0 |
Parse any object other than a HyExpression beginning with a HySymbol equal to one of the disallowed_heads. | def notpexpr(*disallowed_heads):
return some(lambda x: not (
isinstance(x, HyExpression) and
x and
isinstance(x[0], HySymbol) and
x[0] in disallowed_heads)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_othersymbol(line):\n return None",
"def test_missing_single_token(self):\n self.helper_test_evaluate_raises(\n 'A or (B and (C and not D))',\n expected_exc_type=MissingSymbolError,\n A=0,\n B=1,\n D=1)",
"def test_single_extra_toke... | [
"0.5053372",
"0.5052113",
"0.50418425",
"0.49850217",
"0.49680007",
"0.48462263",
"0.4817602",
"0.48168248",
"0.48086628",
"0.46729738",
"0.4664141",
"0.46620685",
"0.46346858",
"0.46272382",
"0.46187416",
"0.46145827",
"0.46143615",
"0.460878",
"0.46011806",
"0.45874092",
"0... | 0.6480621 | 0 |
Parse `parser` several times (`lo` to `hi`) in a row. `hi` can be float('inf'). The result is a list no matter the number of instances. | def times(lo, hi, parser):
@Parser
def f(tokens, s):
result = []
for _ in range(lo):
(v, s) = parser.run(tokens, s)
result.append(v)
end = s.max
try:
for _ in (repeat(1) if isinf(hi) else range(hi - lo)):
(v, s) = parser.run(tok... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_multi(choice, end=None):\n end = end or str(g.model.size)\n pattern = r'(?<![-\\d])(\\d+-\\d+|-\\d+|\\d+-|\\d+)(?![-\\d])'\n items = re.findall(pattern, choice)\n alltracks = []\n\n for x in items:\n\n if x.startswith(\"-\"):\n x = \"1\" + x\n\n elif x.endswith(\"... | [
"0.4880365",
"0.47404096",
"0.47179648",
"0.470378",
"0.46360415",
"0.46103963",
"0.4609697",
"0.45963877",
"0.45378098",
"0.45185974",
"0.45155594",
"0.4511633",
"0.45087922",
"0.4464779",
"0.4458345",
"0.44525602",
"0.44323313",
"0.4415435",
"0.44136307",
"0.43991777",
"0.4... | 0.72359776 | 0 |
Matches the given parser and produces a named tuple `(Tag tag value)` with `tag` set to the given tag name and `value` set to the parser's value. | def tag(tag_name, parser):
return parser >> (lambda x: Tag(tag_name, x)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_reference(self, name_tag):\n top_level_parse_re = re.compile(\"^(.+):(.+)$\")\n\n results = top_level_parse_re.match(name_tag)\n if results:\n return(results.group(1), results.group(2))\n else:\n return (None,None)",
"def parse_value(named_reg_value):\n... | [
"0.5538646",
"0.553688",
"0.55304265",
"0.5503507",
"0.5379562",
"0.52458453",
"0.5207461",
"0.5187187",
"0.5185535",
"0.5160518",
"0.5132922",
"0.5025835",
"0.5006027",
"0.5005376",
"0.49659863",
"0.49604243",
"0.49449548",
"0.49418393",
"0.4910231",
"0.48585212",
"0.4828294... | 0.6260766 | 0 |
Read last build timestamp from the log file | def last_build_processed_timestamp(log_file):
# Get last build processed timestamp
last_timestamp = 0
with open(log_file, "r") as process_file:
if os.path.getsize(process_file.name) > 0:
last_timestamp = process_file.readline().strip()
return last_timestamp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_last_build_processed_timestamp(log_file):\n with open(log_file, \"w\") as process_file:\n process_file.write(str(time.time()))",
"def GetBuildDate(build_filename):\n try:\n with open(build_filename) as f:\n return float(f.readline())\n except (IOError, ValueError):\n return 0.0",
... | [
"0.71376187",
"0.6779207",
"0.6755526",
"0.6730641",
"0.6637661",
"0.6348121",
"0.6277634",
"0.6233516",
"0.6186471",
"0.61769265",
"0.6168673",
"0.61549896",
"0.6153312",
"0.6153262",
"0.61097366",
"0.6045366",
"0.60451233",
"0.6036591",
"0.5966002",
"0.5964683",
"0.5945673"... | 0.8103804 | 0 |
Generates plots for all videos in a directory | def generate_plots(path):
videos = glob(path + '/*.mkv')
print(path, len(videos), videos)
if len(videos) == 0:
return
else:
videos = videos[0]
metadata_list = glob(path + '/metadata.txt')
#print(path, len(metadata_list), metadata_list)
if len(metadata_list) == 0:
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def video_files():\n p = parse_cmdline(get_parser=get_parser_files)\n log.setup_main_handler(\n mods=(\"fogtools\", \"typhon\", \"fogpy\", \"sattools\", \"fcitools\", \"satpy\",\n \"pyresample\"),\n level=logging.INFO)\n vis.show_video_abi_glm(\n files=p.files,\n ... | [
"0.6731108",
"0.65034777",
"0.6334065",
"0.6266662",
"0.6246572",
"0.6235564",
"0.62117976",
"0.61683494",
"0.6158867",
"0.6102118",
"0.6092265",
"0.6078301",
"0.606834",
"0.5971214",
"0.5945981",
"0.59456533",
"0.5926945",
"0.5920736",
"0.5918344",
"0.58989173",
"0.5894912",... | 0.74448717 | 0 |
Create `nb_existing` + `nb_new` lines in the transmittal. | def create_lines(self, nb_existing=1, nb_new=1, **kwargs):
doc = DocumentFactory(
metadata_factory_class=ContractorDeliverableFactory,
revision_factory_class=ContractorDeliverableRevisionFactory,
category=self.category)
rev = doc.get_latest_revision()
metadata... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def newLine(self) :\n if not self.hpgl2 :\n dic = self.pages.get(self.pagecount, None)\n if dic is None :\n self.setPageDict(\"linescount\", 1) \n dic = self.pages.get(self.pagecount)\n nblines = dic[\"linescount\"] ... | [
"0.5686097",
"0.53973794",
"0.5373536",
"0.52844876",
"0.5228212",
"0.51969445",
"0.5139273",
"0.5136653",
"0.51357573",
"0.51017237",
"0.50866765",
"0.5070022",
"0.5069148",
"0.50635684",
"0.50523114",
"0.500983",
"0.49911618",
"0.49664697",
"0.4954358",
"0.4953977",
"0.4944... | 0.55814284 | 1 |
Non contractor cannot ack receipt of transmittals. | def test_non_contractor_acks_receipt(self):
res = self.client.post(self.url)
self.assertEqual(res.status_code, 403) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _send_ack(self):\n ack_packet = packet.Packet.from_data(\n 0,\n self.dest_addr,\n self.own_addr,\n ack=self._next_expected_seqnum\n )\n self._schedule_send_out_of_order(ack_packet)",
"def ack_required(self):\n v = self[22]\n v = v... | [
"0.6460112",
"0.64305913",
"0.64181185",
"0.6250114",
"0.6188823",
"0.608136",
"0.59823006",
"0.5949967",
"0.5943985",
"0.5902159",
"0.5897936",
"0.58878154",
"0.5869167",
"0.5841636",
"0.58208567",
"0.5818153",
"0.5790359",
"0.5729279",
"0.5706158",
"0.56860346",
"0.5656956"... | 0.69539994 | 0 |
Make a prediction with the given input. The prediction process consists of the input tensor transferring to the model device, forward pass of the nn_module in eval mode and application of the prediction_transform to the raw prediction output. | def predict(self, input):
self._check_predict_ready()
with torch.no_grad():
self.eval()
input = deep_to(input, self.device)
prediction = self.nn_module(input)
prediction = self.prediction_transform(prediction)
return prediction | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self, input):\n\n with torch.no_grad():\n input_tensor = self.preprocess_input(input)\n p_labels, p_probs = self.predict_on_batch(input_tensor)\n predictions = np.stack((p_labels, p_probs), axis=1)\n\n return predictions",
"def predict(cls, input):\n clf ... | [
"0.72369206",
"0.70280635",
"0.69705504",
"0.6882179",
"0.6841684",
"0.6813821",
"0.678869",
"0.65115666",
"0.65115666",
"0.65031374",
"0.6496032",
"0.6488619",
"0.6483028",
"0.6481794",
"0.6461958",
"0.64542216",
"0.64486",
"0.63823557",
"0.6380704",
"0.63725114",
"0.6371604... | 0.8179348 | 0 |
Set the nn_module into train mode. | def train(self, mode: bool = True):
if self.nn_module.training != mode:
self.nn_module.train(mode) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_mode_train(self):\n self._set_mode('train')\n return self",
"def train(self):\n self.mode = \"train\"\n self.online_net.train()",
"def train(self):\n self.mode = \"train\"\n self.online_net.train()",
"def set_train_mode(training, mnet, hnet, hhnet, dis):\n ... | [
"0.8144728",
"0.7675277",
"0.7675277",
"0.7567097",
"0.75528985",
"0.74082536",
"0.7332675",
"0.7263821",
"0.7259717",
"0.72031873",
"0.7111367",
"0.70592844",
"0.7042016",
"0.7032377",
"0.7019192",
"0.6991392",
"0.69666255",
"0.6925678",
"0.6881183",
"0.681172",
"0.6764086",... | 0.8258922 | 0 |
Generate an empty configuration file with only a single empty Site policy | def create_empty_config_file():
config = {
"config": [
{
"site": {
"username": "",
"name": "",
"ip_address": "",
"password": "",
"local": "",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_config_file_before(self):\n config = self.create_site_config()\n export_policy = {\n \"export\": {\n \"tenant\": \"intersite-testsuite\",\n \"app\": \"app\",\n \"epg\": \"epg\",\n \"remote_epg\": \"intersite-testsuite-a... | [
"0.69123816",
"0.6818789",
"0.6747462",
"0.66409326",
"0.59324014",
"0.580082",
"0.5746218",
"0.56806177",
"0.5652345",
"0.55335194",
"0.5495179",
"0.54804164",
"0.5454108",
"0.54512924",
"0.54390144",
"0.5415683",
"0.5353648",
"0.5330443",
"0.5325028",
"0.52674586",
"0.52413... | 0.68373185 | 1 |
Set up the remote site. Meant to be overridden by inheriting classes | def setup_remote_site(self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_local_site(self):\n raise NotImplementedError",
"def setUp(self):\n self.setup_remote_site()\n self.setup_local_site()",
"def __init__(self):\n self.site = pywikibot.Site(u'commons', u'commons')\n self.generator = self.getGenerator()",
"def setup(self):\n\n ... | [
"0.7351865",
"0.71371996",
"0.6471106",
"0.6460886",
"0.6439247",
"0.64348316",
"0.64113367",
"0.635672",
"0.635672",
"0.635672",
"0.635672",
"0.635672",
"0.6330865",
"0.63245213",
"0.6315102",
"0.62966764",
"0.62934047",
"0.6286767",
"0.61604464",
"0.6138893",
"0.60801387",
... | 0.8395448 | 0 |
Set up the local site. Meant to be overridden by inheriting classes | def setup_local_site(self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n self.setup_remote_site()\n self.setup_local_site()",
"def setup_remote_site(self):\n raise NotImplementedError",
"def setup(self):\n\n setup_data = get_setup_data()\n\n self.base_url = setup_data['base_url']\n browser = setup_data['browser'].lower()\... | [
"0.7307209",
"0.71960807",
"0.6618908",
"0.6584287",
"0.6563329",
"0.6558109",
"0.6512437",
"0.6484648",
"0.6484648",
"0.6484648",
"0.6484648",
"0.64676434",
"0.6448358",
"0.64482987",
"0.6445225",
"0.6445225",
"0.6424497",
"0.6424497",
"0.6424497",
"0.6424497",
"0.6424497",
... | 0.82535917 | 0 |
Set up the test case. Setup the remote and local site. | def setUp(self):
self.setup_remote_site()
self.setup_local_site() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup(self):\n # Have to wait for a server connection before we\n # can run the test\n self.wait_for_server_connections(10)",
"def setUp(self):\n test_env_setup()",
"def setup_remote_site(self):\n raise NotImplementedError",
"def setUp(self):\n self.brow = webdri... | [
"0.7332431",
"0.7082246",
"0.70760673",
"0.70298827",
"0.6978908",
"0.6978908",
"0.69545174",
"0.69033223",
"0.6877691",
"0.6832449",
"0.68183964",
"0.6790898",
"0.6786601",
"0.677809",
"0.6768166",
"0.67653364",
"0.67524713",
"0.6714655",
"0.6707392",
"0.67031753",
"0.670269... | 0.8576229 | 0 |
Tear down the test case. Tear down the remote and local site. | def tearDown(self):
self.teardown_local_site()
self.teardown_remote_site()
time.sleep(2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def teardown_test(self):\n self.log.info('Tearing down the test case')\n self.iperf_server.stop()\n self.access_point.bridge.teardown(self.brconfigs)\n self.access_point.close()\n wputils.reset_host_interface(self.pkt_sender.interface)\n self.mon.usb('on')",
"def tearDow... | [
"0.7534872",
"0.73962086",
"0.7370009",
"0.73310035",
"0.7247043",
"0.7140761",
"0.71196264",
"0.7116654",
"0.7015063",
"0.696482",
"0.696482",
"0.69535244",
"0.69535244",
"0.6951393",
"0.6949726",
"0.689157",
"0.689157",
"0.689157",
"0.688593",
"0.6884048",
"0.6884048",
"0... | 0.81366926 | 0 |
Generate a basic configuration containing the local and remote site policies. Actual site credentials are set in global variables imported from multisite_test_credentials | def create_site_config():
config = {
"config": [
{
"site": {
"username": "%s" % SITE1_LOGIN,
"name": "Site1",
"ip_address": "%s" % SITE1_IPADDR,
"password": "%s" % SITE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_config_file(self):\n config = self.create_site_config()\n export_policy = {\n \"export\": {\n \"tenant\": \"intersite-testsuite-local\",\n \"app\": \"app\",\n \"epg\": \"epg\",\n \"remote_epg\": \"intersite-testsuite-ap... | [
"0.653249",
"0.6490301",
"0.63971806",
"0.63197035",
"0.63190347",
"0.5756652",
"0.5688375",
"0.5669199",
"0.5642637",
"0.56357676",
"0.5627176",
"0.5614128",
"0.5578653",
"0.556191",
"0.556073",
"0.5556995",
"0.55450904",
"0.55450904",
"0.5543221",
"0.5520929",
"0.551141",
... | 0.6967031 | 0 |
Verify that the remote site has the entry | def verify_remote_site_has_entry(self, mac, ip, tenant_name, l3out_name, remote_epg_name):
site2 = Session(SITE2_URL, SITE2_LOGIN, SITE2_PASSWORD)
resp = site2.login()
self.assertTrue(resp.ok)
query = ('/api/mo/uni/tn-%s/out-%s/instP-%s.json?query-target=children' % (tenant_name,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify(self):\n if self.geturl():\n return True\n return False",
"def check_post(self, url, info):\r\n \r\n test = requests.get(url, headers = self.headers).json()['results']\r\n if info == test:\r\n return True\r\n return False",
"def _urlche... | [
"0.7095956",
"0.64719343",
"0.64107704",
"0.6186604",
"0.6123676",
"0.6075496",
"0.6052845",
"0.6010299",
"0.59730864",
"0.5961953",
"0.5954525",
"0.59486157",
"0.59384876",
"0.5913",
"0.5904583",
"0.5883021",
"0.58655274",
"0.5852213",
"0.5851459",
"0.584828",
"0.5848112",
... | 0.652173 | 1 |
Verify that the remote site has the entry and provides the specfied contract | def verify_remote_site_has_entry_with_provided_contract(self, mac, ip, tenant_name, l3out_name, remote_epg_name, contract_name):
site2 = Session(SITE2_URL, SITE2_LOGIN, SITE2_PASSWORD)
resp = site2.login()
self.assertTrue(resp.ok)
query = '/api/mo/uni/tn-%s/out-%s.json?query-target=subt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_remote_site_has_entry(self, mac, ip, tenant_name, l3out_name, remote_epg_name):\n site2 = Session(SITE2_URL, SITE2_LOGIN, SITE2_PASSWORD)\n resp = site2.login()\n self.assertTrue(resp.ok)\n\n query = ('/api/mo/uni/tn-%s/out-%s/instP-%s.json?query-target=children' % (tenant_na... | [
"0.56794",
"0.5660135",
"0.56169105",
"0.56155354",
"0.5591733",
"0.5438814",
"0.54283285",
"0.5421029",
"0.5370657",
"0.532726",
"0.53145826",
"0.5304276",
"0.53038454",
"0.52644545",
"0.52625453",
"0.5232082",
"0.5208109",
"0.52033883",
"0.52013546",
"0.5180896",
"0.5171062... | 0.6888689 | 0 |
Verify that the remote site has the policy | def verify_remote_site_has_policy(self, tenant_name, l3out_name, instp_name):
site2 = Session(SITE2_URL, SITE2_LOGIN, SITE2_PASSWORD)
resp = site2.login()
self.assertTrue(resp.ok)
query = ('/api/mo/uni/tn-%s/out-%s/instP-%s.json' % (tenant_name, l3out_name, instp_name))
resp = s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify(self):\n if self.geturl():\n return True\n return False",
"def test_basic_remove_policy(self):\n args = self.get_args()\n config = self.create_config_file()\n self.write_config_file(config, args)\n collector = execute_tool(args, test_mode=True)\n ... | [
"0.6503222",
"0.62608546",
"0.61887795",
"0.6128206",
"0.6093805",
"0.6025671",
"0.6003396",
"0.5899015",
"0.5826807",
"0.57733697",
"0.5753594",
"0.57472557",
"0.5745977",
"0.5728767",
"0.5715093",
"0.57131964",
"0.5710037",
"0.5691957",
"0.56792384",
"0.567788",
"0.5664685"... | 0.6775196 | 0 |
Get a mock of the command line arguments | def get_args():
args = mock.Mock()
args.debug = None
args.generateconfig = None
args.config = 'doesntmatter'
return args | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mock_get_args():\n\n return MagicMock()",
"def test_arg_parse(test):\n print(test)\n testargs = ['']\n with mock.patch.object(sys, 'argv', testargs):\n assert gc.arg_parse().interactive",
"def test_parsing_args(event_loop) -> None:\n called = False\n\n async def mock_func(hass, pro... | [
"0.78285116",
"0.73862106",
"0.693358",
"0.6824385",
"0.67919064",
"0.6790265",
"0.67393297",
"0.66914344",
"0.6677997",
"0.6621044",
"0.6559906",
"0.6548342",
"0.65294415",
"0.6523241",
"0.65163857",
"0.6500896",
"0.64581484",
"0.64440006",
"0.64237297",
"0.6401593",
"0.6316... | 0.8090608 | 0 |
Test basic MAC move | def test_basic_mac_move(self):
args = self.get_args()
self.write_config_file(self.create_config_file(), args)
execute_tool(args, test_mode=True)
ip = '3.4.3.4'
mac = '00:11:22:33:33:33'
self.assertFalse(self.verify_remote_site_has_entry(mac, ip, 'intersite-testsuite', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _mac_test(mac):\n\n\t\tif re.search(r'([0-9A-F]{2}[:]){5}([0-9A-F]){2}', mac.upper()) is not None:\n\t\t\treturn True\n\t\telse:\n\t\t\treturn False",
"def test_prepare_mac_header(self):\n self.assertEqual(prepare_mac_header(**self.mac_plain), self.auth_plain)\n self.assertEqual(prepare_mac_hea... | [
"0.6172225",
"0.6131883",
"0.5994028",
"0.59358835",
"0.59154856",
"0.59146136",
"0.58304495",
"0.58213615",
"0.5789043",
"0.57643783",
"0.57119405",
"0.56152964",
"0.5574822",
"0.55708",
"0.555919",
"0.555294",
"0.55398077",
"0.54959714",
"0.54862624",
"0.54616684",
"0.54557... | 0.7466434 | 0 |
Test remove one of multiple endpoints | def test_basic_remove_one_of_multiple_endpoint(self):
args = self.get_args()
config = self.create_config_file()
self.write_config_file(config, args)
execute_tool(args, test_mode=True)
time.sleep(2)
mac1 = '00:11:22:33:33:34'
ip1 = '3.4.3.5'
self.add_endpo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_basic_remove_one_of_multiple_endpoint(self):\n args = self.get_args()\n config = self.create_config_file()\n self.write_config_file(config, args)\n execute_tool(args, test_mode=True)\n\n time.sleep(2)\n mac1 = '00:11:22:33:33:34'\n ip1 = '3.4.3.5'\n ... | [
"0.79431224",
"0.7918341",
"0.7908843",
"0.74060154",
"0.732542",
"0.72361135",
"0.71684533",
"0.7119523",
"0.6881436",
"0.684713",
"0.64847803",
"0.64341676",
"0.64324373",
"0.64073634",
"0.6357826",
"0.631801",
"0.631801",
"0.6308663",
"0.63035923",
"0.62522364",
"0.6231188... | 0.8064927 | 0 |
Test add the endpoint | def test_basic_add_endpoint(self):
args = self.get_args()
config = self.create_config_file()
self.write_config_file(config, args)
execute_tool(args, test_mode=True)
time.sleep(2)
mac = '00:11:22:33:33:33'
ip = '3.4.3.4'
self.assertTrue(self.verify_remote_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_basic_add_endpoint(self):\n args = self.get_args()\n config = self.create_config_file()\n self.write_config_file(config, args)\n collector = execute_tool(args, test_mode=True)\n time.sleep(2)\n\n config['config'].append(self.create_export_policy())\n self.w... | [
"0.80474126",
"0.75272715",
"0.75091356",
"0.7458578",
"0.7254947",
"0.72521925",
"0.71781117",
"0.70729285",
"0.7032229",
"0.70025855",
"0.6964659",
"0.67963433",
"0.67228585",
"0.6685355",
"0.6635145",
"0.6612205",
"0.6582083",
"0.65518564",
"0.6551546",
"0.6527288",
"0.651... | 0.79640484 | 1 |
Test remove the endpoint | def test_basic_remove_endpoint(self):
args = self.get_args()
config = self.create_config_file()
self.write_config_file(config, args)
execute_tool(args, test_mode=True)
time.sleep(2)
mac = '00:11:22:33:33:33'
ip = '3.4.3.4'
self.assertTrue(self.verify_rem... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_basic_remove_endpoint(self):\n mac, ip = self.setup_with_endpoint()\n time.sleep(2)\n\n self.assertTrue(self.verify_remote_site_has_entry(mac, ip, 'intersite-testsuite', 'l3out',\n 'intersite-testsuite-app-epg1'))\n self.... | [
"0.828536",
"0.79282093",
"0.7899661",
"0.7463046",
"0.74537635",
"0.74340045",
"0.7390489",
"0.7344435",
"0.73168343",
"0.7312396",
"0.7302149",
"0.71278733",
"0.70067316",
"0.6982379",
"0.6963426",
"0.68355227",
"0.67464614",
"0.67464614",
"0.6661923",
"0.6657329",
"0.66452... | 0.79375327 | 1 |
Create the export policy | def create_export_policy():
config = {
"export": {
"tenant": "intersite-testsuite",
"app": "app",
"epg": "epg",
"remote_epg": "intersite-testsuite-app-epg",
"remote_sites": [
{
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_export_policy(l3out_name):\n export_policy = {\n \"export\": {\n \"tenant\": \"intersite-testsuite\",\n \"app\": \"app\",\n \"epg\": \"epg\",\n \"remote_epg\": \"intersite-testsuite-app-epg\",\n \"remote_sites\"... | [
"0.7591464",
"0.6972289",
"0.67560166",
"0.6715468",
"0.666488",
"0.66225404",
"0.6512321",
"0.59530276",
"0.59368205",
"0.58883494",
"0.5840365",
"0.5751171",
"0.57272696",
"0.5679028",
"0.56665695",
"0.56465685",
"0.56410825",
"0.56036294",
"0.56035244",
"0.5578853",
"0.548... | 0.7640657 | 0 |
Test adding the endpoint | def test_basic_add_endpoint(self):
args = self.get_args()
config = self.create_config_file()
self.write_config_file(config, args)
collector = execute_tool(args, test_mode=True)
time.sleep(2)
config['config'].append(self.create_export_policy())
self.write_config_f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_basic_add_endpoint(self):\n args = self.get_args()\n config = self.create_config_file()\n self.write_config_file(config, args)\n execute_tool(args, test_mode=True)\n time.sleep(2)\n\n mac = '00:11:22:33:33:33'\n ip = '3.4.3.4'\n self.assertTrue(self.... | [
"0.7961768",
"0.7546528",
"0.7531428",
"0.7487113",
"0.74692094",
"0.72555715",
"0.7200734",
"0.703249",
"0.7005394",
"0.69417787",
"0.6913453",
"0.6858982",
"0.6754575",
"0.6744913",
"0.6741133",
"0.6704777",
"0.6673568",
"0.6602921",
"0.6590168",
"0.6546669",
"0.6535335",
... | 0.80598587 | 0 |
Create a configuration with different EPGs | def create_diff_epg_config_file(self):
config = self.create_site_config()
export_policy = {
"export": {
"tenant": "intersite-testsuite",
"app": "app",
"epg": "epg",
"remote_epg": "intersite-testsuite-app-epg2",
"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_configuration(EngineType=None, EngineVersion=None, Name=None, Tags=None):\n pass",
"def create_config(self) -> None:\n pass",
"def create_config(self) -> None:\n pass",
"def _gen_config():\n cfg = {\"frontends\": {}, \"backends\": {}}\n for machine in Machine.objects(\n ... | [
"0.6670641",
"0.62125176",
"0.62125176",
"0.6175586",
"0.6036967",
"0.6032907",
"0.5891014",
"0.5884348",
"0.58781654",
"0.5875689",
"0.5859736",
"0.5702923",
"0.57000494",
"0.56649536",
"0.559409",
"0.55909014",
"0.55751383",
"0.5568713",
"0.556752",
"0.55577177",
"0.5549555... | 0.66669893 | 1 |
Test changing the policy name | def test_basic_change_policy_name(self):
args = self.get_args()
config = self.create_config_file()
mac = '00:11:22:33:33:33'
ip = '3.4.3.4'
self.write_config_file(config, args)
collector = execute_tool(args, test_mode=True)
time.sleep(4)
self.assertTrue(se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_policyname(self, policyname):\n self.options[\"policyname\"] = policyname",
"def set_policyname(self, policyname):\n self.options['policyname'] = policyname",
"def test_replace_namespaced_policy(self):\n pass",
"def policy_name(self, policy_name):\n\n self._policy_name = p... | [
"0.73485625",
"0.7300705",
"0.7236852",
"0.7149512",
"0.7149512",
"0.71392226",
"0.7054928",
"0.6891003",
"0.6654521",
"0.663868",
"0.6620467",
"0.65188605",
"0.65013367",
"0.6472393",
"0.6470784",
"0.64379805",
"0.6436578",
"0.63770264",
"0.63770264",
"0.63770264",
"0.637702... | 0.7603073 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.