query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Prepare the sequences used by the Neural Network | def prepare_sequences(notes, n_vocab):
sequence_length = GLOBAL_SEQUENCE_LENGTH
# Get all pitch names
pitchnames = sorted(set(item for item in notes))
# Create a dictionary to map pitches to integers
note_to_int = dict((note, number) for number, note in enumerate(pitchnames))
network_input = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_sequences(notes, n_vocab):\n sequence_length = 50\n\n # get all pitch names\n pitchnames = sorted(set(item for item in notes))\n\n # create a dictionary to map pitches to integers\n note_to_int = dict((note, number) for number, note in enumerate(pitchnames))\n\n network_input = []\n ... | [
"0.6689426",
"0.6478123",
"0.64326185",
"0.64018196",
"0.6347999",
"0.6346381",
"0.619188",
"0.61806005",
"0.61420333",
"0.61329055",
"0.61148167",
"0.6100435",
"0.608873",
"0.60376334",
"0.603599",
"0.601905",
"0.60031384",
"0.5962889",
"0.5943119",
"0.5938684",
"0.59183395"... | 0.65555423 | 1 |
Generate notes from the neural network based on a sequence of notes | def generate_notes(model, network_input, n_vocab):
# pick a random sequence from the input as a starting point for the prediction
start = np.random.randint(0, len(network_input)-1)
# Get pitch names and store in a dictionary
pitchnames = sorted(set(item for item in notes))
int_to_note = dict((n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_notes(model, training_notes, note_translator):\n\n # pick a random sequence from the input as a starting point for the prediction\n sequence_length = model.sequence_length\n note_reverse_translator = {index: note for note, index in note_translator.items()}\n init_state = data_preprocess.pr... | [
"0.75724083",
"0.75357854",
"0.7140033",
"0.7138525",
"0.7112814",
"0.6966233",
"0.69008785",
"0.6879311",
"0.6497627",
"0.61884177",
"0.6184555",
"0.6086288",
"0.59519565",
"0.5931394",
"0.5835027",
"0.5832675",
"0.5720372",
"0.5715914",
"0.56507623",
"0.5642474",
"0.5600574... | 0.7653167 | 0 |
convert the output from the prediction to notes and create a midi file from the notes | def create_midi(prediction_output, filename):
offset = 0
output_notes = []
# create note and chord objects based on the values generated by the model
for item in prediction_output:
pattern = item
# pattern is a chord
if ('.' in pattern) or pattern.isdigit():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_midi(prediction_output, model_file):\n offset = 0\n output_notes = []\n\n # create note and chord objects based on the values generated by the model\n for pattern in prediction_output:\n # pattern is a chord\n if ('.' in pattern) or pattern.isdigit():\n notes_in_chor... | [
"0.79950756",
"0.7954297",
"0.79236674",
"0.7789785",
"0.671896",
"0.660403",
"0.6532247",
"0.6258551",
"0.6235759",
"0.62201077",
"0.6185511",
"0.61558264",
"0.6133344",
"0.60906225",
"0.6084611",
"0.60755897",
"0.60568166",
"0.60479105",
"0.60397",
"0.6035738",
"0.6019836",... | 0.8151729 | 0 |
Transmit the data envelopes to the ingestion service. Does not perform retry logic. For partial success and nonretryable failure, simply outputs result to logs. This function should never throw exception. | def _transmit_without_retry(self, envelopes):
# Contains logic from transport._transmit
# TODO: Remove this function from exporter and consolidate with
# transport._transmit to cover all exporter use cases. Uses cases
# pertain to properly handling failures and implementing a retry
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send(self, result):\n\n logger.debug(\"Checking if we should send {}\".format(result))\n if result.is_failure() and self.will_publish(result):\n message = self._construct_message(result)\n headers = {\n \"Content-Type\": \"application/json\"\n }\n\n... | [
"0.5656892",
"0.5287145",
"0.5174026",
"0.515644",
"0.51534945",
"0.5118591",
"0.5063369",
"0.5057553",
"0.50450146",
"0.5035203",
"0.50120544",
"0.49986604",
"0.49908283",
"0.49884164",
"0.49834234",
"0.49751616",
"0.49745554",
"0.49649167",
"0.49632606",
"0.4957523",
"0.493... | 0.736348 | 0 |
podmd Accepts a Bycon `byc` object a Bycon `h_o` handover object with its `target_values` representing `_id` objects of a `variants` collection The function creates a basic BED file and returns its local path. A standard use would be to create a link to this file and submit it as `hgt.customText` parameter to the UCSC ... | def _write_variants_bedfile(h_o, p_f, p_t, byc):
local_paths = byc.get("local_paths")
if not local_paths:
return False
tmp_path = Path( path.join( *local_paths[ "server_tmp_dir_loc" ]) )
if not tmp_path.is_dir():
return False
v_ret = 0
v_max = 1000
if len( h_o["target_valu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_file(material_id):\n apr=get_doc_from_MP(material_id)\n mat_list=generate_matrix(apr)\n formu=POSCAR_title(apr)\n cell_for=generate_cell_formula(apr)\n needed_dos=generate_dos_str(material_id)\n revise_dos=dos_into_string(needed_dos)\n ordered_list=generate_ordered_list(revise_dos... | [
"0.523093",
"0.51998866",
"0.5158229",
"0.5140045",
"0.5118935",
"0.50558704",
"0.5029571",
"0.49992138",
"0.49688032",
"0.48805413",
"0.4840689",
"0.48012224",
"0.47752804",
"0.47610596",
"0.47577068",
"0.47528267",
"0.4687908",
"0.46316627",
"0.4619879",
"0.46195143",
"0.46... | 0.5394805 | 0 |
r"""Compute the ctc loss with batched labels. | def ctc_loss(inputs, padding_mask=-1, **kwargs):
args = ArgHelper.parse(locals())
inputs[0] = activation_ops.softmax(inputs[0], axis=2)
op_lib = loss_ops_lib.Operator
if context.executing_eagerly():
raise NotImplementedError
else:
return op_lib.blend('CTCLoss', **args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ctc_loss(label_length, ctc_input_length, labels, probs):\n label_length = tf.cast(tf.squeeze(label_length), dtype=tf.int32)\n ctc_input_length = tf.cast(tf.squeeze(ctc_input_length), dtype=tf.int32)\n sparse_labels = tf.cast(tf.keras.backend.ctc_label_dense_to_sparse(labels, label_length), dtype=tf.in... | [
"0.6970509",
"0.68200433",
"0.6804985",
"0.6726371",
"0.6681177",
"0.6646176",
"0.6607578",
"0.6524093",
"0.64642483",
"0.6374277",
"0.61923236",
"0.6092338",
"0.6085526",
"0.60759014",
"0.60613245",
"0.6043316",
"0.6035013",
"0.59991264",
"0.5978405",
"0.5954415",
"0.5942769... | 0.70889 | 0 |
r"""Compute the softmax cross entropy with sparse labels. | def sparse_softmax_cross_entropy(
inputs,
axis=1,
ignore_index=None,
reduction='valid',
**kwargs
):
args = ArgHelper.parse(locals())
args['reduction'] = reduction.upper()
op_lib = loss_ops_lib.SparseSoftmaxCrossEntropy
if context.executing_eagerly():
return op_lib \
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sparse_cross_entropy(true, pred, axis=-1, epsilon=1e-7):\n true = ivy.one_hot(true, pred.shape[axis])\n return cross_entropy(true, pred, axis, epsilon)",
"def sparse_cross_entropy_with_probs(probs, labels, name=None):\n with tf.name_scope(name, \"SparseSoftmaxCrossEntropyWithProb\", [probs, labels])... | [
"0.75729984",
"0.7483392",
"0.7342698",
"0.7261253",
"0.71876013",
"0.71847457",
"0.7153395",
"0.708201",
"0.70781726",
"0.707635",
"0.7052675",
"0.7032999",
"0.6964066",
"0.69560903",
"0.69532275",
"0.6948643",
"0.69474673",
"0.6936967",
"0.6919669",
"0.6887562",
"0.68827564... | 0.75418687 | 1 |
Returns a set of decades that covers all of the years and year ranges in the data. data can be a single string or a set of strings disjoint whether or not to exclude decades in the interim between the earliest and latest decades | def decades(self, data, disjoint=True):
decade_set = set()
try:
# multi valued
assert isinstance(data, set)
for datum in data:
preprocessed_year_data = self._extract_year_data(datum)
decade_set = decade_set | self._enumerate_decades(pr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def years(self, data, disjoint=True):\n\n year_set = set()\n try:\n # multi valued\n assert isinstance(data, set)\n for datum in data:\n preprocessed_year_data = self._extract_year_data(datum)\n year_set = year_set | self._enumerate_years... | [
"0.6242524",
"0.584959",
"0.58418256",
"0.5749594",
"0.55666363",
"0.55094856",
"0.54740614",
"0.54646933",
"0.5412162",
"0.5407114",
"0.5374574",
"0.53573066",
"0.53103226",
"0.5309206",
"0.5307339",
"0.5235848",
"0.5222081",
"0.5171749",
"0.51681775",
"0.5146663",
"0.513659... | 0.7365615 | 0 |
Returns a set of years that covers all of the years and year ranges in the data. data can be a single string or a set of strings disjoint whether or not to exclude years in the interim between the earliest and latest years | def years(self, data, disjoint=True):
year_set = set()
try:
# multi valued
assert isinstance(data, set)
for datum in data:
preprocessed_year_data = self._extract_year_data(datum)
year_set = year_set | self._enumerate_years(preprocessed... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def t_range_years(t_range):\r\n start_year = int(t_range[0].split(\"-\")[0])\r\n end_year = int(t_range[1].split(\"-\")[0])\r\n end_month = int(t_range[1].split(\"-\")[1])\r\n end_day = int(t_range[1].split(\"-\")[2])\r\n if end_month == 1 and end_day == 1:\r\n year_range_list = np.arange(sta... | [
"0.6668446",
"0.64742446",
"0.6461352",
"0.6017229",
"0.60148984",
"0.5969544",
"0.593733",
"0.59081143",
"0.57882893",
"0.5774196",
"0.5734059",
"0.56695604",
"0.56593835",
"0.56580514",
"0.5633372",
"0.5602902",
"0.55264854",
"0.55252516",
"0.55181205",
"0.5500564",
"0.5471... | 0.7573435 | 0 |
Maps a match of regexes['match']['date'] to a tuple of years, or a single year. m the re.match object | def _date_match_to_int_or_tuple(self, m):
years = set()
try:
if m[0] != '':
# yyyy-dd-mm
years = int(m[0][0:4])
elif m[1] != '':
# year-range derived from a century
century = int(re.match(re.compile('\\d+'), m[1]).g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _year_range(m):\n return (m.group(1), m.group(2))",
"def _extract_year_data(self, date_string):\n\n try:\n # first see if dateutil can parse the date string\n # simplest case, a single year\n return {parse(date_string).year}\n\n except ValueError:\n ... | [
"0.7254186",
"0.6608783",
"0.6011262",
"0.5957045",
"0.59214723",
"0.59050083",
"0.5880262",
"0.58387053",
"0.5810087",
"0.58070123",
"0.57679784",
"0.57420975",
"0.57067704",
"0.5700978",
"0.56853163",
"0.5677188",
"0.56761444",
"0.56604224",
"0.56588614",
"0.5644384",
"0.56... | 0.7606871 | 0 |
Return a set of decades. If disjoint is false, returns a set of decades that spans the entire range. preprocessed_data a heterogeneous set of ints and tuples of ints | def _enumerate_decades(self, preprocessed_data, disjoint):
if disjoint:
decades = set()
for decade in preprocessed_data:
if isinstance(decade, int):
decades.add(decade // 10 * 10)
elif isinstance(decade, tuple):
dec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decades(self, data, disjoint=True):\n\n decade_set = set()\n try:\n # multi valued\n assert isinstance(data, set)\n for datum in data:\n preprocessed_year_data = self._extract_year_data(datum)\n decade_set = decade_set | self._enumera... | [
"0.7483984",
"0.51474196",
"0.5103328",
"0.5055087",
"0.50201726",
"0.50139266",
"0.49108776",
"0.48341992",
"0.4811175",
"0.4799761",
"0.47267008",
"0.46881026",
"0.46321952",
"0.4605094",
"0.45930317",
"0.45531568",
"0.4522701",
"0.45008975",
"0.44996762",
"0.44854528",
"0.... | 0.7381708 | 1 |
Return a set of years. If disjoint is false, returns a set of years that spans the entire range. preprocessed_data a heterogeneous set of ints and tuples of ints | def _enumerate_years(self, preprocessed_data, disjoint):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def years(self, data, disjoint=True):\n\n year_set = set()\n try:\n # multi valued\n assert isinstance(data, set)\n for datum in data:\n preprocessed_year_data = self._extract_year_data(datum)\n year_set = year_set | self._enumerate_years... | [
"0.80802757",
"0.6195092",
"0.6097575",
"0.6085509",
"0.5956418",
"0.57805914",
"0.5775583",
"0.57030433",
"0.56905186",
"0.55768806",
"0.5571027",
"0.55363435",
"0.5514044",
"0.54679793",
"0.54667073",
"0.54420847",
"0.5440692",
"0.54319644",
"0.5420999",
"0.5370453",
"0.531... | 0.7213386 | 1 |
Extracts the year(s) and/or year range(s) embedded in the date_string, and return a set of ints (year) and/or tuples of ints (year range, start/end). date_string the string containing the dirty date | def _extract_year_data(self, date_string):
try:
# first see if dateutil can parse the date string
# simplest case, a single year
return {parse(date_string).year}
except ValueError:
try:
# strip alphabetical chars and spaces from the left ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def string_to_years(s):\n pattern = r'\\d\\d\\d\\d'\n r = re.compile(pattern)\n min_year = 1960\n max_year = datetime.now().year + 1\n return list(filter(lambda y: y >= min_year and y <= max_year, map(int, r.findall(s))))",
"def _year_range(m):\n return (m.group(1), m.group(2))",
"def parse_y... | [
"0.71493185",
"0.7043156",
"0.68464625",
"0.67900616",
"0.63941294",
"0.62800896",
"0.6208942",
"0.6202308",
"0.6173974",
"0.60687256",
"0.6009146",
"0.5986021",
"0.5980821",
"0.59670657",
"0.59482944",
"0.5917469",
"0.58205444",
"0.57989943",
"0.574035",
"0.5707159",
"0.5699... | 0.8044839 | 0 |
Remove chain if zero var. | def RemoveZeroVar(chain):
return chain[:, np.invert((np.sum(np.var(chain, axis=0), axis=1)<1e-10)), :] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RemoveZeroVar(chain):\n\treturn chain[:, np.invert((np.sum(np.var(chain, axis=0), axis=1)<1e-10)), :]",
"def remove_causal_chain_from_local_Q(self, trial_name, chain_idx):\n for state in range(self.local_Q[trial_name].shape[0]):\n self.local_Q[trial_name][state][chain_idx] = 0",
"def remo... | [
"0.75237256",
"0.65207744",
"0.61948866",
"0.5943889",
"0.5856726",
"0.579234",
"0.55565387",
"0.55563855",
"0.5513278",
"0.5393509",
"0.53831285",
"0.5355641",
"0.53278524",
"0.52536255",
"0.52277136",
"0.5119385",
"0.5117619",
"0.50989103",
"0.50953203",
"0.50734174",
"0.50... | 0.72741723 | 1 |
>>> soup = BeautifulSoup(open("../../data/share/posts/1009.html").read()) >>> ifValidSERP(soup) True >>> soup2 = BeautifulSoup(open("../../data/share/posts/2406.html").read()) >>> ifValidSERP(soup2) False | def ifValidSERP(soupObject):
return soupObject.find("p", class_="noresult_tit") is None and soupObject.title is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_format_wrong(soup):\n a = soup.find('a')\n if a.has_attr('faire'):\n return True\n return False",
"def broken_page(soup):\n ps = soup.find_all(\"p\")\n ps = map(lambda x: x.text, ps)\n unexpected_error = True in map(lambda x: \"unexpected error\" in x, ps)\n \n no_grades = s... | [
"0.6150946",
"0.6123322",
"0.57974476",
"0.56922346",
"0.5682742",
"0.5637584",
"0.5608051",
"0.55979985",
"0.5595201",
"0.55802923",
"0.55608934",
"0.5534084",
"0.55069125",
"0.54980284",
"0.54980284",
"0.54980284",
"0.54980284",
"0.54954755",
"0.5489522",
"0.5457203",
"0.54... | 0.67786336 | 0 |
Returns number of books read | def get_books_read(self):
return len(self.books) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count(self):\n return Library.functions.count(self._book)",
"def book_count(self):\n\n try:\n cur = self._db.cursor()\n cur.execute('SELECT COUNT(*) FROM books')\n return cur.fetchone()[0]\n except sqlite3.Error as e:\n ... | [
"0.7992762",
"0.7731883",
"0.7612036",
"0.6803979",
"0.6539564",
"0.65282",
"0.6519381",
"0.6475682",
"0.6453176",
"0.6382742",
"0.6382742",
"0.6382742",
"0.6382742",
"0.6376332",
"0.6367946",
"0.6364944",
"0.6364356",
"0.63492286",
"0.6307586",
"0.63016653",
"0.62689745",
... | 0.8106499 | 0 |
Adds a rating if it meets criteria | def add_rating(self, rating):
if not rating or rating < 0 or rating > 4:
return "Rating {rating} is not valid. Valid ratings are between 0 and 4".format(rating=rating)
else:
self.ratings.append(rating) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_rating(self, rating):\n if rating >= 0 and rating <= 4:\n self.ratings.append(rating)\n else:\n print(\"Invalid Rating\")",
"def add_rating(user, item, rating):\n users.append(user)\n items.append(item)\n ratings.append(rating)",
"def add_rating(self):\n ... | [
"0.78625226",
"0.63722396",
"0.6271171",
"0.60921353",
"0.6090529",
"0.6087433",
"0.6034467",
"0.5894537",
"0.58583003",
"0.58511144",
"0.5834168",
"0.580135",
"0.5800364",
"0.57674557",
"0.57537365",
"0.57537365",
"0.5751292",
"0.57333684",
"0.5727925",
"0.5715088",
"0.57114... | 0.7357697 | 1 |
Returns average rating or prints none available | def get_average_rating(self):
count = 0
total = 0
ratings_length = len(self.ratings)
if ratings_length > 0:
for rating in self.ratings:
count += 1
total += rating
average = total / count
return average
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_average_rating(self):\n count = 0\n total = 0\n num_books = len(self.books)\n if num_books > 0:\n for rating in self.books.values():\n if rating:\n count += 1\n total += rating\n average = total / count\n... | [
"0.78994644",
"0.77764827",
"0.76753175",
"0.76248264",
"0.75925076",
"0.75614244",
"0.748261",
"0.7427136",
"0.71799606",
"0.717904",
"0.71507555",
"0.7121672",
"0.6946089",
"0.6856904",
"0.68340194",
"0.6830731",
"0.67425144",
"0.67189294",
"0.66959345",
"0.668871",
"0.6650... | 0.8252819 | 0 |
Returns hash of book | def __hash__(self):
return hash((self.title, self.isbn)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash(self) -> bytes:",
"def hash(self) -> str:\r\n ...",
"def get_hash(self):\r\n return",
"def hash(self) -> str:\n return pulumi.get(self, \"hash\")",
"def get_hash(self):\n source = \"\"\n for cell in self.original_cells:\n source += \"\\n\".join(get_sou... | [
"0.72355944",
"0.7082014",
"0.7071481",
"0.7000493",
"0.6883297",
"0.6867283",
"0.67737263",
"0.67702335",
"0.67687285",
"0.6761425",
"0.67514795",
"0.6711301",
"0.66213644",
"0.66213644",
"0.6589381",
"0.65639246",
"0.6561698",
"0.65491515",
"0.6539704",
"0.65378046",
"0.651... | 0.7334127 | 0 |
Adds book and rating if exists | def add_book_to_user(self, book, email, rating=None):
if self.users.get(email):
self.users[email].read_book(book, rating)
self.books[book] = self.books.get(book, 0) + 1
if rating:
book.add_rating(rating)
else:
print("{email} address not fou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_book(self, data):\n exists = self.check_if_exists(data['isbn'])\n\n if exists:\n query = f\"\"\"UPDATE {TABLE} SET quantity = quantity + 10 WHERE bookID = '{data[\"isbn\"]}'\"\"\"\n else:\n query = f\"\"\"INSERT INTO {TABLE}(bookID, title, authors, avg_rating, rat... | [
"0.6787978",
"0.6579681",
"0.6568055",
"0.6551944",
"0.6508678",
"0.6425218",
"0.6392102",
"0.6381456",
"0.61407083",
"0.61249",
"0.6027362",
"0.59443843",
"0.59425426",
"0.59305996",
"0.58900917",
"0.584182",
"0.5823926",
"0.5782583",
"0.57586634",
"0.57273984",
"0.57060885"... | 0.67295533 | 1 |
Prints books in dictionary | def print_catalog(self):
for book in self.books.keys():
print(book) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_book(self):\r\n print(\"Available Books are:\")\r\n for item in self.books:\r\n print(f\"{self.books.index(item)+1}. {item}\")",
"def display_book(self):\n print(\"List of books available is: \")\n for book in books_list :\n print(\"- \",book)",
"de... | [
"0.7210097",
"0.70254695",
"0.6883923",
"0.6709422",
"0.6676588",
"0.66465443",
"0.65207547",
"0.65199316",
"0.64732736",
"0.63754284",
"0.62558043",
"0.6226128",
"0.6200351",
"0.61736345",
"0.6163209",
"0.61529285",
"0.61524075",
"0.608258",
"0.60664874",
"0.59934986",
"0.59... | 0.79404205 | 1 |
Prints users in dictionary | def print_users(self):
for user in self.users.values():
print(user) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_users(self):\n for i, item in enumerate(self.users):\n print(\"{}. {}\".format(i, item.name))",
"def users_view():\n data = get_data()\n return [{'user_id': i, 'name': 'User {0}'.format(str(i))}\n for i in data.keys()]",
"def display_users():\n users = storage.al... | [
"0.765939",
"0.72263163",
"0.70733106",
"0.6875003",
"0.6696791",
"0.66603804",
"0.6646293",
"0.6608518",
"0.6589131",
"0.65826404",
"0.65524274",
"0.6548652",
"0.6523387",
"0.6450315",
"0.6441693",
"0.6434259",
"0.64076483",
"0.63903874",
"0.6368943",
"0.63630533",
"0.635990... | 0.8323811 | 0 |
Returns most read book | def most_read_book(self):
reading_max = 0
most_reads = ""
for book in self.books.keys():
rating = book.get_average_rating()
if rating > reading_max:
most_reads = book
reading_max = rating
else:
continue
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def highest_rated_book(self):\n rating_max = 0\n best_rated_book = \"\"\n for book in self.books.keys():\n rating = book.get_average_rating()\n if rating > rating_max:\n rating_max = rating\n best_rated_book = book\n else:\n ... | [
"0.7724168",
"0.7483818",
"0.71411234",
"0.6562405",
"0.63577133",
"0.62896013",
"0.62841135",
"0.6251964",
"0.62414163",
"0.6132677",
"0.6107795",
"0.6106943",
"0.6083038",
"0.607377",
"0.60098064",
"0.6000276",
"0.5960912",
"0.59562415",
"0.59394085",
"0.5935878",
"0.592481... | 0.8725137 | 0 |
Returns highest rated book | def highest_rated_book(self):
rating_max = 0
best_rated_book = ""
for book in self.books.keys():
rating = book.get_average_rating()
if rating > rating_max:
rating_max = rating
best_rated_book = book
else:
continu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def highest_rated_book(self):\n highest_rated = 0.0\n top_rated_book = \"\"\n\n for book in self.books.keys():\n book_rating = book.get_average_rating()\n if book_rating > highest_rated:\n highest_rated = book_rating\n top_rated_book = book.t... | [
"0.83557385",
"0.7634373",
"0.64668053",
"0.646497",
"0.64457583",
"0.6311305",
"0.62297416",
"0.6174505",
"0.6174505",
"0.60736984",
"0.6066756",
"0.6059369",
"0.6034711",
"0.6018782",
"0.6013541",
"0.59976643",
"0.5940475",
"0.59375906",
"0.5909446",
"0.5899124",
"0.5861581... | 0.8604043 | 0 |
Returns user with highest average rating | def most_positive_user(self):
rating_max = 0
rating_max_user = ""
for user in self.users.values():
rating = user.get_average_rating()
if rating > rating_max:
rating_max = rating
rating_max_user = user
else:
conti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_average_rating(self):\n count = 0\n total = 0\n num_books = len(self.books)\n if num_books > 0:\n for rating in self.books.values():\n if rating:\n count += 1\n total += rating\n average = total / count\n... | [
"0.70983166",
"0.6912731",
"0.68344504",
"0.6794513",
"0.67550117",
"0.6752274",
"0.6622795",
"0.6618791",
"0.657425",
"0.655887",
"0.6550182",
"0.65312135",
"0.6514526",
"0.65007603",
"0.64462924",
"0.64313",
"0.6414315",
"0.6395596",
"0.638889",
"0.6372267",
"0.63228005",
... | 0.7960793 | 0 |
Returns the number of most read books | def get_n_most_read_books(self, n):
if type(n) != int:
print("The argument n = {n} is not an integer. Try again with an integer".format(n=n))
else:
sorted_books = [ book for book in sorted(self.books, key=self.books.get, reverse=True)]
return sorted_books | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def most_read_book(self):\n reading_max = 0\n most_reads = \"\"\n for book in self.books.keys():\n rating = book.get_average_rating()\n if rating > reading_max:\n most_reads = book\n reading_max = rating\n else:\n co... | [
"0.8219369",
"0.71462387",
"0.66454923",
"0.6578928",
"0.65045106",
"0.64410865",
"0.6415552",
"0.63523734",
"0.63387",
"0.63387",
"0.62491214",
"0.6203123",
"0.61888176",
"0.6156324",
"0.6140114",
"0.6134548",
"0.6096439",
"0.60852206",
"0.60635096",
"0.6039976",
"0.6030021"... | 0.7380969 | 1 |
Send debug email to admins. | def send_debug_email(subject, message):
if not subject:
site = get_current_site()
subj = _s('DEBUG_MSG_SUBJECT') or _msg('subject_debug_msg')
subject = '%s: %s' % (site.name, subj)
mail_admins(subject, message, fail_silently=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email_admins(subject, message):\n mail_admins(subject, message=message)",
"def mail_admins(subject, message, fail_silently=False):\n _mail_group(settings.ADMINS, subject, message, fail_silently)",
"def sendadminlog( override=0 ):\n\n global admin_notify_time\n global adminlog\n\n if override... | [
"0.700624",
"0.69679296",
"0.66619134",
"0.66101164",
"0.6536322",
"0.6381845",
"0.6261297",
"0.62524307",
"0.6221707",
"0.6198986",
"0.6173385",
"0.6040536",
"0.6029444",
"0.5963833",
"0.58713526",
"0.58485705",
"0.5809431",
"0.5787586",
"0.5785166",
"0.5740776",
"0.5717475"... | 0.71638185 | 0 |
Send emails to a group. | def send_email_to_group(group, subject, message, fail_silently=False):
if isinstance(group, basestring):
members = get_users_in_group(group)
recipients = [user.email for user in members if user.email]
elif isinstance(group, (list, tuple)):
recipients = group
try:
assert recip... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _mail_group(group, subject, message, fail_silently=False):\n if group:\n mail.send_mail(settings.EMAIL_SUBJECT_PREFIX + subject, message,\n settings.SERVER_EMAIL, [a[1] for a in group],\n fail_silently)\n return\n # If the group had no recipients defined,... | [
"0.80707854",
"0.6781871",
"0.65694135",
"0.63916755",
"0.63060516",
"0.6281303",
"0.62803423",
"0.62803423",
"0.62693524",
"0.6259856",
"0.6252528",
"0.62140393",
"0.6206107",
"0.618567",
"0.6172113",
"0.61584634",
"0.6157868",
"0.6145838",
"0.61180377",
"0.6111764",
"0.6086... | 0.72258323 | 1 |
Private helper to aggregate SHAP values into bins of related features. | def __calculate_agg_shap_scores(self):
self.agg_stats_timer = SimbaTimer(start=True)
for clf_state, clf_state_name in zip(range(2), ["ABSENT", "PRESENT"]):
self.results = {}
self.df_save_path = os.path.join(
self.shap_logs_path,
"SHAP_summary_{}_{}... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform_bins(self, X):\n binner = self.binner_\n if hasattr(binner, \"tree_\"):\n dec_path = self.binner_.decision_path(X)\n association = numpy.zeros((X.shape[0],))\n association[:] = -1\n for j in self.leaves_:\n ind = dec_path[:, j] ... | [
"0.536685",
"0.53028756",
"0.5297548",
"0.52773046",
"0.527647",
"0.52717435",
"0.52448034",
"0.5239028",
"0.52265066",
"0.51943",
"0.5178747",
"0.51728415",
"0.516949",
"0.5167684",
"0.51604414",
"0.5151585",
"0.5139538",
"0.51359856",
"0.5125312",
"0.5120589",
"0.51111573",... | 0.62239313 | 0 |
Private helper to insert the data (i.e., colored arrows, text etc.) into the aggregate shap value visualization and save the results. | def __insert_data_in_img(self):
data_df = pd.read_csv(
os.path.join(
self.shap_logs_path,
"SHAP_summary_{}_{}_{}.csv".format(
self.classifier_name, "PRESENT", self.datetime
),
),
index_col=0,
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def processData(self):\n recordSet = AresChartsService.toMultiSeries(self.vals, self.chartKeys, self.selectedX , self.chartVals, extKeys=self.extKeys)\n self.aresObj.jsGlobal.add(\"data_%s = %s\" % (self.htmlId, json.dumps(recordSet)))",
"def visualise(self):\n\n scores, education = self.get_data()\... | [
"0.56197286",
"0.55523324",
"0.55266005",
"0.5514512",
"0.548664",
"0.54803073",
"0.54062796",
"0.5351485",
"0.5340591",
"0.5303771",
"0.5253525",
"0.52418655",
"0.52133983",
"0.5205377",
"0.5180938",
"0.51616275",
"0.51548773",
"0.5126836",
"0.5116849",
"0.5104162",
"0.50907... | 0.6141829 | 0 |
Extract features from a sentence represented as a list of words. Includes a flag add_to_indexer to | def extract_features(self, ex_words: List[str], add_to_indexer: bool) -> List[int]:
raise Exception("Don't call me, call my subclasses") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_features(self, ex_words: List[str], add_to_indexer: bool=False) -> List[int]:\n raise Exception(\"Don't call me, call my subclasses\")",
"def _sentence_to_features(self,sentence):\n\n configured_features = self.configFeatures\n sentence_features = []\n\n for word_idx in ra... | [
"0.73790205",
"0.70586795",
"0.6696932",
"0.66269016",
"0.66092473",
"0.6585194",
"0.65552074",
"0.65417784",
"0.65111244",
"0.64883614",
"0.64856535",
"0.647473",
"0.64737093",
"0.6448127",
"0.64132744",
"0.63529783",
"0.631795",
"0.63178784",
"0.62807816",
"0.62771124",
"0.... | 0.739767 | 0 |
Train a classifier with the perceptron. | def train_perceptron(train_exs: List[SentimentExample], feat_extractor: FeatureExtractor) -> PerceptronClassifier:
raise Exception("Must be implemented") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(self):\n sys.stderr.write(\"Training Multi-layer Perceptron classifier...\")\n self.clf.fit(self.m_features,self.target)\n sys.stderr.write(\"\\n\")\n \n # save the trained model to file\n with open(os.path.join(self.conf[\"paths\"][\"dir\"],self.conf[\"paths\"][... | [
"0.7362925",
"0.72427166",
"0.7166918",
"0.6913629",
"0.6894902",
"0.6865036",
"0.6854908",
"0.6839923",
"0.6704421",
"0.6680698",
"0.66646695",
"0.66574335",
"0.6651779",
"0.66505635",
"0.6620633",
"0.659549",
"0.65892136",
"0.6542741",
"0.6473617",
"0.64566743",
"0.64548427... | 0.80276585 | 0 |
Checks that position_adjustment returns the correct number of steps to be subtracted or added when the position is on the top of a snake or the bottom of a ladder. Checks that position_adjustment returns 0 when the position is elsewhere. | def test_position_adjustment(self):
board = ss.Board()
assert board.position_adjustment(8) == 10-8
assert board.position_adjustment(56) == 37-56
assert board.position_adjustment(63) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position_adjustment(self, position):\n changed_position = 0\n if position in self.ladders:\n return self.ladders[position] - position\n elif position in self.snakes:\n return self.snakes[position] - position\n return changed_position",
"def move(self): # A... | [
"0.7006407",
"0.57940966",
"0.5752311",
"0.5737879",
"0.5507167",
"0.5448012",
"0.5397324",
"0.53276736",
"0.53084916",
"0.5283515",
"0.51824796",
"0.5147287",
"0.5136505",
"0.50920564",
"0.5078422",
"0.50565064",
"0.50441754",
"0.50383854",
"0.50056046",
"0.49715185",
"0.494... | 0.6700563 | 1 |
Test that ResilientPlayer takes one extra step after sliding down a snake | def test_move_default_extra_steps(self):
player = ss.ResilientPlayer()
random.seed(2)
player.move()
random.seed(1)
player.move()
random.seed(2)
player.move()
assert player.position == 32 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_move_dropped_steps_greater_than_move(self):\n player = ss.LazyPlayer(dropped_steps=3)\n random.seed(2)\n player.move()\n random.seed(2)\n player.move()\n assert player.position == 40",
"def test_move_default_dropped_steps(self):\n player = ss.LazyPlayer()... | [
"0.70096105",
"0.68935305",
"0.6807493",
"0.6662498",
"0.6447271",
"0.64209694",
"0.6270427",
"0.62414765",
"0.62204564",
"0.615403",
"0.6151527",
"0.6132511",
"0.6118273",
"0.6114965",
"0.609501",
"0.6090467",
"0.6063974",
"0.6044024",
"0.59939027",
"0.59865755",
"0.5981301"... | 0.69973004 | 1 |
Test that LazyPlayer takes one step less after going up a ladders. | def test_move_default_dropped_steps(self):
player = ss.LazyPlayer()
random.seed(2)
player.move()
random.seed(5)
player.move()
assert player.position == 44 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_move_dropped_steps_greater_than_move(self):\n player = ss.LazyPlayer(dropped_steps=3)\n random.seed(2)\n player.move()\n random.seed(2)\n player.move()\n assert player.position == 40",
"def test_move_default_extra_steps(self):\n player = ss.ResilientPlaye... | [
"0.75017583",
"0.6730324",
"0.66294205",
"0.63773066",
"0.6272609",
"0.6240576",
"0.61570513",
"0.60627896",
"0.60356265",
"0.5989407",
"0.59687805",
"0.5958815",
"0.5957419",
"0.5949568",
"0.5922356",
"0.59057784",
"0.5904189",
"0.58874583",
"0.58812684",
"0.58393806",
"0.58... | 0.7022837 | 1 |
Tests that LazyPlayer dont move backwards when dropped steps are greater than the next move | def test_move_dropped_steps_greater_than_move(self):
player = ss.LazyPlayer(dropped_steps=3)
random.seed(2)
player.move()
random.seed(2)
player.move()
assert player.position == 40 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_move_default_dropped_steps(self):\n player = ss.LazyPlayer()\n random.seed(2)\n player.move()\n random.seed(5)\n player.move()\n assert player.position == 44",
"def test_move_default_extra_steps(self):\n player = ss.ResilientPlayer()\n random.seed(... | [
"0.7334365",
"0.6641269",
"0.6475652",
"0.61387503",
"0.6134772",
"0.61291",
"0.61152625",
"0.61019933",
"0.60483176",
"0.6041911",
"0.60396975",
"0.6018119",
"0.59843713",
"0.59796757",
"0.59768015",
"0.59652007",
"0.5950277",
"0.5939433",
"0.59343606",
"0.58857846",
"0.5875... | 0.8197672 | 0 |
Tests that single_game returns a tuple. | def test_single_game_returns_tuple(self):
sim = ss.Simulation()
assert type(sim.single_game()) == tuple, 'single_game should return ' \
'tuple' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_single_tuple(self):\n conn = self.connect()\n c = conn.cursor()\n self.safe_create_table(\n conn, \"mystuff\", \"create table mystuff (id integer primary key)\"\n )\n c.execute(\"insert into mystuff (id) values (1)\")\n c.execute(\"insert into mystuff (... | [
"0.6713088",
"0.6669579",
"0.66490626",
"0.6488279",
"0.638762",
"0.6362186",
"0.63546574",
"0.62094206",
"0.6190039",
"0.6178856",
"0.6135326",
"0.6129589",
"0.60323733",
"0.59669423",
"0.5964204",
"0.5952256",
"0.593679",
"0.590705",
"0.58496106",
"0.58379227",
"0.5782221",... | 0.89493525 | 0 |
Tests that two games of single_game is different from each other, when the seed is different. | def test_single_game_works(self):
sim = ss.Simulation(seed=154)
game1 = sim.single_game()
sim = ss.Simulation(seed=79)
game2 = sim.single_game()
assert game1 != game2, 'Your method single_game is not working.' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_single_game_seed_works(self):\n sim = ss.Simulation(seed=23)\n game1 = sim.single_game()\n sim = ss.Simulation(seed=23)\n game2 = sim.single_game()\n assert game1 == game2, 'Your seed in Simulation class is not working.'",
"def test_equal(self):\r\n\r\n a_players = ... | [
"0.81157404",
"0.7059727",
"0.69203585",
"0.66897315",
"0.6630781",
"0.66151136",
"0.6483109",
"0.64159",
"0.64131045",
"0.6410941",
"0.6346281",
"0.6270911",
"0.62650096",
"0.6246768",
"0.6201503",
"0.6187887",
"0.617865",
"0.6160666",
"0.6155558",
"0.615349",
"0.61270845",
... | 0.8136826 | 0 |
Tests that two games of single_game is equal, when the seed is the same. | def test_single_game_seed_works(self):
sim = ss.Simulation(seed=23)
game1 = sim.single_game()
sim = ss.Simulation(seed=23)
game2 = sim.single_game()
assert game1 == game2, 'Your seed in Simulation class is not working.' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_single_game_works(self):\n sim = ss.Simulation(seed=154)\n game1 = sim.single_game()\n sim = ss.Simulation(seed=79)\n game2 = sim.single_game()\n assert game1 != game2, 'Your method single_game is not working.'",
"def test_equal(self):\r\n\r\n a_players = [ZeroPlaye... | [
"0.81622756",
"0.7525932",
"0.67783153",
"0.6768772",
"0.6753167",
"0.65783197",
"0.6494036",
"0.63991237",
"0.6323125",
"0.63176376",
"0.6263558",
"0.6230478",
"0.6161638",
"0.6111521",
"0.60287315",
"0.6027688",
"0.60109663",
"0.60015196",
"0.5999746",
"0.5993655",
"0.59832... | 0.84178203 | 0 |
Tests that run_simulation returns nothing | def test_run_simulation_returns_nothing(self):
sim = ss.Simulation()
assert sim.run_simulation(10) is None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_empty_simulation(self):\n config = {\n 'network_params': {\n 'path': join(ROOT, 'test.gexf')\n },\n 'agent_type': 'BaseAgent',\n 'environment_params': {\n }\n }\n s = simulation.from_config(config)\n s.run_si... | [
"0.77626854",
"0.77274764",
"0.74112415",
"0.7303463",
"0.7178668",
"0.71074367",
"0.7069148",
"0.70681214",
"0.69160265",
"0.6719179",
"0.667552",
"0.6662267",
"0.6497731",
"0.6358623",
"0.6342628",
"0.63359886",
"0.63049287",
"0.6286854",
"0.62855214",
"0.62635136",
"0.6245... | 0.89247197 | 0 |
Tests that run_simulation stores the results | def test_run_simulation_stores_result(self):
sim = ss.Simulation()
assert sim.results == []
sim.run_simulation(10)
assert sim.results != []
assert len(sim.results) == 10 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_results_returns_all_results(self):\n sim = ss.Simulation()\n sim.run_simulation(7)\n assert len(sim.get_results()) == 7",
"def test_simulation(self):\n\t\tprint \"Simulation is being tested\"\n\n\t\tif toggles.DEBUG_FLAG:\n\t\t\tprint \"Debug Flag Set!\"\n\t\t\tprint self.getCon... | [
"0.72314996",
"0.7085128",
"0.6999844",
"0.6956875",
"0.69383395",
"0.69112194",
"0.6830327",
"0.667656",
"0.6667437",
"0.6664308",
"0.66560996",
"0.66404295",
"0.66325206",
"0.6628107",
"0.6608726",
"0.6588195",
"0.65533656",
"0.6500293",
"0.6482116",
"0.6476763",
"0.6472531... | 0.86449283 | 0 |
Tests that get_results returns a list consisting of tuples. | def test_get_results_returns_list_of_tuples(self):
sim = ss.Simulation()
sim.run_simulation(5)
assert type(sim.get_results()) == list
assert type(sim.get_results()[0]) == tuple | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_results(self):\n result = self.test_client._results\n\n assert isinstance(result, list)\n assert len(result) == 1",
"def test_get_results(self):\n pass",
"def getResults():",
"def assertManyResults(self, function, args, results):\r\n for arg, result in zip(args, re... | [
"0.738146",
"0.7208044",
"0.69072825",
"0.6727127",
"0.65326715",
"0.650097",
"0.64806813",
"0.6463932",
"0.6344955",
"0.6324502",
"0.63131404",
"0.6305193",
"0.6211632",
"0.6172891",
"0.613735",
"0.6124938",
"0.61014163",
"0.6091535",
"0.6090757",
"0.6073068",
"0.60141456",
... | 0.8084668 | 0 |
Tests that winners_per_type returns a dictionary | def test_winners_per_type_returns_dict(self):
sim = ss.Simulation()
assert type(sim.winners_per_type()) == dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_players_per_type(self):\n sim = ss.Simulation()\n assert type(sim.players_per_type()) == dict",
"def test_winners_per_type_num_players(self):\n type_of_player = [ss.Player, ss.LazyPlayer, ss.ResilientPlayer]\n sim = ss.Simulation(player_field=type_of_player)\n run = si... | [
"0.7460475",
"0.73244834",
"0.7059976",
"0.7026087",
"0.68466777",
"0.6143772",
"0.5960847",
"0.5940492",
"0.5801115",
"0.57970756",
"0.57904345",
"0.57599425",
"0.5712648",
"0.56462806",
"0.5638244",
"0.56253624",
"0.56001174",
"0.5587972",
"0.5526351",
"0.54692185",
"0.5445... | 0.85515326 | 0 |
Tests that total wins are equal to numbers of simulation. | def test_winners_per_type_sum(self):
sim = ss.Simulation()
sim.run_simulation(14)
winners = sim.winners_per_type()
assert sum(winners.values()) == 14 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_play_game_hard(self):\r\n wins = [0,0,0]\r\n\r\n for i in range(1,10):\r\n a_player_1_id = 1\r\n a_player_2_id = 2\r\n a_players = [RandomPlayer(a_player_1_id), RandomPlayer(a_player_2_id)]\r\n a_x_dist = i\r\n a_y_dist = i\r\n a_num_to_win = 3\r\n a_game = Game(a_... | [
"0.66540855",
"0.6641283",
"0.651022",
"0.6439688",
"0.6402664",
"0.639706",
"0.63893235",
"0.6287492",
"0.62694687",
"0.62559384",
"0.6249074",
"0.6247421",
"0.62210906",
"0.62149644",
"0.6180857",
"0.6174532",
"0.6166144",
"0.61484927",
"0.6138867",
"0.6131443",
"0.6127531"... | 0.6798297 | 0 |
Tests that durations_per_type returns a dictionary | def test_durations_per_type(self):
sim = ss.Simulation()
assert type(sim.durations_per_type()) == dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def durations_per_type(self):\n pass",
"def test_durations_per_type_num_players(self):\n type_of_player = [ss.Player, ss.LazyPlayer, ss.ResilientPlayer]\n sim = ss.Simulation(player_field=type_of_player)\n run = sim.durations_per_type()\n assert list(run.keys()) == ['Player', '... | [
"0.76126635",
"0.69130933",
"0.6763132",
"0.64169866",
"0.6288302",
"0.62874055",
"0.6248118",
"0.6223497",
"0.61402684",
"0.60638607",
"0.60624653",
"0.5815379",
"0.58149046",
"0.5737329",
"0.572361",
"0.57040614",
"0.56947976",
"0.56464267",
"0.56448644",
"0.56156546",
"0.5... | 0.87039316 | 0 |
Tests that players_per_type returns dictionary | def test_players_per_type(self):
sim = ss.Simulation()
assert type(sim.players_per_type()) == dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_players_per_type_num_players(self):\n type_of_player = [ss.Player, ss.LazyPlayer, ss.ResilientPlayer]\n sim = ss.Simulation(player_field=type_of_player)\n run = sim.players_per_type()\n assert list(run.keys()) == ['Player', 'LazyPlayer', 'ResilientPlayer']",
"def test_winners... | [
"0.75420964",
"0.74724466",
"0.7354364",
"0.7230678",
"0.7132466",
"0.7039844",
"0.6974464",
"0.6378547",
"0.6147127",
"0.61053926",
"0.60057855",
"0.59874344",
"0.5845814",
"0.5840158",
"0.58341056",
"0.58270174",
"0.5779566",
"0.56687707",
"0.56667966",
"0.56376815",
"0.563... | 0.86458623 | 0 |
Tests that all types of players are present | def test_players_per_type_num_players(self):
type_of_player = [ss.Player, ss.LazyPlayer, ss.ResilientPlayer]
sim = ss.Simulation(player_field=type_of_player)
run = sim.players_per_type()
assert list(run.keys()) == ['Player', 'LazyPlayer', 'ResilientPlayer'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_players_per_type_num_players_less(self):\n type_of_player = [ss.Player, ss.LazyPlayer, ss.Player]\n sim = ss.Simulation(player_field=type_of_player)\n run = sim.players_per_type()\n assert list(run.keys()) == ['Player', 'LazyPlayer']",
"def test_winners_per_type_num_players(s... | [
"0.747361",
"0.72424835",
"0.71909654",
"0.7176628",
"0.66306865",
"0.6498127",
"0.6485009",
"0.6362596",
"0.63391715",
"0.6321425",
"0.62221444",
"0.62081015",
"0.6085177",
"0.6054983",
"0.604946",
"0.60428005",
"0.60109454",
"0.5990627",
"0.598319",
"0.59704417",
"0.5966648... | 0.7571244 | 0 |
Tests that all types of players are present, but not those who aren't | def test_players_per_type_num_players_less(self):
type_of_player = [ss.Player, ss.LazyPlayer, ss.Player]
sim = ss.Simulation(player_field=type_of_player)
run = sim.players_per_type()
assert list(run.keys()) == ['Player', 'LazyPlayer'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_players_per_type_num_players(self):\n type_of_player = [ss.Player, ss.LazyPlayer, ss.ResilientPlayer]\n sim = ss.Simulation(player_field=type_of_player)\n run = sim.players_per_type()\n assert list(run.keys()) == ['Player', 'LazyPlayer', 'ResilientPlayer']",
"def test_winners... | [
"0.69676596",
"0.6959566",
"0.66561633",
"0.6559737",
"0.6464441",
"0.6401887",
"0.63817614",
"0.61773103",
"0.6123407",
"0.61129445",
"0.6079212",
"0.6024275",
"0.60000664",
"0.5969238",
"0.59636134",
"0.5949633",
"0.5917091",
"0.5904456",
"0.58702326",
"0.5864484",
"0.58623... | 0.72699636 | 0 |
Undoes the Project.Basecamp monkeypatching. | def _unmock_basecamp_access(self):
Project.BasecampProject = self._real_Basecamp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDown(self):\n builtins.__import__ = self.original_imports",
"def monkeymodule():\n from _pytest.monkeypatch import MonkeyPatch\n\n mpatch = MonkeyPatch()\n yield mpatch\n mpatch.undo()",
"def _mock_basecamp_access(self, klass=TestBasecampProject):\n self._real_Basecamp = Proje... | [
"0.59395653",
"0.58390504",
"0.58148414",
"0.5738623",
"0.566452",
"0.5581741",
"0.55454665",
"0.5515342",
"0.5504153",
"0.5504153",
"0.5504153",
"0.5504153",
"0.5504153",
"0.5504153",
"0.5504153",
"0.5504153",
"0.5504153",
"0.5504153",
"0.5496307",
"0.5442506",
"0.54260296",... | 0.75654894 | 0 |
Creates a Project instance, using valid test defaults unless overridden in kwargs. | def create_project(self, **kwargs):
save = kwargs.get('save', True)
if kwargs.has_key('save'):
del(kwargs['save'])
index = self.object_index()
defaults = dict(slug = "test-project-%s" % index,
basecamp_url = "https://foo.basecamphq.com/projects/%s/log" % index)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_project(self):\n pass",
"def test_create_project(self):\n pass",
"def test_create_project(self):\n pass",
"def make_instance(self, include_optional):\n # model = openapi_client.models.project.Project() # noqa: E501\n if include_optional :\n retur... | [
"0.67377275",
"0.67377275",
"0.67377275",
"0.6733338",
"0.6641121",
"0.6638232",
"0.65400493",
"0.6437412",
"0.6354441",
"0.6295501",
"0.6262486",
"0.6259553",
"0.6158875",
"0.6155135",
"0.6154907",
"0.6152247",
"0.613277",
"0.6126964",
"0.6112704",
"0.60817903",
"0.6050086",... | 0.76378614 | 0 |
Create a Dashboard object, using the optional kwargs. If save=False the object is returned without saving. | def create_dashboard(self, save=True, **kwargs):
index = self.object_index()
if not kwargs: kwargs = dict(name="Test Dashboard %s" % index, slug="test-dashboard-%s" % index)
d = Dashboard(**kwargs)
if not save: return d
d.save()
self.assert_(d.id) #Cheap validit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createNewDashboard(userId, name):\n if Dashboard.objects(analystId=userId,name=name):\n return\n newDash = Dashboard()\n newDash.name = name\n newDash.analystId = userId\n newDash.save()\n return newDash",
"def create_dashboard_for_model(self, model_id, model_version=None):\r\n ... | [
"0.6506736",
"0.594477",
"0.59374374",
"0.59303516",
"0.5777631",
"0.57741624",
"0.57482916",
"0.5740831",
"0.56932694",
"0.56458133",
"0.5591037",
"0.5591037",
"0.5591037",
"0.5546158",
"0.55446786",
"0.55230343",
"0.5511173",
"0.5475626",
"0.54752666",
"0.54465854",
"0.5432... | 0.8463067 | 0 |
Returns new proposed values of position and momentum | def get_proposed_values(self):
return self.new_position, self.new_momentum, self.new_grad_logp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_proposed_values(self):\n # Take half step in time for updating momentum\n momentum_bar = self.momentum + 0.5*self.stepsize*self.model.grad_logp(self.position)\n\n # Take full step in time for updating position position\n position_bar = self.position + self.stepsize * momentum_bar\n\n grad_l... | [
"0.7411179",
"0.666384",
"0.6383803",
"0.62856805",
"0.6269769",
"0.6232472",
"0.62020135",
"0.602636",
"0.6011399",
"0.5948838",
"0.59457713",
"0.591209",
"0.5779166",
"0.57611746",
"0.5720674",
"0.5699017",
"0.5695794",
"0.56951565",
"0.5688441",
"0.5683125",
"0.566046",
... | 0.7505171 | 0 |
Print display number for active session (s) | def display_nbr(ctx, as_port=False):
ctl = ctx.ctl
jobs = ctl('list-avail', '--partition', 'main', flatten=False)
if len(jobs) == 0:
click.echo('No jobs running', err=True)
sys.exit(1)
for job in jobs:
info = collect_vnc_info(ctl, job['id'], ctx.ssh_cfg)
if as_port:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def showlinuxsession():\n print('\\nAPI-KEY: {0}'.format(middleware.ixn.apiKey))\n print('Session ID: {0}'.format(middleware.ixn.sessionId.split('/')[-1]))\n print()",
"def nice_output(self):\n return 'Inning {0}'.format(self.num)",
"def display_number(com,count):\n print \"NUM: ... | [
"0.67021835",
"0.62630767",
"0.6156052",
"0.58835924",
"0.5844819",
"0.58337957",
"0.58275574",
"0.5784338",
"0.5745291",
"0.5731504",
"0.5729567",
"0.5720762",
"0.57092357",
"0.5697654",
"0.5697105",
"0.569234",
"0.56872183",
"0.5678447",
"0.5677368",
"0.5674415",
"0.5670849... | 0.67820513 | 0 |
Initializes a model by invoking the _declarative_constructor in SQLAlchemy. We do this for full control over construction of an object | def __init__(self, **kwargs):
_declarative_constructor(self, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_model(self):\n pass",
"def init_model(self):\n pass",
"def initialize_model(self):\n model = self.model_class()\n return model",
"def initialize(self, model):\n pass",
"def __init__(self):\n self.conf = None\n self.section = None\n self... | [
"0.73547405",
"0.73199743",
"0.73054415",
"0.71788186",
"0.7161744",
"0.7003624",
"0.6982105",
"0.6978932",
"0.6933112",
"0.6892595",
"0.6869878",
"0.68538994",
"0.6825778",
"0.6809685",
"0.680115",
"0.6790181",
"0.67675006",
"0.6754955",
"0.67461616",
"0.6728338",
"0.6725077... | 0.79548216 | 0 |
Counts how many of the words in words is in the string | def count(words: list, string: str) -> int:
count = 0
for word in words:
if word in string:
count += 1
return count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_count(string):\n counts = dict()\n words = string.split()\n\n for word in words:\n if word in counts:\n counts[word] += 1\n else:\n counts[word] = 1\n\n return len(counts)",
"def word_count(phrase):\n return collections.Counter(phrase.split())",
"def ... | [
"0.8396281",
"0.8102105",
"0.8020761",
"0.79431856",
"0.79333764",
"0.78711873",
"0.78288954",
"0.77515197",
"0.76638436",
"0.7632681",
"0.75856996",
"0.7585386",
"0.75299984",
"0.75235",
"0.7513716",
"0.7484651",
"0.74768686",
"0.7471442",
"0.73890334",
"0.738431",
"0.735072... | 0.8242722 | 1 |
returns True if should be applied inline | def is_inline(self):
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _isinline(self, tagname):\n return False",
"def is_inline(self):\n\t\treturn self.name in get_elements_collection(self.__res, 'inline_level')",
"async def toggle_inline(self,ctx):\n self.inline = not self.inline",
"def inline(self, *args, **kwargs):\n pass",
"def check_inline(self,... | [
"0.77492195",
"0.7354087",
"0.6929993",
"0.67634755",
"0.67171144",
"0.65181583",
"0.6015258",
"0.59730154",
"0.58445996",
"0.5717896",
"0.566447",
"0.5585809",
"0.55486566",
"0.5530199",
"0.552938",
"0.55007964",
"0.5497933",
"0.5411998",
"0.5401784",
"0.5384311",
"0.5361384... | 0.83974105 | 0 |
Registration view This function get email and password from json request, check if email isn't in db add email and password into db, set status_id to 'Non_active', generate and send urltoken to user email. | def registration_view(request):
json = request.json_body
user_query = User.get_user_by_email(request, request.json['email'])
nickname_query = User\
.get_user_by_nickname(request, request.json['nickname'])
if user_query is None:
if nickname_query is None:
url_token_confirmatio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register():\n if request.method == 'POST':\n details = request.get_json()\n name = details.get('name')\n email = details.get('email')\n national_id = details.get('national_id')\n is_admin = details.get('admin')\n password = details.get('password')\n confirm_p... | [
"0.71419096",
"0.7078366",
"0.69472104",
"0.693519",
"0.6849618",
"0.6833757",
"0.6800396",
"0.67971",
"0.6776243",
"0.6734129",
"0.672741",
"0.6721706",
"0.67000985",
"0.6641306",
"0.6616081",
"0.6606314",
"0.6594442",
"0.6594169",
"0.65885717",
"0.65880513",
"0.6569257",
... | 0.79071903 | 0 |
Confirm registration view This function get url_token, check if it isn't in db return the 404 Error. If url_token is in db, this function create url address, change status_id to 'Active', and set role_id to 'user' | def confirm_registration_view(request):
user_email_token = request.matchdict['email_confirm']
non_active_user = User.get_one(request, url_token=user_email_token)
if non_active_user is None:
return {"msg": "Error404 HTTPNotFound"}
else:
non_active_user.status_id = UserStatus\
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def registration_view(request):\n json = request.json_body\n user_query = User.get_user_by_email(request, request.json['email'])\n nickname_query = User\\\n .get_user_by_nickname(request, request.json['nickname'])\n if user_query is None:\n if nickname_query is None:\n url_toke... | [
"0.6548345",
"0.6258552",
"0.61127406",
"0.608939",
"0.58567214",
"0.57589483",
"0.5681468",
"0.5643639",
"0.5612052",
"0.5604041",
"0.5584628",
"0.55466235",
"0.55418366",
"0.5535246",
"0.55350983",
"0.55026156",
"0.5497721",
"0.5479488",
"0.5478785",
"0.5464513",
"0.5454822... | 0.6808517 | 0 |
Test on creating todo using various string | def test_creating_todo(todoApp, input):
# Create new todo
new_todo_input = todoApp.find_new_todo_input()
print new_todo_input
new_todo_input.send_keys(input, Keys.ENTER)
# ASSERTION
# Check whether the new todo exist in the todo list or not.
todo = todoApp.find_todo(input)
# Check the new todo sta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_a_todo(self):\n # hit the API endpoint\n response = self.make_a_request(\n kind=\"post\",\n version=\"v1\",\n data=self.valid_data\n )\n self.assertEqual(response.data, self.valid_data)\n self.assertEqual(response.status_code, stat... | [
"0.7448695",
"0.7200586",
"0.7179226",
"0.70477134",
"0.67458063",
"0.6732294",
"0.67137444",
"0.6646171",
"0.658738",
"0.64375156",
"0.6411311",
"0.6406063",
"0.63943994",
"0.63770974",
"0.6347952",
"0.63256353",
"0.6297843",
"0.6278811",
"0.61461645",
"0.60870665",
"0.60866... | 0.74891263 | 0 |
Handles putio.get_items request with better error handling. Since the putio API will hand back HTTP exception all the time this function will allow them to happen without crashing your script. If there are no items in a directory we return an empty list. Return A list of Item objects (from putio class...) or an empty l... | def get_items(self, parent=None, id_Number=None):
sigkill = 0
while 1:
try:
value = self.API.get_items(parent_id=parent, id=id_Number)
return value
except putio.PutioError as err:
if str(err) == "You have no items to show... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_items():\n return requester.perform_request(Uri.items)",
"def test_get_all_item(self, app, item):\n res = app.store_items.get_all_items(\n header=item.header,\n type_response=ItemsResponse,\n )\n assert res.status_code == 200",
"async def get_items(\n ... | [
"0.7251653",
"0.62557507",
"0.61749214",
"0.61535305",
"0.60895795",
"0.60632527",
"0.60632527",
"0.6048731",
"0.5943761",
"0.5902527",
"0.58333397",
"0.5765952",
"0.5759044",
"0.5714463",
"0.5705385",
"0.56921226",
"0.56823844",
"0.5629779",
"0.56284565",
"0.56101763",
"0.56... | 0.6713535 | 1 |
Figures out the full path to a file on Put.io itemID equals the id of the file which you want to determine the path. returns a string that contains the path of the file /foo/bar.txt | def putioPath(self, itemID=None):
path = self.get_items(id_Number=itemID)[0].name
while 1:
itemID = self.get_items(id_Number=itemID)[0].parent_id
if itemID == "0":
break
else:
path = self.get_items(id_Number=itemID)[0].name +... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetchPutIOFile(self, fileID=None, fileDir=None):\r\n\r\n sigkill = 0\r\n\r\n if fileID == None or fileDir == None:\r\n raise ValueError('You must send a putio item id and file path.')\r\n\r\n if not fileID in self.contents:\r\n self.getItem(fileID)\r\n\r\n file... | [
"0.65508145",
"0.6093909",
"0.605057",
"0.60210365",
"0.59997284",
"0.5959347",
"0.5940371",
"0.59336776",
"0.59185827",
"0.5912623",
"0.5863045",
"0.58628094",
"0.58371645",
"0.5830468",
"0.5817235",
"0.579462",
"0.5781786",
"0.5779269",
"0.5740309",
"0.5699368",
"0.5698278"... | 0.7573712 | 0 |
We will fetch a file and store it locally. fileID is the file ID of the file you want to download from put.io fileDir The file name and local directory to save the file. | def fetchPutIOFile(self, fileID=None, fileDir=None):
sigkill = 0
if fileID == None or fileDir == None:
raise ValueError('You must send a putio item id and file path.')
if not fileID in self.contents:
self.getItem(fileID)
fileName = self.contents[file... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file(self, file_id, filename=''):\n method = 'getFile?' + 'file_id=' + str(file_id)\n res = requests.post(self.api_url + method, file_id)\n try:\n file_path = res.json()['result']['file_path']\n # Determine the fileName. Use modified file_path if none given.\n ... | [
"0.67713237",
"0.6571637",
"0.6508179",
"0.6468049",
"0.6434974",
"0.63675445",
"0.6354371",
"0.6251986",
"0.6228547",
"0.62186724",
"0.62175226",
"0.621723",
"0.6213369",
"0.61421895",
"0.61183006",
"0.6111253",
"0.60803854",
"0.60776365",
"0.60721976",
"0.6070534",
"0.60533... | 0.76239014 | 0 |
rotate point P about O by dtheta radians | def rotate_point_by(P:Vec3, O:Vec3, dtheta:float):
PO = P - O
R = norm2(PO)
cos_theta = PO.x / R
sin_theta = PO.y / R
cos_dtheta = cos(dtheta)
sin_dtheta = sin(dtheta)
cos_theta_plus_dtheta = cos_theta*cos_dtheta - sin_theta*sin_dtheta
sin_theta_plus_dthet... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate_about(self, p, theta):\n result = self.clone()\n result.translate(-p.x, -p.y)\n result.rotate(theta)\n result.translate(p.x, p.y)\n return result",
"def rotate(self, theta, point):\n r = self - point\n x = r.x * math.cos(theta) - r.y * math.sin(theta)\n... | [
"0.7366025",
"0.7336842",
"0.7231373",
"0.697945",
"0.6894734",
"0.68924886",
"0.6783059",
"0.67477643",
"0.6742044",
"0.6718778",
"0.6710311",
"0.66871434",
"0.665914",
"0.6606632",
"0.65712065",
"0.6569933",
"0.6564392",
"0.65294605",
"0.6525388",
"0.652423",
"0.6508847",
... | 0.88402575 | 0 |
Function to perform read operation with the database to get the top artist | def get_top_artist_tracks(session, number_of_artist):
try:
if not issubclass(type(session), sqlalchemy.orm.session.Session):
raise AttributeError("session not passed correctly, should be of type 'sqlalchemy.orm.session.Session' ")
if not issubclass(type(number_of_artist), int) or number... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_artists_most_played(session_):\n # artists = session_.query(Artist).order_by(Artist.name.asc()).paginate()\n artists = session_.query(Artist).order_by(Artist.plays.desc()).all()\n return artists",
"def top_artists_from_API(api_results):\r\n df = pd.DataFrame(api_results[\"items\"])\r\n col... | [
"0.6849134",
"0.66032416",
"0.65351725",
"0.6413231",
"0.63552356",
"0.63133323",
"0.62837493",
"0.6265987",
"0.6252838",
"0.6200527",
"0.61681056",
"0.6130825",
"0.6129044",
"0.61084133",
"0.61036533",
"0.60961986",
"0.6052323",
"0.6035289",
"0.6007485",
"0.5997498",
"0.5984... | 0.7609244 | 0 |
Add uniform noise to a given dataset. Function to add uniform random noise to a given dataset. Uniform noise in range [510^(p), 510^(p)] is added to each data entry. For integervalued sequences, p = 1. | def add_uniform_noise(data, p=1):
if p < 1:
raise ValueError("'p' has to be greater or equal to 1.")
noise = np.random.uniform(-5.*10**(-p), 5*10**(-p), size = len(data))
randomized_data = data + noise
# ensure there are no negative entries after noise is added
randomized_data = \
ra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_noise(self, data):",
"def uniform_noise_like(\n da: xr.DataArray, low: float = 1e-6, high: float = 1e-3\n) -> xr.DataArray:\n if uses_dask(da):\n mod = dsk\n kw = {\"chunks\": da.chunks}\n else:\n mod = np\n kw = {}\n\n return da.copy(\n data=(high - low) * ... | [
"0.7465272",
"0.7017835",
"0.69086975",
"0.68982387",
"0.68722546",
"0.68413025",
"0.68310094",
"0.6785632",
"0.6685227",
"0.664166",
"0.6633581",
"0.6620472",
"0.6596529",
"0.6596529",
"0.6562329",
"0.6559136",
"0.6473762",
"0.64221513",
"0.63911885",
"0.6359188",
"0.6347256... | 0.7983066 | 0 |
Logbinning of a distribution. | def logbin_distribution(data, nbins = 30):
# define the support of the distribution
lower_bound = min(data)
upper_bound = max(data)
# define bin edges
log = np.log10
lower_bound = log(lower_bound) if lower_bound > 0 else -1
upper_bound = log(upper_bound)
bins = np.logspace(lower_bound, u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bincalc(nbin=0.1,bmin=5,bmax=2000):\n\n logbmin=np.log10(bmin)\n logbmax=np.log10(bmax)\n\n logbins=np.arange(logbmin,logbmax,nbin)\n\n bins=10**logbins\n\n #bins=np.linspace(bmin,bmax,60)\n return (bins)",
"def logbin(data, scale = 1.3, zeros = False):\n if scale < 1:\n raise Val... | [
"0.66757274",
"0.6646079",
"0.62253493",
"0.6120671",
"0.6099856",
"0.60060704",
"0.5891733",
"0.5800523",
"0.5758203",
"0.5757172",
"0.5721329",
"0.57009387",
"0.5697628",
"0.56797785",
"0.5635742",
"0.5630419",
"0.5628087",
"0.56177866",
"0.5596117",
"0.55869347",
"0.558515... | 0.73683405 | 0 |
Get CCDF from a degree sequence. | def get_ccdf(degseq):
uniques, counts = np.unique(degseq, return_counts=True)
cumprob = np.cumsum(counts).astype(np.double) / (degseq.size)
return uniques[::-1], (1. - cumprob)[::-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cdf(self, points=None):\n if points is not None:\n return self.parent.cdf(points)\n else:\n raise ValueError( 'Please digit an input for getCDF method')",
"def getCDF(self):\n return self.cdfSample",
"def cdf(self,x):\n if self.method == 'spline':\n co... | [
"0.66865236",
"0.66738886",
"0.6528202",
"0.6394472",
"0.6394472",
"0.6280722",
"0.612189",
"0.6061525",
"0.6054699",
"0.6042136",
"0.6035633",
"0.6016287",
"0.59556776",
"0.59411925",
"0.593399",
"0.59306073",
"0.5848178",
"0.5825168",
"0.5806766",
"0.5793067",
"0.5657572",
... | 0.6885644 | 0 |
Get `eps_stop` from AMSE upper bound. Upper bound for order statistic to consider for doublebootstrap AMSE minimizer. Entries that are smaller or equal to the border value are ignored during AMSE minimization. | def get_eps_stop(data, amse_border=1, sort=True):
if sort:
data = np.sort(data)[::-1]
return 1 - len(data[np.where(data <= amse_border)]) / len(data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_eps(self, target_ess, upper, min_bisection_its=50, max_ess_error=0.01):\n # Return upper bound if it can't achieve target ESS\n w = self.get_alternate_weights(upper)\n ess = effective_sample_size(w)\n if ess < target_ess:\n return upper\n\n # Return lower boun... | [
"0.54890054",
"0.5254461",
"0.5224461",
"0.5161098",
"0.50961953",
"0.50945413",
"0.4922195",
"0.4905253",
"0.49029648",
"0.4899326",
"0.48968145",
"0.48947158",
"0.48665237",
"0.48532668",
"0.47960132",
"0.47947425",
"0.47858372",
"0.47762918",
"0.47524136",
"0.47450542",
"0... | 0.71831954 | 0 |
Factory function for transforming any iterable to a WindowedIterable. Can be used as a function in pipey pipeline. | def windowify(window_size):
def windowed(iterable):
return WindowedIterable(iterable, window_size)
return windowed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dewindowify(iterable):\n for _, current, _ in iterable:\n yield current",
"def window(iterable, stride=3):\n for i in range(len(iterable) - stride + 1):\n yield iterable[i: i + stride]",
"def iwindow(seq, n):\n it = iter(seq)\n result = tuple(islice(it, n))\n\n if len(result) =... | [
"0.65870017",
"0.6276887",
"0.6252061",
"0.5979201",
"0.59202135",
"0.5901803",
"0.5901803",
"0.5890584",
"0.5884487",
"0.5882071",
"0.58312255",
"0.58300227",
"0.5824383",
"0.5805883",
"0.5774541",
"0.57557213",
"0.5744897",
"0.5730951",
"0.57180876",
"0.5696275",
"0.5636358... | 0.79773754 | 0 |
Yields elements from a WindowedIterable without the cached windows. Can be used as a function in pipey pipeline. | def dewindowify(iterable):
for _, current, _ in iterable:
yield current | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unique_window(iterable, window, key = None):\n seen = collections.deque(maxlen = window)\n seen_add = seen.append\n if key is None:\n for element in iterable:\n if element not in seen:\n yield element\n seen_add(element)\n else:\n for element in it... | [
"0.64814496",
"0.64370525",
"0.63999337",
"0.6393452",
"0.6304972",
"0.6201049",
"0.61454827",
"0.61207074",
"0.59631115",
"0.59161437",
"0.588799",
"0.5862907",
"0.5833489",
"0.5828903",
"0.5827851",
"0.5813124",
"0.5795005",
"0.5790015",
"0.57886785",
"0.5785899",
"0.576882... | 0.73613864 | 0 |
Check for your latest match to verify $check | async def check(self,ctx):
try:
check = verify.check(ctx.message.author.id)
except Exception as e:
await self.bot.say('Error: ' +str(e)+'\n\nIf your match hasn\'t registered yet, wait 5-10 minutes or check http://discord.me/EZLBot for updates. Else, signup again with {}verify... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check():",
"def match(self) -> bool:",
"def verify():",
"def check(self) -> None:",
"def test_version_check_update_available(self):\n output = self.run_command(\"selfupdate --check bennr01:selfupdate_test_future\", exitcode=0)\n self.assertIn(\"Target: bennr01:selfupdate_test_future\", ou... | [
"0.6599547",
"0.61560607",
"0.60273844",
"0.60122466",
"0.59057695",
"0.5849235",
"0.58330333",
"0.58012295",
"0.5780078",
"0.5763232",
"0.5735489",
"0.56997085",
"0.5669704",
"0.56647074",
"0.56647074",
"0.56647074",
"0.56647074",
"0.56266236",
"0.5582165",
"0.55417573",
"0.... | 0.64390785 | 1 |
[Create prediction columns and add them to the self.predicted_columns dictionary] | def create_prediction_columns(self):
if is_classification(self.model) == True:
prediction, probabilities = self.make_predictions()
self.predicted_columns['Model Decision'] = prediction
self.predicted_columns['True Values'] = self.target_data
for i in range(len(np.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict(self, data, only_lp=True):\n df = self.model.transpose(data)\n if only_lp:\n df = df.select(self.label_index_name, self.prediction_name, self.probability)\n return df",
"def predict(data, model, final_columns, category_features, averages):\n new_data = extend_dummy_... | [
"0.66258246",
"0.66254413",
"0.66087073",
"0.6596617",
"0.6541436",
"0.653981",
"0.6455183",
"0.633809",
"0.6312074",
"0.62493366",
"0.6248378",
"0.6227264",
"0.61748564",
"0.6172468",
"0.61246616",
"0.6104596",
"0.6046965",
"0.6040922",
"0.60071677",
"0.59578884",
"0.594849"... | 0.85224473 | 0 |
Return the FeatureOperations that generated ``derived_column`` | def operations_from_derived_column(
self, derived_column: str
) -> List["FeatureOperation"]:
return list(
filter(
lambda op: op.derived_columns is not None
and derived_column in op.derived_columns,
self[derived_column],
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def original_columns_from_derived_column(self, derived_column: str) -> List[str]:\n operations = self.operations_from_derived_column(derived_column)\n\n if len(operations) > 1:\n raise RuntimeError(\n \"Multiple FeatureOperation found that generated column \"\n ... | [
"0.7034697",
"0.6264205",
"0.58456624",
"0.55798423",
"0.5506693",
"0.53352195",
"0.5264634",
"0.5252218",
"0.5208565",
"0.5165842",
"0.51332474",
"0.513137",
"0.51287925",
"0.512307",
"0.5089447",
"0.5088569",
"0.5083715",
"0.50238687",
"0.5020082",
"0.49969816",
"0.4994706"... | 0.7685979 | 0 |
Return the FeatureOperations applied on ``original_column`` | def operations_from_original_column(
self, original_column: str
) -> List["FeatureOperation"]:
return list(
filter(
lambda op: original_column in op.columns,
self[original_column],
)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def original_columns_from_derived_column(self, derived_column: str) -> List[str]:\n operations = self.operations_from_derived_column(derived_column)\n\n if len(operations) > 1:\n raise RuntimeError(\n \"Multiple FeatureOperation found that generated column \"\n ... | [
"0.61692166",
"0.61273307",
"0.58502436",
"0.55084825",
"0.54451436",
"0.54365456",
"0.53751487",
"0.52888155",
"0.5206171",
"0.5201663",
"0.508027",
"0.50541335",
"0.50530684",
"0.50475353",
"0.5007608",
"0.4991465",
"0.49836087",
"0.49430266",
"0.49388215",
"0.49367413",
"0... | 0.7905143 | 0 |
Return the name of the columns from which ``derived_column`` is generated. | def original_columns_from_derived_column(self, derived_column: str) -> List[str]:
operations = self.operations_from_derived_column(derived_column)
if len(operations) > 1:
raise RuntimeError(
"Multiple FeatureOperation found that generated column "
f"{derived_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def derived_columns_from_col(self, column: str) -> List[str]:\n derived_columns = []\n operations = self.operations_from_original_column(column)\n\n for operation in operations:\n if operation.derived_columns is not None:\n derived_columns.extend(operation.derived_col... | [
"0.68002284",
"0.6473398",
"0.6276224",
"0.62645346",
"0.624039",
"0.62050974",
"0.61963874",
"0.6118237",
"0.61114836",
"0.60975206",
"0.6070955",
"0.60598886",
"0.60405964",
"0.60157603",
"0.60076255",
"0.5958728",
"0.5958728",
"0.5935321",
"0.5919565",
"0.59103626",
"0.590... | 0.7360953 | 0 |
Return True if ``other`` is a OperationsList containing the same operations. | def __eq__(self, other: Any) -> bool:
if not isinstance(other, OperationsList):
return False
if not self._operations_list == other._operations_list:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other: SymbolicObject) -> bool:\n\n if isinstance(other, ListObject):\n return self._subobjects == other._subobjects\n else:\n return False",
"def __eq__(self, other):\n if not isinstance(other, CashFlowList):\n return False\n\n return... | [
"0.7605562",
"0.7011663",
"0.68128866",
"0.67968446",
"0.6753017",
"0.6692754",
"0.6628194",
"0.6615114",
"0.6595707",
"0.6594383",
"0.6566219",
"0.6549629",
"0.65435344",
"0.6532957",
"0.6516649",
"0.6473852",
"0.6468497",
"0.646396",
"0.645403",
"0.64523",
"0.64292806",
"... | 0.8506768 | 0 |
Helper function to add an audiobook to database | def add_audiobook(name, duration, author, narrator):
audiobook = AudioBook(
name=name,
duration=duration,
author=author,
narrator=narrator
)
db.session.add(audiobook)
db.session.commit()
return audiobook | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_audiobook(_title_of_the_audiobook, _author_of_the_title, _narrator,\r\n _duration_in_number_of_seconds):\r\n # creating an instance of our Audiobook constructor\r\n new_audiobook = Audiobook(title_of_the_audiobook=_title_of_the_audiobook,\r\n ... | [
"0.77613556",
"0.70807827",
"0.65985125",
"0.6316089",
"0.6239264",
"0.62226313",
"0.6193941",
"0.6126204",
"0.611152",
"0.6100338",
"0.60866594",
"0.6031406",
"0.5984584",
"0.59791315",
"0.5968961",
"0.5952915",
"0.59519464",
"0.5949488",
"0.59182364",
"0.58955574",
"0.58570... | 0.7655839 | 1 |
Shortcut for ``bot.send_chat_action(update.message.chat.id, args, kwargs)`` | def send_action(self, *args, **kwargs):
return self.bot.send_chat_action(self.id, *args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_action(action):\n def decorator(func):\n @wraps(func)\n def command_func(self, update, context, *args, **kwargs):\n context.bot.send_chat_action(chat_id=update.effective_message.chat_id, action=action)\n return func(self, update, context, *args, **kwargs)\n re... | [
"0.7509384",
"0.7375992",
"0.6927227",
"0.6501493",
"0.6169821",
"0.6134623",
"0.6082273",
"0.60704964",
"0.60244894",
"0.6001735",
"0.596165",
"0.5954815",
"0.59119594",
"0.5823286",
"0.5799726",
"0.5714884",
"0.57128656",
"0.5614297",
"0.55790704",
"0.55705637",
"0.55119675... | 0.7766484 | 0 |
Shortcut for ``bot.leave_chat(update.message.chat.id, args, kwargs)`` | def leave(self, *args, **kwargs):
return self.bot.leave_chat(self.id, *args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def leave_chat(self, chat_id: typing.Union[base.Integer, base.String]) -> base.Boolean:\n payload = generate_payload(**locals())\n result = await self.request(api.Methods.LEAVE_CHAT, payload)\n\n return result",
"def leave(bot, event, conversation_id=None, *args):\n\n arglist = list... | [
"0.6716415",
"0.6618045",
"0.6549425",
"0.6191924",
"0.6101038",
"0.6079317",
"0.6001494",
"0.5859587",
"0.5734056",
"0.57170254",
"0.5706082",
"0.5672748",
"0.5663437",
"0.5622406",
"0.5606106",
"0.55953854",
"0.5537519",
"0.55289155",
"0.54851896",
"0.5475721",
"0.54088616"... | 0.8217309 | 0 |
Shortcut for ``bot.get_chat_administrators(update.message.chat.id, args, kwargs)`` | def get_administrators(self, *args, **kwargs):
return self.bot.get_chat_administrators(self.id, *args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_admin_ids(bot, chat_id):\r\n return [admin.user.id for admin in bot.get_chat_administrators(chat_id)]",
"def get_admin_ids(bot, chat_id):\n return [admin.user.id for admin in bot.get_chat_administrators(chat_id)]",
"def get_admin_ids(bot, chat_id):\n return [admin.user.id for admin in bot.get_... | [
"0.72916365",
"0.7257801",
"0.7257801",
"0.7257801",
"0.71312785",
"0.63350284",
"0.6305754",
"0.6275993",
"0.6170726",
"0.6099674",
"0.58945954",
"0.58601385",
"0.58280176",
"0.58112365",
"0.577033",
"0.5728004",
"0.5673534",
"0.5667694",
"0.5667427",
"0.5659937",
"0.5639199... | 0.8342136 | 0 |
Shortcut for ``bot.get_chat_members_count(update.message.chat.id, args, kwargs)`` | def get_members_count(self, *args, **kwargs):
return self.bot.get_chat_members_count(self.id, *args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def get_chat_members_count(self, chat_id: typing.Union[base.Integer, base.String]) -> base.Integer:\n payload = generate_payload(**locals())\n result = await self.request(api.Methods.GET_CHAT_MEMBERS_COUNT, payload)\n\n return result",
"async def membercount(ctx, *args):\n if ctx.me... | [
"0.7653538",
"0.7079209",
"0.67141974",
"0.64766777",
"0.6410987",
"0.63265955",
"0.63157445",
"0.6290398",
"0.6003215",
"0.5918783",
"0.5874979",
"0.5852854",
"0.5671665",
"0.56622785",
"0.5651697",
"0.5633376",
"0.55913067",
"0.5557523",
"0.5552522",
"0.5539572",
"0.5515641... | 0.8773616 | 0 |
Shortcut for ``bot.get_chat_member(update.message.chat.id, args, kwargs)`` | def get_member(self, *args, **kwargs):
return self.bot.get_chat_member(self.id, *args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def get_chat_member(self, chat_id: typing.Union[base.Integer, base.String],\n user_id: base.Integer) -> types.ChatMember:\n payload = generate_payload(**locals())\n result = await self.request(api.Methods.GET_CHAT_MEMBER, payload)\n\n return types.ChatMember(... | [
"0.6845233",
"0.59359425",
"0.59342927",
"0.59342927",
"0.5720699",
"0.5720276",
"0.56279147",
"0.56157714",
"0.55889475",
"0.5583294",
"0.5564403",
"0.55140746",
"0.54459745",
"0.5426997",
"0.5400163",
"0.53775513",
"0.53349453",
"0.53254014",
"0.53250545",
"0.529635",
"0.52... | 0.8052762 | 0 |
Shortcut for ``bot.kick_chat_member(update.message.chat.id, args, kwargs)`` | def kick_member(self, *args, **kwargs):
return self.bot.kick_chat_member(self.id, *args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def kick(ctx, member: discord.Member, *, reason=None):\n await member.kick(reason=reason)\n await ctx.send(f\"User {member} has been kicked\")",
"async def kick(self, member: discord.Member, *, reason=None): # asterix=all parameters after member and reason will just be added to reason\n await... | [
"0.67335683",
"0.6692941",
"0.6343571",
"0.6296833",
"0.6268952",
"0.6116799",
"0.60498536",
"0.603678",
"0.6020632",
"0.6001688",
"0.59897",
"0.5921761",
"0.5896615",
"0.58285856",
"0.5738672",
"0.57337326",
"0.5710275",
"0.5696058",
"0.5683905",
"0.56561285",
"0.56306046",
... | 0.83216196 | 0 |
Shortcut for ``bot.unban_chat_member(update.message.chat.id, args, kwargs)`` | def unban_member(self, *args, **kwargs):
return self.bot.unban_chat_member(self.id, *args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def unban_chat_member(self, chat_id: typing.Union[base.Integer, base.String],\n user_id: base.Integer) -> base.Boolean:\n payload = generate_payload(**locals())\n result = await self.request(api.Methods.UNBAN_CHAT_MEMBER, payload)\n\n return result",
"asy... | [
"0.73356986",
"0.70719296",
"0.70260084",
"0.6497744",
"0.64395726",
"0.6274795",
"0.6266587",
"0.6266034",
"0.6130883",
"0.6102467",
"0.5987942",
"0.5970644",
"0.5834732",
"0.5762892",
"0.57180315",
"0.57048714",
"0.5699499",
"0.56516176",
"0.5640035",
"0.5636267",
"0.562204... | 0.86313546 | 0 |
Gets all the meshes inside all the piper skinned nodes in the scene. | def getMeshes():
nodes = pipernode.get('piperSkinnedMesh')
return {mesh.getParent() for skin in nodes for mesh in skin.getChildren(ad=True, type='mesh') if mesh.getParent()} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_meshes(self):\n for meta_mesh in self.gltf.meshes:\n # Returns a list of meshes\n meshes = meta_mesh.load(self.materials)\n self.meshes.append(meshes)\n\n for mesh in meshes:\n self.scene.meshes.append(mesh)",
"def get_meshes(scene):\r\n ... | [
"0.6114167",
"0.60293436",
"0.5757967",
"0.5612728",
"0.5534438",
"0.54922056",
"0.54847145",
"0.54710627",
"0.54542154",
"0.5363654",
"0.5363654",
"0.5363654",
"0.5363654",
"0.5305868",
"0.52891994",
"0.5282078",
"0.5273619",
"0.5245254",
"0.52361906",
"0.5214873",
"0.521100... | 0.8215878 | 0 |
Locks all the transforms under piper skinned nodes that have mesh shapes. | def lockMeshes():
setLockOnMeshes(2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unlockMeshes():\n setLockOnMeshes(0)",
"def setLockOnMeshes(lock):\n meshes = getMeshes()\n for mesh in meshes:\n try:\n mesh.overrideEnabled.set(1)\n mesh.overrideDisplayType.set(lock)\n except RuntimeError as error:\n pm.warning('Can\\'t set lock on m... | [
"0.5996941",
"0.5933928",
"0.56343156",
"0.5437628",
"0.5400132",
"0.5262749",
"0.5243079",
"0.52421004",
"0.51741475",
"0.51033777",
"0.5092315",
"0.5088405",
"0.50729567",
"0.49983454",
"0.49829763",
"0.49469054",
"0.49222684",
"0.48831803",
"0.4858286",
"0.48506966",
"0.48... | 0.6672777 | 0 |
Unlocks all the transforms under piper skinned nodes that have mesh shapes. | def unlockMeshes():
setLockOnMeshes(0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lockMeshes():\n setLockOnMeshes(2)",
"def cleanUpRigPose(self):\n\n # show the proxy geo\n cmds.select(self.name + \"_mover_grp\", hi=True)\n allNodes = cmds.ls(sl=True)\n for node in allNodes:\n if node.find(\"_proxy_geo\") != -1:\n if cmds.nodeType(n... | [
"0.5675033",
"0.5524052",
"0.5401451",
"0.53727466",
"0.53193283",
"0.5234211",
"0.51849127",
"0.5175909",
"0.51477677",
"0.5075064",
"0.50477535",
"0.5032112",
"0.5016843",
"0.49993888",
"0.49989218",
"0.4995508",
"0.49578157",
"0.4956141",
"0.49486592",
"0.49314776",
"0.492... | 0.6947981 | 0 |
Prepares the scene for a rig. | def prepare():
# getRelativeArt checks if scene is saved
skeleton_path = paths.getRelativeArt()
# if scene is modified, ask user if they would like to save, not save, or cancel operation
if not uiwindow.save():
pm.error('Scene not saved.')
# perform a bone health check before referencing t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_scene(self, ):\n self.scene = create_scene(\n self.opt.splats_img_size, self.opt.splats_img_size, self.opt.fovy,\n self.opt.focal_length, self.opt.n_splats)",
"def set_up_scenes():\n cmd.zoom('Cathepsin', 10) # Zoom out to get a view on the whole complex\n cmd.scene... | [
"0.6489929",
"0.61271745",
"0.6016473",
"0.60112846",
"0.58737195",
"0.58737195",
"0.5808305",
"0.58061624",
"0.58061624",
"0.58061624",
"0.57967305",
"0.5735352",
"0.5718494",
"0.5693235",
"0.5693235",
"0.5693235",
"0.5693235",
"0.5693235",
"0.5693235",
"0.5693235",
"0.56932... | 0.6952782 | 0 |
Creates a new question | def create_question():
if request.content_type != "application/json":
abort(415)
question_text = request.json['question']
answer = request.json['answer']
difficulty = request.json['difficulty']
category = request.json['category']
question_object = Question(qu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_question():\n body = request.get_json()\n\n question_text = body.get('question', None)\n answer = body.get('answer', None)\n category = body.get('category', 1)\n difficulty = body.get('difficulty', 1)\n\n try:\n question = Question(question=question_t... | [
"0.79055667",
"0.7813074",
"0.76496226",
"0.75417274",
"0.7536455",
"0.7524911",
"0.7431518",
"0.7412654",
"0.7412654",
"0.73918843",
"0.73026544",
"0.7290407",
"0.7285686",
"0.7280948",
"0.7277673",
"0.7270049",
"0.7219192",
"0.7162589",
"0.70821846",
"0.70660996",
"0.705721... | 0.80899006 | 0 |
Get all questions filtered by a category | def get_questions_by_category(category_id: int):
category = Category.query.get(category_id)
if category is None:
abort(400)
questions_by_category = Question.query.filter(
Question.category == str(category_id)).all()
return jsonify({
"success": True,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieve_questions_by_category(category_id):\n try:\n selection = Question.query.filter(\n Question.category == category_id).order_by(Question.id).all()\n\n if len(selection) == 0:\n abort(404)\n\n questions = []\n\n for question ... | [
"0.7045061",
"0.70348823",
"0.7026578",
"0.68939084",
"0.6882774",
"0.6860482",
"0.6797814",
"0.6765122",
"0.6690764",
"0.6680299",
"0.6671632",
"0.6665664",
"0.6628369",
"0.6480059",
"0.64080924",
"0.6332876",
"0.6249306",
"0.62117636",
"0.61584663",
"0.61449456",
"0.6097295... | 0.7141734 | 0 |
This endpoint should take category and previous question parameters and return a random questions within the given category, if provided, and that is not one of the previous questions. | def get_quiz_question():
if request.content_type != "application/json":
abort(415)
previous_questions: list[int] = request.json['previous_questions']
category: str = request.json['quiz_category']
filtered_category: list[Category] = Category.query.filter(
Category... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_questions_toplay():\n data = request.get_json()\n category = data.get('category', 'None')\n previous_questions = data.get('previous_questions', None)\n questions = Question.query.filter(Question.category == category).all()\n all_questions = Question.query.all()\n c... | [
"0.74568665",
"0.6912038",
"0.6561906",
"0.6539811",
"0.65362525",
"0.6439181",
"0.64383984",
"0.63652915",
"0.63634086",
"0.6346514",
"0.62832403",
"0.6261533",
"0.61639524",
"0.6094321",
"0.6050536",
"0.6016344",
"0.5915583",
"0.5853105",
"0.58042264",
"0.57684845",
"0.5714... | 0.7499 | 0 |
Validate status transition and set next status. The caller of the transition method will have to aquire conditional variable. | def _transition(self, next_status: Status) -> None:
if next_status == Status.CLOSED:
self._status = next_status
elif (
self._status == Status.AWAITING_SERVER_MESSAGE
and next_status == Status.SERVER_MESSAGE_AVAILABLE
and self._server_message is not None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_status(self):\n if self.status == self.DRAFT:\n self._advance_to_registration()\n elif self.status == self.REGISTRATION:\n self._advance_to_pending()\n elif self.status == self.PENDING:\n self._advance_to_running()",
"def _set_status(self, status, in... | [
"0.6936471",
"0.6545385",
"0.61415124",
"0.6049134",
"0.59733415",
"0.5904015",
"0.58512765",
"0.580843",
"0.5763939",
"0.57431453",
"0.5728972",
"0.5710814",
"0.57087004",
"0.5695417",
"0.5690907",
"0.564556",
"0.5603299",
"0.55643886",
"0.55600923",
"0.5519623",
"0.55151504... | 0.8059536 | 0 |
Return iterator over server messages. | def server_message_iterator(self) -> Iterator[ServerMessage]:
while not self._is_closed():
with self._cv:
self._cv.wait_for(
lambda: self._status
in [Status.CLOSED, Status.SERVER_MESSAGE_AVAILABLE]
)
self._raise... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n while True:\n m = self.recv(timeout=1.0)\n if m is not None:\n yield m\n logger.debug(\"done iterating over bus messages\")",
"def __iter__(self):\n return iter([self.format_message(record) for record in self._messages])",
"def sen... | [
"0.70293",
"0.681426",
"0.6685467",
"0.65742815",
"0.63746",
"0.6322583",
"0.6322583",
"0.6319159",
"0.6243213",
"0.6237469",
"0.6149023",
"0.6103872",
"0.60832894",
"0.6079954",
"0.597399",
"0.5964599",
"0.59449357",
"0.5915447",
"0.59143317",
"0.59071326",
"0.5888881",
"0... | 0.80226314 | 0 |
Set client message for consumption. | def set_client_message(self, client_message: ClientMessage) -> None:
with self._cv:
self._raise_if_closed()
if self._status != Status.AWAITING_CLIENT_MESSAGE:
raise Exception("This should not happen")
self._client_message = client_message # Write
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def client(self,message):\n self.message = message\n self.run()",
"def _set_message(self, value):\n self.__message = value",
"def setMessage(self, message):\n self._message = message",
"def message(self, message):\n self._message = message",
"def message(self, message):\n... | [
"0.7064386",
"0.6990123",
"0.67184645",
"0.65573794",
"0.65573794",
"0.65327984",
"0.6515193",
"0.6515193",
"0.6515193",
"0.6515193",
"0.6515193",
"0.6515193",
"0.6515193",
"0.6515193",
"0.6393413",
"0.6339335",
"0.63246405",
"0.6275719",
"0.62454003",
"0.6086344",
"0.6082703... | 0.7599568 | 0 |
gets the distance between two cities from the database and updates the number of hits if found. | def get_distance_between_cities(self, source, destination):
query = {"$or": [{SOURCE: source, DESTINATION: destination}, {SOURCE: destination, DESTINATION: source}]}
doc1 = self._cities_distance.find_one_and_update(query, {"$inc": {HITS: 1}})
distance = -1
if doc1:
distance =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distanceBetweenTwoCities(cityA, cityB):\r\n\r\n return ( ( (cityA[0] - cityB[0]) ** 2 ) + ( (cityA[1] - cityB[1]) ** 2) ) ** 0.5",
"def evaluate_distance(self, city):\n\t\treturn self.distance[city.value]",
"def calculate_distance(loc1, loc2):\n matrix = googlemaps.distance_matrix.distance_matrix(cli... | [
"0.65696883",
"0.63588417",
"0.63102216",
"0.6298032",
"0.6286711",
"0.6248496",
"0.61212575",
"0.60218096",
"0.6021427",
"0.5920487",
"0.5870352",
"0.5845951",
"0.5799753",
"0.57648885",
"0.5758182",
"0.57455",
"0.57340556",
"0.57309353",
"0.572869",
"0.5690227",
"0.56465304... | 0.75209475 | 0 |
adds two citie and their distance to the database. | def add_cities_to_db(self, source, destination, distance, is_post_insert=False):
if not is_post_insert:
self._cities_distance.insert_one(
{SOURCE: source, DESTINATION: destination, DISTANCE: distance, HITS: 1})
else:
self._cities_distance.insert_one(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(self, other):\n ...",
"def distance(self, keyOne, keyTwo):",
"def distance(self, a, b):\n raise NotImplementedError()",
"def costInsertion(el1,el2):\r\n return 2",
"def distance(self, c1, c2):\r\n x = (c2.x - c1.x) ** 2\r\n y = (c2.y - c1.y) ** 2\r\n d = i... | [
"0.6052168",
"0.59256554",
"0.58947444",
"0.56122863",
"0.5598152",
"0.5561179",
"0.55405825",
"0.5526655",
"0.54927796",
"0.547482",
"0.54159796",
"0.5413959",
"0.5394808",
"0.5382403",
"0.5351781",
"0.5341194",
"0.5296761",
"0.52946454",
"0.5241165",
"0.5225384",
"0.5225066... | 0.6522734 | 0 |
Captures the HTML response to a message | async def respondHTML(self, html):
self.HTMLResponse = html | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def message_body_html(self):\n ...",
"def _html(self, message):\n content = f\"<html><body><h1>{message}</h1></body></html>\"\n return content.encode(\"utf8\") # NOTE: must return a bytes object!",
"def _html(self, message):\n content = f\"<html><body><h1>{message}</h1></body></htm... | [
"0.6637344",
"0.6620112",
"0.65681136",
"0.64055985",
"0.62257975",
"0.62002647",
"0.604187",
"0.6003477",
"0.5985468",
"0.59392756",
"0.59041214",
"0.57948726",
"0.5739584",
"0.5736432",
"0.5728024",
"0.5726305",
"0.5707939",
"0.5704044",
"0.5688189",
"0.5646242",
"0.5642735... | 0.68577594 | 0 |
Check for Walabot connectivity. loop until detect a Walabot. | def verifyWalabotIsConnected():
while True:
try:
wlbt.ConnectAny()
except wlbt.WalabotError as err:
input("- Connect Walabot and press 'Enter'.")
else:
print('- Connection to Walabot established.')
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_connection():\n if connected():\n ws.emit(Message('mycroft.internet.connected'))\n # check for pairing, if not automatically start pairing\n if not is_paired():\n # begin the process\n payload = {\n 'utterances': [\"pair my device\"],\n ... | [
"0.67418945",
"0.67034936",
"0.6321306",
"0.6317192",
"0.6138319",
"0.6137619",
"0.6137448",
"0.6100447",
"0.6077443",
"0.6034586",
"0.5992254",
"0.5982001",
"0.5950899",
"0.5919076",
"0.5894772",
"0.58944863",
"0.5866478",
"0.5837735",
"0.5822696",
"0.5799287",
"0.57872075",... | 0.8310073 | 0 |
Configure Walabot's profile, arena (r, theta, phi), threshold and the image filter. | def setWalabotSettings():
wlbt.SetProfile(wlbt.PROF_SENSOR)
wlbt.SetArenaR(R_MIN, R_MAX, R_RES)
wlbt.SetArenaTheta(THETA_MIN, THETA_MAX, THETA_RES)
wlbt.SetArenaPhi(PHI_MIN, PHI_MAX, PHI_RES)
#wlbt.SetThreshold(THRESHOLD)
wlbt.SetDynamicImageFilter(wlbt.FILTER_TYPE_DERIVATIVE) #Also test with FI... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pibooth_setup_camera(cfg):",
"def __init__(self):\n\n # self.threshold = 3.\n self.gamma_min = 3\n self.gamma_max = 12\n self.n_samples = 40\n # self.do_plots = False\n # self.do_albedo = True\n # self.verbose = True\n\n self.nbands = 7\n sel... | [
"0.55619794",
"0.5276887",
"0.5156513",
"0.51370335",
"0.512774",
"0.51219815",
"0.5073326",
"0.5047057",
"0.50075054",
"0.49671337",
"0.4966661",
"0.49465856",
"0.4934728",
"0.49258626",
"0.49199712",
"0.49144244",
"0.48763582",
"0.48478684",
"0.48258424",
"0.4820601",
"0.48... | 0.75236595 | 0 |
Start the Walabot and calibrate it. | def startAndCalibrateWalabot():
wlbt.StartCalibration()
print('- Calibrating...')
while wlbt.GetStatus()[0] == wlbt.STATUS_CALIBRATING:
wlbt.Trigger()
wlbt.Start()
print('- Calibration ended.\n- Ready!') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setWalabotSettings():\n wlbt.SetProfile(wlbt.PROF_SENSOR)\n wlbt.SetArenaR(R_MIN, R_MAX, R_RES)\n wlbt.SetArenaTheta(THETA_MIN, THETA_MAX, THETA_RES)\n wlbt.SetArenaPhi(PHI_MIN, PHI_MAX, PHI_RES)\n #wlbt.SetThreshold(THRESHOLD)\n wlbt.SetDynamicImageFilter(wlbt.FILTER_TYPE_DERIVATIVE) #Also t... | [
"0.61959416",
"0.6061523",
"0.60181415",
"0.60077643",
"0.58197683",
"0.5722696",
"0.5720339",
"0.56705564",
"0.56593007",
"0.5618712",
"0.56180704",
"0.56057066",
"0.56027627",
"0.5589759",
"0.5566517",
"0.55604434",
"0.5554661",
"0.5530717",
"0.5525474",
"0.5512045",
"0.550... | 0.84001803 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.