query stringlengths 9 3.4k | document stringlengths 9 87.4k | metadata dict | negatives listlengths 4 101 | negative_scores listlengths 4 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Replace all interger occurrences in list of tokenized words with textual representation | def replace_numbers(words):
p = inflect.engine()
new_words = []
for word in words:
if word.isdigit():
new_word = p.number_to_words(word)
new_words.append(new_word)
else:
new_words.append(word)
return new_words | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_nums2words(tokens):\n e = inflect.engine()\n words = []\n for word in tokens:\n if word.isdigit():\n words.append(e.number_to_words(word).replace(',', ''))\n else:\n words.append(word)\n return words",
"def replace_numbers(words):\n p = inflect.engin... | [
"0.712848",
"0.6677634",
"0.6677634",
"0.66645175",
"0.66486406",
"0.6582358",
"0.65370184",
"0.6507017",
"0.650339",
"0.6453735",
"0.64314735",
"0.6304701",
"0.62872326",
"0.6249569",
"0.61461407",
"0.61268705",
"0.60919553",
"0.6002201",
"0.5973062",
"0.59518856",
"0.595131... | 0.65066916 | 12 |
Function to perform the preprocessing steps. | def preprocess(words):
words = to_lowercase(words)
words = remove_punctuation(words)
words = replace_numbers(words)
return words | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_preprocessing(self):\n\n # For now, do nothing\n pass",
"def preprocess(self):",
"def preprocess(self):\n pass",
"def preprocess(self):\n pass",
"def preprocess(self):\n pass",
"def pre_process(self):\n pass",
"def pre_process(self):\n pass",
... | [
"0.83032244",
"0.8285205",
"0.82517445",
"0.82517445",
"0.82517445",
"0.7787406",
"0.7787406",
"0.7787406",
"0.7787406",
"0.7787406",
"0.75145024",
"0.750477",
"0.750477",
"0.750477",
"0.750477",
"0.7465893",
"0.7440773",
"0.7376985",
"0.73461777",
"0.72189754",
"0.7173846",
... | 0.0 | -1 |
The method used to make sure that a new game can be properly set up. | def test_setup_new_game(self):
# Create a new game and make sure it has the correct settings
game = Game()
game.setup_new_game()
self.assertTrue(game.dealer is not None, msg="The dealer of the game was not created.")
self.assertEqual(game.dealer.cards, [])
self.assertEqu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_game(self):",
"def test_init_with_existing_game(self):\n pass\n # Ensure judge is the same",
"def init_new_game(self):\n self.game = get_new_game(self.game_config)",
"def test_valid_new_game(self):\n self._game.new_game()\n self.assertIsRUNNING(self._game)\n ... | [
"0.7768438",
"0.77553225",
"0.7210226",
"0.71760374",
"0.71611285",
"0.7128538",
"0.71211183",
"0.7097392",
"0.69952536",
"0.68901664",
"0.67767847",
"0.66891795",
"0.66610706",
"0.6657264",
"0.6633129",
"0.65772235",
"0.65560424",
"0.65336835",
"0.6524371",
"0.65190214",
"0.... | 0.772596 | 2 |
The method used to make sure that the number of packs of cards used in the deck can be set. | def test_set_pack_number(self):
# Setup new games and attempt to set their number of packs
valid_packs = [
1,
2,
3,
4,
5,
100,
]
for packs in valid_packs:
game = Game()
game.setup_new_game()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_partial_deck_has_fewer_cards(self):\n self.assertEqual(len(self.partialDeck.deck), 46)",
"def test_deck_has_52_cards(self):\n self.assertEqual(len(cardutils.Deck().deck), 52)",
"def test_deal_insufficient_cards(self):\n cards = self.deck._deal(100)\n self.assertEqual(len(ca... | [
"0.7374004",
"0.7103446",
"0.70241",
"0.69315875",
"0.66214824",
"0.64057523",
"0.6400416",
"0.63905966",
"0.63733155",
"0.63548046",
"0.63514054",
"0.62122077",
"0.6207813",
"0.60508186",
"0.60039824",
"0.60039824",
"0.60029846",
"0.5993134",
"0.59795815",
"0.59732604",
"0.5... | 0.6628614 | 4 |
The method used to make sure that the number of starting chips for each player can be set. | def test_set_starting_chips(self):
# Setup new game and attempt to set their valid number of starting chips
valid_chips = [
1,
10,
100,
9999,
]
for chips in valid_chips:
game = Game()
game.setup_new_game()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_partial_deck_has_fewer_cards(self):\n self.assertEqual(len(self.partialDeck.deck), 46)",
"def enough_players():\n return True",
"def set_n_players(self):\n complain = \"\"\n while True:\n clear_output()\n try:\n self.n_players = int(\n ... | [
"0.5986601",
"0.5935184",
"0.591481",
"0.58434373",
"0.57822806",
"0.5757061",
"0.5752133",
"0.5748309",
"0.57169116",
"0.56981397",
"0.56899023",
"0.56770945",
"0.56551063",
"0.56398237",
"0.5611947",
"0.5601338",
"0.55866843",
"0.55602324",
"0.55322117",
"0.5494507",
"0.548... | 0.76785713 | 0 |
The method used to make sure that the number of players in the game can be set. | def test_set_players_number(self):
# Setup new games and attempt to set thier number of players
valid_players = [
1,
2,
10,
999,
]
for players in valid_players:
game = Game()
game.setup_new_game()
game.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_n_players(self):\n complain = \"\"\n while True:\n clear_output()\n try:\n self.n_players = int(\n input(f\"{complain}Please insert the number of players (between 2 to 6): \\n\"))\n if self.n_players >= 2 and self.n_player... | [
"0.7856002",
"0.7477124",
"0.7449072",
"0.73708785",
"0.72020966",
"0.7163081",
"0.7101107",
"0.6963289",
"0.69247246",
"0.6869978",
"0.6805626",
"0.67341477",
"0.666265",
"0.66342485",
"0.66003746",
"0.65017307",
"0.6438204",
"0.643307",
"0.64232385",
"0.6403796",
"0.6400872... | 0.7438455 | 3 |
The method used to make sure that the names of the players in the game can be set. | def test_set_player_names(self):
# Setup new games and attempt to set their players' names
valid_players = [
["Bob", "Sam", "Cal", "Kris"],
["Player 1", "Player 2", "Player 3", "Player 4", "Player 5"],
["Bot"],
["P1", "P2", "P3"],
]
for pl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_names_users(self):\n user_1 = self.view.entry_player_1.get()\n user_2 = self.view.entry_player_2.get()\n if len(user_1) == 0 or len(user_2) == 0:\n\n tk.messagebox.showwarning(\"Warning\", \"Please enter players name\")\n self.logger.warning(\"Please enter players... | [
"0.7112906",
"0.6798745",
"0.67947006",
"0.67672193",
"0.6759732",
"0.66581255",
"0.6556097",
"0.65228826",
"0.64666003",
"0.64418626",
"0.63995534",
"0.63855034",
"0.6371685",
"0.6351709",
"0.63382185",
"0.63223565",
"0.63055414",
"0.62601405",
"0.61606365",
"0.6153325",
"0.... | 0.77651775 | 0 |
Selects two customers that are nearest to each other and their neighbours and removes them from the solution. See ``customers_to_remove`` for the degree of destruction done. Similar to cross route removal in Hornstra et al. (2020). | def cross_route(current: Solution, rnd_state: Generator) -> Solution:
problem = Problem()
destroyed = deepcopy(current)
customers = set(range(problem.num_customers))
removed = SetList()
while len(removed) < customers_to_remove():
candidate = rnd_state.choice(tuple(customers))
rout... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_existing_customers(self):\n # remove the customers which are not active (.is_active )\n self.to_move = False\n #for cust in self.customers:\n # print(cust.state)\n self.customers = [cust for cust in self.customers if cust.state != 'checkout']\n #if cust.t... | [
"0.58851576",
"0.5448354",
"0.5397266",
"0.53144395",
"0.5311116",
"0.5295682",
"0.5100967",
"0.5089005",
"0.50736344",
"0.5059185",
"0.50466216",
"0.5021134",
"0.49826962",
"0.49800837",
"0.49682873",
"0.49234816",
"0.49223632",
"0.49205166",
"0.48926115",
"0.48870838",
"0.4... | 0.653128 | 0 |
Draw a menu to the screen and return the user's option. | def render(self, panel):
page = 0
index = None
while not index:
has_next = page + 1 < len(self.pages)
has_previous = page > 0
key_event = self.show_and_get_input(panel, self.pages[page], has_next=has_next, has_previous=has_previous)
key_sym = key_e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw(self):\n self.menu_pointer.draw()",
"def callMenu():\n print(\"Menu: \\\n \\n Area of a triangle (enter 'triangleArea') \\\n \\n Area of a square (enter 'squareArea') \\\n \\n Area of a parallelogram (enter 'paraArea') \\\n \\n Area of an ellipse (enter 'ellipseArea')\\\n \\n Ar... | [
"0.7474467",
"0.72681385",
"0.7178516",
"0.7143566",
"0.7040018",
"0.7029663",
"0.7010162",
"0.70002234",
"0.6994784",
"0.6974521",
"0.6951417",
"0.6951417",
"0.6905888",
"0.6889777",
"0.6864188",
"0.6853201",
"0.6781071",
"0.67107534",
"0.670106",
"0.6700157",
"0.66957885",
... | 0.0 | -1 |
Compute softmax values for each sets of scores in x. | def softmax(x):
return np.exp(x)/np.sum(np.exp(x),axis=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(self, scores):\n\n\n # for each sample, for each class ,caclulate\n # np.exp(scores) : still (n_samples, n_classes)\n\n # axis = 1\n # a00, a01, a02 as a sinlge one to perfrom np_sum\n # which is the same sample \n # sum_exp : still (n_samples, 1)\n\n # ... | [
"0.7797633",
"0.77625954",
"0.77602196",
"0.7757519",
"0.76584935",
"0.76584935",
"0.76584935",
"0.76584935",
"0.7589092",
"0.7433975",
"0.7410552",
"0.7397003",
"0.7360935",
"0.73204947",
"0.7271785",
"0.72655344",
"0.7264959",
"0.7259807",
"0.72332364",
"0.72179425",
"0.720... | 0.69552547 | 95 |
Sanitize the provided input and return for display in a template. | def sanitize(sensitive_thing):
sanitized_string = sensitive_thing
length = len(sensitive_thing)
if sensitive_thing:
if "http" in sensitive_thing:
# Split the URL – expecting a Slack (or other) webhook
sensitive_thing = sensitive_thing.split("/")
# Get just the las... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize(self, _input):\n sanitized = {}\n for key, inp in _input.items():\n try:\n key = html.escape(key).strip()\n except AttributeError:\n pass\n # try:\n # inp = html.escape(inp).strip()\n # except (Attri... | [
"0.6837212",
"0.671551",
"0.63465",
"0.62541693",
"0.62541574",
"0.624929",
"0.60042685",
"0.59933007",
"0.5918816",
"0.58771557",
"0.5692827",
"0.56926256",
"0.5663534",
"0.564801",
"0.559153",
"0.55577475",
"0.55491936",
"0.55311906",
"0.55037344",
"0.5479245",
"0.54516834"... | 0.5565028 | 15 |
Tidies a string `time` into a `date` in `datetime64[D]` format, and records the status of the conversion (`date_status`). | def tidy_time_string(time):
# TODO - :return date_range: Where date_status is "centred", date_range is a tuple (`first_date`, `last_date`) of
# `datetime64[D]` objects. Otherwise will return a tuple of Not a Time objects.
# TODO - warnings/logging
# TODO - change date offsets to rounding using MonthEn... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_convert(time):\n try:\n time_data = str(time)\n if time_data:\n try:\n time_data = datetime.strptime(time_data, '%Y%m%d')\n except Exception:\n time_data = datetime.strptime(time_data, '%Y%m%d%H%M%S')\n time_data = time_data.s... | [
"0.67671704",
"0.6561771",
"0.6454839",
"0.6385109",
"0.6359751",
"0.6207002",
"0.61763185",
"0.61540025",
"0.6093099",
"0.6084911",
"0.6053707",
"0.5992525",
"0.5986227",
"0.5974825",
"0.5956986",
"0.59523886",
"0.5942912",
"0.5880063",
"0.58654827",
"0.5819688",
"0.5815174"... | 0.65892553 | 1 |
Creates additional columns in an archive catalogue's data frame, containing the tidied date and the date status. | def tidy_time_df(df, time_col, new_tidy_col='date_tidy', new_status_col='date_status'):
date_tidy_series = pd.Series(index=df.index, dtype='datetime64[D]')
date_status_series = pd.Series(index=df.index, dtype='object')
for ref_no, o_time in df[time_col].iteritems():
time = str(o_time)
# TOD... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct_report_columns(self):\n return \"Date,Status\"",
"def add_technical_indicator(df, tic):\n\n df['date'] = df.index\n df = df.reset_index(drop=True)\n cols = ['date'] + [col for col in df if col != 'date']\n df = df[cols]\n\n # drop duplicates\n df = df.drop_duplicates()\n\n ... | [
"0.6245582",
"0.569461",
"0.55898565",
"0.5484624",
"0.5384144",
"0.53206754",
"0.5287756",
"0.5262397",
"0.5247427",
"0.51686",
"0.5157036",
"0.509723",
"0.5071026",
"0.503728",
"0.5009204",
"0.49583736",
"0.49314016",
"0.48982397",
"0.48967764",
"0.48934394",
"0.48725566",
... | 0.5550228 | 3 |
Test that noun_chunks raises Value Error for 'fr' language if Doc is not parsed. | def test_noun_chunks_is_parsed_fr(fr_tokenizer):
doc = fr_tokenizer("trouver des travaux antérieurs")
with pytest.raises(ValueError):
list(doc.noun_chunks) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_noun_chunks_is_parsed(fi_tokenizer):\n doc = fi_tokenizer(\"Tämä on testi\")\n with pytest.raises(ValueError):\n list(doc.noun_chunks)",
"def test_issue401(EN, text, i):\n tokens = EN(text)\n assert tokens[i].lemma_ != \"'\"",
"def test_issue3625():\n nlp = Hindi()\n doc = nlp... | [
"0.81967974",
"0.5773204",
"0.57079947",
"0.55603945",
"0.55467683",
"0.5531417",
"0.5456726",
"0.53696465",
"0.53655165",
"0.53548074",
"0.53134775",
"0.52308595",
"0.5148851",
"0.514678",
"0.5137788",
"0.5127326",
"0.5120156",
"0.51103795",
"0.50573343",
"0.5028861",
"0.502... | 0.846443 | 0 |
initialization function of a quay | def __init__(self, n, **kwargs):
super(Quay, self).__init__(QC)
for i in range(n):
super(Quay, self).append(QC())
for p in QC.PROPERTY:
if p in kwargs.keys():
if isinstance(kwargs[p], (float, int)):
for q in self.qcs:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init(q: qreg) -> control:\n\n return",
"def __init__(self,Q=None):\n \n self.Q = Q",
"def __init__(self, *args):\n _snap.TFltQu_swiginit(self, _snap.new_TFltQu(*args))",
"def __init__(self, name, q_arg):\n super().__init__(name)\n self._q_arg = q_arg\n pass",
... | [
"0.68906045",
"0.65614474",
"0.65232855",
"0.6140419",
"0.6140419",
"0.6138915",
"0.60803175",
"0.6050424",
"0.6035699",
"0.6019924",
"0.6011651",
"0.5988382",
"0.5929836",
"0.5912391",
"0.586321",
"0.5856167",
"0.58513296",
"0.58513296",
"0.5828457",
"0.57839346",
"0.5770587... | 0.5496286 | 43 |
getter for quay crane list | def qcs(self):
return self.aggregation | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def qalist(self):\n return self._palist.qalist",
"def q(self) -> List[Qubit]:\n return self._qubits",
"def getList(self):\n\treturn self.list",
"def list(self):",
"def __getitem__(self, item):\n return self.getList()",
"def getList(self):",
"def getList(self):",
"def items(self) ... | [
"0.6742118",
"0.6245824",
"0.61032283",
"0.5919486",
"0.5884884",
"0.58789665",
"0.58789665",
"0.5849581",
"0.5797776",
"0.57523096",
"0.57523096",
"0.57228744",
"0.5694303",
"0.5674068",
"0.566529",
"0.55730355",
"0.55665857",
"0.5556434",
"0.55019647",
"0.5491846",
"0.54615... | 0.0 | -1 |
Initialize class with dimensions of buffer. | def __init__(self, x, y=None):
self.len = x
if y:
self.size = x * y
self.data = np.empty((x, y))
else:
self.size = self.len
self.data = np.empty((x,))
self.idx = 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, buffer_size: int, batch_size: int):\n self.buffer: list = list()\n self.buffer_size = buffer_size\n self.batch_size = batch_size\n self.idx = 0",
"def __init__(self,width=8,height=8):\n\t\tif height > 32 or width < 1 or height < 1:\n\t\t\traise \"Height must be betw... | [
"0.72747993",
"0.7067661",
"0.7017476",
"0.6882583",
"0.68422496",
"0.67394173",
"0.6729436",
"0.66049755",
"0.6581832",
"0.6571969",
"0.6553695",
"0.6549323",
"0.6549323",
"0.65488917",
"0.65194386",
"0.6515867",
"0.647435",
"0.6461672",
"0.6451565",
"0.645152",
"0.64387226"... | 0.6213043 | 44 |
Add (multidimensional) samples to buffer. | def push(self, samples):
len_s = len(samples)
if self.idx + len_s < self.len:
self.data[self.idx:self.idx + len_s] = samples
self.idx += len_s
else:
if self.idx == self.len:
self.data[:-len_s] = self.data[len_s:]
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addSamples(self, samples):\n try:\n self.buf = np.append(\n self.buf,\n np.fromstring(\n samples,\n dtype=np.float32))\n self.bufcount += 1\n except:\n pass\n if self.bufcount >= self.numBu... | [
"0.7309586",
"0.68047845",
"0.6730027",
"0.669488",
"0.6684545",
"0.6589268",
"0.64348847",
"0.64089745",
"0.6260624",
"0.62548214",
"0.62530696",
"0.6174509",
"0.6046224",
"0.6001303",
"0.59894323",
"0.5982165",
"0.59481347",
"0.59215266",
"0.5910251",
"0.58930796",
"0.58878... | 0.6881006 | 1 |
Pop a number of samples from buffer. | def pop(self, idx=None):
if not idx:
samples = np.copy(self.data[:self.idx])
self.data[:] = np.empty(self.data.shape)
self.idx = 0
else:
if idx > self.idx:
raise ValueError()
samples = np.copy(self.data[:idx])
data =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _popN(self, n):\n for _ in range(n):\n self._buffer.popleft()",
"def pop(self):\n while self.number > self.maxlength:\n self.buffer.popleft()\n self.number -= 1",
"def pop_memory(self, **kwarg):\n for name, obs in kwarg.items():\n self.buffer... | [
"0.67280066",
"0.6347082",
"0.6287858",
"0.60025215",
"0.59872806",
"0.5924517",
"0.59227526",
"0.58538824",
"0.5841255",
"0.58254236",
"0.58163065",
"0.58092636",
"0.58041793",
"0.5779683",
"0.5754109",
"0.5721759",
"0.568317",
"0.5670812",
"0.5636273",
"0.5605704",
"0.56044... | 0.70006067 | 0 |
Return whether the buffer is full. | def is_full(self):
return self.idx == self.len | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bufferIsFull(self):\n return len(self.buffer) == self.bufferSize",
"def isFull(self):\n return self.__size == len(self.__buffer)",
"def is_full(self):\n return len(self) == self.buffer_size",
"def is_full(self):\n return len(self) == self.buffer_size",
"def is_full(self):\n ... | [
"0.902843",
"0.88964313",
"0.8631627",
"0.8631627",
"0.8631627",
"0.8631627",
"0.8273404",
"0.8033453",
"0.786584",
"0.7722272",
"0.7716352",
"0.75985116",
"0.7564237",
"0.75423336",
"0.75304025",
"0.75304025",
"0.75271684",
"0.7520153",
"0.7509155",
"0.7410427",
"0.7410427",... | 0.67810583 | 91 |
Return whether the buffer is empty. | def is_empty(self):
return self.idx == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isBufferEmpty(self):\n return self.ecg_buffer.empty()",
"def is_empty(self):\r\n return self.buff==[]",
"def bufferIsFull(self):\n return len(self.buffer) == self.bufferSize",
"def is_buffer_empty(self): \n if self.buffer.shape == (0, 5):\n return True\n ... | [
"0.8953262",
"0.855195",
"0.8377299",
"0.82790333",
"0.8227648",
"0.8173503",
"0.81430453",
"0.8143014",
"0.8119658",
"0.8119658",
"0.8119658",
"0.8119658",
"0.8119658",
"0.8119658",
"0.8119658",
"0.8080496",
"0.8030943",
"0.79950076",
"0.79667044",
"0.7965184",
"0.7965184",
... | 0.0 | -1 |
Returns the dictionary of genome fasta | def getseq(genomefasta):
genomedict = {}
for i in SeqIO.parse(open(genomefasta), "fasta"):
genomedict[i.id] = str(i.seq)
return genomedict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_fasta_to_dictionary(genome_file):\n filename = genome_file\n dct = {}\n\n id_name = \"\"\n sequence = \"\"\n first_pass = 1\n\n read_fh = open(filename, 'r')\n for i, line in enumerate(read_fh):\n line = line.rstrip()\n if re.search(r'^>(\\S+)(\\s+)(\\S+)(\\s+)(\\S+)(\\s... | [
"0.7508443",
"0.7360985",
"0.71590203",
"0.689614",
"0.6895492",
"0.6875781",
"0.6870282",
"0.6815837",
"0.680902",
"0.67469376",
"0.6740498",
"0.6521526",
"0.64860785",
"0.6435831",
"0.64199185",
"0.64125013",
"0.63991344",
"0.63906515",
"0.6364206",
"0.6346941",
"0.6306387"... | 0.7972919 | 0 |
Program to read a gff and create dictionary of exons from a transcript | def read_gff(gff):
genome = getseq(args.genome)
dictoftranscripts = {}
for k in open(gff):
if not k.startswith("#"):
lines = k.strip().split("\t")
if lines[2] == "exon":
strand = lines[6]
chromosome = lines[0]
start = lines[3]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GFFParse(gff_file):\n genes, utr5, exons=dict(), dict(), dict()\n transcripts, utr3, cds=dict(), dict(), dict()\n # TODO Include growing key words of different non-coding/coding transcripts \n features=['mrna', 'transcript', 'ncrna', 'mirna', 'pseudogenic_transcript', 'rrna', 'snorna', 'snrna', 'tr... | [
"0.75707626",
"0.73930323",
"0.7180306",
"0.6962576",
"0.6809232",
"0.6784794",
"0.67178106",
"0.6689208",
"0.6666986",
"0.6539142",
"0.6533102",
"0.635201",
"0.62793416",
"0.62397146",
"0.6231889",
"0.6221245",
"0.6214062",
"0.61779433",
"0.61518013",
"0.6121378",
"0.6117332... | 0.77669865 | 0 |
Show all or a specific predefined statistic. | def show_predefined_statistics(idx: int = -1) -> None:
if idx < 0:
print(PermutationStatistic._predefined_statistics())
else:
print(PermutationStatistic._STATISTICS[idx][0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def showStat(self):\n print \">>[Stat Information]:\"\n if self.gid != DEFALUT_GROUP_ID:\n print \"Gid = %u\" % self.gid\n print \"[Queries] Arp = %u, Original_to_controller= %u, Current_to_controller = %u\" % (self.query_arp, self.query_control_origin, self.query_control_current)\n... | [
"0.6680718",
"0.65894514",
"0.65171486",
"0.65093523",
"0.6490466",
"0.6477537",
"0.64123726",
"0.640252",
"0.6308846",
"0.63020253",
"0.6296237",
"0.62802315",
"0.6250845",
"0.62471896",
"0.6246921",
"0.6233278",
"0.62177813",
"0.6141919",
"0.6141851",
"0.6141851",
"0.610725... | 0.70260644 | 0 |
Name and index of each statistics defined. | def _predefined_statistics() -> str:
return "\n".join(
f"[{i}] {name}"
for i, (name, _) in enumerate(PermutationStatistic._STATISTICS)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index_stats(self):\r\n request = http.Request('GET', '/metadata/index_stats')\r\n return request, parsers.parse_json",
"def stats(self):",
"def stats(self):\n pass",
"def statistics(self, **_):\n raise NotImplementedError(\"{} doesn't support statistics.\".format(__class__.__n... | [
"0.70576185",
"0.70531046",
"0.69878983",
"0.6797239",
"0.6488815",
"0.6464694",
"0.639589",
"0.63899624",
"0.63841057",
"0.63463813",
"0.6339199",
"0.6293092",
"0.62803864",
"0.62722677",
"0.62664586",
"0.6248297",
"0.62386674",
"0.6170812",
"0.6166758",
"0.615434",
"0.61357... | 0.6436305 | 6 |
Get a statistic by index. | def get_by_index(cls, idx: int) -> "PermutationStatistic":
return cls(*PermutationStatistic._STATISTICS[idx]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_by_index(self, index):\n # makes it easier for callers to just pass in a header value\n index = int(index) if index else 0\n return self.by_index.get(index)",
"def get(self, index):\n raise NotImplementedError() # pragma: no cover",
"def get_at_index(self, index: int) -> obj... | [
"0.7498371",
"0.71451086",
"0.7102152",
"0.6922391",
"0.67885476",
"0.66309804",
"0.66093",
"0.6583636",
"0.657459",
"0.65730995",
"0.6543232",
"0.65285486",
"0.6507778",
"0.64874345",
"0.64874345",
"0.6459586",
"0.64476395",
"0.64476395",
"0.642201",
"0.6396596",
"0.639335",... | 0.709509 | 3 |
Check if statistic (self) is preserved in a bijection. | def preserved_in(self, bijection: BijectionType) -> bool:
return all(self.func(k) == self.func(v) for k, v in bijection.items()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invariant(self):\n\t\treturn (self.demand.popId != self.dstPopId)",
"def is_bijective(self):\n return self.is_injective() and self.is_surjective()",
"def check_all_transformed(cls, bijection: BijectionType) -> Dict[str, List[str]]:\n transf = defaultdict(list)\n all_stats = cls._get_al... | [
"0.59036845",
"0.58631575",
"0.5650684",
"0.5457113",
"0.53898907",
"0.5371066",
"0.53598166",
"0.53580296",
"0.52650684",
"0.524763",
"0.52252597",
"0.5104863",
"0.5102853",
"0.5074673",
"0.5071287",
"0.5058628",
"0.5055895",
"0.5042884",
"0.5037415",
"0.5028868",
"0.5026352... | 0.72229594 | 0 |
Return a distribution of statistic for a fixed length of permutations. If a class is not provided, we use the set of all permutations. | def distribution_for_length(
self, n: int, perm_class: Optional[Av] = None
) -> List[int]:
iterator = perm_class.of_length(n) if perm_class else Perm.of_length(n)
cnt = Counter(self.func(p) for p in iterator)
lis = [0] * (max(cnt.keys(), default=0) + 1)
for key, val in cnt.it... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sampling_class_portion(data,classes,others=None,class_portion=None,rng=np.random.RandomState(100)):\n u, indices = np.unique(classes,return_inverse=True)\n indices=np.asarray(indices)\n num_u=len(u)\n sample_sizes=dict()\n \n # get sample size of each class\n size_min=float(\"inf\")\n f... | [
"0.61888975",
"0.61321306",
"0.5902894",
"0.5809527",
"0.57847863",
"0.5612866",
"0.55107516",
"0.5496993",
"0.5490976",
"0.54454756",
"0.53975725",
"0.537233",
"0.5363853",
"0.5340827",
"0.5332886",
"0.5306523",
"0.525835",
"0.5203852",
"0.51803553",
"0.51737016",
"0.5172415... | 0.6423975 | 0 |
Return a table (i,k) for the distribution of a statistic. Here i=0..n is the length of the permutation and k is the statistic. If a class is not provided, we use the set of all permutations. | def distribution_up_to(
self, n: int, perm_class: Optional[Av] = None
) -> List[List[int]]:
return [self.distribution_for_length(i, perm_class) for i in range(n + 1)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distribution_for_length(\n self, n: int, perm_class: Optional[Av] = None\n ) -> List[int]:\n iterator = perm_class.of_length(n) if perm_class else Perm.of_length(n)\n cnt = Counter(self.func(p) for p in iterator)\n lis = [0] * (max(cnt.keys(), default=0) + 1)\n for key, va... | [
"0.60621035",
"0.5803131",
"0.56659365",
"0.5633736",
"0.54761815",
"0.5446069",
"0.54373926",
"0.5400695",
"0.53731865",
"0.53490126",
"0.5339221",
"0.5321965",
"0.5285499",
"0.52791893",
"0.5278764",
"0.52647245",
"0.52416486",
"0.5241132",
"0.5234149",
"0.5232093",
"0.5230... | 0.56240183 | 4 |
Return all stats that are equally distributed for two classes up to a max length. | def equally_distributed(cls, class1: Av, class2: Av, n: int = 6) -> Iterator[str]:
return (
stat.name
for stat in cls._get_all()
if all(
stat.distribution_for_length(i, class1)
== stat.distribution_for_length(i, class2)
for i in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jointly_equally_distributed(\n class1: Av, class2: Av, n: int = 6, dim: int = 2\n ) -> Iterator[Tuple[str, ...]]:\n return (\n tuple(stat[0] for stat in stats)\n for stats in combinations(PermutationStatistic._STATISTICS, dim)\n if all(\n Counter... | [
"0.6598037",
"0.6402674",
"0.5585297",
"0.5560338",
"0.55585843",
"0.5543845",
"0.54998505",
"0.5416551",
"0.5411819",
"0.5411735",
"0.5398721",
"0.53787124",
"0.53559506",
"0.53210706",
"0.5216282",
"0.51838976",
"0.5151496",
"0.5138267",
"0.51368135",
"0.5108671",
"0.510867... | 0.7223419 | 0 |
Check if a combination of statistics is equally distributed between two classes up to a max length. | def jointly_equally_distributed(
class1: Av, class2: Av, n: int = 6, dim: int = 2
) -> Iterator[Tuple[str, ...]]:
return (
tuple(stat[0] for stat in stats)
for stats in combinations(PermutationStatistic._STATISTICS, dim)
if all(
Counter(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def equally_distributed(cls, class1: Av, class2: Av, n: int = 6) -> Iterator[str]:\n return (\n stat.name\n for stat in cls._get_all()\n if all(\n stat.distribution_for_length(i, class1)\n == stat.distribution_for_length(i, class2)\n ... | [
"0.66576874",
"0.6199647",
"0.59378564",
"0.5789172",
"0.5702513",
"0.56209457",
"0.5614542",
"0.5610369",
"0.56012976",
"0.5587149",
"0.5558948",
"0.5496086",
"0.5490565",
"0.54831845",
"0.54587644",
"0.5453182",
"0.5418705",
"0.5415977",
"0.5410122",
"0.53655595",
"0.535024... | 0.66751057 | 0 |
Check if a combination of statistics in one class is equally distributed to any combination of statistics in the other class, up to a max length. | def jointly_transformed_equally_distributed(
class1: Av, class2: Av, n: int = 6, dim: int = 2
) -> Iterator[Tuple[Tuple[str, ...], Tuple[str, ...]]]:
return (
(tuple(stat[0] for stat in stats1), tuple(stat[0] for stat in stats2))
for stats1, stats2 in combinations(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jointly_equally_distributed(\n class1: Av, class2: Av, n: int = 6, dim: int = 2\n ) -> Iterator[Tuple[str, ...]]:\n return (\n tuple(stat[0] for stat in stats)\n for stats in combinations(PermutationStatistic._STATISTICS, dim)\n if all(\n Counter... | [
"0.68069184",
"0.67847127",
"0.5922778",
"0.5852236",
"0.5794417",
"0.57679653",
"0.5757954",
"0.5685894",
"0.56620884",
"0.56597733",
"0.5649154",
"0.5615442",
"0.55955535",
"0.5567301",
"0.552943",
"0.55247164",
"0.5493836",
"0.5431487",
"0.54256177",
"0.54218966",
"0.54197... | 0.6328433 | 2 |
Get all predefined statistics as an instance of PermutationStatistic. | def _get_all(cls) -> Iterator["PermutationStatistic"]:
yield from (cls(name, func) for name, func in PermutationStatistic._STATISTICS) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _predefined_statistics() -> str:\n return \"\\n\".join(\n f\"[{i}] {name}\"\n for i, (name, _) in enumerate(PermutationStatistic._STATISTICS)\n )",
"def mutation_probabilities(self):\n return list(self.mutation_pool.values())",
"def show_predefined_statistics(idx: int... | [
"0.70551056",
"0.6512036",
"0.6451701",
"0.6330738",
"0.62371397",
"0.6094051",
"0.60733724",
"0.59972787",
"0.59330034",
"0.587885",
"0.5836238",
"0.57374936",
"0.56783426",
"0.5667591",
"0.5646153",
"0.55885726",
"0.5553806",
"0.5530332",
"0.55006117",
"0.54704416",
"0.5459... | 0.7527292 | 0 |
Given a bijection, check which statistics are preserved. | def check_all_preservations(cls, bijection: BijectionType) -> Iterator[str]:
return (stats.name for stats in cls._get_all() if stats.preserved_in(bijection)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_all_transformed(cls, bijection: BijectionType) -> Dict[str, List[str]]:\n transf = defaultdict(list)\n all_stats = cls._get_all()\n for stat1, stat2 in product(all_stats, all_stats):\n if all(stat1.func(k) == stat2.func(v) for k, v in bijection.items()):\n t... | [
"0.66531956",
"0.63910055",
"0.55745256",
"0.5352943",
"0.52362436",
"0.5194983",
"0.5103389",
"0.5067221",
"0.5019369",
"0.48898706",
"0.4860377",
"0.48361117",
"0.48361117",
"0.48361117",
"0.48343045",
"0.481323",
"0.4766111",
"0.47515914",
"0.4739123",
"0.472368",
"0.46902... | 0.5517658 | 3 |
Given a bijection, check what statistics transform into others. | def check_all_transformed(cls, bijection: BijectionType) -> Dict[str, List[str]]:
transf = defaultdict(list)
all_stats = cls._get_all()
for stat1, stat2 in product(all_stats, all_stats):
if all(stat1.func(k) == stat2.func(v) for k, v in bijection.items()):
transf[stat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preserved_in(self, bijection: BijectionType) -> bool:\n return all(self.func(k) == self.func(v) for k, v in bijection.items())",
"def analyse(self):\n self.__try_fitting()\n self.second.rotate()\n self.__try_fitting()",
"def test_sufficient_statistics(self):\n assert (\n ... | [
"0.5534995",
"0.4957287",
"0.4899984",
"0.4860593",
"0.4808464",
"0.47695872",
"0.47544986",
"0.47357872",
"0.47212732",
"0.4716885",
"0.46912074",
"0.4689866",
"0.468611",
"0.4674001",
"0.46639493",
"0.46639493",
"0.46639493",
"0.46483684",
"0.46417412",
"0.46233192",
"0.459... | 0.7150287 | 0 |
Yield all symmetric versions of a bijection. | def symmetry_duplication(
bijection: BijectionType,
) -> Iterator[BijectionType]:
return (
bij
for rotated in (
{k.rotate(angle): v.rotate(angle) for k, v in bijection.items()}
for angle in range(4)
)
for bij in (rotated... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def symmetric(self):\n result = self.directed()\n result.extend([(down, up) for up, down in result])\n return Pairs(result)",
"def yield_symmetric_images(image):\n for h in (True, False): # horizontal\n for v in (True, False): # vertical\n for d in (True, False): # di... | [
"0.65729105",
"0.59622586",
"0.59610325",
"0.58295286",
"0.56446946",
"0.5581517",
"0.5525889",
"0.5328512",
"0.5313593",
"0.5273254",
"0.526318",
"0.5234545",
"0.5233796",
"0.52252924",
"0.52191466",
"0.51288265",
"0.5095979",
"0.5066039",
"0.50310177",
"0.50216424",
"0.4998... | 0.7548317 | 0 |
write a file and returns number of chars | def append_write(filename="", text=""):
with open(filename, 'a') as f:
return f.write(text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_file(filename=\"\", text=\"\"):\n with open(filename, mode='w', encoding='utf-8') as f:\n f.write(text)\n with open(filename, encoding='utf-8') as f:\n chars_wrote = 0\n for line in f:\n for chrs in line:\n chars_wrote += 1\n return chars_wrote",
... | [
"0.76660883",
"0.7458114",
"0.7425081",
"0.74076253",
"0.7348848",
"0.72907513",
"0.7181067",
"0.7137664",
"0.7083144",
"0.6813347",
"0.6753556",
"0.67117894",
"0.66629267",
"0.6444836",
"0.6097364",
"0.6041025",
"0.59749734",
"0.59479547",
"0.5888847",
"0.58717453",
"0.58715... | 0.0 | -1 |
Creates a binary model using the configuration above. | def create_model(
input_length, input_depth, num_conv_layers, conv_filter_sizes, conv_stride,
conv_depths, max_pool_size, max_pool_stride, num_fc_layers, fc_sizes,
num_tasks, batch_norm, conv_drop_rate, fc_drop_rate
):
bin_model = binary_models.BinaryPredictor(
input_length=input_length,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_model():\n m = model_class(*argv[2:-1])\n modelobj[\"model\"] = m",
"def create_model():\r\n parser = argparse.ArgumentParser()\r\n parser.add_argument('--DISC_LR', type=float, default=1e-4)\r\n parser.add_argument('--GEN_LR', type=float, default=1e-3)\r\n parser.add_argument('--GEN_BE... | [
"0.6976374",
"0.6738157",
"0.67200863",
"0.67200863",
"0.6598115",
"0.65837914",
"0.65531623",
"0.6531232",
"0.65258634",
"0.65250564",
"0.65024483",
"0.64977425",
"0.6426681",
"0.6377093",
"0.6304412",
"0.6303984",
"0.62989664",
"0.6277534",
"0.62273085",
"0.62052596",
"0.62... | 0.7062543 | 0 |
Computes the loss for the model. | def model_loss(
model, true_vals, logit_pred_vals, epoch_num, avg_class_loss,
att_prior_loss_weight, att_prior_loss_weight_anneal_type,
att_prior_loss_weight_anneal_speed, att_prior_grad_smooth_sigma,
fourier_att_prior_freq_limit, fourier_att_prior_freq_limit_softness,
att_prior_loss_only, l2_reg_lo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_loss(self):",
"def loss(self):\n if not self.run:\n self._run()\n return self.model_loss",
"def compute_loss(self, **kwargs):\n raise NotImplementedError",
"def compute_loss(self, *args, **kwargs):\n raise NotImplementedError",
"def compute_loss(self, obs,... | [
"0.82527417",
"0.80662954",
"0.7966444",
"0.7829898",
"0.7785851",
"0.7774999",
"0.7773903",
"0.7773903",
"0.7760963",
"0.76660734",
"0.76615447",
"0.7643104",
"0.762887",
"0.7602304",
"0.75895303",
"0.7490758",
"0.7482441",
"0.7434751",
"0.74315244",
"0.7414879",
"0.7407431"... | 0.0 | -1 |
Runs the data from the data loader once through the model, to train, validate, or predict. | def run_epoch(
data_loader, mode, model, epoch_num, num_tasks, att_prior_loss_weight,
batch_size, revcomp, input_length, input_depth, optimizer=None,
return_data=False
):
assert mode in ("train", "eval")
if mode == "train":
assert optimizer is not None
else:
assert optimizer is N... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self) -> None:\n self.model = self.trainer.train_model(self.model, self.data)",
"def _load_training_data(self):\n self._save_training_data()",
"def fit(self, data_loader):\n train_data, valid_data = data_loader.load()\n\n self.compile(self.optimizer, self.loss)\n supe... | [
"0.73353904",
"0.73273337",
"0.71172583",
"0.7087635",
"0.7086511",
"0.69524735",
"0.68974733",
"0.6874695",
"0.68029535",
"0.67629904",
"0.6761732",
"0.6740564",
"0.6729408",
"0.6717705",
"0.666639",
"0.6652321",
"0.66380984",
"0.66373324",
"0.6624034",
"0.6599208",
"0.65854... | 0.0 | -1 |
Trains the network for the given training and validation data. | def train_model(
train_loader, val_loader, test_loader, num_epochs, learning_rate,
early_stopping, early_stop_hist_len, early_stop_min_delta, train_seed, _run
):
run_num = _run._id
output_dir = os.path.join(MODEL_DIR, str(run_num))
if train_seed:
torch.manual_seed(train_seed)
devic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(self, training_data, training_labels, validation_data, validation_labels):\n abstract",
"def train(self, training_data):\n pass",
"def train(self, trainingData, trainingLabels, validationData, validationLabels):\n self.trainingData = trainingData\n self.trainingLabels = tr... | [
"0.7831003",
"0.7694084",
"0.74521255",
"0.7451457",
"0.74462587",
"0.74061525",
"0.73412263",
"0.73408604",
"0.73290575",
"0.72626746",
"0.72339815",
"0.7226424",
"0.7225421",
"0.71824056",
"0.7115206",
"0.7113805",
"0.70988035",
"0.70916414",
"0.7087484",
"0.7050911",
"0.70... | 0.0 | -1 |
METhods for part 2, first one is calculates the price divided by the weight, and then | def stealability(self):
Price_weight = self.price / self.weight
if Price_weight < .05:
return "Not so stealable..."
elif Price_weight < 1.0:
return 'Kinda stealable.'
else:
return 'Very stealable' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_weighted_results():\n pass",
"def getWeight(self) -> float:\n ...",
"def weight(self):",
"def generate_dollar_volume_weights(close, volume):\n \n product = close*volume \n \n \n \n weights=product.apply(lambda r : r/sum(r),axis=1) \n \n assert close.index.... | [
"0.6824928",
"0.6701285",
"0.63847876",
"0.6249634",
"0.61820394",
"0.6160329",
"0.6129356",
"0.60853183",
"0.6084638",
"0.6049865",
"0.6014016",
"0.5994835",
"0.5953426",
"0.5950241",
"0.59280026",
"0.59164476",
"0.5906385",
"0.58688015",
"0.5865969",
"0.5861935",
"0.5858723... | 0.0 | -1 |
Second method is calculates the flammability times the weight, and then | def explode(self):
fire_potential = self.flannability * self.weight
if fire_potential < 10:
return '...fizzle'
elif fire_potential < 50:
return '...boom!'
else:
return '...BABOOM!!'
# part 3 sublass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_weighted_results():\n pass",
"def weight(self):",
"def weighting(wb, m, a):\n s = control.tf([1, 0], [1])\n return (s/m + wb) / (s + wb*a)",
"def update(self, state, action, nextState, reward):\n \"\"\"Description:\n Use second equation in slide 71 of MDP\n Adjest weight of ac... | [
"0.7003657",
"0.68875086",
"0.6864097",
"0.6554528",
"0.65470135",
"0.65269685",
"0.6501361",
"0.6474634",
"0.6315795",
"0.63009286",
"0.6274216",
"0.6245748",
"0.61817664",
"0.6163226",
"0.61394775",
"0.61375505",
"0.6119866",
"0.6117205",
"0.61116475",
"0.61116475",
"0.6099... | 0.0 | -1 |
a method of a BoxingGLove | def punch(self):
# you are not working, futher investagtion needed...
if self.weight < 5:
return "That tickles."
elif self.weight < 15:
return "Hey that hurt!"
else:
return "OUCH!" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSlaves():",
"def get_box(req):",
"def mezclar_bolsa(self):",
"def vault(self):",
"def degibber(self):",
"def g_lb(self):\n pass",
"def loan(self):",
"def g():",
"def falcon():",
"def test_default_boxing_glove_weight(self):\n glove = BoxingGlove('Test Boxing Glove')\n s... | [
"0.6039578",
"0.59777343",
"0.58677846",
"0.5758756",
"0.5739335",
"0.5702562",
"0.56555104",
"0.55625945",
"0.5496464",
"0.5430553",
"0.5360382",
"0.5270328",
"0.52642834",
"0.52203786",
"0.5197174",
"0.5176454",
"0.51158637",
"0.51016134",
"0.509537",
"0.5086172",
"0.508295... | 0.0 | -1 |
Gets environment variable as string. | def getenv_string(setting, default=''):
return os.environ.get(setting, default) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_env(key: str) -> str:\n value = os.getenv(key)\n assert isinstance(value, str), (\n f\"the {key} environment variable must be set and a string, \" f\"{value=}\"\n )\n return value",
"def env(var):\n return os.environ[var]",
"def windows_get_env_value(var_name:... | [
"0.81528544",
"0.7418339",
"0.7405049",
"0.72382337",
"0.72329384",
"0.72261554",
"0.7057835",
"0.69984245",
"0.69965094",
"0.69708145",
"0.6922805",
"0.68801343",
"0.68776995",
"0.685753",
"0.68367887",
"0.68226147",
"0.6817827",
"0.6792033",
"0.6738943",
"0.67099005",
"0.66... | 0.7531773 | 1 |
Gets environment variable as boolean value. | def getenv_bool(setting, default=None):
result = os.environ.get(setting, None)
if result is None:
return default
return str2bool(result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eval_env_as_boolean(varname, standard_value) -> bool:\n return str(os.getenv(varname, standard_value)).lower() in (\"true\", \"1\", \"t\", \"y\")",
"def env_var_bool(key: str) -> bool:\n return env_var_line(key).upper() in (\"TRUE\", \"ON\", \"YES\")",
"def environ_bool(var, default=False):\n if v... | [
"0.82893",
"0.80127674",
"0.7843964",
"0.783441",
"0.7601062",
"0.75889426",
"0.75562733",
"0.73252225",
"0.7213979",
"0.6979548",
"0.6971869",
"0.68721783",
"0.6818791",
"0.6491351",
"0.6471654",
"0.64534855",
"0.6428621",
"0.6404237",
"0.6373961",
"0.6329838",
"0.6319821",
... | 0.81049186 | 1 |
Load citation network dataset (cora only for now) | def load_data(path="data/cora/", dataset="cora"):
print('Loading {} dataset...'.format(dataset))
idx_features_labels = np.genfromtxt("{}{}.content".format(path, dataset),
dtype=np.dtype(str))
features = sp.csr_matrix(idx_features_labels[:, 1:-1], dtype=np.float32)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_citation(dataset_str=\"cora\", normalization=\"AugNormAdj\", cuda=True,task_type = \"full\"):\n names = ['x', 'y', 'tx', 'ty', 'allx', 'ally', 'graph']\n objects = []\n\n for i in range(len(names)):\n with open(\"data/ind.{}.{}\".format(dataset_str.lower(), names[i]), 'rb') as f:\n ... | [
"0.6683991",
"0.6622463",
"0.6141501",
"0.6106169",
"0.60774505",
"0.60507864",
"0.59139097",
"0.58660084",
"0.58487874",
"0.58372116",
"0.5782893",
"0.57269454",
"0.5719912",
"0.5669881",
"0.5667391",
"0.56019217",
"0.5577402",
"0.5559361",
"0.55509675",
"0.5508815",
"0.5499... | 0.5980766 | 6 |
Convert a scipy sparse matrix to a torch sparse tensor. | def sparse_mx_to_torch_sparse_tensor(sparse_mx):
sparse_mx = sparse_mx.tocoo().astype(np.float32)
indices = torch.from_numpy(
np.vstack((sparse_mx.row, sparse_mx.col)).astype(np.int64))
values = torch.from_numpy(sparse_mx.data)
shape = torch.Size(sparse_mx.shape)
return torch.sparse.FloatTen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def csr2tensor(self, matrix: sp.csr_matrix):\n matrix = matrix.tocoo()\n x = torch.sparse.FloatTensor(\n torch.LongTensor(np.array([matrix.row, matrix.col])),\n torch.FloatTensor(matrix.data.astype(np.float32)),\n matrix.shape,\n ).to(self.device)\n retu... | [
"0.8300307",
"0.81481314",
"0.80456084",
"0.8032226",
"0.80131984",
"0.799705",
"0.799705",
"0.79850143",
"0.79850143",
"0.79850143",
"0.7976765",
"0.7964795",
"0.77543104",
"0.7712594",
"0.74288416",
"0.74288416",
"0.7353584",
"0.7196928",
"0.7156608",
"0.6987555",
"0.696929... | 0.80297416 | 15 |
Function setup as many loggers as you want | def setup_logger(name, log_file, level=logging.INFO):
handler = logging.FileHandler(log_file)
handler.setFormatter(formatter)
logger = logging.getLogger(name)
logger.setLevel(level)
logger.addHandler(handler)
return logger | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_logging():\n for name, logger in loggers.items():\n logger.setLevel(LOGGING_MAPPING.get(options.logging, logging.DEBUG))\n handler = logging.FileHandler(\n getattr(options, '{}_log_file_path'.format(name))\n )\n formatter = logging.Formatter(\n '%(asct... | [
"0.78740317",
"0.7486723",
"0.74351895",
"0.73347795",
"0.73000693",
"0.7199389",
"0.7087987",
"0.70320326",
"0.69823223",
"0.6978423",
"0.69602084",
"0.6936834",
"0.69327366",
"0.69308853",
"0.6920356",
"0.6897304",
"0.6891727",
"0.6888452",
"0.6884285",
"0.6870096",
"0.6868... | 0.0 | -1 |
A decorator which can be used to observe members on a class. | def observe(*names: str, change_types: ChangeType = ChangeType.ANY) -> "ObserveHandler":
# backwards compatibility for a single tuple or list argument
if len(names) == 1 and isinstance(names[0], (tuple, list)):
names = names[0]
pairs: List[Tuple[str, Optional[str]]] = []
for name in names:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classproperty(func):\n if not isinstance(func, (classmethod, staticmethod)):\n func = classmethod(func)\n\n return ClassPropertyDescriptor(func)",
"def classproperty(func):\n if not isinstance(func, (classmethod, staticmethod)):\n func = classmethod(func)\n\n return ClassPropertyDes... | [
"0.57596886",
"0.57596886",
"0.57257444",
"0.565604",
"0.5467317",
"0.5434296",
"0.53770643",
"0.5338553",
"0.5338553",
"0.5338553",
"0.5318796",
"0.5306546",
"0.52993506",
"0.5296651",
"0.5287876",
"0.5185864",
"0.51784855",
"0.51630294",
"0.50770926",
"0.50736374",
"0.50622... | 0.0 | -1 |
Called to decorate the function. | def __call__(
self,
func: Union[
Callable[[ChangeDict], None],
Callable[[T, ChangeDict], None],
# AtomMeta will replace ObserveHandler in the body of an atom
# class allowing to access it for example in a subclass. We lie here by
# giving Obser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrapper_fun(*args):\n print(\"Hello Decorator\")\n return fun(*args)",
"def decorate(self, func):\n if not callable(func):\n raise TypeError('Cannot decorate non callable object \"{func}\"'\n .format(func=func))\n self.decorated = func\n ... | [
"0.75918406",
"0.7467022",
"0.74556184",
"0.74200255",
"0.73327786",
"0.72957766",
"0.72129166",
"0.7154273",
"0.71444213",
"0.6987407",
"0.69722015",
"0.6901599",
"0.68459135",
"0.68446183",
"0.6833762",
"0.6833762",
"0.68126655",
"0.68060905",
"0.67986697",
"0.6772928",
"0.... | 0.0 | -1 |
Create a clone of the sentinel. | def clone(self) -> "ObserveHandler":
clone = type(self)(self.pairs, self.change_types)
clone.func = self.func
return clone | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone_zero(self):",
"def clone(self):\n return None",
"def clone(self):",
"def clone(self):\n return self",
"def clone(self):\n raise NotImplementedError",
"def clone(self, *args, **kwargs):\n return self.copy().reset(*args, **kwargs)",
"def clone(self):\n return ... | [
"0.6333348",
"0.6293593",
"0.6130563",
"0.588577",
"0.585229",
"0.57543343",
"0.5749601",
"0.5667616",
"0.5663871",
"0.5661153",
"0.5637386",
"0.56086254",
"0.5599034",
"0.5558445",
"0.5553204",
"0.5536516",
"0.55237055",
"0.5518182",
"0.55069965",
"0.5501923",
"0.54767174",
... | 0.0 | -1 |
Create a clone of the sentinel. | def clone(self) -> "set_default":
return type(self)(self.value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone_zero(self):",
"def clone(self):\n return None",
"def clone(self):",
"def clone(self):\n return self",
"def clone(self):\n raise NotImplementedError",
"def clone(self, *args, **kwargs):\n return self.copy().reset(*args, **kwargs)",
"def clone(self):\n return ... | [
"0.6333348",
"0.6293593",
"0.6130563",
"0.588577",
"0.585229",
"0.57543343",
"0.5749601",
"0.5667616",
"0.5663871",
"0.5661153",
"0.5637386",
"0.56086254",
"0.5599034",
"0.5558445",
"0.5553204",
"0.5536516",
"0.55237055",
"0.5518182",
"0.55069965",
"0.5501923",
"0.54767174",
... | 0.54426754 | 22 |
Handle a change of the target object. This handler will remove the old observer and attach a new observer to the target attribute. If the target object is not an Atom object, an exception will be raised. | def __call__(self, change: ChangeDict) -> None:
old = None
new = None
ctype = change["type"]
if ctype == "create":
new = change["value"]
elif ctype == "update":
old = change["oldvalue"]
new = change["value"]
elif ctype == "delete":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle(self, object, name, old, new):\n raise NotImplementedError",
"def update(self, target):\n self.target = target.detach()",
"def handle_dst(self, object, name, old, new):\n self.next.unregister(old)\n object, name = self.next.register(new)\n if old is not Uninitializ... | [
"0.5505239",
"0.5447666",
"0.5287387",
"0.5242358",
"0.5202192",
"0.5201194",
"0.51845044",
"0.5054616",
"0.5054616",
"0.5051807",
"0.5024639",
"0.5023258",
"0.50199413",
"0.50199413",
"0.50012773",
"0.4991372",
"0.4981381",
"0.4964892",
"0.4939625",
"0.49377948",
"0.4923551"... | 0.5871039 | 0 |
Add or override a member after the class creation. | def add_member(cls: AtomMeta, name: str, member: Member) -> None:
existing = cls.__atom_members__.get(name)
if existing is not None:
member.set_index(member.index)
member.copy_static_observers(member)
else:
member.set_index(len(cls.__atom_members__))
member.set_name(name)
# ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_member_function(cls, methodName, newMethod):\n cls.add_registration_code('def(\"%s\",%s)'%(methodName, newMethod), True)",
"def add_to_class(cls, name, value):\n if hasattr(value, 'contribute_to_class'):\n value.contribute_to_class(cls, name)\n if not name.startswith('_'):\... | [
"0.60400194",
"0.603651",
"0.5997592",
"0.5895129",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.57411194",
"0.56308806",
"0.56049895",
"0.5564861",
"... | 0.6289327 | 0 |
A compatibility pickler function. This function is not part of the public Atom api. | def __newobj__(cls, *args):
return cls.__new__(cls, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ufunc_pickler(ufunc):\n return ufunc.__name__",
"def __reduce_ex__(self, protocol):\n return (_safe_pickle_load, (self.__module__, self.__class__.__name__, self.name))",
"def pickle_fix(arg):\n return pickle_fix.calc(arg)",
"def _mpq_pickle_support():\n from gmpy import mpq\n mpq_t... | [
"0.5591826",
"0.5509971",
"0.53879505",
"0.5170107",
"0.51237637",
"0.4979496",
"0.49626854",
"0.48766857",
"0.48193747",
"0.48092628",
"0.47860783",
"0.4778863",
"0.47671393",
"0.4753181",
"0.4752602",
"0.4747695",
"0.4747695",
"0.47162032",
"0.47157842",
"0.47151735",
"0.47... | 0.0 | -1 |
Get the members dictionary for the type. Returns | def members(cls) -> Mapping[str, Member]:
return cls.__atom_members__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_members():",
"def members(self) -> object:\n return self._members",
"def _types(cls):\n return {}",
"def get_members(self):\n return self._members",
"def getMembers(self):\n outProperties = ctypes.c_void_p()\n _res = self.mAPIContext.SDTypeStruct_getMembers(self.m... | [
"0.63952565",
"0.6141157",
"0.61048436",
"0.6043802",
"0.59790736",
"0.59537697",
"0.59458727",
"0.59143937",
"0.59143937",
"0.59143937",
"0.59143937",
"0.588506",
"0.586556",
"0.58518934",
"0.582172",
"0.58169",
"0.5795562",
"0.579131",
"0.579131",
"0.5717494",
"0.5717494",
... | 0.6644524 | 0 |
Disable member notifications within in a context. Returns | def suppress_notifications(self) -> Iterator[None]:
old = self.set_notifications_enabled(False)
yield
self.set_notifications_enabled(old) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_disable(self) -> None:\n self._cancel_notification_cycle()",
"async def meow_disable(self, ctx: vbu.Context):\n\n try:\n self.meow_chats.remove(ctx.channel)\n except KeyError:\n return await ctx.send(\"Meow chat is already disabled in this channel.\")\n aw... | [
"0.64098877",
"0.6272673",
"0.5996046",
"0.5964311",
"0.5940147",
"0.5921571",
"0.5918627",
"0.5895818",
"0.5807672",
"0.57987577",
"0.5777032",
"0.57702875",
"0.5768139",
"0.5698065",
"0.5666636",
"0.5665004",
"0.5650755",
"0.5621009",
"0.5615958",
"0.56111205",
"0.5584636",... | 0.61531746 | 2 |
An implementation of the reduce protocol. This method creates a reduction tuple for Atom instances. This method should not be overridden by subclasses unless the author fully understands the rammifications. | def __reduce_ex__(self, proto):
args = (type(self),) + self.__getnewargs__()
return (__newobj__, args, self.__getstate__()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __reduce__(self):\n\t\treturn self.__class__, (self.dist, self.frozen)",
"def __reduce__(self):\n return (self.__class__, (self.getstate(),), self.__dict__)",
"def __reduce__(\n self: TokenMatcher,\n ) -> Tuple[Any, Any]: # Precisely typing this would be really long.\n data = (\n ... | [
"0.6684732",
"0.63559514",
"0.6309408",
"0.6007565",
"0.57184553",
"0.5686236",
"0.5661313",
"0.56560147",
"0.56263286",
"0.56263286",
"0.56263286",
"0.56263286",
"0.56263286",
"0.5624138",
"0.54437155",
"0.53765875",
"0.53731275",
"0.53516775",
"0.53506035",
"0.5314747",
"0.... | 0.5673178 | 6 |
Get the argument tuple to pass to __new__ on unpickling. See the Python.org docs for more information. | def __getnewargs__(self):
return () | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getnewargs__(self):\n return ({'pairs': self.__pairs,\n 'app': self.__app,\n 'namespace': self.__namespace},)",
"def __new__(cls, p):\n return tuple.__new__(cls, p)",
"def __new__(*args):",
"def __new__(*args):",
"def __new__(*args):",
"def __new__(*args):",
"def... | [
"0.70684737",
"0.642272",
"0.62783724",
"0.62783724",
"0.62783724",
"0.62783724",
"0.62783724",
"0.62783724",
"0.62783724",
"0.62783724",
"0.62783724",
"0.62783724",
"0.62783724",
"0.62783724",
"0.62783724",
"0.62783724",
"0.62783724",
"0.62783724",
"0.62783724",
"0.62783724",
... | 0.6289682 | 2 |
Set the program details in the GUI. {Boolean} Always returns True. | def __setDetails(self):
self.MainWindow.setWindowTitle("{0} {1}".format(
const.APP_NAME, const.VERSION))
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setProgram(self, program):\n self.program = program",
"def set_program(self, prog):\n self.prog = prog",
"def pr_info(self):\n process = self.backend.get_process(str(self.processBox.currentText()))\n\n if not process:\n return\n\n self.infoWindow2 = QDialog(par... | [
"0.60660547",
"0.59619004",
"0.59247255",
"0.58688223",
"0.5844067",
"0.5796609",
"0.57606316",
"0.57349515",
"0.56842154",
"0.5634517",
"0.5594872",
"0.55846405",
"0.5563236",
"0.55436593",
"0.554133",
"0.55260307",
"0.5519292",
"0.55175734",
"0.5494302",
"0.54732877",
"0.54... | 0.7473526 | 0 |
Runs continously in it's own thread, calling plugin, think functions and other things. Neccessary for timers, etc. | def run(self):
self.connect(self.config["server"]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\n self.thread = threading.Thread(target=self._main)\n self.thread.start()\n self.running = True",
"def _make_async_call(self, plugin, info):\r\n self._threads[str(plugin.name)] = thread = IntrospectionThread(plugin, info)\r\n thread.request_handled.connect(self._... | [
"0.68339056",
"0.66230667",
"0.65725917",
"0.6546856",
"0.65365475",
"0.64562845",
"0.6422816",
"0.63743937",
"0.6364291",
"0.63402826",
"0.6313455",
"0.6309936",
"0.6282736",
"0.6273753",
"0.62502044",
"0.6239591",
"0.62264085",
"0.6209281",
"0.6204822",
"0.61948276",
"0.618... | 0.0 | -1 |
Returns true if a plugin is loaded, otherwise false | def hasPlugin(self, plugin_name):
if plugin_name in self.plugins:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_loaded(self, plugin):\n return self._get_name(plugin) in self.loaded_plugins",
"def autoload(self):\n\t\tpath = self.world.config[\"plugin\"][\"path\"]\n\t\tif not self.load_glob(path):\n\t\t\treturn False\n\t\tif not self.check_deps():\n\t\t\treturn False\n\t\treturn True",
"def has_plugin(self,... | [
"0.82449305",
"0.75101715",
"0.7230979",
"0.7069812",
"0.70386356",
"0.691805",
"0.6850626",
"0.6843381",
"0.6841373",
"0.68310064",
"0.66861874",
"0.66766804",
"0.66580296",
"0.6645501",
"0.66317517",
"0.6622345",
"0.65992326",
"0.65837264",
"0.6525645",
"0.65177065",
"0.643... | 0.72091687 | 3 |
Returns a plugin instance. | def getPlugin(self, plugin_name):
if plugin_name in self.plugins:
return self.plugins[plugin_name]["module"].getPluginInstance()
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plugin_instance(self):\n return self.__plugin_instance",
"def getInstance(config):\n return Plugin(config)",
"def getInstance(config):\n return Plugin(config)",
"def create_plugin(self, **kwargs):\n return self.plugin_class(**kwargs)",
"def getPlugin(self, *args):\n return _l... | [
"0.84703135",
"0.82682073",
"0.82682073",
"0.7754983",
"0.73671436",
"0.70479256",
"0.7027809",
"0.6509363",
"0.6499314",
"0.63523436",
"0.6320262",
"0.6309016",
"0.6308648",
"0.62907016",
"0.6254284",
"0.6235442",
"0.62242097",
"0.62042576",
"0.61898714",
"0.61353517",
"0.61... | 0.6483052 | 9 |
Returns the plugin name if a command exists, otherwise none | def findPluginFromTrigger(self, trigger):
trigger = trigger.lower() # lowercase!
# Loop through all plugins.
for plugin_name in self.plugins:
plugin = self.getPlugin(plugin_name)
# Check if the plugin has that trigger.
if plugin.hasCommand(trigger):
return plugin_name
# Not found :(
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCommandPluginName(self, command):\n if isinstance(command, (VanillaCommandWrapper, )):\n return \"Minecraft\"\n if isinstance(command, (BukkitCommand, )) or isinstance(command, (VanillaCommand, )):\n return \"Bukkit\"\n if isinstance(command, (PluginIdentifiableCom... | [
"0.7861625",
"0.70794326",
"0.69629383",
"0.6962132",
"0.6780297",
"0.66943467",
"0.6660234",
"0.6655404",
"0.6635536",
"0.66057897",
"0.6447168",
"0.6420082",
"0.63883334",
"0.6372596",
"0.6321071",
"0.62909025",
"0.6256734",
"0.62225485",
"0.6219266",
"0.61888486",
"0.61854... | 0.6256634 | 17 |
Returns if a user is an admin or not | def isAdmin(self, nick):
if nick in self.config["admins"]:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_is_admin(user):\n return user in admins",
"def is_admin(user):\n return user.is_authenticated and user.id == app.config.get('ADMIN')",
"def is_admin_user(self):\n if \"is_admin\" in self._properties and self.is_admin == 'YES':\n return True\n return False",
"def is... | [
"0.893059",
"0.87329084",
"0.8720758",
"0.86934495",
"0.8606972",
"0.8575092",
"0.85193145",
"0.8454654",
"0.8378569",
"0.8346424",
"0.8324324",
"0.8313925",
"0.8262614",
"0.82554847",
"0.8234557",
"0.8232175",
"0.82130915",
"0.82102287",
"0.820046",
"0.8189302",
"0.81726366"... | 0.75662035 | 52 |
Prints errors to console or channel. Overrides default one. | def error(self, message, **args):
error_message = Utils.boldCode() + "Error: " + Utils.normalCode() + message
if args.has_key("target"):
self.sendMessage(args["target"], error_message)
if args.has_key("console"):
if args["console"]:
print self.errorTime(), "<ERROR>", Utils.stripCodes(message)
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error(msg):\n sys.stdout.write('%s[ ERROR ]%s %s\\n' % (colors.RED, colors.RESET, msg))",
"def error(*args, **kwargs):\n print(*args, file=sys.stderr, **kwargs)",
"def error(message):\n print(message, file=sys.stderr)",
"def err(*objects, file=sys.stderr, flush=True, style=Fore.RED, **kwargs):\r... | [
"0.6716573",
"0.6705718",
"0.666891",
"0.6587189",
"0.65618104",
"0.65083194",
"0.6506875",
"0.64992285",
"0.64820516",
"0.6474113",
"0.6463985",
"0.64298016",
"0.6427178",
"0.6409016",
"0.6373732",
"0.63657856",
"0.63599813",
"0.63531727",
"0.6303252",
"0.62840086",
"0.62806... | 0.6151281 | 36 |
Delegate len() to the list | def __len__(self):
return len(self.list) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __len__(self):\n return len(self.lst)",
"def __len__(self) -> int:\n return len(self._list)",
"def __len__(self):\n return self._list_size",
"def __len__(self):\n return len(self._list)",
"def __len__(self, *args, **kwargs):\n return len(self._list(*args, **kwargs))",... | [
"0.82745445",
"0.82071984",
"0.803236",
"0.80218816",
"0.7948731",
"0.7840801",
"0.7820482",
"0.7789977",
"0.77131003",
"0.76979923",
"0.7642971",
"0.7616903",
"0.7570917",
"0.75674087",
"0.7518233",
"0.7518233",
"0.7495621",
"0.7467969",
"0.7455057",
"0.7443009",
"0.7443009"... | 0.82164276 | 1 |
Delegate list access to the list | def __getitem__(self, key):
return self.list[key] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handleList(self, _): # pylint: disable=invalid-name",
"def _list(self):\n raise NotImplementedError",
"def list(self):",
"def handle_list(self, object, name, old, new):\n raise NotImplementedError",
"def list():",
"def list():",
"def get_list(self, *args, **kwargs):\n pass",
... | [
"0.7618319",
"0.72351456",
"0.69671774",
"0.67876697",
"0.67852724",
"0.67852724",
"0.6776298",
"0.6776298",
"0.6748505",
"0.6748505",
"0.6748505",
"0.6713678",
"0.66587704",
"0.6524382",
"0.64155626",
"0.6302316",
"0.62050456",
"0.61813194",
"0.61813194",
"0.6062461",
"0.605... | 0.605498 | 20 |
Delegate item setting to the list | def __setitem__(self, key, value):
self.list[key] = value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_item(self, item):\n self.item = item",
"def set_item(self, item):\n self.item = item",
"def setItem(self, item):\n self.setItem(0, item)",
"def set(self, item, value):\r\n raise NotImplementedError",
"def handle_list_items(self, object, name, old, new):\n raise No... | [
"0.7134188",
"0.7134188",
"0.68105966",
"0.68065274",
"0.6634302",
"0.6598864",
"0.65539867",
"0.65539867",
"0.65262127",
"0.64871484",
"0.6486587",
"0.6463725",
"0.6416732",
"0.63427573",
"0.63097346",
"0.6291076",
"0.6290381",
"0.62799877",
"0.62689066",
"0.62689066",
"0.62... | 0.6430695 | 12 |
Delegate deletion to the list | def __delitem__(self, key):
del self.list[key] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self):\n ...",
"def delete(self):\n pass",
"def delete(self):\n pass",
"def delete(self):\n pass",
"def delete(self):\n pass",
"def delete(self, *args, **kwargs):\n pass",
"def delete(self, *args, **kwargs):\n pass",
"def delete(self):\n ... | [
"0.76796913",
"0.73856044",
"0.73856044",
"0.73856044",
"0.73856044",
"0.7317691",
"0.7317691",
"0.7243035",
"0.7193677",
"0.71429205",
"0.7101894",
"0.7101894",
"0.7086735",
"0.703631",
"0.700108",
"0.6980739",
"0.6962558",
"0.69442636",
"0.68949986",
"0.6889769",
"0.6861762... | 0.658531 | 40 |
Delegate str() typecast to the list | def __str__(self):
return str(self.list) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def str_transform_list(L):\n return [str(x) for x in L]",
"def str_list_works(x):\n import ast\n x = ast.literal_eval(x)\n x = [n.strip() for n in x]\n return (x)",
"def safelist(listable):\n if type(listable) == str:\n return [listable]\n else:\n return listable.tolist()",
... | [
"0.70933765",
"0.69337887",
"0.68511224",
"0.6668498",
"0.66303754",
"0.6561758",
"0.6554643",
"0.6550241",
"0.6411791",
"0.6392433",
"0.6375944",
"0.6368587",
"0.6335204",
"0.6300129",
"0.6288121",
"0.62844443",
"0.6282183",
"0.62749064",
"0.62675184",
"0.62556165",
"0.62509... | 0.6576355 | 5 |
Delegate append() to the list | def append(self, value):
self.list.append(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append (self, item):\n pass",
"def append(self, item: Any) -> BaseList:\n super().append(item)\n return self",
"def append(self, *args, **kwargs): # real signature unknown\n pass",
"def append(self, value):\n assert isinstance(value, Item), type(value)\n list.append(... | [
"0.7694579",
"0.74595875",
"0.74573606",
"0.73051286",
"0.7278787",
"0.72393",
"0.7238687",
"0.722572",
"0.7224667",
"0.71918625",
"0.7154941",
"0.71133995",
"0.70053566",
"0.69869167",
"0.6909422",
"0.6901227",
"0.6869687",
"0.67841244",
"0.6766299",
"0.67546135",
"0.6732978... | 0.73121196 | 3 |
Delegate insert() to the list | def insert(self, index, value):
self.list.insert(index, value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(self):\n pass",
"def insert(self, index: int, item: Any) -> BaseList:\n super().insert(index, item)\n return self",
"def insert(self, *args):\n return _libsbml.ListOf_insert(self, *args)",
"def insert(*, list : Union[List[Any], ConduitVariable], index : int, item : Any)... | [
"0.76981884",
"0.76538897",
"0.7507453",
"0.7435977",
"0.7432101",
"0.73447275",
"0.72086906",
"0.72022694",
"0.71954155",
"0.7189005",
"0.7187494",
"0.7047705",
"0.701027",
"0.6992901",
"0.6951245",
"0.6946492",
"0.69339126",
"0.6923873",
"0.6750348",
"0.6749808",
"0.6738996... | 0.7354343 | 5 |
Delegate pop() to the list | def pop(self):
self.list.pop() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop(self):",
"def pop(self):",
"def pop(self):\r\n return self.list.pop()",
"def pop(self): ##################### <-\n value = self.lst[-1]\n self.lst = self.lst[:-1]\n return value",
"def pop():",
"def pop(self):\n pass",
"def pop(self):\n pass",
"def pop(se... | [
"0.8104019",
"0.8104019",
"0.79311556",
"0.7867167",
"0.7832172",
"0.77851623",
"0.77503335",
"0.77503335",
"0.77467185",
"0.7742908",
"0.77351236",
"0.77227414",
"0.767835",
"0.76257366",
"0.7521559",
"0.74597466",
"0.74431336",
"0.7318125",
"0.7282987",
"0.7224658",
"0.7176... | 0.8389024 | 0 |
If avoid_repeats is False, delegates extend() to the list. Otherwise, appends all items that don't create a repeat of 2 items to the list. | def extend(self, other_list:list, avoid_repeats:bool=False):
if not avoid_repeats:
self.list.extend(other_list)
else:
for item in other_list:
if not self.list or not self.list[-1] == item:
self.list.append(item) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extend(self, items):\n\t\tfor item in items:\n\t\t\tself.append(item)",
"def extend(self, item: Any) -> BaseList:\n super().extend(item)\n return self",
"def _maybe_repeat(self, x):\n if isinstance(x, list):\n assert len(x) == self.n\n return x\n else:\n ... | [
"0.62498456",
"0.58820844",
"0.57340544",
"0.5694424",
"0.56086457",
"0.5561484",
"0.5498792",
"0.5492445",
"0.54523814",
"0.5431818",
"0.5429031",
"0.5411647",
"0.540451",
"0.5382095",
"0.53687876",
"0.5337805",
"0.53252906",
"0.53235775",
"0.5305681",
"0.52904165",
"0.52875... | 0.7816751 | 0 |
Reverses the portion of the list between start and end indexes, inclusive. | def reverse(self, start:int=0, end:int=None):
if end == None:
if start == 0:
self.list.reverse()
return
end = len(self) - 1
left = start
right = end
while left < right:
self.swap(left, right)
left += 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rev_list_in_place(lst):\n\n for i in range(len(lst)//2):\n start = lst[i] #0, 1\n end = lst[-i-1] #-1, -2\n\n lst[i] = end\n lst[-i-1] = start\n return lst",
"def reverse_(data, start, stop):\n if start >= stop:\n return\n else:\n tmp = data[start]\n ... | [
"0.75801146",
"0.7426304",
"0.73637533",
"0.72495973",
"0.69379836",
"0.6891903",
"0.6763126",
"0.6715727",
"0.66684985",
"0.6529971",
"0.65189874",
"0.651104",
"0.6492778",
"0.6492647",
"0.6479766",
"0.6479766",
"0.6469574",
"0.6395415",
"0.6336724",
"0.6288921",
"0.62816465... | 0.8482028 | 0 |
Swaps two items in the list. | def swap(self, index_a:int, index_b:int):
if not index_a == index_b:
self.list[index_a], self.list[index_b] = self.list[index_b], self.list[index_a] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _swap(mylist, a, b):\n temp = mylist[a]\n mylist[a] = mylist[b]\n mylist[b] = temp",
"def swap(self, Items, First, Second):\n temp = Items[First]\n Items[First] = Items[Second]\n Items[Second] = temp",
"def swap(in_list: List, index1: int, index2: int) -> List:\n\n in_list[... | [
"0.7930183",
"0.7715602",
"0.7709364",
"0.7709118",
"0.7595853",
"0.7516776",
"0.7483115",
"0.7400099",
"0.73172927",
"0.7073496",
"0.7073496",
"0.70282924",
"0.7027543",
"0.70188946",
"0.69999826",
"0.6980183",
"0.69697773",
"0.6963989",
"0.69568324",
"0.6934204",
"0.6915152... | 0.752669 | 5 |
Determines the minimum and maximum values for any particular tuple index within the list. Returns | def ranges(self, keys:list)->list:
if not isinstance(keys, list):
keys = [keys]
ranges = {}
for key in keys:
ranges[key] = [None, None]
for list_item in self.list:
for key in keys:
if ranges[key][0] is None:
ranges[k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_minmax(self, stmt, slist):\n minel = maxel = None\n for s in slist:\n if s.keyword == \"min-elements\":\n minel = s.arg\n elif s.keyword == \"max-elements\":\n maxel = s.arg\n if minel is None:\n minst = stmt.search_one(\"m... | [
"0.7201116",
"0.7053451",
"0.7039965",
"0.6910799",
"0.6879111",
"0.6841572",
"0.68235934",
"0.6786338",
"0.67859083",
"0.67341435",
"0.67099017",
"0.6705208",
"0.6695408",
"0.66835827",
"0.6665411",
"0.6641725",
"0.6620347",
"0.6598788",
"0.6563562",
"0.6549405",
"0.65433556... | 0.0 | -1 |
A generator that filters through the tuples under specific conditions that can be specified. | def filter(self, filters:list)->list:
for item in self.list:
use_item = True
for filter in filters:
filter_key, filter_value, filter_type = filter
if filter_type == "<" and item[filter_key] >= filter_value:
use_item = False
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combination2_with_pruning(items: Sequence[U], condition: Callable[[U, U], bool]) -> Iterator[Tuple[U, U]]:\n for i in range(len(items) - 1):\n item1 = items[i]\n if not condition(item1, item1):\n break\n for j in range(i + 1, len(items)):\n item2 = items[j]\n ... | [
"0.6575245",
"0.6373978",
"0.6246004",
"0.62212527",
"0.6165847",
"0.6111315",
"0.6110025",
"0.60950655",
"0.6079471",
"0.6078307",
"0.6066584",
"0.60238826",
"0.6008566",
"0.59748495",
"0.5969665",
"0.57931423",
"0.5792632",
"0.57537127",
"0.57456875",
"0.57093096",
"0.57049... | 0.64063805 | 1 |
Quicksorts the list by outside_key, then divides the list by stable blocks of outside_key and quicksorts those blocks by inner_key. Essentially equivalent to SQL statement of SORT BY outside_key, inner_key. | def double_sort(self, outside_key:int, inner_key:int, start:int=0, end:int=None, reverse_outside:bool=False, reverse_inside:bool=False):
self.quicksort(outside_key, start, end)
if reverse_outside:
self.reverse(start, end)
self.sub_quicksort(outside_key, inner_key, start, end, reverse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quick_sort(partition_list, low, high):\n if low >= high:\n return\n part_point = get_partition(partition_list, low, high)\n quick_sort(partition_list, low, part_point - 1)\n quick_sort(partition_list, part_point + 1, high)",
"def sub_quicksort(self, stable_key:int, sort_key:int, start:int=... | [
"0.64460015",
"0.6355268",
"0.63343626",
"0.61252177",
"0.61231464",
"0.60208863",
"0.59688854",
"0.59314775",
"0.59294957",
"0.5915863",
"0.58827007",
"0.58791566",
"0.5866802",
"0.58583575",
"0.58298904",
"0.58237565",
"0.5819016",
"0.57973635",
"0.579664",
"0.57711905",
"0... | 0.70455134 | 0 |
Quicksorts subsets of the list grouped by a stable key. Inplace, nonrecursive. This function maintains the order of blocks of tuples having the same stable_key. Within that block, items are resorted by sort_key using quicksort(). Since quicksort() is ascending, specifying reverse = True will reverse the order within th... | def sub_quicksort(self, stable_key:int, sort_key:int, start:int=0, end:bool=None, reverse:bool=False):
if end == None:
end = len(self) - 1
if start >= end:
return
first = start
for index in range(start + 1, end + 1):
if not self[index][stable_key] ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quicksort(self, key:int, start:int=0, end:int=None):\n if end == None:\n end = len(self) - 1\n if start >= end:\n return\n if start == end - 1:\n if self[start][key] > self[end][key]:\n self.swap(start, end)\n return\n work ... | [
"0.6481071",
"0.6124734",
"0.61035883",
"0.5960609",
"0.5938006",
"0.59239113",
"0.5895712",
"0.58804065",
"0.58605987",
"0.5831882",
"0.578833",
"0.5766656",
"0.5744841",
"0.5650269",
"0.5648659",
"0.56472456",
"0.56437397",
"0.56407726",
"0.56317866",
"0.56163543",
"0.56089... | 0.7287639 | 0 |
A nonrecursive, inplace version of quicksort. Note that Python has notgreat tailrecursion properties, so a recursive approach is not generally recommended. This is inplace to save on memory. Otherwise, it is a straightforward ascending quicksort of all the items between start and end indexes comparing the values in the... | def quicksort(self, key:int, start:int=0, end:int=None):
if end == None:
end = len(self) - 1
if start >= end:
return
if start == end - 1:
if self[start][key] > self[end][key]:
self.swap(start, end)
return
work = [(start, end... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _quick_sort(l, start, end):\n if start < end:\n split_point = partition(l, start, end)\n\n _quick_sort(l, start, split_point - 1)\n _quick_sort(l, split_point + 1, end)\n\n return l",
"def quick_sort(items, low=None, high=None):\r\n # TODO: Check if high and low range bounds hav... | [
"0.8193505",
"0.77273595",
"0.76876134",
"0.76642364",
"0.76446205",
"0.76436085",
"0.7545366",
"0.7532147",
"0.748278",
"0.7454062",
"0.74537796",
"0.7445257",
"0.7441872",
"0.73965734",
"0.73959565",
"0.7365618",
"0.7348234",
"0.7309217",
"0.72909856",
"0.72894216",
"0.7279... | 0.83892685 | 0 |
Determines if three points are collinear. | def collinear(a:tuple, b:tuple, c:tuple)->bool:
return ((b[1] - c[1]) * (a[0] - b[0])) == ((a[1] - b[1]) * (b[0] - c[0])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hasCollinearPoints(listOfPoints):\r\n for points in listOfPoints:\r\n if isCollinear(points[0], points[1], points[2]): #If any of the points are collinear\r\n return True\r\n else:\r\n pass\r\n return False #If none of the points are collinear\r",
"def isCollinear(a,... | [
"0.8034161",
"0.8013386",
"0.7425963",
"0.7253228",
"0.71570814",
"0.68248564",
"0.68098545",
"0.6768294",
"0.659053",
"0.63671917",
"0.6239227",
"0.58782095",
"0.58510786",
"0.58257973",
"0.5767872",
"0.57624406",
"0.56998944",
"0.5678307",
"0.56526023",
"0.56410754",
"0.554... | 0.722665 | 4 |
Determines whether the lines AB and BC make a counterclockwise or clockwise turn. | def direction(a:tuple, b:tuple, c:tuple)->int:
return ((b[1] - a[1]) * (c[0] - b[0])) - ((b[0] - a[0]) * (c[1] - b[1])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isclockwise(self):\n s = sum((seg[1][0] - seg[0][0]) * (seg[1][1] + seg[0][1])\n for seg in self.segment_tuples)\n return s > 0",
"def is_ccw(point_a, point_b, point_c):\r\n return is_on_line(point_a, point_b, point_c) > 0",
"def is_clockwise(vertices):\n v = vert... | [
"0.74345213",
"0.7050063",
"0.6938256",
"0.6867639",
"0.67281264",
"0.6570195",
"0.65248144",
"0.6483469",
"0.6362939",
"0.6355596",
"0.6348816",
"0.6348816",
"0.6196705",
"0.60618496",
"0.60286784",
"0.5938162",
"0.5816794",
"0.57985514",
"0.5764117",
"0.57534015",
"0.575023... | 0.0 | -1 |
Determine if CCW (1), CW(1), or colinear(0) | def orientation(a:tuple, b:tuple, c:tuple)->int:
d = direction(a, b, c)
if d == 0:
return 0
elif d > 0:
return 1
else:
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_ccw(points):\n points = np.asanyarray(points, dtype=np.float64)\n\n if (len(points.shape) != 2 or\n points.shape[1] != 2):\n raise ValueError('CCW is only defined for 2D')\n xd = np.diff(points[:, 0])\n yd = np.column_stack((\n points[:, 1],\n points[:, 1])).resha... | [
"0.6975806",
"0.66116494",
"0.6606028",
"0.65576446",
"0.6379163",
"0.6352987",
"0.6342742",
"0.625941",
"0.6167342",
"0.61235267",
"0.60807854",
"0.6079656",
"0.6001425",
"0.59949446",
"0.58525217",
"0.57770985",
"0.57654357",
"0.573804",
"0.5721898",
"0.57122684",
"0.571094... | 0.0 | -1 |
Determines if the slope of a line is positive. | def positive_slope(line:tuple)->bool:
return line[0][1] < line[1][1] == line[0][0] < line[1][0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_slope(self):\n\t\tif self.high_elevation != self.low_elevation:\n\t\t\treturn True\n\t\treturn False",
"def slope(self):\n if self.b == 0:\n return None\n else:\n return (-1) * self.a/self.b",
"def filter_slope(self,slope):\n if self.slope_interval[0] <= abs(sl... | [
"0.736785",
"0.67845374",
"0.66309035",
"0.6547908",
"0.64874506",
"0.6483003",
"0.6478444",
"0.63426495",
"0.63259435",
"0.6320206",
"0.62273353",
"0.6205177",
"0.6158633",
"0.613933",
"0.61122525",
"0.6104726",
"0.6096476",
"0.6087337",
"0.6063536",
"0.6063536",
"0.59833056... | 0.83179325 | 0 |
Determines if a line moves up from left to right. | def is_upwards(line:tuple)->bool:
return line[1][1] > line[0][1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _move_up(self) -> bool:\n current_agent_node = self._maze.get_player_node()\n\n if current_agent_node.y == 0:\n # Can't go up. Already on the top row\n return False\n else:\n next_node = self._maze.get_node_up(current_agent_node)\n return self._h... | [
"0.70861965",
"0.6750818",
"0.6675489",
"0.6598131",
"0.65929246",
"0.6382831",
"0.6267976",
"0.6258866",
"0.618461",
"0.6151891",
"0.61254895",
"0.61195827",
"0.60737306",
"0.6071918",
"0.6045149",
"0.60422784",
"0.6026788",
"0.60164386",
"0.60142016",
"0.59950626",
"0.59940... | 0.7699524 | 0 |
Determines if a line is horizontal. | def is_horizontal(line:tuple)->bool:
return line[0][1] == line[1][1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_horizontal(self):\n return self.start.x == self.end.x",
"def _isLine(self):\n return (self.width == 0 and self.height > 1) or (self.height == 0 and self.width > 1)",
"def _isLine(self):\n return (self.width == 0 and self.height > 1) or (self.height == 0 and self.width > 1)",
"def ... | [
"0.7609686",
"0.72768867",
"0.72768867",
"0.6881701",
"0.68597597",
"0.6499938",
"0.6489282",
"0.64614856",
"0.63482904",
"0.63324815",
"0.6304397",
"0.6304397",
"0.61203885",
"0.61043155",
"0.6032632",
"0.6023981",
"0.6008056",
"0.59356326",
"0.5913236",
"0.59085",
"0.590548... | 0.80236757 | 0 |
Determines the length and the cosine of the angle from a positive horizontal ray of a line segment. | def line_length_angle(line:tuple)->tuple:
squared_dist = point_sqr_distance(line[0], line[1])
if squared_dist == 0:
return 0,1
distance = math.sqrt(squared_dist)
angle_cosine = (line[1][0] - line[0][0]) / distance
return squared_dist, angle_cosine | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def determine_angle_slope(line, ax):\n x, y = line.get_data()\n\n sp1 = ax.transData.transform_point((x[0],y[0]))\n sp2 = ax.transData.transform_point((x[-1],y[-1]))\n\n rise = (sp2[1] - sp1[1])\n run = (sp2[0] - sp1[0])\n\n return degrees(atan(rise/run))",
"def get_angle(vert1, vert2):\n ... | [
"0.6568259",
"0.6058625",
"0.6033344",
"0.6004007",
"0.59449476",
"0.5929289",
"0.5880977",
"0.5880165",
"0.5810554",
"0.5711322",
"0.5710918",
"0.57101655",
"0.5706915",
"0.57055837",
"0.5633181",
"0.56073636",
"0.5591553",
"0.55895156",
"0.5588889",
"0.5581489",
"0.557368",... | 0.7148612 | 0 |
Takes a sequential list of vertices and turns it into a list of edges. | def edgify(vertices:list)->list:
edges = []
for k in range(0, len(vertices) - 1):
edges.append([vertices[k], vertices[k + 1]])
return edges | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_edges(graph):\n return list(zip(graph[:-1], graph[1:]))",
"def incoming_edges(self, vertices, labels=True):\n return list(self.incoming_edge_iterator(vertices, labels=labels))",
"def getEdges(self):\n edgeList = []\n for v in self.adjList:\n for i in range(len(self.adj... | [
"0.74463135",
"0.6988424",
"0.6973376",
"0.69115984",
"0.69084823",
"0.6798895",
"0.6756665",
"0.67535317",
"0.67494607",
"0.6699782",
"0.66954184",
"0.66598827",
"0.6621105",
"0.6606147",
"0.65837735",
"0.6566445",
"0.650843",
"0.64819276",
"0.64663",
"0.6394724",
"0.6387192... | 0.83298373 | 0 |
Determines the closest point on the infinite line associated with the edge to the given point. The closest point on an infinite line to a point is determined by the intersection of that line (y=mx+b) and a perpendicular line through the | def closest_line_point(point:tuple, edge:tuple)->tuple:
d_y, d_x, b = line_equation((edge[0], edge[1]))
if b == None:
# The line is vertical, need different intercept formula.
return (edge[0][0], point[1])
if d_y == 0:
# The line is horizontal, we can use a faster formula:
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _nearest_point_on_line(begin, end, point):\n b2e = _vec_sub(end, begin)\n b2p = _vec_sub(point, begin)\n nom = _vec_dot(b2p, b2e)\n denom = _vec_dot(b2e, b2e)\n if denom == 0.0:\n return begin\n u = nom / denom\n if u <= 0.0:\n return begin\n elif u >= 1.0:\n return... | [
"0.7810633",
"0.7691588",
"0.7173058",
"0.71486485",
"0.7119254",
"0.7044393",
"0.69271195",
"0.69156563",
"0.6865664",
"0.68619066",
"0.6846239",
"0.68359554",
"0.67854995",
"0.67513555",
"0.67275",
"0.6722305",
"0.66625106",
"0.66622204",
"0.6593246",
"0.6526185",
"0.651947... | 0.7811466 | 0 |
Finds the squared distance between two points. | def point_sqr_distance(point_a:tuple, point_b:tuple)->float:
return (point_b[1]-point_a[1]) ** 2 + (point_b[0] - point_a[0]) ** 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def squaredDistanceTo(self,other):\n if not isinstance(other,Point):\n return \n return (self.longitude - other.getLongitude())**2 +(self.latitude - other.getLatitude())**2",
"def squaredDistance(vec1, vec2):\n return (distance.euclidean(vec1, vec2))**2",
"def squared_distance_calcu... | [
"0.82655483",
"0.81889415",
"0.791692",
"0.791373",
"0.78632396",
"0.7853447",
"0.7808227",
"0.77813464",
"0.7705553",
"0.7671689",
"0.75951076",
"0.75789213",
"0.7487794",
"0.7485779",
"0.74844944",
"0.74210185",
"0.7417538",
"0.7416423",
"0.7406129",
"0.74054956",
"0.740249... | 0.795891 | 2 |
Checks if a value is between two boundary values | def between(check:float, boundary_1:float, boundary_2:float)->bool:
if boundary_1 > boundary_2:
boundary_1, boundary_2 = boundary_2, boundary_1
return boundary_1 <= check and check <= boundary_2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_if_between(a, b, test_val):\n if a < b:\n return a <= test_val <= b\n else:\n return b <= test_val <= a",
"def within_value(v1, v2):\n percentage = 0.1\n error_allowed = percentage * v1\n high = v1 + error_allowed\n low = v1 - error_allowed\n\n return low <= v2 <= high... | [
"0.753235",
"0.74662626",
"0.74073505",
"0.74048406",
"0.73218316",
"0.72808284",
"0.72025293",
"0.7180609",
"0.717863",
"0.7134316",
"0.71139634",
"0.7110848",
"0.7095863",
"0.70765793",
"0.7074509",
"0.7058017",
"0.70498204",
"0.702181",
"0.7013493",
"0.7001683",
"0.6988135... | 0.82189065 | 0 |
Checks if a point is within the rectangle with edge as one of the diagonals. | def near_segment(point:tuple, edge:tuple)->bool:
return between(point[0], edge[0][0], edge[1][0]) and between(point[1], edge[0][1], edge[1][1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inside(point, rectangle):\n\n ll = rectangle.getP1() # assume p1 is ll (lower left)\n ur = rectangle.getP2() # assume p2 is ur (upper right)\n\n return ll.getX() < point.getX() < ur.getX() and ll.getY() < point.getY() < ur.getY()",
"def in_square(self, point):\n size = self.size\n centre =... | [
"0.70133144",
"0.69797367",
"0.6935007",
"0.69121915",
"0.687569",
"0.687569",
"0.6854568",
"0.6748199",
"0.67210734",
"0.6670797",
"0.6650344",
"0.66328245",
"0.6617512",
"0.6605541",
"0.6605422",
"0.65742147",
"0.6531653",
"0.6525218",
"0.65238535",
"0.6522948",
"0.6522948"... | 0.70146877 | 0 |
Dot product of two vectors. | def dot_product(vec_1:tuple, vec_2:tuple)->float:
return vec_1[0] * vec_2[0] + vec_1[1] * vec_2[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dot(a, b):\n\n if len(a) != len(b):\n raise Exception(\"Input vectors must be of same length, not %d and %d\" % (len(a), len(b)))\n\n return float(sum([a[i] * b[i] for i in range(len(a))]))",
"def vec_dot(v1,v2):\r\n \r\n return np.dot(v1,v2)",
"def vector_dot(v1,v2):\n re... | [
"0.87841845",
"0.86563873",
"0.8642669",
"0.86284196",
"0.86162174",
"0.8601663",
"0.85943055",
"0.85549754",
"0.8492725",
"0.84826726",
"0.84747356",
"0.843237",
"0.8408973",
"0.8401954",
"0.8375448",
"0.8345248",
"0.8324872",
"0.83216214",
"0.8315376",
"0.82187545",
"0.8203... | 0.8244592 | 19 |
Magnitude of a vector. | def magnitude(vector:tuple)->float:
return math.sqrt(vector[0] ** 2 + vector[1] ** 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def magnitude(v: Vector) -> float:\n return math.sqrt(sum_of_squares(v))",
"def magnitude_of_vector(v):\n return math.sqrt(sum_of_squares(v))",
"def magnitude(vector):\n return math.sqrt(sum_of_squares(vector))",
"def magnitude(v: Vector) -> float:\n return math.sqrt(sum_of_squares(v)) #math.sqrt... | [
"0.82161707",
"0.82127446",
"0.8133831",
"0.80984265",
"0.80711746",
"0.7985293",
"0.7820759",
"0.77244526",
"0.77204585",
"0.76303875",
"0.7613427",
"0.744135",
"0.7276982",
"0.72540486",
"0.703484",
"0.7024954",
"0.6985379",
"0.6943243",
"0.690651",
"0.6875509",
"0.68388605... | 0.75406647 | 11 |
Returns true if the vector is a zero vector, otherwise false. | def is_zero_vector(vector:tuple)->bool:
return vector[0] == 0 and vector[1] == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isVecZero(vec):\n trues = [isZero(e) for e in vec]\n return all(trues)",
"def is_zero(self):\n for t in self:\n if t != TRIT_ZERO:\n return False\n return True",
"def isZero(self):\n return self.count == 0",
"def is_zero(self):\n return self._ex... | [
"0.8560863",
"0.78165585",
"0.7557371",
"0.753894",
"0.74890184",
"0.7482657",
"0.7468545",
"0.74608725",
"0.745997",
"0.7423766",
"0.74129486",
"0.741105",
"0.7316494",
"0.7311554",
"0.7263635",
"0.70921254",
"0.7089508",
"0.707456",
"0.7040816",
"0.7008552",
"0.69950205",
... | 0.8220028 | 1 |
Cosine of the angle between two vectors. | def vector_cosine_angle(vec_1:tuple, vec_2:tuple)->float:
if is_zero_vector(vec_1) or is_zero_vector(vec_2):
return None
return dot_product(vec_1, vec_2) / (magnitude(vec_1) * magnitude(vec_2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_angle(v1, v2):\n return np.arccos(np.dot(v1, v2))",
"def vector_angle(v1, v2):\n cos_theta = np.dot(v1, v2) / np.linalg.norm(v1) / np.linalg.norm(v2)\n # Clip ensures that cos_theta is within -1 to 1 by rounding say -1.000001 to -1 to fix numerical issues\n angle = np.arccos(np.clip(cos_theta... | [
"0.79781234",
"0.7976167",
"0.79292333",
"0.78854567",
"0.7846663",
"0.78060514",
"0.7798603",
"0.77573013",
"0.7631926",
"0.75654876",
"0.75654525",
"0.7498042",
"0.7497748",
"0.74709314",
"0.7419905",
"0.7411108",
"0.7391557",
"0.7389358",
"0.7339487",
"0.733513",
"0.733068... | 0.7941511 | 2 |
Creates the vector AB from two points. | def vectorize(point_a:tuple, point_b:tuple)->tuple:
return (point_b[0] - point_a[0], point_b[1] - point_a[1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_vector(point_1, point_2):\n return tuple([point_2[0] - point_1[0], point_2[1] - point_1[1]])",
"def vect_creator(point_a, point_b):\n vect = np.subtract(point_a, point_b)\n return vect",
"def createFromTwoPoints(cls, point1, point2, **kwargs):\n vector = Vector.createFromTwoPoints(po... | [
"0.7281753",
"0.7070874",
"0.69608176",
"0.6948325",
"0.66352683",
"0.6487098",
"0.64270216",
"0.6421415",
"0.63846457",
"0.6211581",
"0.61877364",
"0.6004896",
"0.5995361",
"0.5992514",
"0.5986906",
"0.59169644",
"0.5908373",
"0.5893852",
"0.58929795",
"0.58849037",
"0.58823... | 0.6231298 | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.