query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Copied and modified from the official icetop_Level3_scripts
def rerun_reconstructions_snow_lambda(tray, snow_lambda): SnowFactor = snow_lambda name = 'processing' # Remove the L2 reconstructions tray.Add(level2_IceTop.RemoveOldLevel2, 'RemoveOldLevel2') extra_keys = ['LaputopSnowDiagnostics', 'IceTopHLCSeedRTPulses_SnowCorrected', 'StationDensity', 'IceTopMaxSignalTank', 'IceTopMaxSignalString', 'IceTopMaxSignal', 'IceTopMaxSignalInEdge', 'IceTopNeighbourMaxSignal', 'Laputop_OnionContainment', 'Laputop_FractionContainment', 'Laputop_NearestStationIsInfill', ] tray.Add('Delete', keys=extra_keys) CleanHLCTankPulses=icetop_globals.icetop_HLCseed_clean_hlc_pulses ExcludedHLCTanks=icetop_globals.icetop_HLCseed_excluded_tanks tray.Add(level2_IceTop.OfflineIceTopReco, name+'_RTOfflineIceTopReco', Pulses=CleanHLCTankPulses, Excluded=ExcludedHLCTanks, SnowFactor=SnowFactor, Detector='IC86.2012' ) reco_track='Laputop' # Creates: # *IceTopLaputopSeededSelectedHLC # *IceTopLaputopSeededSelectedSLC # *IceTopLaputopSeededRejectedHLC # *IceTopLaputopSeededRejectedSLC # *IceTopLaputopSeededAfterPulsesSLC # *IceTopLaputopSeededAfterPulsesSLC from icecube import icetop_Level3_scripts try: from icecube.topeventcleaning.segments import SelectPulsesFromSeed except: from icecube.icetop_tank_select.segments import SelectPulsesFromSeed it_tank_select_seed = 'Laputop' tray.AddSegment(SelectPulsesFromSeed, name+'_SelectPulsesFromSeed', Seed=it_tank_select_seed, HLCPulses=icetop_globals.icetop_hlc_pulses, SLCPulses=icetop_globals.icetop_slc_pulses, debug=True, tag='IceTopLaputopSeeded', If=lambda fr: "Laputop" in fr and fr["Laputop"].fit_status_string=="OK") #if small events to be included, then you want SelectPulsesFromSeed using laputopsmall for small events. it_tank_select_seed = 'LaputopSmall' tray.AddSegment(SelectPulsesFromSeed, name+'_SelectPulsesFromSeedSmall', Seed=it_tank_select_seed, HLCPulses=icetop_globals.icetop_hlc_pulses, SLCPulses=icetop_globals.icetop_slc_pulses, debug=True, tag='IceTopLaputopSmallSeeded', If=lambda fr: "LaputopSmall" in fr and fr["Laputop"].fit_status_string!="OK") # "Snow correct" the pulses which are used for the laputop reconstruction. # Extra pulses with "_SnowCorrected" added will be created. # These can be used later on for checks, but NOT for a new reconstruction, since this is a non-perfect correction! # The reconstruction should do its own snow correction. # These snow corrected pulses do can be used for Quality cuts (like maximal signal etc.) snow_correction = toprec.I3SimpleSnowCorrectionService("snow_correction", SnowFactor) tray.AddModule(SnowCorrectPulses, name+'SnowCorrrect', Pulses=[CleanHLCTankPulses], Track=reco_track, SnowService=snow_correction, If=lambda fr: "Laputop" in fr and fr["Laputop"].fit_status_string=="OK") tray.AddModule(SnowCorrectPulses, name+'SnowCorrrectSmall', Pulses=[CleanHLCTankPulses], Track=reco_track+"Small", SnowService=snow_correction, If=lambda fr: "LaputopSmall" in fr and fr["Laputop"].fit_status_string!="OK") # Do the cuts tray.AddSegment(IceTopQualityCuts, name+'_IceTopQualityCuts', pulses=CleanHLCTankPulses+"_SnowCorrected", detector='IC86.2012', removeOrNot=False, reco_track=reco_track, isMC=True) return tray
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exo2():", "def substantiate():", "def falcon():", "def CL(self):", "def script(self):", "def exercise_b2_106():\r\n pass", "def exercise_b2_113():\r\n pass", "def test_fobj():\n Level3File(get_test_data('nids/Level3_FFC_N0Q_20140407_1805.nids'))", "def mezclar_bolsa(self):", "def exe...
[ "0.60673505", "0.57316786", "0.57143044", "0.56544286", "0.55507493", "0.5425385", "0.53751373", "0.53641415", "0.5281127", "0.52700067", "0.5243484", "0.5227051", "0.5217968", "0.5208976", "0.51897764", "0.517396", "0.5118316", "0.5114902", "0.5114671", "0.51113915", "0.5110...
0.0
-1
Load the data which has been generated by the simulator from historic files
def get_candles_data(self): df = pd.read_csv(f'realtime_data/data.csv', names=['date', 'open', 'high', 'low', 'close', 'volume', 'barCount', 'average']) df = self.data_util_ref.pre_data_process(df) output = self.visual_ref.get_candles_visual_data(df) return json.dumps([output['data'][-45:], output['annotations'], self.today])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _load_state(self):\n \n if os.path.isfile(self.histFile):\n with open(self.histFile,'rb') as hf:\n oldFile = hf.read()\n \n if os.path.isfile(oldFile):\n self.dbFile.Value = oldFile", "def load_(self):\n path = os.path.jo...
[ "0.70352036", "0.70295185", "0.69942", "0.6906483", "0.63878626", "0.6382765", "0.6270393", "0.62033886", "0.62032616", "0.6193245", "0.6143477", "0.612875", "0.6127106", "0.6097942", "0.60866916", "0.6064095", "0.6058584", "0.60450536", "0.6044156", "0.60385203", "0.6036894"...
0.0
-1
Load the data which has been generated by the simulator from historic files
def get_prediction_data(self): df = pd.read_csv(f'realtime_data/data.csv', names=['date', 'open', 'high', 'low', 'close', 'volume', 'barCount', 'average']) df = self.data_util_ref.pre_data_process(df) output = self.visual_ref.get_prediction_visual_data(df) # return json.dumps([output['data'][-30:], output['annotations']]) return output
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _load_state(self):\n \n if os.path.isfile(self.histFile):\n with open(self.histFile,'rb') as hf:\n oldFile = hf.read()\n \n if os.path.isfile(oldFile):\n self.dbFile.Value = oldFile", "def load_(self):\n path = os.path.jo...
[ "0.70349073", "0.7028908", "0.69926465", "0.69052213", "0.6388666", "0.6382003", "0.6272473", "0.6202085", "0.6201776", "0.6192213", "0.61428773", "0.61299187", "0.6126348", "0.6097556", "0.6085418", "0.60641634", "0.60568464", "0.60444623", "0.6042505", "0.6037602", "0.60348...
0.0
-1
Checks the date and time, and then decides if a shift from master to slave (or vice versa) is needed. If necessary, makes the shift.
def main(): date = time.gmtime().tm_mday if date == 1 or date == 2: # in case it missed once # shift from slave to master, checking to ensure it hasn't already happened status = check_status() if status == 'slave': slave_to_master() elif status == 'master': print("Shift has probably already happened") else: print("In a forbidden state:", status) elif date == 22 or date == 23: #in case it missed once # shift from master to slave, checking to ensure it hasn't already happened status = check_status() if status == 'master': master_to_slave() elif status == 'slave': print("Shift has probably already happened") else: print("In a forbidden state:", status) else: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __is_valid_move(self, scheduling_unit, turnus, date, person, overtime, depth=0, check_turnuses=[]):\n \n \n if not schedule_utils.is_valid_move (scheduling_unit, turnus, date, person, overtime):\n return False\n \n # if the workplace has the special rule: work in the afternoon, if the n...
[ "0.5707775", "0.56430596", "0.5583629", "0.5324878", "0.5245917", "0.5093938", "0.50450516", "0.49869803", "0.4892492", "0.488806", "0.4854944", "0.485275", "0.48295307", "0.48010412", "0.47898087", "0.4774762", "0.47731286", "0.4770391", "0.47576922", "0.47565082", "0.471500...
0.74977547
0
Check the status of the application, i.e., whether it is running on the master or slave. Also check to see if there are any issues, like the web dyno on the slave running, or both workers running etc.
def check_status(): # assume no web dynos on master - there should never be a web dyno on master r = req.get(f"{MASTER_API_URL}/formation/worker", headers=MASTER_API_HEADERS) if r.status_code != req.codes.ok: print("Couldn't get master worker formation") print(r.status_code, ":", r.text) return 'unknown:1' master_worker = r.json()['quantity'] # this is guaranteed to work i think r = req.get(f"{SLAVE_API_URL}/formation/worker", headers=SLAVE_API_HEADERS) if r.status_code != req.codes.ok: print("Couldn't get slave worker formation") print(r.status_code, ":", r.text) return 'unknown:2' slave_worker = r.json()['quantity'] r = req.get(f"{SLAVE_API_URL}/formation/web", headers=SLAVE_API_HEADERS) if r.status_code != req.codes.ok: print("Couldn't get slave web formation") print(r.status_code, ":", r.text) return 'unknown:3' slave_web = r.json()['quantity'] # all done if slave_web != 0: return 'forbidden-web' elif master_worker != 0 and slave_worker != 0: return 'both' elif master_worker != 0: return 'master' elif slave_worker != 0: return 'slave' else: return 'none'
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_configuration_server(self) -> bool:\n return (\n self.container is not None\n and self.container.exec_run(\n \"bash -c 'curl -s --head http://localhost:19071/ApplicationStatus'\"\n )\n .output.decode(\"utf-8\")\n .split(\"\\r\\n...
[ "0.6630676", "0.6584592", "0.64988655", "0.6488543", "0.6485963", "0.6476117", "0.6447399", "0.63786393", "0.62928927", "0.6289477", "0.6250488", "0.62484485", "0.6197466", "0.6183795", "0.6161205", "0.61303514", "0.61219287", "0.61159056", "0.6114376", "0.609758", "0.6067191...
0.6729618
0
Shift the process from master to slave, shifting data as needed.
def master_to_slave(): print("Shifting from master to slave") stop_master_worker() setup_slave_web() prepare_push() push_to_slave() stop_slave_web() start_slave_worker() print("DONE!")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def slave_to_master():\n print(\"Shifting from slave to master\")\n stop_slave_worker()\n setup_slave_web()\n pull_from_slave()\n commit_pull_to_db()\n stop_slave_web()\n start_master_worker()\n print(\"DONE!\")", "def runSlaveRun():\n\n np.set_printoptions(linewidth=1000)\n functio...
[ "0.72516125", "0.5815426", "0.567222", "0.5663159", "0.54625714", "0.5429651", "0.53810555", "0.53091127", "0.5294686", "0.5285994", "0.51691014", "0.5157244", "0.5134187", "0.512011", "0.50734735", "0.50418085", "0.5016566", "0.5001079", "0.4958527", "0.49188", "0.49104735",...
0.7314937
0
Shift the process from slave to master, shifting data as needed.
def slave_to_master(): print("Shifting from slave to master") stop_slave_worker() setup_slave_web() pull_from_slave() commit_pull_to_db() stop_slave_web() start_master_worker() print("DONE!")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def master_to_slave():\n print(\"Shifting from master to slave\")\n stop_master_worker()\n setup_slave_web()\n prepare_push()\n push_to_slave()\n stop_slave_web()\n start_slave_worker()\n print(\"DONE!\")", "def write_master(self, data):\n self._write(self.master_fd, data)", "def...
[ "0.72428024", "0.5692221", "0.56806463", "0.55942285", "0.5393446", "0.5345593", "0.53245896", "0.53045934", "0.5239213", "0.5215958", "0.5118116", "0.5114614", "0.50847006", "0.5059445", "0.5055491", "0.5023818", "0.5010442", "0.5004643", "0.49860305", "0.49616227", "0.49346...
0.7228141
1
Sets up the web server on the slave, then checks it.
def setup_slave_web(): print("Starting slave web") r = req.patch(f"{SLAVE_API_URL}/formation/web", json=API_PAYLOAD_1, headers=SLAVE_API_HEADERS) if r.status_code != req.codes.ok: print("Unable to start the web dyno on slave") print(r.text) return False #wait a bit for the web process to start up print("Waiting a bit") time.sleep(10) r = req.get(SLAVE_URL) if not r.text.startswith("Index"): print("Something is wrong with slave:") print(r.text) return False print("Got response from slave:", r.text) return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_server(manager):\n if not manager.is_daemon:\n return\n\n web_server_config = manager.config.get('web_server')\n\n if not web_server_config:\n return\n\n web_server = WebServer(\n bind=web_server_config['bind'],\n port=web_server_config['port'],\n )\n\n if we...
[ "0.6809068", "0.67656696", "0.6656338", "0.6610853", "0.65221626", "0.6354455", "0.62950474", "0.6216161", "0.62008417", "0.62003654", "0.6176954", "0.601398", "0.6004903", "0.5986498", "0.59861344", "0.5985435", "0.5959048", "0.5956801", "0.5941647", "0.58429754", "0.5814541...
0.81821865
0
Stops the web process on the slave.
def stop_slave_web(): print("Stopping slave web") r = req.patch(f"{SLAVE_API_URL}/formation/web", json=API_PAYLOAD_0, headers=SLAVE_API_HEADERS) if r.status_code != req.codes.ok: print("Unable to stop the web dyno on slave") print(r.text) return False #wait a bit for the web process to stop print("Waiting a bit") time.sleep(2) return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def webserver_stop():\n run(\"kill $(cat %s)\" % GUNICORN_PIDFILE)\n run(\"rm %s\" % GUNICORN_PIDFILE)", "def stop_slave_worker():\n print(\"Stopping slave worker\")\n r = req.patch(f\"{SLAVE_API_URL}/formation/worker\", json=API_PAYLOAD_0, headers=SLAVE_API_HEADERS)\n if r.status_code != req.code...
[ "0.7413745", "0.7409462", "0.70902383", "0.7082552", "0.68931115", "0.68733066", "0.68609893", "0.6817112", "0.67590433", "0.67129856", "0.6705761", "0.6702287", "0.66915804", "0.6671726", "0.6669743", "0.6660702", "0.66476685", "0.66400963", "0.6629474", "0.6618239", "0.6569...
0.8396582
0
Starts the worker process on the master.
def start_master_worker(): print("Starting master worker") r = req.patch(f"{MASTER_API_URL}/formation/worker", json=API_PAYLOAD_1, headers=MASTER_API_HEADERS) if r.status_code != req.codes.ok: print("Unable to start the worker dyno on master") print(r.text) return False #wait a bit for the worker process to start print("Waiting a bit") time.sleep(10) return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def worker(ctx_obj):\n execute(start_worker_command(settings=ctx_obj['settings']))", "def start(self):\n control_process = mp.Process(target = self._start, args = [])\n control_process.start()", "def start_slave_worker():\n print(\"Starting slave worker\")\n r = req.patch(f\"{SLAVE_API_U...
[ "0.74038696", "0.7210624", "0.70151126", "0.7001591", "0.6949406", "0.6915681", "0.68317443", "0.67932683", "0.6752919", "0.6713696", "0.6707904", "0.66620183", "0.66078997", "0.6578205", "0.647364", "0.6429986", "0.63926333", "0.6350077", "0.6317507", "0.6302991", "0.6230232...
0.7759477
0
Stops the worker process on the master.
def stop_master_worker(): print("Stopping master worker") r = req.patch(f"{MASTER_API_URL}/formation/worker", json=API_PAYLOAD_0, headers=MASTER_API_HEADERS) if r.status_code != req.codes.ok: print("Unable to stop the worker dyno on master") print(r.text) return False #wait a bit for the worker process to stop print("Waiting a bit") time.sleep(2) return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stop(self):\n\n # immediate is necessary if it's in recovery (for now).\n # we don't care the result.\n master = gp.MasterStop(\"Stopping Master Standby\",\n self.datadir, mode='immediate')\n master.run()", "def stop_slave_worker():\n print(\"Stopp...
[ "0.7388482", "0.7279379", "0.7237633", "0.6967597", "0.6921898", "0.68627954", "0.6821255", "0.68206173", "0.67904496", "0.6728565", "0.67254424", "0.67202437", "0.6709311", "0.67050105", "0.6670142", "0.66601145", "0.66253245", "0.6620445", "0.6605411", "0.66041267", "0.6577...
0.76747125
0
Starts the worker process on the slave.
def start_slave_worker(): print("Starting slave worker") r = req.patch(f"{SLAVE_API_URL}/formation/worker", json=API_PAYLOAD_1, headers=SLAVE_API_HEADERS) if r.status_code != req.codes.ok: print("Unable to start the worker dyno on slave") print(r.text) return False #wait a bit for the worker process to start up print("Waiting a bit") time.sleep(10) return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_worker(self):\n # TODO(xiejw): To allow execution framework to add train hooks.\n return self._start_distributed_training()", "def worker(ctx_obj):\n execute(start_worker_command(settings=ctx_obj['settings']))", "def start_master_worker():\n print(\"Starting master worker\")\n r = req.pa...
[ "0.7050969", "0.68271756", "0.6755335", "0.67251605", "0.65629065", "0.65401715", "0.6436881", "0.6374149", "0.6337312", "0.6323815", "0.6307696", "0.6272211", "0.62686425", "0.62494606", "0.6231326", "0.61917204", "0.61633587", "0.61614466", "0.6132043", "0.61305064", "0.612...
0.7931532
0
Stops the worker process on the slave.
def stop_slave_worker(): print("Stopping slave worker") r = req.patch(f"{SLAVE_API_URL}/formation/worker", json=API_PAYLOAD_0, headers=SLAVE_API_HEADERS) if r.status_code != req.codes.ok: print("Unable to stop the worker dyno on slave") print(r.text) return False #wait a bit for the worker process to stop print("Waiting a bit") time.sleep(2) return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Stop(self):\n if self.child_pid:\n self.data = self.host.Communicate(self.child_pid, echo_error=True,\n kill=True,\n kill_string=IperfServer.KILL_STRING)\n self.child_pid = None", "def stop(self):\n\n # immediat...
[ "0.7121769", "0.7078228", "0.70730764", "0.703866", "0.69969434", "0.6940482", "0.6888461", "0.6873332", "0.6864292", "0.6846163", "0.6844958", "0.6808371", "0.6796847", "0.6751896", "0.6735001", "0.6733168", "0.6719779", "0.67189586", "0.66959256", "0.6666449", "0.6627743", ...
0.817291
0
Prepares to send data from master (this) to slave.
def prepare_push(): print("Preparing to push") cur = conn.cursor() try: for tname in TABLES: with open(f'{tname}.db', 'w') as f: print(f"Copying {tname}") cur.copy_to(f, f'"{tname}"') return True except IOError: print("IO ERROR") return False finally: cur.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def slave_to_master():\n print(\"Shifting from slave to master\")\n stop_slave_worker()\n setup_slave_web()\n pull_from_slave()\n commit_pull_to_db()\n stop_slave_web()\n start_master_worker()\n print(\"DONE!\")", "def master_to_slave():\n print(\"Shifting from master to slave\")\n ...
[ "0.5962205", "0.58612955", "0.5847379", "0.5833639", "0.5828165", "0.5792788", "0.5755556", "0.56804013", "0.5674747", "0.5459173", "0.54531056", "0.5439083", "0.54315406", "0.5406502", "0.5381936", "0.5331048", "0.5322958", "0.5303191", "0.5276801", "0.5276801", "0.5276801",...
0.0
-1
Sends data from the master (this) to the slave.
def push_to_slave(): print("Pushing to slave") try: for tname in TABLES: with open(f'{tname}.db', 'rb') as f: print(f"Pushing {tname}") r = req.post(f"{SLAVE_URL}/push_db/{tname}", files={'file': f}, data={'key': HMA_KEY}) if r.status_code != req.codes.ok: print("Something wrong with slave on push:") print(r.text) return False return True except IOError: print("IO ERROR") return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_master(self, data):\n self._write(self.master_fd, data)", "def send(self):\n if(self.target):\n try:\n self.message = self.message +\"\\r\\n\"\n self.target[0].send(self.message)\n except socket.error, err:\n print er...
[ "0.7521397", "0.67997825", "0.67381716", "0.6720654", "0.669663", "0.6656692", "0.6556619", "0.65406233", "0.6521673", "0.6500805", "0.6472015", "0.6464885", "0.6464885", "0.6463158", "0.6460335", "0.6371669", "0.6364468", "0.6352487", "0.63482475", "0.633402", "0.63125366", ...
0.0
-1
Pulls data from the slave.
def pull_from_slave(): print("Pulling from slave") r = req.get(f"{SLAVE_URL}/prepare_pull") if r.status_code != req.codes.ok: print("Something wrong with slave on prepare pull") print(r.text) return False print("Prepared") try: for tname in TABLES: with open(f'{tname}.db', 'wb') as f: print(f"Pulling {tname}") r = req.post(f"{SLAVE_URL}/pull_db/{tname}", data={'key': HMA_KEY}) if r.status_code != req.codes.ok: print("Something went wrong") print(r.text) return False f.write(r.content) return True except IOError: print("IO ERROR") return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def _pull(self) -> None:\n raise NotImplementedError()", "def pull(self):", "def _pull(self) -> None:\n raise NotImplementedError() # pragma: no cover", "def get_data(self):\n self._send_command(self._adapter.get_data())", "def pull(self):\n raise NotImplementedError()", ...
[ "0.68342793", "0.6720848", "0.65273225", "0.626639", "0.61622834", "0.61532104", "0.6083716", "0.601274", "0.60006136", "0.59574234", "0.5846637", "0.58430606", "0.5761794", "0.5746034", "0.57344276", "0.5729992", "0.56974876", "0.5640078", "0.5632374", "0.5596392", "0.555516...
0.67073804
2
Commit data pulled from slave to the master's database.
def commit_pull_to_db(): print("Committing pulled data") cur = conn.cursor() try: for tname in TABLES: cur.execute(f"DELETE FROM {tname};") with open(f'{tname}.db', 'r') as f: print(f"Copying {tname}") cur.copy_from(f, f'"{tname}"') conn.commit() return True except IOError: print("IO ERROR") return False finally: cur.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Commit(self):\n sql_cnxn = self.GetMasterConnection()\n try:\n sql_cnxn.commit()\n except MySQLdb.DatabaseError:\n logging.exception('Commit failed for cnxn, rolling back')\n sql_cnxn.rollback()", "def slave_to_master():\n print(\"Shifting from slave to master\")\n stop_slave_wo...
[ "0.6980852", "0.6679038", "0.64713585", "0.6355909", "0.62791294", "0.6135586", "0.6130546", "0.61136794", "0.61062694", "0.60972565", "0.6095288", "0.6005328", "0.59964836", "0.59951985", "0.5989465", "0.59722084", "0.59344745", "0.59253657", "0.59253657", "0.59253657", "0.5...
0.5606902
46
Reimplemented to capture the Tab key pressed/released event.
def event(self, event): if event.type() == QEvent.ShortcutOverride and event.key() == Qt.Key_Tab: event.accept() return True if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Tab: return self.keyPressEvent(event) return super().event(event)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def OnKeyDown2(self, event):\r\n\r\n if self.GetActivePage() == -1:\r\n event.Skip()\r\n return\r\n \r\n # We can't leave tab processing to the system on Windows, tabs and keys\r\n # get eaten by the system and not processed properly if we specify both\r\n # wxT...
[ "0.6881452", "0.6782852", "0.6661517", "0.66373795", "0.6533331", "0.6484942", "0.64714545", "0.6413943", "0.62985414", "0.62599313", "0.6241822", "0.62392884", "0.62282753", "0.61531764", "0.61026293", "0.609596", "0.59973466", "0.59498143", "0.59262854", "0.5887352", "0.586...
0.64935756
5
Uses the current cursor position, which is in a code view, and gets the corresponding instruction address that is associated to the code. Returns the start of the function if unable to calculate.
def get_src_to_inst(self) -> int: # get the Qt document doc: QCodeDocument = self.document() # get the current position of the cursor cursor = self.textCursor() pos = cursor.position() # get the node at the associated cursor position current_node = doc.get_stmt_node_at_position(pos) if ( current_node is not None and hasattr(current_node, "tags") and current_node.tags is not None and "ins_addr" in current_node.tags ): asm_ins_addr = current_node.tags["ins_addr"] else: # the top of the function decompiled asm_ins_addr = self._code_view.function.addr return asm_ins_addr
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_code(func):\n import inspect\n\n raw = \"\".join(inspect.getsource(func))\n found = re.findall(\"(k = .*)\", raw)\n\n if any(found):\n code = found[0]\n return code\n else:\n return \"\"", "def getInstructionBefore(self, address: ghidra....
[ "0.6299851", "0.6007909", "0.60040885", "0.6001951", "0.5926025", "0.59078115", "0.5856952", "0.5770866", "0.57665575", "0.57530594", "0.57365364", "0.5735565", "0.5707904", "0.5673848", "0.56713", "0.5665861", "0.5659602", "0.5657597", "0.5647901", "0.5603577", "0.5597595", ...
0.7334392
0
initialize parameters using kaiming normal
def init_parameters(module: nn.Module): for m in module.modules(): if isinstance(m, nn.Conv2d): # todo: check if fan_out is valid nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu') elif isinstance(m, nn.BatchNorm2d): nn.init.constant_(m.weight, 1) nn.init.constant_(m.bias, 0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __setup_parameters__(self):\r\n self.M=self.N+1\r\n self.u=1+self.pu\r\n self.d=1-self.pd\r\n self.qu=(math.exp((self.r-self.div)*self.dt)-self.d)/(self.u-self.d)\r\n self.qd=1-self.qu", "def init_paramters(self):\r\n carb_bg_ratio = 5.0\r\n time_to_breakdown ...
[ "0.7051572", "0.6925155", "0.6915251", "0.68529457", "0.68099403", "0.6714396", "0.6687382", "0.6675767", "0.6673424", "0.66504097", "0.66460747", "0.66280675", "0.66103244", "0.6576185", "0.6574086", "0.65717214", "0.6559772", "0.65528405", "0.6546903", "0.6539553", "0.65352...
0.0
-1
Tests the inference method.
def test_inference(self, tmpdir, setup_task_environment): root = str(tmpdir.mkdir("anomaly_inference_test")) # Get task environment setup_task_environment = deepcopy(setup_task_environment) # since fixture is mutable task_environment = setup_task_environment.task_environment task_type = setup_task_environment.task_type output_model = setup_task_environment.output_model dataset = setup_task_environment.dataset # 1. Create the training task and get inference results on an untrained model. dataset = dataset.get_subset(Subset.VALIDATION) train_task = TrainingTask(task_environment, output_path=root) dataset = train_task.infer(dataset.with_empty_annotations(), InferenceParameters(is_evaluation=True)) train_task.save_model(output_model) # 2. check if the model is saved correctly assert output_model.get_data("weights.pth") is not None # Should not raise an error # 3. Create new task environment and inference task and test inference new_dataset: DatasetEntity = get_hazelnut_dataset(task_type, one_each=True) gt_val_dataset = new_dataset.get_subset(Subset.VALIDATION) new_task_environment = create_task_environment(gt_val_dataset, task_type) # this loads the output model from the previous training task when creating the new InferenceTask new_task_environment.model = output_model inference_task = InferenceTask(new_task_environment, output_path=root) pred_val_dataset = inference_task.infer( gt_val_dataset.with_empty_annotations(), InferenceParameters(is_evaluation=True) ) # compare labels with the original validation dataset for item1, item2 in zip(dataset, pred_val_dataset): assert set([label.name for label in item1.annotation_scene.get_labels()]) == set( [label.name for label in item2.annotation_scene.get_labels()] ) # 4. Check whether performance metrics are produced correctly # This tests whether the performance metrics are calculated correctly and assigned to the result set output_model = ModelEntity( gt_val_dataset, new_task_environment.get_model_configuration(), ) result_set = ResultSetEntity( model=output_model, ground_truth_dataset=gt_val_dataset, prediction_dataset=pred_val_dataset ) inference_task.evaluate(result_set) if task_type in (TaskType.ANOMALY_CLASSIFICATION, TaskType.ANOMALY_DETECTION): assert result_set.performance.score.name == "f-measure" elif task_type == TaskType.ANOMALY_SEGMENTATION: assert result_set.performance.score.name == "Dice Average" # 5. Check if OpenVINO model can be generated inference_task.export(ExportType.OPENVINO, output_model, dump_features=False) assert output_model.get_data("openvino.bin") is not None # Should not raise an error assert not output_model.has_xai # 6. Check if ONNX model can be generated inference_task.export(ExportType.OPENVINO, output_model, dump_features=False) assert output_model.get_data("model.onnx") is not None # Should not raise an error assert not output_model.has_xai
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inference(self):\n raise NotImplementedError", "def inference(model, data, diagnostics, seed, extra_fitting_args):\n pass", "def inference(self, x, name):\n raise NotImplemented", "def test_inference(VD, CD):\n \n if VD['inference_process'] == None:\n VD['terminal_output'] +...
[ "0.7798499", "0.7028686", "0.6684394", "0.66657066", "0.6625743", "0.6539838", "0.6301463", "0.62897986", "0.6276158", "0.6228454", "0.62056077", "0.61593705", "0.61272967", "0.6122539", "0.611181", "0.60995996", "0.60318434", "0.5953834", "0.5880599", "0.58443904", "0.583019...
0.609276
16
Calculate a checksum for the given path. Will eventually use this to ensure config has changed before reloading.
def checksum(path): with open(path, 'r') as f: return md5(f.read()).digest()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_checksum(path: Union[Path, str]) -> str:\n path = Path(path)\n if not (path.is_file() or path.is_dir()):\n msg.fail(f\"Can't get checksum for {path}: not a file or directory\", exits=1)\n if path.is_file():\n return hashlib.md5(Path(path).read_bytes()).hexdigest()\n else:\n ...
[ "0.7271267", "0.6893249", "0.67964584", "0.6699954", "0.65897936", "0.6586321", "0.6519239", "0.65081114", "0.6485526", "0.6472071", "0.646679", "0.6462213", "0.64450413", "0.64431435", "0.63804424", "0.6329311", "0.6290257", "0.62881494", "0.6251396", "0.6229306", "0.6219351...
0.7938589
0
Set up inotify if requested.
def _setup_inotify(self, flag): i = None if flag: try: import inotify.adapters except ImportError: raise AssertionError( 'cannot use inotify, package not installed') else: i = inotify.adapters.Inotify(paths=[self.watch], block_duration_s=0) return (flag, i)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start(self):\n self._class_setup()\n\n self._inotify_fd = InotifyFileWatcher._libc.inotify_init()\n if self._inotify_fd < 0:\n error = OSError('failed call to inotify_init')\n error.errno = ctypes.get_errno()\n error.strerror = errno.errorcode[ctypes.get_errno()]\n raise error\n ...
[ "0.68859357", "0.6521524", "0.5825635", "0.5661374", "0.56051093", "0.5601565", "0.55341774", "0.5521033", "0.54301476", "0.53801805", "0.53308344", "0.521609", "0.5213829", "0.5188312", "0.51532716", "0.5120239", "0.51025105", "0.5082971", "0.507481", "0.50697386", "0.506352...
0.7264749
0
Create watch directory if it does not exist.
def _setup_watch(self, watch): assert not isfile(watch), 'watch dir is a file' if pathexists(watch): return watch os.makedirs(watch) if self.chown: try: os.chown(watch, *self.chown) except OSError: pass # Non-fatal if self.chmod: try: os.chmod(watch, self.chmod) except OSError: pass # Non-fatal return watch
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_dir(self):\n\n if not os.path.isdir(self.directory):\n os.mkdir(self.directory, 755)\n if not os.path.exists(self.log_file):\n from pathlib import Path\n Path(self.log_file).touch()", "def start_check():\n if not os.path.exists(outfancy_temp_files):\n ...
[ "0.6459634", "0.6346766", "0.6331183", "0.6299552", "0.6197254", "0.6110146", "0.6098661", "0.6089687", "0.6088672", "0.60865545", "0.6084467", "0.6080845", "0.6065921", "0.6042916", "0.603886", "0.59679985", "0.5966238", "0.5957223", "0.59505254", "0.5901048", "0.5883695", ...
0.77630746
0
Set up for chown/chmod.
def _setup_permissions(self, chown, chmod): if chown is not None: if isinstance(chown, str): user, group = chown, None else: try: # Try to extract tuple. user, group = chown except ValueError: # If length of iterable is not 2, then allow 1. assert len(chown) == 1, 'chown must be user or tuple' user, group = chown[0], None except TypeError: # If not iterable, use given value as user. user, group = chown, None # Lookup user id. if isinstance(user, str): user_info = pwd.getpwnam(user) user = user_info.pw_uid # Lookup group id, or use -1 (do not change group) if isinstance(group, str): group = grp.getgrnam(group).pw_gid elif group is None: group = -1 # Return tuple usable by os.chown(). chown = (user, group) # Ensure chmod is numeric if given. if chmod is not None: assert isinstance(chmod, numbers.Number), 'chmod must be a number' return chown, chmod
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_permissions():\n sudo('chown %s:%s -R %s' % (env.apache_user, env.apache_user, env.whole_path_symlinked))", "def Chown(self):\n cmd = 'chmod -R 0775 %s' % self.procdir\n self.ExecCmd(cmd)", "def set_ownership(self):\n\n os.chmod(os.path.join(\"%s\" % NetworkManager_conf_dir, s...
[ "0.7886576", "0.7704895", "0.7617247", "0.75252616", "0.7270645", "0.72335154", "0.7083537", "0.70804906", "0.6867677", "0.6863387", "0.6816202", "0.67961174", "0.6747547", "0.67430216", "0.6602624", "0.65472955", "0.6544091", "0.64677674", "0.6467248", "0.6389743", "0.637281...
0.7632436
2
Run the service command.
def start_command(self, wait_for_config=True): self.process = subprocess.Popen(shlex.split(self.command)) LOGGER.info( 'Command (%s) started with pid %s', self.command, self.process.pid)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _run_command_in_service(context, service, command):\n if context.docker_compose_path:\n cmd = _make_compose_command(context, 'run', '--rm', '-d', service)\n cmd.extend(command)\n else:\n raise Exception(\"not implemented\")\n\n try:\n # universal_newlines decodes output on ...
[ "0.6806571", "0.66887987", "0.6567109", "0.6553368", "0.6491652", "0.6458441", "0.6445283", "0.63440955", "0.6291305", "0.6275552", "0.62669", "0.626131", "0.6257048", "0.62291175", "0.622709", "0.6215655", "0.6206896", "0.6186277", "0.61826146", "0.61619884", "0.6153432", ...
0.0
-1
Reload configuration. If reload command is given, run that, otherwise, signal process with HUP.
def reload_command(self): if self.reload is None: if not self.check_command(): LOGGER.info('Command dead, restarting...') self.start_command(wait_for_config=False) else: LOGGER.info('Sending HUP signal...') self.process.send_signal(signal.SIGHUP) else: LOGGER.info('Executing reload command...') subprocess.call(shlex.split(self.reload))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reload_config():\n subprocess.run([SUPERVISOR_CMD, \"reload\"])", "def nginx_reload():\n log('reload nginx', yellow)\n sudo('/etc/init.d/nginx reload')", "def reload_config(self):\n pass", "def command_reload(interface,command,args):\n command_unload(interface,command,args)\n comman...
[ "0.75852543", "0.6688586", "0.6681827", "0.66347086", "0.633552", "0.6311228", "0.6310406", "0.62902033", "0.6279588", "0.6202909", "0.6199834", "0.61551714", "0.6126377", "0.6089492", "0.6079683", "0.60628176", "0.59531575", "0.5931519", "0.5927496", "0.5915352", "0.5904567"...
0.8385148
0
Return False if command is dead, otherwise True.
def check_command(self): return self.process is not None and self.process.poll() is None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_dead(self):\n if self.killer:\n if self.killer.stype == 'fire' and not (self.killer in self.pjs.fires):\n return True\n elif self.killer.stype == 'enemy' and self.timeout == 0:\n return True\n else:\n return False", "def __is_act...
[ "0.6922289", "0.6847067", "0.68249875", "0.66671854", "0.66655314", "0.6653957", "0.65789324", "0.6558258", "0.6550506", "0.649371", "0.64785314", "0.64250284", "0.63963515", "0.6387006", "0.6375392", "0.6337235", "0.62643814", "0.62609", "0.6241368", "0.6222854", "0.62103415...
0.69605875
0
Use polling method to enumerate files in watch dir.
def get_config_files(self): flag, i = self.inotify if flag: kwargs = {} if PY3: kwargs['timeout_s'] = 0 filenames = set() for event in i.event_gen(**kwargs): if event is None: break filenames.add(event[3]) return list(filenames) else: return os.listdir(self.watch)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _watchFolder(self):\n wm = pyinotify.WatchManager()\n wm.add_watch(self.gdocs_folder, pyinotify.IN_MODIFY, rec=True)\n \n handler = EventHandler(self)\n notifier = pyinotify.Notifier(wm, handler)\n \n print 'waiting for changes . . .'\n notifier.loop()", ...
[ "0.6876409", "0.68680036", "0.64799684", "0.6349804", "0.6330774", "0.62145215", "0.6179047", "0.61642784", "0.6136405", "0.6117507", "0.6073316", "0.6064468", "0.6056099", "0.5972339", "0.5963462", "0.5934348", "0.59193623", "0.59006125", "0.5864853", "0.5843844", "0.5831716...
0.6089402
10
Get unique list of new config files in watch dir.
def get_config(self): config = set() while True: filenames = self.get_config_files() for fn in filenames: if fn not in self.watch_names: filenames.remove(fn) if fn in config: filenames.remove(fn) # If we did not find any new config files, exit loop. if not filenames: break # Save the config files we found, sleep, then look again. config.update(filenames) # Sleep a bit to allow for settling. We loop until no new # config files are found. time.sleep(1.0) return config
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_config_files(self):\n flag, i = self.inotify\n\n if flag:\n kwargs = {}\n\n if PY3:\n kwargs['timeout_s'] = 0\n\n filenames = set()\n\n for event in i.event_gen(**kwargs):\n if event is None:\n break\...
[ "0.7831209", "0.70418906", "0.66463995", "0.6577422", "0.64742094", "0.64292943", "0.64021975", "0.6402068", "0.63111544", "0.62958807", "0.6260233", "0.61890477", "0.61561424", "0.61066765", "0.610564", "0.6097907", "0.6075739", "0.6075056", "0.6053437", "0.6035494", "0.6028...
0.7109554
1
Kill the running command.
def kill(self): if self.process is not None: LOGGER.info('Killing command...') self.process.kill() self.process = None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def kill(self):\n\n self.proc.kill()", "def kill(self):\n self._process.kill()", "def kill(self):\n self._stop_proc(signal.SIGKILL)", "def kill(self):\n self._update()\n if self.running_mode == \"local\":\n for process in self.processes:\n try:\n ...
[ "0.7861475", "0.7555022", "0.749188", "0.7406674", "0.72241443", "0.7057569", "0.7053252", "0.7020611", "0.7016701", "0.69516635", "0.693628", "0.6888209", "0.6873801", "0.6854114", "0.6798234", "0.6792874", "0.67909163", "0.6775448", "0.674491", "0.6723775", "0.6702169", "...
0.8239272
0
Run test command to verify configuration.
def test_command(self, quiet=True): # If there is no test command, assume the config is good to go. if self.test is None: return True # Attempt parse. kwargs = {} if quiet: kwargs['stdout'] = DEVNULL kwargs['stderr'] = subprocess.STDOUT return subprocess.call(shlex.split(self.test), **kwargs) == 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Checktest(self, expectedoutput):\n\n if expectedoutput == 0:\n result = self.runner.invoke(yoda.cli, [\"setup\", \"check\"])\n self.assertEqual(result.exit_code, 0)\n self.assertIn(\"The configuration file does not exist.\", result.output)\n return\n\n ...
[ "0.69138324", "0.67915976", "0.6790115", "0.67689073", "0.6737845", "0.6722288", "0.6666319", "0.66587526", "0.65559405", "0.6525426", "0.651796", "0.65171564", "0.64026606", "0.6394368", "0.6387093", "0.6379195", "0.63411385", "0.6338479", "0.630961", "0.62860626", "0.621526...
0.6250256
20
Backs up entire configuration.
def backup_config(self): prev_config = set() for src in self.config: dst = '%s.prev' % src LOGGER.debug('Backing up %s to %s', src, dst) try: shutil.copy(src, dst) except IOError as e: if e.errno != errno.ENOENT: raise # If the config file is missing, we can skip backing it up. LOGGER.warning('File %s missing, skipping backup', src) else: prev_config.add(dst) return prev_config
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def backup(config_file, bakfile):\n return _backup_config(config_file, bakfile)", "def backup(ctx, project, origin, force):\n\n if not check_main_conf(ctx):\n return\n\n if origin is not None and project is None:\n click.echo(\"--project option is required when --origin is set.\")\n ...
[ "0.6370239", "0.62242675", "0.61583614", "0.61377156", "0.6079129", "0.60359734", "0.59865093", "0.59671223", "0.59083843", "0.5764068", "0.5725047", "0.5714281", "0.56883514", "0.56292564", "0.5621002", "0.5616206", "0.5596354", "0.5594662", "0.55940187", "0.5514033", "0.549...
0.6756827
0
Remove backup once command is restarted.
def remove_config(self, config): for fn in config: try: os.remove(fn) LOGGER.debug('Removed backup: %s', fn) except IOError as e: if e.errno != errno.ENOENT: LOGGER.warning('Could not remove backup: %s', fn)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __removeBackup(self):\n pass #FIXME!!", "def delete_old_backup(self):\n print \"### Info ### Delete redundant backups\"\n for i in range(len(self.date_list)-20):\n os.remove(os.path.abspath(self.backup_path + U'/voc2brain_backup_' + str(self.date_list[0])+ \".sdb3\") )", "de...
[ "0.8196065", "0.70776635", "0.6619657", "0.63696575", "0.62427235", "0.61607236", "0.613132", "0.61143297", "0.61006206", "0.60654944", "0.6063608", "0.60433877", "0.6026956", "0.59964967", "0.5993778", "0.59595126", "0.5955549", "0.5950114", "0.58985144", "0.5865423", "0.585...
0.5485173
58
Restores a previous config backup.
def restore_config(self, config): for src in config: # Remove .prev dst, _ = splitext(src) LOGGER.debug('Restoring %s from %s', dst, src) shutil.move(src, dst)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __restoreBackup(self):\n pass #FIXME!!!", "def restore_config(self):\n self._clear_previous_windows_assigment()\n self._restart_i3_config()", "def restore_backup():\n\n # restore vim configuration folder\n if exists('.vim-bkp'):\n print(green('Restoring your vim configurat...
[ "0.72900516", "0.7256316", "0.7031564", "0.68569666", "0.67252886", "0.6492015", "0.6481564", "0.64403677", "0.64377254", "0.63916713", "0.6362085", "0.6353648", "0.6302588", "0.62942183", "0.6231615", "0.62304366", "0.618073", "0.6173418", "0.6165256", "0.6148223", "0.608969...
0.68605244
3
Copy new configuration to location service expects.
def install_config(self, config): for fn in config: dst = [p for p in self.config if basename(p) == fn][0] src = pathjoin(self.watch, fn) try: os.makedirs(dirname(dst)) except OSError as e: if e.errno != errno.EEXIST: raise LOGGER.debug('Overwriting %s with %s', src, dst) shutil.move(src, dst) if self.chown is not None: os.chown(dst, *self.chown) if self.chmod is not None: os.chmod(dst, self.chmod)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _prepare(self):\n logging.info('-> copy configuration...')\n path_cofig = self.params['path_config_bUnwarpJ']\n shutil.copy(path_cofig, os.path.join(self.params['path_exp'],\n os.path.basename(path_cofig)))\n if 'path_config_IJ_SIFT' in se...
[ "0.66751164", "0.6538778", "0.6319601", "0.6304055", "0.6287822", "0.6230367", "0.62281555", "0.6134705", "0.6039623", "0.6001801", "0.59539455", "0.59479195", "0.5938517", "0.5936677", "0.5883111", "0.5872014", "0.5860854", "0.5835609", "0.58065426", "0.5762701", "0.5741781"...
0.5214433
95
Backup old config, write new config, test config, HUP or restore.
def test_and_swap(self, config): LOGGER.info('Attempting to apply new configuration') backup = self.backup_config() # We have backed up ALL config files (not just the ones we might # replace). If any error occurs from here out, we will need to restore # our config, so we will use exception handling. try: self.install_config(config) # We have now merged in our new configuration files, lets test this # config. if self.test_command(quiet=False): LOGGER.debug('Configuration good, reloading') self.reload_command() self.remove_config(backup) else: LOGGER.info('Configuration bad, restoring') self.restore_config(backup) except Exception: LOGGER.exception('Failure, restoring config', exc_info=True) self.restore_config(backup)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _backup_config(config_file, bak_path=None):\n try:\n if not bak_path:\n bak_path = config_file+\".bak\"\n with open(config_file, 'r') as oldfile, open(bak_path, 'w') as bakfile:\n tmp = oldfile.read(1024)\n while tmp:\n bakfile.write(tmp)\n ...
[ "0.7156795", "0.7003359", "0.67606544", "0.6459555", "0.64326864", "0.63440835", "0.63262016", "0.63146156", "0.62513983", "0.6244165", "0.6195551", "0.61006075", "0.60527635", "0.6048218", "0.60470015", "0.60405976", "0.6031093", "0.59871054", "0.5954373", "0.59194183", "0.5...
0.72788405
0
Plot and save histograms from predicted steerings and real steerings. Arguments
def make_and_save_histogramsX(pred_steerings, real_steerings, img_name = "histogramsX.png"): pred_steerings = np.array(pred_steerings) real_steerings = np.array(real_steerings) max_h = np.maximum(np.max(pred_steerings), np.max(real_steerings)) min_h = np.minimum(np.min(pred_steerings), np.min(real_steerings)) bins = np.linspace(min_h, max_h, num=50) plt.hist(pred_steerings, bins=bins, alpha=0.5, label='Predicted', color='b') plt.hist(real_steerings, bins=bins, alpha=0.5, label='Real', color='r') #plt.title('Steering angle') plt.legend(fontsize=10) plt.savefig(img_name, bbox_inches='tight')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_and_save_histogramsY(pred_steerings, real_steerings,\n img_name = \"histogramsY.png\"):\n pred_steerings = np.array(pred_steerings)\n real_steerings = np.array(real_steerings)\n max_h = np.maximum(np.max(pred_steerings), np.max(real_steerings))\n min_h = np.minimum(...
[ "0.76754117", "0.64281666", "0.6419849", "0.63231015", "0.6262315", "0.62221205", "0.6151655", "0.6125331", "0.6123557", "0.61125845", "0.6079311", "0.60636973", "0.6062547", "0.6060509", "0.6034784", "0.6033427", "0.60138935", "0.6013693", "0.6010012", "0.59823984", "0.59726...
0.7740116
0
Plot and save histograms from predicted steerings and real steerings. Arguments
def make_and_save_histogramsY(pred_steerings, real_steerings, img_name = "histogramsY.png"): pred_steerings = np.array(pred_steerings) real_steerings = np.array(real_steerings) max_h = np.maximum(np.max(pred_steerings), np.max(real_steerings)) min_h = np.minimum(np.min(pred_steerings), np.min(real_steerings)) bins = np.linspace(min_h, max_h, num=50) plt.hist(pred_steerings, bins=bins, alpha=0.5, label='Predicted', color='b') plt.hist(real_steerings, bins=bins, alpha=0.5, label='Real', color='r') #plt.title('Steering angle') plt.legend(fontsize=10) plt.savefig(img_name, bbox_inches='tight')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_and_save_histogramsX(pred_steerings, real_steerings,\n img_name = \"histogramsX.png\"):\n pred_steerings = np.array(pred_steerings)\n real_steerings = np.array(real_steerings)\n max_h = np.maximum(np.max(pred_steerings), np.max(real_steerings))\n min_h = np.minimum(...
[ "0.7740603", "0.6428022", "0.6419536", "0.6322531", "0.62623787", "0.62226415", "0.61514246", "0.61257786", "0.6123551", "0.6112254", "0.6079733", "0.6064892", "0.6062117", "0.60601425", "0.6035143", "0.6033051", "0.601378", "0.6013595", "0.6009719", "0.5982897", "0.59727293"...
0.7675895
1
Plot and save confusion matrix computed from predicted and real labels. Arguments
def plot_confusion_matrix(real_labels, pred_prob, classes, normalize=False, img_name="confusion.png"): real_labels = np.array(real_labels) # Binarize predicted probabilities pred_prob = np.array(pred_prob) pred_labels = np.zeros_like(pred_prob) pred_labels[pred_prob >= 0.5] = 1 cm = confusion_matrix(real_labels, pred_labels) plt.figure() plt.imshow(cm, interpolation='nearest', cmap=plt.cm.Blues) #plt.title("Confusion matrix") plt.colorbar() tick_marks = np.arange(len(classes)) plt.xticks(tick_marks, classes) plt.yticks(tick_marks, classes, rotation=90) if normalize: cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis] thresh = cm.max() / 2. for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])): plt.text(j, i, cm[i, j], horizontalalignment="center", color="white" if cm[i, j] > thresh else "black") plt.tight_layout() plt.ylabel('True label') plt.xlabel('Predicted label') plt.savefig(img_name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_confusion_matrix(self, y_true, y_pred, title=None):\r\n\r\n if not title:\r\n title = 'confusion matrix'\r\n\r\n # Compute confusion matrix\r\n\r\n y_pred = np.array(y_pred)\r\n y_true = np.array(y_true)\r\n cm = confusion_matrix(y_true, y_pred)\r\n # O...
[ "0.7909803", "0.77706945", "0.7693289", "0.7669506", "0.7644297", "0.7616977", "0.757757", "0.75686", "0.7555622", "0.7483602", "0.74831176", "0.74774474", "0.7476126", "0.7471495", "0.7468893", "0.7465456", "0.74556404", "0.7446722", "0.74444157", "0.7443814", "0.74419767", ...
0.7841449
1
Set up Tasmota sensor dynamically through discovery.
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_discover_sensor(tasmota_entity, discovery_hash): """Discover and add a Tasmota sensor.""" async_add_entities( [ TasmotaSensor( tasmota_entity=tasmota_entity, discovery_hash=discovery_hash ) ] ) hass.data[ DATA_REMOVE_DISCOVER_COMPONENT.format(sensor.DOMAIN) ] = async_dispatcher_connect( hass, TASMOTA_DISCOVERY_ENTITY_NEW.format(sensor.DOMAIN, TASMOTA_DOMAIN), async_discover_sensor, )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def async_discover_sensor(tasmota_entity, discovery_hash):\n async_add_entities(\n [\n TasmotaSensor(\n tasmota_entity=tasmota_entity, discovery_hash=discovery_hash\n )\n ]\n )", "def setup_sensors(self):\n self._ta...
[ "0.6551506", "0.64838266", "0.64127916", "0.63373846", "0.6302272", "0.62259805", "0.6224144", "0.61740553", "0.61011136", "0.6077729", "0.60729074", "0.6011457", "0.5998973", "0.5998924", "0.599695", "0.5978081", "0.59712714", "0.59689814", "0.5960322", "0.5929455", "0.59252...
0.5853148
24
Discover and add a Tasmota sensor.
async def async_discover_sensor(tasmota_entity, discovery_hash): async_add_entities( [ TasmotaSensor( tasmota_entity=tasmota_entity, discovery_hash=discovery_hash ) ] )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def async_add_binary_sensor(mac):\n if USB_MOTION_ID in api_stick.devices[mac].features:\n _LOGGER.debug(\"Add binary_sensors for %s\", mac)\n async_add_entities([USBBinarySensor(api_stick.devices[mac])])\n\n # Register services\n platform.async_register_ent...
[ "0.6059688", "0.583049", "0.5694654", "0.5584414", "0.5579093", "0.55689627", "0.55304766", "0.5517644", "0.55015105", "0.550125", "0.5478783", "0.54301524", "0.54066986", "0.5383559", "0.5372278", "0.5371746", "0.5358791", "0.53568757", "0.53443986", "0.5335553", "0.5331908"...
0.65760076
0
Initialize the Tasmota sensor.
def __init__(self, **kwds): self._state = None super().__init__( discovery_update=self.discovery_update, **kwds, )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n\n super().__init__()\n\n self.active = True\n self.driver = Driver.instance()\n self.sensor_manager = SensorManager.instance()\n\n self.pwm = Adafruit_PCA9685.PCA9685(address=0x40, busnum=1) # create PCA9685-object at I2C-port\n self.pwm.set_pwm_freq...
[ "0.61697245", "0.5928329", "0.5887117", "0.5875876", "0.586315", "0.5852638", "0.5817024", "0.57665086", "0.576379", "0.5753676", "0.57419896", "0.5735377", "0.5708823", "0.5682858", "0.5679623", "0.56617826", "0.5624354", "0.5596242", "0.55879885", "0.5565041", "0.5562199", ...
0.0
-1
Return the device class of the sensor.
def device_class(self) -> Optional[str]: class_or_icon = SENSOR_DEVICE_CLASS_ICON_MAP.get( self._tasmota_entity.quantity, {} ) return class_or_icon.get(DEVICE_CLASS)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def device_class(self):\n return self.sensor_type[\"class\"]", "def device_class(self):\n return SENSOR_TYPES[self.sensor][3].get(\"device_class\")", "def device_class(self):\n return self._sensor_type", "def device_class(self):\r\n return self._sensor_cfg[3]", "def device_class...
[ "0.93628424", "0.92430294", "0.9240069", "0.9161452", "0.9161452", "0.9156968", "0.90412056", "0.90412056", "0.8956785", "0.89529496", "0.8950599", "0.8919914", "0.871994", "0.8717259", "0.87069035", "0.8660478", "0.8652474", "0.83961546", "0.83828783", "0.8380708", "0.838070...
0.81339943
31
Return if the entity should be enabled when first added to the entity registry.
def entity_registry_enabled_default(self) -> bool: # Hide status sensors to not overwhelm users if self._tasmota_entity.quantity in status_sensor.SENSORS: return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _enabled_entity_exists(self) -> bool:\n return self.entity_exists(self._enabled_toggle_entity_id)", "def entity_registry_enabled_default(self) -> bool:\n return self._enabled_default", "def entity_registry_enabled_default(self) -> bool:\n return False", "def entity_registry_enabled_defau...
[ "0.76484686", "0.7445516", "0.7369543", "0.7279766", "0.7243998", "0.7243998", "0.72242576", "0.702323", "0.68542576", "0.6784123", "0.67786515", "0.66620255", "0.6639556", "0.6639556", "0.6639556", "0.6639556", "0.6639556", "0.6639556", "0.66098607", "0.65822154", "0.6575364...
0.7130893
7
Return the state of the entity.
def state(self): return self._state
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def state(self):\n return self.get_state()", "def state(self):\n result = self.getResult()\n return result.state", "def getState(self) :\n return self.state", "def getState(self):\n return self.state", "def getState(self):\n return self.state", "def getState(self...
[ "0.770336", "0.7654755", "0.76498735", "0.7620778", "0.7620778", "0.7620778", "0.75572854", "0.75572854", "0.74765974", "0.7446079", "0.7446079", "0.7413098", "0.7413098", "0.73877645", "0.73821914", "0.73821914", "0.73821914", "0.73821914", "0.73821914", "0.73806906", "0.735...
0.727765
94
Return the unit this state is expressed in.
def unit_of_measurement(self): return self._tasmota_entity.unit
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_unit(self):\n return self.unit", "def unit(self):\n return self._unit", "def unit(self):\n return self._unit", "def unit(self):\n return self._unit", "def unit(self):\n return self.__unit", "def unit(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"...
[ "0.8381375", "0.82579356", "0.82013446", "0.82013446", "0.81742126", "0.791395", "0.7801508", "0.7801508", "0.7801508", "0.7801508", "0.7801508", "0.7801508", "0.7801508", "0.7801508", "0.7801508", "0.7801508", "0.7801508", "0.7801508", "0.7801508", "0.7801508", "0.7801508", ...
0.8035094
5
Set up the Garmin Connect component.
async def async_setup(hass: HomeAssistant, config: dict): hass.data[DOMAIN] = {} return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connect(self):\n pass", "def connect(self):\n pass", "def connect(self):\n pass", "def connect(self):\n pass", "def connect(self):\n pass", "def connect(self):\n pass", "def connect(self):\n pass", "def connect(self):\n pass", "def connect...
[ "0.62827325", "0.62827325", "0.62827325", "0.62827325", "0.62827325", "0.62827325", "0.62827325", "0.62827325", "0.62815505", "0.61928016", "0.61755365", "0.6139352", "0.6137068", "0.61368144", "0.6065569", "0.60075444", "0.5984593", "0.59311897", "0.59311897", "0.5917158", "...
0.0
-1
Set up Garmin Connect from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): username = entry.data[CONF_USERNAME] password = entry.data[CONF_PASSWORD] garmin_client = Garmin(username, password) try: await hass.async_add_executor_job(garmin_client.login) except ( GarminConnectAuthenticationError, GarminConnectTooManyRequestsError, ) as err: _LOGGER.error("Error occurred during Garmin Connect login request: %s", err) return False except (GarminConnectConnectionError) as err: _LOGGER.error( "Connection error occurred during Garmin Connect login request: %s", err ) raise ConfigEntryNotReady from err except Exception: # pylint: disable=broad-except _LOGGER.exception("Unknown error occurred during Garmin Connect login request") return False garmin_data = GarminConnectData(hass, garmin_client) hass.data[DOMAIN][entry.entry_id] = garmin_data for component in PLATFORMS: hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, component) ) return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_config(config_name, host, port, core=''):\n global CONFIGS\n CONFIGS[config_name] = {'host': host, 'port': port, 'core': core}", "def setup():\n\tglobal config_parser, config_file\n\tglobal prefix\n\n\tif os.path.islink(sys.argv[0]):\n\t\tlink = os.readlink(sys.argv[0])\n\n\t\tif not os.path.isabs(...
[ "0.62775207", "0.60732806", "0.5851702", "0.58259803", "0.5785242", "0.57221854", "0.57136893", "0.56654847", "0.56587076", "0.56587076", "0.56514394", "0.5620723", "0.55982435", "0.5576343", "0.55624145", "0.5553576", "0.55496615", "0.554902", "0.554902", "0.5542576", "0.552...
0.5439701
30
Unload a config entry.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(entry, component) for component in PLATFORMS ] ) ) if unload_ok: hass.data[DOMAIN].pop(entry.entry_id) return unload_ok
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def async_unload_entry(hass, config_entry):\n unload_ok = await hass.config_entries.async_forward_entry_unload(\n config_entry, \"climate\"\n )\n return unload_ok", "async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:\n hass.data.pop(DOMAIN)\n return True", ...
[ "0.697284", "0.6888074", "0.6779855", "0.6747459", "0.6689002", "0.6657831", "0.66162205", "0.6603433", "0.65925974", "0.65595686", "0.65411645", "0.6507643", "0.6507643", "0.6507643", "0.6507643", "0.64977276", "0.64931643", "0.6486601", "0.6486601", "0.6486601", "0.6486601"...
0.6459733
28
Update data via library.
async def async_update(self): today = date.today() try: self.data = await self.hass.async_add_executor_job( self.client.get_stats_and_body, today.isoformat() ) except ( GarminConnectAuthenticationError, GarminConnectTooManyRequestsError, GarminConnectConnectionError, ) as err: _LOGGER.error( "Error occurred during Garmin Connect get activity request: %s", err ) return except Exception: # pylint: disable=broad-except _LOGGER.exception( "Unknown error occurred during Garmin Connect get activity request" ) return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_data():\n pass", "def update(self, data):\n pass", "def update(self, data):\n pass", "def update(self, data):\n pass", "def update(self, data):\n pass", "def update(self, data):\n self.data.update(data)", "def update(self, data):\n return ...
[ "0.8435785", "0.8008672", "0.8008672", "0.8008672", "0.8008672", "0.7589883", "0.7447164", "0.7291235", "0.7291235", "0.72886306", "0.72539234", "0.7127528", "0.71165633", "0.7108259", "0.7090543", "0.7049341", "0.7018547", "0.7013633", "0.69404083", "0.69404083", "0.69404083...
0.0
-1
Installs the OpenMPI package on the VM.
def _Install(vm): vm.Install('build_tools') vm.Install('wget') vm.RemoteCommand('wget %s -P %s' % (MPI_URL, INSTALL_DIR)) vm.RemoteCommand('cd %s && tar xvfz %s' % (INSTALL_DIR, MPI_TAR)) make_jobs = vm.NumCpusForBenchmark() shared_lib_command = ('--enable-shared' if FLAGS.openmpi_enable_shared else '--disable-shared') if FLAGS.openmpi_with_cuda_support: cuda_cmd = ('--with-cuda=/usr/local/cuda-{version}/ ' '--with-cuda-libdir=/usr/local/cuda-{version}/lib64/'.format( version=FLAGS.cuda_toolkit_version)) else: cuda_cmd = '' config_cmd = ( './configure --enable-static {shared_lib_cmd} --prefix=/usr ' '{cuda_cmd}'.format(shared_lib_cmd=shared_lib_command, cuda_cmd=cuda_cmd)) vm.RobustRemoteCommand( 'cd %s && %s && make -j %s && sudo make install' % (MPI_DIR, config_cmd, make_jobs))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def AptInstall(vm):\n vm.RobustRemoteCommand('sudo apt-get {}'.format(REMOVE_MPI_CMD))\n _Install(vm)", "def YumInstall(vm):\n vm.RobustRemoteCommand('sudo yum {}'.format(REMOVE_MPI_CMD))\n _Install(vm)", "def install():\n PackCommandExecutor().pack()\n InstallCommandExecutor().install()", "def ins...
[ "0.749848", "0.6820002", "0.6406495", "0.6319433", "0.62312424", "0.61590135", "0.61590135", "0.6028888", "0.59898764", "0.5981365", "0.5926291", "0.59055406", "0.5884631", "0.58507264", "0.5765704", "0.5713537", "0.57048243", "0.5699972", "0.5699972", "0.5667024", "0.5660338...
0.80011517
0
Installs the OpenMPI package on the VM.
def YumInstall(vm): vm.RobustRemoteCommand('sudo yum {}'.format(REMOVE_MPI_CMD)) _Install(vm)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _Install(vm):\n vm.Install('build_tools')\n vm.Install('wget')\n vm.RemoteCommand('wget %s -P %s' % (MPI_URL, INSTALL_DIR))\n vm.RemoteCommand('cd %s && tar xvfz %s' % (INSTALL_DIR, MPI_TAR))\n make_jobs = vm.NumCpusForBenchmark()\n shared_lib_command = ('--enable-shared' if FLAGS.openmpi_enable_shared\n...
[ "0.80011517", "0.749848", "0.6406495", "0.6319433", "0.62312424", "0.61590135", "0.61590135", "0.6028888", "0.59898764", "0.5981365", "0.5926291", "0.59055406", "0.5884631", "0.58507264", "0.5765704", "0.5713537", "0.57048243", "0.5699972", "0.5699972", "0.5667024", "0.566033...
0.6820002
2
Installs the OpenMPI package on the VM.
def AptInstall(vm): vm.RobustRemoteCommand('sudo apt-get {}'.format(REMOVE_MPI_CMD)) _Install(vm)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _Install(vm):\n vm.Install('build_tools')\n vm.Install('wget')\n vm.RemoteCommand('wget %s -P %s' % (MPI_URL, INSTALL_DIR))\n vm.RemoteCommand('cd %s && tar xvfz %s' % (INSTALL_DIR, MPI_TAR))\n make_jobs = vm.NumCpusForBenchmark()\n shared_lib_command = ('--enable-shared' if FLAGS.openmpi_enable_shared\n...
[ "0.80011517", "0.6820002", "0.6406495", "0.6319433", "0.62312424", "0.61590135", "0.61590135", "0.6028888", "0.59898764", "0.5981365", "0.5926291", "0.59055406", "0.5884631", "0.58507264", "0.5765704", "0.5713537", "0.57048243", "0.5699972", "0.5699972", "0.5667024", "0.56603...
0.749848
1
Uninstalls the OpenMPI package on the VM.
def _Uninstall(vm): vm.RemoteCommand('cd {0} && sudo make uninstall'.format(MPI_DIR))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def AptUninstall(vm):\n remove_str = 'sudo apt-get --purge autoremove -y '\n for package in APT_PACKAGES:\n vm.RemoteCommand(remove_str + package)", "def AptUninstall(vm):\n _Uninstall(vm)", "def YumUninstall(vm):\n _Uninstall(vm)", "def _unprovision_node(self, conn):\n conn.run(f\"rm -rf {EXPO...
[ "0.6643343", "0.6554691", "0.6437639", "0.61634016", "0.61421573", "0.6033786", "0.6024719", "0.5982157", "0.59412205", "0.59231645", "0.5891756", "0.5881228", "0.5796456", "0.5779653", "0.57771873", "0.57449394", "0.5722418", "0.57108957", "0.5706674", "0.56761074", "0.56503...
0.8364465
0
Uninstalls the OpenMPI package on the VM.
def YumUninstall(vm): _Uninstall(vm)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _Uninstall(vm):\n vm.RemoteCommand('cd {0} && sudo make uninstall'.format(MPI_DIR))", "def AptUninstall(vm):\n remove_str = 'sudo apt-get --purge autoremove -y '\n for package in APT_PACKAGES:\n vm.RemoteCommand(remove_str + package)", "def AptUninstall(vm):\n _Uninstall(vm)", "def _unprovision_no...
[ "0.8364465", "0.6643343", "0.6554691", "0.61634016", "0.61421573", "0.6033786", "0.6024719", "0.5982157", "0.59412205", "0.59231645", "0.5891756", "0.5881228", "0.5796456", "0.5779653", "0.57771873", "0.57449394", "0.5722418", "0.57108957", "0.5706674", "0.56761074", "0.56503...
0.6437639
3
Uninstalls the OpenMPI package on the VM.
def AptUninstall(vm): _Uninstall(vm)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _Uninstall(vm):\n vm.RemoteCommand('cd {0} && sudo make uninstall'.format(MPI_DIR))", "def AptUninstall(vm):\n remove_str = 'sudo apt-get --purge autoremove -y '\n for package in APT_PACKAGES:\n vm.RemoteCommand(remove_str + package)", "def YumUninstall(vm):\n _Uninstall(vm)", "def _unprovision_no...
[ "0.8364465", "0.6643343", "0.6437639", "0.61634016", "0.61421573", "0.6033786", "0.6024719", "0.5982157", "0.59412205", "0.59231645", "0.5891756", "0.5881228", "0.5796456", "0.5779653", "0.57771873", "0.57449394", "0.5722418", "0.57108957", "0.5706674", "0.56761074", "0.56503...
0.6554691
2
Sample from Gumbel(0, 1)
def sample_gumbel(shape, eps=1e-10): U = torch.rand(shape).float() return - torch.log(eps - torch.log(U + eps))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sample(self):\n return self._root.sample()", "def _sample_gumbel(self, shape, eps=1e-20):\r\n U = tf.random_uniform(shape, minval=0, maxval=1)\r\n return -tf.log(-tf.log(U + eps) + eps)", "def _sample_gumbel(shape, eps=1e-10, out=None):\n if out is None:\n U = torch.rand(shape)\n...
[ "0.7220574", "0.716382", "0.71507114", "0.70995146", "0.699274", "0.6973968", "0.6961668", "0.6939623", "0.69043535", "0.69043535", "0.68841726", "0.6842815", "0.68167746", "0.6810973", "0.6809102", "0.6749228", "0.6749228", "0.670747", "0.6694305", "0.6573771", "0.65735567",...
0.712813
3
Draw a sample from the GumbelSoftmax distribution
def gumbel_softmax_sample(logits, tau=1, eps=1e-10): gumbel_noise = sample_gumbel(logits.size(), eps=eps).to(logits.device) y = logits + gumbel_noise return F.softmax(y / tau, dim=-1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __call__(self,logits):\n \n #sample from Gumbel(0, 1)\n uniform = self._srng.uniform(logits.shape,low=0,high=1)\n gumbel = -T.log(-T.log(uniform + self.eps) + self.eps)\n \n #draw a sample from the Gumbel-Softmax distribution\n return T.nnet.softmax((log...
[ "0.6941609", "0.6940321", "0.67074233", "0.67074233", "0.6654661", "0.6653647", "0.66407585", "0.66212577", "0.6611909", "0.66037244", "0.6586376", "0.6510714", "0.64653856", "0.64653856", "0.6389543", "0.6238159", "0.62353337", "0.62065417", "0.620225", "0.61525905", "0.6108...
0.5875712
28
Sample from the GumbelSoftmax distribution and optionally discretize.
def gumbel_softmax(logits, tau=1, hard=False, eps=1e-10): y_soft = gumbel_softmax_sample(logits, tau=tau, eps=eps) if hard: shape = logits.size() _, k = y_soft.data.max(-1) # this bit is based on # https://discuss.pytorch.org/t/stop-gradients-for-st-gumbel-softmax/530/5 y_hard = torch.zeros(*shape).to(logits.device) y_hard = y_hard.zero_().scatter_(-1, k.view(shape[:-1] + (1,)), 1.0) # this cool bit of code achieves two things: # - makes the output value exactly one-hot (since we add then # subtract y_soft value) # - makes the gradient equal to y_soft gradient (since we strip # all other gradients) y = Variable(y_hard - y_soft.data) + y_soft # TODO: test this works else: y = y_soft return y
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __call__(self,logits):\n \n #sample from Gumbel(0, 1)\n uniform = self._srng.uniform(logits.shape,low=0,high=1)\n gumbel = -T.log(-T.log(uniform + self.eps) + self.eps)\n \n #draw a sample from the Gumbel-Softmax distribution\n return T.nnet.softmax((log...
[ "0.6209665", "0.6097411", "0.6038015", "0.6031522", "0.6009968", "0.60037225", "0.5969186", "0.59546846", "0.594529", "0.59424144", "0.59238946", "0.5917662", "0.5917157", "0.58992356", "0.58821446", "0.58690953", "0.5866002", "0.5855132", "0.5850308", "0.58380175", "0.582960...
0.0
-1
This function opens the database.txt file and checks all the entries and returns a line in the database.txt file
def getbook(): #Opens the database file to read the lines with open("database.txt", "r") as f: #Iterates through each line and splits the line into individual strings for line in f: s=line.strip() string=s.split(":") return(string)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_database(self):\n # open the database\n f = open('KISS_LINES','r')\n # make a list which will contain lines\n tlc = []\n for row in f:\n tlc.append(f.readline())\n f.close()\n\n return tlc", "def lookForDB():\n done = False\n msg = \"\"\n...
[ "0.61832035", "0.61019087", "0.5959006", "0.5931096", "0.5930615", "0.5808133", "0.57629114", "0.5742603", "0.5694034", "0.56101996", "0.5608124", "0.5526544", "0.5519519", "0.5513351", "0.5489417", "0.54727405", "0.54715866", "0.54519093", "0.5449876", "0.5423103", "0.541830...
0.6053122
2
This method provides an ability to set order book's deep on the fly. If some of deep's parameters is <0 (bid_count or ask_count) then method raise the custom ChangeOrderBookDeepError exception.
def set_deep(self, deep: Deep) -> None: def is_deep_invalid(var: Deep): return not isinstance(var, Deep) \ or False in [str(value).isdigit() for value in deep.__dict__.values()] \ or deep.bid_count < 0 \ or deep.ask_count < 0 # Exit rule if is_deep_invalid(deep): raise ChangeOrderBookDeepError(deep) self.deep = deep
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_overflow_bids_market_default_depth(new_order_book: Callable[[], OrderBook]) -> NoReturn:\n book = new_order_book\n\n for _ in range(book.depth):\n book.add_offer('bids', 1, 1)\n\n assert book.depth == len(book.bids)\n assert not book.asks\n\n # try to put 21th lot into bids\n with...
[ "0.5391954", "0.52650684", "0.5231182", "0.5148186", "0.46605176", "0.46045893", "0.4553652", "0.44586703", "0.43845412", "0.43609735", "0.4305438", "0.42446724", "0.42142078", "0.40942338", "0.40583956", "0.40488294", "0.40381512", "0.4022892", "0.4010043", "0.40016043", "0....
0.79812324
0
This method provide an ability to place an order in order book. After each addition of order the list will be resorted by price (first orders contains the highest price)
def place_order(self, order: Order) -> None: if order.id in [order.id for order in self.orders]: raise OrderAlreadyCreatedError(order) if not order.symbol.is_enabled: raise SymbolIsNotEnabledError(order.symbol) t = Thread(target=self.__place_order, args=(order,)) t.start() self.__sort_orders_by_price()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __sort_orders_by_price(self):\n self.orders = sorted(self.orders, key=lambda o: o.price, reverse=True)", "def order(self, order):\n\n #print(\"Evaluating order: \", order)\n if self.security != order.secid:\n raise (\"Cannot place order for security \"\n \"%s...
[ "0.72955734", "0.72195446", "0.71405244", "0.68157446", "0.68157446", "0.66305166", "0.6570422", "0.64215416", "0.6358998", "0.6337733", "0.62889314", "0.6281809", "0.6275868", "0.6248093", "0.62321734", "0.6133264", "0.6128235", "0.61075634", "0.60340667", "0.6027881", "0.59...
0.6340491
9
Private method that provide an ability to sort the orders by price
def __sort_orders_by_price(self): self.orders = sorted(self.orders, key=lambda o: o.price, reverse=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_ordering_by_price_desc(self):\n request = self.factory.get('/api/v1/cars', {'distance': 10000,\n 'ordering': '-price'})\n response = CarAdViewSet.as_view({'get': 'list'})(request)\n self.assertEqual(response.status_code, HTTPStatus.OK...
[ "0.6997947", "0.6924603", "0.68009967", "0.64891934", "0.64143217", "0.6405557", "0.63602364", "0.62634486", "0.6196882", "0.61302906", "0.60694", "0.6041694", "0.5944023", "0.5943299", "0.5924566", "0.59217286", "0.5914415", "0.59045845", "0.58919334", "0.58767736", "0.58767...
0.8428332
0
This method provide an ability to get order from order book by order action (sell or buy). By other words you can get asks or bids here.
def get_orders_by_action(self, action: OrderAction, count: int = None) -> list: if not isinstance(count, int) and count is not None: return list() return [order for order in self.orders if order.action == action][:count]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def order_book_fetch(self, symbol):\n orderbook = self.orderbooks[symbol]\n asks = [[float(price), float(stats[0]) * float(stats[1])] for price, stats in orderbook['asks'].items()]\n bids = [[float(price), float(stats[0]) * float(stats[1])] for price, stats in orderbook['bids'].items()]\n ...
[ "0.71501344", "0.6836726", "0.6609372", "0.65721977", "0.63465905", "0.6233696", "0.6085227", "0.6083367", "0.60727364", "0.6054158", "0.60227066", "0.6011243", "0.5949031", "0.5942736", "0.59371984", "0.593053", "0.5894108", "0.58863455", "0.58636063", "0.58327985", "0.58307...
0.58196706
21
This method provide an ability to find order by id and reject it.
def reject_order(self, order: Order) -> None: order = self.get_order_by_id(order.id) order.status = OrderStatus.REJECT
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _on_order_not_found(self, msg):\r\n parts = msg[\"id\"].split(\":\")\r\n oid = parts[1]\r\n self.debug(\"### got 'Order not found' for\", oid)\r\n # we are now going to fake a user_order message (the one we\r\n # obviously missed earlier) that will have the effect of\r\n ...
[ "0.6331195", "0.6186556", "0.6181075", "0.6084242", "0.5875732", "0.57537323", "0.5748262", "0.5568031", "0.5513399", "0.5510577", "0.5493943", "0.54261667", "0.54258156", "0.5360014", "0.52910525", "0.5274176", "0.52361274", "0.51995444", "0.5193858", "0.51862836", "0.516938...
0.65955037
0
This method provide an ability to fill order in order book. This action means that order is completed.
def fill_order(self, order: Order) -> None: order = self.get_order_by_id(order.id) order.status = OrderStatus.FILL
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def complete_order(order):\n enroll_user_in_order_items(order)\n\n # If this order included assigned coupons, update them to indicate that they're redeemed\n order_coupon_ids = order.couponredemption_set.values_list(\n \"coupon_version__coupon__id\", flat=True\n )\n if order_coupon_ids:\n ...
[ "0.69658357", "0.6763817", "0.6571123", "0.6434398", "0.642819", "0.637576", "0.63689506", "0.6323911", "0.6295991", "0.6225115", "0.6218789", "0.6211016", "0.619821", "0.61803144", "0.61738944", "0.61684597", "0.61589706", "0.6155346", "0.61527157", "0.61496073", "0.61088544...
0.72761214
0
This method provide an ability to find and return order by using order id.
def get_order_by_id(self, order_id: uuid4) -> Order: return next(filter(lambda order: order.id == order_id, self.orders), None)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_order(self, order_id):\n for o in self.order_lst:\n if o.get_orderId() == order_id:\n return o", "def get_specific_order(self,order_id):\n self.query = \"SELECT * FROM orders WHERE order_id=%s\"\n self.input = (order_id,) #tuple to support indexing\n ...
[ "0.7514056", "0.721555", "0.70594895", "0.7021259", "0.69872725", "0.6922816", "0.69152623", "0.68144035", "0.6652619", "0.6628141", "0.6549546", "0.6531448", "0.6531208", "0.6498182", "0.64718544", "0.64614034", "0.64035887", "0.6351011", "0.63160884", "0.6310548", "0.630651...
0.70215946
3
This method provide an ability to get a market data snapshot. For example it can be helpful when you need to print order book or sent it to someone.
def get_market_data(self) -> dict: return MarketData(asks=self.get_orders_by_action(OrderAction.SELL, self.deep.ask_count), bids=self.get_orders_by_action(OrderAction.BUY, self.deep.bid_count)).format
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_market_snapshot(filled_order_book: Callable[[], OrderBook]) -> NoReturn:\n book = filled_order_book\n\n snapshot = book.get_market_snapshot()\n\n assert len(snapshot['asks']) == book.depth\n assert len(snapshot['bids']) == book.depth\n\n asks_prices = [ask['price'] for ask in snapshot['...
[ "0.6772954", "0.6265355", "0.60531557", "0.6049403", "0.5982641", "0.59300596", "0.58924204", "0.5888865", "0.5825112", "0.5790062", "0.57323784", "0.5681437", "0.56225586", "0.56170344", "0.5588275", "0.5558285", "0.5555326", "0.55443895", "0.5522842", "0.55121446", "0.55108...
0.53932893
27
Converts the auto incremented id of a ShortURL object and turns it into a shorturl hash
def encode(shorturl_id: int) -> str: short_resource = [] while shorturl_id > 0: character_index = shorturl_id % BASE short_resource.append(CHARACTER_SPACE[character_index]) shorturl_id //= BASE return "".join(short_resource[::-1])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shortURLToId(self, shortURL):\n id = 0\n for i in shortURL: \n val_i = ord(i) \n if(val_i >= ord('a') and val_i <= ord('z')): \n id = id*62 + val_i - ord('a') \n elif(val_i >= ord('A') and val_i <= ord('Z')): \n id = id*62 + val_i - o...
[ "0.7222362", "0.6813473", "0.6670428", "0.6613821", "0.6553491", "0.6440487", "0.6438503", "0.6381131", "0.6311566", "0.62947756", "0.6259774", "0.62407327", "0.620263", "0.61301494", "0.61228126", "0.6112265", "0.6034276", "0.59468937", "0.5900785", "0.5891555", "0.58526796"...
0.69266266
1
Overrides the save to initially save to get the id then computes the shorturl hash and saves it to the model within a transaction context
def save(self, **kwargs): res = super().save(**kwargs) short_path_component = encode(res.id) self.validated_data["short_path_component"] = short_path_component return super().save(**kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save(self,\n force_insert=False,\n force_update=False,\n using=None,\n update_fields=None):\n # If the short url wasn't specified\n if not self.short_url:\n # We pass the model instance that is being saved\n self.short_url = cr...
[ "0.7197661", "0.6860182", "0.6255863", "0.61694384", "0.6149716", "0.61207795", "0.60940796", "0.60643685", "0.6051648", "0.6023449", "0.6023449", "0.60225886", "0.601806", "0.60015386", "0.60015386", "0.5995751", "0.5987927", "0.5978799", "0.5970341", "0.5942499", "0.5940011...
0.6772935
2
Each line has a width of 100 units. Each character's width may be many units wide. This function will return the number of lines required to write out a string, as well as how many units were used in the last line.
def numberOfLines(self, widths, S): # create a storage for the number of lines and current line's width lineCount = 1 lineWidth = 0 for c in S: # find the width of c by getting the index and retrieving the # width from the widths list cWidth = widths[ord(c) - ord('a')] # add width to current line's width lineWidth += cWidth # Check if current line's width exceeds the max if (lineWidth > 100): # add a new line lineCount += 1 # add the current character's width to current line's width lineWidth = cWidth # return the results return [lineCount, lineWidth]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def longlines(x):\n return sum(len(plain(line)) // cw for line in x.split(\"\\n\"))", "def get_width(self):\n return max(map(len, self.get_lines()))", "def _label_width(text):\n width = 0\n for lineno, line in enumerate(text.split(u'\\n')):\n size = [_BIG_FONT, _SMALL_FONT][lineno > ...
[ "0.64796424", "0.64689755", "0.6344055", "0.63050586", "0.6292749", "0.62515736", "0.6186615", "0.6142328", "0.6140158", "0.61232287", "0.6122727", "0.61053264", "0.6101904", "0.6101904", "0.60962397", "0.60413265", "0.6031096", "0.60083973", "0.59954613", "0.59206414", "0.59...
0.61721885
7
Attempt to place mover into contents. Returns a Boolean representation of success.
def contain(self, mover): # Check if mover can exit old location old_location = mover.location if(not old_location): return False if(not old_location.allow_exit(mover)): return False # Check if mover can enter current location if(not self.allow_entry(mover)): return False # Set new location if(not self.contents): self.contents = [] self.contents.append(mover) mover.location = self # Inform both locations of movement if(old_location): old_location.exited(mover) self.entered(mover) return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move(self) -> bool:\n pass", "def allow_entry(self, mover):\n return True", "def test_object_move(self):\n self.assertTrue(self.obj1 in self.room1.contents)\n # use move_to hook\n self.obj1.move_to(self.room2)\n self.assertFalse(self.obj1 in self.room1.contents)\n ...
[ "0.5737424", "0.5638439", "0.5441351", "0.5409434", "0.5399845", "0.5309671", "0.52931213", "0.5276102", "0.5168468", "0.5082271", "0.50646865", "0.505076", "0.50131536", "0.50104046", "0.50004804", "0.4979135", "0.49734983", "0.4963041", "0.49610388", "0.49543136", "0.495197...
0.7234833
0
Determines if the mover is permitted to enter the room
def allow_entry(self, mover): return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowedToEnter(self):\n if base.cr.isPaid():\n return True\n place = base.cr.playGame.getPlace()\n myHoodId = ZoneUtil.getCanonicalHoodId(place.zoneId)\n if myHoodId in \\\n (ToontownGlobals.ToontownCentral,\n ToontownGlobals.MyEstate,\n T...
[ "0.6933369", "0.6317256", "0.6274393", "0.6119734", "0.6043591", "0.6006229", "0.59973824", "0.5966571", "0.59650975", "0.59650975", "0.5949079", "0.590017", "0.58607984", "0.5843126", "0.5832102", "0.58177775", "0.57856125", "0.57780486", "0.5743955", "0.57223856", "0.572238...
0.66670233
1
Determines if the mover is permitted to exit the room.
def allow_exit(self, mover): return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_exited(self):\n agents = self.board[self.agent_locs_idx]\n return agents & (CellTypes.agent | CellTypes.exit) == CellTypes.exit", "def can_exit(self) -> bool:\n return False", "def check_exit(self, position, direction):\n if self.get_room((position[0] + direction[0], positio...
[ "0.6301413", "0.6263654", "0.62400985", "0.60136616", "0.58825636", "0.58812755", "0.58409286", "0.5794512", "0.5793184", "0.5782265", "0.5782265", "0.57529366", "0.5692975", "0.5673591", "0.56546485", "0.56517553", "0.5650926", "0.5650613", "0.5642109", "0.56175417", "0.5615...
0.7196453
0
Called after the mover has entered the room.
def entered(self, mover): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exited(self, mover):\n pass", "def after_turn(self):\n pass", "def game_over(self):\n self.end_of_level()\n self.message_holder.add_widget(self.you_lose_label)\n Clock.schedule_once(self.goto_menu, 5)", "def end_of_level(self):\n Clock.unschedule(self.update)\n ...
[ "0.6746905", "0.6695229", "0.66767555", "0.63322276", "0.627838", "0.627838", "0.6254879", "0.6229721", "0.6191655", "0.61626804", "0.60663325", "0.6041078", "0.598377", "0.59339255", "0.5903108", "0.585522", "0.5828244", "0.5815816", "0.5759303", "0.57528126", "0.5750263", ...
0.75459206
0
Called after the mover has exited the room.
def exited(self, mover): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def leave(self):\n self.pleaseQuit=1", "def on_pre_leave(self):\n Logger.info('Application: Leaving the Intro screen.')", "def on_pre_leave(self):\n Logger.info('Application: Leaving the Intro screen.')", "def endGame(self):\n pass", "def on_client_exit(self, game) -> None:\n ...
[ "0.6788173", "0.65788233", "0.65788233", "0.65397877", "0.6511395", "0.6485533", "0.6424921", "0.6411908", "0.64101607", "0.6407878", "0.637953", "0.63781476", "0.6357803", "0.6351377", "0.63508695", "0.6343258", "0.6334145", "0.63243484", "0.62887913", "0.6288441", "0.627727...
0.78373396
0
Creates a tree from list. First element is root value, others are children nodes. (values or subtrees).
def construct(lst): t = Tree() t.root = lst[0] for node in lst[1:]: if isinstance(node, list): t.nodes.append(construct(node)) else: t.nodes.append(node) return t
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_tree(tree_list, nums):\n\n if len(nums) == 0:\n return tree_list\n next_list = []\n j = 0\n for i in tree_list:\n for _ in range(2):\n if i is not None and j < len(nums):\n if nums[j] is No...
[ "0.70470774", "0.69341266", "0.6903691", "0.6826804", "0.67401844", "0.6710746", "0.65991884", "0.6522682", "0.63863814", "0.6339975", "0.63145685", "0.63064444", "0.6274908", "0.6264302", "0.62484676", "0.62479275", "0.6221631", "0.62191725", "0.6189883", "0.6159182", "0.615...
0.7338503
0
A small test method for ticking.
def tick(self): self.count += 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tick(self, tick):\n pass", "def tick(self, tick):\n pass", "def tick(self):", "def tick(self):\n pass", "def tick(self):\n pass", "def tick(self):\r\n pass", "def tick(self):\n return True", "def tick(self, dt):\n pass", "def _tick(self):\n\t\tse...
[ "0.7585349", "0.7585349", "0.7569551", "0.7563374", "0.7563374", "0.7549485", "0.7092856", "0.7018002", "0.6987178", "0.69818205", "0.6821981", "0.6712875", "0.66921383", "0.66777706", "0.6638356", "0.66231155", "0.6546713", "0.65091604", "0.6470777", "0.64506656", "0.6409298...
0.61954355
34
A method to make all the objects necessary for testing.
def setUp(self): self.simulation = FooSimulation(count=5, g=6, h=9, i=12) self.foo = Foo(simulation=self.simulation, name='foo', a=4, b=42, c="Hello") self.handler = Handler(ProxyLock(self.simulation), ProxyLock(self.foo), [Attribute("count"), Attribute("g")], [Attribute('b')], [Attribute('a')])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_objects(self):\n pass", "def test_constructor(self):\n pass", "def setUpClass(cls):\r\n cls.jon = Person.create(name='Jon', age=143)\r\n cls.eric = Person.create(name='Eric', age=25)\r\n cls.blake = Person.create(name='Blake', age=14)\r\n\r\n cls.physics = Cou...
[ "0.7469929", "0.71140385", "0.7040179", "0.6990236", "0.68704045", "0.68704045", "0.68704045", "0.68704045", "0.68704045", "0.68704045", "0.6843066", "0.68285465", "0.68145835", "0.6789554", "0.67843175", "0.67811996", "0.67123467", "0.6711415", "0.6684922", "0.66496056", "0....
0.0
-1
A test to see if the packets get processed correctly.
def test_process_packet(self): packet = {'a': 7} self.assertEqual(self.foo.a, 4) self.handler.process_packet(packet) self.assertEqual(self.foo.a, 7) packet = {'b': 9, 'a': 20} self.handler.process_packet(packet) self.assertEqual(self.foo.a, 20) self.assertEqual(self.foo.b, 42)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pes_packet_check_formedness(payload):\n b1 = ord(payload[0])\n b2 = ord(payload[1])\n b3 = ord(payload[2])\n\n b4 = ord(payload[3])\n if b1 != 0 or b2 != 0 or b3 != 1:\n return False\n return True", "def test_process_packet_message(self):\n\n pkt = {'type': 'message',\n ...
[ "0.6842402", "0.67776984", "0.6636898", "0.6476315", "0.638278", "0.6337137", "0.6315716", "0.6269154", "0.6244437", "0.61474615", "0.6122378", "0.60583025", "0.60583025", "0.6045686", "0.6007994", "0.6007994", "0.6007165", "0.59843373", "0.59433156", "0.59417355", "0.5931659...
0.6646249
2
A test to make sure that the handler collects the right information.
def test_prepare_packet(self): self.handler.prepare_packet() self.foo.c = "World" self.foo.b = 21 self.simulation.tick() packet = self.handler.prepare_packet() self.assertEqual(packet['b'], 21) self.assertEqual(packet['count'], 6) for key in ['g', 'c', 'a']: with self.assertRaises(KeyError): # pylint: disable=pointless-statement packet[key]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_init_adds_handler(self):\n pass", "def test_handle(self):\n with pytest.raises(NotImplementedError):\n self.handler.handle(MagicMock())", "def test_handle_basic(self):\n response = self.handler.handle(self.request, '/')\n\n self.view.assert_called_with(self.reque...
[ "0.71886176", "0.71320015", "0.7119762", "0.71087456", "0.700912", "0.69731605", "0.6775578", "0.6775131", "0.6685757", "0.6584737", "0.6575072", "0.65643466", "0.654191", "0.6502415", "0.64595646", "0.64021575", "0.63768643", "0.63718456", "0.63311636", "0.63125056", "0.6312...
0.0
-1
convert list of dicts to ndarray of type np.float32
def dicts2ndarray(data_dicts): # NEVER make any assumption about the order of .keys() return aps = [ap for ap in data_dicts[0].keys() if ap != 'tag'] aps.sort() data_num = len(data_dicts) data_len = len(data_dicts[0][aps[0]]) ndary = np.zeros([data_num, len(aps), data_len], dtype=np.float32) for idx, d in enumerate(data_dicts): for aidx, ap in enumerate(aps): ndary[idx, aidx, :] = d[ap] return ndary
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate_pandas_to_numpy(data_list:list) -> list:\n list_size = len(data_list)\n for i in range(list_size):\n data_list[i] = data_list[i].values.astype('float32')\n return data_list", "def convert_dict_to_ndarray(*dictionaries):\n\n array_list = []\n\n # Loop all dicts\n for dictio...
[ "0.6651815", "0.65400195", "0.61362433", "0.6098978", "0.60989004", "0.60879093", "0.60031056", "0.59976625", "0.59976625", "0.59976625", "0.59841895", "0.59794885", "0.5843597", "0.5822316", "0.5761593", "0.57518655", "0.57207453", "0.57119364", "0.571017", "0.570412", "0.56...
0.70575464
0
process raw data according to method given
def process(self, method): process_dicts = [] for d in self.data_dicts: dd = copy.deepcopy(d) for ap in self.aps: dd[ap] = method(d[ap]) process_dicts.append(dict2str(dd)) # print(process_dicts) # print(type(process_dicts[0])) return Dataset(process_dicts)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_data(self, data):\n return data", "def processor(self, data):\n streaming_data = self.decoder.decodeData(data)\n # Add Your code here to process data and handle transport/storage", "def processor(self, data):\n streaming_data = self.decoder.decodeData(data)\n # Ad...
[ "0.72334456", "0.6959639", "0.6959639", "0.6959639", "0.6959639", "0.6959639", "0.6959639", "0.6871298", "0.6871298", "0.68358284", "0.6817933", "0.6815306", "0.67331237", "0.6659602", "0.66281915", "0.65316874", "0.6517139", "0.6490532", "0.6486199", "0.64807916", "0.6477415...
0.5911429
54
Assembles a list of circuits into a qobj which can be run on the backend.
def assemble_circuits(circuits, run_config=None, qobj_header=None, qobj_id=None): qobj_header = qobj_header or QobjHeader() run_config = run_config or RunConfig() if isinstance(circuits, QuantumCircuit): circuits = [circuits] userconfig = QobjConfig(**run_config.to_dict()) experiments = [] max_n_qubits = 0 max_memory_slots = 0 for circuit in circuits: # header stuff n_qubits = 0 memory_slots = 0 qubit_labels = [] clbit_labels = [] qreg_sizes = [] creg_sizes = [] for qreg in circuit.qregs: qreg_sizes.append([qreg.name, qreg.size]) for j in range(qreg.size): qubit_labels.append([qreg.name, j]) n_qubits += qreg.size for creg in circuit.cregs: creg_sizes.append([creg.name, creg.size]) for j in range(creg.size): clbit_labels.append([creg.name, j]) memory_slots += creg.size # TODO: why do we need creq_sizes and qreg_sizes in header # TODO: we need to rethink memory_slots as they are tied to classical bit experimentheader = QobjExperimentHeader(qubit_labels=qubit_labels, n_qubits=n_qubits, qreg_sizes=qreg_sizes, clbit_labels=clbit_labels, memory_slots=memory_slots, creg_sizes=creg_sizes, name=circuit.name) # TODO: why do we need n_qubits and memory_slots in both the header and the config experimentconfig = QobjExperimentConfig(n_qubits=n_qubits, memory_slots=memory_slots) instructions = [] for opt in circuit.data: current_instruction = QobjInstruction(name=opt.name) if opt.qargs: qubit_indices = [qubit_labels.index([qubit[0].name, qubit[1]]) for qubit in opt.qargs] current_instruction.qubits = qubit_indices if opt.cargs: clbit_indices = [clbit_labels.index([clbit[0].name, clbit[1]]) for clbit in opt.cargs] current_instruction.memory = clbit_indices if opt.params: params = list(map(lambda x: x.evalf(), opt.params)) params = [sympy.matrix2numpy(x, dtype=complex) if isinstance(x, sympy.Matrix) else x for x in params] if len(params) == 1 and isinstance(params[0], numpy.ndarray): # TODO: Aer expects list of rows for unitary instruction params; # change to matrix in Aer. params = params[0] current_instruction.params = params # TODO (jay): I really dont like this for snapshot. I also think we should change # type to snap_type if opt.name == "snapshot": current_instruction.label = str(opt.params[0]) current_instruction.type = str(opt.params[1]) if opt.control: mask = 0 for clbit in clbit_labels: if clbit[0] == opt.control[0].name: mask |= (1 << clbit_labels.index(clbit)) current_instruction.conditional = QobjConditional(mask="0x%X" % mask, type='equals', val="0x%X" % opt.control[1]) instructions.append(current_instruction) experiments.append(QobjExperiment(instructions=instructions, header=experimentheader, config=experimentconfig)) if n_qubits > max_n_qubits: max_n_qubits = n_qubits if memory_slots > max_memory_slots: max_memory_slots = memory_slots userconfig.memory_slots = max_memory_slots userconfig.n_qubits = max_n_qubits return Qobj(qobj_id=qobj_id or str(uuid.uuid4()), config=userconfig, experiments=experiments, header=qobj_header, type=QobjType.QASM.value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assemble_circuits(circuits, qobj_id=None, qobj_header=None, run_config=None):\n qobj_config = QasmQobjConfig()\n if run_config:\n qobj_config = QasmQobjConfig(**run_config.to_dict())\n\n # Pack everything into the Qobj\n experiments = []\n max_n_qubits = 0\n max_memory_slots = 0\n f...
[ "0.7279348", "0.6496389", "0.59102285", "0.5772845", "0.57442355", "0.5727163", "0.55746835", "0.55432576", "0.55362433", "0.5509834", "0.5474253", "0.5412955", "0.5407767", "0.53782344", "0.53507787", "0.53283745", "0.5326846", "0.5310684", "0.52896637", "0.52684003", "0.526...
0.69339204
1
Convert all config sections to have unique names. Adds unique suffixes to config sections for compability with configparser.
def unique_config_sections(config_file): section_counters = defaultdict(int) output_stream = io.StringIO() with open(config_file) as fin: for line in fin: if line.startswith('['): section = line.strip().strip('[]') _section = section + '_' + str(section_counters[section]) section_counters[section] += 1 line = line.replace(section, _section) output_stream.write(line) output_stream.seek(0) return output_stream
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fix_compname_configs(ibs):\n # ibs.MANUAL_CONFIG_SUFFIX = '_MANUAL_' #+ ut.get_computer_name()\n # ibs.MANUAL_CONFIGID = ibs.add_config(ibs.MANUAL_CONFIG_SUFFIX)\n # We need to fix the manual config suffix to not use computer names anymore\n\n configid_list = ibs.get_valid_configids()\n cfgsuff...
[ "0.6045993", "0.5563847", "0.5368636", "0.5358432", "0.5267798", "0.51614577", "0.51502544", "0.5139199", "0.5124081", "0.50915194", "0.507346", "0.50681233", "0.49954256", "0.4976946", "0.49577245", "0.49545503", "0.4944312", "0.492063", "0.4905497", "0.490392", "0.48970628"...
0.5965138
1
The last value for the W array is correct
def test_W_end(self): self.assertAlmostEqual(attempt.W[-1], 9.494852380803035)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def w(self) -> np.ndarray:\n return self.array[:, 0] if self.scalar_vector else self.array[:, 3]", "def get_w(self, i_order):\n\n return np.array([]), np.array([])", "def w(self) -> float:\n return self.A[0] if self.scalar_vector else self.A[3]", "def new_w(w, d):\n\n if w.sum() > 0:\...
[ "0.6439141", "0.6317358", "0.6140997", "0.60708946", "0.60476446", "0.6045793", "0.6034233", "0.5948805", "0.5945211", "0.58441013", "0.58261454", "0.5818163", "0.57634544", "0.5760683", "0.5717286", "0.5704453", "0.5694879", "0.5665707", "0.5622648", "0.56216794", "0.5620351...
0.639363
1
The last value for the Z array is correct
def test_Z_end(self): self.assertAlmostEqual(attempt.Z[-1], 41.47999849170943)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def z(self):\n return self._arr[2]", "def z(self):\n return self._data[2]", "def get_lz(self):\r\n return self.dz * self.nz - self.oz", "def relu(Z):\n\n A = np.maximum(0, Z)\n\n assert (A.shape == Z.shape)\n\n return A", "def z(self):\r\n return self.unif[2]", "def z(sel...
[ "0.72840196", "0.66340685", "0.6575737", "0.6572709", "0.65650034", "0.65324533", "0.65268767", "0.65268767", "0.65268767", "0.6514927", "0.64908797", "0.64388865", "0.6430518", "0.64048165", "0.6372679", "0.6338418", "0.6318305", "0.62974244", "0.6289918", "0.6280703", "0.62...
0.6586646
2
The first value for the W array is correct
def test_W_start(self): self.assertAlmostEqual(attempt.W[0], 12)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def w(self) -> np.ndarray:\n return self.array[:, 0] if self.scalar_vector else self.array[:, 3]", "def w(self) -> float:\n return self.A[0] if self.scalar_vector else self.A[3]", "def get_w(self, i_order):\n\n return np.array([]), np.array([])", "def __init__(self, w):\n self.w =...
[ "0.6571864", "0.63333076", "0.62975305", "0.6284889", "0.60969466", "0.60714823", "0.599055", "0.5986858", "0.59700614", "0.5932216", "0.585418", "0.58040833", "0.5794119", "0.5789142", "0.5787203", "0.5778182", "0.57695913", "0.57609683", "0.573644", "0.5735926", "0.57335657...
0.59087545
10
The first value for the Z array is correct
def test_Z_start(self): self.assertAlmostEqual(attempt.Z[0], 40)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def z(self):\n return self._arr[2]", "def z(self) -> float:\n return self.A[3] if self.scalar_vector else self.A[2]", "def z(self):\n return self._data[2]", "def z(self):\r\n return self.unif[2]", "def z(self):\n return self[:, 2]", "def z(self):\n return self.coords...
[ "0.73199224", "0.6729115", "0.6569211", "0.6560481", "0.6554395", "0.6549071", "0.6405089", "0.63656455", "0.63523674", "0.6309033", "0.6308248", "0.63073283", "0.6301584", "0.6276863", "0.6261062", "0.6253484", "0.6253484", "0.6253484", "0.62091494", "0.618319", "0.61823267"...
0.64692014
6
The arrays all have the correct lengths
def test_lengths(self): self.assertEqual(size(attempt.Z), 201) self.assertEqual(size(attempt.W), 201)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def array(self):", "def test_ncols_vrt_array(self):\n self.assertEqual(_test_array(landsat_vrt).shape[2], 235)", "def test_has_correct_length(self) -> None:\n assert len(list(self._dataset)) == 7168", "def test_nbands_vrt_array(self):\n self.assertEqual(_test_array(landsat_vrt).shape[0],...
[ "0.6665907", "0.6437724", "0.6414497", "0.6371735", "0.62632823", "0.61963075", "0.6181136", "0.6181136", "0.6171587", "0.6137263", "0.61063594", "0.6080566", "0.6074043", "0.6025451", "0.6017989", "0.5976124", "0.59638834", "0.594764", "0.5943476", "0.59414154", "0.5932839",...
0.0
-1
The maxIndex variables are correct
def test_maxIndex(self): self.assertEqual(attempt.maxIndexZ, 113) self.assertEqual(attempt.maxIndexW, 134)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def maxQualifiedIndex(self, indices):\n entry = self.getConfig()\n # the leader keep its own record updated to the newest\n indices[self.datacenter_id] = len(self.log) - 1\n # print('!!!!!', indices)\n if entry['config'] == 'single':\n return sorted([indices[x] for x i...
[ "0.7089196", "0.67561334", "0.67561334", "0.67561334", "0.6644873", "0.6621024", "0.65653", "0.6489624", "0.64309424", "0.6412204", "0.6361595", "0.63488233", "0.63382834", "0.63159776", "0.62829936", "0.6254711", "0.6254558", "0.6239701", "0.6237676", "0.61731935", "0.616580...
0.7708999
0
Parses ansible facts file in JSON format to discover drives. Required facts in the format are shown below. { ...
def get_devices(): try: with open(DEVICES, 'r') as f: data = json.load(f)['devices'] except (IOError, ValueError) as err: raise SwiftlmCheckFailure('Failure opening %s: %s' % (DEVICES, err)) devices = [] for d in data: l = d.get('label', LABEL_CHECK_DISABLED) devices.append(Device( device=d['name'], mount=MOUNT_PATH+d['swift_drive_name'], label=l )) return devices
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_hostsdata_from_hostsfile(hosts_file) -> dict:\n\n if not os.path.isfile(hosts_file):\n logger.error(f\"Suzieq inventory {hosts_file} must be a file\")\n print(f\"ERROR: Suzieq inventory {hosts_file} must be a file\")\n sys.exit(1)\n\n if not os.access(hosts_file, os.R_OK):\n ...
[ "0.62157637", "0.59848344", "0.59457314", "0.5934885", "0.5726563", "0.56022584", "0.5492696", "0.548934", "0.544715", "0.5425406", "0.53883463", "0.5386127", "0.5320267", "0.530013", "0.5203763", "0.5157003", "0.5150875", "0.51109576", "0.499665", "0.49880725", "0.49814734",...
0.48628756
31
Checks mount point is owned by swift
def is_ug_swift(d, r): stats = os.stat(d.mount) uid = stats.st_uid gid = stats.st_gid user = pwd.getpwuid(uid).pw_name group = grp.getgrgid(gid).gr_name if user == group == 'swift': return True else: r.msgkey('user', user) r.msgkey('group', group) return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ownercheck(self, userhost):\n if self.cfg and self.cfg.owner:\n if userhost in self.cfg.owner: return True\n return False", "def _check_mounted_system(self):\n res = self.su_cmd('touch /system/.dwarf_check')\n if res == '':\n res = self._do_adb_command('shell...
[ "0.6451464", "0.6307461", "0.6153694", "0.6151752", "0.61308235", "0.6095205", "0.60757345", "0.60000616", "0.5997545", "0.5997545", "0.5976451", "0.59735596", "0.5972847", "0.5931066", "0.59120023", "0.59047663", "0.58646756", "0.58345026", "0.5809635", "0.5780444", "0.57620...
0.6578928
0
Checks the relevant swift mount points and diskusage
def main(): results = [] results.extend(check_mounts()) results.extend(diskusage()) return results
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_mounted_system(self):\n res = self.su_cmd('touch /system/.dwarf_check')\n if res == '':\n res = self._do_adb_command('shell ls -la /system')\n if '.dwarf_check' in res:\n res = self.su_cmd('rm /system/.dwarf_check')\n if res == '':\n ...
[ "0.65840626", "0.6307514", "0.6279391", "0.626951", "0.6082033", "0.60685736", "0.60032076", "0.5917685", "0.5890955", "0.58835125", "0.5840331", "0.58330125", "0.5823619", "0.58203804", "0.5819363", "0.581247", "0.58020556", "0.5750178", "0.5736998", "0.5730349", "0.5725064"...
0.6437659
1
Return a transformed Variable if there is a large (>12) shift.
def get_offset(self): if self.shift >= 12 and not isinstance(self, OffsetVariable): return OffsetVariable( rank=self.rank, name=self.name, shift=self.shift, units=self.units, parent=self.parent, ) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read12bit(self, register):\n valuearray = bytearray(self.device.readregistermulti(register, 2))\n return struct.unpack('!H', valuearray)[0] & ((2 ** 12) - 1) # Convert to short and discard first four bits", "def len12(self): # -> Any | float:\n ...", "def shift(self):\n return ...
[ "0.54482156", "0.5174691", "0.48559287", "0.48548213", "0.4682742", "0.46447504", "0.46120813", "0.46117097", "0.45603758", "0.45588163", "0.45473444", "0.44411454", "0.44405517", "0.44322982", "0.44162038", "0.44104075", "0.43977198", "0.43933216", "0.43922186", "0.43858984", ...
0.5158371
2
The inverse of `get_offset()`.
def get_standard(self): if self.shift >= 12 and isinstance(self, OffsetVariable): return StandardVariable( rank=self.rank, name=self.name, shift=self.shift, units=self.units, parent=self.parent, ) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Offset(self) -> int:", "def Offset(self) -> int:", "def Offset(self) -> int:", "def offset(self, offset):\n raise NotImplementedError(\"This should have been implemented.\")", "def get_offset(self):\n return self.offset", "def offset(self):\n return self.__offset", "def offset(...
[ "0.84163034", "0.84163034", "0.84163034", "0.78482765", "0.7759836", "0.77160716", "0.77160716", "0.76086974", "0.75559103", "0.75314885", "0.75314885", "0.75314885", "0.75314885", "0.75314885", "0.75314885", "0.75314885", "0.75008124", "0.74963164", "0.74358535", "0.72741544",...
0.0
-1
Add the fill params if needed.
def _fill_root(self): if self.parent in filled_variables: return f"{self.name} {st_persistent_perc}P {st_k}k" return self.name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fill_missing_parameters(self):\n pseudo_id = self.get_param_by_type(PseudoID)\n pseudo_name = self.get_param_by_type(PseudoName)\n if pseudo_id is None and pseudo_name is not None:\n self.parameters.append(\n PseudoID(pseudo_name.value)\n ) # take name...
[ "0.6528969", "0.63597214", "0.6197034", "0.61547756", "0.6130784", "0.61055094", "0.6097497", "0.5999343", "0.59145826", "0.5904964", "0.5889323", "0.5852561", "0.58364487", "0.58171743", "0.57736933", "0.5735036", "0.5718243", "0.56878495", "0.56824", "0.56730765", "0.567059...
0.0
-1
Add the fill params if needed.
def _nn_fill_root(self): if self.parent in filled_variables: return f"{self.name} {nn_n_months}NN" return self.name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fill_missing_parameters(self):\n pseudo_id = self.get_param_by_type(PseudoID)\n pseudo_name = self.get_param_by_type(PseudoName)\n if pseudo_id is None and pseudo_name is not None:\n self.parameters.append(\n PseudoID(pseudo_name.value)\n ) # take name...
[ "0.6528969", "0.63597214", "0.6197034", "0.61547756", "0.6130784", "0.61055094", "0.6097497", "0.5999343", "0.59145826", "0.5904964", "0.5889323", "0.5852561", "0.58364487", "0.58171743", "0.57736933", "0.5735036", "0.5718243", "0.56878495", "0.56824", "0.56730765", "0.567059...
0.0
-1
Filled name (if applicable).
def filled(self): if self.parent in filled_variables: return f"{self._fill_root} {self.shift}M" return self._fill_root
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name(self, name):\n pass", "def name():\n pass", "def name():\n pass", "def getName(self):\n return \"\"", "def name_field(self):\r\n return 'name'", "def test_name_empty_string(self):\r\n self.name = \"\"", "def name(self) -> str: # pragma: no cover",...
[ "0.69951504", "0.6751056", "0.6751056", "0.67024434", "0.6659543", "0.6640836", "0.65940964", "0.65553534", "0.65237314", "0.6510735", "0.64991957", "0.64991957", "0.64991957", "0.64991957", "0.64991957", "0.647957", "0.647957", "0.647957", "0.647957", "0.6468007", "0.6453826...
0.0
-1