query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Build new_events This factory method is actually the events factory.
def build_events(self) -> list: raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_new_event(self):\n pass", "def handle_new_events(self, events):\n for event in events:\n self.events.append(\n self.create_event_object(\n event[0],\n event[1],\n int(event[2])))", "def create_event(self...
[ "0.7068018", "0.6923349", "0.6733583", "0.6481142", "0.6407484", "0.63098305", "0.6274381", "0.62523794", "0.61910576", "0.61229914", "0.601929", "0.6007083", "0.6007083", "0.6007083", "0.60045576", "0.597696", "0.595828", "0.593561", "0.5929939", "0.5923887", "0.5875728", ...
0.6995154
1
Collecting new events and push them into the events buffer
def collect_new_events(self) -> list: self.logger.debug('Collecting new events...') events = self.build_events() if not events: self.logger.debug('No new events.') for event in events: self.logger.info('A new event has been detected: {}'.format(event)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_events(self):\n while 1:\n try:\n self.events_local.append(self._q.get(False))\n except queue.Empty:\n break", "def slurp_events(self):\n while self.has_event():\n self.get_event()", "def _store_events(self, c, e):\n ...
[ "0.7208618", "0.69300455", "0.67458445", "0.6702277", "0.64130634", "0.6407206", "0.6382773", "0.63692826", "0.6364064", "0.6345537", "0.6214517", "0.6210405", "0.61788917", "0.61758673", "0.6163426", "0.6151569", "0.6115069", "0.6052047", "0.6035892", "0.6028083", "0.6023511...
0.81267637
0
Return the first event in the events buffer. if the events buffer is empty, return None.
def pull_event(self): self._buffer_buisy_mutex.acquire() event = None if self._events_buffer: event = self._events_buffer.pop(0) self._dilivered_events_stack.push(event.hash) self._buffer_buisy_mutex.release() if event: self.logger.info('Pullin...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next(self):\r\n ready = select.select([self.filehandle],[ ], [ ], 0)[0]\r\n if ready:\r\n s = os.read(self.filehandle, Format.EventSize)\r\n if s:\r\n event = EventStruct.EventStruct(self)\r\n event.decode(s)\r\n return event\r\n\r\n return None", "def get_event(self):...
[ "0.68624073", "0.675701", "0.65967983", "0.64074314", "0.6368702", "0.6367154", "0.6064259", "0.6038515", "0.5982681", "0.5966734", "0.59468913", "0.59100795", "0.58604395", "0.58548284", "0.5846003", "0.58087397", "0.5797214", "0.5741647", "0.568052", "0.56763804", "0.567339...
0.6717159
2
Collect and store events in infinite loop with interval `_check_for_new_events_interval`
def run(self): self.logger.info(f'Running {self.__class__.__name__}') while True: last_check = time.time() self.collect_new_events() while time.time() - last_check < self._check_for_new_events_interval: self.logger.debug('Waiting for new events collect...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_events(self):\n while 1:\n try:\n self.events_local.append(self._q.get(False))\n except queue.Empty:\n break", "def collect_new_events(self) -> list:\n self.logger.debug('Collecting new events...')\n events = self.build_events()\n...
[ "0.7514532", "0.7251609", "0.69642305", "0.6617071", "0.64833236", "0.6442508", "0.64266163", "0.6419499", "0.62670517", "0.6204146", "0.6163505", "0.6123297", "0.6066979", "0.60647124", "0.6037076", "0.6023934", "0.60231", "0.6019544", "0.5935497", "0.591859", "0.58918107", ...
0.705858
2
A factory method that build and return all the scope instances of the endpoint
def collect_all(self) -> list: raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scope(self): # noqa: ANN201", "def scope(self) -> List[Region]:\n return [self]", "def _construct_endpoints(self):\n # Functions\n async def get_function_list_data(request: web.Request):\n entrypoints = [elm.to_dict() for elm in self._function_manager.definitions.values()]\...
[ "0.5739762", "0.5559985", "0.5545814", "0.5464133", "0.5434428", "0.5422983", "0.536801", "0.5362967", "0.5270679", "0.526368", "0.522724", "0.5190502", "0.5137176", "0.51323414", "0.51149523", "0.5109984", "0.50831056", "0.5074194", "0.5068082", "0.5059394", "0.5058056", "...
0.0
-1
Return whether the bot is pollable or not
def pollable(self): return bool(self.ScopeCollector)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_poll(self):\n return self.subscription_list.mode == gnmi_pb2.SubscriptionList.POLL", "def should_poll(self):\n return self._should_poll", "def should_poll(self):\n return self.notifier.socket is not None", "def should_poll(self) -> bool:\n return True", "def should_po...
[ "0.71498877", "0.7049278", "0.70060855", "0.68412566", "0.68412566", "0.68412566", "0.68330795", "0.68330795", "0.68330795", "0.68330795", "0.68330795", "0.68330795", "0.68330795", "0.6816082", "0.6816082", "0.6816082", "0.6816082", "0.6816082", "0.6816082", "0.6816082", "0.6...
0.634647
59
Return the conditional tasks of this bot.
def get_conditional_tasks(self, scope: EndpointScope=None): from nudgebot.tasks import ConditionalTask conditional_tasks = [task for task in self._tasks if issubclass(task, ConditionalTask)] if scope: static_hierarchy = [ps.__class__ for ps in scope.hierarchy] conditional...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_created_tasks(self):\n tasks = []\n for task_config in get_task_configs(self.context):\n task = task_config.get_created_task(self.context)\n if not task:\n continue\n matched, not_matched = task.start_conditions_status()\n if not not_...
[ "0.651819", "0.6293233", "0.62041074", "0.61520755", "0.6030803", "0.60058683", "0.59421945", "0.59181774", "0.58944106", "0.5864872", "0.5841039", "0.57834464", "0.57781357", "0.57735986", "0.5766781", "0.5705261", "0.5684001", "0.5660684", "0.5619601", "0.5606973", "0.56057...
0.7749001
0
If the bot is pollable, performing a poll, collecting all the scopes from the scopes collectors, updating statistics and handling tasks.
def poll(self): if not self.pollable: self.logger.warning('Poll has been triggered but the bot is not pollable! Return;') return self._busy_mutext.acquire() try: self.logger.info('Stating poll') for scope in self.ScopeCollector.collect_all(): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def poll(self, ctx, choice=None):\n\n if choice is None or choice.lower() in (\"online\", \"voice\"):\n suggestions = get_suggestions(get_users(ctx, choice))\n\n if suggestions:\n poll_id = create_strawpoll(\"What to play?\", suggestions)\n\n if poll...
[ "0.54762065", "0.53788805", "0.53186905", "0.53170043", "0.5184612", "0.5109608", "0.5096446", "0.50746995", "0.50663227", "0.5019184", "0.5006015", "0.4936928", "0.4913336", "0.4876137", "0.48729563", "0.48675004", "0.4866862", "0.48607504", "0.48592043", "0.48447618", "0.48...
0.8014664
0
Pulling new events from the event factory, collecting statistics and handling tasks
def handle_events(self): self._busy_mutext.acquire() try: event = self.EventsFactory.pull_event() while event: self.logger.debug('Handling new event: {}'.format(event.id)) event_endpoint_scope_classes = event.EndpointScope.get_static_hierarchy() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_new_events(self, events):\n for event in events:\n self.events.append(\n self.create_event_object(\n event[0],\n event[1],\n int(event[2])))", "def collect_new_events(self) -> list:\n self.logger.debug('Co...
[ "0.6928928", "0.66840243", "0.65027535", "0.64619464", "0.6460602", "0.6405665", "0.635793", "0.6357241", "0.6314258", "0.62627983", "0.62376845", "0.6235711", "0.62312156", "0.62292194", "0.6201306", "0.61748487", "0.61748487", "0.61693776", "0.61435163", "0.61425567", "0.61...
0.75559413
0
Run the bot's main loop. Checking each cycle for new events, collecting statistics and handling tasks.
def run(self): if self.pollable: self.poll() if not self.EventsFactory.is_alive(): self.EventsFactory.start() while True: if not self.EventsFactory.is_alive(): self.logger.error(f'{self} events factory has died..') raise SubThre...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self):\n self.logger.info(f'Running {self.__class__.__name__}')\n while True:\n last_check = time.time()\n self.collect_new_events()\n while time.time() - last_check < self._check_for_new_events_interval:\n self.logger.debug('Waiting for new eve...
[ "0.7277891", "0.7167473", "0.7075082", "0.6992124", "0.69774413", "0.6944734", "0.6898651", "0.6894622", "0.68806136", "0.6825181", "0.67936915", "0.6781551", "0.6758954", "0.6758954", "0.6722563", "0.67086315", "0.66868275", "0.66772085", "0.6672398", "0.6656355", "0.6614758...
0.0
-1
This returns a json object with the current weather data
def getData(tme=currentTime): # attempts request 10 times for attempt in range(10): try: # make a request to the url and return it in json format url = "https://api.darksky.net/forecast/%s/%s,%s,%s?exclude=minutely,hourly,daily,alerts,flags" % (API_KEY, LAT, LNG, tme) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_weather(self):\n with urllib.request.urlopen(self.url) as response:\n json_data = response.read().decode('utf-8')\n\n data = json.loads(json_data)\n\n weather = {}\n weather['current'] = {\n 'temp': round(data['current']['temp_f']),\n 'humidity':...
[ "0.8403848", "0.79218674", "0.75721085", "0.7333801", "0.73297447", "0.7300376", "0.71959585", "0.7157717", "0.714969", "0.71045464", "0.7076542", "0.70307815", "0.69357234", "0.6829944", "0.68273324", "0.68176526", "0.68121034", "0.6744426", "0.6736956", "0.6727928", "0.6727...
0.0
-1
convert temperature to Celsius and round to tenths place always has fahrenheit temperatures from source
def convertTemp(t, convertTo="C"): # check if target temperature is celcius (metric) if convertTo == "C": # returns celcius (metric) temperature return round(((5 / 9) * (t - 32)), 1) else: # returns fahrenheit but rounded return round(t, 1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_f_to_c(temp_in_farenheit): ## ##\n celsiustemp = round((temp_in_farenheit - 32) * 5/9, 1) ##\n return celsiustemp ##", "def fahr_to_celsius(temp):\n...
[ "0.78028524", "0.7697944", "0.7693355", "0.7597741", "0.7461831", "0.7330447", "0.7304864", "0.72830915", "0.72584087", "0.7248814", "0.7248472", "0.72136587", "0.71933347", "0.7159759", "0.7137415", "0.7072251", "0.70268846", "0.7010395", "0.70004326", "0.6964403", "0.692998...
0.7118849
15
returns wind direction by converting to cardinal direction
def convertToWindDirection(wb): if wb >= 0 and wb < 11.25: return "N" elif wb >= 11.25 and wb < 33.75: return "NNE" elif wb >= 33.75 and wb < 56.25: return "NE" elif wb >= 56.25 and wb < 78.75: return "ENE" elif wb >= 78.75 and wb < 101.25: return "E" elif...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wind_direction(self):\n names = ['anc_wind_direction']\n return self.sensor.get_with_fallback('wind_direction', names)", "def wind_direction(self):\n return self.flow_field.wind_direction", "async def direction(self, value) -> str:\n if value is None:\n return \"N\"\n...
[ "0.8051601", "0.772605", "0.7561617", "0.6858852", "0.6829403", "0.6813727", "0.6801408", "0.6787277", "0.67743737", "0.6764944", "0.67020386", "0.6669546", "0.66545075", "0.6628825", "0.6559923", "0.65528166", "0.65011674", "0.6466648", "0.64575577", "0.64373934", "0.6432996...
0.74717367
3
Return feature complexity value
def complexity(self): raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_complexity(self):\n if self.layer_type() == nn.Conv2d:\n return pow(self.layer_type.get_sub_value(\"conv_window_size\"), 2) * self.layer_type.get_sub_value(\n \"out_features\")\n elif self.layer_type() == nn.Linear:\n return self.layer_type.get_sub_value(\...
[ "0.6790964", "0.66218597", "0.641455", "0.6044887", "0.60209787", "0.5925947", "0.591959", "0.5895237", "0.58917314", "0.5765962", "0.56985533", "0.567084", "0.567084", "0.567084", "0.567084", "0.567084", "0.565596", "0.564267", "0.56411445", "0.5639347", "0.5630512", "0.56...
0.7181252
0
The value of the feature is the min distance between any object in the extension of c1 and any object on the extension of c2, moving only along redges.
def denotation(self, model): ext_c1 = model.uncompressed_denotation(self.c1) ext_c2 = model.uncompressed_denotation(self.c2) ext_r = model.uncompressed_denotation(self.r) # (Debugging) # ec1 = sorted(cache.universe.value(x) for x in cache.uncompress(ext_c1, self.c1.ARITY)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def minimum_distance(object_1, object_2):\n\n # package import\n import numpy as np\n\n # main algorithm\n minimum_distance = 100000\n\n for coord_1 in object_1:\n for coord_2 in object_2:\n distance_btwn_coords = np.linalg.norm(coord_1 - coord_2)\n if distance_btwn_coor...
[ "0.64672554", "0.6217276", "0.61850023", "0.6081567", "0.606083", "0.5999995", "0.5996432", "0.5954135", "0.59468925", "0.5916301", "0.5907533", "0.58643496", "0.58624357", "0.5848533", "0.5842086", "0.5776009", "0.57662404", "0.5752642", "0.57183474", "0.5716433", "0.5711440...
0.0
-1
The value of the feature is f1 < f2
def denotation(self, model): ext_f1 = self.f1.denotation(model) ext_f2 = self.f2.denotation(model) return ext_f1 < ext_f2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __gt__(self, other):\n return self.__f > other.get_f()", "def __ge__(self,f2):\n return self > f2 or self == f2", "def __gt__(self, other):\n return self.x ** 2 + self.y ** 2 > other.x ** 2 + other.y ** 2", "def threshad(f, f1, f2=None):\n\n if f2 is None: \n y = binary(f1 <=...
[ "0.7495265", "0.74074596", "0.73894393", "0.7220509", "0.71422136", "0.7136578", "0.71185535", "0.70948553", "0.70477045", "0.69834864", "0.69177634", "0.686342", "0.6826311", "0.6817896", "0.6801876", "0.67579144", "0.6755326", "0.67524177", "0.674877", "0.67084754", "0.6631...
0.0
-1
The feature evaluates to true iff the nullary atom is true in the given state
def denotation(self, model): # return self.atom.extension(cache, state) return model.primitive_denotation(self.atom)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_true(node):\n return is_scalar_cst(node, True) or is_vector_uniform_cst(node, True)", "def on_true(self) -> global___Expression:", "def __bool__(self):\n return len(self._states_) > 0", "def fullGrid(state):\n return not ((state[:, :, 0] + state[:, :, 1]) == 0).any()", "def boolean_func...
[ "0.6562623", "0.65170795", "0.6263885", "0.61745733", "0.6139357", "0.6104485", "0.6104217", "0.60726494", "0.60725033", "0.6036591", "0.60332745", "0.60322684", "0.60322684", "0.6001883", "0.5990397", "0.5982798", "0.5947548", "0.59247506", "0.59022444", "0.58872384", "0.588...
0.0
-1
r"""compute amplitude phase error compute amplitude phase error of two complex valued matrix
def ampphaerror(orig, reco): amp_orig = np.abs(orig) amp_reco = np.abs(reco) pha_orig = np.angle(orig) pha_reco = np.angle(reco) # print(np.abs(amp_orig - amp_reco)) # print(np.abs(pha_orig - pha_reco)) # print(np.mean(np.abs(amp_orig - amp_reco))) # print(np.mean(np.abs(pha_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_phase_amplitude_damping_error_noncanonical(self):\n error = phase_amplitude_damping_error(0.25, 0.5, 0.3, canonical_kraus=False)\n circ, p = error.error_term(0)\n self.assertEqual(p, 1, msg=\"Kraus probability\")\n self.assertEqual(circ[0][\"qubits\"], [0])\n self.assert...
[ "0.57301235", "0.5672069", "0.5634887", "0.55991733", "0.5460378", "0.5439556", "0.5384441", "0.53555703", "0.53211105", "0.53139055", "0.53101045", "0.5309513", "0.5285496", "0.5270891", "0.5257104", "0.5252667", "0.5211097", "0.5206943", "0.52064764", "0.519271", "0.5184854...
0.63241947
0
r"""Mean Squared Error The Mean Squared Error (MSE) is expressed as
def mse(o, r): return np.mean(np.square((np.abs(o).astype(float) - np.abs(r).astype(float))))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def MSE(actual, noisy):\n mean_squared_error(actual, noisy)", "def MeanSqError(self):\r\n\t\treturn self.mse", "def compute_MSE(e):\n\n return 1/2*np.mean(e**2)", "def MeanSquaredError(y_data, y_model):\n\tn = np.size(y_model)\n\tMSE = (1/n)*np.sum((y_data-y_model)**2)\n\n\treturn MSE", "def mse(ac...
[ "0.8507595", "0.8144864", "0.8103423", "0.8007305", "0.7935467", "0.791784", "0.7868778", "0.7831256", "0.7799074", "0.773619", "0.7590051", "0.7585499", "0.75660074", "0.7517208", "0.75151676", "0.75089014", "0.75050557", "0.7480824", "0.74724436", "0.74634266", "0.7453086",...
0.6980898
56
Print 6 power 3
def six_cubed(): print(math.pow(6, 3))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def six_cubed():\n print(math.pow(6,3))", "def print_pow():\n a = get_inp_pow()\n n = get_inp_pow('power')\n print(a, \"^\", n, \" = \", pow(a, n), sep='')", "def print_power(x):\r\n if(type(x)!=int):\r\n if(power(x)==1 or power(x)==0):\r\n print(calc_power(x))\r\n else:...
[ "0.80794406", "0.739419", "0.66700226", "0.6589733", "0.6485324", "0.638416", "0.6293852", "0.62722826", "0.61774296", "0.61550194", "0.61198187", "0.59969866", "0.5990775", "0.59640026", "0.59278244", "0.59264386", "0.59198284", "0.5873405", "0.5873405", "0.5857948", "0.5857...
0.80480736
1
Print the hypotenuse of straight angled triangle with 3 and 5 rib lengths
def hypotenuse(): print(math.sqrt(5*5 + 3*3))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def triangular_area():\n print(1*1/2, 2*2/2, 3*3/2, 4*4/2, 5*5/2, 6*6/2, 7*7/2, 8*8/2, 9*9/2,\n 10*10/2)", "def hypotenuse():\n print(math.sqrt(5**2 +3**2))", "def triangle(self):\n \n R = Householder.triangle_operation(self)[0] \n \n return(R.round(10))", "de...
[ "0.716252", "0.69258684", "0.68606097", "0.68530416", "0.6835748", "0.67376614", "0.66448975", "0.66325754", "0.65477556", "0.65080655", "0.6503776", "0.64483434", "0.64430314", "0.6440897", "0.6418103", "0.6221835", "0.6206969", "0.6188036", "0.6169473", "0.6046872", "0.6028...
0.70707786
1
Some original examples in SQuAD have indices wrong by 1 or 2 character. We test and fix this here.
def _get_correct_alignement(context, answer): gold_text = answer["text"] start_idx = answer["answer_start"] end_idx = start_idx + len(gold_text) if context[start_idx:end_idx] == gold_text: return start_idx, end_idx # When the gold label position is good elif context[start_idx - 1 : end_idx ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_index_geq_3(self):\n self.insert()\n data = self.tbl[6:]\n assert self.check(self.idata[2:], data)", "def test_stochatreat_input_idx_col_str(correct_params):\n idx_col_not_str = 0\n with pytest.raises(TypeError):\n stochatreat(\n data=correct_params[\"data\"]...
[ "0.58099073", "0.56744087", "0.56158406", "0.5522892", "0.5503032", "0.54781187", "0.5442574", "0.5439417", "0.5433266", "0.5433266", "0.5433081", "0.541962", "0.5385678", "0.53835106", "0.53824735", "0.52802736", "0.52733016", "0.52319086", "0.5225618", "0.5197222", "0.51944...
0.0
-1
first match is returned in match case
def get_answer_indices_from_sentence(answer_text: str, sentence: str, loose_match: bool = False): # sometimes extracted answers does not match with the original text :/ try: pattern = r"(?<![a-zA-Z0-9])(%s)(?![a-zA-Z0-9])" % re.escape(answer_text) match_str = re.search(pattern, sentence) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def first_match(s,patterns):\n\n for p in patterns:\n m=p.match(s)\n if m:\n return p,m\n return None,None", "def _FindFirstCompoundMatch(matches):\n for m in matches:\n if isinstance(m.value, models.Compound):\n return m\n return None", "def match(self, ite...
[ "0.6874615", "0.66699106", "0.65208817", "0.6322175", "0.62504864", "0.62194806", "0.61659265", "0.6103416", "0.60927224", "0.60927224", "0.6083921", "0.6060716", "0.6040884", "0.59855664", "0.59727067", "0.59399265", "0.5920194", "0.59165275", "0.5913169", "0.5902508", "0.58...
0.0
-1
Removes the citations that consist of a pair of brackets having a substring containing at least one digit inside them.
def remove_citations(text: str) -> str: text = re.sub("\[[a-zA-Z]\]", "", text) return re.sub(r"\[(\s|\w)*\d+(\s|\w)*\]", "", text)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _remove_between_square_brackets(text):\n return re.sub('\\[[^]]*\\]', '', text)", "def clean_all_brackets(text):\n if \"[\" in text and \"]\" in text:\n text = delete_first_brackets(text)\n return clean_all_brackets(text)\n else:\n return text", "def clean_newick_string(self, ...
[ "0.627086", "0.6270785", "0.605527", "0.5885382", "0.58816636", "0.5716584", "0.55261326", "0.54964125", "0.5492156", "0.5491435", "0.54455703", "0.5420037", "0.54059094", "0.5369905", "0.5256885", "0.52483344", "0.5220134", "0.51920635", "0.51877683", "0.51309067", "0.512497...
0.6384374
0
Create and return a `User` with superuser powers. Superuser powers means that this user is an admin that can do anything they want.
def create_superuser(self, username, email, password, **kwargs): kwargs.setdefault('is_staff', True) kwargs.setdefault('is_superuser', True) if kwargs.get('is_staff') is not True: raise ValueError('Superuser must have is_staff=True.') if kwargs.get('is_superuser') is not Tru...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_user_as_admin(self, *args, **kwargs):\n profile = self.create_user(*args, **kwargs)\n profile.make_administrator()\n return profile", "def create_superuser(self, username, major, password):\r\n user = self.create_user(username, major, password=password,)\r\n user.is_admi...
[ "0.7354598", "0.7346853", "0.7292081", "0.72741586", "0.7273662", "0.722427", "0.7210906", "0.7199503", "0.71846986", "0.7173363", "0.7138555", "0.71200466", "0.7115839", "0.7092951", "0.70887464", "0.708154", "0.7074986", "0.706979", "0.7068387", "0.70664716", "0.70519775", ...
0.0
-1
Allows us to get a user's token by calling `user.token` instead of `user.generate_jwt_token(). The `` decorator above makes this possible. `token` is called a "dynamic property".
def token(self): return self._generate_jwt_token()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def UserToken(self) -> object:", "def _get_token(self):\n return user.get_token()", "async def get_user(token: str = Depends(get_user_token_strict)) -> schemas.UserToken:\n token_info = await security.decode_jwt(token)\n return schemas.UserToken.from_token(token_info)", "def decorated(*args, **k...
[ "0.74925566", "0.71262574", "0.7045925", "0.6967166", "0.6867049", "0.68216413", "0.6814544", "0.6807034", "0.6781353", "0.67762995", "0.6704667", "0.66133755", "0.659621", "0.6594218", "0.6567751", "0.6567751", "0.65423006", "0.6423605", "0.6423605", "0.6415719", "0.64120895...
0.67203206
10
Generates a JSON Web Token that stores this user's ID and has an expiry date set to 60 days into the future.
def _generate_jwt_token(self): import jwt from datetime import datetime, timedelta from django.conf import settings dt = datetime.now() + timedelta(days=60) token = jwt.encode({ 'id': self.pk, 'username': self.username, 'exp': int(dt.strftime...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _generate_jwt_token(self):\n dt = datetime.now() + timedelta(days=60)\n\n token = jwt.encode({\n 'id': self.pk,\n 'exp': int(dt.strftime('%s'))\n }, settings.SECRET_KEY, algorithm='HS256')\n\n return token.decode('utf-8')", "def generate_auth_token(self, expi...
[ "0.793682", "0.77396196", "0.77252686", "0.7569785", "0.7550483", "0.7504947", "0.74958557", "0.74798924", "0.745215", "0.7271606", "0.72704905", "0.7229112", "0.7227402", "0.71781677", "0.7081612", "0.69910264", "0.69628245", "0.69411725", "0.69014037", "0.6862004", "0.68561...
0.8095364
0
Validates if all ConfigurationOption names are unique in the ConfigurationOptions instance.
def configuration_options_object_processor(configuration_options): option_names = [option.name for option in configuration_options.configuration_options] for option_name in option_names: if option_names.count(option_name) > 1: raise WashError(f'Configuration option with the name {option_name...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _validate_options(self):\r\n valid_choices = ('correct', 'partially-correct', 'incorrect')\r\n for option in self.options:\r\n choice = option['choice']\r\n if choice is None:\r\n raise ValueError('Missing required choice attribute.')\r\n elif choic...
[ "0.66978174", "0.6242515", "0.6204667", "0.61873025", "0.6138533", "0.60712093", "0.6030964", "0.598881", "0.5862973", "0.5836668", "0.5816893", "0.5737586", "0.5737399", "0.57218176", "0.570948", "0.5619496", "0.55831975", "0.55713516", "0.55708873", "0.5567247", "0.55379665...
0.7466442
0
Validates if all ConfigurationOptionParameter names are unique in the ConfigurationOption instance. Also validates if at least one required parameter is specified in the ConfigurationOption instance.
def configuration_option_object_processor(configuration_option): parameter_names = [parameter.name for parameter in configuration_option.parameters] for parameter_name in parameter_names: if parameter_names.count(parameter_name) > 1: raise WashError(f'Parameter with the name {parameter_name}...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _validate(self):\n for p in self.parameters:\n #Check for missing required parameters:\n if p.is_required and not(p.is_set):\n raise ValueError(\"Parameter %s is not set.\" \\\n % p.names[-1])\n #Also repeat the parameter va...
[ "0.6902311", "0.6522125", "0.6513697", "0.64732", "0.64559853", "0.6451961", "0.6323427", "0.6316556", "0.6186604", "0.6156855", "0.6142861", "0.612921", "0.60664105", "0.6061574", "0.6059569", "0.60359025", "0.5982344", "0.59677446", "0.5965603", "0.59638935", "0.5913237", ...
0.7193669
0
Get stats for user(s) ( of teas drunk, of teas brewed, of times brewed, of teas received)
def stats(self): try: slack_id = MENTION_RE.search(self.command_body).groups()[0] except AttributeError: slack_id = None if slack_id: users = [UserManager.get_by_slack_id(slack_id)] else: users = self.session.query(User).filter(User.tea_ty...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_stats(df):\r\n print('\\nCalculating User Stats...\\n')\r\n start_time = time.time()\r\n # TO DO: Display counts of user types\r\n df = ['user type'].value_counts()\r\n print('count of user typs:\\n')\r\n # TO DO: Display counts of gender\r\n df = ['grnder'].value...
[ "0.7520656", "0.7389398", "0.7170555", "0.7159044", "0.71519357", "0.71448964", "0.7137626", "0.7130871", "0.7130532", "0.7130459", "0.71226174", "0.7107432", "0.706119", "0.70610684", "0.70570743", "0.704516", "0.7041531", "0.70409685", "0.7035824", "0.7029423", "0.70275396"...
0.70605934
14
Return a marker's initial pose if it was passed in.
def initial_pose(self): return self._initial_pose
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_init_pose(self):\n return self.init_pose_R, self.init_pose_t", "def start_pose():\n global start_pose\n while start_pose is None:\n pass\n return start_pose", "def _set_init_pose(self):\n raise NotImplementedError()", "def _set_init_pose(self):\n ...
[ "0.6584604", "0.6367691", "0.6337681", "0.6337681", "0.6337681", "0.6199046", "0.6134793", "0.60044897", "0.5989717", "0.5986071", "0.59107316", "0.5883016", "0.58752507", "0.58548284", "0.57934", "0.5782603", "0.57810706", "0.5780764", "0.5670274", "0.5653202", "0.56078744",...
0.7495326
0
Get the marker template's interactive marker server.
def server(self): return self._server
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_server(self):\n\n pass", "def get_mapserver(self):\n return self.get_node('//MapServer')", "def server(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"server\")", "def server(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"server\")", "def server(self) ->...
[ "0.5713564", "0.5681471", "0.56718", "0.56718", "0.55612904", "0.53901726", "0.5360627", "0.53534365", "0.5328185", "0.52752024", "0.5226425", "0.52251995", "0.5196644", "0.51267505", "0.5064403", "0.50298774", "0.49947485", "0.49527696", "0.49257052", "0.4907691", "0.4877441...
0.5278075
10
Get the interactive marker map of this marker template.
def marker_map(self): return self._marker_map
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_map(self):\n return self.map", "def get_map(self):\n return self.parent.controller.get_map()", "def mappable(self):\n return self._mappable.get(self._plotid, None)", "def markers (self):\n return self._markers", "def get_map(self):\n return self._locmap", "def G...
[ "0.6520739", "0.64780396", "0.63716984", "0.6316054", "0.6315033", "0.6121316", "0.60842246", "0.59842247", "0.5905344", "0.5881036", "0.5847196", "0.57981193", "0.5774668", "0.5716302", "0.569977", "0.56583416", "0.55513626", "0.5545483", "0.5514279", "0.5488387", "0.5481627...
0.77108824
0
Get the callback map of this marker template.
def callback_map(self): return self._callback_map
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def marker_map(self):\n return self._marker_map", "def get_map(self):\n return self.map", "def get_map(self):\n return self.parent.controller.get_map()", "def MAP(self):\n return self.__map", "def get_map(self):\n return self._locmap", "def get_callback(self):\n ...
[ "0.7049451", "0.6784116", "0.6679001", "0.6338827", "0.6203012", "0.6103992", "0.6036267", "0.58860934", "0.58419704", "0.5811328", "0.571724", "0.5705887", "0.5624895", "0.54811853", "0.5466417", "0.5464931", "0.54548174", "0.5448449", "0.5445454", "0.54268634", "0.5374627",...
0.78254753
0
Get the menu handler of this marker template.
def menu_handler(self): return self._menu_handler
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_menu ( self, object ):\n return self.menu", "def menu(self):\n return self._menu", "def get_menu ( self, object, row ):\n return self.menu", "def GetMenu(self):\n return self._menu", "def menu(self):\n try:\n return get_template('{}/menu.html'.format(se...
[ "0.687998", "0.6734362", "0.66681284", "0.6660644", "0.6325513", "0.630204", "0.6267521", "0.608892", "0.60468376", "0.60233533", "0.60089546", "0.59873855", "0.5929736", "0.5915794", "0.5880168", "0.58781844", "0.5877921", "0.5829185", "0.58093506", "0.5780745", "0.5773996",...
0.8167384
0
Returns dictionary for CDP neighbor phone
def phone_parse(neighbor): mgmt_ip = neighbor[mgmt_ip_s] hostname = neighbor[hostname_s].split('.')[0] if nxos: sysname = neighbor['sysname'] if sysname != '': hostname = sysname if mgmt_ip == '': ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Neighbors(vendor):\n neighbors = {\"cisco\" : \"\", \"juniper\" : \"\", \"vyatta\" : \"\" }\n cisco_neighbors = {}\n juniper_neighbors = {}\n vyatta_neighbors = {}\n while True:\n print \"***\\t\\t%s NEIGHBORS***\" % (vendor)\n n = raw_input(\"\\t\\tNeighbor information (Press any ...
[ "0.6110668", "0.6060373", "0.59975594", "0.58959544", "0.5839219", "0.57849395", "0.56733996", "0.5624407", "0.56165946", "0.5539645", "0.546498", "0.5460354", "0.5419926", "0.54115295", "0.53951436", "0.5389832", "0.5381396", "0.5365169", "0.53650045", "0.5330386", "0.531964...
0.6916648
0
Returns dictionary for CDP neighbor router or switch
def router_sw_parse(neighbor): mgmt_ip = neighbor[mgmt_ip_s] hostname = neighbor[hostname_s].split('.')[0] if hostname.__contains__('('): hostname = hostname.split('(')[0] if nxos: sysname = neighbor['sysname'] if sysname !=...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Neighbors(vendor):\n neighbors = {\"cisco\" : \"\", \"juniper\" : \"\", \"vyatta\" : \"\" }\n cisco_neighbors = {}\n juniper_neighbors = {}\n vyatta_neighbors = {}\n while True:\n print \"***\\t\\t%s NEIGHBORS***\" % (vendor)\n n = raw_input(\"\\t\\tNeighbor information (Press any ...
[ "0.63590497", "0.6126241", "0.61201745", "0.60082996", "0.5985307", "0.59344363", "0.5915709", "0.586581", "0.5772417", "0.5727852", "0.57097715", "0.5701715", "0.569434", "0.5683343", "0.564236", "0.56369084", "0.56235886", "0.5598898", "0.55868256", "0.5574442", "0.5525679"...
0.6161124
1
Returns dictionary for CDP neighbor wireless access point
def wap_parse(neighbor): mgmt_ip = neighbor[mgmt_ip_s] hostname = neighbor[hostname_s].split('.')[0] if nxos: sysname = neighbor['sysname'] if sysname != '': hostname = sysname if mgmt_ip == '': m...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_access_points(self):\r\n return {\"invalid mac\": {\"mac\": \"invalid mac\", \"ssid\": \"none\"}}", "def createWIFIAccessPoint():\n ifname = config.get(\"interface\", \"wifi\")\n ipaddress = config.get(\"hotspot\", \"ip\")\n prefix = int(config.get(\"hotspot\", \"prefix\"))\n ssid = co...
[ "0.65589803", "0.60421294", "0.58815694", "0.5777488", "0.5672514", "0.566989", "0.5562045", "0.5560893", "0.55289185", "0.55088353", "0.54970974", "0.54738414", "0.54605913", "0.54371357", "0.54343486", "0.54248816", "0.53932667", "0.5372743", "0.5359739", "0.5346931", "0.53...
0.5178175
30
Returns dictionary for CDP neighbor that isn't a phone, access point, router, or switch
def other_parse(neighbor): mgmt_ip = neighbor[mgmt_ip_s] hostname = neighbor[hostname_s].split('.')[0] if nxos: sysname = neighbor['sysname'] if sysname != '': hostname = sysname if mgmt_ip == '': ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Neighbors(vendor):\n neighbors = {\"cisco\" : \"\", \"juniper\" : \"\", \"vyatta\" : \"\" }\n cisco_neighbors = {}\n juniper_neighbors = {}\n vyatta_neighbors = {}\n while True:\n print \"***\\t\\t%s NEIGHBORS***\" % (vendor)\n n = raw_input(\"\\t\\tNeighbor information (Press any ...
[ "0.6003028", "0.5648148", "0.56309026", "0.54871684", "0.54836214", "0.5455412", "0.53574145", "0.53206867", "0.5274642", "0.5270559", "0.52702534", "0.5257775", "0.52102804", "0.52034205", "0.5196427", "0.5195789", "0.5183352", "0.5181435", "0.5161388", "0.5145692", "0.51405...
0.5547205
3
Given TEXTFSM CDP neighbor, checks type of device and runs through corresponding parser function.
def parse(n): capabilities = n['capabilities'] if n['platform'].__contains__('IP Phone') or capabilities.__contains__('Phone'): phone_parse(n) elif capabilities.__contains__('Router') and capabilities.__contains__('Source-Route-Bridge') or \ capabi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _parse_device_from_datagram(\n device_callback: Callable[[SwitcherBase], Any], datagram: bytes\n) -> None:\n parser = DatagramParser(datagram)\n if not parser.is_switcher_originator():\n logger.debug(\"received datagram from an unknown source\")\n else:\n device_type: DeviceType = par...
[ "0.5448138", "0.5367822", "0.51965165", "0.51411146", "0.5129462", "0.4950195", "0.4934969", "0.49349013", "0.47787055", "0.47489983", "0.4734217", "0.4636806", "0.46320385", "0.46221396", "0.46014342", "0.4576387", "0.4569176", "0.45680135", "0.45521274", "0.45414808", "0.45...
0.55118585
0
Parses CUCM export of phones with fields 'Description', 'Device Name', and 'Directory Number 1'
def cucm_export_parse(file): phones = {} while True: try: with open(file) as phonelist_csv: for line in phonelist_csv: if not line.__contains__('Description,Device Name,Directory Number 1'): info = line.split(',') ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_phone(parsed_data):\n result = []\n known_values = []\n\n contacts = {'registrant_contact': [], 'administrative_contact': [], 'technical_contact': [],\n 'domain_registrar' :[]}\n if 'registrant_contact' in parsed_data:\n contacts['registrant_conta...
[ "0.5697088", "0.53372353", "0.5237132", "0.52135444", "0.5204209", "0.5193696", "0.5180402", "0.51639044", "0.5127449", "0.5107768", "0.5095245", "0.5094951", "0.50657725", "0.5043901", "0.50421095", "0.49992374", "0.4995149", "0.49897113", "0.49766734", "0.49737394", "0.4962...
0.7282722
0
Parses device lists and outputs to spreadsheet
def output_to_spreadsheet(routers_switches, phones, aps, others, failed_devices, file_location): # Creates Excel workbook and worksheets wb = Workbook() routers_switches_ws = wb.active routers_switches_ws.title = 'Routers_Switches' phones_ws = wb.create_sheet('Phones') aps_ws = wb.create_sheet('...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_devices_summary():\n\n # This function was created to replace get_devices_information\n # because it wasn't detecting virtual systems in Palo Alto Virtual Systems\n global nipper_xml\n devices = {}\n headings = []\n\n # Add the table headings to a list\n for h in nipper_xml.findall(\"....
[ "0.653493", "0.64370185", "0.619556", "0.60104626", "0.5987369", "0.59667", "0.5913384", "0.5850942", "0.57446754", "0.5737992", "0.5729885", "0.57229185", "0.57079405", "0.5698568", "0.56967455", "0.5694549", "0.5687321", "0.5673653", "0.56696445", "0.56641084", "0.56432945"...
0.615764
3
Simple decorator that intercepts connection errors and ignores these if settings specify this.
def omit_exception(method): @functools.wraps(method) def _decorator(self, *args, **kwargs): if self._ignore_exceptions: try: return method(self, *args, **kwargs) except ConnectionInterrupted: return None else: return ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def raises_conn_error(func):\n @functools.wraps(func)\n def wrapper(*args, **kwargs):\n try:\n return func(*args, **kwargs)\n except exc.InvalidRequestError:\n LOG.exception('Connection error:')\n raise errors.ConnectionError()\n\n return wrapper", "def cat...
[ "0.72698784", "0.66141045", "0.6369015", "0.6124528", "0.60732985", "0.6064023", "0.6020223", "0.598191", "0.5975428", "0.5972395", "0.5914723", "0.5908168", "0.58850574", "0.58763325", "0.586832", "0.5864718", "0.58527994", "0.58304864", "0.5756849", "0.5747329", "0.57441664...
0.57709926
18
Lazy client connection property.
def client(self): if self._client is None: self._client = self._client_cls(self._server, self._params, self) return self._client
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _getClientConnection(self):\n self.client = twisted_client.DivvyClient(self.host, self.port, timeout=1.0)\n return self.client.connection.deferred", "def _http_client(self):\n\n self.__enforce_connected()\n return self.collection._http_client", "def Client(self):\n return...
[ "0.68353057", "0.647777", "0.6356882", "0.63473797", "0.63429874", "0.6337806", "0.6315816", "0.62760454", "0.62649846", "0.61533195", "0.6150137", "0.6147768", "0.6136684", "0.6119306", "0.61188084", "0.60776466", "0.60776466", "0.6076847", "0.6074807", "0.6074807", "0.60748...
0.615881
9
Return a raw redis client (connection). Not all pluggable clients supports this feature. If not supports this raises NotImplementedError
def raw_client(self): warnings.warn("raw_client is deprecated. use self.client.get_client instead", DeprecationWarning, stacklevel=2) return self.client.get_client(write=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_redis_client(self):\n\n client = Client(\n #connection_pool=connection_pool,\n host=self.backend_settings.get('HOST', 'localhost'),\n port=int(self.backend_settings.get('PORT', 6379)),\n io_loop=self.io_loop,\n password=self.backend_settings.get...
[ "0.75808513", "0.7364119", "0.7324798", "0.7252318", "0.7140241", "0.7111231", "0.70927393", "0.70927393", "0.7028319", "0.70221347", "0.6977828", "0.6932089", "0.68634254", "0.68316096", "0.68309367", "0.68088293", "0.67714703", "0.67087954", "0.66233534", "0.6567602", "0.65...
0.6708816
17
Return a next index for read client. This function implements a default behavior for get a next read client for masterslave setup. Overwrite this function if you want a specific behavior.
def get_next_client_index(self, write=True): if write or len(self._server) == 1: return 0 return random.randint(1, len(self._server) - 1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __next_index():\n return redis_store.incr(String.__name__.lower() + '-index')", "def get_client(self, write=True):\r\n index = self.get_next_client_index(write=write)\r\n\r\n if self._clients[index] is None:\r\n self._clients[index] = self.connect(index)\r\n\r\n return ...
[ "0.6373826", "0.60432035", "0.57846725", "0.57057947", "0.56468946", "0.5631014", "0.5614183", "0.56074053", "0.56074053", "0.5567467", "0.5533405", "0.5528173", "0.5506794", "0.55002165", "0.5483921", "0.54825854", "0.5479725", "0.54147923", "0.5399875", "0.53776383", "0.534...
0.72630644
0
Method used for obtain a raw redis client. This function is used by almost all cache backend operations for obtain a native redis client/connection instance.
def get_client(self, write=True): index = self.get_next_client_index(write=write) if self._clients[index] is None: self._clients[index] = self.connect(index) return self._clients[index]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_redis_client(self):\n\n client = Client(\n #connection_pool=connection_pool,\n host=self.backend_settings.get('HOST', 'localhost'),\n port=int(self.backend_settings.get('PORT', 6379)),\n io_loop=self.io_loop,\n password=self.backend_settings.get...
[ "0.77595675", "0.75294465", "0.7431494", "0.7431494", "0.7419155", "0.7383458", "0.7361354", "0.7291747", "0.7288551", "0.7055464", "0.69388926", "0.687926", "0.682468", "0.681639", "0.6660242", "0.6626695", "0.6580045", "0.6546807", "0.6497834", "0.64684373", "0.6462292", ...
0.0
-1
Method that parse a connection string.
def parse_connection_string(self, constring): try: host, port, db = constring.split(":") port = port if host == "unix" else int(port) db = int(db) return host, port, db except (ValueError, TypeError): raise ImproperlyConfigured("Incorrec...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _parse_connection_string(self, connection_string):\n self.host = '127.0.0.1'\n self.port = 3306\n self.db = None\n self.user = None\n self.pwd = None\n for part in connection_string.split(';'):\n part = part.strip()\n if part != '':\n ...
[ "0.8401574", "0.6616161", "0.6538914", "0.6453745", "0.6397597", "0.6344282", "0.6208351", "0.6030974", "0.59864354", "0.57071424", "0.56045955", "0.5569482", "0.5531569", "0.5472697", "0.5466513", "0.5460773", "0.54534364", "0.5451783", "0.5448955", "0.5406482", "0.5380559",...
0.7921391
1
Given a connection index, returns a new raw redis client/connection instance. Index is used for master/slave setups and indicates that connection string should be used. In normal setups, index is 0.
def connect(self, index=0): host, port, db = self.parse_connection_string(self._server[index]) return self.connection_factory.connect(host, port, db)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connect(self, index=0, write=True):\r\n master_name, sentinel_hosts, db = self.parse_connection_string(self._connection_string)\r\n\r\n sentinel_timeout = self._options.get('SENTINEL_TIMEOUT', 1)\r\n sentinel = Sentinel(sentinel_hosts, socket_timeout=sentinel_timeout)\r\n\r\n if wri...
[ "0.5969906", "0.5762544", "0.5700567", "0.5463157", "0.5462497", "0.5395308", "0.5355108", "0.53345335", "0.5311246", "0.53111696", "0.53071743", "0.5279201", "0.52436805", "0.5213795", "0.52018327", "0.5171319", "0.5145463", "0.5115737", "0.51155186", "0.51154757", "0.510455...
0.64365077
0
Persist a value to the cache, and set an optional expiration time. Also supports optional nx parameter. If set to True will use redis setnx instead of set.
def set(self, key, value, timeout=DEFAULT_TIMEOUT, version=None, client=None, nx=False): if not client: client = self.get_client(write=True) key = self.make_key(key, version=version) value = self.pickle(value) if timeout is True: warnings.warn("Using T...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set(self, key, value, ttl=None):\n if ttl and (type(ttl) is int) and (ttl > 0):\n ttl += int(dt.now().strftime('%s'))\n self.dadd('ttl', (key, ttl))\n return super(MyCache, self).set(key, value)", "def set_cache(self, key, value):\n self.r.set(key, value)\n s...
[ "0.71424836", "0.703814", "0.7037537", "0.693196", "0.69029826", "0.68569165", "0.6698016", "0.66800463", "0.66005665", "0.65324146", "0.6516281", "0.65056723", "0.64677554", "0.6453569", "0.64420253", "0.6440975", "0.6368826", "0.6368644", "0.63575447", "0.63526106", "0.6343...
0.64705276
12
Adds delta to the cache version for the supplied key. Returns the new version.
def incr_version(self, key, delta=1, version=None, client=None): if client is None: client = self.get_client(write=True) if version is None: version = self._backend.version old_key = self.make_key(key, version) value = self.get(old_key, version=version...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def incr(self, key, delta=1):\n try:\n key = self.prepare_key(key)\n return super(CacheClass, self).incr(key, delta)\n except Exception as err:\n return self.warn_or_error(err, delta)", "def incr(self, key, delta=1, version=None, client=None):\r\n return self...
[ "0.6767568", "0.6661848", "0.6260883", "0.6248231", "0.6220057", "0.5948065", "0.5826451", "0.56962454", "0.55747366", "0.54451704", "0.53051615", "0.52766025", "0.5254437", "0.52447313", "0.5226823", "0.5207911", "0.52070314", "0.52013683", "0.5162349", "0.5153979", "0.51407...
0.73972917
0
Add a value to the cache, failing if the key already exists. Returns ``True`` if the object was added, ``False`` if not.
def add(self, key, value, timeout=DEFAULT_TIMEOUT, version=None, client=None): return self.set(key, value, timeout, client=client, nx=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(self, key, value, timeout=None):\n try:\n key = self.prepare_key(key)\n if self._cache.exists(key):\n return False\n return self.set(key, value, timeout)\n except Exception as err:\n return self.warn_or_error(err, False)", "async de...
[ "0.79764557", "0.784722", "0.76094764", "0.7570547", "0.67336345", "0.66414005", "0.65780276", "0.6525757", "0.65098953", "0.64111245", "0.6403692", "0.63962054", "0.6391893", "0.6364911", "0.63507026", "0.63174766", "0.63061655", "0.6276967", "0.6250194", "0.6208237", "0.620...
0.60447884
43
Retrieve a value from the cache. Returns unpickled value if key is found, the default if not.
def get(self, key, default=None, version=None, client=None): if client is None: client = self.get_client(write=False) key = self.make_key(key, version=version) try: value = client.get(key) except ConnectionError: raise ConnectionInterrupted(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cache_get(key, default=None):\n mc = get_cache_client()\n try:\n return decode_value(mc.get(get_key(key))) or default\n except:\n return default", "def get(self, key, default=None):\n try:\n # get the value from the cache\n value = self._cache.get(self.prep...
[ "0.8608674", "0.8461511", "0.7560578", "0.7520198", "0.7461802", "0.74511784", "0.7430722", "0.7409133", "0.7403028", "0.7392436", "0.73517424", "0.73517424", "0.7344049", "0.7314685", "0.7308884", "0.73088133", "0.73088133", "0.73070526", "0.7288571", "0.72056913", "0.716522...
0.69232833
37
Remove a key from the cache.
def delete(self, key, version=None, client=None): if client is None: client = self.get_client(write=True) try: return client.delete(self.make_key(key, version=version)) except ConnectionError: raise ConnectionInterrupted(connection=client)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(self, key):\n del self._cache[key]", "def delete_cache(self, key):\n self.r.delete(key)", "def delete(self, key):\n # Initialize key variables\n result = self.cache.delete(key)\n\n # Return\n return result", "def delete(self, key):\n try:\n ...
[ "0.83336556", "0.83148736", "0.82934654", "0.82560545", "0.80965835", "0.8031949", "0.8010773", "0.7989685", "0.7981018", "0.79799193", "0.79403096", "0.78806204", "0.7873276", "0.7864556", "0.7860124", "0.7842964", "0.7785126", "0.77501744", "0.7734317", "0.77335244", "0.770...
0.0
-1
Remove all keys matching pattern.
def delete_pattern(self, pattern, version=None, client=None): if client is None: client = self.get_client(write=True) pattern = self.make_key(pattern, version=version) try: keys = client.keys(pattern) if keys: return client.delete(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _delete_keys_script(key_pattern):\n return \"\"\"\n local curkey = redis.call('keys', '%(key_pattern)s')\n if next(curkey) then\n redis.call('del', unpack(curkey))\n end\n \"\"\" % dict(key_pattern = key_pattern)", "def removeAllKeys(self) -> None:\n ...", "def ...
[ "0.71263444", "0.71224153", "0.69078034", "0.68396205", "0.62849766", "0.6268765", "0.6172009", "0.6127846", "0.6119483", "0.60778594", "0.60445154", "0.60347545", "0.6034711", "0.6016867", "0.59771806", "0.59697485", "0.59694785", "0.59510666", "0.59176606", "0.59154534", "0...
0.5490217
58
Remove multiple keys at once.
def delete_many(self, keys, version=None, client=None): if client is None: client = self.get_client(write=True) if not keys: return keys = [self.make_key(k, version=version) for k in keys] try: return client.delete(*keys) except C...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_many(self, keys):\n raise NotImplementedError()", "def delete_many(self, keys):\n return self.delete_many_values(keys)", "def delete_many(self, keys):\n try:\n if keys:\n self._cache.delete(*map(self.prepare_key, keys))\n except Exception as err:...
[ "0.7817214", "0.7613119", "0.75661665", "0.7246898", "0.72212213", "0.7096062", "0.70484746", "0.6989821", "0.6989821", "0.6989821", "0.69775665", "0.6884616", "0.68422145", "0.68080235", "0.6671621", "0.6636076", "0.6628445", "0.6601189", "0.6573967", "0.6571191", "0.6570996...
0.68532324
12
Flush all cache keys.
def clear(self, client=None): if client is None: client = self.get_client(write=True) client.flushdb()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flush():\n for k in cache._thecache.keys():\n del cache._thecache[k]", "def flush_all(cls):\n for sess in cls._session_registry.values():\n sess.flush()", "def flush(self):\n self._getMemcacheClient().flush_all()", "def flush():\n global CACHE, STATS_KEYS_COUNT\n CA...
[ "0.8249561", "0.74615514", "0.74002236", "0.73858947", "0.73273766", "0.7129604", "0.7088885", "0.6993901", "0.6992103", "0.6972405", "0.6971914", "0.69617254", "0.6873503", "0.684811", "0.681874", "0.67652905", "0.6680763", "0.66221285", "0.6614499", "0.6566027", "0.6557009"...
0.0
-1
Unpickles the given value.
def unpickle(value): try: value = int(value) except (ValueError, TypeError): value = smart_bytes(value) value = pickle.loads(value) return value
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unserialize(val):\n return pickle.loads(val)", "def _decode_value(self, value):\n return pickle.loads(value.value) if value else value", "def from_value(value):\n return pickle.dumps(value)", "def base64unpickle(self, value):\n if value:\n return pickle.loads(self.base64decod...
[ "0.7045012", "0.7031028", "0.6841384", "0.65678066", "0.6526041", "0.64857894", "0.6477095", "0.61220485", "0.6111226", "0.6080982", "0.6064356", "0.60208184", "0.6005177", "0.5897015", "0.58008486", "0.5781338", "0.57552445", "0.57470506", "0.5712168", "0.56796086", "0.56617...
0.7501486
0
Pickle the given value.
def pickle(self, value): if isinstance(value, bool) or not isinstance(value, integer_types): return pickle.dumps(value, self._pickle_version) return value
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_value(value):\n return pickle.dumps(value)", "def dump_object(self, value):\n return pickle.dumps(value)", "def _encode_value(self, value):\n return pickle.dumps(value)", "def unserialize(val):\n return pickle.loads(val)", "def value(self) -> Any:\n return pickle.loads(self.pi...
[ "0.77703", "0.7441614", "0.6958083", "0.6798523", "0.6667502", "0.6574332", "0.6568599", "0.6552237", "0.65478945", "0.6544326", "0.65061575", "0.6471692", "0.64400285", "0.6392385", "0.6310394", "0.6301115", "0.6247126", "0.6234851", "0.619252", "0.61067325", "0.6043083", ...
0.75480545
1
Set a bunch of values in the cache at once from a dict of key/value pairs. This is much more efficient than calling set() multiple times. If timeout is given, that timeout will be used for the key; otherwise the default cache timeout will be used.
def set_many(self, data, timeout=DEFAULT_TIMEOUT, version=None, client=None): if client is None: client = self.get_client(write=True) try: pipeline = client.pipeline() for key, value in data.items(): self.set(key, value, timeout, version=versio...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_many(self, data, timeout=None):\n try:\n safe_data = {}\n for key, value in data.iteritems():\n safe_data[self.prepare_key(key)] = pickle.dumps(value)\n if safe_data:\n self._cache.mset(safe_data)\n map(self.expire, safe_d...
[ "0.7048416", "0.65402865", "0.65266925", "0.65183073", "0.6350942", "0.62865585", "0.62400687", "0.6119562", "0.60667795", "0.60572", "0.60372555", "0.5987229", "0.5970992", "0.5851879", "0.5771597", "0.5759905", "0.5714097", "0.56895006", "0.56890684", "0.56627226", "0.55355...
0.6101358
8
Add delta to value in the cache. If the key does not exist, raise a ValueError exception.
def incr(self, key, delta=1, version=None, client=None): return self._incr(key=key, delta=delta, version=version, client=client)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def incr(self, key, delta=1):\n try:\n key = self.prepare_key(key)\n return super(CacheClass, self).incr(key, delta)\n except Exception as err:\n return self.warn_or_error(err, delta)", "async def _add(self, key, value, ttl=None):\n if key in SimpleMemoryBack...
[ "0.7142552", "0.66308564", "0.65371734", "0.63884085", "0.62857854", "0.6254576", "0.6170329", "0.60990596", "0.6067846", "0.60315996", "0.6010248", "0.5961082", "0.5929392", "0.59237266", "0.5892977", "0.5892977", "0.58660084", "0.5862615", "0.5854951", "0.580561", "0.580539...
0.52970463
82
Decreace delta to value in the cache. If the key does not exist, raise a ValueError exception.
def decr(self, key, delta=1, version=None, client=None): return self._incr(key=key, delta=-delta, version=version, client=client)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decr(self, key, delta=1):\n try:\n key = self.prepare_key(key)\n return super(CacheClass, self).decr(key, delta)\n except Exception as err:\n return self.warn_or_error(err, delta)", "def decr(self, key, delta=1):\n\t\treturn self._incrdecr(\"decr\", key, delta)"...
[ "0.7430303", "0.6069981", "0.599998", "0.5940083", "0.5817379", "0.5777649", "0.5653828", "0.5540521", "0.5511951", "0.5498733", "0.5495983", "0.54901856", "0.546873", "0.5436476", "0.5412869", "0.53812855", "0.53312963", "0.520011", "0.51767087", "0.51663154", "0.5164387", ...
0.5794123
5
Executes TTL redis command and return the "timetolive" of specified key. If key is a non volatile key, it returns None.
def ttl(self, key, version=None, client=None): if client is None: client = self.get_client(write=False) key = self.make_key(key, version=version) if not client.exists(key): return 0 return client.ttl(key)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_ttl(self, key, now=None):\n if now is None:\n now = time.time()\n with self._lock:\n # pylint: disable=unused-variable\n expire, _value = self._values[key]\n return expire - now", "def ttl(self, key):\n return self._command(b'PTTL', key, ha...
[ "0.69026345", "0.68486464", "0.6479326", "0.59795386", "0.5874349", "0.5834716", "0.5834716", "0.5786248", "0.57667464", "0.57667464", "0.57667464", "0.5726573", "0.5716824", "0.57058173", "0.57058173", "0.5512666", "0.54317343", "0.5408408", "0.53892404", "0.5384477", "0.537...
0.61664176
3
Test if key exists.
def has_key(self, key, version=None, client=None): if client is None: client = self.get_client(write=False) key = self.make_key(key, version=version) try: return client.exists(key) except ConnectionError: raise ConnectionInterrupted(connecti...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exists(self, key_name: str) -> bool:\n pass", "def key_exists(dictionary, key):\n\n exists = dictionary.get(key, None)\n return exists is not None", "def has(self, key):", "def has(self, key):\n return False", "def containsKey(self, key):\n return get(key) != None", "def ha...
[ "0.8538106", "0.8020361", "0.79491585", "0.7948841", "0.7855513", "0.7791192", "0.77758735", "0.77736175", "0.7767599", "0.77593726", "0.7699159", "0.7668944", "0.7656245", "0.76534593", "0.7638008", "0.7625921", "0.7601507", "0.7591905", "0.7566847", "0.7560203", "0.74866575...
0.698617
55
Same as keys, but uses redis >= 2.8 cursors for make memory efficient keys iteration.
def iter_keys(self, search, itersize=None, client=None, version=None): if client is None: client = self.get_client(write=False) pattern = self.make_key(search, version=version) cursor = b"0" while True: cursor, data = client.scan(cursor, match=pattern,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def keysAll():", "def iterkeys(self):", "def iterkeys(self):", "def __iter__(self):\n with SessionContext(self.SessionClass) as session:\n keys = session.query(PAW2_DBObject.key)\n keys = [c[0] for c in keys]\n random.shuffle(keys)\n return keys.__it...
[ "0.6539967", "0.6439033", "0.6439033", "0.6406501", "0.6317287", "0.62992024", "0.6295674", "0.62863976", "0.6251499", "0.61752737", "0.61744106", "0.6127187", "0.61208725", "0.6091683", "0.6080563", "0.60704976", "0.60620534", "0.60554224", "0.60449165", "0.60397065", "0.600...
0.61971253
9
Execute KEYS command and return matched results.
def keys(self, search, version=None, client=None): if client is None: client = self.get_client(write=False) pattern = self.make_key(search, version=version) try: encoding_map = [smart_text(k) for k in client.keys(pattern)] return [self.reverse_key(k)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def keys(self, pattern=\"*\"):\n return self._command(b'KEYS', pattern, handler=list_of_keys)", "def cli(ctx):\n return ctx.gi.cannedkeys.get_keys()", "def hkeys(self, key):\n return self._command(b'HKEYS', key, handler=list_of_keys)", "def get_keys(self):\r\n\t\tlogger.debug(\"Getting the k...
[ "0.6484579", "0.64004225", "0.63666326", "0.596718", "0.5795308", "0.57775927", "0.57604456", "0.56159306", "0.5600945", "0.54936355", "0.54684335", "0.54242885", "0.5403328", "0.5398406", "0.53625154", "0.53272474", "0.5319963", "0.5312056", "0.5285476", "0.5284211", "0.5275...
0.51984143
27
Simple decorator that intercepts connection errors and ignores these if settings specify this.
def auto_failover(method): @functools.wraps(method) def _decorator(self, *args, **kwargs): if self._in_fallback: pass_seconds = (datetime_now() - self._in_fallback_date).total_seconds() if pass_seconds > self._options.get("FAILOVER_TIME", 30): print("Go to...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def raises_conn_error(func):\n @functools.wraps(func)\n def wrapper(*args, **kwargs):\n try:\n return func(*args, **kwargs)\n except exc.InvalidRequestError:\n LOG.exception('Connection error:')\n raise errors.ConnectionError()\n\n return wrapper", "def cat...
[ "0.72698784", "0.66141045", "0.6369015", "0.6124528", "0.60732985", "0.6064023", "0.6020223", "0.598191", "0.5975428", "0.5972395", "0.5914723", "0.5908168", "0.58850574", "0.58763325", "0.586832", "0.5864718", "0.58527994", "0.58304864", "0.57709926", "0.5756849", "0.5747329...
0.55187356
36
Set a bunch of values in the cache at once from a dict of key/value pairs. This is much more efficient than calling set() multiple times. If timeout is given, that timeout will be used for the key; otherwise the default cache timeout will be used.
def set_many(self, data, timeout=DEFAULT_TIMEOUT, version=None, client=None, herd=True): if client is None: client = self.get_client(write=True) set_function = self.set if herd else super(HerdClient, self).set try: pipeline = client.pipeline() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_many(self, data, timeout=None):\n try:\n safe_data = {}\n for key, value in data.iteritems():\n safe_data[self.prepare_key(key)] = pickle.dumps(value)\n if safe_data:\n self._cache.mset(safe_data)\n map(self.expire, safe_d...
[ "0.7048416", "0.65402865", "0.65266925", "0.65183073", "0.6350942", "0.62865585", "0.62400687", "0.6119562", "0.6101358", "0.60667795", "0.60572", "0.60372555", "0.5987229", "0.5970992", "0.5851879", "0.5771597", "0.5759905", "0.5714097", "0.56890684", "0.56627226", "0.553553...
0.56895006
18
Slightly different logic than connection to multiple Redis servers. Reserve only one write and read descriptors, as they will be closed on exit anyway.
def __init__(self, server, params, backend): super(SentinelClient, self).__init__(server, params, backend) self._client_write = None self._client_read = None self._connection_string = server
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run():\n\n # Channel for server 1\n channel1 = grpc.insecure_channel('localhost:50050')\n # Channel for server 2\n channel2 = grpc.insecure_channel('localhost:50051')\n\n # Try connecting to server 1\n try:\n grpc.channel_ready_future(channel1).result(timeout=10)\n except grpc.FutureTimeoutError:\n ...
[ "0.5756547", "0.5705014", "0.56609225", "0.56317014", "0.56010807", "0.5594784", "0.5534754", "0.5484524", "0.5445007", "0.5390398", "0.5271254", "0.5266093", "0.5203367", "0.5198337", "0.51727325", "0.51431376", "0.51426405", "0.5134598", "0.5107338", "0.5099761", "0.5095901...
0.0
-1
Creates a redis connection with connection pool.
def connect(self, index=0, write=True): master_name, sentinel_hosts, db = self.parse_connection_string(self._connection_string) sentinel_timeout = self._options.get('SENTINEL_TIMEOUT', 1) sentinel = Sentinel(sentinel_hosts, socket_timeout=sentinel_timeout) if write: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_connection(self, params):\r\n return Redis(connection_pool=self.get_or_create_connection_pool(params))", "def _get_conn(self):\n return redis.Redis(connection_pool=self.pool)", "def redis_conn_pool(self) -> ConnectionPool:\n if self._redis_conn_pool is None:\n if self._c...
[ "0.816493", "0.8086648", "0.80148584", "0.7929269", "0.78915024", "0.7698564", "0.76977664", "0.7661963", "0.7301383", "0.7234917", "0.7058955", "0.7024496", "0.6995398", "0.6990696", "0.6944723", "0.68580353", "0.68409115", "0.6773969", "0.6773969", "0.67109364", "0.67108244...
0.0
-1
Closing old connections, as master may change in time of inactivity.
def close(self, **kwargs): del(self._client_write) del(self._client_read) self._client_write = None self._client_read = None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close_TCP_connections(self):\n if self.master_connection is not None:\n self.master_connection.end_connection()", "def killconnections(self):\n for conn in self._connections:\n try:conn.close()\n except:pass\n self._connections=[]", "def close_connectio...
[ "0.724613", "0.71849734", "0.70590407", "0.70198625", "0.68154216", "0.6805143", "0.67401", "0.67300326", "0.6710922", "0.6699254", "0.66523874", "0.66515815", "0.6563905", "0.65553296", "0.6547943", "0.65115845", "0.6450652", "0.64278555", "0.6373628", "0.63606566", "0.63296...
0.0
-1
Persist a value to the cache, and set an optional expiration time.
def set(self, key, value, timeout=DEFAULT_TIMEOUT, version=None, client=None, nx=False): if client is None: key = self.make_key(key, version=version) client = self.get_server(key) return super(ShardClient, self).set(key=key, value=value, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save(self, key, value, expires_in=None):\n raise NotImplementedError()", "def set_cache(self, key, value):\n self.r.set(key, value)\n self.r.expire(key, time=1500)", "def set(self, key, value, ttl=None):\n self._cache[key] = (value, self._clock() + (ttl or self.default_ttl))", ...
[ "0.760283", "0.75839907", "0.7389476", "0.7343514", "0.7335355", "0.7321049", "0.7248851", "0.72112036", "0.72053784", "0.70779395", "0.70533335", "0.7046328", "0.68926704", "0.6892219", "0.68712306", "0.68530697", "0.68502986", "0.6814827", "0.679815", "0.6783913", "0.677559...
0.0
-1
Set a bunch of values in the cache at once from a dict of key/value pairs. This is much more efficient than calling set() multiple times. If timeout is given, that timeout will be used for the key; otherwise the default cache timeout will be used.
def set_many(self, data, timeout=DEFAULT_TIMEOUT, version=None): for key, value in data.items(): self.set(key, value, timeout, version=version)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_many(self, data, timeout=None):\n try:\n safe_data = {}\n for key, value in data.iteritems():\n safe_data[self.prepare_key(key)] = pickle.dumps(value)\n if safe_data:\n self._cache.mset(safe_data)\n map(self.expire, safe_d...
[ "0.7050163", "0.65413386", "0.651945", "0.6352375", "0.62874395", "0.62409884", "0.6121251", "0.61032474", "0.6068264", "0.6058403", "0.6038714", "0.59884614", "0.59725994", "0.58536285", "0.5773165", "0.5760298", "0.5715581", "0.5691752", "0.56912005", "0.5664539", "0.553672...
0.65285224
2
Test if key exists.
def has_key(self, key, version=None, client=None): if client is None: key = self.make_key(key, version=version) client = self.get_server(key) key = self.make_key(key, version=version) try: return client.exists(key) except ConnectionError: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exists(self, key_name: str) -> bool:\n pass", "def key_exists(dictionary, key):\n\n exists = dictionary.get(key, None)\n return exists is not None", "def has(self, key):", "def has(self, key):\n return False", "def containsKey(self, key):\n return get(key) != None", "def ha...
[ "0.8538106", "0.8020361", "0.79491585", "0.7948841", "0.7855513", "0.7791192", "0.77758735", "0.77736175", "0.7767599", "0.77593726", "0.7699159", "0.7668944", "0.7656245", "0.76534593", "0.7638008", "0.7625921", "0.7601507", "0.7591905", "0.7566847", "0.7560203", "0.74866575...
0.6787201
79
Remove multiple keys at once.
def delete_many(self, keys, version=None): res = 0 for key in [self.make_key(k, version=version) for k in keys]: client = self.get_server(key) res += self.delete(key, client=client) return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_many(self, keys):\n raise NotImplementedError()", "def delete_many(self, keys):\n return self.delete_many_values(keys)", "def delete_many(self, keys):\n try:\n if keys:\n self._cache.delete(*map(self.prepare_key, keys))\n except Exception as err:...
[ "0.78181726", "0.7613702", "0.7566873", "0.7248788", "0.7222351", "0.70959216", "0.7048892", "0.6990814", "0.6990814", "0.6990814", "0.69779724", "0.6886202", "0.68539685", "0.6840806", "0.68096286", "0.6636776", "0.6628584", "0.66031945", "0.65741676", "0.65718824", "0.65697...
0.6672314
15
Remove all keys matching pattern.
def delete_pattern(self, pattern, version=None): pattern = self.make_key(pattern, version=version) keys = [] for server, connection in self._serverdict.items(): keys.extend(connection.keys(pattern)) res = 0 if keys: for server, connection in s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _delete_keys_script(key_pattern):\n return \"\"\"\n local curkey = redis.call('keys', '%(key_pattern)s')\n if next(curkey) then\n redis.call('del', unpack(curkey))\n end\n \"\"\" % dict(key_pattern = key_pattern)", "def removeAllKeys(self) -> None:\n ...", "def ...
[ "0.71254295", "0.7120807", "0.6908498", "0.68388987", "0.62851423", "0.62675834", "0.6172457", "0.6128228", "0.6118215", "0.607907", "0.6034034", "0.6033035", "0.6014922", "0.59763515", "0.596867", "0.5966957", "0.59499526", "0.5918134", "0.59159", "0.58328205", "0.5824407", ...
0.60441214
10
Given a main connection parameters, build a complete dict of connection parameters.
def make_connection_params(self, host, port, db): kwargs = { "db": db, "parser_class": self.get_parser_cls(), "password": self.options.get('PASSWORD', None), } if host == "unix": kwargs.update({'path': port, 'connection_class': UnixDomai...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_conn_params(self) -> dict[str, Any]:\n conn = self.get_connection(self.slack_conn_id)\n if not conn.password:\n raise AirflowNotFoundException(\n f\"Connection ID {self.slack_conn_id!r} does not contain password (Slack API Token).\"\n )\n conn_para...
[ "0.6778545", "0.6718613", "0.66834867", "0.6634806", "0.6489588", "0.63820136", "0.62357676", "0.6113212", "0.6085891", "0.6050217", "0.6034028", "0.60113174", "0.5992468", "0.5983846", "0.59766847", "0.59404546", "0.5936679", "0.5914405", "0.58865356", "0.57984245", "0.57612...
0.60750484
9
Given a basic connection parameters, return a new connection.
def connect(self, host, port, db): params = self.make_connection_params(host, port, db) return self.get_connection(params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_new_connection(self, conn_params):\r\n self.__connection_string = conn_params.get('connection_string', '')\r\n conn = Database.connect(**conn_params)\r\n return conn", "def establish_connection(self):\n conninfo = self.client\n for name, default_value in items(self.defa...
[ "0.76189566", "0.75521696", "0.70348966", "0.6959789", "0.6826062", "0.68241984", "0.67967474", "0.67898035", "0.6777832", "0.6749526", "0.6713498", "0.6677202", "0.6601608", "0.6575085", "0.6556423", "0.65309495", "0.650741", "0.64950335", "0.64948314", "0.64918983", "0.6474...
0.61695904
48
Given a now preformated params, return a new connection. The default implementation uses a cached pools for create new connection.
def get_connection(self, params): return Redis(connection_pool=self.get_or_create_connection_pool(params))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_new_connection(self, conn_params):\r\n self.__connection_string = conn_params.get('connection_string', '')\r\n conn = Database.connect(**conn_params)\r\n return conn", "def get_or_create_connection_pool(self, params):\r\n key = frozenset((k, repr(v)) for (k, v) in params.items...
[ "0.76215917", "0.7489781", "0.73058176", "0.7165421", "0.7008004", "0.65971446", "0.6503326", "0.6394611", "0.6264323", "0.62370783", "0.6193519", "0.61733115", "0.6165344", "0.6136383", "0.61237514", "0.61154366", "0.60612833", "0.60064197", "0.5986906", "0.598591", "0.59634...
0.71042955
4
Given a connection parameters and return a new or cached connection pool for them. Reimplement this method if you want distinct connection pool instance caching behavior.
def get_or_create_connection_pool(self, params): key = frozenset((k, repr(v)) for (k, v) in params.items()) if key not in self._pools: self._pools[key] = self.get_connection_pool(params) return self._pools[key]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_connection_pool(self, params):\r\n cp_params = dict(params)\r\n cp_params.update(self.pool_cls_kwargs)\r\n return self.pool_cls(**cp_params)", "def get_connection(self, params):\r\n return Redis(connection_pool=self.get_or_create_connection_pool(params))", "def build_connect...
[ "0.7633331", "0.7093984", "0.704607", "0.70299256", "0.7016528", "0.6718907", "0.66587025", "0.66581637", "0.66004694", "0.6494415", "0.6447045", "0.641799", "0.63243353", "0.6310433", "0.63036764", "0.6295449", "0.6271186", "0.6250118", "0.61557645", "0.61037254", "0.6043522...
0.7563619
1
Given a connection parameters, return a new connection pool for them. Overwrite this method if you want a custom behavior on creating connection pool.
def get_connection_pool(self, params): cp_params = dict(params) cp_params.update(self.pool_cls_kwargs) return self.pool_cls(**cp_params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_or_create_connection_pool(self, params):\r\n key = frozenset((k, repr(v)) for (k, v) in params.items())\r\n if key not in self._pools:\r\n self._pools[key] = self.get_connection_pool(params)\r\n return self._pools[key]", "def build_connection_pool(conn_details: dict):\n\n ...
[ "0.7737848", "0.7455023", "0.7187452", "0.70865107", "0.6992813", "0.69039977", "0.684276", "0.672731", "0.66503847", "0.6621734", "0.659866", "0.6564659", "0.6443048", "0.6405981", "0.63895524", "0.6246814", "0.62264544", "0.615156", "0.6043402", "0.6006722", "0.6000867", ...
0.79732764
0
Load class from path.
def load_class(path): mod_name, klass_name = path.rsplit('.', 1) try: mod = import_module(mod_name) except AttributeError as e: raise ImproperlyConfigured('Error importing {0}: "{1}"'.format(mod_name, e)) try: klass = getattr(mod, klass_name) except AttributeErr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load(path):\n pass", "def import_class(path):\n components = path.split(\".\")\n module = components[:-1]\n module = \".\".join(module)\n # __import__ needs a native str() on py2\n mod = __import__(module, fromlist=[str(components[-1])])\n return getattr(mod, str(components[-1]))", ...
[ "0.7547932", "0.74888587", "0.7334474", "0.7334474", "0.72811824", "0.7205953", "0.71651363", "0.7003949", "0.69815", "0.6721728", "0.67175806", "0.6711963", "0.66392964", "0.6612859", "0.66105014", "0.6606692", "0.66007376", "0.6546381", "0.6542882", "0.6378108", "0.6363662"...
0.745131
2
Tests calculating confusion matrix per subpopulation. Tests
def test_confusion_matrix_per_subgroup(): mx1 = np.array([[2, 1, 0], [0, 0, 0], [0, 0, 0]]) mx2 = np.array([[2, 0, 0], [0, 0, 0], [0, 2, 1]]) mx3 = np.array([[2, 0, 1], [0, 2, 0], [1, 0, 1]]) with pytest.warns(UserWarning) as w: pcmxs, bin_names = fumt.confusion_matrix_per_subgroup( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate_classifications(self):\n test_labels = open('./digitdata/testlabels', 'r')\n self.init_confusion_matrix()\n i = 0\n class_stats = {0:[0,0], 1:[0,0], 2:[0,0], 3:[0,0], 4:[0,0], 5:[0,0], 6:[0,0], 7:[0,0], 8:[0,0], 9:[0,0]}\n total_correct = 0\n num_labels = 1000...
[ "0.6618988", "0.66012615", "0.65771365", "0.64746296", "0.6443359", "0.6311446", "0.62488693", "0.6220614", "0.6143405", "0.6113498", "0.60880667", "0.60832113", "0.6033341", "0.6021256", "0.6018865", "0.59884655", "0.59654135", "0.59608114", "0.59072", "0.5879316", "0.582956...
0.68114936
0
Tests calculating confusion matrix per indexbased subpopulation. Tests
def test_confusion_matrix_per_subgroup_indexed(): incorrect_shape_error_gt = ('The ground_truth parameter should be a ' '1-dimensional numpy array.') incorrect_shape_error_p = ('The predictions parameter should be a ' '1-dimensional numpy array.') ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_confusion_matrix_per_subgroup():\n\n mx1 = np.array([[2, 1, 0], [0, 0, 0], [0, 0, 0]])\n mx2 = np.array([[2, 0, 0], [0, 0, 0], [0, 2, 1]])\n mx3 = np.array([[2, 0, 1], [0, 2, 0], [1, 0, 1]])\n\n with pytest.warns(UserWarning) as w:\n pcmxs, bin_names = fumt.confusion_matrix_per_subgroup...
[ "0.66565275", "0.62798464", "0.62386554", "0.6203715", "0.61975443", "0.6048215", "0.5992596", "0.59676194", "0.58624643", "0.5859458", "0.58580637", "0.58289576", "0.58109146", "0.5807874", "0.5788835", "0.5787484", "0.57719433", "0.5745471", "0.5728884", "0.572269", "0.5708...
0.6355921
1
BEWARE DIRTY HACK IN COORDINATE FLIPPING!!!!
def wrench_stamped_cb(self, ws): force_vec = np.array([ws.wrench.force.x, ws.wrench.force.y, ws.wrench.force.z]) scaled_vec = np.multiply(force_vec, self.scaling) mag = np.linalg.norm(force_vec) normalized_vec = np.divide(force_vec,mag) ta = TaxelArray() ta.header.fr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetLoCorner(self):\n ...", "def footprint_corner_indices():", "def degibber(self):", "def test_coord_preceding_fs(self):", "def solvate(self):\n\n pass", "def _update_farness_map(self,ind):", "def GetFlippedPoints2(paths,blankarray):\n #this may not work for double ups?\n for i ...
[ "0.59002066", "0.56784844", "0.56707025", "0.5661258", "0.5572482", "0.55679095", "0.5510954", "0.5503216", "0.55014324", "0.54342633", "0.5431841", "0.5417132", "0.5391007", "0.5321995", "0.53189087", "0.53001356", "0.5299283", "0.52908045", "0.5242194", "0.5197884", "0.5188...
0.0
-1
Print a result / processing summary.
def printSummary(result): inputCount = result['inputCount'] print('Kept %d of %d (%.2f%%) candidate substring%s seen on input.' % (len(result['substrings']), inputCount, len(result['substrings']) / inputCount * 100.0, '' if inputCount == 1 else 's'), file=sys.stderr) notEnou...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_results(summary):\n print ('Total running time %.2f secs (includes DB checks)'\n % summary.total_time)\n\n print 'OK:', summary.ok\n print 'Errors:', summary.errors\n\n # Display stats\n print 'Changes stats:'\n for var, s in summary.stats.iteritems():\n print '\\t%s:...
[ "0.76587313", "0.76228726", "0.7593415", "0.7478287", "0.7439275", "0.73064995", "0.73064995", "0.72284836", "0.71081173", "0.7048422", "0.7037371", "0.6983675", "0.6979697", "0.69744676", "0.6973929", "0.6933947", "0.6898518", "0.6890774", "0.6888606", "0.68714935", "0.68520...
0.64669585
46
Returns the number of prizes that will be awarded for this prize.
def num_awarded(self, floor=None): if self.award_to in ("individual_overall", "floor_overall", "dorm"): # For overall prizes, it is only possible to award one. return 1 elif self.award_to in ("floor_dorm", "individual_dorm"): # For dorm prizes, this is just the number of dorms. re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num_pickets(self) -> int:\n return len(self.pickets)", "def get_num_petals(self):\n return self._num_petals", "def psizes(self):\n return self._cache.psizes", "def num_votes(self):\n return sum(self.votes_per_count)", "def size(self) -> int:\n\n return self.sizes.sum(...
[ "0.65297043", "0.6438432", "0.638483", "0.625789", "0.61884695", "0.6187963", "0.6182225", "0.6173951", "0.6150105", "0.612123", "0.61027765", "0.6080633", "0.6056884", "0.60247165", "0.601722", "0.60013944", "0.5973453", "0.5966288", "0.5964273", "0.5963277", "0.59582824", ...
0.6676239
0
Adds a ticket from the user if they have one. Throws an exception if they cannot add a ticket.
def add_ticket(self, user): profile = user.get_profile() if profile.available_tickets() <= 0: raise Exception("This user does not have any tickets to allocate.") ticket = RaffleTicket(raffle_prize=self, user=user) ticket.save()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def ticket_add(self, ctx, user: discord.Member):\n guild_settings = await self.config.guild(ctx.guild).all()\n is_admin = await is_admin_or_superior(self.bot, ctx.author) or any(\n [ur.id in guild_settings[\"supportroles\"] for ur in ctx.author.roles]\n )\n must_be_admi...
[ "0.75067663", "0.65820646", "0.6444056", "0.64260346", "0.6213124", "0.61979747", "0.6157786", "0.60477424", "0.59763026", "0.59427506", "0.58696246", "0.5796449", "0.5795518", "0.579028", "0.576608", "0.5748269", "0.56843877", "0.56670624", "0.5599975", "0.5599003", "0.55944...
0.7707899
0
Removes an allocated ticket.
def remove_ticket(self, user): # Get the first ticket that matches the query. ticket = RaffleTicket.objects.filter(raffle_prize=self, user=user)[0] ticket.delete()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ticket_deleted(self, ticket):\n if 'ticket' not in self.sources:\n return\n gnp = GrowlNotificationPacket(notification='ticket',\n title='Ticket #%d deleted' % ticket.id,\n description=self._ticket_repr(ticket))\...
[ "0.6529886", "0.62774307", "0.6127702", "0.6008233", "0.59739345", "0.5789608", "0.57860637", "0.57634157", "0.57043296", "0.54994345", "0.53857934", "0.53857934", "0.53857934", "0.53857934", "0.53857934", "0.53857934", "0.53857934", "0.53857934", "0.53857934", "0.53857934", ...
0.64663655
1
Returns the number of tickets allocated to this prize. Takes an optional argument to return the number of tickets allocated by the user.
def allocated_tickets(self, user=None): query = self.raffleticket_set.filter(raffle_prize=self) if user: query = query.filter(user=user) return query.count()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num_assigned(self):\n return FlicketTicket.query.filter_by(assigned=self.user).count()", "def num_pickets(self) -> int:\n return len(self.pickets)", "def num_attendees(self):\r\n n = sum([c.qty for c in self.contribution_set.all()])\r\n return n", "def num_allocated_resources(...
[ "0.6878064", "0.62725556", "0.60077244", "0.5967526", "0.59303814", "0.587535", "0.5703093", "0.5699997", "0.5674289", "0.56504005", "0.56465405", "0.5644256", "0.5603991", "0.5569141", "0.5529344", "0.55266505", "0.55215555", "0.5503645", "0.54946893", "0.54946893", "0.54825...
0.7432309
0
Compute the transport plan P in regularization path for any given value of lambda
def compute_transport_plan(lam, lambda_list, Pi_list): if lam <= lambda_list[0]: Pi_inter = np.zeros(np.shape(Pi_list[-1])) elif lam >= lambda_list[-1]: Pi_inter = Pi_list[-1].toarray() else: idx = np.where(lambda_list < lam)[0][-1] lam_k = lambda_list[idx] lam_k1 = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_PRP(initial):\n return plan_route((initial[0],initial[1]), initial[2],\n # Goals:\n [(2,3),(3,2)],\n # Allowed locations:\n [(0,0),(0,1),(0,2),(0,3),\n (1,0),(1,1),(1,2),(1,3),\n ...
[ "0.5900887", "0.58707184", "0.57448065", "0.56907046", "0.5612557", "0.56111515", "0.5553134", "0.5529714", "0.55141824", "0.54726917", "0.5471628", "0.54607534", "0.54519314", "0.5421288", "0.5413783", "0.5371945", "0.5369936", "0.5324903", "0.5300132", "0.52990323", "0.5296...
0.70644534
0
Function of regularized path for l2panalized UOT
def ot_ul2_reg_path(a: np.array, b: np.array, C: np.array, lambdamax=np.inf, savePi=False, itmax=50000, save_AT_length=False): n = np.shape(a)[0] m = np.shape(b)[0] ones_n = np.ones((n,)) ones_m = np.ones((m,)) n_iter = 0 lambda_list = [] Pi_list = [] active_index_i = [] active_in...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_path2():\n path = [ (np.pi/10, 0.3, 1)] * 20\n execute_path(path, True)", "def constructShortestPath(self):", "def test_path7():\n path = [(0, 0, 1)]\n path += [\n [('A', 3, 0)],\n (0, 1, 1),\n [('A', 2, 0)],\n (np.pi/2, 1, 1),\n [('B',3,0)],\n (0, 1, 1),\n [('B',2,0)],\n (...
[ "0.5639856", "0.56145984", "0.5576992", "0.55674124", "0.54332876", "0.5414987", "0.53547007", "0.53476965", "0.53245836", "0.5295886", "0.5274415", "0.5268144", "0.5239604", "0.52213246", "0.5107726", "0.509267", "0.5091212", "0.5058955", "0.50285155", "0.50141966", "0.49931...
0.48698047
34
BFGS algorithm for l2penalized UOT
def ot_ul2_solve_BFGS(C, a, b, reg, maxiter=100000, tol=1e-14): # define objective function f def f(G): G = G.reshape((a.shape[0], b.shape[0])) return np.sum(G * C) + reg * np.sum((G.sum(1) - a) ** 2) + reg * np.sum((G.sum(0) - b) ** 2) # define the gradient of f def df(G): G =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def epsilon_fit_Chang_homemade(l_onde,vl1,vl2,vt1,vt2,gl1,gl2,gt1,gt2,f_t1,f_t2,f_l1,f_l2,epsinf1,epsinf2):\n # Chang PRB38 12369\n v = 1e4/l_onde\n \n epsx = (epsinf1+epsinf2)/2 - (f_l1*(vl1**2 - vt1**2))/(-vt1**2 + v**2 + 1j*v*gt1) - (f_l2*(vl2**2 - vt2**2))/(-vt2**2 + v**2 + 1j*v*gt2)\n eps...
[ "0.6178091", "0.6163994", "0.6161734", "0.61285937", "0.6091864", "0.6065697", "0.6045943", "0.6042955", "0.6023794", "0.60228187", "0.59937096", "0.5975979", "0.59758705", "0.59608454", "0.59554476", "0.5945483", "0.59318066", "0.5918379", "0.5907455", "0.5906748", "0.589358...
0.0
-1
Construction of design matrix H
def get_X_lasso(n, m): jHa = np.arange(m * n) iHa = np.repeat(np.arange(n), m) jHb = np.arange(m * n) iHb = np.tile(np.arange(m), n) + n j = np.concatenate((jHa, jHb)) i = np.concatenate((iHa, iHb)) H = sp.csc_matrix((np.ones(n * m * 2), (i, j)), shape=(n+m, n*m)) return H
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def H(self) -> BaseMatrix:", "def H(self) -> BaseMatrix:", "def create_design_matrix(self):\n self.design_matrix = np.zeros([self.n, self.p])\n self.design_matrix[:,0] = 1.0 #First comlum is 1 (bias term)\n\n for i in range(self.n):\n fo...
[ "0.7562958", "0.7562958", "0.68509895", "0.6653759", "0.65847844", "0.6574229", "0.64227295", "0.6341365", "0.62836915", "0.6248243", "0.617559", "0.61622995", "0.6127728", "0.608536", "0.608536", "0.60789907", "0.60694474", "0.604963", "0.6047809", "0.6045653", "0.5936148", ...
0.0
-1
Celer algorithm for lassoformulated l2penalized UOT
def ot_ul2_solve_lasso_celer(C, a, b, reg, nitermax=100000, tol=1e-14): X = get_X_lasso(C.shape[0], C.shape[1]) y = np.concatenate((a, b)) reg2 = 1.0 / (2 * (C.shape[0] + C.shape[1]) * reg) model = celer.Lasso(reg2, max_iter=nitermax, weights=C.ravel(), positive=True, fit_intercept=False, tol=tol) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lherzolite():\n\n rho = 3270.\n\n C = np.zeros((6,6), dtype=float)\n C[0,0] = 187.4; C[0,1] = 63.71; C[0,2] = 63.87; C[0,3] = 0.78; C[0,4] = 2.02; C[0,5] = -3.2\n C[1,0] = C[0,1]; C[1,1] = 211.25; C[1,2] = 64.5; C[1,3] = -3.07; C[1,4] = 0.87; C[1,5] = -5.78...
[ "0.59114254", "0.5880291", "0.5843534", "0.5838584", "0.58302855", "0.5817063", "0.5756946", "0.5756367", "0.57547534", "0.5744916", "0.5710205", "0.57045275", "0.56486785", "0.5626035", "0.56195045", "0.5611582", "0.55996555", "0.5590846", "0.55713654", "0.5568172", "0.55511...
0.0
-1
Coordinate descent algorithm for lassoformulated l2penalized UOT
def ot_ul2_solve_lasso_cd(C, a, b, reg, nitermax=100000, tol=1e-14): X = get_X_lasso(C.shape[0], C.shape[1]) X = X.dot(sp.diags((1 / C.ravel()))) y = np.concatenate((a, b)) reg2 = 1.0 / (2 * (C.shape[0] + C.shape[1]) * reg) model = Lasso(reg2, positive=True, fit_intercept=False, max_iter=nitermax, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method2(self):\n cres=np.zeros(self.NL,dtype=float) # List of invariants\n # The U matrices from Fukui's method; storage...\n Ux_loc=np.zeros((self.kS.Nx+1,self.kS.Ny+1),dtype=complex)\n Uy_loc=np.zeros((self.kS.Nx+1,self.kS.Ny+1),dtype=complex)\n \n for il in range...
[ "0.5958752", "0.5712532", "0.56944275", "0.56809044", "0.5679663", "0.5633035", "0.5623024", "0.5588956", "0.55861765", "0.55407983", "0.5530264", "0.55237794", "0.552077", "0.55181515", "0.5517798", "0.5506699", "0.55033195", "0.55033195", "0.5500844", "0.5489448", "0.548216...
0.0
-1
MajorizationMinimization algorithm for l2penalized UOT
def ot_ul2_solve_mu(C, a, b, reg, nitermax=100000, tol=1e-14, P0=None, verbose=False): if P0 is None: P = a[:, None] * b[None, :] else: P = P0 abt = np.maximum(a[:, None] + b[None, :] - C / (2 * reg), 0) for i in range(nitermax): Pold = P.copy() P = P * abt / (P.sum(0, k...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def l1(P, q):\n\n m, n = P.size\n\n # Solve equivalent LP \n #\n # minimize [0; 1]' * [u; v]\n # subject to [P, -I; -P, -I] * [u; v] <= [q; -q]\n #\n # maximize -[q; -q]' * z \n # subject to [P', -P']*z = 0\n # [-I, -I]*z + 1 = 0 \n # ...
[ "0.60062426", "0.60009205", "0.5966422", "0.5898558", "0.58854496", "0.58482015", "0.5734522", "0.56935805", "0.5605645", "0.5604729", "0.55998397", "0.55965626", "0.55877346", "0.5570163", "0.5558406", "0.5549005", "0.554849", "0.5545878", "0.5530043", "0.551141", "0.5501329...
0.0
-1
Updates a single entity. Implementers should return a tuple containing two iterables (to_update, to_delete).
def map(self, entity): return ([], [])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def entityUpdates(self, *args):\n\t\tfor entity in self.members.values():\n\t\t\tentity.update(*args)", "def update_entities(self):\n raise NotImplementedError()", "def update_many(\n self,\n *args: Union[dict, Mapping],\n session: Optional[ClientSession] = None\n ) -> UpdateMany...
[ "0.63851154", "0.621751", "0.61388403", "0.6048954", "0.60383564", "0.59614515", "0.5907158", "0.5735908", "0.5735908", "0.5735908", "0.5729625", "0.570714", "0.57034546", "0.56934524", "0.5678083", "0.5675096", "0.5666016", "0.5653511", "0.5618034", "0.56139493", "0.55728024...
0.0
-1
Called when the mapper has finished, to allow for any final work to be done.
def finish(self): logging.info(str(self) + ' Mapper finished.') if self.next_mapper is not None: logging.info(str(self) + ' Next: ' + str(self.next_mapper)) self.next_mapper.run() pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def finished(self):\n pass", "def _finished(self) -> None:", "def finish(self):\n pass", "def finish(self):\n pass", "def finished(self):\n raise NotImplementedError()", "def finished(self):\r\n raise NotImplementedError", "def finished(self):", "def finish(self):\r...
[ "0.6983338", "0.67524016", "0.6732718", "0.6732718", "0.6725664", "0.6718488", "0.6698824", "0.6674772", "0.6650086", "0.65816665", "0.65816665", "0.6573483", "0.6461058", "0.6453406", "0.6439004", "0.6439004", "0.6388175", "0.63703626", "0.6352022", "0.63432056", "0.6340175"...
0.8608334
0
Returns a query over the specified kind, with any appropriate filters applied.
def get_query(self): q = db.Query(self.KIND,keys_only=self.KEYS_ONLY) for prop, value in self.FILTERS: q.filter("%s =" % prop, value) if self.ancestor: q.ancestor(self.ancestor) q.order(self.ORDER_BY) return q
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_query(kind):\n days = 4\n now = datetime.datetime.now()\n earlier = now - datetime.timedelta(days=days)\n\n query = query_pb2.Query()\n query.kind.add().name = kind\n\n datastore_helper.set_property_filter(query.filter, 'created_at',\n PropertyFilter.GREATER_THA...
[ "0.74351525", "0.65386915", "0.6099638", "0.6088493", "0.60041225", "0.5947028", "0.5898798", "0.5851256", "0.5801757", "0.5797533", "0.5785968", "0.57396966", "0.57052547", "0.5698724", "0.56677943", "0.5620565", "0.55979", "0.5590759", "0.558977", "0.5579419", "0.55156595",...
0.60751003
4