query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Check whether 'str' contains ANY of the chars in 'set' | def containsAny(str, set):
return 1 in [c in str for c in set] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def containsAll(str, set):\n return 0 not in [c in str for c in set]",
"def containsAll(str, set):\n return 0 not in [c in str for c in set]",
"def stringContainsAllCharacters(string, characters):\n assert type(string) is str\n assert iter(characters)\n return False not in [character in string f... | [
"0.8711984",
"0.8711984",
"0.7367383",
"0.71409243",
"0.688554",
"0.6795197",
"0.67915064",
"0.6781748",
"0.6717026",
"0.66774803",
"0.66679716",
"0.66580963",
"0.6646333",
"0.663464",
"0.66149026",
"0.64809537",
"0.64582187",
"0.64574534",
"0.63834673",
"0.6349886",
"0.63395... | 0.85994124 | 4 |
This method switches screen for answering selected question. | def on_question_select(self, dt):
self.popup.dismiss()
questions = open("data/questions.fay", "w+")
questions_all = ""
question_id = self.list_quests.adapter.selection[0].text.split(" ")[1]
for key in self.data_all_ids.iterkeys():
if question_id == key.split("*[SEA... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_question(self):\n self.user_answers = []\n self.curent_question = choice(self.to_ask)",
"def question_switch(request, id):\n question = get_object_or_404(Question, pk=id)\n\n # qproposal - endorse part\n categories = Category.objects.filter(name='proposed')\n proposed_cat = cat... | [
"0.64592946",
"0.6262374",
"0.5930208",
"0.59202445",
"0.58245206",
"0.5804689",
"0.57879037",
"0.5774548",
"0.56596786",
"0.5602707",
"0.56022376",
"0.55968744",
"0.55678",
"0.5552816",
"0.55396307",
"0.5536568",
"0.5500813",
"0.5481551",
"0.54706687",
"0.5463495",
"0.545823... | 0.0 | -1 |
Adds expertise to that user on that particular message, and on parent If is_vote, prevents the user from voting twice | def add_expertise(self, user, score, is_vote=False):
if user==None or user.is_anonymous():
return
# If user already has expertise on that message
if self.is_expert(user):
expert = self.expert_set.filter(user=user)[0]
expert.score += score
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def up_vote(cls, user, message):\r\n pass",
"def up_vote(cls, user, message):\n pass",
"def approve_me(message):\n users = hf.get_users()\n for user in users:\n if user[\"id\"] == message._get_user_id():\n if user[\"approval_level\"] == \"unapproved\": # Unknown\n ... | [
"0.5933715",
"0.59034425",
"0.57062197",
"0.55862963",
"0.5535667",
"0.55254495",
"0.54281944",
"0.54217803",
"0.54198277",
"0.5418959",
"0.5356316",
"0.533468",
"0.53296787",
"0.53250575",
"0.5255677",
"0.52351785",
"0.52181774",
"0.52105844",
"0.5192726",
"0.5190838",
"0.51... | 0.71805614 | 0 |
Returns the function f(x) = ax^2 + bx +c | def build_quadratic_function(a,b,c):
return lambda x: a*x**2 + b*x + c | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def func(f,c):\n return(f**2+c)",
"def f(self, x: np.array) -> np.array:\n return self.a * x**2 + self.b * x + self.c",
"def fn(x):\n\n # coefficients\n A = 728.0\n B = 0.317\n C = 0.486\n D = -8.99 * 1.6\n\n # function\n fx = - D / x**2 - A / B * math.exp(- x / B) + 6 * C / x**7... | [
"0.798579",
"0.7714811",
"0.75692666",
"0.75645816",
"0.74564946",
"0.7416912",
"0.7337142",
"0.733002",
"0.7242603",
"0.7236114",
"0.7229654",
"0.72183347",
"0.7217811",
"0.71495736",
"0.7147901",
"0.7134982",
"0.7125325",
"0.7125325",
"0.7124957",
"0.7099208",
"0.7085564",
... | 0.63983256 | 66 |
Returns True if this iterator has no more results. | def done(self):
if self._finished or self._unfinished:
return False
# Clear the 'current' values when iteration is done.
self.current_index = self.current_future = None
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hasNext(self):\n return self.iterator.hasNext()",
"def hasNext(self) -> bool:\n return self.idx < len(self.m) - 1",
"def hasNext(self) -> bool:\n return self.idx < len(self.m) - 1",
"def hasNext(self) -> bool:\n return len(self.list) != 0",
"def has_next(self):\n ... | [
"0.7821844",
"0.7640414",
"0.7640414",
"0.76351017",
"0.7620194",
"0.75854146",
"0.7552501",
"0.75523275",
"0.7546073",
"0.7472873",
"0.7444017",
"0.73761845",
"0.7353032",
"0.7303976",
"0.7282603",
"0.7277675",
"0.7246562",
"0.7224861",
"0.71725786",
"0.7139082",
"0.7132586"... | 0.67624086 | 48 |
Get the height of the board. | def get_grid_height(self):
# replace with your code
return self._grid_height | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def height(self):\n return self.board.shape[0]",
"def getHeight(self):\n return self.height",
"def getHeight(self):\n return self.height",
"def getHeight(self):\n return self._height",
"def get_grid_height(self):\n return self._height",
"def get_grid_height(self):\n ... | [
"0.8506178",
"0.7828281",
"0.7828281",
"0.7792005",
"0.7788401",
"0.7788401",
"0.77683884",
"0.77683884",
"0.77683884",
"0.77683884",
"0.77662206",
"0.7763028",
"0.776071",
"0.77545404",
"0.7742475",
"0.77377915",
"0.7721646",
"0.769687",
"0.76945823",
"0.76945823",
"0.769458... | 0.0 | -1 |
Residual Sum of Squares | def RSS(X,Y,w):
v = Y[:,0]- (np.dot(X,w[1:]) + w[0])
return np.dot(v,v) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ssr(self):\n return (self.resid * self.resid).sum(0)",
"def _compute_residuals(self):\n residuls = self.I - self.E\n return residuls",
"def residuals(self) -> npt.NDArray[np.float64]:\n return self.data - self.theory",
"def _residuals(params: List[float], xs: np.ndarray, ys: n... | [
"0.7235167",
"0.7155512",
"0.7121078",
"0.7121021",
"0.710784",
"0.698279",
"0.6696653",
"0.66806144",
"0.6622361",
"0.6615381",
"0.66066676",
"0.6575129",
"0.6538329",
"0.6524298",
"0.6491339",
"0.6471113",
"0.64214367",
"0.6417203",
"0.6407544",
"0.6407403",
"0.63933295",
... | 0.0 | -1 |
Get basic block upper bound While the current instruction is not referenced from anywhere and the preceding instruction is not referencing anywhere else, step backwards. Return the first address at which the above conditions are no longer true. | def get_basic_block_begin_from_ea( ea ):
oldea = 0
while get_first_fcref_to( ea ) == BADADDR and get_first_fcref_from( get_first_cref_to( ea ) ) == BADADDR and ea != BADADDR:
oldea = ea
ea = get_first_cref_to( ea )
if ea == BADADDR:
return oldea
return ea | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_basic_block_end_from_ea( ea ): \r\n\tlastea = ea\r\n\twhile get_first_fcref_from( ea ) == BADADDR and ea != BADADDR and \\\r\n\t\tget_first_fcref_to( get_first_cref_from(ea) ) == BADADDR:\r\n\t\tlastea = ea\r\n\t\tea = get_first_cref_from( ea )\r\n\tif ea == BADADDR:\r\n\t\treturn lastea\r\n\treturn ea",... | [
"0.67343694",
"0.6626304",
"0.61955315",
"0.6051958",
"0.6016333",
"0.6016333",
"0.59829676",
"0.5966944",
"0.59173936",
"0.5838285",
"0.576008",
"0.5741059",
"0.5741017",
"0.57273793",
"0.57049286",
"0.5651515",
"0.56408674",
"0.5627701",
"0.5619415",
"0.5609546",
"0.5609546... | 0.6002967 | 6 |
Get basic block lower bound The same as get_basic_block_begin_from_ea(), just forwards. | def get_basic_block_end_from_ea( ea ):
lastea = ea
while get_first_fcref_from( ea ) == BADADDR and ea != BADADDR and \
get_first_fcref_to( get_first_cref_from(ea) ) == BADADDR:
lastea = ea
ea = get_first_cref_from( ea )
if ea == BADADDR:
return lastea
return ea | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_basic_block_begin_from_ea( ea ):\r\n\toldea = 0\r\n\twhile get_first_fcref_to( ea ) == BADADDR and get_first_fcref_from( get_first_cref_to( ea ) ) == BADADDR and ea != BADADDR:\r\n\t\toldea = ea\r\n\t\tea = get_first_cref_to( ea )\r\n\tif ea == BADADDR:\r\n\t\treturn oldea\r\n\treturn ea",
"def get_lower... | [
"0.7230071",
"0.6916907",
"0.6916907",
"0.6618858",
"0.66183424",
"0.62876934",
"0.59510756",
"0.59158295",
"0.59154725",
"0.58694553",
"0.57809335",
"0.5770137",
"0.5758265",
"0.5752834",
"0.5729101",
"0.56824875",
"0.56386894",
"0.5625911",
"0.56021315",
"0.5600602",
"0.558... | 0.6097801 | 6 |
Pad a string with chars on the right until it reaches a certain width Useful for aligning columns in console outputs. | def right_pad(message, pad_to=20, pad_with=' '):
message = str(message)
while len(message) < pad_to:
message = message + pad_with
return message | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _padright(width, s):\n fmt = \"{0:<%ds}\" % width\n return fmt.format(s)",
"def r_pad(arg, length):\n if length <= len(arg):\n return arg\n else:\n return arg + \" \" * (length - len(arg))",
"def rightpad(field, length):\r\n field = str(field)\r\n field_length = len(field)\r... | [
"0.8034596",
"0.7423374",
"0.72077507",
"0.7183193",
"0.71716905",
"0.69505227",
"0.6950405",
"0.6922684",
"0.68264174",
"0.67449063",
"0.67058015",
"0.66520536",
"0.66440463",
"0.6621518",
"0.6609157",
"0.65422994",
"0.6541979",
"0.6538457",
"0.6538457",
"0.6538457",
"0.6538... | 0.7439632 | 1 |
Formats a datetime object for use in HTTP headers. >>> import datetime >>> httpdate(datetime.datetime(1970, 1, 1, 1, 1, 1)) | def httpdate(date_obj):
return date_obj.strftime("%a, %d %b %Y %H:%M:%S GMT") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def httpdate(dt):\n weekday = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\", \"Sun\"][dt.weekday()]\n month = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\",\n \"Oct\", \"Nov\", \"Dec\"][dt.month - 1]\n return \"%s, %02d %s %04d %02d:%02d:%02d GMT\" % ... | [
"0.765246",
"0.75625944",
"0.7507938",
"0.72609115",
"0.72609115",
"0.7104092",
"0.6912582",
"0.68527716",
"0.663588",
"0.66126496",
"0.65928483",
"0.64821714",
"0.6464707",
"0.642708",
"0.6350752",
"0.6286007",
"0.62321824",
"0.6223939",
"0.6202698",
"0.6200877",
"0.6178946"... | 0.8169875 | 0 |
Load an image and convert to pytorch channels last tensor format. | def load_image(image_path):
img_transforms = get_standard_img_transforms()
image = Image.open(image_path)
images = img_transforms(image).unsqueeze(0)
return images | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_image(self, id_: str) -> Tensor:\n filename = os.path.join(self.root, \"output\", id_ + \".jpg\")\n with Image.open(filename) as img:\n array = np.array(img)\n tensor: Tensor = torch.from_numpy(array) # type: ignore[attr-defined]\n # Convert from HxWxC to C... | [
"0.7417594",
"0.7170793",
"0.67669946",
"0.66797113",
"0.6616173",
"0.6588416",
"0.6528917",
"0.6469931",
"0.64220494",
"0.6340824",
"0.63385403",
"0.628088",
"0.6256944",
"0.6238576",
"0.6209687",
"0.6209466",
"0.61713314",
"0.61689484",
"0.615313",
"0.6144948",
"0.61357075"... | 0.5699907 | 54 |
Returns the MQTT topic for Event emissions. | def build_event_topic(self, thing, event):
return "{}/event/{}/{}".format(
self.servient_id,
thing.url_name,
event.url_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_topic(self) -> str:\n\t\treturn os.getenv('MQTT_DRIVEN_TOPIC', 'app/event')",
"def __get_topic(self) -> str:\n\t\treturn os.getenv('MQTT_DRIVER_TOPIC', 'app/book/#')",
"def topic(self):\n return self.config.get('topic', f'{NAMESPACE}/{self.id}')",
"def get_topic(self):\n return self.t... | [
"0.81358963",
"0.7041271",
"0.69020903",
"0.67607504",
"0.6704191",
"0.661064",
"0.654145",
"0.6377663",
"0.63426167",
"0.6294223",
"0.6236447",
"0.60440487",
"0.60071784",
"0.59327537",
"0.5927437",
"0.58913857",
"0.5825069",
"0.57017314",
"0.56514937",
"0.5579907",
"0.55780... | 0.6704718 | 4 |
Destroys the MQTT handler. Called when the MQTT runner stops. | def teardown(self):
self._periodic_refresh_subs.stop()
self._interaction_subscriber.dispose()
yield None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __del__(self):\n AppHelper.stopEventLoop()",
"def __del__(self):\n AppHelper.stopEventLoop()",
"def __del__(self):\n self.motorStop()\n GPIO.cleanup()",
"def shutdown():\n global handler, transport, protocol\n if handler is not None:\n handler.close()\n ... | [
"0.7034109",
"0.7034109",
"0.69749033",
"0.69600254",
"0.6922832",
"0.68801606",
"0.68440485",
"0.68403196",
"0.68278986",
"0.6819401",
"0.6815878",
"0.681255",
"0.67497796",
"0.6739412",
"0.6700779",
"0.6693081",
"0.66596705",
"0.6633798",
"0.66300607",
"0.6616381",
"0.66024... | 0.0 | -1 |
Expire a HIT that is no longer needed as Mechanical Turk service The effect is identical to the HIT expiring on its own. The HIT no longer appears on the Mechanical Turk web site, and no new Workers are allowed to accept the HIT. Workers who have accepted the HIT prior to expiration are allowed to complete it or return... | def expire(self):
if not self.has_connection():
self.generate_connection()
self.connection.expire_hit(self.mturk_id)
self.update() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expire_hit(self, hit_id):\r\n params = {'HITId' : hit_id,}\r\n return self._process_request('ForceExpireHIT', params)",
"def expire(hit_id, app, sandbox, exit=True):\n if (hit_id and app) or not (hit_id or app):\n raise click.BadParameter(\"Must specify --hit_id or --app, but not both... | [
"0.73888403",
"0.67620504",
"0.60273427",
"0.5957056",
"0.5877826",
"0.5856536",
"0.57681644",
"0.5708138",
"0.56894314",
"0.5677497",
"0.56699806",
"0.5601099",
"0.5578133",
"0.5560449",
"0.5525884",
"0.5523473",
"0.5512716",
"0.54293454",
"0.5421103",
"0.54023373",
"0.53911... | 0.6965314 | 1 |
Increase the maximum assignments or extend the expiration date Increase the maximum number of assignments, or extend the expiration date, of an existing HIT. | def extend(self, assignments_increment=None, expiration_increment=None):
self.connection.extend_hit(self.mturk_id,
assignments_increment=assignments_increment,
expiration_increment=expiration_increment)
self.update() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extend_hit(self, hit_id, assignments_increment=None, expiration_increment=None):\r\n # must provide assignment *or* expiration increment\r\n if (assignments_increment is None and expiration_increment is None) or \\\r\n (assignments_increment is not None and expiration_increment is not N... | [
"0.67988765",
"0.6200029",
"0.5546698",
"0.5539892",
"0.5539188",
"0.5480833",
"0.5466556",
"0.53643614",
"0.52725226",
"0.5268507",
"0.5262331",
"0.52576584",
"0.5212357",
"0.51508516",
"0.51216614",
"0.5109937",
"0.51096165",
"0.5093978",
"0.50939673",
"0.5092095",
"0.50706... | 0.67035836 | 1 |
Returns a list of vectors for all spectra | def calculate_vectors(self, spectrum_list: List[Spectrum]) -> np.ndarray:
n_rows = len(spectrum_list)
reference_vectors = np.empty(
(n_rows, self.output_vector_dim), dtype="float")
binned_spectrums = self.model.spectrum_binner.transform(spectrum_list, progress_bar=self.progress_bar)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_all_spectra(self):\n pass",
"def all_spectra(self) -> List[Spectrum]:\n all_spec = []\n for ann_i in range(self._num_ann):\n # If there is only one spectrum per annulus then get_spectra will just return an object\n ann_spec = self.get_spectra(ann_i)\n ... | [
"0.6906286",
"0.66665363",
"0.6338239",
"0.62906414",
"0.621119",
"0.6174408",
"0.5907404",
"0.58785576",
"0.585899",
"0.58556795",
"0.5851686",
"0.58397555",
"0.5811974",
"0.57129216",
"0.57088685",
"0.5696138",
"0.5687967",
"0.56719315",
"0.5616514",
"0.5604283",
"0.5601074... | 0.60239637 | 6 |
Check if input_string has numbers (09) | def __has_numbers(self, input_string):
return bool(re.search(r'\d', input_string)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hasNumbers(inputString):\n return any(char.isdigit() for char in inputString)",
"def is_number(c):\n return '0' <= c <= '9'",
"def isNumber(string):\r\n for char in string:\r\n charNum = ord(char)\r\n if (charNum < 48 or charNum > 57):\r\n return False\r\n return True",... | [
"0.78693485",
"0.7792281",
"0.7667592",
"0.765685",
"0.745634",
"0.72987586",
"0.7284375",
"0.72187203",
"0.71772075",
"0.7174273",
"0.7107795",
"0.7098636",
"0.70972335",
"0.70786554",
"0.70640105",
"0.7035809",
"0.7012435",
"0.6998527",
"0.69772154",
"0.69650745",
"0.696170... | 0.8178898 | 0 |
() > list(list) Generates list of lists of letters i.e. grid for the game. e.g. [['I', 'G', 'E'], ['P', 'I', 'S'], ['W', 'M', 'G']] | def generate_grid():
field = []
three_lst = []
for three_let in range(0, 3):
three_lst = []
for i in range(0, 3):
three_lst.append(chr(random.randint(97, 122)))
field.append(three_lst)
return field | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_grid() -> List[List[str]]:\r\n list_of_game_letters = []\r\n timed_list = []\r\n letters = [j for j in string.ascii_lowercase]\r\n for i in range(9):\r\n timed_list.append(random.choice(letters))\r\n if len(timed_list) == 3:\r\n list_of_game_letters.append(timed_li... | [
"0.8358331",
"0.75958323",
"0.7299012",
"0.7179665",
"0.6904408",
"0.6904408",
"0.6904408",
"0.67994016",
"0.67682165",
"0.67508966",
"0.67276686",
"0.66574097",
"0.6552938",
"0.64899373",
"0.64783424",
"0.64290637",
"0.63799095",
"0.63615215",
"0.63558877",
"0.6332286",
"0.6... | 0.7486779 | 2 |
Get or create XDG_DATA_DIRS variable. | def Retrieve_XdgDataDir():
xdg_datadir_var = os.environ.get('XDG_DATA_DIRS')
if not xdg_datadir_var:
xdg_datadir_var = "/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop"
xdg_datadir_var = xdg_datadir_var.split(":")
return xdg_datadir_var | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def platform_data_dir():\n if POSIX: # nocover\n dpath_ = os.environ.get('XDG_DATA_HOME', '~/.local/share')\n elif DARWIN: # nocover\n dpath_ = '~/Library/Application Support'\n elif WIN32: # nocover\n dpath_ = os.environ.get('APPDATA', '~/AppData/Roaming')\n else: # nocover\n... | [
"0.7285555",
"0.6858856",
"0.6786311",
"0.6683764",
"0.66236645",
"0.6618925",
"0.654857",
"0.6534069",
"0.65216947",
"0.6518759",
"0.649531",
"0.64408904",
"0.64382267",
"0.6434149",
"0.64198464",
"0.63425946",
"0.6329387",
"0.63153696",
"0.630991",
"0.629416",
"0.6217162",
... | 0.7790974 | 0 |
Return either the basename of the desktop file searched, or None. | def LocateDesktopFileName(desktop_search_term: str):
desktop_basename = None
desktoplist = LocateDesktopFile(desktop_search_term)
if len(desktoplist) >= 1:
desktop_basename = os.path.basename(desktoplist[0])
return desktop_basename | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def basename(self):\n return self._getbyspec(\"basename\")[0]",
"def basename(source_file) :\n if source_file is not None and source_file != '' :\n return os.path.basename(source_file)\n\n return ''",
"def get_file_basename(self):\n return self._basename[:]",
"def get_filename(self... | [
"0.6940074",
"0.6768641",
"0.6749639",
"0.6696546",
"0.6691333",
"0.66817975",
"0.66207606",
"0.6559187",
"0.6506048",
"0.64591706",
"0.64477164",
"0.64382625",
"0.6433794",
"0.64292675",
"0.63686836",
"0.63635755",
"0.63569355",
"0.63371426",
"0.63325",
"0.62984514",
"0.6256... | 0.8068064 | 0 |
Checks test_pw against hashed_pw by hashing with salt and pepper | def check(self, test_pw, hashed_pw, salt):
try:
test_hashed = scrypt.hash(test_pw, salt + self.pepper, buflen=CryptoConsts.HASH_BYTES)
return test_hashed == hashed_pw
except scrypt.error:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __is_correct_password(salt: bytes, pw_hash: bytes, password: str) -> bool:\n return hmac.compare_digest(\n pw_hash, hashlib.pbkdf2_hmac(\"sha256\", password.encode(), salt, 100000)\n )",
"def test_hash_verification(self):\n pw = generate_password(8)\n for hash_method in (ldap_des_c... | [
"0.72166365",
"0.71149665",
"0.7035832",
"0.69561905",
"0.69438624",
"0.69338137",
"0.69102854",
"0.6897812",
"0.6843269",
"0.6811192",
"0.6795696",
"0.67817956",
"0.6676392",
"0.6652329",
"0.6645831",
"0.66264814",
"0.66262907",
"0.66262907",
"0.662007",
"0.662007",
"0.66200... | 0.81604296 | 0 |
Hashes password with random salt and pepper and returns hashed password and salt | def hash(self, password):
try:
salt = self.__get_salt()
except NotImplementedError:
raise CryptoError('Could not encrypt password')
hashed = scrypt.hash(password, salt + self.pepper, buflen=CryptoConsts.HASH_BYTES)
return hashed, salt | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _pepper_hash(pepper, password, salt):\n return '{:0>8}{:s}{:s}'.format(pepper, password, salt)",
"def hash_password(self, password):\n salt = hashlib.sha256(os.urandom(60)).hexdigest().encode('ascii')\n pwdhash = hashlib.pbkdf2_hmac('sha256', password.encode('utf-8'), \n ... | [
"0.7718126",
"0.76193047",
"0.74522865",
"0.74418753",
"0.7384774",
"0.7351287",
"0.734831",
"0.7345207",
"0.7279459",
"0.72683376",
"0.72653306",
"0.72653306",
"0.72653306",
"0.7221512",
"0.7199817",
"0.7199768",
"0.7182793",
"0.71658087",
"0.71658087",
"0.71223",
"0.711486"... | 0.6872143 | 30 |
Returns a list of TNT tokens. | def get_tokens_unprocessed(self, text):
self.cur = []
start = end = self.whitespace(0, text)
while start <= end < len(text):
try:
# try line number
while text[end] in self.NUMBERS:
end += 1
if end != start: # actual... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tokens(self) -> List[str]:\n return self.tokens",
"def tokens(self):\n # type: () -> List[Token]\n return self._tokens",
"def get_tokens(self):\r\n return TokenGroup.get_tokens(self._tu, self.extent)",
"def getTokens(self):\n list = []\n for i in range(self.startIdx,... | [
"0.7910274",
"0.7680641",
"0.7627312",
"0.7621838",
"0.7570274",
"0.73945796",
"0.73422265",
"0.73422265",
"0.73422265",
"0.73297286",
"0.728324",
"0.72673774",
"0.71462727",
"0.7144849",
"0.71131057",
"0.7055251",
"0.7053643",
"0.7011309",
"0.69980854",
"0.69764787",
"0.6956... | 0.0 | -1 |
Returns the minimax action using self.depth and self.evaluationFunction | def getAction(self, gameState):
"*** YOUR CODE HERE ***"
best_result = self.getaplhabeta(gameState, 0, 0, gameState.getNumAgents(), -float('inf'), float('inf'))
return best_result[0] # return the result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAction(self, gameState: GameState):\n _max = float(\"-inf\")\n action = None\n for move in gameState.getLegalActions(0):\n util = minimax(self.evaluationFunction, 1, 0,\n gameState.generateSuccessor(0, move), self.depth)\n if util > _max o... | [
"0.748417",
"0.73825383",
"0.71819884",
"0.71099836",
"0.70880735",
"0.7069946",
"0.70674497",
"0.70488465",
"0.7005658",
"0.69661313",
"0.6964615",
"0.69616",
"0.69460255",
"0.69012016",
"0.68966156",
"0.68859357",
"0.6827233",
"0.6767046",
"0.67576903",
"0.6753057",
"0.6707... | 0.0 | -1 |
Tests response with bad server IP address. | def test_udp_bad_server():
assert dnsck_query("8.8.8.88", "google.com", "A", 1) == 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_functional_bad_ip(self, url):\n response = requests.get(\"http://localhost:80/ip2w/{url}\".format(url=url))\n self.assertEqual(response.status_code, BAD_REQUEST)\n self.assertEqual(response.json().get(\"error\"),\n \"No city for ip {}\".format(url))",
"def te... | [
"0.76076627",
"0.71319216",
"0.6826325",
"0.6786383",
"0.67786354",
"0.6754177",
"0.6739915",
"0.659795",
"0.65934277",
"0.6572452",
"0.6525295",
"0.6508231",
"0.6501905",
"0.6364203",
"0.6331205",
"0.6315787",
"0.6292695",
"0.62595594",
"0.6241883",
"0.62227",
"0.62223107",
... | 0.66022646 | 7 |
Tests response with no records returned. | def test_udp_no_records():
assert dnsck_query("8.8.8.8", "test.google.com", "A", 1) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_nil_results(self):\n class Test(pyperry.Base):\n def _config(cls):\n cls.attributes('id')\n cls.configure('read', adapter=TestAdapter)\n TestAdapter.data = None\n TestAdapter.count = 3\n result = Test.fetch_records(Test.scoped())\n ... | [
"0.75205636",
"0.73410344",
"0.73410344",
"0.73111796",
"0.73111796",
"0.73111796",
"0.7242733",
"0.71973634",
"0.71928376",
"0.71866465",
"0.7156628",
"0.7121017",
"0.7041776",
"0.702241",
"0.6965808",
"0.6947232",
"0.68928164",
"0.68811977",
"0.6857614",
"0.68428886",
"0.68... | 0.0 | -1 |
Returns the project folder or the parent folder of the active view | def get_project_path(window: 'Any') -> 'Optional[str]':
if not window:
return None
num_folders = len(window.folders())
if num_folders == 0:
return get_directory_name(window.active_view())
elif num_folders == 1:
folder_paths = window.folders()
return folder_paths[0]
el... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project_path(cur_path=''):\n if not cur_path:\n cur_path = __file__\n real_path = os.path.realpath(cur_path)\n # path of upper-level directory\n upper_folder = os.path.split(real_path)[0]\n # path of topmost-level directory (trunk)\n return os.path.split(upper_folder)[0]",
"def get_c... | [
"0.7095011",
"0.68499935",
"0.6816204",
"0.67651856",
"0.6724891",
"0.6724891",
"0.6715892",
"0.67155415",
"0.6657905",
"0.6657905",
"0.6657905",
"0.6657905",
"0.6628177",
"0.6616974",
"0.6603293",
"0.6594085",
"0.6530523",
"0.65279615",
"0.6524974",
"0.65084684",
"0.65071964... | 0.74819803 | 0 |
Check all items of an iterable are the same value | def check_all_iterable_values_equal(iterable):
return all(second_value_onwards == iterable[0] for second_value_onwards in iterable[1:]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_equal(iterator):\n\n iterator = iter(iterator)\n\n try:\n first = next(iterator)\n except StopIteration:\n return True\n\n return all(first == rest for rest in iterator)",
"def all_same(items):\n \n return all(x == items[0] for x in items)",
"def equal(iterator):\n tr... | [
"0.7660191",
"0.76364774",
"0.7235359",
"0.7209357",
"0.7203459",
"0.7108601",
"0.7001102",
"0.6897473",
"0.68842685",
"0.6739659",
"0.6705989",
"0.6641368",
"0.6484102",
"0.64598346",
"0.64598346",
"0.6426111",
"0.63812107",
"0.62567884",
"0.6251753",
"0.6248722",
"0.6238555... | 0.8052813 | 0 |
Returns true if it is a valid action to reequip that item. | def can_act(self, **kwargs):
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_repairing(self) -> bool:\n return self.orders and self.orders[0].ability.id in {\n AbilityId.EFFECT_REPAIR,\n AbilityId.EFFECT_REPAIR_MULE,\n AbilityId.EFFECT_REPAIR_SCV,\n }",
"def _apply_item(self, item: Item) -> bool:\n if self.locked:\n ... | [
"0.6134925",
"0.60804397",
"0.5987494",
"0.59725565",
"0.5968461",
"0.5948763",
"0.5942145",
"0.59217536",
"0.5881622",
"0.57628304",
"0.57485163",
"0.571618",
"0.57155275",
"0.569826",
"0.5599213",
"0.5599213",
"0.55711675",
"0.5559889",
"0.55313087",
"0.5521899",
"0.550376"... | 0.0 | -1 |
Refreshes CRC for the provided webhook_id. | def refresh(self, webhook_id: str) -> NoReturn:
try:
return self.api(
method="PUT",
endpoint=f"all/{config('TWITTER_ENV_NAME')}/webhooks/{webhook_id}.json",
)
except Exception as e:
raise e | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cli_jira_webhook_get(ctx, webhook_id):\n jira_webhook_path = \"rest/webhooks/1.0/webhook\"\n _url = jira_webhook_path\n\n if webhook_id:\n _url = f'{jira_webhook_path}/{webhook_id}'\n\n _res = ctx.obj['connect'].get(_url, headers=json_headers, auth=True)\n ctx.obj['writer'].out(_res)",
... | [
"0.5000307",
"0.48283345",
"0.4828133",
"0.47760397",
"0.47652534",
"0.4718564",
"0.4676473",
"0.46459606",
"0.46219504",
"0.4611461",
"0.4598001",
"0.45559764",
"0.45559",
"0.45447248",
"0.45348197",
"0.4529725",
"0.45228475",
"0.4521242",
"0.4494904",
"0.44897926",
"0.44865... | 0.6843676 | 0 |
Removes the webhook from the provided webhook_id. | def delete (self, webhook_id: str) -> NoReturn:
try:
return self.api(
method="DELETE",
endpoint=f"all/{config('TWITTER_ENV_NAME')}/webhooks/{webhook_id}.json",
)
except Exception as e:
raise e | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cli_jira_webhook_delete(ctx, webhook_id):\n jira_webhook_path = \"rest/webhooks/1.0/webhook\"\n _url = f'{jira_webhook_path}/{webhook_id}'\n _res = ctx.obj['connect'].delete(_url, headers=json_headers, auth=True)\n ctx.obj['writer'].out(_res)",
"async def delete_webhook(self, webhook: 'dt_webhook... | [
"0.7884652",
"0.78361064",
"0.76614076",
"0.72193515",
"0.6598278",
"0.6510675",
"0.6288968",
"0.6273562",
"0.61018556",
"0.5963745",
"0.5945888",
"0.57889354",
"0.5671626",
"0.5646223",
"0.56198144",
"0.56072354",
"0.55956864",
"0.5434203",
"0.53965855",
"0.5386136",
"0.5352... | 0.8084425 | 0 |
Returns all environments, webhook URLs and their statuses for the authenticating app. Only one webhook URL can be registered to each environment. | def webhooks(self) -> json:
try:
return self.api(method="GET", endpoint=f"all/webhooks.json").json()
except Exception as e:
raise e | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_environments():\n return ENVIRONMENTS",
"def getEnvironments(request):\n environments = Environment.objects.all()\n serializer = environmentSerializer(environments, many=True)\n result = {'data':serializer.data, 'code':HTTP_200_OK, 'message':OK}\n return result",
"def... | [
"0.6255304",
"0.60560155",
"0.5968811",
"0.5822635",
"0.57663",
"0.57403696",
"0.5686505",
"0.56520015",
"0.5622789",
"0.56082916",
"0.5606459",
"0.56004304",
"0.5580336",
"0.557331",
"0.54874176",
"0.5486982",
"0.5450403",
"0.54223406",
"0.54159874",
"0.53968626",
"0.5375746... | 0.5764198 | 5 |
Return all layer data from tree. | def getAllLayers(self):
layersData = []
for row in range(self.jobRow.rowCount()):
nameItem = self.jobRow.child(row, 0)
data = nameItem.data(QtCore.Qt.UserRole)
layersData.append(data)
return layersData | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data(self):\n return self.topo_data_flattened",
"def tree_features(self):\n return self._tree_features",
"def getAllLayers(self):\n jobItem = self.item(0, 0)\n layerObjects = [jobItem.child(row, 0).data(QtCore.Qt.UserRole)\n for row in range(jobItem.ro... | [
"0.64070916",
"0.6099374",
"0.6071615",
"0.60311484",
"0.59554577",
"0.59361345",
"0.5935082",
"0.5913461",
"0.5883158",
"0.5872937",
"0.58630455",
"0.58412176",
"0.58293605",
"0.5822033",
"0.5798815",
"0.57886815",
"0.5781587",
"0.5777497",
"0.5764594",
"0.5757519",
"0.57160... | 0.5712192 | 21 |
Return the current selected row number. | def getCurrentRow(self):
item = self.getSelectedItem()
if item:
return item.row()
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_row(self):\n return self._row_number",
"def get_selected_index(self) -> int:\n return self._selected_index",
"def getSelectedRow(self):\n return self.__selectedRow",
"def currentRow(self):\n for item in self.__service_list.selectedItems():\n return self.__servic... | [
"0.7755324",
"0.7671941",
"0.7566818",
"0.747371",
"0.73814875",
"0.73799634",
"0.7239083",
"0.7223376",
"0.70235175",
"0.6895296",
"0.6869162",
"0.68690175",
"0.68690175",
"0.68690175",
"0.68690175",
"0.68690175",
"0.68690175",
"0.68690175",
"0.68690175",
"0.68690175",
"0.68... | 0.7472518 | 4 |
Return the layer that the current layer depends on. | def getDependOnItem(self):
currentRow = self.getCurrentRow()
if currentRow == 0:
return None
return self.jobRow.child(currentRow - 1, 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dependOnLayer(self):\n return self.data.depend_on_layer",
"def dependErLayer(self):\n return self.data.depend_er_layer",
"def layer(self):\n return self.GetLayer()",
"def get_penultimate_layer(self):\n return self.model.outputs[1]",
"def layer( self ):\n return self._... | [
"0.79801315",
"0.7762125",
"0.7127272",
"0.7068335",
"0.7007939",
"0.70032096",
"0.6604535",
"0.6562773",
"0.6441851",
"0.64118665",
"0.6404417",
"0.63283217",
"0.63095295",
"0.62923926",
"0.6187002",
"0.61800086",
"0.61701334",
"0.61561537",
"0.61003125",
"0.6021268",
"0.597... | 0.0 | -1 |
Return the layer objects for all layers in the model | def getAllLayers(self):
jobItem = self.item(0, 0)
layerObjects = [jobItem.child(row, 0).data(QtCore.Qt.UserRole)
for row in range(jobItem.rowCount())]
return layerObjects | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_layers(model):\n layers = []\n for l in model.layers:\n if hasattr(l, 'layers'):\n layers += get_all_layers(l)\n else:\n layers.append(l)\n return layers",
"def get_layers(model):\n layers = []\n for child in model.children():\n layer_name = c... | [
"0.80876344",
"0.7550395",
"0.7415417",
"0.7091392",
"0.70693886",
"0.70092016",
"0.6915218",
"0.68889827",
"0.68593556",
"0.68568796",
"0.6835731",
"0.6830545",
"0.6675618",
"0.6672889",
"0.66687816",
"0.6654914",
"0.6646962",
"0.66440624",
"0.66258174",
"0.6537873",
"0.6508... | 0.7304424 | 3 |
Prepare image for inputting to the neural network. Returns a Variable | def prep_image(img, inp_dim):
orig_im = img
dim = orig_im.shape[1], orig_im.shape[0]
img = (letterbox_image(orig_im, (inp_dim, inp_dim)))
img_ = img[:,:,::-1].transpose((2,0,1)).copy()
img_ = torch.from_numpy(img_).float().div(255.0).unsqueeze(0)
return img_, orig_im, dim | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess(self, img):\n img_ = image.load_img(img, target_size=(299, 299))\n img_ = image.img_to_array(img_)\n img_ = np.expand_dims(img_, axis=0)\n img_ = preprocess_input(img_)\n return img_",
"def recreate_image(im_as_var):\n recreated_im = im_as_var.data.numpy()[0]\... | [
"0.6292989",
"0.6213266",
"0.62102914",
"0.61979645",
"0.61689955",
"0.61648303",
"0.6141449",
"0.61282605",
"0.61204344",
"0.6115377",
"0.6114955",
"0.61023825",
"0.60957295",
"0.60832125",
"0.60818315",
"0.60212433",
"0.60140944",
"0.599777",
"0.59675115",
"0.59660816",
"0.... | 0.0 | -1 |
Returns the IoU of two bounding boxes | def bbox_iou(box1, box2):
#Get the coordinates of bounding boxes
b1_x1, b1_y1, b1_x2, b1_y2 = box1[:,0], box1[:,1], box1[:,2], box1[:,3]
b2_x1, b2_y1, b2_x2, b2_y2 = box2[:,0], box2[:,1], box2[:,2], box2[:,3]
#get the corrdinates of the intersection rectangle
inter_rect_x1 = torch.max(b1_x1, b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_iou(bbox1, bbox2):\n area_1 = (bbox1[2] - bbox1[0] + 1) * (bbox1[3] - bbox1[1])\n area_2 = (bbox2[2] - bbox2[0] + 1) * (bbox2[3] - bbox2[1])\n\n inter_x1 = torch.max(torch.cat([bbox1.new([bbox1[0]]), bbox1.new([bbox2[0]])]))\n inter_x2 = torch.max(torch.cat([bbox1.new([bbox1[1]]), bbox1.new([b... | [
"0.7981629",
"0.7917817",
"0.79110086",
"0.7904408",
"0.782365",
"0.782365",
"0.7802457",
"0.77283657",
"0.77097446",
"0.76958805",
"0.76529616",
"0.765062",
"0.7631885",
"0.7614024",
"0.7553006",
"0.75387645",
"0.7537067",
"0.7530325",
"0.7528009",
"0.75036454",
"0.7502786",... | 0.72410554 | 35 |
Sets the guest of this V1beta1MemoryInstancetype. Required amount of memory which is visible inside the guest OS. | def guest(self, guest):
if guest is None:
raise ValueError("Invalid value for `guest`, must not be `None`")
self._guest = guest | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def submit_vserver_memory(vs_host, type_instance, value):\n submit_generic(vs_host, 'memory', 'vs_memory', value, type_instance)",
"def memory(self, memory):\n\n self._memory = memory",
"def is_guest(self, is_guest):\n\n self._is_guest = is_guest",
"def memory(self, memory_mb):\n\n co... | [
"0.61686337",
"0.58067524",
"0.5718511",
"0.5637002",
"0.56244624",
"0.56232625",
"0.5596183",
"0.5562346",
"0.5464245",
"0.54549855",
"0.5428118",
"0.5422613",
"0.53817725",
"0.5370721",
"0.534583",
"0.5321532",
"0.5310287",
"0.52537054",
"0.52530795",
"0.5230804",
"0.520141... | 0.6711113 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, V1beta1MemoryInstancetype):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Create an ExportConfig instance. | def create(self, validated_data):
return ExportConfig.objects.create(**validated_data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_export_policy():\n config = {\n \"export\": {\n \"tenant\": \"intersite-testsuite\",\n \"app\": \"app\",\n \"epg\": \"epg\",\n \"remote_epg\": \"intersite-testsuite-app-epg\",\n \"remote_sites\": [\n ... | [
"0.66310173",
"0.64067394",
"0.6041121",
"0.6041121",
"0.59686893",
"0.59456503",
"0.58888835",
"0.58058923",
"0.57762325",
"0.55834943",
"0.5475853",
"0.5471979",
"0.54518896",
"0.5407002",
"0.5350441",
"0.5306321",
"0.5300995",
"0.5289416",
"0.5249605",
"0.51701593",
"0.516... | 0.7162129 | 0 |
Update an ExportConfig instance. | def update(self, instance, validated_data):
instance.config_type = validated_data.get('config_type', instance.config_type)
instance.upload.delete(False) # delete the old file..
instance.upload = validated_data.get('upload', instance.upload)
instance.name = validated_data.get('name', ins... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self):\n self.save_config_file()",
"def update(self, enabled=None, cnames=None, comment=None):\r\n new_config = DistributionConfig(self.connection, self.config.origin,\r\n self.config.enabled, self.config.caller_reference,\r\n ... | [
"0.60661274",
"0.5922461",
"0.5864707",
"0.5801853",
"0.57641125",
"0.5760607",
"0.575042",
"0.5748401",
"0.5725301",
"0.57073516",
"0.5639941",
"0.5611013",
"0.5597492",
"0.5581104",
"0.5458199",
"0.5431198",
"0.5417182",
"0.5406054",
"0.539331",
"0.53769153",
"0.5365302",
... | 0.0 | -1 |
Serialize the ExportTaskResult for this ExportTask. | def get_result(self, obj):
try:
result = obj.result
serializer = ExportTaskResultSerializer(result, many=False, context=self.context)
return serializer.data
except ExportTaskResult.DoesNotExist as e:
return None # no result yet | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export(self):\n \n return self._export",
"def serialize(self, to_file=None):\n if to_file is not None:\n raise ValueError(\n \"TaskInfo does not support serialization to a custom filename\")\n\n to_file = self.filename\n gitrepo.write_task(to_file,... | [
"0.6364193",
"0.60341316",
"0.59629804",
"0.593558",
"0.5804653",
"0.57993054",
"0.5726449",
"0.5689695",
"0.5681064",
"0.5556878",
"0.55507904",
"0.55227196",
"0.5491642",
"0.54729706",
"0.54477024",
"0.5433362",
"0.5432514",
"0.54296094",
"0.54195774",
"0.5389487",
"0.53834... | 0.66260934 | 0 |
Get the duration for this ExportTask. | def get_duration(self, obj):
started = obj.started_at
finished = obj.finished_at
if started and finished:
return str(finished - started)
else:
return None # can't compute yet | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_duration(self):\n return self._duration",
"def get_duration(self):\n return self.duration",
"def duration(self):\n return self._get('duration')",
"def duration(self):\n return self._get(\"duration\")",
"def duration(self):\n return self._duration",
"def duration... | [
"0.7562647",
"0.7476767",
"0.7316154",
"0.7300918",
"0.72792083",
"0.72792083",
"0.72792083",
"0.72792083",
"0.72792083",
"0.72792083",
"0.72792083",
"0.72792083",
"0.7235028",
"0.7229848",
"0.71430486",
"0.7053289",
"0.7053289",
"0.70263445",
"0.6974633",
"0.69082063",
"0.68... | 0.61072195 | 80 |
Return the Job's extent as a GeoJSON Feature. | def get_extent(self, obj):
uid = str(obj.uid)
name = obj.name
geom = obj.the_geom
geometry = json.loads(GEOSGeometry(geom).geojson)
feature = OrderedDict()
feature['type'] = 'Feature'
feature['properties'] = {'uid': uid, 'name': name}
feature['geometry'] =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_geojson(self):\n return _property_op(arctern.ST_AsGeoJSON, self)",
"def get_geographic_extent(self, project):\n if project.geographic_extent is not None:\n return json.loads(project.geographic_extent.json)\n else:\n return None",
"def data_geojson(self):\n ... | [
"0.69524235",
"0.6892024",
"0.6620965",
"0.6495442",
"0.63587207",
"0.6079808",
"0.5945006",
"0.5918523",
"0.59057796",
"0.5886193",
"0.588251",
"0.5880496",
"0.58792853",
"0.58447474",
"0.5842417",
"0.58413804",
"0.58261836",
"0.5790566",
"0.57550496",
"0.57550496",
"0.57155... | 0.73056036 | 1 |
Return the duration of the the run. | def get_duration(self, obj):
started = obj.started_at
finished = obj.finished_at
if started and finished:
return str(finished - started)
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_duration(self) -> 'outputs.DurationResponse':\n return pulumi.get(self, \"run_duration\")",
"def duration( self ):\n return (self.start and time.process_time()-self.start) or 0",
"def run_duration(self) -> Optional[pulumi.Input['DurationArgs']]:\n return pulumi.get(self, \"run_dura... | [
"0.8417808",
"0.819502",
"0.8045367",
"0.80439633",
"0.80439633",
"0.8023815",
"0.79950726",
"0.79892987",
"0.7961966",
"0.79191387",
"0.7884022",
"0.7841182",
"0.78284746",
"0.77820396",
"0.776649",
"0.77656126",
"0.7761725",
"0.7727792",
"0.7724618",
"0.7723136",
"0.7687307... | 0.6932192 | 91 |
Return the configurations selected for this export. | def get_configurations(self, obj):
configs = obj.configs.all()
serializer = SimpleExportConfigSerializer(configs, many=True,
context={'request': self.context['request']})
return serializer.data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_currently_selected_configuration(self):\n return self.get_container().currently_selected_configuration",
"def configuration_sets(self):\n return self._configuration_sets",
"def component_configurations(self):\n return self._component_configurations",
"def config(self) -> dict:\n ... | [
"0.6853227",
"0.67481124",
"0.6584395",
"0.6536647",
"0.6487592",
"0.6430588",
"0.6407711",
"0.6378201",
"0.6298632",
"0.6283158",
"0.62625074",
"0.62620616",
"0.62464744",
"0.6237522",
"0.62287414",
"0.6196368",
"0.61259055",
"0.6104337",
"0.6104337",
"0.6098201",
"0.6080668... | 0.65374184 | 3 |
Return the Tags selected for this export. | def get_tags(self, obj):
tags = obj.tags.all()
serializer = TagSerializer(tags, many=True)
return serializer.data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tags(self):\n return self.tags",
"def tags(self):\n return self._tags",
"def tags(self):\n return self._tags",
"def tags(self):\n return self._tags",
"def tags(self):\n return self._tags",
"def tags(self):\n return self._tags",
"def tags(self):\n ... | [
"0.73380053",
"0.7302255",
"0.7302255",
"0.7302255",
"0.7302255",
"0.7302255",
"0.7302255",
"0.7302255",
"0.7302255",
"0.729797",
"0.7256367",
"0.71493477",
"0.71424526",
"0.71403897",
"0.7136932",
"0.7114394",
"0.70728105",
"0.7038036",
"0.7030303",
"0.70224565",
"0.69899863... | 0.0 | -1 |
Convert a text in snake_case format into the CamelCase format. | def _to_camel_case(text: str) -> str:
return "".join(word.title() for word in text.split("_")) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snake_to_camel(text: str) -> str:\n\n data = [\n i.capitalize()\n for i in text.split(\"_\")\n ]\n return \"\".join(data)",
"def CamelCase_to_snake_case(text):\n s1 = re.sub('(.)([A-Z][a-z]+)', r'\\1_\\2', text)\n return re.sub('([a-z0-9])([A-Z])', r'\\1_\\2', s1).lower()",
"de... | [
"0.82688236",
"0.79535013",
"0.78673553",
"0.7816046",
"0.7723107",
"0.76516396",
"0.74879974",
"0.7445716",
"0.7413008",
"0.72874415",
"0.7287037",
"0.7273926",
"0.7244735",
"0.7240098",
"0.7217153",
"0.7202608",
"0.72015375",
"0.7186691",
"0.7173794",
"0.7166559",
"0.713114... | 0.7911021 | 2 |
Convert a text in CamelCase format into the snake_case format. | def _camel_case_to_snake_case(text: str) -> str:
return re.sub(r"(?<!^)(?=[A-Z])", "_", text).lower() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CamelCase_to_snake_case(text):\n s1 = re.sub('(.)([A-Z][a-z]+)', r'\\1_\\2', text)\n return re.sub('([a-z0-9])([A-Z])', r'\\1_\\2', s1).lower()",
"def snake_case_text(text):\n newText = format_snake_case(text)\n Text(\"%(text)s\").execute({\"text\": newText})",
"def snake_to_camel(text: str) ->... | [
"0.8534282",
"0.8186557",
"0.7617794",
"0.7427732",
"0.73847556",
"0.73583025",
"0.7327763",
"0.7324695",
"0.7265301",
"0.72585094",
"0.7255463",
"0.7232512",
"0.7178466",
"0.7161547",
"0.71508",
"0.7144487",
"0.7143077",
"0.7120995",
"0.7110461",
"0.7108454",
"0.7090522",
... | 0.8359534 | 1 |
Give the index of the matching close bracket for the opening bracket at 'index_of_open_bracket' in the input 'text'. | def _match_brackets(text: str, index_of_open_bracket: int) -> int:
if text[index_of_open_bracket] != "[":
raise SyntaxError(
"Index {} in 'text' is not an open bracket '['. It is {}".format(
index_of_open_bracket,
text[index_of_open_bracket],
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(self, sub, start=0):\n br = \"([{\"[\")]}\".index(sub)]\n count = 0\n for i in range(start, len(self.string)):\n char = self.string[i]\n if char == br:\n count += 1\n elif char == sub:\n if count > 0:\n ... | [
"0.6649529",
"0.6281053",
"0.6215554",
"0.6131802",
"0.59866416",
"0.59478724",
"0.59153324",
"0.5891129",
"0.5874383",
"0.58268845",
"0.57471514",
"0.5730779",
"0.571721",
"0.5650885",
"0.5629365",
"0.5618481",
"0.5614065",
"0.55302835",
"0.54772687",
"0.54564226",
"0.544269... | 0.83171517 | 0 |
Sets the next node for l. | def addNode(l: ListNode, v: int) -> ListNode:
node = ListNode(v)
l.next = node
return l | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_next(self, node):\r\n self.__next = node",
"def set_next(self, node):\n self.__next = node",
"def setNext(self, nextNode):\n self.__next = nextNode",
"def setNext(self, next_node):\n self.__nextListNode = next_node",
"def set_next(node, value):\n node['next'] ... | [
"0.78329337",
"0.7792042",
"0.7493664",
"0.7270642",
"0.7153497",
"0.7117645",
"0.6965104",
"0.6512356",
"0.6512356",
"0.64304274",
"0.6423388",
"0.61274517",
"0.60913575",
"0.59979755",
"0.59842336",
"0.59781206",
"0.58922493",
"0.5891037",
"0.58782333",
"0.580572",
"0.57131... | 0.57192385 | 20 |
Returns the amount of videos fetched by this query | def count_videos(self):
return len(self.videos) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_video_count(self):\n done = self.cur.execute(\"SELECT video_ID FROM videos\")\n return done",
"def get_total_view_count(self):\n done = self.cur.execute(\"SELECT CAST(SUM(view_count) AS DECIMAL(10, 0)) FROM videos\")\n count = self.cur.fetchone()[0]\n return count",
"... | [
"0.82817036",
"0.7279558",
"0.72771585",
"0.72535306",
"0.714803",
"0.7011779",
"0.6877138",
"0.68436086",
"0.6735827",
"0.67164594",
"0.66826177",
"0.6648064",
"0.6627532",
"0.65684414",
"0.655887",
"0.64775765",
"0.6385982",
"0.6334452",
"0.6326633",
"0.63119364",
"0.630153... | 0.81859946 | 1 |
Creates a vDataFrame of the model. Returns vDataFrame model vDataFrame | def to_vdf(self):
return (vDataFrame(self.name, self.cursor)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def df_model(self):\n return self.Kernel.df(self.xdata)",
"def data_frame_creator(self):\n\n return pd.DataFrame()",
"def create_df(Varr, Iarr, POA, T, mode):\n df = pd.DataFrame()\n df['voltage'] = Varr\n df['current'] = Iarr\n df['E'] = POA\n df['T'] = T\n df['mode'] = mode\n ... | [
"0.67738086",
"0.6715691",
"0.64423925",
"0.64409804",
"0.63185704",
"0.630337",
"0.6296539",
"0.62595004",
"0.6243439",
"0.62352836",
"0.62092257",
"0.6154794",
"0.6150721",
"0.6150721",
"0.6150721",
"0.6150721",
"0.6150721",
"0.61274844",
"0.6120135",
"0.61164004",
"0.60725... | 0.7613239 | 0 |
Drops the model from the Vertica DB. | def drop(self):
drop_model(self.name, self.cursor, print_info = False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model_delete(self, db):\n db.session.delete(self)\n db.session.commit()",
"def drop():\n if prompt_bool(\"Are you sure you want to lose all your data\"):\n db.drop_all()\n db.engine.execute(\"drop table if exists alembic_version\")",
"def drop_db():\n database.db.reflect()... | [
"0.72508526",
"0.69836456",
"0.6917769",
"0.68880904",
"0.6859423",
"0.68522936",
"0.6782825",
"0.6738364",
"0.6720149",
"0.66878045",
"0.66410327",
"0.66410327",
"0.6630014",
"0.6607574",
"0.658283",
"0.65371263",
"0.65319484",
"0.64996743",
"0.6499378",
"0.6499378",
"0.6499... | 0.791849 | 0 |
Testing U rho U^1 with U = X (x) X | def test_paulix():
N = 2
rho = identity(N)
rho = single_qubit_gate(rho, X, 0)
rho = single_qubit_gate(rho, X, 1)
rho = rho.reshape(2 ** N, 2 ** N)
rho_true = np.zeros((2 ** N, 2 ** N), complex)
rho_true[-1, -1] = 1.0
assert np.allclose(rho_true, rho), f"expected `psi_true` to be equal to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Re(self, rho, u, d_p, mu):\n return rho*u*d_p/mu",
"def test_special_U(self):\n self.check_oneq_special_cases(U3Gate(0.0, 0.1, -0.1).to_matrix(), \"U\", {})\n self.check_oneq_special_cases(U3Gate(0.0, 0.1, 0.2).to_matrix(), \"U\", {\"u\": 1})\n self.check_oneq_special_cases(U3... | [
"0.6883748",
"0.6613926",
"0.64293396",
"0.6408487",
"0.6370954",
"0.635602",
"0.6326869",
"0.628096",
"0.6216217",
"0.6176169",
"0.61293894",
"0.6116985",
"0.61113334",
"0.6104179",
"0.60746783",
"0.605196",
"0.60429347",
"0.6040646",
"0.6017491",
"0.60112816",
"0.6009788",
... | 0.679538 | 1 |
Call close on the underlying session. | def close(self):
return self._http.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close(self):\n self.__session.close()",
"def close(self):\n self.__session.close()",
"def close(self):\n self.__session.close()",
"def close(self):\n self.__session.close()",
"def close(self):\n self.__session.close()",
"def close(self):\n self.__session.clos... | [
"0.8460768",
"0.8460768",
"0.8460768",
"0.8460768",
"0.8460768",
"0.8460768",
"0.83304155",
"0.83188426",
"0.81902784",
"0.81829846",
"0.8122222",
"0.79760396",
"0.79480237",
"0.7935393",
"0.7906344",
"0.78558624",
"0.7855407",
"0.7829621",
"0.7822601",
"0.7814396",
"0.780348... | 0.0 | -1 |
Computes the recall metric for N in n_values. | def recallN(order_l, gt_idx_l, n_values):
#print(len(gt_idx_l))
#print(len(order_l))
correct_at_n = np.zeros(len(n_values))
#TODO can we do this on the matrix in one go?
for qIx, pred in enumerate(order_l):
for i,n in enumerate(n_values):
# if in top N then also in top NN, where NN >... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def M_Recall(y_true, y_pred):\n true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))\n possible_positives = K.sum(K.round(K.clip(y_true, 0, 1)))\n recall = true_positives / (possible_positives + K.constant(K.epsilon()))\n return recall",
"def recall(y_true, y_pred):\r\n true_positive... | [
"0.67679703",
"0.6666522",
"0.6666522",
"0.6666522",
"0.6666522",
"0.6666522",
"0.6666522",
"0.6657226",
"0.66538316",
"0.6636632",
"0.6636201",
"0.6628104",
"0.6628104",
"0.6628104",
"0.6628104",
"0.6628104",
"0.6628104",
"0.6628104",
"0.6628104",
"0.6628104",
"0.6628104",
... | 0.682642 | 0 |
Computes the mean Average Precision of this retrieval. | def mAP(rank_l, gt_name_d):
sum_ap = 0. # sum of average precisions
n = 0.
gt = gt_name_d.copy()
# loop over result lines
for query_name, results in parse_results_from_list(rank_l):
#print("\n\nquery_name: %s"%query_name)
if results[0][0] == -1: # failed to match this query
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean_average_precision(rs):\n return np.mean([average_precision(r) for r in rs])",
"def mean_average_precision(rs):\n return np.mean([average_precision(r) for r in rs])",
"def mean_average_precision(rs):\n return np.mean([average_precision(r) for r in rs])",
"def getAverage(self):\n return... | [
"0.77356446",
"0.76956576",
"0.76956576",
"0.73533875",
"0.7322943",
"0.7315561",
"0.73047155",
"0.72829443",
"0.72829443",
"0.72552377",
"0.72427726",
"0.72247875",
"0.7206282",
"0.71933734",
"0.7178057",
"0.7125878",
"0.70863265",
"0.70574194",
"0.7056179",
"0.7056179",
"0.... | 0.0 | -1 |
convert datetime index to epoch int allows for cross language/platform portability | def datetime_to_int64(df):
if isinstance(df.index, pd.DatetimeIndex):
df.index = df.index.astype(np.int64) / 1e9
df.reset_index(inplace=True)
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def epoch(value):\n if isinstance(value, datetime.datetime):\n return int(calendar.timegm(value.timetuple())*1000)\n return '' #fails silently for non-datetime objects",
"def datetime_to_epoch(datetime):\n return datetime.astype('int64') // 1e9",
"def epoch():\n return datetime2epoch(datetim... | [
"0.74467283",
"0.73463136",
"0.71073335",
"0.7090605",
"0.70800143",
"0.70520645",
"0.70520645",
"0.6874138",
"0.67844397",
"0.67308265",
"0.67191845",
"0.66991323",
"0.6639568",
"0.65328664",
"0.64874595",
"0.6374223",
"0.63637894",
"0.6348927",
"0.6335476",
"0.6323622",
"0.... | 0.6112997 | 29 |
Concurrent is a decorator for a function which will cause that function to immediately return when called, but be left running in 'in the background'. It is intended as a functional equivalent to the 'go func()' syntax in the Go programming language. | def concurrent(f):
def err_logger(*args, **kwargs):
'''
err_logger logs uncaught exceptions, which is nice to have in long
running processes in other threads.
'''
try:
f(*args, **kwargs)
except Exception as e:
logging.error(e, exc_info=True)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concurrent(\n func=None, queue=None, unique=False, timeout_seconds=0, expire_seconds=0\n):\n if isinstance(func, str):\n return lambda f: Concurrent(\n func=f,\n dft_queue=func,\n unique=unique,\n timeout_seconds=timeout_seconds,\n expire_seco... | [
"0.66855305",
"0.6305784",
"0.615026",
"0.61239636",
"0.61165196",
"0.6070392",
"0.59549135",
"0.59327644",
"0.5922913",
"0.5895389",
"0.5886202",
"0.58397776",
"0.5832745",
"0.58107203",
"0.58107203",
"0.58107203",
"0.579995",
"0.57952136",
"0.57750887",
"0.57607603",
"0.572... | 0.57854855 | 18 |
Initialization for the Holt Winters Seasonal Models | def _holt_win_init(x, xi, p, y, l, b, s, m):
p[xi.astype(np.bool)] = x
alpha, beta, gamma, l0, b0, phi = p[:6]
s0 = p[6:]
alphac = 1 - alpha
betac = 1 - beta
gammac = 1 - gamma
y_alpha = alpha * y
y_gamma = gamma * y
l[:] = 0
b[:] = 0
s[:] = 0
l[0] = l0
b[0] = b0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, number_of_cheeses, number_of_stools):\n self.model = TOAHModel(number_of_stools)\n self.model.fill_first_stool(number_of_cheeses)",
"def __init__(self, num_of_cheeses, num_of_stools):\n\n self.toah_model = TOAHModel(num_of_stools)\n self.toah_model.fill_first_stool(... | [
"0.6674427",
"0.6565442",
"0.6357141",
"0.6212764",
"0.61915123",
"0.61806047",
"0.6077927",
"0.6011584",
"0.5955769",
"0.58970356",
"0.58589673",
"0.58352125",
"0.58031535",
"0.5782233",
"0.5767847",
"0.5735428",
"0.57306784",
"0.5696844",
"0.5686858",
"0.56805843",
"0.56451... | 0.0 | -1 |
Split a GCS URI into bucket and path. | def split_gcs_uri(gcs_uri):
m = GCS_REGEX.match(gcs_uri)
bucket = m.group(1)
path = ""
if m.group(2):
path = m.group(2).lstrip("/")
return bucket, path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_gcs_uri(gcs_uri):\n m = GCS_REGEX.match(gcs_uri)\n bucket = m.group(1)\n path = \"\"\n if m.group(2):\n path = m.group(2).lstrip(\"/\")\n return bucket, path",
"def get_bucket_and_path_from_uri(path):\n parsed_url = urlparse(path)\n return parsed_url.netloc, parsed_url.path.... | [
"0.8798143",
"0.77190244",
"0.7439958",
"0.7318105",
"0.72443867",
"0.712356",
"0.7051498",
"0.7051498",
"0.67282236",
"0.6610039",
"0.64892966",
"0.64485675",
"0.6280475",
"0.6243666",
"0.6240241",
"0.6154104",
"0.6136296",
"0.60970813",
"0.6002572",
"0.5973932",
"0.5901956"... | 0.8784649 | 1 |
Uniform distribution between min and max | def __init__(self, min: float, max: float):
super().__init__()
# store input parameters
self.min = min
self.max = max | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initializeDistribution(self):\n self.minVal = min(math.exp(self.upperBound),math.exp(self.lowerBound))\n self.maxVal = max(math.exp(self.upperBound),math.exp(self.lowerBound))",
"def _uniform(val_range):\r\n return np.random.uniform(val_range[0], val_range[1])",
"def uniform_dist(low, high):\n ... | [
"0.7134392",
"0.709007",
"0.68898547",
"0.6829375",
"0.6753466",
"0.6744035",
"0.6561126",
"0.65312546",
"0.6501695",
"0.6425674",
"0.64250743",
"0.63577074",
"0.634742",
"0.63353163",
"0.6271833",
"0.6233696",
"0.6219992",
"0.6179467",
"0.6169452",
"0.61544144",
"0.6146064",... | 0.0 | -1 |
Request Authorization header has no value. This is an unknown service request, i.e., it is not a part of the original service specification. | def test_authorization_header_empty(self, _get_key_secret):
request = Request(self.environ)
request.authorization = "bad authorization header"
request.body = self.get_request_body()
response = self.xmodule.grade_handler(request, '')
real_response = self.get_response_values(respon... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_authorization_header_empty(self, get_key_secret):\r\n request = Request(self.environ)\r\n request.authorization = \"bad authorization header\"\r\n request.body = self.get_request_body()\r\n response = self.xmodule.grade_handler(request, '')\r\n real_response = self.get_r... | [
"0.7202221",
"0.7074588",
"0.7054413",
"0.6919532",
"0.6869497",
"0.6628194",
"0.65263647",
"0.65195256",
"0.6506443",
"0.64752686",
"0.64248955",
"0.6393487",
"0.6354913",
"0.63206965",
"0.63206965",
"0.63082194",
"0.6299203",
"0.6273099",
"0.62436366",
"0.6240936",
"0.62287... | 0.71908396 | 1 |
Should fail if we do not accept past due grades, and it is past due. | def test_grade_past_due(self):
self.xmodule.accept_grades_past_due = False
self.xmodule.due = datetime.datetime.now(UTC)
self.xmodule.graceperiod = Timedelta().from_json("0 seconds")
request = Request(self.environ)
request.body = self.get_request_body()
response = self.xm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_showanswer_past_due(self):\r\n\r\n # can't see after attempts used up, even with due date in the future\r\n used_all_attempts = CapaFactory.create(showanswer='past_due',\r\n max_attempts=\"1\",\r\n at... | [
"0.6567515",
"0.6262829",
"0.6199663",
"0.61215067",
"0.60718155",
"0.6057693",
"0.60156703",
"0.6007282",
"0.60001415",
"0.5997088",
"0.59868026",
"0.5985534",
"0.59815407",
"0.59733236",
"0.5933585",
"0.59262776",
"0.5915885",
"0.59091276",
"0.59011036",
"0.58947474",
"0.58... | 0.7589779 | 0 |
Tests that LTI parameter context_id is equal to course_id. | def test_context_id(self):
assert str(self.system.course_id) == self.xmodule.context_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_context_id(self):\r\n self.assertEqual(self.system.course_id.to_deprecated_string(), self.xmodule.context_id)",
"def verify_course(self, course, course_id='edX/toy/2012_Fall'):\n assert course_id == str(course.id)",
"def test_course_filter(self):\n user = self.make_user()\n ... | [
"0.731286",
"0.7153221",
"0.6504615",
"0.61604375",
"0.60503066",
"0.60126173",
"0.595559",
"0.59508294",
"0.5750599",
"0.57438254",
"0.5728129",
"0.57155603",
"0.56992066",
"0.56611407",
"0.56528354",
"0.5637025",
"0.5605761",
"0.56045175",
"0.5600945",
"0.5582407",
"0.55773... | 0.79229575 | 0 |
View function for home page of site. | def index(request):
# Render the HTML template index.html with the data in the context variable
return render(request, 'index.html') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home(request):\n\treturn render(request, \"compta/home.html\")",
"def home_page(request):\r\n return render(request, 'ez_main/home_page.html')",
"def home(request):\r\n return render(request, 'home.html')",
"def homepage(request):\n\treturn render(request, 'core/homepage.html')",
"def homepage(req... | [
"0.8493426",
"0.84268916",
"0.83415145",
"0.83306193",
"0.82976943",
"0.8295291",
"0.8276345",
"0.82545686",
"0.82155704",
"0.8132563",
"0.81246215",
"0.81224865",
"0.8121264",
"0.81049734",
"0.8098485",
"0.80935514",
"0.80935514",
"0.80935514",
"0.80935514",
"0.80935514",
"0... | 0.0 | -1 |
Find a value and return it | def find_value(self, key):
values = self.values
if key not in values:
raise AttributeError("Config has no value for {}".format(key))
val = values[key]
if isinstance(val, Default):
return val.val
else:
return val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_value(dic, key):\n return dic[key]",
"def find(found_item, _):\n if found_item:\n return found_item[1]\n else:\n return default",
"def lookup(self, key):\n n = self.find(key)\n if n:\n return n.value\n else:\n ... | [
"0.7356561",
"0.7180738",
"0.716797",
"0.6965395",
"0.692145",
"0.6912257",
"0.68643767",
"0.6841767",
"0.673396",
"0.6728164",
"0.67245144",
"0.6721205",
"0.6710407",
"0.6674901",
"0.66195244",
"0.65972465",
"0.6596949",
"0.6585134",
"0.6581496",
"0.65656954",
"0.6565036",
... | 0.6380859 | 32 |
normalizes a vector vec vector to normalize | def uv(vec):
return vec / sqrt(dot(vec, vec)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalizeVector(v):\n normalizer = 1.0 / sum(v)\n\n normalized = [i * normalizer for i in v]\n return normalized",
"def normalize(self):\n self.vector /= np.linalg.norm(self.vector)",
"def normalize(self):\n self._vectors = [vector.normalized() for vector in self._vectors]",
"def n... | [
"0.83029854",
"0.8283816",
"0.8235499",
"0.82230014",
"0.82225305",
"0.8213764",
"0.81011266",
"0.8054864",
"0.8035965",
"0.8035232",
"0.79933584",
"0.7851281",
"0.7850016",
"0.7849789",
"0.77852285",
"0.77793175",
"0.7751731",
"0.7738076",
"0.7696441",
"0.7694664",
"0.764472... | 0.0 | -1 |
Plots potential energy landscape | def plot_potential(self):
imshow(self.U, extent=(self.x[0], self.x[-1], self.y[0], self.y[-1]), aspect='auto', interpolation='None')
xlabel('x')
ylabel('y') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_energies(self):\n plt.plot(self.energies[0], self.energies[1])\n plt.xlabel('Time (s)')\n plt.ylabel('Energy (J)')\n plt.show()",
"def plot(self, num_levels=10):\n if num_levels == -1:\n num_levels = len(self.energies())\n print(self.energies(num_leve... | [
"0.7004734",
"0.69521713",
"0.6932262",
"0.67240036",
"0.66137713",
"0.6600352",
"0.6550917",
"0.65344065",
"0.6427424",
"0.641678",
"0.63775426",
"0.6332064",
"0.6332016",
"0.6309895",
"0.6260501",
"0.62594175",
"0.6255168",
"0.6251051",
"0.6226126",
"0.621713",
"0.6212393",... | 0.63277894 | 13 |
The temporal delay calculated from the coherency phase spectrum. | def coherency_phase_delay(time_series, lb=0, ub=None, csd_method=None):
if csd_method is None:
csd_method = {'this_method': 'welch'} # The default
f, fxy = get_spectra(time_series, csd_method)
lb_idx, ub_idx = utils.get_bounds(f, lb, ub)
if lb_idx == 0:
lb_idx = 1
p =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delay(self):\r\n return self.relative_phases / (2 * np.pi * self.frequencies)",
"def delay(self):\r\n return self.relative_phases / (2 * np.pi * self.frequencies)",
"def delay(self):\r\n p_shape = self.phase.shape[:-1]\r\n delay = np.zeros(self.phase.shape)\r\n for i in r... | [
"0.7722208",
"0.7722208",
"0.72185796",
"0.68148",
"0.66151536",
"0.66139495",
"0.6523703",
"0.64790946",
"0.6478099",
"0.63351923",
"0.632901",
"0.63248736",
"0.63130647",
"0.62867147",
"0.6256615",
"0.62269205",
"0.62174916",
"0.620331",
"0.6199988",
"0.618156",
"0.612936",... | 0.5857616 | 50 |
r""" Compute the phase delay between the spectra of two signals. The input to this function is in the frequency domain. | def _coherency_phase_delay(f, fxy):
return np.angle(fxy) / (2 * np.pi * f) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delay(self):\r\n return self.relative_phases / (2 * np.pi * self.frequencies)",
"def delay(self):\r\n return self.relative_phases / (2 * np.pi * self.frequencies)",
"def test_coherence_phase_delay():\r\n\r\n # Set up two time-series with a known phase delay:\r\n nz = np.random.rand(t.sh... | [
"0.65603334",
"0.65603334",
"0.64328176",
"0.6399782",
"0.63493586",
"0.62005866",
"0.6050688",
"0.5921325",
"0.58629364",
"0.5858026",
"0.5836208",
"0.57640505",
"0.57260615",
"0.5709868",
"0.5707974",
"0.5674772",
"0.5672937",
"0.5671081",
"0.56161296",
"0.55840623",
"0.557... | 0.5875526 | 8 |
Check that the spectral estimators are normalized in the correct Watts/Hz fashion | def test_periodogram_spectral_normalization():
x = np.random.randn(1024)
f1, Xp1 = tsa.periodogram(x)
f2, Xp2 = tsa.periodogram(x, Fs=100)
f3, Xp3 = tsa.periodogram(x, N=2**12)
p1 = np.sum(Xp1) * 2 * np.pi / 2**10
p2 = np.sum(Xp2) * 100 / 2**10
p3 = np.sum(Xp3) * 2 * np.pi / 2**12... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_compute_spectral_norms(self):\n\t\tdetails = self.watcher.analyze(layers=[self.second_layer], pool=False, randomize=False, plot=False, mp_fit=False, svd_method=ACCURATE_SVD)\n\n\t\t# SLOW method\n\t\ta = details.spectral_norm.to_numpy()\n\t\tself.assertAlmostEqual(a[0],20.2149, places=3)\n\t\tself.assertA... | [
"0.71188986",
"0.6626745",
"0.6622641",
"0.65333724",
"0.6521917",
"0.6504251",
"0.630933",
"0.62968963",
"0.6295818",
"0.62663406",
"0.6257663",
"0.6257639",
"0.6245022",
"0.62150204",
"0.62037057",
"0.62037057",
"0.62037057",
"0.61962885",
"0.61820143",
"0.61797005",
"0.616... | 0.6340316 | 6 |
Check that the spectral estimators are normalized in the correct Watts/Hz fashion | def test_multitaper_spectral_normalization():
x = np.random.randn(1024)
f1, Xp1, _ = tsa.multi_taper_psd(x)
f2, Xp2, _ = tsa.multi_taper_psd(x, Fs=100)
f3, Xp3, _ = tsa.multi_taper_psd(x, NFFT=2**12)
p1 = np.sum(Xp1) * 2 * np.pi / 2**10
p2 = np.sum(Xp2) * 100 / 2**10
p3 = np.sum(X... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_compute_spectral_norms(self):\n\t\tdetails = self.watcher.analyze(layers=[self.second_layer], pool=False, randomize=False, plot=False, mp_fit=False, svd_method=ACCURATE_SVD)\n\n\t\t# SLOW method\n\t\ta = details.spectral_norm.to_numpy()\n\t\tself.assertAlmostEqual(a[0],20.2149, places=3)\n\t\tself.assertA... | [
"0.71188986",
"0.6626745",
"0.6622641",
"0.65333724",
"0.6521917",
"0.6504251",
"0.6340316",
"0.630933",
"0.62968963",
"0.6295818",
"0.62663406",
"0.6257663",
"0.6257639",
"0.6245022",
"0.62150204",
"0.62037057",
"0.62037057",
"0.62037057",
"0.61962885",
"0.61797005",
"0.6166... | 0.61820143 | 19 |
Initializer for the multi_taper_SNR object | def __init__(self, input=None, bandwidth=None, adaptive=False,
low_bias=False):
self.input = input
self.signal, self.noise = signal_noise(input)
self.bandwidth = bandwidth
self.adaptive = adaptive
self.low_bias = low_bias | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, snps, phenotype):\n self.snps = snps\n self.phenotype = phenotype",
"def __init__(self):\n\n #call super class's __init__ method\n super(TRiseSampler, self).__init__(name=\"trise\", observed=False)",
"def __init__(\r\n self,\r\n signal_to_noise_ratio... | [
"0.6360974",
"0.6289074",
"0.6250269",
"0.62231153",
"0.61238176",
"0.6122738",
"0.60927737",
"0.60903895",
"0.60509115",
"0.6002973",
"0.5990973",
"0.5988502",
"0.5973656",
"0.594844",
"0.59170157",
"0.5914401",
"0.58934695",
"0.58701426",
"0.5853926",
"0.58287144",
"0.58156... | 0.0 | -1 |
Constructor function for the Hilbert analyzer class. | def __init__(self, input=None):
BaseAnalyzer.__init__(self, input) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, hilbert):\n super().__init__(DoubledHilbert(hilbert))",
"def __init__(self, hilbert: AbstractHilbert):\n self._hilbert = hilbert # type: AbstractHilbert\n\n self._model_state = {} # type: PyTree\n self._parameters = {} # type: PyTree",
"def __init__(\n s... | [
"0.82622075",
"0.770626",
"0.7355108",
"0.68605876",
"0.673454",
"0.6395139",
"0.6382529",
"0.62928045",
"0.62618685",
"0.62537795",
"0.62481093",
"0.6237326",
"0.61802566",
"0.6098138",
"0.6095773",
"0.6083835",
"0.608297",
"0.6054992",
"0.60307395",
"0.60240746",
"0.6015903... | 0.64297175 | 5 |
Construct an array filled with ones at and below the given diagonal. | def tri(N, M=None, k=0, dtype=float):
if M is None: M = N
m = greater_equal(subtract.outer(arange(N), arange(M)),-k)
return m.astype(dtype) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_diagonal_image(n):\n alist = []\n for i in range(0, n):\n alist.append([])\n for j in range(0,n):\n if i ==j:\n alist[i].append(1)\n else:\n alist[i].append(0)\n\n ##########\n # img = create_zeroed_image(n)\n # for i in rang... | [
"0.6796524",
"0.6263713",
"0.62313557",
"0.62025994",
"0.61487424",
"0.6142415",
"0.6130708",
"0.6107816",
"0.60867256",
"0.60548925",
"0.60483676",
"0.5938935",
"0.5896266",
"0.5887757",
"0.58250666",
"0.58223253",
"0.58075863",
"0.5801285",
"0.57977676",
"0.5791338",
"0.578... | 0.0 | -1 |
Lower triangle of an array. Return a copy of an array with elements above the `k`th diagonal zeroed. | def tril(m, k=0):
m = asanyarray(m)
out = multiply(tri(m.shape[0], m.shape[1], k=k, dtype=int),m)
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _flatten_lower_triangle(matrix):\r\n matrix = asarray(matrix)\r\n flattened = []\r\n for col_num in range(matrix.shape[1]):\r\n for row_num in range(matrix.shape[0]):\r\n if col_num < row_num:\r\n flattened.append(matrix[row_num][col_num])\r\n return flattened",... | [
"0.6425329",
"0.5702113",
"0.56926495",
"0.5679635",
"0.5640587",
"0.55935395",
"0.55656505",
"0.5557891",
"0.55056477",
"0.54999477",
"0.5477235",
"0.54704493",
"0.5449503",
"0.5436707",
"0.54184973",
"0.53942215",
"0.53772354",
"0.5292614",
"0.52918905",
"0.52906626",
"0.52... | 0.59441024 | 1 |
Upper triangle of an array. Construct a copy of a matrix with elements below the kth diagonal zeroed. Please refer to the documentation for `tril`. See Also tril Examples >>> np.triu([[1,2,3],[4,5,6],[7,8,9],[10,11,12]], 1) array([[ 1, 2, 3], [ 4, 5, 6], [ 0, 8, 9], [ 0, 0, 12]]) | def triu(m, k=0):
m = asanyarray(m)
out = multiply((1-tri(m.shape[0], m.shape[1], k-1, int)),m)
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upper_tri(A):\n d = pairwise_distances(A,A)\n m = d.shape[0]\n r,c = np.triu_indices(m,1)\n return(d[r,c])",
"def triu(m, k=0):\r\n return m * (1 - tri(m.shape[0], m.shape[1], k=k - 1, dtype=m.dtype))",
"def upper(mat):\n idx = np.triu_indices_from(mat, k=1)\n return mat[idx]",
"def ... | [
"0.70016456",
"0.68791497",
"0.6846577",
"0.67107743",
"0.6188429",
"0.6185684",
"0.6063736",
"0.60219705",
"0.5879165",
"0.5824861",
"0.5732545",
"0.5676017",
"0.566514",
"0.5602416",
"0.56019807",
"0.5597879",
"0.5539093",
"0.5538249",
"0.548181",
"0.5454993",
"0.5426823",
... | 0.70818573 | 0 |
Generate a Van der Monde matrix. The columns of the output matrix are decreasing powers of the input vector. Specifically, the ith output column is the input vector to the power of ``N i 1``. Such a matrix with a geometric progression in each row is named Van Der Monde, or Vandermonde matrix, from AlexandreTheophile Va... | def vander(x, N=None):
x = asarray(x)
if N is None: N=len(x)
X = ones( (len(x),N), x.dtype)
for i in range(N-1):
X[:,i] = x**(N-i-1)
return X | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vandermonde_matrix(x):\n m = size(x) \n n = m+1\n V = ones((m, n))\n for j in range(1, n):\n for i in range(0, m):\n V[i,j] = pow(x[i],j) \n return V",
"def generate_V(self):\n\n n_samples, n_dimensions, L = self.n_samples, self.n_dimensions, self.L\n\n V = np.... | [
"0.7436844",
"0.6173259",
"0.58772373",
"0.5850074",
"0.57708234",
"0.5738677",
"0.56673604",
"0.56285274",
"0.5609783",
"0.5609366",
"0.5596983",
"0.5587698",
"0.55401814",
"0.55339944",
"0.5532001",
"0.5521156",
"0.55035424",
"0.54004455",
"0.53444445",
"0.5335521",
"0.5319... | 0.6074705 | 2 |
Return the indices to access (n, n) arrays, given a masking function. Assume `mask_func` is a function that, for a square array a of size ``(n, n)`` with a possible offset argument `k`, when called as ``mask_func(a, k)`` returns a new array with zeros in certain locations (functions like `triu` or `tril` do precisely t... | def mask_indices(n,mask_func,k=0):
m = ones((n,n),int)
a = mask_func(m,k)
return where(a != 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mask_indices(n, mask_func, k=0):\r\n m = np.ones((n, n), int)\r\n a = mask_func(m, k)\r\n return np.where(a != 0)",
"def masked_indices(mask):\n\treturn np.nonzero(np.ravel(mask,order='C'))[0]",
"def non_masked_indices(mask):\n\treturn np.nonzero(np.ravel(mask-1,order='C'))[0]",
"def get_mask_in... | [
"0.832098",
"0.74624175",
"0.73548913",
"0.6602883",
"0.652169",
"0.6466128",
"0.6118983",
"0.5889769",
"0.58183503",
"0.5760746",
"0.5735351",
"0.5585752",
"0.5571087",
"0.5568994",
"0.55316454",
"0.54690063",
"0.5446137",
"0.54161173",
"0.53868085",
"0.5330221",
"0.5323084"... | 0.80422163 | 1 |
Return the indices for the lowertriangle of an (n, n) array. | def tril_indices(n,k=0):
return mask_indices(n,tril,k) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _low_tri_indices(rowCount):\n for col in range(rowCount):\n for row in range(col, rowCount):\n yield (row, col)",
"def least_indices(array: np.ndarray, n: int) -> tuple:\n flat = array.ravel()\n indices = np.argpartition(flat, n)[:n]\n indices = indices[np.argsort(fl... | [
"0.6704067",
"0.653861",
"0.6194193",
"0.6175976",
"0.61605936",
"0.6141694",
"0.6128341",
"0.60780674",
"0.6019167",
"0.5948387",
"0.5915022",
"0.5881797",
"0.58560073",
"0.5810991",
"0.5795254",
"0.5692788",
"0.5662853",
"0.564581",
"0.56225514",
"0.5545275",
"0.55315137",
... | 0.5562508 | 19 |
Return the indices for the lowertriangle of an (n, n) array. See `tril_indices` for full details. | def tril_indices_from(arr,k=0):
if not arr.ndim==2 and arr.shape[0] == arr.shape[1]:
raise ValueError("input array must be 2-d and square")
return tril_indices(arr.shape[0],k) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _low_tri_indices(rowCount):\n for col in range(rowCount):\n for row in range(col, rowCount):\n yield (row, col)",
"def tril_indices_from(arr, k=0):\r\n if not arr.ndim == 2 and arr.shape[0] == arr.shape[1]:\r\n raise ValueError(\"input array must be 2-d and square\"... | [
"0.6755344",
"0.66526127",
"0.6545226",
"0.6260556",
"0.6221781",
"0.619691",
"0.61570567",
"0.59987015",
"0.58828783",
"0.5873679",
"0.5870515",
"0.5870169",
"0.5766556",
"0.5755701",
"0.56202334",
"0.5610463",
"0.5605049",
"0.55585104",
"0.55240935",
"0.5456417",
"0.5437639... | 0.66356224 | 2 |
Return the indices for the lowertriangle of an (n, n) array. See `triu_indices` for full details. | def triu_indices_from(arr,k=0):
if not arr.ndim==2 and arr.shape[0] == arr.shape[1]:
raise ValueError("input array must be 2-d and square")
return triu_indices(arr.shape[0],k) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _low_tri_indices(rowCount):\n for col in range(rowCount):\n for row in range(col, rowCount):\n yield (row, col)",
"def triu_indices(n, k=0):\r\n return mask_indices(n, np.triu, k)",
"def least_indices(array: np.ndarray, n: int) -> tuple:\n flat = array.ravel()\n in... | [
"0.68235254",
"0.6416853",
"0.63039875",
"0.61677176",
"0.6162944",
"0.61572176",
"0.6135953",
"0.6028089",
"0.5960476",
"0.5902467",
"0.59017396",
"0.57216513",
"0.56082475",
"0.55834895",
"0.5519474",
"0.5488446",
"0.54367197",
"0.5399651",
"0.53273046",
"0.52910477",
"0.52... | 0.6130919 | 7 |
Return an iterator over the values of a dictionary. | def itervalues(d, **kw):
return iter(getattr(d, _itervalues)(**kw)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def itervalues(d):\n return iter(getattr(d, _itervalues)())",
"def itervalues(d):\r\n return iter(getattr(d, _itervalues)())",
"def itervalues(self):\n return DictValuesIterator(self)",
"def itervalues(self):\n return iter(kvp.value for kvp in self.keyvaluepair_set.all())",
"def iterval... | [
"0.76038533",
"0.759449",
"0.75789016",
"0.74970734",
"0.74708176",
"0.7417123",
"0.7331701",
"0.7212243",
"0.71511436",
"0.7124317",
"0.70671904",
"0.70009923",
"0.69980973",
"0.69067776",
"0.68919003",
"0.6884046",
"0.68811375",
"0.6873443",
"0.6852655",
"0.683082",
"0.6825... | 0.733221 | 7 |
Return an iterator over the (key, value) pairs of a dictionary. | def iteritems(d, **kw):
return iter(getattr(d, _iteritems)(**kw)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self) -> iter:\n return iter(self._dict)",
"def iteritems(self):\n return iter((kvp.key, kvp.value) for kvp in self.keyvaluepair_set.all())",
"def iter_over_pairs(pairs):\r\n if isinstance(pairs, dict):\r\n return pairs.iteritems()\r\n else:\r\n return pairs",
"... | [
"0.69681364",
"0.6962657",
"0.68685055",
"0.6746838",
"0.67312443",
"0.67283183",
"0.672741",
"0.6719771",
"0.670634",
"0.6694921",
"0.6673996",
"0.66608566",
"0.66370773",
"0.65998065",
"0.659718",
"0.6581123",
"0.65757334",
"0.6571146",
"0.65570706",
"0.65514755",
"0.655086... | 0.60994196 | 53 |
Return an iterator over the (key, [values]) pairs of a dictionary. | def iterlists(d, **kw):
return iter(getattr(d, _iterlists)(**kw)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iteritems(self):\n return iter((kvp.key, kvp.value) for kvp in self.keyvaluepair_set.all())",
"def iter_over_pairs(pairs):\r\n if isinstance(pairs, dict):\r\n return pairs.iteritems()\r\n else:\r\n return pairs",
"def itervalues(self):\n return iter(kvp.value for kvp in se... | [
"0.70931435",
"0.7014377",
"0.70028114",
"0.69225967",
"0.69109845",
"0.6905411",
"0.6885402",
"0.6884745",
"0.67762935",
"0.67021227",
"0.6692182",
"0.66854835",
"0.6664243",
"0.6656871",
"0.6656871",
"0.66396326",
"0.66253984",
"0.66205364",
"0.65872157",
"0.65744513",
"0.6... | 0.0 | -1 |
Extract the time unit of the object. If it is an iterable, get the time unit of the first element. | def get_time_unit(obj):
# If this is a Time object, no problem:
if isinstance(obj, TimeInterface):
return obj.time_unit
# Otherwise, if it is iterable, we recurse on it:
try:
it = iter(obj)
except TypeError:
return None
else:
return get_time_unit(six... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_time_unit(self, variables):\n if len(self.TIME_VARIABLE):\n # times = self._get_variable(variables, self.TIME_VARIABLE)[:]\n units = variables['time'].units\n return units\n else:\n return \"\"",
"def infer_time_unit(time_seconds_arr: Collection[f... | [
"0.68348324",
"0.65372753",
"0.64424586",
"0.639273",
"0.63738185",
"0.6343383",
"0.62967396",
"0.6209188",
"0.61761665",
"0.61742204",
"0.6062775",
"0.604468",
"0.6043162",
"0.6043162",
"0.5999046",
"0.5973236",
"0.5897307",
"0.5829815",
"0.58050936",
"0.57874376",
"0.576579... | 0.8267647 | 0 |
Returns the maximal time | def max(self, axis=None, out=None):
# this is a quick fix to return a time and will
# be obsolete once we use proper time dtypes
if axis is not None:
raise NotImplementedError('axis argument not implemented')
if out is not None:
raise NotImplementedError('ou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_time(self):\n return self._max_time",
"def max(self):\n\n return time_stat(self, stat=\"max\")",
"def max_time(self):\n return self._ll_tree_sequence.get_max_time()",
"def max_time(self):\n return self.time[np.argmax(self.flux)]",
"def max_time(self) -> str:\n return ... | [
"0.8171023",
"0.8118685",
"0.7994427",
"0.78654677",
"0.78486705",
"0.76854223",
"0.75836694",
"0.7573576",
"0.71487963",
"0.71030337",
"0.70632994",
"0.702682",
"0.6984809",
"0.6863642",
"0.68570375",
"0.6774001",
"0.67246974",
"0.6716762",
"0.67163664",
"0.6700915",
"0.6607... | 0.0 | -1 |
Returns the minimal time | def min(self, axis=None, out=None):
# this is a quick fix to return a time and will
# be obsolete once we use proper time dtypes
if axis is not None:
raise NotImplementedError('axis argument not implemented')
if out is not None:
raise NotImplementedError('ou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min(self):\n\n return time_stat(self, stat=\"min\")",
"def min_time(self):\n return self._ll_tree_sequence.get_min_time()",
"def min_time(self) -> str:\n return self._min_time",
"def min_time(self):\n #{{{ function to return time of first sample\n\n return self.mintime",
"def... | [
"0.83780795",
"0.834636",
"0.81920797",
"0.80191606",
"0.7940992",
"0.7754936",
"0.76451457",
"0.74169564",
"0.7380019",
"0.7338924",
"0.71497285",
"0.7090096",
"0.7031173",
"0.6966853",
"0.6922955",
"0.6902626",
"0.6878068",
"0.68446565",
"0.68139964",
"0.6799294",
"0.675374... | 0.0 | -1 |
Returns the maximal time | def max(self, axis=None, out=None):
# this is a quick fix to return a time and will
# be obsolete once we use proper time dtypes
if axis is not None:
raise NotImplementedError('axis argument not implemented')
if out is not None:
raise NotImplementedError('ou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_time(self):\n return self._max_time",
"def max(self):\n\n return time_stat(self, stat=\"max\")",
"def max_time(self):\n return self._ll_tree_sequence.get_max_time()",
"def max_time(self):\n return self.time[np.argmax(self.flux)]",
"def max_time(self) -> str:\n return ... | [
"0.8171023",
"0.8118685",
"0.7994427",
"0.78654677",
"0.78486705",
"0.76854223",
"0.75836694",
"0.7573576",
"0.71487963",
"0.71030337",
"0.70632994",
"0.702682",
"0.6984809",
"0.6863642",
"0.68570375",
"0.6774001",
"0.67246974",
"0.6716762",
"0.67163664",
"0.6700915",
"0.6607... | 0.0 | -1 |
Pad a timeseries with zeros on either side, depending on its length | def zero_pad(time_series, NFFT):
n_dims = len(time_series.shape)
n_time_points = time_series.shape[-1]
if n_dims>1:
n_channels = time_series.shape[:-1]
shape_out = n_channels + (NFFT,)
else:
shape_out = NFFT
# zero pad if time_series is too short
if n_time_po... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zero_pad(data):\n N = len(data)\n pow_2 = np.ceil(np.log2(N))\n return np.pad(data,(0,int((2**pow_2)-N)),'constant')",
"def test_zero_pad():\r\n # Freely assume that time is the last dimension:\r\n ts1 = np.empty((64, 64, 35, 32))\r\n NFFT = 64 \r\n zp1 = utils.zero_pad(ts1, NFFT)\r\n ... | [
"0.74751264",
"0.7169507",
"0.67756844",
"0.6690908",
"0.6675604",
"0.65574944",
"0.655052",
"0.6541518",
"0.6512747",
"0.6481003",
"0.6415681",
"0.6393594",
"0.6385069",
"0.635512",
"0.62841284",
"0.62533486",
"0.623212",
"0.6208525",
"0.62011343",
"0.6189114",
"0.6186118",
... | 0.74202365 | 1 |
Fill the main diagonal of the given array of any dimensionality. For an array with ndim > 2, the diagonal is the list of locations with indices a[i,i,...,i], all identical. This function modifies the input array inplace, it does not return a value. This functionality can be obtained via diag_indices(), but internally t... | def fill_diagonal(a, val):
if a.ndim < 2:
raise ValueError("array must be at least 2-d")
if a.ndim == 2:
# Explicit, fast formula for the common case. For 2-d arrays, we
# accept rectangular ones.
step = a.shape[1] + 1
else:
# For more than d=2, the strided f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_diagonal(a, val):\r\n return fill_diagonal_(a, val)",
"def diagonal(a, offset=0, axis1=0, axis2=1):\n # TODO(okuta): check type\n return a.diagonal(offset, axis1, axis2)",
"def get_diagonal(self, array):\n diags = [array[::-1, :].diagonal(i) for i in range(-array.shape[0] + 1, array.sh... | [
"0.6677904",
"0.6511456",
"0.59948796",
"0.59430236",
"0.59069014",
"0.58060294",
"0.57434887",
"0.56305265",
"0.5629766",
"0.5577794",
"0.55106074",
"0.54815257",
"0.545753",
"0.5384273",
"0.5381367",
"0.536636",
"0.5282695",
"0.52794725",
"0.5244483",
"0.52428657",
"0.52399... | 0.7303793 | 0 |
Return the indices to access the main diagonal of an array. This returns a tuple of indices that can be used to access the main diagonal of an array with ndim (>=2) dimensions and shape (n,n,...,n). For ndim=2 this is the usual diagonal, for ndim>2 this is the set of indices to access A[i,i,...,i] for i=[0..n1]. | def diag_indices(n, ndim=2):
idx = np.arange(n)
return (idx,) * ndim | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diag_indices_from(arr):\r\n if not arr.ndim >= 2:\r\n raise ValueError(\"input array must be at least 2-d\")\r\n # For more than d=2, the strided formula is only valid for arrays with\r\n # all dimensions equal, so we check first.\r\n if not np.alltrue(np.diff(arr.shape) == 0):\r\n ra... | [
"0.7577567",
"0.7144074",
"0.67870235",
"0.65572584",
"0.6304568",
"0.6185231",
"0.6179251",
"0.5898182",
"0.58639926",
"0.5855626",
"0.57824403",
"0.5757688",
"0.5676579",
"0.5651263",
"0.5639654",
"0.556598",
"0.54811",
"0.54114467",
"0.539298",
"0.5389154",
"0.53828233",
... | 0.7124634 | 2 |
Return the indices to access the main diagonal of an ndimensional array. See diag_indices() for full details. | def diag_indices_from(arr):
if not arr.ndim >= 2:
raise ValueError("input array must be at least 2-d")
# For more than d=2, the strided formula is only valid for arrays with
# all dimensions equal, so we check first.
if not np.alltrue(np.diff(arr.shape) == 0):
raise ValueError("All... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diag_indices(n, ndim=2):\n\n if not use_origin_backend():\n return dpnp_diag_indices(n, ndim)\n\n return call_origin(numpy.diag_indices, n, ndim)",
"def diag_indices(n, ndim=2):\r\n idx = np.arange(n)\r\n return (idx,) * ndim",
"def diagonal_inds(tensor):\n assert tensor.dim() >= 2\n ... | [
"0.8027248",
"0.76106304",
"0.73417777",
"0.7031329",
"0.65160924",
"0.650754",
"0.64378256",
"0.6428602",
"0.6368871",
"0.61170965",
"0.6025158",
"0.5994503",
"0.59830636",
"0.59723586",
"0.59131795",
"0.5902443",
"0.5898179",
"0.58798677",
"0.58798677",
"0.5866953",
"0.5856... | 0.765408 | 1 |
Return the indices to access (n,n) arrays, given a masking function. Assume mask_func() is a function that, for a square array a of size (n,n) with a possible offset argument k, when called as mask_func(a,k) returns a new array with zeros in certain locations (functions like triu() or tril() do precisely this). Then th... | def mask_indices(n, mask_func, k=0):
m = np.ones((n, n), int)
a = mask_func(m, k)
return np.where(a != 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mask_indices(n,mask_func,k=0):\r\n m = ones((n,n),int)\r\n a = mask_func(m,k)\r\n return where(a != 0)",
"def masked_indices(mask):\n\treturn np.nonzero(np.ravel(mask,order='C'))[0]",
"def non_masked_indices(mask):\n\treturn np.nonzero(np.ravel(mask-1,order='C'))[0]",
"def get_idxes_from_mask(ma... | [
"0.7987847",
"0.7650373",
"0.7525215",
"0.6637633",
"0.6546128",
"0.65330654",
"0.61176735",
"0.5921416",
"0.58720803",
"0.5862646",
"0.583249",
"0.5808943",
"0.58077127",
"0.57237893",
"0.56801605",
"0.5645876",
"0.56419647",
"0.5638932",
"0.5607495",
"0.5586064",
"0.5579274... | 0.8200937 | 0 |
Return the indices for the lowertriangle of an (n,n) array. | def tril_indices(n, k=0):
return mask_indices(n, np.tril, k) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _low_tri_indices(rowCount):\n for col in range(rowCount):\n for row in range(col, rowCount):\n yield (row, col)",
"def least_indices(array: np.ndarray, n: int) -> tuple:\n flat = array.ravel()\n indices = np.argpartition(flat, n)[:n]\n indices = indices[np.argsort(fl... | [
"0.675269",
"0.6458192",
"0.62418944",
"0.6234887",
"0.618907",
"0.6168332",
"0.60378003",
"0.60245353",
"0.5988688",
"0.5966936",
"0.59515214",
"0.5850899",
"0.57870805",
"0.57623595",
"0.5744705",
"0.56964034",
"0.55729866",
"0.5559781",
"0.5548834",
"0.5538482",
"0.5515335... | 0.57258785 | 15 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.