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 |
|---|---|---|---|---|---|---|
Adds primary text string onsets/offsets to all nodes that represent tokens. In SaltDocuments, this data was stored in TextualRelation edges only. | def _add_offsets_to_token_nodes(self):
for edge_index in self._textual_relation_ids:
token_node_index = self.edges[edge_index].source
self.nodes[token_node_index].onset = self.edges[edge_index].onset
self.nodes[token_node_index].offset = self.edges[edge_index].offset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assign_textual_node_features(ndata, textset, ntype):\n node_ids = ndata[dgl.NID].numpy()\n\n for field_name, field in textset.fields.items():\n examples = [getattr(textset[i], field_name) for i in node_ids]\n\n tokens, lengths = field.process(examples)\n\n if not field.batch_first:\n... | [
"0.56806487",
"0.5558746",
"0.5420864",
"0.5388493",
"0.5375551",
"0.53266215",
"0.53263026",
"0.5312888",
"0.5255938",
"0.52336764",
"0.521463",
"0.5200022",
"0.5173629",
"0.512864",
"0.5114523",
"0.50887275",
"0.50882906",
"0.5073677",
"0.50692797",
"0.5068018",
"0.50339144... | 0.72844553 | 0 |
Adds to every span node the list of tokens (token node IDs) that belong to it. SpanNode.tokens a list of `int` ids of `TokenNode`s | def _add_token_node_ids_to_span_nodes(self):
span_dict = defaultdict(list)
for span_edge in self._spanning_relation_ids:
token_node_id = self.edges[span_edge].target
span_node_id = self.edges[span_edge].source
span_dict[span_node_id].append(token_node_id)
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_span_node_ids_to_token_nodes(self):\n span_dict = defaultdict(list)\n for span_edge in self._spanning_relation_ids:\n token_node_id = self.edges[span_edge].target\n span_node_id = self.edges[span_edge].source\n span_dict[token_node_id].append(span_node_id)\n\... | [
"0.7736828",
"0.61374366",
"0.609583",
"0.60759944",
"0.58065456",
"0.57227135",
"0.57088804",
"0.57023436",
"0.5640737",
"0.5593042",
"0.55628616",
"0.5515745",
"0.5444999",
"0.5391665",
"0.53902817",
"0.537551",
"0.5355724",
"0.53296465",
"0.52996624",
"0.5273694",
"0.52518... | 0.7866296 | 0 |
returns a list of absolute filepaths for all files found in the given directory. | def abslistdir(directory):
abs_dir = os.path.abspath(directory)
filenames = os.listdir(abs_dir)
return [os.path.join(abs_dir, filename) for filename in filenames] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_filepaths(self, directory):\n folder_paths = [os.path.join(directory, folder) for folder in os.listdir(directory) if not folder.startswith('.')]\n filepaths = [[os.path.join(cur_folder, cur_file) for cur_file in os.listdir(cur_folder)] for cur_folder in folder_paths]\n return filepath... | [
"0.81050324",
"0.80519843",
"0.79594743",
"0.7959108",
"0.7946928",
"0.7936476",
"0.79087204",
"0.79087204",
"0.79087204",
"0.7785415",
"0.7750252",
"0.76906574",
"0.7511898",
"0.75106066",
"0.74836767",
"0.7424115",
"0.73264945",
"0.73001796",
"0.72954065",
"0.72446567",
"0.... | 0.7527842 | 12 |
Returns true if the resource has not been updated since the given timestamp. | def isFresh(self, timestamp):
pass; | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_updated(self):\n return self.timestamp > 0",
"def is_outdated(self, timestamp):\n\n expiry_time = datetime.datetime.now() - self.cache_time\n return expiry_time > timestamp",
"def isFresh(self, timestamp):\n if not os.path.exists(self.__resource):\n return False;\n... | [
"0.7913203",
"0.75742966",
"0.7541799",
"0.7057558",
"0.69103086",
"0.6848536",
"0.6776707",
"0.67662865",
"0.6734345",
"0.6678252",
"0.6654128",
"0.66401654",
"0.6638965",
"0.6615578",
"0.6613361",
"0.6609859",
"0.6608848",
"0.6594054",
"0.659306",
"0.65477264",
"0.6497396",... | 0.66325146 | 13 |
Returns true if the resource has not been updated since the given timestamp. | def isFresh(self, timestamp):
if not os.path.exists(self.__resource):
return False;
return os.path.getmtime(self.__resource) < timestamp; | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_updated(self):\n return self.timestamp > 0",
"def is_outdated(self, timestamp):\n\n expiry_time = datetime.datetime.now() - self.cache_time\n return expiry_time > timestamp",
"def needs_update(self):\n now = time.time()/60\n return (self.last_update_time_in_minutes+sel... | [
"0.79159415",
"0.7573777",
"0.7060449",
"0.69099295",
"0.6851877",
"0.67777663",
"0.6768238",
"0.673652",
"0.6678873",
"0.6656108",
"0.66399854",
"0.6638755",
"0.66327274",
"0.6617876",
"0.66167015",
"0.6611177",
"0.66099775",
"0.6595119",
"0.6592914",
"0.6547103",
"0.6499417... | 0.75428075 | 2 |
If true, no two list items may have the same value for this column. | def enforce_unique_values(self):
return self.properties.get('enforceUniqueValues', None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _all_elem_same(self, row):\n return len(set(row)) == 1 and row[0] != self.BLANK_CELL_CHAR",
"def isIsosceles(self):\n\t\treturn self.a == self.b or self.a == self.c or self.b == self.c",
"def __ne__(self, other: 'UserList') -> bool:\n return not self == other",
"def tied(self):\n for... | [
"0.6726265",
"0.65145135",
"0.63198954",
"0.6266274",
"0.609761",
"0.6085212",
"0.5987421",
"0.5958557",
"0.5953424",
"0.59279114",
"0.59244746",
"0.59122807",
"0.5907172",
"0.5904836",
"0.5868663",
"0.58338195",
"0.58284104",
"0.57980615",
"0.57745165",
"0.57627773",
"0.5761... | 0.5744341 | 25 |
Specifies whether the column values can used for sorting and searching. | def indexed(self):
return self.properties.get('indexed', None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def orderable(self):\r\n if self.column.orderable is not None:\r\n return self.column.orderable\r\n return self.table.orderable",
"def set_sorting_enabled(self, value):\n self.tableWidget.setSortingEnabled(value)",
"def IsColumnMode(self):\n return self.VertEdit.Enabled",... | [
"0.61216855",
"0.5987958",
"0.57315433",
"0.5708952",
"0.5580935",
"0.5506374",
"0.5459479",
"0.53071624",
"0.53053325",
"0.52187115",
"0.52124786",
"0.5207485",
"0.51880604",
"0.51844394",
"0.51833254",
"0.5179272",
"0.5110233",
"0.50993276",
"0.50675493",
"0.49929795",
"0.4... | 0.0 | -1 |
For site columns, the name of the group this column belongs to. Helps organize related columns. | def column_group(self):
return self.properties.get('columnGroup', None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_group_names(self):\n return [self.frame.columns[i] for i in self.group_cols]",
"def group(self) -> str:\n return self._db_data.group",
"def get_country_groups_grid_column_names_by_order(self):\n self.column_name_list = self.get_grid_column_names_by_order(self.country_groups_grid_di... | [
"0.6130151",
"0.59105843",
"0.5744882",
"0.57420087",
"0.57420087",
"0.57420087",
"0.57420087",
"0.5541083",
"0.55370325",
"0.5502198",
"0.5440606",
"0.5434247",
"0.54196864",
"0.5416315",
"0.5386398",
"0.53482205",
"0.53455323",
"0.53253424",
"0.53220016",
"0.5309603",
"0.53... | 0.6828804 | 0 |
This column stores data from a list of choices. | def choice(self):
return self.get_property('choice', ChoiceColumn()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def choices(self, choices: Iterable[Tuple[str, str]]):\n try:\n iter(choices)\n except TypeError:\n raise TypeError(\"'choices' isn't a valid iterable\")\n\n apply_choices = []\n for i, (choice_id, choice_label) in enumerate(choices):\n apply_choices.app... | [
"0.5778576",
"0.5667357",
"0.5608106",
"0.5593724",
"0.55903304",
"0.55620927",
"0.555747",
"0.5412634",
"0.54106724",
"0.5338997",
"0.532426",
"0.5252421",
"0.52266175",
"0.5205539",
"0.51780534",
"0.5171869",
"0.51542026",
"0.51495636",
"0.5108218",
"0.51066554",
"0.5093219... | 0.5948859 | 0 |
Make boxes transparent with colored edges & whiskers | def make_edgecolor(ax, color=None):
for i,artist in enumerate(ax.artists):
# Set the linecolor on the artist to the facecolor, and set the facecolor to None
col = artist.get_facecolor()
if color is not None:
col = color
artist.set_edgecolor(col)
artist.set_facecolor('None')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transparent_boxes(ax, **kwargs):\n facecolor = kwargs.get('facecolor', 'white')\n edgecolor = kwargs.get('edgecolor', 'black')\n edgewidth = kwargs.get('edgewidth', 1)\n for i,box in enumerate(ax.artists):\n box.set_edgecolor(edgecolor)\n box.set_facecolor(facecolor)\n box.set_... | [
"0.7440463",
"0.61766535",
"0.6111535",
"0.6065841",
"0.59877676",
"0.5959805",
"0.58755773",
"0.58744353",
"0.5854805",
"0.5840496",
"0.58148897",
"0.58088255",
"0.58048856",
"0.5770017",
"0.5763467",
"0.5715623",
"0.57142997",
"0.56848603",
"0.56848603",
"0.56801414",
"0.56... | 0.51785356 | 84 |
Try to create a Panda object from a Person JSON | def test_panda_to_json_from_person_json(self):
json_person = self.test_person.to_json()
with self.assertRaises(ValueError):
self.test_panda.from_json(json_person) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dict(dictionary=dict()):\n obj = Person()\n obj.set_id(dictionary[\"id\"]) # eigentlich Teil von BusinessObject !\n obj.set_name(dictionary[\"name\"])\n obj.set_berechtigung(dictionary[\"berechtigung\"])\n obj.set_email(dictionary[\"email\"])\n obj.set_google_id(... | [
"0.5996296",
"0.5979634",
"0.58622855",
"0.5853503",
"0.57727855",
"0.5741541",
"0.57254004",
"0.572146",
"0.5708599",
"0.57048583",
"0.5691086",
"0.5557344",
"0.55462813",
"0.5525846",
"0.55258065",
"0.5514457",
"0.5462752",
"0.54480493",
"0.54466957",
"0.54299176",
"0.54297... | 0.7743778 | 0 |
Confidence region for a t Distribution. | def ct(df=1, loc=0, scale=1, type="equal", conf=0.95):
# ==========================================================================
# Account for the different types of cutoff quantiles
alpha = 1 - conf
if (type == "less"):
p_lower = alpha
p_upper = 1.0
elif (type == "more"):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_confidence(self, t, df):\n t_table = self.t_table\n nearest_df = round(find_nearest(t_table.index, df), 0)\n nearest_t = round(find_nearest(t_table.loc[nearest_df], t), 6)\n for col in list(t_table):\n if nearest_t == round(t_table[col][nearest_df], 6):\n ... | [
"0.63769203",
"0.61940664",
"0.5694016",
"0.5622552",
"0.5615678",
"0.55996823",
"0.5550412",
"0.545191",
"0.53653884",
"0.5228462",
"0.5147684",
"0.51392156",
"0.5124844",
"0.51103204",
"0.5053451",
"0.5048654",
"0.5024756",
"0.5019782",
"0.498935",
"0.49811196",
"0.49790162... | 0.0 | -1 |
Density Function for the t distribution. Returns the probability density value at the value x. | def dt(x, df=1, loc=0, scale=1, ncp=None, log=False):
# ==========================================================================
if log:
return t.logpdf(x, df=df, loc=0, scale=1)
else:
return t.pdf(x, df=df, loc=0, scale=1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def x_density_function(self, x):\n return self.wavefunction(x) * self.wavefunction(x)",
"def __call__(self,\n x0: Union[float, np.ndarray],\n xt: Union[float, np.ndarray],\n t: float) -> Union[float, np.ndarray]:\n return self._model.exact_density(x0=... | [
"0.72047466",
"0.715641",
"0.7087854",
"0.7069435",
"0.669381",
"0.6673914",
"0.6606843",
"0.6569857",
"0.64532936",
"0.6391592",
"0.6388787",
"0.6346544",
"0.63461787",
"0.63461787",
"0.6311127",
"0.6293481",
"0.6280864",
"0.6265347",
"0.6256383",
"0.6227106",
"0.62248474",
... | 0.5879161 | 42 |
The quantile function for the t distribution. You provide a quantile (eg q=0.75) or array of quantiles, and it returns the value along the t distribution that corresponds to the qth quantile. So using a value of q=0.30 means that 30% of the values are below the returned value. So it essentially gives us the cut off poi... | def qt(q, df=1, loc=0, scale=1, ncp=None, lowertail=True, log=False):
# ==========================================================================
if log:
raise NotImplementedError("Log option is not implemented yet.")
elif lowertail:
return t.ppf(q=q, df=df, loc=loc, scale=scale)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def percentile(t: torch.tensor, q: float):\n # Note that ``kthvalue()`` works one-based, i.e. the first sorted value\n # indeed corresponds to k=1, not k=0! Use float(q) instead of q directly,\n # so that ``round()`` returns an integer, even if q is a np.float32.\n k = 1 + round(.01 * float(q) * (t.num... | [
"0.69816756",
"0.6878866",
"0.68612754",
"0.68612754",
"0.66957897",
"0.6676191",
"0.66159856",
"0.65270746",
"0.64924747",
"0.640851",
"0.63872135",
"0.6356319",
"0.6315398",
"0.6224654",
"0.62139803",
"0.6200898",
"0.6194422",
"0.6171296",
"0.6164038",
"0.6127959",
"0.61034... | 0.0 | -1 |
The cumulative distribution function for the t distribution. You provide a value along the t distribution (eg x=3) or array of values, and it returns what proportion of values lie below it (the quantile) Alternatively, if you select lowertail=False, it returns the proportion of values that are above it. | def pt(x, df=1, loc=0, scale=1, ncp=None, lowertail=True, log=False):
if lowertail and not log:
return t.cdf(x, df=df, loc=loc, scale=scale)
elif not lowertail and not log:
return t.sf(x, df=df, loc=loc, scale=scale)
elif lowertail and log:
return t.logcdf(x, df=df, loc=loc, scale=sc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ucdf(t,tmax):\n return t/tmax if t<tmax else 1.",
"def custom_pdf(self, cum_probs, values):\n rnd_num = random()\n for p in range(len(cum_probs)):\n if rnd_num < cum_probs[p]:\n return values[p]",
"def get_low_high(a):\n\n return stats.pareto.cdf((10000,1000000... | [
"0.64214677",
"0.58980256",
"0.58581764",
"0.578782",
"0.5727213",
"0.5713745",
"0.5632287",
"0.5625939",
"0.5619102",
"0.55923116",
"0.55904615",
"0.55886066",
"0.55855054",
"0.5550487",
"0.55484724",
"0.5546477",
"0.5542129",
"0.5531803",
"0.5520189",
"0.5511479",
"0.551113... | 0.5408683 | 31 |
Swaps two of the words in the sentence randomly. | def __swap_two_random_words(self, tokenized_sentence: list) -> str:
sentence_length = len(tokenized_sentence)
# Initialize return variable to keep Pylance happy
new_sentence = ""
# Some variables to keep track of changes and attempted changes
has_changed = False
attempts ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swap_words(name, times=1):\r\n\twords = name.split(\" \")\r\n\tif len(words) <= 1: # return the name if it only has one word, this permutation is not applicable\r\n\t\treturn name\r\n\tfor _ in range(times):\r\n\t\tidx = random.randint(0, len(words) - 2)\r\n\t\twords[idx], words[idx + 1] = words[idx+1], words[... | [
"0.7502698",
"0.74633485",
"0.667398",
"0.65114665",
"0.6374586",
"0.6282678",
"0.6244169",
"0.62069476",
"0.610509",
"0.60260564",
"0.5981666",
"0.5975359",
"0.5952929",
"0.5902227",
"0.58991504",
"0.5873016",
"0.5860813",
"0.5833129",
"0.58024293",
"0.57630634",
"0.5759819"... | 0.75956345 | 0 |
Convert the zipped SQL file with the market data to a Parquet file. | def convert_sql_to_parquet():
logging.basicConfig(
format='%(levelname)-8s | %(asctime)s | %(name)s: %(message)s',
level=logging.INFO
)
zipped_sql_file, output_dir = parse_command_line_args()
if not output_dir.exists():
output_dir.mkdir()
parquet_file = output_dir / (zipp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def csv_file_to_parquet(input_file, output_file):\n df = pd.read_csv(input_file)\n df.to_parquet(output_file)",
"def export_to_parquet(data):\n table = pa.Table.from_pandas(data)\n pq.write_to_dataset(table\n , root_path=os.path.join(os.getcwd(),EXPORT_PATH['PARQUET_BASE_PATH']... | [
"0.69544196",
"0.688331",
"0.66062194",
"0.6543609",
"0.65411806",
"0.651528",
"0.6312932",
"0.62374306",
"0.61467576",
"0.60214126",
"0.5905973",
"0.58870256",
"0.5835542",
"0.5748705",
"0.5724191",
"0.56720704",
"0.56479406",
"0.5627407",
"0.5555396",
"0.5447365",
"0.544616... | 0.87257946 | 0 |
Return the name of the entity. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entity_name(self):\n return self.__entity_name",
"def entity_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"entity_name\")",
"def entity_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"entity_name\")",
"def name(self):\n return \"{} {}\".format(self.... | [
"0.8988081",
"0.830123",
"0.830123",
"0.7981105",
"0.7968869",
"0.75547564",
"0.7544363",
"0.753696",
"0.753696",
"0.753696",
"0.75339216",
"0.7524735",
"0.74966395",
"0.74897224",
"0.7478738",
"0.74753976",
"0.74632776",
"0.7451028",
"0.7451028",
"0.7451028",
"0.7451028",
... | 0.0 | -1 |
Return the device state attributes. | def device_state_attributes(self):
if self.hass.data[DOMAIN][CALENDAR_PLATFORM].event is None:
# No tasks, we don't need to show anything.
return None
return {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\r\n return self._attributes",
"def device_state_attributes(self):\n return self._attrs",
"def device_state_attributes(self):\n return self.attr",
"def device_state_attributes(self... | [
"0.93173087",
"0.9245708",
"0.92207897",
"0.92147964",
"0.92147964",
"0.9210798",
"0.9210798",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
... | 0.0 | -1 |
Test exception is thrown when the jar file is missing. | def test_create_canonical_classpath_with_broken_classpath(self):
a = self.make_target('a/b', JvmTarget)
classpath_products = ClasspathProducts(self.pants_workdir)
jar_path = 'ivy/jars/org.x/lib/x-1.0.jar'
# this sets the path for the artifact without actually materializing it.
resolved_jar = Resol... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_raises_if_argument_junit_jar_does_not_exist(self, junit4_hooks):\n junit_path = \"/no/jar/here/\" + _junit4_runner.JUNIT_JAR\n args = empty_args(junit_path=junit_path, hamcrest_path=HAMCREST_PATH)\n\n with pytest.raises(plug.PlugError) as exc_info:\n junit4_hooks.parse_args... | [
"0.7110956",
"0.673989",
"0.6660955",
"0.66515625",
"0.65470475",
"0.6524355",
"0.65017956",
"0.64401406",
"0.639584",
"0.63760686",
"0.6353104",
"0.6333339",
"0.6288438",
"0.62816596",
"0.6264847",
"0.6260693",
"0.6259397",
"0.6221644",
"0.61755407",
"0.61616945",
"0.6154064... | 0.0 | -1 |
Extract value from a pytorch tensor. | def unwrap(t):
if isinstance(t, torch.Tensor):
return t.item()
return t | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scalar(val: torch.Tensor):\n return val.item()",
"def value(self):\n if not self.isscalar():\n raise ValueError(\"value called on a non-scalar tensor.\")\n else:\n return self.defval",
"def get_value(self, indices):\r\n assert len(indices) == 3, indices\r\n ... | [
"0.7584539",
"0.680358",
"0.6726078",
"0.6689959",
"0.6441144",
"0.6416382",
"0.63908094",
"0.6346679",
"0.6310985",
"0.6286801",
"0.6278813",
"0.62407583",
"0.62171876",
"0.62007225",
"0.6190445",
"0.6089136",
"0.6016434",
"0.59737873",
"0.59241414",
"0.5919827",
"0.591872",... | 0.6603736 | 4 |
Generates a random string | def generator(size=6, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generateRandomString():\n return ''.join(b64encode(urandom(32)).decode('utf-8'))",
"def generate_random_string():\n return \"\".join(random.choice(string.ascii_lowercase + string.digits) for _ in range(16)) # nosec",
"def __generate_random_string():\n return uuid4().hex[:6].upper()",
"def g... | [
"0.85014915",
"0.8366145",
"0.8131259",
"0.80346197",
"0.7969227",
"0.79116094",
"0.7878069",
"0.7839492",
"0.77557343",
"0.77436584",
"0.77285564",
"0.77165174",
"0.77063763",
"0.7690905",
"0.7674214",
"0.76599663",
"0.7651333",
"0.7634878",
"0.7609182",
"0.7585954",
"0.7579... | 0.0 | -1 |
Write json to file. This function is for debugging purpose only. | def write_to_file(file_name, json_data):
in_tests.test_write_to_file_file_name(file_name)
in_tests.test_var_type(json_data, "json_data", (dict, list))
print(f" Writing json to `{file_name}`...")
try:
Path(file_name).parent.mkdir(parents=True, exist_ok=True)
except PermissionError:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self, _filepath=None):\n _json_txt = json.dumps(self.json_dict, indent=2)\n self._write_json_text(_json_txt, _filepath)",
"def _write_json(self):\n with open(self._file_path, 'w') as f:\n json.dump(self._content, f, indent=4, separators=None,\n encod... | [
"0.8343098",
"0.82871974",
"0.7876471",
"0.78309596",
"0.78165233",
"0.7802871",
"0.7802871",
"0.77876925",
"0.77738833",
"0.7746452",
"0.77296686",
"0.7711171",
"0.7703292",
"0.7697258",
"0.7642684",
"0.7596881",
"0.75781447",
"0.7571781",
"0.75679815",
"0.75622076",
"0.7522... | 0.7301848 | 46 |
Sets the learning rate to the initial LR decayed by 10 after args.lr_decay_step steps | def adjust_learning_rate(optimizer, args, epoch):
lr = args.learning_rate * (0.1 ** (epoch // args.lr_decay_step))
for param_group in optimizer.param_groups:
param_group['lr'] = lr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_learning_rate(self):\n\n if (self.FLAGS.learning_rate_decay is \"exponential\"):\n self.learning_rate = tf.train.exponential_decay(\n self.FLAGS.learning_rate,\n self.global_step,\n self.... | [
"0.7788797",
"0.7731507",
"0.7573828",
"0.7537865",
"0.75235254",
"0.75075626",
"0.75022215",
"0.74724704",
"0.74616647",
"0.74616647",
"0.7435772",
"0.7427893",
"0.7414677",
"0.74139524",
"0.7404863",
"0.739486",
"0.7387398",
"0.7381159",
"0.73613435",
"0.736105",
"0.7357521... | 0.7511394 | 5 |
Get the queue for the given task name | def get_queue(self, task_name):
for name, queue in self.queues.items():
if task_name in queue:
return name
return self.default_queue | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queue_by_name(name):\n sqs = boto3.resource('sqs')\n return sqs.get_queue_by_name(QueueName=name)",
"def get_by_name(task_name):\n return tasks.find_one({'name': task_name})",
"def getTask(self, name):\n for t in self.tasks:\n if isinstance(name, str):\n if t.n... | [
"0.76343167",
"0.71001387",
"0.70934874",
"0.70853627",
"0.6944676",
"0.68942785",
"0.68693787",
"0.68387425",
"0.6806787",
"0.68044204",
"0.67910147",
"0.66736746",
"0.6656947",
"0.66534805",
"0.66532665",
"0.6644332",
"0.6636157",
"0.66341865",
"0.6590256",
"0.65869015",
"0... | 0.89769137 | 0 |
Validate text autoformatting via autopep8, yapf or black. | def test_document_formatting(formatter, completions_codeeditor, qtbot):
code_editor, completion_plugin = completions_codeeditor
text, expected = get_formatter_values(formatter)
# After this call the manager needs to be reinitialized
CONF.set('completions',
('provider_configuration', 'lsp',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check(self, linter: Linter, cursor: Cursor, docstring: PetscDocStringImpl) -> None:\n super().check(linter, cursor, docstring)\n self._check_whitespace_formatting(docstring)\n return",
"def test_pep8(self):\n pep8style = pep8.StyleGuide(quiet=True)\n result = pep8style.check_files(['mo... | [
"0.6091317",
"0.60864246",
"0.60140675",
"0.59913146",
"0.59913146",
"0.59809816",
"0.59267676",
"0.58772355",
"0.5802408",
"0.5787021",
"0.5776831",
"0.5770846",
"0.5768626",
"0.572012",
"0.5695637",
"0.56947196",
"0.56771845",
"0.56616163",
"0.566089",
"0.56472653",
"0.5640... | 0.0 | -1 |
Check if there are queens on the board lying on a column which attack each other. This would happen if more than one queen lies on the same column on the board. | def multipleQueensAlongColumns(board):
(rows, columns) = (len(board), len(board[0]))
for column in range(columns):
count = 0
for row in range(rows):
if board[row][column] == 1:
count += 1
if count > 1:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isfree(col,queens):\n if col in queens:\n return False\n elif any([ abs(col-col1)==len(queens)-index for index,col1 in enumerate(queens)]):\n #c[r]==c[j]; r-j==c[r]-c[j]; r-j==c[j]-c[r]\n # col is the colomn to check; len(queens) just be the row index of col, dont subtract 1\n ... | [
"0.7543181",
"0.74735725",
"0.73940665",
"0.7185003",
"0.71080774",
"0.70699245",
"0.6982467",
"0.69613665",
"0.69524795",
"0.68901414",
"0.688677",
"0.687768",
"0.68603015",
"0.6845563",
"0.6841511",
"0.683381",
"0.683381",
"0.68275297",
"0.68275297",
"0.68232054",
"0.681022... | 0.7831585 | 0 |
Test the functionality of the `on_same_domain` function. It should return True if the URLs given are on the same domain, or False if they aren't. | def test_on_same_domain(self):
self.assertTrue(on_same_domain(
"https://google.com/a/b",
"http://sub-domain.google.com?time=0400"
)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_not_on_same_domain(self):\n self.assertFalse(on_same_domain(\n \"https://google.com\",\n \"https://google.goggle.com/google.com/google\"\n ))",
"def is_same_domain(url1, url2):\n return tldextract.extract(url1).domain == tldextract.extract(url2).domain",
"def sam... | [
"0.7675396",
"0.7381898",
"0.73564583",
"0.73101443",
"0.7293069",
"0.684061",
"0.6776624",
"0.6290789",
"0.6282609",
"0.6263146",
"0.6179027",
"0.60617447",
"0.60430825",
"0.5931026",
"0.5916494",
"0.5884555",
"0.58342385",
"0.58142614",
"0.5797016",
"0.56856847",
"0.5599009... | 0.80228186 | 0 |
Test the `on_same_domain` function returns false for two URLs which happen to be on different domains. | def test_not_on_same_domain(self):
self.assertFalse(on_same_domain(
"https://google.com",
"https://google.goggle.com/google.com/google"
)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_on_same_domain(self):\n self.assertTrue(on_same_domain(\n \"https://google.com/a/b\",\n \"http://sub-domain.google.com?time=0400\"\n ))",
"def is_same_domain(url1, url2):\n return tldextract.extract(url1).domain == tldextract.extract(url2).domain",
"def is_same_d... | [
"0.78632414",
"0.7516597",
"0.7492658",
"0.7477833",
"0.7451178",
"0.7025151",
"0.6820861",
"0.66619194",
"0.63043463",
"0.6222067",
"0.6196874",
"0.6125914",
"0.60356987",
"0.6034138",
"0.60099405",
"0.5993109",
"0.5981744",
"0.5955817",
"0.5875143",
"0.5775519",
"0.57747775... | 0.87000537 | 0 |
Convert time part of a datetime object into minutes | def get_minutes(self, datetime):
return datetime.hour*60.0+datetime.minute+datetime.second/60 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_minutes(time):\n return int(time / 60)",
"def timeToMinutes(timestamp):\n if len(timestamp) == 5: \n return int(timestamp[0])*600 + int(timestamp[1])*60 + int(timestamp[3])*10 + int(timestamp[4])\n return None",
"def MINUTE(time):\n return _make_datetime(time).minute",
"def con... | [
"0.7721607",
"0.7549755",
"0.74434644",
"0.7396315",
"0.7253915",
"0.7201473",
"0.7044733",
"0.69922626",
"0.6844657",
"0.66715306",
"0.6645723",
"0.66333866",
"0.6624911",
"0.6615479",
"0.6591979",
"0.65866977",
"0.6574264",
"0.65665936",
"0.65396136",
"0.6530093",
"0.649631... | 0.7865296 | 0 |
Convert time stamp to datetime | def parse_time_stamp(self, time_stamp):
# return iso8601.parse_date(time_stamp).replace(tzinfo=datetime.timezone.utc)
return iso8601.parse_date(time_stamp) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conv_time(stamp):\n value = datetime.fromtimestamp(stamp)\n return value.strftime('%Y-%m-%d %H:%M:%S')",
"def _timestamp_to_datetime(timestamp):\n return datetime.fromtimestamp(timestamp * 0.001, tz=timezone.utc)",
"def convert_timestamp(ts):\n format = '%Y-%m-%d %H:%M:%S'\n return datet... | [
"0.7251719",
"0.72310764",
"0.721382",
"0.70236796",
"0.7005531",
"0.68940043",
"0.6857499",
"0.6857158",
"0.6839591",
"0.6839152",
"0.6834405",
"0.6812984",
"0.67844856",
"0.6733536",
"0.67028576",
"0.6634553",
"0.66029686",
"0.6572502",
"0.6570248",
"0.6550068",
"0.6539681"... | 0.6550962 | 19 |
Computes topk accuracy for all values of k | def accuracy(output: Tensor, target: Tensor, topk: Iterable = (1,)) -> List[Tensor]:
maxk = max(topk)
batch_size = target.size(0)
_, pred = torch.topk(output, maxk, dim=1, largest=True, sorted=True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in top... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accuracy_topk(output, target, topk=(5,10)):\n maxk = max(topk)\n batch_size = target.size(0)\n\n _, pred = output.topk(maxk, 1, True, True)\n pred = pred.t()\n correct = pred.eq(target.view(1, -1).expand_as(pred))\n\n res = []\n for k in topk:\n correct_k = correct[:k].view(-1).floa... | [
"0.8161203",
"0.812069",
"0.8030977",
"0.7945338",
"0.7859936",
"0.7857365",
"0.78569627",
"0.7844462",
"0.7844462",
"0.7838626",
"0.7829203",
"0.78263384",
"0.7820126",
"0.78166324",
"0.7815025",
"0.7812451",
"0.7812451",
"0.7812451",
"0.7812451",
"0.7812451",
"0.7812451",
... | 0.0 | -1 |
Set model weights from a list of NumPy ndarrays. | def set_weights(model, weights: Weights) -> None:
state_dict = OrderedDict(
{k: torch.Tensor(np.atleast_1d(v)) for k, v in zip(model.state_dict().keys(), weights)}
)
model.load_state_dict(state_dict, strict=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_weights(self, weights):\r\n self.weights = weights.reshape(self.output_size, self.input_size+1)",
"def set_weights(self, weights):\n tuples = []\n for layer in self.layers:\n num_param = len(layer.weights)\n layer_weights = weights[:num_param]\n for sw, w in zip(layer.weights... | [
"0.7287452",
"0.720378",
"0.69648415",
"0.68350023",
"0.68350023",
"0.6832923",
"0.6671743",
"0.6636685",
"0.6602762",
"0.6557076",
"0.65108436",
"0.64079946",
"0.6388806",
"0.6365956",
"0.63073003",
"0.62976676",
"0.6257824",
"0.61736673",
"0.6138969",
"0.6133557",
"0.605531... | 0.5869625 | 26 |
Returns a list of all available categories for jokes | def all_categories(local):
categories = []
if local == True:
categories = list(map((lambda c: c.name), Category.all()))
else:
categories = jokes_api.categories()
click.echo(categories) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_categories(self):\n raise NotImplementedError()",
"def categories(self):\n game_categories = self.game_categories.all()\n return [ gc.category for gc in game_categories ]",
"def get_categories():\n try:\n result = {\n \"success\": True,\n \"categori... | [
"0.70718956",
"0.7055565",
"0.7025372",
"0.7023024",
"0.6946695",
"0.6923377",
"0.6890132",
"0.6855126",
"0.68485403",
"0.68349046",
"0.6823872",
"0.68035126",
"0.6794125",
"0.67746794",
"0.6709996",
"0.6683452",
"0.6656619",
"0.6642117",
"0.6640448",
"0.66313064",
"0.6626907... | 0.8009729 | 0 |
Stringify a file size in humanfriendly terms. | def size_str(num):
if num > 2 ** 30:
return "%0.2fGB" % (num / 2 ** 30)
elif num > 2 ** 20:
return "%0.2fMB" % (num / 2 ** 20)
elif num > 2 ** 10:
return "%0.2fkB" % (num / 2 ** 10)
else:
return "%d bytes" % num | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pretty_print_file_size(size: float) -> str:\n for x in [\"bytes\", \"KB\", \"MB\", \"GB\", \"TB\"]:\n if size < 1024.0:\n return f\"{size:3.1f} {x}\"\n size /= 1024.0\n return str(size)",
"def get_file_size_str(size):\n if size < 128: return f'{size}B' # only show bytes for ... | [
"0.84238297",
"0.80506366",
"0.79346746",
"0.78384817",
"0.7835554",
"0.7744606",
"0.7648322",
"0.75072217",
"0.7478509",
"0.7470998",
"0.7423861",
"0.7253696",
"0.72401667",
"0.7216826",
"0.72135454",
"0.7212507",
"0.7205664",
"0.7191572",
"0.71834743",
"0.71823585",
"0.7153... | 0.7511718 | 7 |
Helper function that strips SNAPPY suffixes for samples. | def only_source_name(full_name):
if full_name.count("-") >= 3:
tokens = full_name.split("-")
return "-".join(tokens[:-3])
else:
return full_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_samples(vr):\n return [name.split('.', 1)[0] for name in vr.samples]",
"def removesuffix(self, x) -> String:\n pass",
"def strip_suffix(s, suffixes):\n for suffix in suffixes:\n if s.endswith(suffix):\n return s.rstrip(suffix)\n return s",
"def test_strip_column_prefix... | [
"0.66986114",
"0.6041791",
"0.60292345",
"0.5969765",
"0.5866886",
"0.58508855",
"0.57409376",
"0.5634408",
"0.56153053",
"0.55746335",
"0.55290014",
"0.5499426",
"0.5485006",
"0.5480491",
"0.54698783",
"0.54557645",
"0.5394554",
"0.5351796",
"0.5341004",
"0.53018576",
"0.528... | 0.5115586 | 44 |
Return ``int``value sex for the given ``sample`` in ``pedigree``. | def get_sex(self, sample):
for line in self.pedigree:
if line["patient"] == sample:
return line["sex"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sex(sex):\n sex_m, sex_w = 0, 0\n if sex == \"w\":\n sex_w = 1\n if sex == \"m\":\n sex_m = 1\n\n return sex_m, sex_w",
"def _get_user_sex(user: User) -> Sex:\n return User.query.filter_by(id=user.id).first().sex",
"def recode_resend(sex_value):\n\tif sex_value == 'Male... | [
"0.56973296",
"0.54846776",
"0.5469207",
"0.53206444",
"0.5252537",
"0.5199721",
"0.5187707",
"0.51743245",
"0.5155948",
"0.508896",
"0.5058736",
"0.5040613",
"0.50268304",
"0.49879766",
"0.4986793",
"0.4895978",
"0.4880101",
"0.48252788",
"0.48157886",
"0.47743392",
"0.47419... | 0.77355 | 0 |
Return absolute URL for the detail view of this case. | def get_absolute_url(self):
return reverse(
"variants:case-detail",
kwargs={"project": self.project.sodar_uuid, "case": self.sodar_uuid},
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_absolute_url(self):\n return reverse('model-detail-view', args=[str(self.id)])",
"def get_absolute_url(self):\n return reverse('model-detail-view', args=[str(self.id)])",
"def get_absolute_url(self):\n return reverse(\"jewelry_detail\", args = [str(self.id)])",
"def get_absolute_... | [
"0.82196677",
"0.82196677",
"0.8127263",
"0.8033525",
"0.79573077",
"0.79555786",
"0.79096377",
"0.7848949",
"0.7843553",
"0.7840721",
"0.7835712",
"0.7831441",
"0.7823432",
"0.77770233",
"0.777177",
"0.77505463",
"0.7738156",
"0.77301276",
"0.77274215",
"0.77175987",
"0.7701... | 0.77647483 | 15 |
Return het./hom. ratio on chrX for ``sample``. | def chrx_het_hom_ratio(self, sample):
try:
variant_set = self.latest_variant_set
if not variant_set:
return -1
else:
sample_stats = variant_set.variant_stats.sample_variant_stats.get(
sample_name=sample
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chrx_het_hom_ratio(self, sample):\n case = self.sample_to_case().get(sample)\n if not case:\n return 0.0\n else:\n return case.chrx_het_hom_ratio(sample)",
"def test_rh_mixing_ratio():\n p = 1013.25 * units.mbar\n temperature = 20. * units.degC\n w = 0.012 ... | [
"0.8137299",
"0.58489174",
"0.58479124",
"0.5702655",
"0.55716866",
"0.5521785",
"0.549853",
"0.5442392",
"0.5435246",
"0.54341346",
"0.5417821",
"0.54079825",
"0.53776604",
"0.53688204",
"0.53670436",
"0.5362167",
"0.5355255",
"0.5337289",
"0.53318447",
"0.53002083",
"0.5291... | 0.7672608 | 1 |
Shorten ``text`` to ``max_chars`` characters if longer. | def shortened_notes_text(self, max_chars=50):
if len(self.notes) > max_chars:
return self.notes[:max_chars] + "..."
else:
return self.notes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shortened_text(self, max_chars=50):\n if len(self.text) > max_chars:\n return self.text[:max_chars] + \"...\"\n else:\n return self.text",
"def truncate(text: str = \"\", max_len: int = 50) -> str:\n return text if len(text) < max_len else text[:max_len]",
"def _trunc... | [
"0.81508243",
"0.74331146",
"0.7375322",
"0.73616964",
"0.735186",
"0.7239252",
"0.71748984",
"0.69174826",
"0.67670983",
"0.6737731",
"0.6695401",
"0.6640852",
"0.6619495",
"0.6559657",
"0.65574646",
"0.6411755",
"0.63624376",
"0.62897474",
"0.62751883",
"0.6255699",
"0.6079... | 0.69486713 | 7 |
Shorten ``text`` to ``max_chars`` characters if longer. | def shortened_text(self, max_chars=50):
if len(self.comment) > max_chars:
return self.comment[:max_chars] + "..."
else:
return self.comment | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shortened_text(self, max_chars=50):\n if len(self.text) > max_chars:\n return self.text[:max_chars] + \"...\"\n else:\n return self.text",
"def truncate(text: str = \"\", max_len: int = 50) -> str:\n return text if len(text) < max_len else text[:max_len]",
"def _trunc... | [
"0.81508243",
"0.74331146",
"0.7375322",
"0.73616964",
"0.735186",
"0.71748984",
"0.69486713",
"0.69174826",
"0.67670983",
"0.6737731",
"0.6695401",
"0.6640852",
"0.6619495",
"0.6559657",
"0.65574646",
"0.6411755",
"0.63624376",
"0.62897474",
"0.62751883",
"0.6255699",
"0.607... | 0.7239252 | 5 |
Shorten ``text`` to ``max_chars`` characters if longer. | def shortened_text(self, max_chars=50):
if len(self.text) > max_chars:
return self.text[:max_chars] + "..."
else:
return self.text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def truncate(text: str = \"\", max_len: int = 50) -> str:\n return text if len(text) < max_len else text[:max_len]",
"def _truncate_string(self, text, max_size):\n import textwrap\n\n if len(text) <= max_size:\n return text\n return textwrap.wrap(text, max_size-3)[0] + \"...\""... | [
"0.7433514",
"0.73762196",
"0.7362364",
"0.7352537",
"0.7238451",
"0.717513",
"0.6948463",
"0.69172263",
"0.6767947",
"0.6737989",
"0.6695083",
"0.664076",
"0.6618207",
"0.65601224",
"0.6557214",
"0.64129096",
"0.63612473",
"0.6288558",
"0.6275656",
"0.62556547",
"0.6081927",... | 0.8150601 | 0 |
Return true if no flags are set and the model can be deleted. | def no_flags_set(self):
# TODO: unit test me
return not any(
(
self.flag_bookmarked,
self.flag_candidate,
self.flag_final_causative,
self.flag_for_validation,
self.flag_molecular != "empty",
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_delete(self):\r\n return True",
"def has_delete_permission(self, request, obj=None):\r\n return False",
"def can_fast_delete(self, *args, **kwargs):\n return False",
"def has_delete_permission(self, request, obj=None):\n return False",
"def has_delete_permission(self, re... | [
"0.7620562",
"0.70751935",
"0.70427245",
"0.6986205",
"0.6986205",
"0.6955778",
"0.6924368",
"0.6896284",
"0.68844134",
"0.6858396",
"0.6839724",
"0.6814502",
"0.67255145",
"0.67234",
"0.6702387",
"0.66745067",
"0.6631508",
"0.65386313",
"0.6518957",
"0.6512865",
"0.6464405",... | 0.5711179 | 66 |
Return whether prioritization is enabled in this query. | def is_prioritization_enabled(self):
return all(
(
self.query_settings.get("prio_enabled"),
self.query_settings.get("prio_algorithm"),
self.query_settings.get("prio_hpo_terms", []),
)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_priority(self):\n return False",
"def has_priority ( self ):\n return self.priority is not None and self.priority >= 0",
"def isSetPriority(self):\n return _libsbml.Event_isSetPriority(self)",
"def run_precondition(self) -> bool:\n return self._does_apply",
"def enabled(se... | [
"0.5998744",
"0.58560574",
"0.5708423",
"0.56286",
"0.56111073",
"0.56111073",
"0.56111073",
"0.56111073",
"0.56111073",
"0.56111073",
"0.56111073",
"0.56111073",
"0.5592923",
"0.5592923",
"0.5592923",
"0.5592923",
"0.5592923",
"0.5592923",
"0.55900127",
"0.55231154",
"0.5518... | 0.8691473 | 0 |
Function to extract a number out from a string which contains it. | def get_number(x):
return re.findall(r'\d+', x)[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_number(self, string):\n #string = string.encode('ascii', 'ignore')\n #return int(filter(str.isdigit, string))\n s = (re.findall('\\d+', string))\n return int(''.join(s))",
"def getNumFromString(self, string):\n \n m = re.search(r'\\d+$', string)\n if m is not... | [
"0.8072367",
"0.75418496",
"0.75144076",
"0.7496383",
"0.7478208",
"0.73512137",
"0.72836953",
"0.72720057",
"0.7259342",
"0.7220392",
"0.70938265",
"0.7034191",
"0.6942942",
"0.6891903",
"0.68245727",
"0.6779717",
"0.676908",
"0.6764738",
"0.67459965",
"0.66962653",
"0.66961... | 0.7736045 | 1 |
Function to remove redundant whitespaces in input string. | def remove_extra_middle_spaces(x):
return " ".join(x.split()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_white_spaces(input_string):\n return re.sub(r'\\s+', ' ', input_string).strip()",
"def _clean(s):\n return re.sub(r'\\s+', ' ', s.strip())",
"def space_strip(string):\n string= re.sub(\"(?m)^\\s+\", \"\", string)\n return re.sub(\"(?m)\\s+$\", \"\", string)",
"def strip... | [
"0.8103806",
"0.80929846",
"0.7894493",
"0.78638357",
"0.7787533",
"0.769301",
"0.7564099",
"0.7520941",
"0.7483926",
"0.74709374",
"0.7388469",
"0.7385829",
"0.7383737",
"0.7365095",
"0.735388",
"0.7318697",
"0.73082674",
"0.73073363",
"0.7289824",
"0.7278208",
"0.72732025",... | 0.7069948 | 40 |
Converts a pytorch tensor into an image | def to_img(t):
return torchvision.transforms.ToPILImage()(t) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_image(tensor):\n # Converts to PIL image\n unloader = transforms.ToPILImage()\n # Clone the tensor to CPU\n image = tensor.cpu().clone()\n # Remove fake batch dimension\n image = image.squeeze(0)\n # Convert to PIL image\n image = unloader(image)\n return image",
"def tensor_to_... | [
"0.80810976",
"0.8067614",
"0.78449786",
"0.7781439",
"0.75836545",
"0.7562613",
"0.7443037",
"0.73652774",
"0.73300713",
"0.72115",
"0.71705633",
"0.7156045",
"0.6914949",
"0.6898882",
"0.68391126",
"0.68168753",
"0.6816416",
"0.681472",
"0.6780448",
"0.67406064",
"0.6735992... | 0.78766614 | 2 |
Test exception is raised if the array variable shape is incorrect | def test_invalid_array_shape(self, parse_input_mocked_metadata):
with pytest.raises(
BlackbirdSyntaxError, match=r"has declared shape \(1, 2\) but actual shape \(2, 2\)"
):
parse_input_mocked_metadata(
"complex array A[1, 2] =\n\t-1.0+1.0j, 2.7e5+0.2e-5j\n\t-0.1-2... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_shape(self, varname, varshape, ndim): \n if len(varshape) != ndim:\n raise ShapeError('Shape=%s. Expected %i-D array for %s' %\n (repr(varshape), ndim, varname))",
"def test_check_X_too_many_dims():\n with pytest.raises(ValueError):\n check_X(np.o... | [
"0.79647946",
"0.7354592",
"0.73433805",
"0.7172847",
"0.710498",
"0.70463026",
"0.6996874",
"0.6956707",
"0.6945625",
"0.69218117",
"0.6918826",
"0.6914766",
"0.68975747",
"0.6890942",
"0.6889408",
"0.6883319",
"0.6879904",
"0.6877337",
"0.6861965",
"0.6856137",
"0.6851369",... | 0.70921874 | 5 |
Sets and returns the `end_timestamp` of an index based on the timeranges of the documents present inside it. | def __update_index_timerange(self, index, index_id):
index_name = index + "_" + str(index_id)
target_config = index + ".target_config"
begin_timestamp = self.client.get(
index=target_config, doc_type="config", id=index_id
)["_source"]["begin_timestamp"]
end_timestam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_time_stamp(self, end_time_stamp):\n\n self._end_time_stamp = end_time_stamp",
"def end_timestamp(self):\n return ms_from_dt(self.range().end())",
"def set_index_last_started_at(self, index_db_name: str, timestamp: int) -> None:\n attr_name = INDEX_ATTR_PREFIX + index_db_name\n ... | [
"0.6461551",
"0.6408989",
"0.61016816",
"0.60159326",
"0.58986825",
"0.5893411",
"0.5893411",
"0.5893411",
"0.5844481",
"0.5844481",
"0.5759401",
"0.5744888",
"0.57037157",
"0.5619158",
"0.5611337",
"0.559081",
"0.5590375",
"0.5590375",
"0.5590375",
"0.5590375",
"0.5590375",
... | 0.7659367 | 0 |
Closes connection with the elasticsearch server. | def shutdown(self):
ts.client.transport.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Close(self):\n self._elastic_db.bulk_index(self._index_name, self._doc_type, self._data)\n self._data = []\n sys.stdout.write(u'. [DONE]\\n')\n sys.stdout.write(u'ElasticSearch index name: {0:s}\\n'.format(\n self._index_name))\n sys.stdout.flush()",
"def close(self):\n self.inde... | [
"0.7196958",
"0.6859846",
"0.6448358",
"0.6437342",
"0.64199823",
"0.6403143",
"0.63199496",
"0.62505233",
"0.6234385",
"0.6211198",
"0.6185643",
"0.6175678",
"0.6136868",
"0.6133922",
"0.6133922",
"0.6133922",
"0.6133922",
"0.6133922",
"0.6133922",
"0.6133922",
"0.61247367",... | 0.58992136 | 50 |
Backward pass for a single timestep of a vanilla RNN. | def rnn_step_backward(dnext_h, cache):
dx, dprev_h, dWx, dWh, db = None, None, None, None, None
##############################################################################
# TODO: Implement the backward pass for a single step of a vanilla RNN. #
# ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backward_pass(self, grad):\n pass",
"def backward_and_step(self, loss):\n self.opt.zero_grad()\n loss.backward()\n self.opt.step()",
"def backward(self, dout):\n \n ########################\n # PUT YOUR CODE HERE #\n #######################\n for l in range(len(s... | [
"0.72582924",
"0.7152384",
"0.7079535",
"0.70364827",
"0.68903387",
"0.6878717",
"0.6846149",
"0.6846149",
"0.68310696",
"0.68124175",
"0.67877245",
"0.67877245",
"0.6688241",
"0.6681934",
"0.6673654",
"0.66715366",
"0.66653323",
"0.66482764",
"0.65927064",
"0.6512077",
"0.65... | 0.6861673 | 6 |
Compute the backward pass for a vanilla RNN over an entire sequence of data. | def rnn_backward(dh, cache):
dx, dh_prev, dWx, dWh, db = None, None, None, None, None
##############################################################################
# TODO: Implement the backward pass for a vanilla RNN running an entire #
# sequence of data. You should use the rnn_step_backward function th... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backward_pass(self):\r\n # the gradient of cross-entropy on top of softmax is (t-y)\r\n back_output = (self.targets - self.y) / self.y.shape[0]\r\n\r\n for layer in reversed(self.layers):\r\n back_output = layer.backward_pass(back_output)",
"def backward(self, loss):\n ... | [
"0.70729333",
"0.69903165",
"0.6958207",
"0.6950155",
"0.6916186",
"0.6916186",
"0.68856996",
"0.6878103",
"0.6838837",
"0.6783538",
"0.6783538",
"0.6774044",
"0.67555124",
"0.6736983",
"0.66960055",
"0.6673998",
"0.6634201",
"0.6626266",
"0.6618638",
"0.6590171",
"0.65611655... | 0.7060489 | 1 |
Backward pass for word embeddings. We cannot backpropagate into the words since they are integers, so we only return gradient for the word embedding matrix. | def word_embedding_backward(dout, cache):
dW = None
##############################################################################
# TODO: Implement the backward pass for word embeddings. #
# #
# HINT: Look up the f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backward(self, gradient: Tensor) -> Tensor:\n self.b_grad = np.sum(gradient, axis=0)\n self.w_grad = self.inputs.T @ gradient\n return gradient @ self.w.T",
"def _backward(self, w=None):\n grad = self.w # Should be I * self.w . We keep a vector for simplicity\n\n # Left mu... | [
"0.6913785",
"0.6864387",
"0.68118054",
"0.67654765",
"0.66550833",
"0.6651812",
"0.65430754",
"0.65046024",
"0.6402917",
"0.6379707",
"0.6260643",
"0.6242716",
"0.62360924",
"0.62360924",
"0.6209998",
"0.61673504",
"0.6162195",
"0.6140693",
"0.61107767",
"0.6088412",
"0.6079... | 0.7696244 | 0 |
A numerically stable version of the logistic sigmoid function. | def sigmoid(x):
pos_mask = (x >= 0)
neg_mask = (x < 0)
z = np.zeros_like(x)
z[pos_mask] = np.exp(-x[pos_mask])
z[neg_mask] = np.exp(x[neg_mask])
top = np.ones_like(x)
top[neg_mask] = z[neg_mask]
return top / (1 + z) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid(x):\n return 1 / (1 + math.exp(-x))",
"def sigmoid(x):\n return 1 / (1 + exp(-x))",
"def sigmoid(x):\n return 1 / (1 + exp(-x))",
"def sigmoid(x):\n return 1 / (1 + math.exp(-x))",
"def sigmoid(x):\n\n return 1 / (1 + math.exp(-x))",
"def sigmoid(x):\n\n return 1 / (1 + math.e... | [
"0.84727824",
"0.8418851",
"0.8418851",
"0.8418648",
"0.8406039",
"0.8406039",
"0.8395496",
"0.83875006",
"0.8354437",
"0.83412933",
"0.83412933",
"0.83412933",
"0.83412933",
"0.83412933",
"0.83412933",
"0.83299893",
"0.83146125",
"0.83126956",
"0.83046055",
"0.82958627",
"0.... | 0.7900994 | 46 |
Forward pass for a single timestep of an LSTM. The input data has dimension D, the hidden state has dimension H, and we use a minibatch size of N. | def lstm_step_forward(x, prev_h, prev_c, Wx, Wh, b):
next_h, next_c, cache = None, None, None
#############################################################################
# TODO: Implement the forward pass for a single timestep of an LSTM. #
# You may want to use the numerically stable sigmoid implement... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, x):\n x = tensor(x).unsqueeze(1)\n x = self.cnn(x)\n\n # LSTM from here\n batch_size = x.shape[0]\n x = x.view(batch_size, x.shape[1] * x.shape[2], x.shape[3])\n x = x.permute(2, 0, 1) # Converting from (B,H,W)->(W,B,H)\n\n output = self.rnn(x)\n ... | [
"0.65560275",
"0.6527141",
"0.650994",
"0.64725894",
"0.64116424",
"0.63977146",
"0.6358227",
"0.63299626",
"0.6287189",
"0.6260743",
"0.62393874",
"0.6220493",
"0.621685",
"0.62128496",
"0.61926734",
"0.61668944",
"0.6158258",
"0.61381185",
"0.61255854",
"0.6092533",
"0.6067... | 0.6127442 | 18 |
Backward pass for a single timestep of an LSTM. | def lstm_step_backward(dnext_h, dnext_c, cache):
dx, dh, dc, dWx, dWh, db = None, None, None, None, None, None
#############################################################################
# TODO: Implement the backward pass for a single timestep of an LSTM. #
# ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backward_and_step(self, loss):\n self.opt.zero_grad()\n loss.backward()\n self.opt.step()",
"def lstm_backward(dh, cache):\n dx, dh_prev, dWx, dWh, db = None, None, None, None, None\n #############################################################################\n # TODO: Implement the... | [
"0.68590873",
"0.6858795",
"0.6654086",
"0.65926987",
"0.6581532",
"0.65500206",
"0.65103906",
"0.6488392",
"0.64483684",
"0.64483684",
"0.6402425",
"0.6387275",
"0.6381484",
"0.63745767",
"0.63502514",
"0.62679964",
"0.6267557",
"0.61945623",
"0.61945623",
"0.61814624",
"0.6... | 0.6397221 | 11 |
Backward pass for temporal affine layer. | def temporal_affine_backward(dout, cache):
x, w, b, out = cache
N, T, D = x.shape
M = b.shape[0]
dx = dout.reshape(N * T, M).dot(w.T).reshape(N, T, D)
dw = dout.reshape(N * T, M).T.dot(x.reshape(N * T, D)).T
db = dout.sum(axis=(0, 1))
return dx, dw, db | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def temporal_affine_forward(x, w, b):\n N, T, D = x.shape\n M = b.shape[0]\n out = x.reshape(N * T, D).dot(w).reshape(N, T, M) + b\n cache = x, w, b, out\n return out, cache",
"def affine_backward(dout, cache):\n x, w, b = cache\n dx, dw, db = None, None, None\n ####################################... | [
"0.6915407",
"0.6892761",
"0.6835825",
"0.6770653",
"0.6764108",
"0.6697073",
"0.6653632",
"0.6648822",
"0.6611196",
"0.6605598",
"0.654563",
"0.6542562",
"0.6526736",
"0.6525348",
"0.65199816",
"0.6436225",
"0.63633186",
"0.6347031",
"0.63444525",
"0.63386923",
"0.63370657",... | 0.7352023 | 0 |
Using empty value to the animal_name field | def test_invalid_animal_form(self):
data = {'owner': 1, 'specie': 1, 'breed': 1, 'animal_name': ''}
form = AddAnimalForm(data=data)
self.assertFalse(form.is_valid()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_name_empty_string(self):\r\n self.name = \"\"",
"def sanitize_name(self):\n self._name = self.get_name().strip()",
"def validate_allow_empty(cls, value: str, field: ModelField) -> str:\n if cls.allow_empty is False:\n if isinstance(value, str) and value == '':\n ... | [
"0.6312162",
"0.58489394",
"0.5671751",
"0.5647709",
"0.56220937",
"0.5548289",
"0.5514891",
"0.5487807",
"0.548247",
"0.54614806",
"0.54554504",
"0.54278016",
"0.54191005",
"0.53465295",
"0.53429985",
"0.53382736",
"0.5315729",
"0.53024226",
"0.5300356",
"0.5298862",
"0.5296... | 0.0 | -1 |
Returns unique identifier for an ePortfolio element in a presentation. | def get_epo_id(href):
beginIndex = href.find("contextId=") + len("contextId=")
epoId = href[beginIndex:]
endIndex = 0
nextCharacter = epoId[endIndex]
while nextCharacter.isdigit():
endIndex += 1
nextCharacter = epoId[endIndex]
epoId = epoId[:endIndex]
return epoId | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ews_pid (tag):\n\n return mapitags.PROP_ID(tag)",
"def get_semeval_id(element):\n translation = {'OrgQuestion': 'ORGQ_ID',\n 'RelQuestion': 'RELQ_ID',\n 'RelComment': 'RELC_ID',\n 'Thread': 'THREAD_SEQUENCE'}\n\n if element.tag in translation.key... | [
"0.6081418",
"0.5944249",
"0.590192",
"0.57796675",
"0.5766189",
"0.57641715",
"0.56975377",
"0.56718504",
"0.5650378",
"0.5633759",
"0.56181186",
"0.5609371",
"0.5583731",
"0.5568214",
"0.556619",
"0.55494165",
"0.553792",
"0.55215967",
"0.5505821",
"0.5505749",
"0.5478907",... | 0.0 | -1 |
Returns fileDict updated with addresses of CSS files linked to in a single presentation page. fileDict['css'] list will be populated with any CSS links found. | def get_css(soup, fileDict):
for link in soup.findAll('link'):
if link['type'] == 'text/css':
css = DOMAIN + link['href']
if css not in fileDict['cssUrls']:
fileDict['cssUrls'].append(css)
fileName = css[css.rfind("/") + 1:]
if f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populate_file_dict(epObject, uc, fileDict):\r\n fileDict = get_pages(epObject, fileDict)\r\n for url in fileDict['pageUrls']:\r\n soup = make_soup(url)\r\n fileDict = get_embedded_object(soup, fileDict, uc)\r\n fileDict = get_css(soup, fileDict)\r\n fileDict = get_img(soup, fi... | [
"0.64324707",
"0.638212",
"0.6073951",
"0.5862082",
"0.54049224",
"0.54007274",
"0.54007274",
"0.54007274",
"0.54007274",
"0.54007274",
"0.54007274",
"0.54007274",
"0.54007274",
"0.53514725",
"0.5321237",
"0.5313228",
"0.53112847",
"0.5286774",
"0.52571046",
"0.52370054",
"0.... | 0.78971934 | 0 |
Returns fileDict populated with information from all pages of an ePortfolio presentation. | def populate_file_dict(epObject, uc, fileDict):
fileDict = get_pages(epObject, fileDict)
for url in fileDict['pageUrls']:
soup = make_soup(url)
fileDict = get_embedded_object(soup, fileDict, uc)
fileDict = get_css(soup, fileDict)
fileDict = get_img(soup, fileDict, uc)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pages(epObject, fileDict):\r\n homePage = DOMAIN + epObject.ViewLink\r\n soup = make_soup(homePage)\r\n fileDict['pageUrls'].append(homePage)\r\n fileDict['pageFileNames'].append('index.html')\r\n fileDict['pageIds'].append(str(epObject.ObjectId))\r\n for a in soup.find_all('a', {'href': ... | [
"0.6529201",
"0.6192074",
"0.6181265",
"0.59622926",
"0.57342136",
"0.56897587",
"0.5643427",
"0.552843",
"0.55221504",
"0.5504497",
"0.54564756",
"0.53980297",
"0.5396478",
"0.5340109",
"0.53232574",
"0.53102314",
"0.5309218",
"0.5258261",
"0.5247129",
"0.52229065",
"0.51806... | 0.675591 | 0 |
Erase black lines between squares of the same color. | def undrawGrid(draw,points,coeff2,newColorArray):
## This is the merge function.
## If two neighboring regions are considered to be the same color by the comparison function then this function replaces the black line between them by a line of their color (making it invisible).
for j in range(0,coeff2-1):... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_colors(self):\n for r in range(0, self.maze.get_nrows()):\n for c in range(0, self.maze.get_ncols()):\n self.set_color((r, c), 'white', draw=False)\n\n self.cvs.itemconfig(self.cvs_cells[self.maze.get_start_cell()],\n fill='green')\n self.cvs.... | [
"0.64504504",
"0.62295645",
"0.6149258",
"0.61013377",
"0.60835075",
"0.6080292",
"0.6035723",
"0.59870344",
"0.5969807",
"0.59518147",
"0.58792615",
"0.58362234",
"0.5825922",
"0.5796501",
"0.5759481",
"0.5727319",
"0.5723786",
"0.57192534",
"0.5689627",
"0.5681141",
"0.5652... | 0.586527 | 11 |
Split [a, b] into 256 intervals according to probs. Return the byteth interval. | def update_interval(a, b, probs, byte):
mask = (1 << WIDTH) - 1
assert 0 <= a <= mask
assert 0 <= b <= mask
total_length = b - a + 1
assert total_length >= 256
assert probs.shape == (256,)
assert np.all(probs >= 0)
assert np.abs(np.sum(probs) - 1) < 1e-6
assert 0 <= byte <= 0xFF
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _split_byte(bs):\n mask_msb = 0b11110000\n mask_lsb = 0b00001111\n\n return (mask_msb & bs[0]) >> 4, mask_lsb & bs[0]",
"def interval_split(a,b,split_ps):\n ps = [a] + [s for s in sorted(split_ps) if a < s < b] + [b]\n return [(p1,p2) for p1,p2 in zip(ps,ps[1:])]",
"def interval(a, b):\n ... | [
"0.64698666",
"0.62370646",
"0.5770937",
"0.5682076",
"0.5535789",
"0.54863566",
"0.5483383",
"0.5442545",
"0.5432423",
"0.5371568",
"0.53450674",
"0.53208226",
"0.52739084",
"0.5259421",
"0.52381694",
"0.5221875",
"0.5216687",
"0.5206564",
"0.5165214",
"0.513279",
"0.5124638... | 0.70963776 | 0 |
Returns a dictionary of edge cases that fuzzywuzzy is unable to catch. This could be because PRIS database stores reactor names and Webscrape database fetches power plant names, or because PRIS reactor names are abbreviated. | def edge_cases():
pris_edge_cases = {'OHI-': 'Ōi',
'ASCO-': 'Ascó',
'ROVNO-': 'Rivne',
'SHIN-KORI-': 'Kori',
'ANO-': 'Arkansas One',
'HANBIT-': 'Yeonggwang',
'FERMI-': 'Enrico Fermi',
'BALTIC-': 'Kaliningrad',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_police_abbreviations(self):\n for word in self.report.get_words():\n for uword in self.rules.police_abbreviations:\n if uword[\"word\"] == word.text.lower():\n self.add_error(\n f\"{word.text} är en intern förkortning. \"\n ... | [
"0.53449327",
"0.51897705",
"0.51325065",
"0.5116838",
"0.5088508",
"0.5081386",
"0.5049337",
"0.5041673",
"0.50361735",
"0.50239676",
"0.49804512",
"0.49278393",
"0.49141613",
"0.49036273",
"0.48860916",
"0.48609376",
"0.48584527",
"0.48489895",
"0.48077416",
"0.4804405",
"0... | 0.58624643 | 0 |
Check to see if tag creation is allowed by everyone or just Administrators. | def tag_check():
async def check(ctx):
if ctx.author.id == ctx.bot.owner_id:
return True
is_allowed = (
ctx.author.guild_permissions.administrator
or await ctx.bot.get_guild_setting(ctx.guild.id, "tag_creation_allowed")
)
if is_allowed:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cog_check(self, ctx):\n return ctx.author.guild_permissions.administrator",
"def cog_check(self, ctx):\r\n return ctx.author.guild_permissions.administrator",
"def cog_check(self, ctx):\r\n return ctx.author.guild_permissions.administrator",
"def test_permissions(self):\n taxo... | [
"0.7189031",
"0.71729326",
"0.71729326",
"0.6948009",
"0.65706396",
"0.6540863",
"0.6524014",
"0.64952034",
"0.64891326",
"0.64891326",
"0.64051026",
"0.639966",
"0.639441",
"0.6376342",
"0.6366205",
"0.63501805",
"0.63453174",
"0.6342421",
"0.62872505",
"0.6284981",
"0.62813... | 0.75933444 | 0 |
Returns the name of the entity. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entity_name(self):\n return self.__entity_name",
"def entity_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"entity_name\")",
"def entity_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"entity_name\")",
"def get_entity_name() -> str:\n return \"NewsIt... | [
"0.89739835",
"0.8291558",
"0.8291558",
"0.7967351",
"0.7880483",
"0.7533299",
"0.7487097",
"0.7487097",
"0.7487097",
"0.7478316",
"0.74730295",
"0.7465874",
"0.745873",
"0.7451315",
"0.7436373",
"0.74336773",
"0.74258566",
"0.7410182",
"0.74037564",
"0.7396105",
"0.7396105",... | 0.0 | -1 |
Returns the state attributes. | def state_attributes(self):
attrs = {}
if self._last_action:
attrs[ATTR_LAST_ACTION] = self._last_action
return attrs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_attributes(self):\n return self._attributes",
"def state_attributes(self):\n return self._attributes",
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\n return self._state_attrs",
"def device_state_attributes(self):\... | [
"0.89359796",
"0.89359796",
"0.85107046",
"0.83974403",
"0.83974403",
"0.8381539",
"0.8357211",
"0.8352963",
"0.8327151",
"0.8313749",
"0.8313749",
"0.8313749",
"0.8313749",
"0.8313749",
"0.8313749",
"0.8313749",
"0.8313749",
"0.8313749",
"0.8313749",
"0.8313749",
"0.8313749"... | 0.7832778 | 37 |
True if entity is on. | def is_on(self):
return self._cur != -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_on(self) -> bool:\n return self.entity_description.is_on_fn(self._client)",
"def is_on(self) -> bool:\n return self.entity_description.state_fn(self._valve)",
"def is_on(hass, entity_id):\n return hass.states.is_state(entity_id, STATE_ON)",
"def is_on(self) -> bool:\n return se... | [
"0.85561126",
"0.82328606",
"0.80042636",
"0.7902383",
"0.7902383",
"0.7623602",
"0.7474469",
"0.74592996",
"0.74592996",
"0.74592996",
"0.74592996",
"0.74592996",
"0.74424726",
"0.7378187",
"0.7366283",
"0.7366283",
"0.7366283",
"0.7366283",
"0.7366283",
"0.7366283",
"0.7366... | 0.0 | -1 |
True if isinstance, False otherwise | def is_kind_of_class(obj, a_class):
if isinstance(obj, a_class):
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _isinstance(cls, x):\n return isinstance(x, cls.PYTHON_TYPE_CHECK)",
"def verify_type(self, obj):\n return isinstance(obj, self.type_)",
"def _isinstancetype(an_obj):\n if an_obj is None: return False\n if not PY3K:\n return isinstance(an_obj, types.InstanceType)\n typstr = st... | [
"0.81197107",
"0.7646734",
"0.7633899",
"0.75826496",
"0.7554565",
"0.7511596",
"0.7448276",
"0.7433479",
"0.7361052",
"0.73368466",
"0.7322956",
"0.7301687",
"0.7288201",
"0.7260252",
"0.7247967",
"0.7247967",
"0.7247967",
"0.7247967",
"0.7247967",
"0.7247967",
"0.7238835",
... | 0.7287103 | 13 |
Calculate tree balance factor | def update_balances(self, recursive=True):
if self.node:
if recursive:
if self.node.left:
self.node.left.update_balances()
if self.node.right:
self.node.right.update_balances()
self.balance = self.node.left.height -... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def balance(self):\n if self.val is None:\n return 0\n return self.left.depth() - self.right.depth()",
"def getBalanceFactor(self):\n \n return (self._leftSubtreeHeight - self._rightSubtreeHeight)",
"def calc_balance(self, node):\n if node is None:\n ret... | [
"0.74981624",
"0.7408132",
"0.73375696",
"0.72003835",
"0.71872187",
"0.6998073",
"0.6910783",
"0.6778254",
"0.6775765",
"0.6665928",
"0.66523194",
"0.65350187",
"0.6526495",
"0.6463097",
"0.6443356",
"0.6345919",
"0.63396966",
"0.6287024",
"0.62583756",
"0.62203145",
"0.6204... | 0.66265154 | 11 |
Initializes the learning rate scheduler. | def _initScheduler(self) -> torch.optim.lr_scheduler.ReduceLROnPlateau:
return torch.optim.lr_scheduler.ReduceLROnPlateau(
self.optimizer,
mode=cfg.training.scheduler_mode,
factor=cfg.training.scheduler_factor,
patience=cfg.training.scheduler_patience,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_scheduler(self):\n gamma = self.config_dict.get(\"gamma\")\n if gamma is None:\n return None\n else:\n return torch.optim.lr_scheduler.ExponentialLR(self.optimizer, gamma=gamma)",
"def lr_scheduler(self, lr_init, global_step):\n pass",
"def _init_sched... | [
"0.7515188",
"0.7386347",
"0.69720066",
"0.69185364",
"0.69084096",
"0.68611956",
"0.6847927",
"0.68258727",
"0.672815",
"0.66976935",
"0.66707605",
"0.66707605",
"0.66293746",
"0.65914106",
"0.6558425",
"0.65398073",
"0.6538176",
"0.65199757",
"0.6494307",
"0.64880794",
"0.6... | 0.7085269 | 2 |
Creates a ball that starts in the middle of screen | def __init__(self):
self.x = int(constants.SCREEN_WIDTH/2)
self.y = int(constants.SCREEN_HEIGHT/2)
self.DX = self.getRandSpeed()
self.DY = self.getRandSpeed()
self.RADIUS = 5 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_ball():\n ball = Ball()\n # Starting position of the ball.\n # Take into account the ball size so we don't spawn on the edge.\n ball.x = random.randrange(BALL_SIZE, SCREEN_WIDTH - BALL_SIZE)\n ball.y = random.randrange(BALL_SIZE, SCREEN_HEIGHT - BALL_SIZE)\n\n # Speed and direction of re... | [
"0.77228105",
"0.7665498",
"0.73436254",
"0.7242733",
"0.7199887",
"0.71788865",
"0.7137445",
"0.7125304",
"0.7099498",
"0.7044389",
"0.70418036",
"0.701051",
"0.69794995",
"0.69492346",
"0.69344366",
"0.68432426",
"0.6842423",
"0.6751062",
"0.67364484",
"0.6718706",
"0.67182... | 0.59355754 | 71 |
Resets all properties of the ball | def reset(self):
self.x = int(constants.SCREEN_WIDTH/2)
self.y = int(constants.SCREEN_HEIGHT/2)
self.DX = self.getRandSpeed()
self.DY = self.getRandSpeed() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resetball(self):\n self._ball = Ball()",
"def reset(self, balls=None):\r\n if balls is None:\r\n balls = self.balls\r\n for ball in balls:\r\n ball.reset()",
"def reset(self):\r\n # Reset ball ralley counter, mostly for progress viewing\r\n self.ball... | [
"0.8253611",
"0.77254134",
"0.74415004",
"0.74094343",
"0.7320084",
"0.72817534",
"0.7258626",
"0.7167321",
"0.7138291",
"0.7069328",
"0.7011117",
"0.6963798",
"0.6838937",
"0.67544645",
"0.67337507",
"0.6730882",
"0.67017794",
"0.6690245",
"0.6669513",
"0.66584766",
"0.66499... | 0.6472566 | 37 |
Get the (x,y) position of the ball Returns (x location of ball, y location of ball) | def getBallPos(self) -> (int,int):
return self.x, self.y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ball_position_and_state(self):\n return (self.x, self.y, self.is_ball_visible)",
"def get_position(self):\n return (self.x_pos, self.y_pos)",
"def get_pos(self):\n return (self.x, self.y)",
"def position(self):\n return self.x, self.y",
"def get_location(self):\r\n ... | [
"0.75780284",
"0.74851304",
"0.7460875",
"0.73551166",
"0.73355657",
"0.72714406",
"0.7237141",
"0.71387804",
"0.7031907",
"0.69597214",
"0.69193965",
"0.6912429",
"0.69097006",
"0.689496",
"0.6875988",
"0.6847295",
"0.6822357",
"0.6803534",
"0.6743977",
"0.672523",
"0.672068... | 0.8551318 | 0 |
Return a new Account object. | def __init__(
self,
account_blocked,
buying_power,
cash,
created_at,
currency,
daytrade_count,
daytrading_buying_power,
equity,
id,
initial_margin,
last_equity,
last_maintenance_margin,
long_mar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def account(self):\r\n return Account(self)",
"def account(self):\n return Account(self)",
"def account(self, account_id):\r\n return Account(self, account_id)",
"def account():\n\n bank_test = Bank.objects.create(name='R-Bank')\n company_test = Company.objects.create(name='Tre Bel... | [
"0.8219379",
"0.82028586",
"0.79448986",
"0.75918263",
"0.7493616",
"0.745823",
"0.7428262",
"0.72694707",
"0.716125",
"0.7119624",
"0.7066871",
"0.70008",
"0.6957328",
"0.69341004",
"0.68933314",
"0.6882183",
"0.6861029",
"0.6812466",
"0.68051374",
"0.66957915",
"0.66000926"... | 0.0 | -1 |
Return a new Asset object. | def __init__(
self,
id,
asset_class,
exchange,
symbol,
status,
tradable,
marginable,
shortable,
easy_to_borrow):
self.id = id
self.asset_class = asset_class
self.exchange = exchange
self.symbol... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def asset(self, asset_id):\n headers, items = self._get('/asset/%s' % asset_id)\n return Asset.fromdict(items[0], api=self, full=True)",
"def __new__(cls, asset):\n if isinstance(asset, Asset):\n return asset\n if isinstance(asset, File):\n return FileAsset(asset... | [
"0.7297233",
"0.72046256",
"0.71780646",
"0.66239",
"0.6491148",
"0.61189693",
"0.610188",
"0.59622127",
"0.58824533",
"0.5860355",
"0.58110243",
"0.57746536",
"0.57317704",
"0.57253265",
"0.5677477",
"0.5665867",
"0.5635528",
"0.56330997",
"0.5620094",
"0.5618329",
"0.558075... | 0.51608366 | 43 |
r""" list_campaigns(self, kwargs) > ApiResponse Gets an array of campaigns. | def list_campaigns(self, **kwargs) -> ApiResponse:
return self._request(kwargs.pop('path'), params=kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_list_of_campaigns(self, limit=0, offset=0):\n logger.info(\"Function call: get_list_of_campaigns\")\n return self.__handle_result(self.__send_request('campaigns', 'GET', {'limit': limit or 0, 'offset': offset or 0}))",
"def list_campaigns_extended(self, **kwargs) -> ApiResponse:\n re... | [
"0.7797828",
"0.7384614",
"0.7295399",
"0.7289506",
"0.7025364",
"0.69737095",
"0.6858887",
"0.675433",
"0.6699876",
"0.6574729",
"0.65243983",
"0.64558333",
"0.6419986",
"0.6342131",
"0.63322896",
"0.62659",
"0.61625737",
"0.6153562",
"0.60065275",
"0.59886926",
"0.59794253"... | 0.91198665 | 0 |
r""" get_campaign(self, campaignId, kwargs) > ApiResponse Gets a campaign specified by identifier. | def get_campaign(self, campaignId, **kwargs) -> ApiResponse:
return self._request(fill_query_params(kwargs.pop('path'), campaignId), params=kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_campaign(self, campaign_id: str) -> dict:\n return self.http_request(\"GET\", f'/campaign/{campaign_id}')",
"def get(self, campaign_id):\n campaign = Campaign.query.filter_by(mailchimp_id=campaign_id).first()\n if campaign is None:\n return {\"message\": \"Campaign could n... | [
"0.8356688",
"0.75014514",
"0.74091667",
"0.7261408",
"0.7066863",
"0.6870958",
"0.6703742",
"0.6669547",
"0.6601276",
"0.64146173",
"0.6402148",
"0.63833237",
"0.6180947",
"0.616946",
"0.6071944",
"0.599983",
"0.5858463",
"0.5858438",
"0.583261",
"0.5703481",
"0.56322855",
... | 0.9035137 | 0 |
r""" delete_campaign(self, campaignId, kwargs) > ApiResponse Sets the campaign status to archived. Archived entities cannot be made active again. See developer notes for more information. | def delete_campaign(self, campaignId, **kwargs) -> ApiResponse:
return self._request(fill_query_params(kwargs.pop('path'), campaignId), params=kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rpc_campaign_delete(self, campaign_id):\n\t\tsession = db_manager.Session()\n\t\tsession.delete(db_manager.get_row_by_id(session, db_models.Campaign, campaign_id))\n\t\tsession.commit()\n\t\tsession.close()\n\t\treturn",
"def delete_adcampaign(self, campaign_id, batch=False):\n path = '%s' % campaign_... | [
"0.70074016",
"0.6975269",
"0.69163483",
"0.60309505",
"0.5984588",
"0.5551692",
"0.5438922",
"0.53275144",
"0.53229326",
"0.5291472",
"0.5214432",
"0.5136913",
"0.5098933",
"0.5086119",
"0.5075033",
"0.5025599",
"0.4976109",
"0.495808",
"0.49549347",
"0.4877589",
"0.48695925... | 0.7605506 | 0 |
r""" get_campaign_extended(self, campaignId, kwargs) > ApiResponse Gets an array of campaigns with extended data fields. | def get_campaign_extended(self, campaignId, **kwargs) -> ApiResponse:
return self._request(fill_query_params(kwargs.pop('path'), campaignId), params=kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_campaigns_extended(self, **kwargs) -> ApiResponse:\n return self._request(kwargs.pop('path'), params=kwargs)",
"def get_campaign(self, campaignId, **kwargs) -> ApiResponse:\n return self._request(fill_query_params(kwargs.pop('path'), campaignId), params=kwargs)",
"def get_adcampaign(sel... | [
"0.8444411",
"0.6423818",
"0.64011496",
"0.62945",
"0.6094803",
"0.59072864",
"0.58411837",
"0.5774564",
"0.57489026",
"0.5684616",
"0.55856895",
"0.5585295",
"0.55327994",
"0.54195565",
"0.5405788",
"0.5391327",
"0.5329111",
"0.52382123",
"0.52187634",
"0.51804036",
"0.51573... | 0.87357885 | 0 |
Returns True if the given usage key is for an XBlock aside | def is_xblock_aside(usage_key):
return isinstance(usage_key, (AsideUsageKeyV1, AsideUsageKeyV2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_item(self, usage_key):\n if not isinstance(usage_key, BlockUsageLocator) or usage_key.deprecated:\n # The supplied UsageKey is of the wrong type, so it can't possibly be stored in this modulestore.\n return False\n\n if usage_key.block_id is None:\n raise Insu... | [
"0.64941037",
"0.6111959",
"0.6050745",
"0.5688474",
"0.56851476",
"0.56751025",
"0.5636359",
"0.55457866",
"0.5482954",
"0.54808235",
"0.54778075",
"0.5469594",
"0.5459308",
"0.54497576",
"0.5410232",
"0.5404032",
"0.5356563",
"0.532855",
"0.5318316",
"0.5316624",
"0.5315466... | 0.86138487 | 0 |
Initialize a new bordered window | def __init__(self, title, height, width, y, x):
logging.info(
"Create Border {height},{width},{y},{x}".format(
height=height,
width=width,
y=y,
x=x
)
)
self.__border = curses.newwin(height, width, y, x)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __create_win(self):\r\n self.__calc_size()\r\n try:\r\n self.win = curses.newwin(self.height, self.width, self.posy, self.posx)\r\n self.panel = curses.panel.new_panel(self.win)\r\n self.win.scrollok(True)\r\n self.win.keypad(1)\r\n self.do_p... | [
"0.71584517",
"0.68808347",
"0.68620425",
"0.68244416",
"0.68133163",
"0.67687196",
"0.6711553",
"0.66812825",
"0.6667972",
"0.6665805",
"0.6645828",
"0.65772814",
"0.6553715",
"0.65507376",
"0.65346116",
"0.6512733",
"0.6472049",
"0.64288145",
"0.6426796",
"0.6421196",
"0.64... | 0.75131255 | 0 |
Performs crazyass raw SQL queries to get a list of `question_info` objects | def get_question_info(submission_set, question_number, num_question_parts):
submission_ids = submission_set.values_list('id', flat=True)
submission_ids_str = map(str, submission_ids)
# In case of no submissions, submission_id IN (%s) will throw an error
# submission_id in 0 makes it fail gracefully
if len(su... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetchQuestions (self):\n # Create query and get data\n query = \"SELECT * from \" + self.dbTable + \" where main_ID = '\" + str(self.ID) + \"'\";\n data = self.sqlConnection.executeSelectQuery(query);\n \n # Convert the data into Question objects\n self.convertQuestion... | [
"0.7484444",
"0.6729881",
"0.6672755",
"0.64628255",
"0.613009",
"0.610798",
"0.6043598",
"0.603668",
"0.60183674",
"0.5974736",
"0.59531504",
"0.59429115",
"0.58828807",
"0.58751506",
"0.58581316",
"0.581584",
"0.57958186",
"0.5771788",
"0.57509136",
"0.57372516",
"0.5717751... | 0.0 | -1 |
Return timestamp by calling ``time.strftime(fmt, timestruct())``. | def timestamp(fmt, timestruct=None):
return _time.strftime(fmt, timestruct or _time.gmtime()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strftime(self, fmt, roundofs=0): # pylint: disable=invalid-name\n _ = roundofs\n if not self._struct:\n yday = self._days - DayNum(self.year, 1, 1) + 1\n wday = _DayNumToWeekdayNum(self._days)\n self._struct = (self.year, self.month, self.day, 0, 0, 0, wday, yday, 0)\n return LocalStrf... | [
"0.7445952",
"0.73659384",
"0.73535335",
"0.7333845",
"0.7299848",
"0.72839344",
"0.72839344",
"0.72502875",
"0.72269666",
"0.71355736",
"0.7080344",
"0.7039789",
"0.69772714",
"0.6966146",
"0.69366115",
"0.68952745",
"0.68458813",
"0.68448347",
"0.6822056",
"0.6788966",
"0.6... | 0.8997184 | 0 |
Factory class which wraps any model and returns a model suitable for DPSGD learning. The class will replicate the model in a memoryefficient way and run the forward and backward passes in parallel over the inputs. | def __init__(
self,
base_model: nn.Module,
num_replicas: int,
L2_clip: float,
noise_multiplier: float,
secure_rng: bool = False,
seed: Optional[int] = None,
watchdog: Optional[PrivacyWatchdog] = None,
) -> None:
super().__init__()
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_model():\r\n parser = argparse.ArgumentParser()\r\n parser.add_argument('--DISC_LR', type=float, default=1e-4)\r\n parser.add_argument('--GEN_LR', type=float, default=1e-3)\r\n parser.add_argument('--GEN_BETA1', type=float, default=0.9)\r\n parser.add_argument('--GEN_BETA2', type=float, default=0.9... | [
"0.69366926",
"0.6575874",
"0.64476717",
"0.63656634",
"0.6323812",
"0.632001",
"0.62908286",
"0.6283259",
"0.62632114",
"0.62542784",
"0.62520367",
"0.62500674",
"0.6240236",
"0.62139744",
"0.6209358",
"0.62092",
"0.61762005",
"0.6153211",
"0.6148011",
"0.61458576",
"0.61415... | 0.5857394 | 81 |
Prepare model for the next batch by reinitializing the model replicas with the updated weights and informing the PrivacyWatchdog about the state of the training. | def prepare_next_batch(self) -> None:
if not (
self._forward_succesful and self._clip_succesful and self._noise_succesful
):
raise RuntimeError(
"An error occured during model training. The model.prepare_next_batch() "
" method must be called after... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_model_optimizer_and_scheduler(self):\n\n ###################################################################\n # MODEL PREPARATION\n # -----------------\n # - step 1: Initialize a random model from config\n # - step 2: Load model weights from checkpoint if any\n ... | [
"0.67867",
"0.6725695",
"0.65153414",
"0.6487081",
"0.6431792",
"0.6383308",
"0.6348631",
"0.6217325",
"0.6206838",
"0.6164813",
"0.6160209",
"0.6133684",
"0.61176556",
"0.6103946",
"0.60963035",
"0.6087941",
"0.60473734",
"0.60060996",
"0.59967184",
"0.59944177",
"0.59879065... | 0.71752584 | 0 |
Factory class which wraps a PyTorch model to provide access to persample gradients. It will replicate the base model and peform the forward and backward passes in parallel. Contrary to the PrivacyWrapper, this class doesn't offer any additional features except calculating persample gradients. The wrapper includes a san... | def __init__(
self,
base_model: nn.Module,
num_replicas: int,
) -> None:
super().__init__()
self.num_replicas = num_replicas
self.wrapped_model = base_model
self.snooper = ModelSnooper()
self.snooper.snoop(self.wrapped_model)
del self.snooper
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(\n self,\n base_model: nn.Module,\n num_replicas: int,\n L2_clip: float,\n noise_multiplier: float,\n secure_rng: bool = False,\n seed: Optional[int] = None,\n watchdog: Optional[PrivacyWatchdog] = None,\n ) -> None:\n super().__init__(... | [
"0.62387085",
"0.57584316",
"0.5686173",
"0.566254",
"0.5648074",
"0.554967",
"0.545541",
"0.54512197",
"0.540086",
"0.5380508",
"0.5365276",
"0.5347754",
"0.5338524",
"0.53285307",
"0.5294444",
"0.5255661",
"0.52425",
"0.5226404",
"0.51546556",
"0.5134653",
"0.5095493",
"0... | 0.5783028 | 1 |
Return True if number is prime. | def is_prime(number):
if number <= 1:
return False
max_element = int(math.ceil(math.sqrt(number)))
# iterate through all elements from 2 through sqrt(n)
for element in range(2,max_element + 1):
if number % element == 0:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_prime_number(number_):\n flag = 0\n for values in range(2, number_//2):\n if number_ % values == 0:\n flag += 1\n if flag == 1:\n return True\n else:\n return False",
"def is_prime(number):\n\t\n\tif number < 2: return False\n\telif number == 2: return True\n\te... | [
"0.8257161",
"0.8243624",
"0.8191229",
"0.81504107",
"0.80566925",
"0.80419075",
"0.80096567",
"0.80058324",
"0.80004966",
"0.79851073",
"0.7975722",
"0.7945524",
"0.793624",
"0.7920225",
"0.7888884",
"0.7845249",
"0.7840306",
"0.77951753",
"0.779481",
"0.77864987",
"0.777893... | 0.8023641 | 6 |
Allows a new user to register an account. Following successful registration, redirects to either ``/accounts/register/complete/`` or, if supplied, the URL specified in the keyword argument ``success_url``. By default, ``registration.forms.RegistrationForm`` will be used as the registration form; to change this, pass a ... | def register(request, success_url=settings.PREFIX_URL + '/accounts/register/complete/',
form_class=RegistrationForm,
template_name='registration/registration_form.html'):
if hasattr(settings, 'SHOW_DATASET_INTERFACE_OPTIONS') and settings.SHOW_DATASET_INTERFACE_OPTIONS:
show_datase... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register(request, success_url=None,\r\n form_class=RegistrationForm, profile_callback=None,\r\n template_name='registration/registration_form.html',\r\n extra_context=None):\r\n if request.method == 'POST':\r\n form = form_class(data=request.POST, files=request.FIL... | [
"0.87003946",
"0.7834944",
"0.7391076",
"0.7209871",
"0.71135324",
"0.7099406",
"0.70758414",
"0.69563186",
"0.69412136",
"0.6919151",
"0.6914263",
"0.6844012",
"0.6834358",
"0.6833996",
"0.68038684",
"0.6795563",
"0.67681044",
"0.67200905",
"0.670776",
"0.67026323",
"0.66956... | 0.0 | -1 |
Load the main page in react | def react():
page = get_page_arg()
items = load_data(page)
total_pages = get_total_pages()
data = {"current_page": page,
"total_pages": total_pages,
"items": items.dict()}
context = {"props": json.dumps(data)}
return render_template('react.html', **context) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main_page():\n return render_template(\"index.html\")",
"def main_page():\n return render_template(\"main_page.html\")",
"def main():\r\n st.sidebar.title(\"MỤC LỤC\")\r\n selection = st.sidebar.radio(\"Go to\", list(PAGES.keys()))\r\n\r\n page = PAGES[selection]\r\n\r\n with st.spinner(f... | [
"0.69048727",
"0.6820593",
"0.6643831",
"0.6526773",
"0.64651865",
"0.6420566",
"0.640309",
"0.640309",
"0.63800156",
"0.6379792",
"0.6379792",
"0.633144",
"0.6291103",
"0.6275256",
"0.62455285",
"0.6229249",
"0.6229249",
"0.61828256",
"0.61536777",
"0.6124752",
"0.6124261",
... | 0.651506 | 4 |
Ensures a 404 is returned when an invalid customer ID is passed | def test_get_non_existent_customer_returns_404(self):
get_customer_url = reverse("customer_detail", kwargs={"pk": 1002})
response = self.client.get(get_customer_url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_restaurant_by_id_not_number(self):\n resp = self.test_client.get(self.API_BASE + '/hello', headers=auth_header_cru_restaurants)\n self.assertEqual(resp.status_code, 400)",
"def test_bad_pk(self):\n self.url_kwargs[self.pk_url_kwarg] = 1234\n response = self._get()\n ... | [
"0.6230983",
"0.622345",
"0.622345",
"0.622345",
"0.6169294",
"0.612782",
"0.6051124",
"0.6032979",
"0.6023103",
"0.59781826",
"0.5974431",
"0.59469664",
"0.5943102",
"0.5936407",
"0.5934957",
"0.59334934",
"0.58934444",
"0.5892337",
"0.5885083",
"0.58435714",
"0.5837195",
... | 0.7245524 | 0 |
Ensure that a book can't be rented out if not available | def test_create_rental_with_unavailable_book(self):
create_rental_url = reverse(
"customer_rental_list", kwargs={"pk": self.user1.pk}
)
data = {"book": self.book3.pk}
response = self.client.post(create_rental_url, data=data, format="json")
self.assertEqual(response.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rent_book(self, user, book):\n if book.in_stock > 0:\n # check if the user has the book\n try:\n r = self.get(rented_by=user, book=book, returned_on=None)\n # if there is a rental by the user, raise a custom exception\n raise RentalExist... | [
"0.69052815",
"0.6850929",
"0.67350703",
"0.6647401",
"0.6518213",
"0.6105418",
"0.60817015",
"0.6009008",
"0.59613985",
"0.587117",
"0.5857886",
"0.5816907",
"0.57935077",
"0.5757161",
"0.57512945",
"0.56983584",
"0.56811774",
"0.56772804",
"0.5661885",
"0.56364834",
"0.5632... | 0.66889 | 3 |
Gets the value of an environment variable within the Shell | def getenv(self, name):
return self.environment[name] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def env(var):\n return os.environ[var]",
"def windows_get_env_value(var_name: str) -> str:\n if var_name in os.environ.keys():\n return os.environ[var_name]",
"def GetEnvVariable(name):\n return os.environ.get(name)",
"def _get_env(key: str) -> str:\n value = os.getenv(key)\n as... | [
"0.7932712",
"0.78744805",
"0.78080493",
"0.76401556",
"0.76286596",
"0.7571606",
"0.7496366",
"0.72320455",
"0.71190345",
"0.71149296",
"0.7102304",
"0.70960605",
"0.7090687",
"0.70160663",
"0.70115685",
"0.7004518",
"0.6978606",
"0.6966443",
"0.6955333",
"0.6862371",
"0.684... | 0.6897012 | 19 |
Checks whether the coordinates are inside of the object | def is_inside(self, x: int, y: int) -> bool:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_inside(self, coordinates: tuple) -> bool:\n if len(coordinates) != 2:\n raise IndexError(\"Coordinates consist of x and y\")\n x, y = coordinates\n if (self.MIN_X <= x <= self.MAX_X) and (self.MIN_Y <= y <= self.MAX_Y):\n return True\n else:\n ret... | [
"0.77976453",
"0.7676617",
"0.74041814",
"0.73605055",
"0.73430943",
"0.73360795",
"0.7289547",
"0.72795963",
"0.72285116",
"0.7220123",
"0.7217889",
"0.72029495",
"0.7140673",
"0.709911",
"0.70981383",
"0.70858204",
"0.7078173",
"0.70423746",
"0.70423746",
"0.70390314",
"0.7... | 0.8130981 | 0 |
Returns stationary rotation pivot to the center of the object. Update should be used after calling this function. | def rotation_pivot_to_center(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotation(self):\n\t\treturn self.piv.a.rotate.v",
"def pivot_point(self):\n return (self.last_close + self.last_high + self.last_low) / 3",
"def rotation_center(self, *args, **kwargs) -> Any:\n pass",
"def relativeRotation(self):\n return self.rotation()",
"def safe_north_point(sel... | [
"0.6441238",
"0.6060877",
"0.59251",
"0.59237015",
"0.57738626",
"0.57564765",
"0.57351756",
"0.5733987",
"0.57265",
"0.56197524",
"0.55926734",
"0.5590121",
"0.55778074",
"0.55601794",
"0.55553925",
"0.55127263",
"0.55041534",
"0.55025566",
"0.5488824",
"0.5465886",
"0.54635... | 0.7755911 | 0 |
Check if the user is one associated with an app service (exclusively) | def get_if_app_services_interested_in_user(self, user_id: str) -> bool:
if self.exclusive_user_regex:
return bool(self.exclusive_user_regex.match(user_id))
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_application_owner(user, application):\n\n if application.auth_user == user:\n \"\"\"Check auth_user first\"\"\"\n return True\n\n elif not application.auth_user and application.user_id:\n \"\"\"Check Auth0 for legacy applications\"\"\"\n if application.user_id == get_auth0_... | [
"0.6790912",
"0.6415444",
"0.6265316",
"0.6251666",
"0.61698425",
"0.61693615",
"0.6165143",
"0.6133615",
"0.6049688",
"0.6036117",
"0.60166854",
"0.6001616",
"0.5966012",
"0.5937263",
"0.5923739",
"0.591038",
"0.59017754",
"0.58841246",
"0.5870964",
"0.58382744",
"0.5836593"... | 0.7507853 | 0 |
Get the application service state. | async def get_appservice_state(
self, service: ApplicationService
) -> Optional[ApplicationServiceState]:
# if we have created transactions for this AS but not yet attempted to send
# them, we will have a row in the table with state=NULL (recording the stream
# positions we have proc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state(self) -> ApplicationState:\n return self.state",
"def appstate(self) -> NamedAppState:\n return self._appstate",
"def get_state(self):\n return self._env.get_state()",
"def get_state(self):\n _, state, _, _, _, _, _ = win32serviceutil.QueryServiceStatus(self.name)\n ... | [
"0.7626148",
"0.73970115",
"0.73069566",
"0.72594494",
"0.67940325",
"0.672457",
"0.667027",
"0.6659617",
"0.6655641",
"0.6565665",
"0.6496042",
"0.64585406",
"0.63922334",
"0.6388137",
"0.6388137",
"0.6388137",
"0.6388137",
"0.6388137",
"0.6388137",
"0.6388137",
"0.6388137",... | 0.6533963 | 10 |
Extract the Python code from \pyenv{ } | def _CleanChunk(self, chunk):
mystr = '\n'.join(chunk)
p2 = re.compile(self.pat+'(.*)}', re.DOTALL)
q2 = p2.search(mystr)
code = q2.group(2)
code = BalanceCurlies(code)
nl, nr = CountCurlies(code)
assert nl==nr, "Number of left and right curly braces not equal:"+c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getpythonenv(options,buildout):\n crypt=''\n if os.uname()[0] != 'Darwin':\n crypt=' -lcrypt '\n myfile = open(\n os.path.join(\n options['compile-directory'],\n 'Modules',\n 'Setup.local'),\n 'w'\n )\n myfile.write(\"\"\"\nzlib zlibmodule.c ... | [
"0.5958364",
"0.59060645",
"0.5868896",
"0.5768195",
"0.57148916",
"0.5685237",
"0.56249046",
"0.5594238",
"0.5591691",
"0.5589285",
"0.55778897",
"0.55349535",
"0.53381675",
"0.53247947",
"0.5307095",
"0.53053343",
"0.53053343",
"0.52819",
"0.527781",
"0.52530086",
"0.522150... | 0.0 | -1 |
Return the index of this node in a list of all nodes in the tree. | def tree_id(self):
if self.is_root:
return 0
elif self._link is not None:
return self._link.tree_id
else:
return self._tree_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(self):\n return self._ll_tree.get_index()",
"def iter_leaf_idx(self):\n def leaf_idx(tree, total):\n total[0] += 1\n for elem in tree[1:]:\n if isinstance(elem, Tree):\n for elem2 in leaf_idx(elem, total):\n yi... | [
"0.69951594",
"0.6771714",
"0.66898113",
"0.6539747",
"0.644365",
"0.63125104",
"0.6248345",
"0.62054497",
"0.6180763",
"0.6179813",
"0.61643094",
"0.61057556",
"0.6104049",
"0.61003953",
"0.6054963",
"0.6039968",
"0.60289305",
"0.59986037",
"0.5995167",
"0.59739035",
"0.5924... | 0.0 | -1 |
Return the descendent node. | def descendent(self):
if self.is_root:
return None
# set in CatalogArbor._plant_trees
if self._descendent is not None:
return self._descendent
# conventional Arbor object
desc_link = self._link.descendent
if desc_link is None:
return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getNode(self):\n node = Edge.getNode(self)\n node.tag = 'depedge'\n return(node)",
"def get_node(self):\r\n return self._node",
"def get_node(self):\n return self.__node",
"def getNode(self):\n node = Node.getNode(self)\n node.tag = 'relnode'\n retu... | [
"0.7078342",
"0.6899762",
"0.6897733",
"0.6655669",
"0.66388977",
"0.6638464",
"0.662349",
"0.662349",
"0.6584348",
"0.6557864",
"0.65364254",
"0.6533643",
"0.65073574",
"0.6460638",
"0.64368784",
"0.63859934",
"0.6366619",
"0.6351962",
"0.6296749",
"0.6275821",
"0.6272267",
... | 0.75717556 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.