query
stringlengths
9
9.05k
document
stringlengths
10
222k
metadata
dict
negatives
listlengths
30
30
negative_scores
listlengths
30
30
document_score
stringlengths
4
10
document_rank
stringclasses
2 values
Edit the car info given car_id receive a json object data = { car_id = "1", used = "2", model = "3", ..... } return {status, error_code, data(car_info)}
def edit_car(request): try: parsed_data = get_json_data(request) if not authenticate_user(parsed_data): ret = Response(AUTHENTICATION_FAIL, error_code[AUTHENTICATION_FAIL]) return HttpResponse(ret.serialize(f)) car = Car.objects.get(car_id=parsed_data["car_id"]) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit_car():\n carid = request.form[\"carid\"]\n make = request.form[\"make\"]\n bodytype = request.form[\"bodytype\"] \n color = request.form[\"color\"]\n seats = request.form[\"seats\"]\n location = request.form[\"location\"]\n costperhour = request.form[\"costperhour\"]\n\n # create a...
[ "0.7468365", "0.6669337", "0.65150374", "0.63757503", "0.6337304", "0.6288194", "0.61077744", "0.5961732", "0.5890917", "0.5864226", "0.5838485", "0.57958025", "0.57762665", "0.5762462", "0.57314473", "0.5647342", "0.56307065", "0.5587375", "0.55309385", "0.550685", "0.548634...
0.7290608
1
Get all cars from user receive a json object data = { username = "username" } return {status, error_code, data([car1_info, car2_info, ...])}
def get_cars(request): try: parsed_data = get_json_data(request) if not authenticate_user(parsed_data): ret = Response(AUTHENTICATION_FAIL, error_code[AUTHENTICATION_FAIL]) return HttpResponse(ret.serialize(f)) ret_list = [] user = User.objects.get(usernam...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_car():\n params = (\n ('fields', 'batteryLevel,connection.connected,connection.since,doors.allClosed,doors.leftOpen,doors.locked,doors.rightOpen,doors.trunkOpen,engineOn,fuelLevel,geo.latitude,geo.longitude,immobilizerEngaged,mileage,powerState,vin'),)\n r = requests.get(HOST, params=params, c...
[ "0.62472326", "0.6224683", "0.6120991", "0.60858727", "0.59794945", "0.59657836", "0.596093", "0.59167427", "0.5887537", "0.5884386", "0.57649136", "0.57583237", "0.57410055", "0.5737226", "0.57347286", "0.5734401", "0.57097995", "0.57022816", "0.5695659", "0.56941134", "0.56...
0.7392168
0
Get the most recent posted cars receive a json object data = { start = 1, end = 2 }
def get_recent_cars(request): try: parsed_data = get_json_data(request) ret_list = [] cars = Car.objects.all() sorted_cars = sorted(cars, key=lambda x: x.last_edit, reverse=True) start = int(parsed_data["start"]) end = int(parsed_data["end"]) end = min(en...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def last(self):\n data = self._http_get(\"last\")\n return data.json()", "def get_last_data(request):\n\n return_list = []\n if request.POST:\n try:\n conn = psycopg2.connect(dbname=DB_NAME,\n user=DB_USER,\n ...
[ "0.6138192", "0.59883475", "0.59533083", "0.58350104", "0.57525367", "0.5696679", "0.56359804", "0.55815715", "0.55174816", "0.55026615", "0.5491506", "0.5405283", "0.538379", "0.5355811", "0.53283286", "0.52971864", "0.5277565", "0.5271555", "0.5258697", "0.52500385", "0.523...
0.75390077
0
Adds CTC loss on top of pred symbol and returns the resulting symbol
def _add_ctc_loss(pred, seq_len, num_label, loss_type): label = mx.sym.Variable('label') if loss_type == 'warpctc': print("Using WarpCTC Loss") sm = _add_warp_ctc_loss(pred, seq_len, num_label, label) else: print("Using MXNet CTC Loss") assert loss_type == 'ctc' sm = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _add_mxnet_ctc_loss(pred, seq_len, label):\n pred_ctc = mx.sym.Reshape(data=pred, shape=(-4, seq_len, -1, 0))\n\n loss = mx.sym.contrib.ctc_loss(data=pred_ctc, label=label)\n ctc_loss = mx.sym.MakeLoss(loss)\n\n softmax_class = mx.symbol.SoftmaxActivation(data=pred)\n softmax_loss = mx.sym.MakeL...
[ "0.7279776", "0.67509294", "0.6634631", "0.64416933", "0.636777", "0.6334527", "0.62488717", "0.62174857", "0.6172037", "0.5912462", "0.5818996", "0.58138746", "0.5788817", "0.5786746", "0.57292295", "0.5714518", "0.5672616", "0.56589985", "0.5637777", "0.55821425", "0.553402...
0.73154473
0
Creates an unrolled LSTM symbol for inference if loss_type is not specified, and for training if loss_type is specified. loss_type must be one of 'ctc' or 'warpctc'
def lstm_unroll(num_lstm_layer, seq_len, num_hidden, num_label, loss_type=None): # Create the base (shared between training and inference) and add loss to the end pred = _lstm_unroll_base(num_lstm_layer, seq_len, num_hidden) if loss_type: # Training mode, add loss return _add_ctc_loss(pred,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, incoming, n_units,\n W_ci=tf.zeros, W_ig=tf.zeros, W_og=tf.zeros, W_fg=tf.zeros,\n b_ci=tf.zeros, b_ig=tf.zeros, b_og=tf.zeros, b_fg=tf.zeros,\n a_ci=tf.tanh, a_ig=tf.sigmoid, a_og=tf.sigmoid, a_fg=tf.sigmoid, a_out=tf.identity,\n c...
[ "0.6248323", "0.61311096", "0.60797215", "0.60686815", "0.60521054", "0.60028666", "0.5984797", "0.59480095", "0.58063996", "0.57800037", "0.5692031", "0.5684242", "0.56633073", "0.5610074", "0.5585353", "0.558503", "0.5528418", "0.55205464", "0.551147", "0.55097836", "0.5505...
0.71515894
0
Returns name and shape of init states of LSTM network
def init_states(batch_size, num_lstm_layer, num_hidden): init_c = [('l%d_init_c' % l, (batch_size, num_hidden)) for l in range(num_lstm_layer)] init_h = [('l%d_init_h' % l, (batch_size, num_hidden)) for l in range(num_lstm_layer)] return init_c + init_h
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_initial_state(state_sizes: list, batch_size, name):\n\n init_states = []\n\n # for each layer, create a tf variable and tile\n for i, tupl in enumerate(state_sizes):\n c = tf.get_variable(name+\"_c_%d\"%i, shape=[1, tupl[0]])\n h = tf.get_variable(name+\"_h_%d\"%i, shape=[1, tupl[1]...
[ "0.6832012", "0.6490874", "0.64794016", "0.63486713", "0.61073273", "0.61069", "0.6104121", "0.61003625", "0.6077626", "0.6058606", "0.60517395", "0.5974428", "0.5965294", "0.5960053", "0.5928339", "0.592516", "0.5925127", "0.591759", "0.587162", "0.58607215", "0.5859695", ...
0.6766326
1
Test _attach_and_stream when the container stops normally.
def test_container_stops_normally(self, m_sys, m_docker_client): # attach(..., stream=True) returns a generator. def container_output_gen(): yield ("Some output\n") yield ("from the container.") m_docker_client.attach.return_value = container_output_gen() m_stdo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_killed(self, m_sys, m_docker_client):\n # attach(..., stream=True) returns a generator.\n def container_output_gen():\n yield (\"Some output\\n\")\n yield (\"from the container.\")\n # Commit suicide, simulating being killed from another terminal.\n ...
[ "0.6251586", "0.5918803", "0.58964515", "0.58917296", "0.58857954", "0.581574", "0.5713234", "0.5620514", "0.5608439", "0.56070626", "0.55646825", "0.55644155", "0.5562548", "0.5554517", "0.5540115", "0.548404", "0.5483997", "0.5481819", "0.5453746", "0.5448113", "0.54479104"...
0.68866575
0
Test _attach_and_stream when killed by another process.
def test_killed(self, m_sys, m_docker_client): # attach(..., stream=True) returns a generator. def container_output_gen(): yield ("Some output\n") yield ("from the container.") # Commit suicide, simulating being killed from another terminal. os.kill(os.get...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_mp_pipe_replacement(self):\n parent, child = create_psuedo_anonymous_duct_pair()\n\n def mp_child_target():\n parent.close()\n time.sleep(3)\n child.send(\"hello world\")\n child.close()\n\n p = multiprocessing.Process(target=mp_child_target...
[ "0.5820887", "0.5777434", "0.57680166", "0.5731921", "0.5641282", "0.5630609", "0.5615017", "0.5594535", "0.5577908", "0.55604076", "0.555966", "0.55333686", "0.55158263", "0.5509919", "0.5502959", "0.5460285", "0.5447026", "0.5431141", "0.53817034", "0.5374262", "0.5365074",...
0.60617507
0
Run dbsync for a specified duration
def run_dbsync(self, run_time: int = 0): with open((self._working_dir + '/logs/dbsync/' + self._logfile), "w+") as dbsync_logfile: self._start_dbsync(dbsync_logfile) if run_time > 0: time.sleep(run_time) self.stop_dbsync()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def execute(timeSync):\r\n while True:\r\n runSched(timeSync)\r\n # Syncdb()\r", "def sync_db():\n pass", "def syncDBLoop(self):\n while 1:\n self.evSyncDB.wait()\n if self.bQuit == True:\n return\n \n self.evSyncDB.clear()\n self.db.syncDB()\n \n sel...
[ "0.7578095", "0.66645306", "0.6235826", "0.6131023", "0.6005941", "0.59655493", "0.5887655", "0.58157724", "0.5800394", "0.5766759", "0.57633954", "0.5666165", "0.56166655", "0.5612632", "0.5546815", "0.55266", "0.5525298", "0.5483633", "0.5416993", "0.5412211", "0.53690493",...
0.7918123
0
Reads ArcGIS dbf file Returns a pysal.lib.weights.weights.W object Examples Type 'dir(w)' at the interpreter to see what methods are supported. Open an ArcGIS dbf file and read it into a pysal weights object >>> import pysal.lib >>> w = pysal.lib.io.open(pysal.lib.examples.get_path('arcgis_ohio.dbf'),'r','arcgis_dbf')....
def _read(self): if self.pos > 0: raise StopIteration id_var = self.file.header[1] startPos = len(self.file.header) if startPos == 3: startPos = 0 elif startPos == 4: startPos = 1 else: raise ValueError("Wrong structure, a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cfdReadNeighbourFile(self): \r\n with open(self.neighbourFile,\"r\") as fpid:\r\n print('Reading neighbour file ...')\r\n\r\n ## (list) 1D, indices refer to faces, list value is the face's neighbour cell\r\n self.neighbours=[]\r\n start=False\r\n \r...
[ "0.553539", "0.5275145", "0.5228641", "0.51275873", "0.5003142", "0.49990562", "0.48962325", "0.4857007", "0.480897", "0.46667188", "0.46583158", "0.4651854", "0.46031675", "0.4603103", "0.45909962", "0.45832577", "0.4564821", "0.45395407", "0.45395404", "0.44673905", "0.4466...
0.5436518
1
Compare position of val to position of self. Return true if the two pieces have the same position.
def __eq__(self, val): if type(val)== type(self): return val.getPosition()==self.getPosition() and self.getName()==val.getName() return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_position_for_same_occupancy(self, position1, position2):\n return self.board.board[position1] == self.board.board[position2]", "def __flt_eq_pos(self, other):\n if self.position is None:\n return True\n\n return (\n self.position == other.position\n ...
[ "0.6700722", "0.6460452", "0.629321", "0.6234782", "0.6168382", "0.614241", "0.6116273", "0.6066237", "0.603371", "0.6020098", "0.5977026", "0.5946027", "0.5944572", "0.59200644", "0.58380294", "0.58275545", "0.5816172", "0.5812624", "0.58060807", "0.57808554", "0.5780674", ...
0.7136205
0
Load parameters of Unit3D component into state_dict.
def load_unit3d(state_dict, eval_type, src_name, tgt_name, h5_dir, use_batch_norm=True, use_bias=False): h5f = h5py.File(os.path.join(h5_dir, '{:s}_{:s}.h5'.format(eval_type, src_name)), 'r') state_dict[tgt_name + '.conv3d.weight'] = torch.from_numpy(h5f['weight'][...]).permute(4, 3, 0, 1, 2) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_state_dict(self, arg):\n self.TrajectoryAutoencoder.load_state_dict(torch.load(arg))", "def load_i3d(eval_type, h5_dir='param/'):\n state_dict = {}\n load_unit3d(state_dict, eval_type, 'Conv3d_1a_7x7', 'conv_1a', h5_dir)\n\n load_unit3d(state_dict, eval_type, 'Conv3d_2b_1x1', 'conv_2b', ...
[ "0.65356356", "0.62873423", "0.5968935", "0.5948332", "0.5845028", "0.57920855", "0.5693434", "0.5679292", "0.5609613", "0.554131", "0.55263484", "0.5508585", "0.54796845", "0.5435286", "0.5420295", "0.5355181", "0.5350723", "0.53325725", "0.5328443", "0.5325811", "0.5320041"...
0.63032746
1
Load all the parameters of InceptionI3D model into state_dict.
def load_i3d(eval_type, h5_dir='param/'): state_dict = {} load_unit3d(state_dict, eval_type, 'Conv3d_1a_7x7', 'conv_1a', h5_dir) load_unit3d(state_dict, eval_type, 'Conv3d_2b_1x1', 'conv_2b', h5_dir) load_unit3d(state_dict, eval_type, 'Conv3d_2c_3x3', 'conv_2c', h5_dir) load_block(state_dict, eval...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_state_dict(self, arg):\n self.TrajectoryAutoencoder.load_state_dict(torch.load(arg))", "def load_state_dict(self, state_dict):\n self.XY_net.load_state_dict(state_dict['XY_net'])\n self.XY_optimizer_minee.load_state_dict(\n state_dict['XY_optimizer_minee'])\n self....
[ "0.68653655", "0.65390885", "0.64288425", "0.62878567", "0.6253509", "0.6241428", "0.6186826", "0.6078195", "0.60680234", "0.6052236", "0.6028413", "0.6012456", "0.5968443", "0.59386265", "0.59187746", "0.58965504", "0.5872777", "0.58593005", "0.5853677", "0.5827504", "0.5795...
0.66550106
1
Follow a context. By following a context you will receive all messages sent through the event stream that have the context defined to the callback provided.
def follow(self, context, callback): followers_list = self.followers.setdefault(context, []) if callback not in followers_list: followers_list.append(callback)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _call_followers(self, event):\n context = self.get_context(event)\n if context is not None:\n for callback in self.followers.get(context, []):\n callback(event)", "def SetContextCallback(self, context):\n self._contextCallback = context", "def forward_context(...
[ "0.6020187", "0.58117324", "0.5564524", "0.5320402", "0.5157448", "0.50976217", "0.50734353", "0.5046295", "0.501335", "0.50041103", "0.4973527", "0.49559167", "0.4948715", "0.49457806", "0.4914835", "0.48882326", "0.4878829", "0.48594946", "0.48508334", "0.4830979", "0.48289...
0.65882254
0
Get the context for an event. If not found return event_id.
def get_context(event): for link in event.links.links: if link.get("type") == "CONTEXT": context = link.get("target") break else: context = None return context
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def event_id(self):\n return self._event_id", "def GetEventIdentifier(self):\n return self._event_identifier", "def get_event(self, eventid):\n return self.s.query(Event).get(eventid)", "def get_event_eid(eid):\n return EventModel.query.get_or_404(eid)", "def get_event(self, event_id):\...
[ "0.70538527", "0.68012685", "0.67689633", "0.65239763", "0.6434205", "0.638782", "0.63083977", "0.61937714", "0.6080787", "0.60558647", "0.6048353", "0.6039121", "0.60218024", "0.5984016", "0.59110355", "0.58831054", "0.58774924", "0.5834099", "0.5815435", "0.5803337", "0.577...
0.703927
1
Call all followers of a context callback methods.
def _call_followers(self, event): context = self.get_context(event) if context is not None: for callback in self.followers.get(context, []): callback(event)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def follow(self, context, callback):\n followers_list = self.followers.setdefault(context, [])\n if callback not in followers_list:\n followers_list.append(callback)", "def generateFollowers(self):\n for f in self._genericGenerator(self.getFollowers):\n yield f", "def...
[ "0.8054596", "0.64584273", "0.63695544", "0.6216068", "0.61616683", "0.6055616", "0.6054398", "0.60464066", "0.59246397", "0.5914625", "0.5909593", "0.58848095", "0.5847526", "0.5731443", "0.56934786", "0.5649177", "0.56334376", "0.56182736", "0.5604243", "0.5558574", "0.5558...
0.82580906
0
Look at all files passed in on commandline for invalid CPRINTS calls.
def main(argv: Optional[List[str]] = None) -> Optional[int]: return_code = 0 parser = preupload.lib.argument_parser() args = parser.parse_args(argv) for filename in args.filename: lines = preupload.lib.cat_file(args, filename).splitlines() for linenum, line in enumerate(lines, start=1):...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_listing_clashes(filename, argument):\n print((\"Clashes with {}:\").format(argument))\n process_if_clashing(filename, argument)", "def file_name_check(file_name):\n # Please print out which line of the above program contains an error. E.g. if the bug is on line 4 then print 4\n # END OF C...
[ "0.5992827", "0.588682", "0.5882276", "0.58433956", "0.5595384", "0.55929667", "0.5575312", "0.550234", "0.5325258", "0.5263228", "0.5227432", "0.52130693", "0.5191065", "0.5185855", "0.5170185", "0.51503795", "0.51392597", "0.5139163", "0.513815", "0.5137285", "0.5134748", ...
0.6742574
0
Test contract for user response
def test_user_responsse(user_response, client): resp = client.get_user() assert resp.keys() == user_response.keys()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_successful_get_an_answer(self):\n self.is_authenticated(self.user1)\n response = self.get_answer()\n self.assertEqual(response.status_code, status.HTTP_200_OK)", "def test_user_information_request(self):\n pass", "def test_input_text_returned_in_response_data(self):\n ...
[ "0.6567083", "0.6469839", "0.64682263", "0.64176136", "0.63952804", "0.6338916", "0.63221055", "0.6294874", "0.62615865", "0.61474174", "0.6142984", "0.61378133", "0.61290914", "0.6113222", "0.61035395", "0.60872346", "0.607993", "0.6054024", "0.6052609", "0.60522634", "0.604...
0.70861113
0
Tests the path specification initialization.
def testInitialize(self): path_spec = tsk_path_spec.TSKPathSpec( location=u'/test', parent=self._path_spec) self.assertIsNotNone(path_spec) path_spec = tsk_path_spec.TSKPathSpec( data_stream=u'test', location=u'/test', parent=self._path_spec) self.assertIsNotNone(path_spec) path_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testInitialize(self):\n path_spec = apm_path_spec.APMPathSpec(parent=self._path_spec)\n\n self.assertIsNotNone(path_spec)\n\n path_spec = apm_path_spec.APMPathSpec(\n location='/apm2', parent=self._path_spec)\n\n self.assertIsNotNone(path_spec)\n\n path_spec = apm_path_spec.APMPathSpec(\n...
[ "0.7828453", "0.65761775", "0.642966", "0.64142275", "0.62701917", "0.62537086", "0.62294465", "0.61993927", "0.61979413", "0.6130422", "0.60881066", "0.60683423", "0.60630363", "0.60392886", "0.6026892", "0.60242605", "0.6019086", "0.601817", "0.59985644", "0.599064", "0.597...
0.7610531
1
Tests the path specification comparable property.
def testComparable(self): path_spec = tsk_path_spec.TSKPathSpec( location=u'/test', parent=self._path_spec) self.assertIsNotNone(path_spec) expected_comparable = u'\n'.join([ u'type: TEST', u'type: TSK, location: /test', u'']) self.assertEqual(path_spec.comparable, exp...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testComparable(self):\n path_spec = apm_path_spec.APMPathSpec(parent=self._path_spec)\n\n self.assertIsNotNone(path_spec)\n\n expected_comparable = '\\n'.join([\n 'type: TEST',\n 'type: APM',\n ''])\n\n self.assertEqual(path_spec.comparable, expected_comparable)\n\n path_spe...
[ "0.7102935", "0.62669355", "0.6178851", "0.6173921", "0.6011653", "0.59915006", "0.59731394", "0.5943001", "0.5937971", "0.58659446", "0.5819007", "0.57998884", "0.5798577", "0.57919943", "0.5768742", "0.5763338", "0.57630247", "0.57592815", "0.5756416", "0.5743247", "0.57410...
0.683633
1
Destroy the DCGMMonitor. This function must be called in order to appropriately deallocate the resources.
def destroy(self): dcgm_agent.dcgmShutdown() self._thread_pool.terminate() self._thread_pool.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy(self):\n if self._ptr is not None:\n # run and remove destructor on c data\n _global_destroy(self._display, self._ptr)\n ffi.gc(self._ptr, None)\n self._ptr = None\n self._display = None", "def destroy(self):\r\n self.__destroy()", ...
[ "0.6654744", "0.6555072", "0.6414927", "0.6267235", "0.62573326", "0.6222781", "0.62087786", "0.6188092", "0.61494327", "0.6145454", "0.6137849", "0.61213255", "0.6115661", "0.6115661", "0.6098185", "0.6098185", "0.6098185", "0.6098185", "0.6057349", "0.60044384", "0.5931868"...
0.6799968
0
Get all projects that the user has the given permissions for.
def get_permitted_projects(self, permissions): user_permission_query = Q() group_permission_query = Q() for permission in permissions: user_permission_query = user_permission_query & Q( userpermission__permissions__key=permission ) group_permis...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_accessible_projects(user):\n query = Q(deprecated_files=False)\n\n query &= get_public_projects_query()\n\n if user.is_authenticated:\n query |= get_restricted_projects_query(user)\n\n if user.is_credentialed:\n query |= get_credentialed_projects_query(user)\n\n query |= get_pr...
[ "0.73993754", "0.7250303", "0.7147191", "0.70684075", "0.6964391", "0.69468164", "0.68801725", "0.6864998", "0.68316734", "0.6823821", "0.6821501", "0.6815403", "0.676973", "0.67580867", "0.6749198", "0.6742206", "0.6735226", "0.67151594", "0.67086357", "0.66790086", "0.66783...
0.78211063
0
Get all environments that the user has the given permissions for.
def get_permitted_environments(self, permissions): user_permission_query = Q() group_permission_query = Q() for permission in permissions: user_permission_query = user_permission_query & Q( userpermission__permissions__key=permission ) group_pe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_environments():\n return ENVIRONMENTS", "def getEnvironments(request):\n environments = Environment.objects.all()\n serializer = environmentSerializer(environments, many=True)\n result = {'data':serializer.data, 'code':HTTP_200_OK, 'message':OK}\n return result", "def...
[ "0.7298775", "0.65951914", "0.62701565", "0.6123379", "0.6103944", "0.604619", "0.5883706", "0.58337605", "0.5818717", "0.581008", "0.5730958", "0.5720051", "0.5717791", "0.5707382", "0.5660213", "0.56505644", "0.5601639", "0.5545547", "0.5528961", "0.5511986", "0.55039203", ...
0.7017802
1
Set Winner and if no exception, return winning team
def set_winner(game_ID, team): r.hset("state:" + game_ID, "winner", team) return team
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_winner(self):\n diff = self.home_score - self.away_score\n if diff > 0:\n return self.home_team\n elif diff < 0:\n return self.away_team\n else:\n return None", "def calc_winner(self):\n pass", "def winner(self):\n return (\"Non...
[ "0.7377407", "0.7148394", "0.7111746", "0.7074286", "0.7056888", "0.6938372", "0.6938372", "0.69210815", "0.6869209", "0.6844349", "0.6844349", "0.6840777", "0.68241185", "0.6816313", "0.6736115", "0.67078567", "0.6701166", "0.6694143", "0.6673979", "0.66438913", "0.6603614",...
0.7549486
0
Converts the given `s` into an ASCIIencoded string from a Unicodeencoded one.
def unicode_to_ascii(s: str) -> str: chars = [] for c in unicodedata.normalize('NFD', s): if unicodedata.category(c) != 'Mn' and c in ALLOWED_CHARS: chars.append(c) return "".join(chars)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unicode_to_ascii(s):\n ret = \"\"\n for ch in s:\n try:\n ach = str(ch)\n ret += ach\n except UnicodeEncodeError:\n ret += \"?\"\n return ret", "def unicodeToAscii(s):\n return ''.join(\n c for c in unicodedata.normalize('NFD', s)\n if ...
[ "0.80530214", "0.7639015", "0.75411695", "0.7500414", "0.7283374", "0.72818977", "0.7221033", "0.72080964", "0.70875305", "0.70871806", "0.70841277", "0.7066727", "0.7027619", "0.70116156", "0.69688123", "0.694573", "0.6916214", "0.6898315", "0.68660194", "0.68598235", "0.685...
0.7804846
1
Returns the JSON file locations as a list.
def json_fpaths() -> [str]: return glob.glob(f"{RECIPES_DIRPATH}/*.json")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def locations(self):\n return self.data.get(\"locations\", [])", "def locations(self):\n return [part.file for part in self.iterParts() if part]", "def locations(self):\n return [part.file for part in self.iterParts() if part]", "def locations(self):\n return [part.file for part i...
[ "0.7117035", "0.67887336", "0.67887336", "0.67887336", "0.67069376", "0.6670644", "0.6662277", "0.66217643", "0.6557245", "0.65487367", "0.65021336", "0.6481439", "0.6472302", "0.64608634", "0.64167076", "0.6407466", "0.6391989", "0.6311217", "0.6309606", "0.6303351", "0.6299...
0.694632
1
Fetches the data and places it in ROOT/recipes.
def fetch_the_data(): subprocess.run(["wget", "https://storage.googleapis.com/recipe-box/recipes_raw.zip"]) subprocess.run(["unzip", "recipes_raw.zip", "-d", RECIPES_DIRPATH]) subprocess.run(["rm", "recipes_raw.zip"])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_zenodo(self):\n\n # full path to the stitches root directory where the example dir will be stored\n if self.data_dir is None:\n data_directory = pkg_resources.resource_filename('stitches', 'data')\n else:\n data_directory = self.data_dir\n\n # build neede...
[ "0.6245214", "0.6241662", "0.6241662", "0.6226766", "0.6198662", "0.6165738", "0.6121912", "0.5900479", "0.58915704", "0.5837386", "0.5733908", "0.5716107", "0.5688135", "0.5627597", "0.5602928", "0.5599404", "0.55957514", "0.55879015", "0.5540788", "0.5540788", "0.5540788", ...
0.7108394
0
Attempt to reconstitute the recipe texts (.txt files) from the .json files in the data dump. Format for typical recipe in recipes_raw_nosource_ar.json
def reconstitute(): with open(TEXT_FPATH, 'w') as txt: for jfpath in json_fpaths(): with open(jfpath) as f: jstruct = json.load(f) for recipe in jstruct.keys(): _reconstitute_recipe(txt, jstruct[recipe])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_make_json_advanced(self):\n resources = get_test_resources()\n output, filename = make_json(commit=\"1245\", exclude=[\"tei:note\", \"tei:orig\"], credit=\"PerseusDL\", **resources)\n output = json.loads(output)\n self.assertEqual(\n output[\"text\"][\"0\"][\"0\"][\"...
[ "0.63832706", "0.6344451", "0.6266392", "0.6258279", "0.62190217", "0.61804116", "0.6039548", "0.6027089", "0.59477043", "0.5741175", "0.5722742", "0.5635411", "0.55661666", "0.55637896", "0.5558796", "0.55394006", "0.5533201", "0.552489", "0.5516686", "0.5515263", "0.5502386...
0.7741061
0
Returns a Sawtooth wave of Sample rate Ss with Ns number of samples and Sample Frequency Fs
def sawtooth(fs: float, Ns: int, Ss: int) -> np.ndarray: Ss = np.linspace(0, 1, Ss) return sig.sawtooth(2 * np.pi * fs * Ss)[0:Ns]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def spectral(w, s=1.0):\n n_in, n_out = w.size()\n n = max(n_out, n_in)\n gain = s / math.sqrt(n)\n return w.normal_(0, 1).mul_(gain)", "def gen_square_wave(sample_rate=44100, frequency=440, duration=1000, amplitude=0.3):\n # Calculate the total number of samples required to produce a tone of\n ...
[ "0.70675087", "0.69157755", "0.6851375", "0.6797078", "0.66893816", "0.6640114", "0.63278276", "0.62240446", "0.62175643", "0.6156091", "0.61267036", "0.61228645", "0.6075052", "0.60575694", "0.6036729", "0.60245645", "0.60090667", "0.5987655", "0.5965741", "0.5961952", "0.59...
0.78252214
0
Returns a Triangle wave of Sample rate Ss with Ns number of samples and Sample Frequency Fs
def triangle(fs: float, Ns: int, Ss: int) -> np.ndarray: Ss = np.linspace(0, 1, Ss) return sig.sawtooth(2 * np.pi * fs * Ss, 0.5)[0:Ns]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tri(frequency, amplitude=0.3):\n wave_length = sampler_rate // frequency\n # range from -0.3 to 0.3\n def sampler(t):\n saw_wave = t / wave_length - floor(t / wave_length + 0.5)\n tri_wave = 2 * abs(2 * saw_wave) - 1\n return amplitude * tri_wave\n\n return sampler", "def tri...
[ "0.6694266", "0.66805387", "0.65939575", "0.65774953", "0.6506993", "0.6488529", "0.6342446", "0.634183", "0.62340295", "0.6142268", "0.60790604", "0.60547304", "0.60342395", "0.5972168", "0.59320486", "0.5772053", "0.5769285", "0.5768378", "0.5767567", "0.57552654", "0.57485...
0.7569804
0
Returns a Cosine wave of Sample rate Ss with Ns number of samples and Sample Frequency Fs
def cos(fs: float, Ns: int, Ss: int) -> np.ndarray: t = np.arange(Ns) omega = 2 * np.pi * fs / Ss return np.cos(omega * t)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_freqs(Fs, n):\r\n\r\n return np.linspace(0, float(Fs) / 2, float(n) / 2 + 1)", "def samp_from_freq(n_samples):\n datapath = os.path.normpath(os.getcwd()+os.sep+os.pardir+os.sep+\"Dataset\"+os.sep+\"All_channels_500hz.npy\")\n data = np.load(datapath)\n fourier = np.fft.rfft(data,a...
[ "0.6720286", "0.6695193", "0.66337484", "0.65112084", "0.6426439", "0.6398528", "0.6379758", "0.6349647", "0.63196146", "0.62916994", "0.62803966", "0.62794083", "0.6249711", "0.6236641", "0.6223268", "0.622305", "0.6197544", "0.61473197", "0.6139644", "0.6107206", "0.6093398...
0.7322077
0
Get the primitive roots of the modulo
def PrimitiveRoots(self, modulo): modRange = range(1, modulo) required = {x for x in modRange if fractions.gcd(x, modulo)} return [g for g in modRange if required == {pow(g, powers, modulo) for powers in modRange}]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_generator(modulus):\n return sympy.ntheory.primitive_root(modulus)", "def primitive_root(n):\n if n == 2:\n return 1\n phi = euler_phi(n)\n phi_divisors = factorize(phi)\n for g in range(2, n + 1):\n if gcd(g, n) != 1:\n continue\n for d, _ in phi_divisors:...
[ "0.6900234", "0.6570498", "0.6545125", "0.6443999", "0.63940936", "0.6374898", "0.63004357", "0.63003904", "0.6290598", "0.62899435", "0.625735", "0.62297606", "0.6209194", "0.61932445", "0.60664463", "0.5981598", "0.5971845", "0.5878766", "0.58545893", "0.5851274", "0.584104...
0.8176876
0
Run a unit test to ensure that key exchange communications are working
def UnitTest(): print('--Running key exchange unit test--') server = DiffieHellman() t0 = threading.Thread(target=server.UnitTestServer) t0.start() time.sleep(0.1) logname = 'dhlog' with open(logname, 'w') as stdout: subprocess.call(['python', 'keyExch...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setUp(self):\n\n self.private_key = self.get_new_key()\n self.public_key = self.private_key.public_key()\n\n self.pem_private_key = self.private_key.private_bytes(\n serialization.Encoding.PEM,\n serialization.PrivateFormat.PKCS8,\n serialization.NoEncrypti...
[ "0.68959457", "0.6768567", "0.6740749", "0.67402774", "0.6681738", "0.6668606", "0.6642968", "0.6633357", "0.6619077", "0.6554481", "0.6428186", "0.63924134", "0.6349333", "0.63427824", "0.6338166", "0.6320229", "0.63075775", "0.62685555", "0.6263551", "0.62614954", "0.624999...
0.72412264
0
Performs mask damaging in numpy for a single object.
def _damage_single_object_mask(mask, shift, scale, rotate, dilate): # For now we just do shifting and scaling. Better would be Affine or thin # spline plate transformations. if shift: mask = _shift_mask(mask) if scale: mask = _scale_mask(mask) if rotate: mask = _rotate_mask(mask) if dilate: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_mask(self, array):\n # assert that the array and Mask.data are of the same size\n assert array.shape == self.shape, \"array and mask should be of the same shape\"\n\n array_copy = array.copy()\n\n # Applying mask\n # apply func_true where Mask.data is True\n arra...
[ "0.6581553", "0.645084", "0.64089704", "0.624001", "0.62089777", "0.6206625", "0.6106563", "0.61044997", "0.60834694", "0.6082419", "0.60604167", "0.60547453", "0.6044454", "0.60163283", "0.59976715", "0.59909415", "0.59805685", "0.5972587", "0.58964914", "0.58889", "0.586071...
0.6550946
1
Returns the current quorum configuration (config[i]) to application Returns config[i] when no reconfiguration occurs or no agreement on proposal. Once participants agree on proposal, returns proposal set U current configuration.
def get_config_app(self): if self.degree(self.id) in [0, 1, 2]: return self.get_config_j(self.id) else: return list(set(self.get_config_j(self.id)) | set(self.get_prp_j(self.id)[1]))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_config(self):\n if self.allow_reco():\n return self.chs_config()\n else:\n return self.get_config_j(self.id)", "def configuration(self) -> Optional[pulumi.Input['BrokerConfigurationArgs']]:\n return pulumi.get(self, \"configuration\")", "def configuration(self...
[ "0.6239466", "0.60387367", "0.60387367", "0.5956868", "0.59504783", "0.5895645", "0.58602935", "0.582811", "0.5820163", "0.58134586", "0.5805068", "0.58021927", "0.57909834", "0.5775168", "0.5733354", "0.5731225", "0.573007", "0.57178", "0.5675857", "0.56626356", "0.5660312",...
0.6082164
1
Returns either the value stored in all[k] or if k == i, whether there exists p_l one phase "ahead" of p_i
def my_alll(self, k): all_k = self.get_all_j(k) exists_pl_ahead = False ahead = (self.get_prp_j(self.id)[0] + 1) % 3 for l in self.all_seen: if self.get_prp_j(l)[0] == ahead: exists_pl_ahead = True return all_k or ((k == self.id) and exists_pl_ahead)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def first_active(self, k):\n return k - self.p", "def fn(x):\n k = 0 \n for i, ch in enumerate(s): \n if mp.get(i, inf) < x: continue \n if k < len(p) and ch == p[k]: k += 1\n return k == len(p)", "def _is_polynomial(self, p, i):\n or...
[ "0.56682724", "0.55324847", "0.54159045", "0.5402462", "0.53369343", "0.52204055", "0.52181983", "0.51593745", "0.5117445", "0.5115613", "0.50642437", "0.5046544", "0.5038634", "0.50367725", "0.50101006", "0.49974707", "0.49965903", "0.49912035", "0.4976445", "0.4962322", "0....
0.7482815
0
Calculates the degree of p_k's most recently received notification Calculated as twice the notification phase plus one whenever all participants are using the same notification (0 otherwise), where each notification is a configuration replacement proposal.
def degree(self, k): one_if_my_all_k = 1 if self.my_alll(k) else 0 return (2 * self.get_prp_j(k)[0]) + one_if_my_all_k
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def langmuir_occ(p, k):\n\n intermediate = k * p\n\n occupancy = intermediate / (intermediate + 1)\n\n return occupancy", "def _calculate_probability(self,k):\n\t\tif abs(k * self.delta_x) > (3 * np.sqrt(self.variance)):\n\t\t\treturn 0.0\n\t\tbinom_coeff = special.binom(self.n,(self.n + k)/2)\n\t\tb_va...
[ "0.575358", "0.5645525", "0.5627544", "0.55538696", "0.5541306", "0.54604745", "0.54539067", "0.5432265", "0.5383388", "0.5368729", "0.5346243", "0.5339594", "0.53276587", "0.53068185", "0.52934635", "0.5250172", "0.5222444", "0.51899505", "0.51531494", "0.51329046", "0.51319...
0.64719737
0
Tests whether p_k and p_k' have degrees that differ by <= 1 Used when considering operations in mod 6
def corr_deg(self, k, k_prime): ok_deg_tups = [{0, 5}, {5, 5}] for x in range(0, 5): ok_deg_tups.append({x, x+1}) ok_deg_tups.append({x, x}) return {self.degree(k), self.degree(k_prime)} in ok_deg_tups
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def echo_fun(self, k):\n same_all = self.my_alll(self.id) == self.get_echo_all_j(k)\n ok_deg = ((self.degree(k) - self.degree(self.id)) % 6) in {0, 1}\n return self.echo_no_all(k) and same_all and ok_deg", "def goodDLK_2(d,l,k) :\n if (d == 0) and ((l != 0) or (k != 3)) :\n return ...
[ "0.6549065", "0.6408314", "0.62199163", "0.6166814", "0.6073687", "0.6015139", "0.60098195", "0.5946944", "0.5922223", "0.580886", "0.5793645", "0.5749401", "0.5662234", "0.5647768", "0.5639147", "0.5632892", "0.56150824", "0.5612917", "0.5608243", "0.55855036", "0.5585182", ...
0.6567329
0
Returns maximum phase value of two processors considering mod 3 operations. Assumes that no two processors in FD[i].part have two notifications that p_i stores for which the degree differs by more than one.
def mod_max(self): phs = set() for k in self.get_fd_part_j(self.id): phs.add(self.get_prp_j(k)[0]) if (1 in phs) and (2 not in phs) and (self.get_prp_j(self.id)[0] != max(phs)): self.all_seen = set() return max(phs) else: return self.get_pr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_ntf(self):\n deg_diffs = set()\n for k in self.get_fd_part_j(self.id):\n deg_diff = (self.degree(k) - self.degree(self.id)) % 6\n deg_diffs.add(deg_diff)\n if not (deg_diffs <= {0, 1}):\n return self.get_prp_j(self.id)\n else:\n max_le...
[ "0.5673758", "0.5658783", "0.55484", "0.5479257", "0.533177", "0.5197469", "0.51458836", "0.50572944", "0.5057134", "0.50482756", "0.50440663", "0.5006366", "0.49880645", "0.49865636", "0.4975815", "0.4964766", "0.49578205", "0.49548864", "0.49516526", "0.49196458", "0.491935...
0.5880462
0
Stale info check type 1 Tests that all notifications of configuration proposals are valid.
def stale_info_type_1(self): for k in self.prp.keys(): if (self.get_prp_j(k)[0] == 0) and (self.get_prp_j(k)[1] != constants.BOTTOM): logger.debug("Stale info (type 1) found!") return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_config(self):", "def stale_info_type_2(self):\n config_values = self.config.values()\n bot_exists = constants.BOTTOM in config_values\n empty_exists = [] in config_values\n if bot_exists or empty_exists:\n logger.debug(f\"Stale info (type 2) found! Current config...
[ "0.60339475", "0.59377944", "0.5910291", "0.5813845", "0.56256354", "0.55865383", "0.55583864", "0.55517274", "0.5533488", "0.5477461", "0.54541314", "0.54493076", "0.535062", "0.5346866", "0.53342646", "0.53342646", "0.53342646", "0.53342646", "0.532297", "0.53192294", "0.53...
0.6215256
0
Stale info check type 2 Tests that there are no configuration conflicts or an active reset process
def stale_info_type_2(self): config_values = self.config.values() bot_exists = constants.BOTTOM in config_values empty_exists = [] in config_values if bot_exists or empty_exists: logger.debug(f"Stale info (type 2) found! Current config: {self.config}") return bot_exis...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_contradictory_multiple_actions(self):\n self.render_config_template(\n modules=[{\n \"name\": \"system\",\n \"metricsets\": [\"process\"],\n \"period\": \"1s\"\n }],\n processors=[{\n \"include_fields\": {\...
[ "0.62229544", "0.6143", "0.6102025", "0.60690427", "0.6050885", "0.60290176", "0.6003052", "0.59661", "0.5961326", "0.59563583", "0.5942481", "0.5918147", "0.5906738", "0.5895629", "0.58829015", "0.5879181", "0.5837083", "0.5837083", "0.5835069", "0.5821932", "0.582185", "0...
0.62378997
0
Stale info check type 3 Tests that the phase information, including all_seen, are not out of synch
def stale_info_type_3(self): type_3_a = False type_3_b_set = set() prp_sets = [] exists_phase_2 = False for k in self.get_fd_part_j(self.id): if not self.corr_deg(self.id, k): type_3_a = True if self.get_prp_j(k)[0] == ((self.get_prp_j(self...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_unstaged_changes(self):\n pass", "def check_consistency(self, es):", "def test_full_house_flush_ind(self):", "def insync_and_state_check(self):\n self.step('verifying tables are properly synced on all endpoints')\n is_ok = True\n limit, count = 10, 0\n while count...
[ "0.59557796", "0.58068776", "0.5780649", "0.5647411", "0.56288046", "0.5578073", "0.55761534", "0.55458236", "0.5541266", "0.55296147", "0.5525599", "0.54691684", "0.54571563", "0.5455311", "0.5441073", "0.54253876", "0.542445", "0.53946173", "0.53917575", "0.5380218", "0.537...
0.5904927
1
Tests if we are in the special state where there are no participants and all FD monitors are stable
def no_participants_and_stable_fd_monitors(self): if len(self.get_fd_j(self.id)) < 1: return False for k in self.get_fd_j(self.id): if (not self.resolver.fd_stable_monitor(k)) or (self.get_config_j(k) != constants.NOT_PARTICIPANT): return False logger.debu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_device_state(self):", "def nanny(self): \n while not self.started and not self.failed:\n eventlet.sleep(.1)\n return not self.failed", "def test_verify_state_of_a_device_when_disconnected_from_the_device():", "def __bool__(self):\n return self.wait(0)", "def p...
[ "0.6425011", "0.63082165", "0.6045461", "0.59334505", "0.59191984", "0.5908985", "0.5904193", "0.5903354", "0.5896522", "0.587225", "0.581643", "0.5764986", "0.5762647", "0.57485974", "0.5692651", "0.5689246", "0.5686668", "0.5686668", "0.5686668", "0.5686668", "0.5686668", ...
0.79300994
0
Return e from an input distribution
def get_e(num_sys=1, prob='thermal'): if prob == 'thermal': return np.sqrt(uniform(size=num_sys)) elif prob == 'flat': return uniform(size=num_sys) elif prob == 'circular': return np.zeros(num_sys) elif prob == 'tokovinin': # From Tokovinin & Kiyaeva (2016), MNRAS 456 r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def e(self):\n if self._e is None:\n # self._e = self.distributions.uniform(0.3,0.33)\n # return self._e\n # max is set by q but also limited by users choice of e_max.\n res_a = 29.9*((self.j[0]/self.k[0])**(2/3))\n q = self.distributions.truncated_norm...
[ "0.7415424", "0.7137588", "0.71217835", "0.695846", "0.6825506", "0.63998413", "0.6388059", "0.6343656", "0.6254818", "0.62431073", "0.6239055", "0.6230489", "0.62157154", "0.62043214", "0.6115948", "0.6113689", "0.6105811", "0.6094007", "0.6073158", "0.60673875", "0.60582536...
0.7340206
1
Create set of binaries to be saved to P_binary.binary_set
def generate_binary_set(num_sys=100000, ecc_prob='thermal', a_prob='log_flat', method='kepler'): global binary_set if method != 'kepler' and method != 'MOND': print("You must provide a valid method.") return # Create random binaries M1, M2, a, e, M, Omega, omega, inc = create_binaries...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createBinObjects(n):\n bins = []\n for i in range(n):\n \tbins.append(Bin())\n return bins", "def get_binaries(kdb,entry):\n xml = objectify.fromstring(entry.dump_xml())\n binaries = list(xml.xpath('./Binary'))\n for binary in binaries:\n yield (binary.Key.text, Binary(kdb,binary)...
[ "0.5964837", "0.59422576", "0.5907919", "0.58536303", "0.5810957", "0.55953133", "0.5575792", "0.5559989", "0.5528495", "0.54272175", "0.54035234", "0.5372073", "0.5370181", "0.5360584", "0.5342469", "0.5317253", "0.53051674", "0.52968377", "0.5291435", "0.5269143", "0.525454...
0.6768494
0
Test parsing a NatNet 3.0 packet containing an EchoRequest message.
def test_parse_echorequest_packet_v3(): data = open('test_data/echorequest_packet_v3.bin', 'rb').read() echo_request = deserialize(data, Version(3), strict=True) # type: EchoRequestMessage assert echo_request.timestamp == 278554190
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_nmap_icmp_echo_request(self):\n assert_equal(self.test_nmap.ICMP_ECHO_REQUEST, 8)", "def test_serialize_echorequest_message():\n expected = open('test_data/echorequest_packet_v3.bin', 'rb').read()\n actual = serialize(EchoRequestMessage(278554190))\n\n assert actual == expected", "def ...
[ "0.6922761", "0.645755", "0.62202394", "0.61036783", "0.6077745", "0.5845379", "0.561444", "0.56112283", "0.5592843", "0.5554618", "0.55424106", "0.5531693", "0.55176955", "0.5470128", "0.5331703", "0.52536505", "0.5216656", "0.52039826", "0.5197637", "0.5129498", "0.5113845"...
0.78382856
0
Test serializing an EchoRequest message.
def test_serialize_echorequest_message(): expected = open('test_data/echorequest_packet_v3.bin', 'rb').read() actual = serialize(EchoRequestMessage(278554190)) assert actual == expected
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_parse_echorequest_packet_v3():\n data = open('test_data/echorequest_packet_v3.bin', 'rb').read()\n echo_request = deserialize(data, Version(3), strict=True) # type: EchoRequestMessage\n\n assert echo_request.timestamp == 278554190", "def test_to_from_bytes(self):\n self.assertIsInstance...
[ "0.6572642", "0.61764574", "0.6086326", "0.59407955", "0.5922413", "0.58965194", "0.58927226", "0.5885049", "0.5877283", "0.5793095", "0.5780958", "0.57690734", "0.5724307", "0.5715814", "0.571562", "0.56420356", "0.5629515", "0.5627429", "0.56192356", "0.56028426", "0.559966...
0.802424
0
Returns the library context used in this discovery context.
def get_library_context(cls) -> tlib.LibraryContext: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def context(self):\n LOGGER.debug('Getting context: %s', self._context)\n return self._context", "def context(self):\n return self._context", "def context(self):\n return self._context", "def context(self):\n return self._context", "def context(self):\n return self...
[ "0.667756", "0.66378725", "0.66378725", "0.66378725", "0.66378725", "0.66378725", "0.66378725", "0.66378725", "0.663065", "0.66174483", "0.6544556", "0.649594", "0.6494292", "0.6387364", "0.63614374", "0.63529253", "0.6344479", "0.63225037", "0.63176763", "0.6317549", "0.6312...
0.77775526
0
Given an item path, yields all valid meta file paths that could provide direct metadata for that item. This also verifies that all of the resulting meta file paths exist.
def meta_files_from_item(cls, rel_item_path: pl.Path) -> tt.PathGen: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def items_from_meta_file(cls, rel_meta_path: pl.Path) -> tt.PathMetadataPairGen:\n pass", "def items_from_meta_file(cls, rel_meta_path: pl.Path) -> tt.PathMetadataPairGen:\n rel_meta_path, abs_meta_path = library_context.co_norm(rel_sub_path=rel_meta_path)\n\n # Check that the provid...
[ "0.66138536", "0.6287318", "0.5991842", "0.59201646", "0.55912", "0.55242085", "0.53850317", "0.536932", "0.535586", "0.5347209", "0.53227246", "0.5274453", "0.5271265", "0.5266176", "0.51852953", "0.5179801", "0.51075685", "0.5093312", "0.50908816", "0.5088963", "0.50860953"...
0.7029848
0
Given a meta file path, yields all item paths that this meta file provides metadata for, along with the metadata itself.
def items_from_meta_file(cls, rel_meta_path: pl.Path) -> tt.PathMetadataPairGen: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def meta_files_from_item(cls, rel_item_path: pl.Path) -> tt.PathGen:\n pass", "def items_from_meta_file(cls, rel_meta_path: pl.Path) -> tt.PathMetadataPairGen:\n rel_meta_path, abs_meta_path = library_context.co_norm(rel_sub_path=rel_meta_path)\n\n # Check that the provided path exis...
[ "0.6940595", "0.69089586", "0.6876326", "0.64572424", "0.628037", "0.62579995", "0.5958289", "0.5942649", "0.59193397", "0.59042585", "0.587694", "0.5822334", "0.57854456", "0.5695793", "0.56426466", "0.5638825", "0.5620414", "0.56117773", "0.55844843", "0.55390435", "0.55067...
0.71756345
0
Wrapper for scipy.integrate.solve_ivp that uses tqdm to monitor progress.
def solve_ivp_tqdm(fun, t_span, y0, t_eval, **kwargs): sol = None n = len(t_eval) - 1 for i in tqdm(range(n)): t0 = t_eval[i] tf = t_eval[i + 1] s = solve_ivp(fun, [t0, tf], y0, t_eval=[t0, tf], **kwargs) y0 = s.y[:, 1] if sol is None: sol = s else...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tqdm(*args, **kwargs):\n kwargs_ = dict(file=sys.stdout, disable=C.DISPLAY.PROGRESS.DISABLE, leave=False)\n kwargs_.update(kwargs)\n clear_tqdm()\n return tq.tqdm(*args, **kwargs_)", "def __call__(self, pv, sp, dt, freeze_ff=False): \n error = sp - pv\n if not freeze_ff:\n ...
[ "0.57856476", "0.54917467", "0.54638255", "0.5340637", "0.53261566", "0.5145216", "0.51342434", "0.5121947", "0.51104546", "0.5110409", "0.50878906", "0.5081126", "0.503787", "0.50289875", "0.49790072", "0.49576634", "0.49356022", "0.49148926", "0.49119833", "0.49048683", "0....
0.67726123
0
Return (left, right) and (bottom, top) tuples specifying a square viewport of sidelength `width` centered at `center`.
def compute_xy_lims(center, width): x, y = center w2 = width / 2 return (x - w2, x + w2), (y - w2, y + w2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def center(width, height):\n return width/2, height/2", "def get_bottom_center(left, right):\n x = (right.x - left.x) / 2 + left.x\n y = right.y - (right.y - left.y) / 5\n return (x, y)", "def center2corner(center):\n x, y, w, h = center[0], center[1], center[2], center[3]\n x1 = x - w * ...
[ "0.69217473", "0.6217429", "0.6214814", "0.613843", "0.6086448", "0.6063258", "0.6029447", "0.59973025", "0.59623396", "0.59502745", "0.59427935", "0.5881541", "0.587597", "0.5813926", "0.5798873", "0.57948077", "0.57931226", "0.5784657", "0.57794344", "0.57760435", "0.575416...
0.62433493
1
Handle logout requests Delete user's session entry in the sessions table Also, delete user's cookie whether session entry delete is successful or not Return 200 OK on success Otherwise, return 500 INTERNAL SERVER ERROR
def logout(): DBSessionMaker = sessionmaker(bind=engine) db_session = DBSessionMaker() # Find and delete user's session entry in the session table try: cookie_sess_id = request.cookies.get('session') db_session.query(Sessions).filter(Sessions.id==cookie_sess_id).delete() db_sess...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logout():\n session.clear()\n return json_response(status=200, response_data={\"success\": True})", "def logout():\n body = request.json\n user_id = body.get('user_id')\n user = User.get(User.id == user_id).username\n clear_token(user)\n return HTTPResponse(status=200, body={\"message\":...
[ "0.7407927", "0.7350498", "0.7283106", "0.7283106", "0.7241016", "0.7215676", "0.72012705", "0.7179627", "0.7175114", "0.7168609", "0.7154243", "0.71284455", "0.7119963", "0.71039796", "0.70737725", "0.7069549", "0.7069501", "0.70591354", "0.70546526", "0.7053894", "0.7050064...
0.81909466
0
Fills result_buffer with l, r bounds of intervals in w > low_threshold which exceed high_threshold somewhere
def find_intervals_above_threshold(w, high_threshold, low_threshold, result_buffer, dynamic_low_threshold_coeff=0): in_candidate_interval = False current_interval_passed_test = False current_interval = 0 result_buffer_size = len(result_buffer) last_index_in_w = len(w) - 1 current_candidate_inter...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def regrid(old_grid):\n bins = np.floor((np.log10(old_grid) - l_min) / dl).astype(int)\n w = (bins >= 0) & (bins < nbins)\n\n return bins, w", "def Bounds_to_short_filter(chargeBounds,dischargeBounds):\n \n global time_treshold \n \n ## first Filter filters all the windows which are below a ...
[ "0.553738", "0.54760826", "0.5427398", "0.53159803", "0.5290415", "0.5239659", "0.5216173", "0.51883864", "0.51512986", "0.51274943", "0.5100661", "0.5094", "0.5070553", "0.5060594", "0.50378984", "0.50272125", "0.49709576", "0.49683148", "0.4963083", "0.4962075", "0.49619874...
0.73507464
0
Finds argmax, area and center of gravity of hits in w indicated by (l, r) bounds in raw_hits. raw_hits should be a numpy array of (left, right) bounds (inclusive) Other arguments are numpy arrays which will be filled with results. centers, argmaxes are returned in samples right of hit start you probably want to convert...
def compute_hit_properties(w, raw_hits, argmaxes, areas, centers): for hit_i in range(len(raw_hits)): current_max = -999.9 current_argmax = -1 current_area = 0.0 current_center = 0.0 for i, x in enumerate(w[raw_hits[hit_i, 0]:raw_hits[hit_i, 1]+1]): if x > current...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _getTopCenterIndices(self, resolution, rectangular):\n # get x, y indices to get away from the ring basis.\n # indices starts with (0, 0) in the middle, with (r2, p1) -> (1, 0), etc. (x is on the pos 1 ray)\n\n numAxialLevels = 2 * resolution\n xi, yi = self.indices()\n if r...
[ "0.54468155", "0.5245982", "0.52018434", "0.51407737", "0.5027572", "0.501179", "0.49909672", "0.49505368", "0.49250877", "0.49115202", "0.49069312", "0.4905353", "0.48982129", "0.48870504", "0.4865395", "0.48550183", "0.4845263", "0.47969246", "0.4787651", "0.4767172", "0.47...
0.73296267
0
Construct a GRU RNN cell. It is configured to be passed to a multi rnn cell wrapper.
def build_gru_cell(num_units, dropout): cell = tf.nn.rnn_cell.GRUCell(num_units) if dropout: result = tf.nn.rnn_cell.DropoutWrapper(cell, output_keep_prob=1-dropout) return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _initialize_gru_cell(self, num_units):\n return gru_cell.LayerNormGRUCell(\n num_units,\n w_initializer=self.uniform_initializer,\n u_initializer=random_orthonormal_initializer,\n b_initializer=tf.constant_initializer(0.0))", "def build_rnn_cell(type, num_units, dropout):\n ...
[ "0.75219285", "0.67751324", "0.65611047", "0.652693", "0.65234923", "0.6497355", "0.6401402", "0.6371681", "0.6347477", "0.6342275", "0.62993085", "0.6285365", "0.6272967", "0.6165039", "0.61427605", "0.6132339", "0.610192", "0.6040023", "0.59487605", "0.58486575", "0.5812393...
0.75191617
1
Multi RNN cell wraps a sequence of cells into one cell
def build_multi_rnn(cells): return tf.nn.rnn_cell.MultiRNNCell(cells)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_rnn_cells(self, is_list=False):\n\n stacked_rnn = []\n for _ in range(self.num_layers):\n single_cell = self._rnn_single_cell()\n stacked_rnn.append(single_cell)\n\n if is_list:\n return stacked_rnn\n else:\n return tf.nn.rnn_cell....
[ "0.7117752", "0.70600027", "0.674815", "0.65157115", "0.6431374", "0.63540703", "0.6354059", "0.62947875", "0.6241957", "0.6232274", "0.61524653", "0.6138036", "0.6061001", "0.6054821", "0.6045019", "0.5993263", "0.59205985", "0.5865216", "0.5863549", "0.58027077", "0.5800259...
0.76230234
0
Writes an inverted depth map for visualization purposes
def write_inverse_depth_map(image, file_path, exp=2): max_int = 65535 image = image.astype(np.float) # First normalize image so it has min 0 and max = max_int image -= image.min() image *= (max_int / image.max()) # Invert the depth map and clip values inv_depth = np.power((max_int - ima...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def depth_write(filename, depth):\n height,width = depth.shape[:2]\n f = open(filename,'wb')\n # write the header\n f.write(TAG_CHAR)\n np.array(width).astype(np.int32).tofile(f)\n np.array(height).astype(np.int32).tofile(f)\n \n depth.astype(np.float32).tofile(f)\n f.close()", "def vi...
[ "0.6111801", "0.5630799", "0.56008345", "0.55997056", "0.5511597", "0.542956", "0.5360804", "0.5283929", "0.52789986", "0.52727956", "0.52653193", "0.52343005", "0.5219354", "0.5218975", "0.52015257", "0.51914287", "0.5164077", "0.5152135", "0.51328915", "0.51264036", "0.5116...
0.7003182
0
Write the reference image to file
def write_reference_image(image, file_path): image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR) image_file = file_io.FileIO(file_path, mode='w') scipy.misc.imsave(image_file, image) if FLAGS.wandb: import_wandb_idempotent() wandb.log({"reference_images": wandb.Image( image, capti...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(self, image):\n raise NotImplementedError()", "def write_image(self, filename):\n cv2.imwrite(filename, self.image)", "def write(self, filename):\n\n self.__image.save(filename)", "def write_image(self, image_name, image):\n raise NotImplementedError", "def _write_imag...
[ "0.69628483", "0.69618964", "0.68769765", "0.6668209", "0.66418636", "0.6594738", "0.6593247", "0.6537305", "0.65141255", "0.6454284", "0.6440225", "0.6417902", "0.63384825", "0.62854207", "0.6278705", "0.6278705", "0.62725496", "0.62672776", "0.62109727", "0.62030536", "0.62...
0.8076047
0
The data_root directory should contain multiple sessions, which are then parsed into the data structure that the train data generator expects
def gen_data(data_root, val_ratio = 0.1): session_list = os.listdir(data_root)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_sessions_raw(data_folder, dataset_id, subject):\r\n runs = []\r\n labels = []\r\n sessions_path = []\r\n bad_sessions_path = []\r\n\r\n # the following verification will be required for handling several datasets\r\n if dataset_id in [\"raw_clean_32\"]:\r\n # stack all subject's se...
[ "0.6645324", "0.6629811", "0.6509914", "0.6344045", "0.6299465", "0.62585074", "0.6237367", "0.61997366", "0.6190447", "0.61850005", "0.6172695", "0.6130764", "0.6053007", "0.6043277", "0.6009851", "0.6003062", "0.5983032", "0.5980272", "0.59700936", "0.5967737", "0.5965835",...
0.7452929
0
mvs input path list
def gen_pipeline_mvs_list(dense_folder): image_folder = os.path.join(dense_folder, 'images') cam_folder = os.path.join(dense_folder, 'cams') cluster_list_path = os.path.join(dense_folder, 'pair.txt') cluster_list = open(cluster_list_path).read().split() # for each dataset mvs_list = [] pos ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ReadMaterialNameList(InputPath,MaterialInputFormat):\r\n\r\n FullNameList=os.listdir(InputPath)\r\n MaterialPathList=[]\r\n\r\n for FullName in FullNameList:\r\n Name,NameType=os.path.splitext(FullName)\r\n if NameType=='.'+MaterialInputFormat:\r\n MaterialPath=os.path.join(In...
[ "0.5590496", "0.55235755", "0.551063", "0.5434746", "0.5407543", "0.533063", "0.5286901", "0.5258207", "0.52529585", "0.5233829", "0.5219519", "0.52053213", "0.51721156", "0.5170925", "0.5170338", "0.51638436", "0.51434004", "0.5124624", "0.50988007", "0.5092586", "0.5089801"...
0.56417423
0
Bottleneck style deconvolutional block. Applies convolution to decrease to fewer features. upscales in lower feature space. Convolves to specified feature numbers
def deconv_block(input_tensor: tf.Tensor, features: int, name: str) -> tf.Tensor: out = input_tensor out = KL.Conv2D( int(features // 2), 1, strides=(1, 1), name=name + f"_c{1}", )(input_tensor) out = KL.Activation("relu")(KL.BatchNormalization()(out)) out = KL.Conv...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deconv2d(layer_input, skip_input, filters, f_size=4, dropout_rate=0):\n u = UpSampling2D(size=2)(layer_input)\n u = Conv2D(filters, kernel_size=f_size, strides=1, padding='same', activation='relu')(u)\n if dropout_rate:\n u = Dropout(dropout_rate)(u)\n ...
[ "0.66970915", "0.6696661", "0.65982324", "0.6569558", "0.6451675", "0.64417726", "0.6432913", "0.64248526", "0.6383107", "0.638251", "0.6306522", "0.62553823", "0.62296945", "0.62154955", "0.6210682", "0.62052447", "0.6203493", "0.6182055", "0.6151423", "0.6131423", "0.612682...
0.69930655
0
Method to build Autoencoder model
def build(self) -> KM.Model: # For decoder number of features in opposite order of encoder decoder_features = self.encoder_features.copy() decoder_features.reverse() # build the encoder model self.encoder_model = self.encoder( features=self.encoder_features, name="e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_autoencoder(self):\n # first build the encoder model\n inputs = Input(shape=(self.state_dim, ), name='state')\n feature_size = 32\n x = Dense(256, activation='relu')(inputs)\n x = Dense(128, activation='relu')(x)\n feature = Dense(feature_size, name='feature_vect...
[ "0.82949173", "0.76155895", "0.75755745", "0.7398432", "0.7116697", "0.70985246", "0.7069066", "0.7069066", "0.70482296", "0.6987326", "0.6975115", "0.6914817", "0.69129205", "0.6911162", "0.68955237", "0.68723565", "0.6821266", "0.68082154", "0.6784743", "0.67726874", "0.676...
0.7890221
1
Serial Port Listener Thread Parse incoming serial data as NMEA and update global position variables
def serialListener(): global serial_running, serial_port, serial_baud _ser = None while serial_running: # Attempt to connect to the serial port. while _ser == None: try: _ser = serial.Serial(port=serial_port,baudrate=serial_baud,timeout=5) logging...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_from_serial(self):\n self.running = True\n while self.running:\n data = self.serial.readline().decode()\n if \"DATA\" not in data:\n print(\"ERREUR : {}\".format(data))\n continue\n\n try:\n _, hum, tem = data.spli...
[ "0.66137105", "0.6448608", "0.638399", "0.63070023", "0.62900025", "0.62591594", "0.6203933", "0.6140255", "0.6090649", "0.607038", "0.60594726", "0.6046943", "0.603479", "0.6034654", "0.60236263", "0.59371054", "0.59338635", "0.59257245", "0.5924867", "0.59244245", "0.592183...
0.6639838
0
Habitat Uploader Thread. Every X seconds, upload current position to Habitat (if it is valid).
def uploadLoop(): global position_valid, update_rate, upload_loop_running, last_upload_time while upload_loop_running: if position_valid: if (time.time() - last_upload_time) > update_rate: uploadPosition() last_upload_time = time.time() time.sleep(0.5...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put_upload(self):\n # print \"starting upload...\", self.current_upload['filepath']\n self.touch()\n self.log(\"STARTING_UPLOAD\", level=INFO)\n try:\n Backend.put_file(self.fileobj, self.current_upload[\"gcs_url\"])\n except exceptions.FilePutError as err:\n ...
[ "0.62125075", "0.58900535", "0.588939", "0.57625514", "0.56021225", "0.558986", "0.55853134", "0.55834824", "0.55829453", "0.5580088", "0.5574044", "0.55571914", "0.5483306", "0.5414025", "0.54065275", "0.54006064", "0.5394117", "0.53883696", "0.53689504", "0.5345808", "0.532...
0.77333915
0
Launch filtering, sorting and paging to output results.
def run(self): query = self.query # count before filtering # self.cardinality = query.add_columns(self.columns[0].sqla_expr).count() self._set_column_filter_expressions() self._set_global_filter_expression() self._set_sort_expressions() self._set_yadcf_data(quer...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _main_search(args = None, stdout = None, stderr = None) :\n if stdout is None :\n stdout = sys.stdout\n if stderr is None :\n stderr = sys.stderr\n # Process arguments\n if args is None :\n parser = _makeParser_search()\n args = parser.parse_args()\n args = _processAr...
[ "0.6229353", "0.59733063", "0.59710497", "0.595373", "0.59382564", "0.5879047", "0.586713", "0.5776297", "0.57640386", "0.5739738", "0.5725649", "0.5720083", "0.5701067", "0.56792367", "0.56787074", "0.5669591", "0.56633604", "0.56586134", "0.5649159", "0.5640814", "0.5633297...
0.6596437
0
Calculate the Npad for padding can be adjusted with compression parameter By default, 8 times smaller than ROI
def init_Npad(ROI, compression = 8): if (ROI[2]-ROI[0])>(ROI[3]-ROI[1]): Npad = (ROI[2]-ROI[0])//compression else: Npad = (ROI[3]-ROI[1])//compression return Npad
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def padding(self):\n pad = self.ntiles - self.windowsize\n return (int((pad - 1)/2.), int((pad + 1)/2.))", "def padding_width(self):\n ...", "def make_padding(kernel_size, stride, dilation):\n return -((-kernel_size - (kernel_size - 1) * (dilation - 1)) // stride + 1) // 2", "def padd...
[ "0.7143295", "0.6820026", "0.6658783", "0.65967077", "0.6595212", "0.6571076", "0.652692", "0.6465871", "0.64643", "0.64542764", "0.64039046", "0.63836664", "0.6337319", "0.6321386", "0.63163275", "0.6272476", "0.62662464", "0.6221071", "0.6217532", "0.6215494", "0.62136424",...
0.82028204
0
The dump() method returns a list of strings describing the memory structure of the tag, suitable for printing with join(). The
def dump(self): return []
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dump(self) : \n mybuffer = []\n if None not in (self.version, self.operation_id) :\n mybuffer.append(chr(self.version[0]) + chr(self.version[1]))\n mybuffer.append(pack(\">H\", self.operation_id))\n mybuffer.append(pack(\">I\", self.request_id or 1))\n ...
[ "0.69860065", "0.6731522", "0.63727385", "0.63554734", "0.6334931", "0.631974", "0.62619233", "0.6211208", "0.61863095", "0.6178631", "0.6169962", "0.6127721", "0.6067054", "0.60600877", "0.6046598", "0.6044149", "0.6036777", "0.5998513", "0.5989506", "0.59705776", "0.5962360...
0.6774778
1
Format the tag to make it NDEF compatible or erase content.
def format(self, version=None, wipe=None): if hasattr(self, "_format"): args = "version={0!r}, wipe={1!r}" args = args.format(version, wipe) log.debug("format({0})".format(args)) status = self._format(version, wipe) if status is True: self._ndef = None...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setHTMLFormat(self, tag):\r\n\r\n self.formatBeginTag = tag.strip()\r\n name = tag.split(\"<\")[1].strip().split(\" \")[0]\r\n self.formatEndTag = \"</\" + name + \">\"", "def format_tag(tag):\n # If the tag presented is an IP address then no modifications are required\n try:\n ip_netwo...
[ "0.6241722", "0.62015337", "0.5582614", "0.5329126", "0.52722013", "0.52667856", "0.5261306", "0.5112217", "0.5098085", "0.5040138", "0.50002456", "0.4988982", "0.49860567", "0.49759218", "0.49672845", "0.4957511", "0.48991778", "0.48872223", "0.48762155", "0.48676845", "0.48...
0.64110184
0
Authenticate a tag with a password. A tag that was once protected with a password requires authentication before write, potentially also read, operations may be performed. The password must be the same as the
def authenticate(self, password): if hasattr(self, "_authenticate"): args = "password={0!r}".format(password) log.debug("authenticate({0})".format(args)) self._authenticated = self._authenticate(password) if self._authenticated is True: self._ndef = None ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticate(self, password):\n request = self.request(Message.SERVERDATA_AUTH, unicode(password))\n with self.response_to(request) as response:\n if response.id == -1:\n raise AuthenticationError\n self.is_authenticated = True", "def authenticate(self, user...
[ "0.6604293", "0.6422022", "0.6362609", "0.62599635", "0.6093403", "0.599157", "0.59540224", "0.59466195", "0.5909857", "0.5858733", "0.58374655", "0.5792238", "0.57880074", "0.5733425", "0.5731193", "0.57185864", "0.5706808", "0.56747884", "0.5662594", "0.5651024", "0.5629167...
0.6644355
0
testing adding Nans to empty rows in sparse matrix
def test_add_nans_to_weights(): # create input sparse matrix with one empty row (j=2) coords = np.array([[0, 3, 1, 0], [0, 3, 1, 2]]) data = np.array([4.0, 5.0, 7.0, 9.0]) Matin = sps.COO(coords, data, shape=(4, 4)) # this is what is expected to come out (Nan added at i=0, j=2) coords = np.arra...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_add_nans_to_weights():\n # create input sparse matrix with one empty row (j=2)\n row = np.array([0, 3, 1, 0])\n col = np.array([0, 3, 1, 2])\n data = np.array([4., 5., 7., 9.])\n Matin = sps.coo_matrix((data, (row, col)), shape=(4, 4))\n\n # this is what is expected to come out (Nan ad...
[ "0.7653261", "0.6942307", "0.6642543", "0.65246856", "0.6388985", "0.638396", "0.63753945", "0.614265", "0.6079368", "0.5998489", "0.5955489", "0.5925455", "0.5894164", "0.58506966", "0.5786227", "0.57838506", "0.57823104", "0.57536805", "0.5743613", "0.5722805", "0.5714739",...
0.7446927
1
For each entry in op_dict, create an appropriate dictionary that can be used to fill the 'code' template.
def _pull_argops(op_dict): import inspect out = [] keys = op_dict.keys() keys.sort() # Not necessary, but makes scanning the printout easier for k in keys: # Create a dictionary that will be used to fill the 'code' template d = {} d["enum_name"] = enum_name = op_dict[k][3:] #...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def code_input(dict_, i):\n for key in dict_:\n dict_[key] = i + dict_[key]\n return dict_", "def render(self, code_proxy):\n code_proxy.bytecode.add(opcode.opmap[self.opname])", "def dict_to_code(mapping):\n lines = (\"{} = {}\".format(key, repr(value))\n for key...
[ "0.57808787", "0.55444884", "0.5413896", "0.5402583", "0.5367587", "0.5339427", "0.532061", "0.5296568", "0.5256839", "0.52433896", "0.51989514", "0.5136526", "0.5134199", "0.51259196", "0.5122549", "0.51182413", "0.51154214", "0.5094699", "0.5089987", "0.50874263", "0.503335...
0.61465585
0
Render the body template, if defined. Otherwise, jump the context as a JSON object.
def render_body(self, context): if self.body_template: return render_jinja2(self.body_template, context) else: return json.dumps(context, cls=JSONEncoder)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render(self, _template, context=None):\n variables = {}\n if context:\n variables.update(context)\n rv = self.jinja2.render_template(_template, **variables)\n self.response.write(rv)", "def render(self, _template, **context):\n context['_request'] = self.request\...
[ "0.6415161", "0.6371459", "0.614349", "0.6088617", "0.6073203", "0.6023662", "0.59383094", "0.59063464", "0.5894329", "0.5863352", "0.58564246", "0.5829931", "0.5821167", "0.57523584", "0.573967", "0.5728318", "0.57185173", "0.5712654", "0.5710085", "0.5700231", "0.5688118", ...
0.8101176
0
Render the payload URL.
def render_payload_url(self, context): return render_jinja2(self.payload_url, context)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def renderHTTP(self, ctx):\n return url.URL.fromContext(ctx).child('')", "def url(self):\n return url_for_item(self.key)", "def url(self):\n return url_for_item(self.key)", "def __str__(self):\n self.render()\n params = '&'.join(['%s=%s'%x for x in self.data.items() if x[1]...
[ "0.69234157", "0.60506034", "0.60506034", "0.60468316", "0.58912516", "0.58324456", "0.58206755", "0.57969487", "0.57580036", "0.5751476", "0.5719406", "0.5718504", "0.5689432", "0.5686505", "0.5625121", "0.56219465", "0.561779", "0.5611863", "0.5607267", "0.56013036", "0.558...
0.83381814
0
Render the CustomLink given the provided context, and return the text, link, and link_target.
def render(self, context): text = render_jinja2(self.link_text, context).strip() if not text: return {} link = render_jinja2(self.link_url, context).strip() link_target = ' target="_blank"' if self.new_window else '' # Sanitize link text allowed_schemes = get...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def custom_links(context, obj):\n content_type = ContentType.objects.get_for_model(obj)\n custom_links = CustomLink.objects.filter(content_types=content_type, enabled=True)\n if not custom_links:\n return ''\n\n # Pass select context data when rendering the CustomLink\n link_context = {\n ...
[ "0.65826654", "0.65728986", "0.6345681", "0.59130216", "0.57122743", "0.56766665", "0.5618983", "0.5512928", "0.5460195", "0.543479", "0.54293305", "0.54070026", "0.53497344", "0.5223261", "0.51964355", "0.51875687", "0.5176072", "0.5161376", "0.51202476", "0.5097645", "0.509...
0.67232096
0
Synchronize template content from the designated DataFile (if any).
def sync_data(self): self.template_code = self.data_file.data_as_string
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def updateFileData(self):\n with open(pagePath(self.pageName)) as f:\n self.fileData = f.read()\n self.lastUpdated = time.time()", "def test_yaml_file_watch(self):\n # Set initial data\n _setup_template_value('yaml_file_test_values.tmp.yml', 'yaml_file_test_values_1.yml')\n...
[ "0.5942566", "0.58803123", "0.5711093", "0.5618945", "0.56182575", "0.55685955", "0.55464983", "0.5508211", "0.54465634", "0.5385772", "0.5309885", "0.5250627", "0.52483416", "0.52441293", "0.5243234", "0.52383935", "0.52373266", "0.5227429", "0.5219678", "0.5208981", "0.5191...
0.7512393
0
Wrapper around `image.size` to suppress an OSError in case the file is inaccessible. Also opportunistically catch other exceptions that we know other storage backends to throw.
def size(self): expected_exceptions = [OSError] try: from botocore.exceptions import ClientError expected_exceptions.append(ClientError) except ImportError: pass try: return self.image.size except tuple(expected_exceptions): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_image_size(file_name):\r\n return Image.open(file_name).size", "def size(path):", "def remove_img_size(self, id):\n\n try:\n img_size = os.path.getsize(\"{}{}.jpg\".format(self.img_path, id))\n logger.debug(\"img_size: {}\".format(img_size))\n except FileNotFoundE...
[ "0.6170825", "0.5982166", "0.59802794", "0.59526426", "0.5938609", "0.5935151", "0.5859361", "0.5820605", "0.57776374", "0.5775356", "0.5722424", "0.5716205", "0.5692693", "0.5692693", "0.56543833", "0.56506926", "0.56453097", "0.5643101", "0.5634143", "0.5629508", "0.5626837...
0.70213586
0
Sets screen timeout to integer given in wait, 0 to not wait, 1 to wait
def set_timeout(self, wait): self._screen.timeout(wait)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wait(wait_time=WAIT_TIME):\n # time.sleep(wait_time)\n pass", "def wait_second(self, time_wait):\n # each test case 1st check for the stop button flag\n if not self.stopLoop:\n # get time\n ts = datetime.datetime.now().strftime(self.tsFormat)\n # Create la...
[ "0.6864472", "0.6734727", "0.66955775", "0.6690098", "0.66128355", "0.65210015", "0.65123713", "0.6465837", "0.64603263", "0.6449477", "0.6414831", "0.63922095", "0.6379595", "0.63737917", "0.6324914", "0.6282336", "0.6238094", "0.622744", "0.62160945", "0.6168285", "0.614871...
0.8473102
0
Resize terminal, returns terminal size as [y,x]
def _size_term(self): curr_dim = self._screen.getmaxyx() dims = [50, 150] if curr_dim[0] < dims[0] or curr_dim[1] < dims[1]: sys.stdout.write("\x1b[8;{rows};{cols}t".format(rows=dims[0], cols=dims[1])) curses.resize_term(dims[0], dims[1]) return dims e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_terminal_size_windows():\r\n\r\n\r\n #from https://gist.github.com/jtriley/1108174, thank you very much for this hard to produce code!\r\n\r\n # stdin handle is -10\r\n # stdout handle is -11\r\n # stderr handle is -12\r\n h = windll.kernel32.GetStdHandle(-12)\r\n csbi = create_string_bu...
[ "0.72301054", "0.72121006", "0.69198793", "0.69139826", "0.68285036", "0.67593", "0.67591816", "0.6742283", "0.66999054", "0.66502917", "0.6555379", "0.65499055", "0.6541336", "0.65292513", "0.6461325", "0.64533347", "0.642946", "0.6397398", "0.63638514", "0.63601255", "0.635...
0.7643062
0
Adds char to screen at modified y, modified x and returns modified coordinates
def add_char(self, coord, char, modify=False): if modify: range_y, range_x = self._map_dims new_coord = [coord[0]+range_y[0]-1, coord[1]+range_x[0]-1] self._screen.addch(new_coord[0], new_coord[1], char) self._screen.refresh() return new_coord ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def point(self, x, y, char):\n assert len(char) == 1\n assert x >= 0\n assert x < self.cols\n assert y >= 0\n assert y < self.lines\n\n self.canvas[y][x] = char", "def move_character(self, old_y, old_x, y_pos, x_pos):\n self.map[old_y][old_x] = ' '\n self.m...
[ "0.7519669", "0.7025201", "0.699285", "0.6764224", "0.6750597", "0.6709837", "0.6686409", "0.6661057", "0.6660266", "0.6515418", "0.6512104", "0.64473236", "0.6424062", "0.6377652", "0.63251984", "0.62041324", "0.61488396", "0.61447257", "0.6105792", "0.60999763", "0.60823166...
0.72516125
1
Displays room on screen from room object given and returns player position
def display_room(self, room, player_start=[]): map_start = 8 self.clear() room_width = 0 spacing = 3 image_file = str(room.include[0].value.strip()) room_tx = self.read_text(image_file) room_id = room.attrs['id'] self.ascii_to_screen_map(map_start, room_tx...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def adminDisplayRoom(player, room):\r\n curRoom = world.maps.World.mapGrid[room]\r\n exitstr = ''\r\n \r\n sendToPlayer( player, \"{0}{1} - (Room #: {2})\".format(LCYAN, curRoom.name, room) )\r\n \r\n items = curRoom.getItems()\r\n if items:\r\n sendToPlayer( player, \"{0}You notice: {1...
[ "0.6467579", "0.6305366", "0.59879905", "0.5919578", "0.588053", "0.58723104", "0.5866267", "0.582144", "0.5761883", "0.5741979", "0.57015663", "0.56834424", "0.5594203", "0.5560418", "0.5539656", "0.55343395", "0.5512155", "0.55069023", "0.5488417", "0.54213583", "0.54205406...
0.7651127
0
Returns a vector of concept scores for the given features using a normalized dot product similarity as in Yeh et al.
def dot_prod_concept_score( features, concept_vectors, epsilon=1e-5, beta=1e-5, channels_axis=-1, ): # First check that all the dimensions make sense assert features.shape[channels_axis] == concept_vectors.shape[-1], ( f'Expected input to have {concept_vectors.shape[-1]} elements in ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_normalization_scalar(features: List[List[float]]) -> List[List[float]]:\n normalized_features = []\n for feature in features:\n sum_squares = 0\n for i in feature:\n sum_squares += i * i\n sum_squares_root = np.sqrt(sum_squares)\n if sum_squares == 0:\n ...
[ "0.6520329", "0.6430667", "0.6394072", "0.6382461", "0.6351479", "0.6329946", "0.6322808", "0.6261107", "0.6182496", "0.6160588", "0.60493076", "0.60208386", "0.59891814", "0.59368724", "0.593012", "0.58729786", "0.5855223", "0.58174413", "0.57436484", "0.5715467", "0.5713523...
0.6894692
0
Returns the completeness score for the given set of concept vectors `concept_vectors` using testing data `X` with labels `y`. This score is computed using Yeh et al.'s definition of a concept completeness score based on a model `features_to_concepts_fn`, which maps input features in the test data to a Mdimensional spac...
def completeness_score( X, y, features_to_concepts_fn, concepts_to_labels_model, concept_vectors, task_loss, g_model=None, test_size=0.2, concept_score_fn=dot_prod_concept_score, predictor_train_kwags=None, g_optimizer='adam', acc_fn=sklearn.metrics.accuracy_score, ch...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def direct_completeness_score(\n X,\n y,\n features_to_concepts_fn,\n concept_vectors,\n task_loss,\n g_model=None,\n test_size=0.2,\n concept_score_fn=dot_prod_concept_score,\n predictor_train_kwags=None,\n g_optimizer='adam',\n acc_fn=sklearn.metrics.accuracy_score,\n channels...
[ "0.7881465", "0.63660175", "0.5906341", "0.57350284", "0.57198316", "0.56847036", "0.5677614", "0.54979914", "0.5444112", "0.54306525", "0.54055405", "0.53992796", "0.5395767", "0.5350958", "0.5346281", "0.53277713", "0.5252939", "0.5245883", "0.52315956", "0.52152485", "0.52...
0.7786654
1
Returns the completeness score for the given set of concept vectors `concept_vectors` using testing data `X` with labels `y`. This score is computed as the predictive accuracy of a model trained to predict the labels using the concepts scores alone. It differs from the method above in that it does not require a pretrai...
def direct_completeness_score( X, y, features_to_concepts_fn, concept_vectors, task_loss, g_model=None, test_size=0.2, concept_score_fn=dot_prod_concept_score, predictor_train_kwags=None, g_optimizer='adam', acc_fn=sklearn.metrics.accuracy_score, channels_axis=-1, ): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def completeness_score(\n X,\n y,\n features_to_concepts_fn,\n concepts_to_labels_model,\n concept_vectors,\n task_loss,\n g_model=None,\n test_size=0.2,\n concept_score_fn=dot_prod_concept_score,\n predictor_train_kwags=None,\n g_optimizer='adam',\n acc_fn=sklearn.metrics.accur...
[ "0.746663", "0.6051819", "0.60288906", "0.58814985", "0.5831503", "0.582439", "0.58031857", "0.5762847", "0.57567835", "0.57425153", "0.57226914", "0.5668934", "0.56666696", "0.56418574", "0.5637015", "0.5628586", "0.56230634", "0.56153", "0.56012875", "0.55907965", "0.557798...
0.7730111
0
Finds the delta in time since the last timestamp If the game is not started it resets timestamp to None and returns 0. If the game is started but the timestamp is None, make the first timestamp to the current time. Otherwise it will return the amount of time since the timestamp in seconds.
def elapsed_time(self): # reset timer if game is not started if not self.started: self.timestamp = None return 0 # sets the first timer if self.timestamp is None: self.timestamp = time.time() return 0 # if there is a previous timer ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def time_left(timestamp):\n if timestamp is None:\n return None\n return max(0.0, timestamp - time.time())", "def seconds_from_last_update(self):\n return (datetime.utcnow() - self.last_update_datetime).total_seconds()", "def seconds_since_previous_event(self):\n if self.previous_eve...
[ "0.7057593", "0.6650774", "0.6599977", "0.659276", "0.65243965", "0.65226424", "0.64636683", "0.64425397", "0.6433153", "0.64077157", "0.63585246", "0.6326008", "0.6321055", "0.63080907", "0.6296014", "0.62940556", "0.6289301", "0.6285546", "0.62577814", "0.6245347", "0.62418...
0.72524625
0
Searches the list of players for a given name Returns the first instance where a player has the given name.
def find_player(self, name): for index in range(0, len(self.player_list)): if self.player_list[index].name == name: return self.player_list[index]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def player(self, name):\n\n self.name = name\n q = Query()\n data = TinyDB('app/data/db_player.json').table('players')\n\n self.search_result = data.search(\n (q.name == self.name) |\n (q.surname == self.name)\n )\n\n if len(self.search_re...
[ "0.7655409", "0.7581371", "0.73113996", "0.72627175", "0.7086329", "0.70571876", "0.70207703", "0.686663", "0.6809111", "0.67774487", "0.6688535", "0.6658734", "0.66132474", "0.6570869", "0.65514565", "0.65377414", "0.6527125", "0.65249634", "0.6492997", "0.6479223", "0.64773...
0.8673462
0
Find yourself from the player list
def find_self(self): for index in range(0, len(self.player_list)): if self.player_list[index].name == self.jid: return self.player_list[index]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_player(self, name):\n for index in range(0, len(self.player_list)):\n if self.player_list[index].name == name:\n return self.player_list[index]", "def found_specific_player(self) -> Player:\n search_question = ('Nom du joueur recherché : ',\n ...
[ "0.71058077", "0.692956", "0.6456459", "0.62968767", "0.6243386", "0.60800767", "0.6001927", "0.5991489", "0.5903297", "0.5883829", "0.5882624", "0.58718306", "0.58087987", "0.5801809", "0.57950425", "0.5751915", "0.5722757", "0.5700745", "0.5680296", "0.5672891", "0.5670528"...
0.6999478
1
Create a ``RegistrationProfile`` for a given ``User``, and return the ``RegistrationProfile``.
def create_profile(self,user): salt= sha.new(str(random.random())).hexdigest()[:5] activation_key = sha.new(salt+user.username).hexdigest() return RegistrationProfile(user=user, activation_key=activation_key)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_registration_profile(self, user):\n salt = hashlib.sha1(str(random.random())).hexdigest()[:10]\n activation_key = hashlib.sha1(salt + user.username).hexdigest()\n\n return self.create(user=user, activation_key=activation_key)", "def create_profile(self, user):\n salt = sha....
[ "0.8223235", "0.78692263", "0.7372174", "0.73067397", "0.70762444", "0.6990593", "0.69725096", "0.6967239", "0.6944255", "0.6929402", "0.6837238", "0.6790474", "0.67200273", "0.6655921", "0.6645508", "0.6624257", "0.6616297", "0.6602875", "0.6593323", "0.6572731", "0.6567856"...
0.82466364
0
Redirects to url associated with shortened url
def link_redirect(request, shortened_url: str): try: url = Url.objects.get(short_url=shortened_url) long_url = url.long_url return HttpResponseRedirect(long_url) except Url.DoesNotExist or TypeError: return HttpResponseBadRequest("Wrong url")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def go_to_short_url(short_url):\n try:\n original_url = storage.get(short_url)\n return redirect(original_url)\n except:\n abort(400)", "def redirect_to_url(request, short_url):\n try:\n url = Url.objects.get(short_url=short_url)\n except Url.DoesNotExist:\n raise H...
[ "0.83120644", "0.8086085", "0.77167374", "0.76132107", "0.7463425", "0.7415398", "0.729672", "0.7218429", "0.7165089", "0.7079031", "0.7077186", "0.7062728", "0.70217586", "0.7017701", "0.6979237", "0.6929563", "0.6903711", "0.67491883", "0.674119", "0.6737849", "0.6708151", ...
0.8299281
1
Given a list of `rows` containing unicode strings, return a new list of rows with those strings encoded as utf8 for CSV compatibility.
def _get_utf8_encoded_rows(row): if six.PY2: return [six.text_type(item).encode('utf-8') for item in row] else: return [six.text_type(item) for item in row]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _unicode_rows(stream, encoding, dialect, **kwds):\n # Get Unicode stream.\n if isinstance(stream, io.IOBase):\n streamreader_type = codecs.getreader(encoding)\n unicode_stream = streamreader_type(stream)\n elif isinstance(stream, Iterable):\n first_row, str...
[ "0.7000041", "0.69420046", "0.65636086", "0.643498", "0.6428575", "0.64129543", "0.6176699", "0.59829676", "0.59803176", "0.59619296", "0.596183", "0.58481246", "0.57346743", "0.57331055", "0.56966454", "0.55054474", "0.5471676", "0.5449447", "0.54462504", "0.5416911", "0.535...
0.8232703
0
Verify if course.id exists
def validate_course(self, id_curso): from openedx.core.djangoapps.content.course_overviews.models import CourseOverview try: aux = CourseKey.from_string(id_curso) return CourseOverview.objects.filter(id=aux).exists() except InvalidKeyError: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verify_course(self, course, course_id='edX/toy/2012_Fall'):\n assert course_id == str(course.id)", "def is_course_exists(self):\n db = Course._file.read_db()\n courses = db[\"courses\"]\n for crs in courses:\n if crs[\"course_name\"] == self._course_name:\n ...
[ "0.78091115", "0.70707774", "0.68760955", "0.68757963", "0.6827377", "0.6823711", "0.6817545", "0.67981637", "0.6734861", "0.67331326", "0.6726011", "0.6682209", "0.6659843", "0.66595834", "0.66560584", "0.66188556", "0.65669453", "0.6452305", "0.6389866", "0.638358", "0.6345...
0.76066273
1
Returns information about the ancestors of an xblock.
def get_block_ancestors(self, xblock, store): ancestors = [] def collect_ancestor_info(ancestor): """ Collect xblock info regarding the specified xblock and its ancestors. """ if ancestor.location.block_type != 'course': ancestors.append({...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ancestors(self):\r\n return Node.s_ancestors(self)", "def ancestors(self):\n return self._ancestors", "def ancestors(self):\n return self._ancestors", "def ancestors(self):\n l = []\n n = self.node.parentNode\n while n:\n l.append(XmlWrapper(n))\n ...
[ "0.735646", "0.7268895", "0.7268895", "0.7257731", "0.7257731", "0.71810794", "0.7109341", "0.69479054", "0.6913855", "0.6909901", "0.68298626", "0.6665915", "0.66607493", "0.6615914", "0.6523836", "0.6522884", "0.6334188", "0.6259896", "0.6209838", "0.6107409", "0.60912377",...
0.78379494
0
Collect xblock info regarding the specified xblock and its ancestors.
def collect_ancestor_info(ancestor): if ancestor.location.block_type != 'course': ancestors.append({'type': ancestor.location.block_type, 'display_name': ancestor.display_name}) collect_ancestor_info(store.get_item(ancestor.parent))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_block_ancestors(self, xblock, store):\n ancestors = []\n\n def collect_ancestor_info(ancestor):\n \"\"\"\n Collect xblock info regarding the specified xblock and its ancestors.\n \"\"\"\n if ancestor.location.block_type != 'course':\n ...
[ "0.72645545", "0.56650704", "0.55771035", "0.5513479", "0.5433513", "0.532408", "0.532408", "0.5282096", "0.51781416", "0.51250774", "0.4981804", "0.49569547", "0.49468282", "0.4935761", "0.4935761", "0.49333844", "0.49292848", "0.49287447", "0.4918975", "0.48472416", "0.4801...
0.6892105
1
Quickly plot multiple images at once. each arr has to be a list of 2D or 3D images Example ======= x = np.ones((200,200)) plot_some([x],[x]) x = np.ones((5,200,200)) plot_some(x,x,x)
def plot_some(*arr, **kwargs): title_list = kwargs.pop('title_list',None) pmin = kwargs.pop('pmin',0) pmax = kwargs.pop('pmax',100) cmap = kwargs.pop('cmap','magma') imshow_kwargs = kwargs return _plot_some(arr=arr, title_list=title_list, pmin=pmin, pmax=pmax, cmap=cmap, **imshow_kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def PlotImages(x):\r\n # 5.1 Create figure-window and axes\r\n _, ax = plt.subplots(nrows = 2, ncols= 3)\r\n # 5.2\r\n ax[0,0].imshow(x[0, :].reshape(75,75))\r\n ax[0,1].imshow(x[1, :].reshape(75,75))\r\n ax[0,2].imshow(x[2, :].reshape(75,75))\r\n ax[1,0].imshow(x[3, :].reshape(75,75))\r\n ...
[ "0.70711166", "0.7066877", "0.701081", "0.6905507", "0.68050313", "0.6788474", "0.6689471", "0.6664214", "0.6644253", "0.66416115", "0.6564791", "0.6560931", "0.6557468", "0.65556717", "0.6523524", "0.6523524", "0.6523524", "0.6478707", "0.6459929", "0.6411923", "0.64117026",...
0.7205167
0
Initialise the QEMAdapter instance. This constructor initialises the adapter instance, extracting the appropriate configuration options passed in by the server, creating a InterfaceData object to interact with the sevrer and backplane handlers and starting a period update loop within the tornado IOLoop instance to hand...
def __init__(self, **kwargs): # Initialise the superclass ApiAdapter - this parses the keyword arguments # into the options used below. super(InterfaceAdapter, self).__init__(**kwargs) interface_options = { 'working_dir' : str(self.options.get('working_directory')), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(\n self, config: interface.BaseConfig, session_manager: ClientSessionManager\n ):\n super().__init__(max_calls=1) # To StateProducer via interface.AppleTV\n self._config = config\n self._session_manager = session_manager\n self._protocols_to_setup: Queue[SetupDat...
[ "0.6246754", "0.6134311", "0.60056937", "0.59435606", "0.59399885", "0.5938015", "0.58114725", "0.5783236", "0.57771885", "0.57014894", "0.56744635", "0.5656668", "0.56562054", "0.5633026", "0.5632867", "0.5621585", "0.5616236", "0.56147224", "0.56017303", "0.55965614", "0.55...
0.684456
0
Handle an HTTP PUT request. This method handles an HTTP PUT request routed to the adapter.This decodes the JSON body of the request into a dict, and passes the result with the request path to the underlying InterfaceData instance, where it is parsed and appropriate actions taken.
def put(self, path, request): try: data = json_decode(request.body) self.interface_data.set(path, data) response = self.interface_data.get(path, False) status_code = 200 except MetadataParameterError as e: response = {'error': str(e)} ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put(self, path, request):\n\n content_type = 'application/json'\n\n try:\n data = json_decode(request.body)\n self.fileInterface.set(path, data)\n response = self.fileInterface.get(path)\n status_code = 200\n except FileInterfaceError as e:\n ...
[ "0.7248065", "0.6955489", "0.6941687", "0.6785341", "0.6680217", "0.6676589", "0.66458213", "0.6615419", "0.6500376", "0.64675933", "0.64273846", "0.6404214", "0.6280552", "0.62804186", "0.62793255", "0.6271429", "0.6265722", "0.6231033", "0.6231033", "0.6231033", "0.618072",...
0.7927173
0
Handle background update loop tasks. This method polls the sensors in the background and is executed periodically in the tornado IOLoop instance.
def update_loop(self): # Handle background tasks #self.interface_data.backplane.poll_all_sensors() # Schedule the update loop to run in the IOLoop instance again after appropriate # interval IOLoop.instance().call_later(self.update_interval, self.update_loop)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self):\n while True:\n # Do something\n print('Doing something imporant in the background')\n\n self.loadData()\n time.sleep(self.interval)", "def add_update_loop(self):\n l = LoopingCall(self.update_active_node)\n l.clock = self.reactor\n ...
[ "0.66790515", "0.6355443", "0.634593", "0.6324028", "0.6284374", "0.62757915", "0.62316465", "0.62310386", "0.6216169", "0.6204409", "0.6203999", "0.61990917", "0.6163417", "0.61604416", "0.6124282", "0.6124282", "0.61110944", "0.60961056", "0.60944873", "0.60881984", "0.6076...
0.8306783
0
Saves a new baseline file into the port's baseline directory. The file will be named simply "expected", suitable for use as the expected results in a later run.
def _save_baseline_data(self, data, modifier, generate_new_baseline=True): port = self._port fs = port._filesystem if generate_new_baseline: relative_dir = fs.dirname(self._testname) baseline_path = port.baseline_path() output_dir = fs.join(baseline_path, rel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_test_baseline(self, file_name):\n return os.path.abspath(\n os.path.join(\n os.path.abspath(__file__),\n u'..',\n u'baselines',\n file_name))", "def bless_output(self):\n actual_output_file = path.splitext(self.source_na...
[ "0.61419886", "0.61045825", "0.5936975", "0.56854904", "0.5615434", "0.5565428", "0.55316305", "0.5527674", "0.54743046", "0.54691416", "0.54440033", "0.53628296", "0.53045976", "0.5276994", "0.5240396", "0.52365404", "0.5218536", "0.52183956", "0.5201798", "0.51563257", "0.5...
0.676486
0
A property that calculates the exceeded ratio (amount spent / total amount) of this budget.
def exceeded_ratio(self) -> float: return self.amount_spent / self.total_amount
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def budget_used(self):\n return int(self.total_spent() / self.budget() * 100.0)", "def percent_raised(self):\n total_cost = self.total_cost()\n if total_cost:\n return round(self.total_raised() * 100 / total_cost, 2)\n else:\n return 0", "def ratio(self):\n ...
[ "0.6591943", "0.6559081", "0.63274586", "0.6305053", "0.6276677", "0.62711346", "0.6237848", "0.6213536", "0.6212942", "0.61523706", "0.61523706", "0.6116475", "0.6113221", "0.6110212", "0.60746557", "0.6064563", "0.6050357", "0.60138005", "0.5991126", "0.5988578", "0.5982346...
0.83884895
0
Adds a budget to the dictionary.
def add_budget(self, budget: Budget) -> None: self.budgets[budget.category] = budget
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deposit(self, amount, budget):\r\n if budget != \"Total Balance\":\r\n assert budget in self.budgets, \"Specified budget doesn't exist\"\r\n self.budgets[budget] += float(amount)\r\n self.balance += float(amount)", "def declare_new_budget(date, exp_data):\n\n exp_list =...
[ "0.63456917", "0.60231787", "0.5939616", "0.59035134", "0.5890429", "0.5828401", "0.5779284", "0.57482374", "0.5545248", "0.5494234", "0.5493827", "0.5463563", "0.5444056", "0.5438311", "0.54316634", "0.5424708", "0.54197586", "0.540606", "0.5402471", "0.53940505", "0.5336805...
0.7852479
0