query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Return a Matplotlib Axes array to be used in all visualizations in the notebook. Provide a central point to control graph sizes. Adjust the size attribute to control how big to render images | def get_ax(rows=1, cols=1, size=16):
_, ax = plt.subplots(rows, cols, figsize=(size * cols, size * rows))
return ax | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ax(rows=1, cols=1, size=16):\n _, ax = plt.subplots(rows, cols, figsize=(size*cols, size*rows))\n return ax",
"def get_ax(rows=1, cols=1, size=16):\n _, ax = plt.subplots(rows, cols, figsize=(size*cols, size*rows))\n return ax",
"def get_ax(rows=1, cols=1, size=8):\r\n _, ax = plt.subplo... | [
"0.6995708",
"0.6995708",
"0.69909465",
"0.6967519",
"0.69618386",
"0.69150853",
"0.69150853",
"0.6912052",
"0.6782566",
"0.6779475",
"0.63615865",
"0.63033676",
"0.62792975",
"0.62403536",
"0.6224871",
"0.6140819",
"0.6097152",
"0.60868704",
"0.604939",
"0.6045033",
"0.60368... | 0.69959086 | 0 |
open sql file and read result to pandas dataframe | def read_sql_from_file(path, conn):
with open(path, 'r', encoding='utf-8') as f:
qu = f.read()
df = read_sql(qu, conn)
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query(self, sql):\n df = pd.read_sql(sql, self.conn)\n return df",
"def query_to_df(db, sql):\n conn_string = return_connection(db)\n with pg2.connect(conn_string) as conn:\n return psql.read_sql(sql, conn)",
"def read_sql_query(sql: str, con: RdsDataApi, database: Optional[str] ... | [
"0.7578803",
"0.7521947",
"0.7340611",
"0.73007333",
"0.71697307",
"0.7145733",
"0.7115768",
"0.7113902",
"0.71017885",
"0.70614535",
"0.7037162",
"0.7007734",
"0.6967868",
"0.69536024",
"0.6907001",
"0.69034314",
"0.6900759",
"0.6888985",
"0.6885968",
"0.6831431",
"0.6822827... | 0.7833117 | 0 |
for current target and dataframe (pre_clust_df) transform all features to woe buckets and learn model | def full_modeling(target, pre_clust_df, model_path, id_column):
targets = [x for x in pre_clust_df.columns if x[:8] == 'default_']
# folders for result saving
folder_auc = model_path + '/pictures/roc_auc'
folder_column_pics = model_path + '/pictures'
folder_model_output = model_path + '/model_output... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess_feature(df):",
"def transform_train_data(df):\n return df.rdd.map(\n lambda x: (\n Vectors.dense([x.amount, x.split, x.maintain4, x.maintain12]),\n x.intime\n )\n ).toDF([\"features\", \"label\"])",
"def cluster_by_split(filtered_df):\n global feature... | [
"0.6235735",
"0.6067175",
"0.6045808",
"0.6000694",
"0.5986487",
"0.5972561",
"0.59375983",
"0.5912315",
"0.590315",
"0.5823235",
"0.58231467",
"0.58022463",
"0.5763611",
"0.57518566",
"0.57234585",
"0.57188344",
"0.57007515",
"0.569017",
"0.5686344",
"0.56673455",
"0.561648"... | 0.6397659 | 0 |
Generate GradCAM at different layers of ResNet152 | def demo2(image_paths, output_dir, cuda):
device = get_device(cuda)
# Synset words
classes = get_classtable()
# Model
model = models.resnet152(pretrained=True)
model.to(device)
model.eval()
# The four residual layers
target_layers = ["relu", "layer1", "layer2", "layer3", "layer4"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grad_cam_batch(input_model, images, classes, layer_name):\n loss = tf.gather_nd(input_model.output, np.dstack([range(images.shape[0]), classes])[0])\n layer_output = input_model.get_layer(layer_name).output\n grads = K.gradients(loss, layer_output)[0]\n gradient_fn = K.function([input_model.input, ... | [
"0.7020831",
"0.6723679",
"0.66918373",
"0.6514261",
"0.65074456",
"0.6171934",
"0.615975",
"0.6125562",
"0.61211646",
"0.6104127",
"0.60718155",
"0.6071536",
"0.6047656",
"0.6044598",
"0.60417295",
"0.6018157",
"0.6011776",
"0.6005091",
"0.5952455",
"0.59439194",
"0.5914834"... | 0.748433 | 0 |
Loads the existing OpenStack Keypair | def initialize(self):
super(self.__class__, self).initialize()
try:
self.__keypair = nova_utils.get_keypair_by_name(
self._nova, self.keypair_settings.name)
return self.__keypair
except Exception as e:
logger.warn('Cannot load existing keypair... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_key():",
"def load_key():\n return open(\"Secret.key\",\"rb\").read()",
"def create(self):\n self.initialize()\n\n if not self.__keypair:\n logger.info('Creating keypair %s...' % self.keypair_settings.name)\n\n if self.keypair_settings.public_filepath and os.path... | [
"0.7189895",
"0.6517558",
"0.648187",
"0.64195603",
"0.64188176",
"0.64004326",
"0.6370742",
"0.6292563",
"0.62764764",
"0.6230832",
"0.6219282",
"0.62125903",
"0.6180529",
"0.60919774",
"0.6073888",
"0.6063422",
"0.60568666",
"0.59565926",
"0.5932089",
"0.5882537",
"0.587159... | 0.7845108 | 0 |
Responsible for creating the keypair object. | def create(self):
self.initialize()
if not self.__keypair:
logger.info('Creating keypair %s...' % self.keypair_settings.name)
if self.keypair_settings.public_filepath and os.path.isfile(
self.keypair_settings.public_filepath):
logger.info("Up... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_keypair(self, username):\n msg = \"create_keypair not implemented\"\n raise NotImplementedError(msg)",
"def create_key_pair(self) -> Keypair:\n res = self.context.post(\n \"/dsum/create_key_pair\", None, None, \"DSum: failed creating a Curve 25519 Keypair\")\n re... | [
"0.80888253",
"0.78946847",
"0.76902384",
"0.7655257",
"0.75913066",
"0.7544867",
"0.7514757",
"0.747879",
"0.74046516",
"0.72713006",
"0.7267716",
"0.7267246",
"0.72401583",
"0.6886206",
"0.685062",
"0.6836581",
"0.67714626",
"0.666824",
"0.6648626",
"0.663982",
"0.6611549",... | 0.8068847 | 1 |
Returns the OpenStack keypair object | def get_keypair(self):
return self.__keypair | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, name):\n path = '/os-keypairs/%s' % name\n res = self.client.call(path, 'GET', data='', \n token=self.manager.identity.token)\n self.logger.debug('Get openstack key pair %s: %s' % (name, truncate(res)))\n return res[0]['keypair']",
"def init... | [
"0.74607193",
"0.71862775",
"0.71742755",
"0.7043159",
"0.6730009",
"0.6715334",
"0.6648596",
"0.66434497",
"0.6613817",
"0.6516933",
"0.6420968",
"0.6287733",
"0.6248867",
"0.6180987",
"0.612444",
"0.6101417",
"0.60537064",
"0.60257906",
"0.60006696",
"0.5963234",
"0.5896387... | 0.7459602 | 1 |
Sets the last_modification of this AdditionalInfoResponseTimestamps. | def last_modification(self, last_modification):
self._last_modification = last_modification | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_modified(self, last_modified):\n\n self._last_modified = last_modified",
"def last_modified_dts(self, last_modified_dts):\n\n self._last_modified_dts = last_modified_dts",
"def last_updated(self, last_updated):\n\n self._last_updated = last_updated",
"def last_updated(self, last... | [
"0.72340417",
"0.68768615",
"0.6674735",
"0.6674735",
"0.6674735",
"0.6674735",
"0.6600833",
"0.6493505",
"0.63677263",
"0.63109577",
"0.6299651",
"0.6257775",
"0.6257775",
"0.6247048",
"0.6247048",
"0.6176834",
"0.6173237",
"0.6095075",
"0.6063976",
"0.5996479",
"0.5996479",... | 0.79767364 | 0 |
Sets the availability of this AdditionalInfoResponseTimestamps. | def availability(self, availability):
self._availability = availability | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_available(self):\n self._available = True\n self._timeout_stamp = datetime.now()",
"def set_availability(self, available: bool) -> None:\n self._attr_available = available\n self.schedule_update_ha_state()",
"def set_availability(self, available: bool) -> None:\n self... | [
"0.63755864",
"0.6079537",
"0.6079537",
"0.59843475",
"0.5740844",
"0.5688291",
"0.56257373",
"0.5434451",
"0.5280206",
"0.52409625",
"0.5186938",
"0.51610863",
"0.5156062",
"0.51475394",
"0.5111984",
"0.50719017",
"0.50218046",
"0.4982686",
"0.49308842",
"0.49190474",
"0.491... | 0.67319524 | 0 |
Sets the validity of this AdditionalInfoResponseTimestamps. | def validity(self, validity):
self._validity = validity | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validity(self, validity):\n if self.local_vars_configuration.client_side_validation and validity is None: # noqa: E501\n raise ValueError(\"Invalid value for `validity`, must not be `None`\") # noqa: E501\n\n self._validity = validity",
"def setValid(self):\n self.valid = Tr... | [
"0.5790018",
"0.5446713",
"0.539757",
"0.5382739",
"0.5382739",
"0.5377016",
"0.5358312",
"0.5197369",
"0.50806177",
"0.50763357",
"0.4945376",
"0.49413902",
"0.49362656",
"0.48737335",
"0.4814998",
"0.4814998",
"0.48023972",
"0.47987747",
"0.4789244",
"0.4780952",
"0.4763620... | 0.6337611 | 0 |
Initialize LSH algorithm with a hashing functor, descriptor index and hash nearestneighbor index. In order to provide outofthebox neighbor querying ability, at least the ``descriptor_index`` and ``hash2uuids_kvstore`` must be provided. The UIDs of descriptors in the ``descriptor_index`` should be fully mapped by the ke... | def __init__(self, lsh_functor, descriptor_index, hash2uuids_kvstore,
hash_index=None,
distance_method='cosine', read_only=False):
super(LSHNearestNeighborIndex, self).__init__()
# TODO(paul.tunison): Add in-memory empty defaults for
# descriptor_index/hash2u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _new_lsh_index(self):\n minhashes = {}\n lsh = MinHashLSH(self._config.threshold, self._config.num_perm)\n\n # Event generator for streaming Elasticsearch results.\n events = self._datastore.search_stream(\n query_string=self._config.query,\n query_filter={},\n... | [
"0.6456378",
"0.60631484",
"0.5868888",
"0.5725651",
"0.5480085",
"0.54548675",
"0.5306687",
"0.5269298",
"0.5245594",
"0.5240167",
"0.5228141",
"0.5226449",
"0.52048737",
"0.51841885",
"0.51767963",
"0.51213276",
"0.5079123",
"0.5058296",
"0.5052293",
"0.5040301",
"0.5032952... | 0.8218425 | 0 |
Internal method to be implemented by subclasses to build the index with the given descriptor data elements. Subsequent calls to this method should rebuild the current index. This method shall not add to the existing index nor raise an exception to as to protect the current index. | def _build_index(self, descriptors):
with self._model_lock:
if self.read_only:
raise ReadOnlyError("Cannot modify container attributes due to "
"being in read-only mode.")
self._log.debug("Clearing and adding new descriptor elements")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_index(self):\n self.rebuild_index()",
"def build_index():\n pass",
"def _update_index(self, descriptors):\n with self._model_lock:\n if self.read_only:\n raise ReadOnlyError(\"Cannot modify container attributes due \"\n \"t... | [
"0.72547895",
"0.6932546",
"0.6901113",
"0.65515655",
"0.6488637",
"0.63804775",
"0.63155717",
"0.6282419",
"0.6277858",
"0.6277478",
"0.61938465",
"0.6155492",
"0.6088519",
"0.6073517",
"0.60093737",
"0.6001238",
"0.59837264",
"0.5975098",
"0.5934633",
"0.592091",
"0.5897822... | 0.76118064 | 0 |
Internal method to be implemented by subclasses to additively update the current index with the one or more descriptor elements given. If no index exists yet, a new one should be created using the given descriptors. | def _update_index(self, descriptors):
with self._model_lock:
if self.read_only:
raise ReadOnlyError("Cannot modify container attributes due "
"to being in read-only mode.")
# tee out iterable for use in adding to index as well as hash c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_index(self, descriptors):\n with self._model_lock:\n if self.read_only:\n raise ReadOnlyError(\"Cannot modify container attributes due to \"\n \"being in read-only mode.\")\n\n self._log.debug(\"Clearing and adding new descri... | [
"0.7290595",
"0.5932061",
"0.58223623",
"0.5640807",
"0.56363523",
"0.56255984",
"0.55559283",
"0.5552263",
"0.55315506",
"0.55315506",
"0.5506679",
"0.54696727",
"0.5453186",
"0.5447808",
"0.54461026",
"0.54410577",
"0.54367346",
"0.54315275",
"0.54052234",
"0.54015446",
"0.... | 0.83484805 | 0 |
Remove descriptors from this index associated with the given UIDs. | def _remove_from_index(self, uids):
with self._model_lock:
if self.read_only:
raise ReadOnlyError("Cannot modify container attributes due "
"to being in read-only mode.")
uids = list(uids)
# Remove UIDs from our hash2uid-k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_descriptor(self, uuid):\n self.remove_many_descriptors([uuid])",
"def remove_many_descriptors(self, uuids):",
"def remove_descriptor(self, uuid):",
"def remove_many_descriptors(self, uuids):\n # Chunk up operation based on max clauses available to us\n\n def batch_op(_batch):\... | [
"0.70615095",
"0.704063",
"0.6577618",
"0.63564056",
"0.5699009",
"0.56984663",
"0.5652547",
"0.5646998",
"0.5586256",
"0.5575667",
"0.55703604",
"0.55475426",
"0.5403445",
"0.53883266",
"0.5363939",
"0.5342305",
"0.53421175",
"0.533988",
"0.5328503",
"0.52953845",
"0.5286483... | 0.83948106 | 0 |
Internal method to be implemented by subclasses to return the nearest `N` neighbors to the given descriptor element. When this internal method is called, we have already checked that there is a vector in ``d`` and our index is not empty. | def _nn(self, d, n=1):
self._log.debug("generating hash for descriptor")
d_v = d.vector()
d_h = self.lsh_functor.get_hash(d_v)
def comp_descr_dist(d2_v):
return self._distance_function(d_v, d2_v)
with self._model_lock:
self._log.debug("getting near hashe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_nearest_neighbour_1d(self):\n x = np.array([2., 1., 4., 5., 3.])\n x_new = np.array([-3, 0, 1.2, 3, 3, 2.5, 4.7, 6])\n val, ind = _nearest_neighbour_1d(x, x_new)\n np.testing.assert_array_equal(val, [1., 1., 1., 3., 3., 2., 5., 5.])\n np.testing.assert_array_equal(ind, [... | [
"0.636273",
"0.630254",
"0.60281736",
"0.5943924",
"0.59283555",
"0.5885495",
"0.5877531",
"0.58613336",
"0.5830915",
"0.57700646",
"0.57700646",
"0.56760716",
"0.56691253",
"0.5665002",
"0.56431895",
"0.563362",
"0.5632298",
"0.5618386",
"0.5602656",
"0.5597303",
"0.55920225... | 0.6726871 | 0 |
Level as a string. | def level_name(self) -> str:
return getLevelName(self.level) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_level(self, level):\n return",
"def __str__(self):\n string = ''\n\n # gets the nodes at each level and puts the values into a string\n for i in range(self.get_height()+1):\n nodes = self.get_nodes_on_level(i)\n level = [str(node.value) if node else '-' f... | [
"0.70281094",
"0.6984572",
"0.6966007",
"0.6825643",
"0.6811092",
"0.6721429",
"0.6673605",
"0.66604024",
"0.66604024",
"0.66604024",
"0.66604024",
"0.6650703",
"0.6650703",
"0.6631484",
"0.6623055",
"0.658296",
"0.65787655",
"0.65737617",
"0.65655804",
"0.6522336",
"0.652138... | 0.77638847 | 0 |
Initialize an instance of the game visualizer. Store the referee to use to run the game. Additionally, the initial order of players is stored. | def __init__(self, referee):
super(GameVisualizerWindow, self).__init__()
self.referee = referee
self.darea = None # set in init_ui()
self.scores = None # set in init_ui()
self.player_color_order = [player.get_color() for player in referee.get_current_state().get_players()]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.screen = pg.display.get_surface()\n self.screen_rect = self.screen.get_rect()\n self.clock = pg.time.Clock()\n self.fps = 60\n self.keys = pg.key.get_pressed()\n self.done = False\n # ship = random.choice(list(prepare.GFX[\"ships\"].values... | [
"0.679442",
"0.6789897",
"0.66815865",
"0.66547024",
"0.66024655",
"0.6598829",
"0.65734255",
"0.6536193",
"0.65354216",
"0.65309167",
"0.65183204",
"0.651029",
"0.6440358",
"0.64252824",
"0.6383633",
"0.63720644",
"0.635871",
"0.6323436",
"0.630629",
"0.6305288",
"0.62966394... | 0.7888223 | 0 |
Initialize and configure the user interface. This involves setting up the drawing area, the button to do turns, and a text view to display scores, as well as setting up callbacks. Configurations such as widget sizes and labels are also set here. | def init_ui(self):
self.set_title(TITLE)
self.set_default_size(WINDOW_WIDTH, WINDOW_HEIGHT)
self.set_resizable(False)
fixed = Gtk.Fixed()
self.add(fixed)
darea = Gtk.DrawingArea()
darea.connect(DRAW_EVENT, self.on_draw)
darea.set_size_request(DRAWING_ARE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_ui(self):\n self.master.title(\"Backbone\")\n self.master.geometry(\"300x150\")\n\n self.pack(fill=BOTH, expand=1)\n\n self.btn_upload_file = Button(self, text=\"Upload file\", command=self.upload_file)\n self.btn_upload_file.place(x=90, y=10)\n\n self.btn_create_... | [
"0.66681504",
"0.663576",
"0.66196823",
"0.6619261",
"0.6588875",
"0.65485215",
"0.6535268",
"0.65008545",
"0.64888674",
"0.64518774",
"0.64388704",
"0.64347047",
"0.6428803",
"0.64084625",
"0.6373432",
"0.63612574",
"0.6330323",
"0.63185287",
"0.6310055",
"0.63019323",
"0.62... | 0.74698806 | 0 |
Return a list of scores representing the scores of the players, in the order of player's turns. | def get_scores_in_order_of_players(self):
players = self.referee.get_current_state().get_players()
player_scores = []
for player_color in self.player_color_order:
for player in players:
if player_color == player.get_color():
player_scores... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_scores(self):\n return [(self.players[p.get_color()], p.get_score()) for p in self.state.get_players()]",
"def calculate_scores(players):\n scores = {}\n for player in players.tuple_:\n scores[player.id_] = player.score()\n return scores",
"def get_players_by_rank(self):\n ... | [
"0.8231863",
"0.708941",
"0.70600694",
"0.69003886",
"0.68367106",
"0.6832921",
"0.67670155",
"0.6752282",
"0.6668831",
"0.66560477",
"0.656077",
"0.65558183",
"0.65367687",
"0.6521682",
"0.65157676",
"0.6506245",
"0.6499215",
"0.64963645",
"0.6492643",
"0.6460885",
"0.641571... | 0.8183596 | 1 |
Get a string representation of all the players current scores. The players are listed in turn order (meaning it does not start at the player whose turn it is currently, but starts at the first player who placed a penguin.) | def get_current_scores_buffer(self):
player_scores = self.get_scores_in_order_of_players()
score_string = "Scores:\n"
for color, score in zip(self.player_color_order, player_scores):
player_score = "{}: {}".format(color, score)
score_string += player_score
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_scoreboard(self):\n output = ''\n # parallel dictionaries with innings and scores\n innings = []\n away = []\n home = []\n for x in self:\n innings.append(x['inning'])\n away.append(x['away'])\n home.append(x['home'])\n # g... | [
"0.72212094",
"0.700178",
"0.6971123",
"0.69110477",
"0.6735857",
"0.6676208",
"0.6612254",
"0.659147",
"0.65792733",
"0.65697765",
"0.6559172",
"0.6509007",
"0.6461611",
"0.6422059",
"0.6406507",
"0.639278",
"0.6347347",
"0.63014215",
"0.62833303",
"0.6267375",
"0.6261915",
... | 0.7885591 | 0 |
Helper function to perform a turn when a button is clicked. This function makes the referee run the next turn of the game. This function also updates the labels of the button that was pressed to tell the user if a round is currently being ran or not. This function also sets the new scores in the scores box after the tu... | def do_next_turn(self, button):
button.set_label(RUNNING_TURN_MSG)
self.referee.run_turn()
self.scores.get_buffer().set_text(self.get_current_scores_buffer())
button.set_label(RUN_NEXT_TURN_MSG)
self.darea.queue_draw() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_next_turn_click(self, button):\n if self.referee.is_game_over():\n Gtk.main_quit()\n else:\n self.do_next_turn(button)\n # if the game is over after this turn, we will shutdown on the next click,\n # so visually alert the player with the button label... | [
"0.7048446",
"0.6712457",
"0.6562238",
"0.6472978",
"0.63358074",
"0.62775713",
"0.62745523",
"0.62213975",
"0.6115055",
"0.61080164",
"0.6100496",
"0.6090055",
"0.607604",
"0.60638136",
"0.60425466",
"0.60403013",
"0.60321194",
"0.60312575",
"0.6012323",
"0.6010205",
"0.5969... | 0.823928 | 0 |
Callback function that runs when a button is clicked. This function will run the next turn of the game if the game is not over, or will shut down the program if the game is over. This function will also update the button label to display the game is over or not. | def on_next_turn_click(self, button):
if self.referee.is_game_over():
Gtk.main_quit()
else:
self.do_next_turn(button)
# if the game is over after this turn, we will shutdown on the next click,
# so visually alert the player with the button label
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_next_turn(self, button):\n button.set_label(RUNNING_TURN_MSG)\n self.referee.run_turn()\n self.scores.get_buffer().set_text(self.get_current_scores_buffer())\n button.set_label(RUN_NEXT_TURN_MSG)\n self.darea.queue_draw()",
"def on_click(button):\n global ttt, choices... | [
"0.7148402",
"0.71446335",
"0.7122622",
"0.6774405",
"0.6766827",
"0.6748884",
"0.672878",
"0.6569718",
"0.6546862",
"0.65195405",
"0.64864796",
"0.6469882",
"0.6464471",
"0.6455949",
"0.64405733",
"0.6390221",
"0.63795745",
"0.63476944",
"0.63342875",
"0.6323387",
"0.6317748... | 0.8086216 | 0 |
Create a list of players with size num_players. The colors of each player are in the order defined in BoardPlayer.POSSIBLE_COLORS. Each player has a depth of 1. | def get_player_list(num_players):
colors = BoardPlayer.POSSIBLE_COLORS
player_list = []
for i in range(num_players):
player_list.append(Player(colors[i], DEPTH))
return player_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_player_list(num_players, game_grid):\n\n if num_players == 1:\n return [Cycle(\"Player 1\", 2, 2, \"R\", Color(\"Blue\"), Color(\"White\")),\n Cycle(\"AI\", len(game_grid) - 3, len(game_grid[0]) - 3, \"L\", Color(\"Red\"), Color(\"White\")),\n Cycle(\"AI\", len(ga... | [
"0.74653816",
"0.71190274",
"0.69114",
"0.6725265",
"0.65766233",
"0.63620275",
"0.62997985",
"0.6270952",
"0.6266892",
"0.6210848",
"0.6206907",
"0.61643654",
"0.61266655",
"0.5864176",
"0.58553654",
"0.5844819",
"0.5837506",
"0.5829588",
"0.5822507",
"0.5800725",
"0.5797632... | 0.8641923 | 0 |
Parse a string representing the number of players and convert it to an integer representing the number of players to use. The string must be numeric and must be between 2 and 4, inclusive, otherwise None is returned | def parse_num_players(num_players):
try:
num_players = int(num_players)
except ValueError:
return None
if num_players < 2 or num_players > 4:
return None
return num_players | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getNumFromString(self, string):\n \n m = re.search(r'\\d+$', string)\n if m is not None:\n return int(m.group())\n else:\n return 0",
"def info_player_id(self, playername):\r\n number = 0\r\n name = playername.title().replace(\" \", \"+\")\r\n ... | [
"0.63758874",
"0.6296648",
"0.61954373",
"0.6072014",
"0.6059474",
"0.60295767",
"0.6026044",
"0.6011106",
"0.59960264",
"0.5989781",
"0.5965972",
"0.5880547",
"0.5842748",
"0.58197284",
"0.58116",
"0.58019173",
"0.5784927",
"0.576755",
"0.575936",
"0.5723573",
"0.57172006",
... | 0.8473476 | 0 |
Run the visualizer with the given number of players. | def run_visualizer(num_players):
num_players = parse_num_players(num_players)
if num_players is None:
raise ValueError("Invalid player count given.")
players = get_player_list(num_players)
ref = Referee(players, (5, 5), timeout=600)
win = GameVisualizerWindow(ref)
win.show_all()
G... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_simulation(self, num_games=10):\n for _ in range(num_games):\n self.result.append(self.single_game())",
"def run_trials(self, num=0):\n if num == 'all':\n self.trials_to_run = len(self.trials)\n else:\n self.trials_to_run = num\n self.vision_eg... | [
"0.6365585",
"0.6150837",
"0.6030641",
"0.59946847",
"0.59803605",
"0.5919918",
"0.5898477",
"0.58953476",
"0.5692316",
"0.56912553",
"0.56769323",
"0.56539273",
"0.55989254",
"0.5564556",
"0.55590165",
"0.5540571",
"0.5535289",
"0.5460685",
"0.5444915",
"0.54234105",
"0.5419... | 0.8455506 | 0 |
Force sorted responses by self.ipset._get_new/deleted_set_ips. _get_new/deleted_set_ips use internally sets and return randomly ordered responses. This method ensures sorted responses from them in order to guarantee call order in self.ipset.set_members. | def force_sorted_get_set_ips(self):
original_get_new_set_ips = self.ipset._get_new_set_ips
original_get_deleted_set_ips = self.ipset._get_deleted_set_ips
def sorted_get_new_set_ips(set_name, expected_ips):
unsorted = original_get_new_set_ips(set_name, expected_ips)
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lotteryPendingQueue(ipSet):\n\t# make list of possible predicates and remove duplicates\n\tpredicates = [ip.predicate for ip in ipSet]\n\tseen = set()\n\tseen_add = seen.add\n\tpredicates = [pred for pred in predicates if not (pred in seen or seen_add(pred))]\n\n\t#choose the predicate\n\tweightList = np.array... | [
"0.5145373",
"0.51405823",
"0.5088774",
"0.50321305",
"0.50162804",
"0.50126475",
"0.49818024",
"0.49794364",
"0.48830393",
"0.48404258",
"0.4814375",
"0.4799804",
"0.47892106",
"0.47680792",
"0.47661233",
"0.47639957",
"0.47504014",
"0.4743116",
"0.468946",
"0.46522427",
"0.... | 0.8169664 | 0 |
Generate a temporary standard edge file based on the given adjacency edge file. | def generateEdgeFile(adj_filename):
# Parse the adjacency file
edges = []
edge_id = 0
min_v = None
max_v = None
min_depth = 0
depth = 0
num_nodes = 0
with open(adj_filename, 'r') as adj_f:
r = csv.reader(adj_f, delimiter='\t')
for row_idx, row in enumerate(r):
if not num_nodes:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_edge_features(edge_features, edge_file):\n dgl.data.utils.save_tensors(edge_file, edge_features)",
"def export_graph(cls, graph, filename):\n edges = {}\n for node in graph.values():\n for neighbour, dist in node.distances.items():\n if (node.id, neighbour) in... | [
"0.6024162",
"0.58897555",
"0.5825257",
"0.5786747",
"0.5727056",
"0.5714465",
"0.5684711",
"0.567218",
"0.56542605",
"0.5579996",
"0.55602103",
"0.5531733",
"0.54472744",
"0.5443352",
"0.54141134",
"0.53695107",
"0.5321498",
"0.5285575",
"0.5255383",
"0.5216882",
"0.5208768"... | 0.7351656 | 0 |
Return the given boundary as a Q object suitable for querysets. | def _boundary_filter(self, south, west, north, east):
return Q(latitude__gt=south, longitude__gt=west,
latitude__lt=north, longitude__lt=east) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def boundary(self): # -> BaseGeometry:\n ...",
"def _create_filter_object(form_data: Dict) -> Q:\n filter_object = Q(title__icontains=form_data[\"title\"])\n filter_object &= Q(author__icontains=form_data[\"author\"])\n filter_object &= Q(\n publication_language__icontains... | [
"0.57327753",
"0.5393648",
"0.5344611",
"0.5293871",
"0.52651924",
"0.5209962",
"0.5151361",
"0.51221335",
"0.509879",
"0.5091258",
"0.50874144",
"0.5077453",
"0.50735956",
"0.50507224",
"0.50312674",
"0.4991418",
"0.49901503",
"0.49759102",
"0.49629217",
"0.49530393",
"0.494... | 0.6247211 | 0 |
Return the airports in the given boundary, combining multiple checks if the boundary overlaps a hemisphere line. | def for_boundary(self, south, west, north, east):
south = float(south)
west = float(west)
north = float(north)
east = float(east)
if west * east < 0:
# Boundary overlaps a hemisphere line, look up either side of it.
if (180 - west) < west:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detect_area_with_boundary(self, boundary): \r\n # create a polynome approximation with the boundary curve\r\n #update boundary\r\n self.set_boundary(boundary)\r\n \r\n # step 1: find the line connected head and tail\r\n head = boundary.get_head(boundary.mode)\r\n ... | [
"0.5394385",
"0.53189814",
"0.523158",
"0.5114259",
"0.50788957",
"0.49425542",
"0.4872695",
"0.48638052",
"0.48591077",
"0.4844756",
"0.48313314",
"0.481995",
"0.48155817",
"0.48141488",
"0.48097947",
"0.47850233",
"0.4776012",
"0.47720993",
"0.47235444",
"0.4717238",
"0.471... | 0.5646328 | 0 |
Get softargmax coordinate for the given score map. | def soft_argmax(self, score_map):
# (bs, feat_size * feat_size)
score_vec = score_map.view((-1, self.feat_size * self.feat_size))
prob_vec = nn.functional.softmax(score_vec, dim=1)
if not hasattr(self, 'coord_x'):
# generate coordinates and indexes
self.indice = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_maximum_from_heatmap(self, heatmap):\n assert heatmap.size(0) == 1 and heatmap.size(1) == 1\n max_map = torch.eq(heatmap, self.pool(heatmap)).float()\n heatmap = heatmap * max_map\n score = heatmap.view(-1)\n score, pos_idx = score.topk(self.max_num_people)\n mask... | [
"0.65778434",
"0.63588685",
"0.627444",
"0.6260095",
"0.61241853",
"0.6041717",
"0.590227",
"0.58632195",
"0.5844217",
"0.57985765",
"0.57653546",
"0.57485694",
"0.57485694",
"0.57485694",
"0.57485694",
"0.57430995",
"0.57019997",
"0.5674879",
"0.5664324",
"0.56596255",
"0.56... | 0.8427702 | 0 |
Getting attribute from common configuration file | def __get_common(attribute):
return common.API_COMMON_CONFIG[attribute] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_attr(self, server, attribute):\n\t\tattribute = str(attribute)\n\t\tcfg = self.get_cfg(server)\n\t\tif cfg:\n\t\t\treturn cfg.get(attribute)",
"def _get_attribute(self, profile, attribute):\n self.validate_root()\n self.is_valid_profile(profile)\n if attribute not in self.config[self... | [
"0.7258007",
"0.69346863",
"0.69201845",
"0.6858345",
"0.6795432",
"0.6713505",
"0.6605009",
"0.6463244",
"0.63739073",
"0.6330982",
"0.62900496",
"0.6279128",
"0.62187576",
"0.618842",
"0.6186253",
"0.61832786",
"0.61632085",
"0.61560833",
"0.61529845",
"0.6120516",
"0.61144... | 0.7257732 | 1 |
Getting url to API based on common configuration file and data code filters | def get_url(self, dataset_code):
module = None
for qol_param in common.QOL_PARAMS:
if dataset_code in common.QOL_PARAMS[qol_param]:
module = common.QOL_PARAMS[qol_param][dataset_code]
break
url = self.__get_host(dataset_code)
url = self.__appl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url(vmanage_host,vmanage_port,api):\r\n \"\"\" function to get the url provide api endpoint \"\"\"\r\n \r\n return f\"https://{vmanage_host}:{vmanage_port}{api}\"",
"def appurl( instkey, name, **matchdict ) :",
"def getURLs():",
"def _get_api_url(self):\n return \"%s/%s/\" % (settings.API... | [
"0.6248061",
"0.61557114",
"0.6150488",
"0.61260974",
"0.61066705",
"0.6093489",
"0.60448945",
"0.6019714",
"0.6001403",
"0.599803",
"0.59788513",
"0.59691656",
"0.59664416",
"0.5960868",
"0.594734",
"0.5928648",
"0.5926427",
"0.5920128",
"0.5910003",
"0.58931714",
"0.5890854... | 0.6174639 | 1 |
Initialize your data structure here. Set the size of the deque to be k. | def __init__(self, k: int):
self.capacity = k
self.frontIndex = 0
self.lastIndex = 1
self.deque = [0] * self.capacity
self.size = 0 # current size
| {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, k):\n self._data = []\n self._length = k",
"def __init__(self, k):\n self.queue = []\n self.size = k\n self.front = 0\n self.rear = 0",
"def __init__(self, k):\n self.queue = [0]*k\n self.headIndex = 0\n self.count = 0\n s... | [
"0.7902773",
"0.7679447",
"0.7633498",
"0.7627674",
"0.7582613",
"0.7521146",
"0.75211114",
"0.7503723",
"0.7489586",
"0.7476659",
"0.7475489",
"0.7424546",
"0.73562276",
"0.7342713",
"0.73352766",
"0.7096012",
"0.6864832",
"0.66151357",
"0.6569535",
"0.6564774",
"0.6529423",... | 0.82578045 | 0 |
Adds an item at the front of Deque. Return true if the operation is successful. | def insert_front(self, value: int) -> bool:
if self.size != self.capacity:
self.deque[self.frontIndex] = value
self.size += 1
if self.frontIndex == 0:
self.frontIndex = self.capacity - 1
else:
self.frontIndex -= 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push_front(self, e):\n if(self.size_ >= self.capacity_):#If our Deque is full we need to resize it first\n self.resize_front()\n self.data_[self.front_]= e#New Front\n self.size_+=1\n # print(\"Case 1\")\n elif(self.front_ == -1 and self.size_ ==0) :#If ... | [
"0.6975975",
"0.6975836",
"0.69515646",
"0.6903378",
"0.68868315",
"0.68819815",
"0.68557245",
"0.68127394",
"0.678145",
"0.6776072",
"0.6745622",
"0.6681152",
"0.66517055",
"0.66379315",
"0.6589232",
"0.65483433",
"0.6511195",
"0.6491245",
"0.6474825",
"0.6454851",
"0.643672... | 0.7306541 | 0 |
Take arbitrary number of str arguments (not list) and return expanded, absolute path to a user's (or userdefined) cltk_data dir. | def make_cltk_path(*fp_list):
return os.path.join(CLTK_DATA_DIR, *fp_list) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_data_dir():\r\n assert sys.argv\r\n prefix_path = os.path.dirname(sys.argv[0])\r\n local_data = os.path.join(prefix_path, \"data\")\r\n return local_data",
"def get_app_data_dir(appname, *args):\n import ubelt as ub\n ub.schedule_deprecation(\n modname='ubelt', name='get_app_da... | [
"0.58661675",
"0.5668878",
"0.56555104",
"0.5650495",
"0.5595522",
"0.5523274",
"0.54594797",
"0.5454015",
"0.5431963",
"0.540515",
"0.5386639",
"0.5351135",
"0.5348916",
"0.53021574",
"0.5289212",
"0.5272937",
"0.52652055",
"0.52642393",
"0.5259409",
"0.5253235",
"0.5218821"... | 0.6467885 | 0 |
rpc SetDebugLevel (DebugLevelRequest) returns (BaseResponse) { option (google.api.http) = { | def SetDebugLevel(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_debuglevel(self, level):\n self.debugging = level",
"def setDebugFLags(sessionId):\n try:\n if not authentication.checkSessionId(sessionId, ADMIN):\n abort(403)\n if request.data is None:\n abort(400)\n debugFlags = json.loads(request.data)\n De... | [
"0.6524345",
"0.61447215",
"0.6071056",
"0.6021396",
"0.56288624",
"0.5567556",
"0.55668926",
"0.5558487",
"0.55518526",
"0.5518022",
"0.55119455",
"0.5408538",
"0.53755057",
"0.5363909",
"0.5355801",
"0.5307751",
"0.53025997",
"0.5299265",
"0.52971476",
"0.5263971",
"0.52637... | 0.79708946 | 0 |
rpc UpdateNetworkID (UpdateNetworkIDRequest) returns (BaseResponse) { option (google.api.http) = { | def UpdateNetworkID(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetNetworkID(self, request, context):\n context.set_code(grpc.StatusCode.UNIMPLEMENTED)\n context.set_details('Method not implemented!')\n raise NotImplementedError('Method not implemented!')",
"def put(self, id):\n context = request.environ.get('context')\n net_obj = dbapi.networks_up... | [
"0.6377155",
"0.597741",
"0.56649214",
"0.56214505",
"0.5573502",
"0.5530543",
"0.55015075",
"0.54945767",
"0.53921235",
"0.530519",
"0.52978355",
"0.52969354",
"0.5288424",
"0.5288424",
"0.5288424",
"0.52693397",
"0.5260793",
"0.5172831",
"0.516545",
"0.5126393",
"0.5124526"... | 0.83613276 | 0 |
rpc GetNetworkID (GetNetworkIDRequest) returns (GetNetworkIDResponse) { option (google.api.http) = { | def GetNetworkID(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_network_id(self):\n\t\treturn call_sdk_function('PrlVirtNet_GetNetworkId', self.handle)",
"def get_network_id(options, network):\n service_instance = get_vc_content(options)\n datacenter = get_datacenter(options)\n for item in datacenter.networkFolder.childEntity:\n if (item.name == networ... | [
"0.7171402",
"0.6616125",
"0.6607974",
"0.6472358",
"0.6472358",
"0.6472358",
"0.6451169",
"0.6377823",
"0.63719785",
"0.63127875",
"0.6158992",
"0.61568797",
"0.6053438",
"0.60057765",
"0.59049284",
"0.5859211",
"0.5817157",
"0.5731048",
"0.5705311",
"0.5654971",
"0.5641681"... | 0.81038713 | 0 |
rpc AddNode (AddNodeRequest) returns (BaseResponse) { option (google.api.http) = { | def AddNode(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_node(self, node):",
"def addnode(self, ip_addr: str, cmd: str) -> None:\n assert type(ip_addr) == str\n assert cmd in COMMANDS\n return self.rpc_call(\"addnode\", ip_addr, cmd)",
"def add_node (self, node):\n raise NotImplementedError",
"def _add_node(self, node_name, node_typ... | [
"0.6886949",
"0.66823274",
"0.6648524",
"0.6632756",
"0.65144575",
"0.6461046",
"0.63111734",
"0.62823254",
"0.6270688",
"0.6242011",
"0.61145186",
"0.6106171",
"0.61001",
"0.6069039",
"0.60320395",
"0.60257554",
"0.6008064",
"0.5974223",
"0.5972402",
"0.5953031",
"0.5950946"... | 0.8054984 | 0 |
rpc GetBlockHeight (GetBlockHeightRequest) returns (GetBlockHeightResponse) { option (google.api.http) = { | def GetBlockHeight(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_block_height(self, blk_hash, cb):\r\n data = serialize.ser_hash(blk_hash)\r\n self.send_command('blockchain.fetch_block_height', data, cb)",
"def get_block_hash(height):\n return requests.get(BASE+f'/api/block-index/{height}').json()['blockHash']",
"def height(self):\n return ... | [
"0.69185287",
"0.6833825",
"0.6609316",
"0.6593401",
"0.630603",
"0.6188763",
"0.6185624",
"0.6182024",
"0.6149188",
"0.61161625",
"0.60192716",
"0.5953324",
"0.58345455",
"0.57578415",
"0.5682839",
"0.5682839",
"0.5682839",
"0.5676383",
"0.56692904",
"0.56692904",
"0.5665602... | 0.8232079 | 0 |
rpc GetBlockHash (GetBlockHashRequest) returns (GetBlockHashResponse) { option (google.api.http) = { | def GetBlockHash(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_block(blockhash):\n return requests.get(BASE+f'/api/block/{blockhash}').json()",
"def get_block_hash(height):\n return requests.get(BASE+f'/api/block-index/{height}').json()['blockHash']",
"def get_blockHash(self, data):\n blockHash = data['blockHash']\n return blockHash",
"def ge... | [
"0.7595978",
"0.7173805",
"0.6853576",
"0.6824187",
"0.6586017",
"0.6550719",
"0.65430444",
"0.6444644",
"0.6444644",
"0.63811195",
"0.61842805",
"0.6078641",
"0.6065449",
"0.606363",
"0.6060592",
"0.60471463",
"0.6044907",
"0.6044907",
"0.60407466",
"0.6018738",
"0.59679776"... | 0.78051454 | 0 |
rpc GetBlockHeader (GetBlockRequest) returns (GetBlockHeaderResponse) { option (google.api.http) = { | def GetBlockHeader(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetBlock(self, request, context):\n context.set_code(grpc.StatusCode.UNIMPLEMENTED)\n context.set_details('Method not implemented!')\n raise NotImplementedError('Method not implemented!')",
"def GetBlockHash(self, request, context):\n context.set_code(grpc.StatusCode.UNIMPLEMENTED)\n context.s... | [
"0.67096466",
"0.65781176",
"0.6541774",
"0.6459646",
"0.6158835",
"0.6119097",
"0.594869",
"0.58376133",
"0.58140343",
"0.5777425",
"0.5696825",
"0.56788206",
"0.56240237",
"0.56043345",
"0.55059505",
"0.54990935",
"0.54933983",
"0.5474018",
"0.5440675",
"0.54353565",
"0.539... | 0.8214981 | 0 |
rpc GetBlock (GetBlockRequest) returns (GetBlockResponse) { option (google.api.http) = { | def GetBlock(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_block(blockhash):\n return requests.get(BASE+f'/api/block/{blockhash}').json()",
"def get_block(self, crypto, block_height='', block_number='', latest=False):\n raise NotImplementedError(\n \"This service does not support getting getting block data. \"\n \"Or rather it has... | [
"0.7107428",
"0.68164647",
"0.6625506",
"0.65607804",
"0.6505889",
"0.64306474",
"0.63874197",
"0.63551414",
"0.6283359",
"0.62779987",
"0.62558174",
"0.619906",
"0.6185053",
"0.6125997",
"0.61109483",
"0.6100958",
"0.61004436",
"0.61004436",
"0.6088709",
"0.60805076",
"0.605... | 0.7806856 | 0 |
rpc GetNodeInfo (GetNodeInfoRequest) returns (GetNodeInfoResponse) { option (google.api.http) = { | def GetNodeInfo(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetNodeInfo(self, hvparams=None):\n return self.GetLinuxNodeInfo()",
"def get(self, request, nnid, wfver, desc):\n try:\n return_data = NNCommonManager().get_nn_node_info(nnid, wfver, desc)\n return Response(json.dumps(return_data))\n except Exception as e:\n ... | [
"0.7439849",
"0.6852461",
"0.65889823",
"0.6323488",
"0.62261367",
"0.6143817",
"0.60689044",
"0.6056143",
"0.5977873",
"0.58589566",
"0.58075047",
"0.5785552",
"0.5767497",
"0.57391393",
"0.57375586",
"0.5720717",
"0.57124937",
"0.5708837",
"0.5707627",
"0.5707309",
"0.57073... | 0.8246034 | 0 |
Normalizes a given hospital name. 1. Converts all words to lower case. 2. Removes all stopwords. | def normalize_hospital_name(name):
normalized_name = name.lower()
stopword_list = stopwords.words('english')
filtered_words = [word for word in wordpunct_tokenize(normalized_name) if word not in stopword_list]
slug = slugify(' '.join(filtered_words))
return slug | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _normalize_name(self, name, aggressive=False):\n stopwords = 'the', 'a'\n if aggressive:\n # Remove anything in brackets.\n name = re.sub(r'\\([^)]+\\)', '', name)\n # Some shows have a \"with Firstname Lastname\" suffix, like \"The Daily Show\n # with ... | [
"0.72365785",
"0.68701774",
"0.6862431",
"0.6830881",
"0.6830881",
"0.6761262",
"0.6750685",
"0.6738248",
"0.6719288",
"0.6670043",
"0.6665048",
"0.66137934",
"0.6578984",
"0.6569107",
"0.65648854",
"0.6541455",
"0.65140444",
"0.64899707",
"0.64899707",
"0.64899707",
"0.64876... | 0.79034716 | 0 |
does a git reset hard to whatever remote the branch is assigned to | def reset_branch_to_remote(repo, branch, hard=True):
remote = repo.get_branch_remote(branch)
kw = dict(remote=remote, branch=branch)
if hard:
kw['flags'] = '--hard'
repo.issue('git reset {flags} {remote}/{branch}'.format(**kw)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hard_reset_branches(args):\n checkout_branches(args)\n man = load_manifest()\n for (name, project) in man.projects.iteritems():\n print >>sys.stderr, \"Hard resetting tracking branch in project: %s\" % name\n repo = GitRepo(workdir_for_project(project))\n repo.check_command([\"reset\", \"--hard\", ... | [
"0.7487938",
"0.7343279",
"0.72039735",
"0.680071",
"0.6762364",
"0.6681312",
"0.66094434",
"0.65522313",
"0.64959395",
"0.6403131",
"0.6313687",
"0.619142",
"0.61898285",
"0.6114071",
"0.601012",
"0.59937227",
"0.5980438",
"0.5962808",
"0.59619427",
"0.5953685",
"0.59454954"... | 0.8294332 | 0 |
Changes the url format for committing | def change_url_format(repo, out_type='ssh'):
url = repo.url
url_parts = re.split('[/:]', url)
in_type = url_parts[0]
url_fmts = {
'https': ('.com/', 'https://'),
'ssh': ('.com:', 'git@'),
}
url_fmts['git'] = url_fmts['ssh']
new_repo_url =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_url(self, command):\n\n return '{}{}'.format(self.url,command)",
"def _format_api_url(self, url):\n user_name = self._get_user_name()\n # format and return url\n return url.format(\n user_name = user_name,\n element = urllib.quote(self.qnet_element.enc... | [
"0.65926516",
"0.6366216",
"0.614659",
"0.6131997",
"0.6079068",
"0.5984888",
"0.5974174",
"0.5911585",
"0.5877944",
"0.58651567",
"0.5848259",
"0.5804585",
"0.5783219",
"0.5775814",
"0.57553697",
"0.5724391",
"0.57028",
"0.56964356",
"0.56613433",
"0.5646112",
"0.563889",
... | 0.69633836 | 0 |
Checkout `branch` and automatically overwrites conflict files. | def checkout2(repo, branch, overwrite=True):
cmd = 'git checkout %s' % (branch,)
out = repo.issue(cmd, error='return')
if overwrite and out is not None:
repo._handle_overwrite_error(out)
repo._handle_abort_merge_rebase(out)
# Retry
repo.issue(cmd) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkout(branch=\"lf-dev\"):\n with cd(FOLDER):\n sudo('git fetch', user='tomcat')\n sudo('git checkout %s' % branch, user='tomcat')\n status()",
"def gitCheckoutBranch(self, path, branch):\r\n\r\n with workInDirectory(path):\r\n fetch_cmd = [\"git\", \"fetch\"]\r\n ... | [
"0.65946996",
"0.6574886",
"0.6410081",
"0.6246568",
"0.6213896",
"0.6204029",
"0.61986405",
"0.6193927",
"0.6152797",
"0.61391264",
"0.6123888",
"0.61154884",
"0.6081411",
"0.6080463",
"0.60580766",
"0.60198873",
"0.6007687",
"0.5984934",
"0.5980404",
"0.5944135",
"0.5940276... | 0.68562466 | 0 |
DEPRICATE My standard build script names. Calls mingw_build.bat on windows and unix_build.sh on unix | def std_build_command(repo='.'):
import utool as ut
print('+**** stdbuild *******')
print('repo = %r' % (repo,))
if sys.platform.startswith('win32'):
# vtool --rebuild-sver didnt work with this line
#scriptname = './mingw_build.bat'
scriptname = 'mingw_build.bat'
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build():\n local('wintersmith build')",
"def compile_build_files(ctx):\n project_dir = Path(__file__).parent\n\n build_dir = project_dir / \"build\"\n ninja_dir = project_dir / \"build/ninja\"\n artifacts_dir = project_dir / \"build/artifacts\"\n\n if artifacts_dir.exists():\n shutil... | [
"0.62677795",
"0.6129463",
"0.6032943",
"0.5977447",
"0.577154",
"0.5720386",
"0.56446457",
"0.5628962",
"0.5623403",
"0.550566",
"0.5472778",
"0.54249173",
"0.5416323",
"0.53943837",
"0.53937995",
"0.53872776",
"0.536856",
"0.53682464",
"0.5364527",
"0.53571385",
"0.53334236... | 0.6428409 | 0 |
A view that renders the bag contents page | def view_bag(request):
return render(request, 'bag/bag.html') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def view_bag(request):\n return render(request, 'bag/bag.html')",
"def view_bag(request):\n template = 'bag/bag.html'\n return render(request, template)",
"def view_shoppingbag(request):\n\n return render(request, 'shoppingbag/shoppingbag.html')",
"def view_basket(request):\n\n return render(r... | [
"0.81315035",
"0.7977562",
"0.6872735",
"0.68546337",
"0.6620919",
"0.6348403",
"0.6221381",
"0.6121466",
"0.6058291",
"0.6022294",
"0.60026085",
"0.59646916",
"0.5949683",
"0.5934281",
"0.5898349",
"0.58762145",
"0.58650833",
"0.5857844",
"0.5836029",
"0.5827804",
"0.5826162... | 0.81268024 | 1 |
busy wait for robot completion | def waitrobot(robot):
while not robot.GetController().IsDone():
time.sleep(0.01) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def busyWait(self):\n time.sleep(0.0)",
"def waitForCompletion(self):\n\n while(json.loads(self.robot.device())['state']!=0):\n time.sleep(0.1)\n continue\n\n return",
"def wait(self):\n time.sleep(0.010)",
"def wait(self):\n pass",
"def wait(self):\... | [
"0.7729015",
"0.7684526",
"0.76390046",
"0.7526746",
"0.7526746",
"0.7480899",
"0.7480899",
"0.7480899",
"0.7480899",
"0.7460632",
"0.7429611",
"0.7353933",
"0.73518384",
"0.7336683",
"0.7308061",
"0.7302214",
"0.72688043",
"0.7262008",
"0.7262008",
"0.72150105",
"0.7173207",... | 0.8239064 | 0 |
Reads input file and runs monte carlo simulation to convert raman tensors from molecular to labratory coordinates and prints the matrix in the mueller formalism to a file | def main(cliArgs):
log.info("START RAMAN TENSOR CONVERSION")
# Read tensor file as matrices
tensorlist = util.readFileAsMatrices(cliArgs.tensorfile, (3,3))
# PREPARE SIMULATION
log.info("Prepare simulation")
# Copy the structure of tensorlist with empty arrays. This copy will be filled with the... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n\tif len(sys.argv) < 12 or len(sys.argv) > 13:\n\t\tprint(\"Input parameters must be: 'filename lambda mu C c0 Q theta L H simulation_time is_debug repeats(optionally)'\")\n\telse:\n\t\tstart_time = time.time()\n\n\t\tfile_name = sys.argv[1]\n\t\tlambd = float(sys.argv[2])\n\t\tmu = float(sys.argv[3])... | [
"0.63589895",
"0.6317133",
"0.62950945",
"0.6243753",
"0.6216487",
"0.6118958",
"0.60965335",
"0.60688287",
"0.60328394",
"0.5999172",
"0.59918565",
"0.59618837",
"0.5955662",
"0.59437644",
"0.59124404",
"0.5902302",
"0.58720607",
"0.5864495",
"0.58569854",
"0.5856138",
"0.58... | 0.66973764 | 0 |
add post filter object as a report entry | def add_post_filter_object(self, data_obj):
self._description = data_obj.description
self._filter = data_obj.filter
self._method = data_obj.method
self._operator = data_obj.operator
self._type = 'pfo' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, event):\n post_event(event, self.baseUrl, self.filterName)",
"def addAutoSaveFilter(filter):",
"def post_filter(self, qs):\n return qs",
"def _filter_post(post):\n\n return True",
"def add_filter_entry(entry_message, data=''):\n return partial(__add_entry,\n ... | [
"0.5869994",
"0.5798248",
"0.5682353",
"0.56647676",
"0.5580719",
"0.5488624",
"0.54865915",
"0.5483772",
"0.5360345",
"0.532434",
"0.5279582",
"0.5261436",
"0.52171093",
"0.51795906",
"0.5126167",
"0.51139915",
"0.51130533",
"0.5110276",
"0.51059115",
"0.51031727",
"0.509438... | 0.76323026 | 0 |
Inverse of builtin zip(), returns iterators of each tuple item. Returns tuple of iterators based upon an iterable, each item of which is assumed to be a tuple of the same number of items (i.e., of the sort created by zip() builtin). Assumes that all items of the iterable are a tuple with same length as the initial item... | def unzip(iterable: Iterable[Tuple[Any, ...]]) -> Tuple[Iterator[Any], ...]:
first, iterator = _common.peek(iter(iterable))
if first is None:
return ()
tees = itertools.tee(iterator, len(first))
return (map(operator.itemgetter(i), tee) for i, tee in enumerate(tees)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unzip_finite(\n iterable: Iterable[Tuple[Any, ...]],\n) -> Tuple[Iterator[Any], ...]:\n for zipped in zip(*iterable):\n yield zipped",
"def pairwise(iterable):\r\n a = iter(iterable)\r\n return izip(a, a)",
"def unzip(seq: Iterable) -> tuple:\n seq = iter(seq)\n # check how man... | [
"0.7884123",
"0.73951375",
"0.73822427",
"0.7329859",
"0.72852314",
"0.7253318",
"0.72527623",
"0.72527623",
"0.72527623",
"0.72360116",
"0.7232941",
"0.71585727",
"0.7145812",
"0.71393615",
"0.71206856",
"0.7116042",
"0.7116042",
"0.7113765",
"0.7113765",
"0.7113765",
"0.711... | 0.7844818 | 1 |
Similar to unzip(), but limited to finite iterables. This function does not distinguish sentinel values of the sort used by itertools.zip_longest(). Such sentinels will be included in the returned item iterators. See unzip_longest_finite() in this module to efficiently unzip an iterable created using itertools.zip_long... | def unzip_finite(
iterable: Iterable[Tuple[Any, ...]],
) -> Tuple[Iterator[Any], ...]:
for zipped in zip(*iterable):
yield zipped | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unzip_longest_finite(\n iterable: Iterable[Tuple[Any, ...]],\n *,\n fillvalue: Optional[Any] = None,\n) -> Tuple[Iterator[Any], ...]:\n for zipped in zip(*iterable):\n yield tuple(item for item in zipped if item != fillvalue)",
"def zip_discard_compr(*iterables: Iterable, senti... | [
"0.7599641",
"0.7005301",
"0.64382815",
"0.62493163",
"0.6243333",
"0.6125157",
"0.61182976",
"0.6105243",
"0.5990228",
"0.59512585",
"0.5897735",
"0.5838505",
"0.57998437",
"0.5778073",
"0.57158124",
"0.5677239",
"0.5629741",
"0.56005573",
"0.5599043",
"0.5512083",
"0.546287... | 0.7502314 | 1 |
Similar to unzip(), but limited to finite iterables. This function distinguishes sentinel values of the sort used by itertools.zip_longest(). Such sentinels will be stripped from the returned item iterators. Use unzip_finite() in this module to efficiently unzip iterables created using builtin zip(). | def unzip_longest_finite(
iterable: Iterable[Tuple[Any, ...]],
*,
fillvalue: Optional[Any] = None,
) -> Tuple[Iterator[Any], ...]:
for zipped in zip(*iterable):
yield tuple(item for item in zipped if item != fillvalue) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zip_discard_compr(*iterables: Iterable, sentinel: Any = object()) -> Any:\r\n return [[entry for entry in iterable if entry is not sentinel]\r\n for iterable in zip_longest(*iterables, fillvalue=sentinel)]",
"def unzip_finite(\n iterable: Iterable[Tuple[Any, ...]],\n) -> Tuple[Iterator[A... | [
"0.71071625",
"0.70818937",
"0.6151461",
"0.61206645",
"0.61140555",
"0.6043417",
"0.5882001",
"0.58613545",
"0.5844499",
"0.5748359",
"0.57428557",
"0.5737231",
"0.5674092",
"0.55678666",
"0.5558231",
"0.55369616",
"0.5512515",
"0.5436522",
"0.5401102",
"0.53359205",
"0.5334... | 0.71139956 | 0 |
Returns the ith (0indexed) binary array from the enumeration of all 2^n binary array with n elements, in order [0,0,...,0],[1,0,...,0], etc. | def ith_binary_array(i,n=9):
return numpy.array([(i//2**j) % 2 for j in xrange(n)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_naive_array(n):\n result = list()\n for i in range(1, n+1):\n result.append(i)\n return result",
"def create_array( n ):",
"def binary_compositions(n):\n return productrange(*[2]*(n-1))",
"def create_n(N):\n\n all_n = np.array([])\n max_bin_len = len(bin(2 ** N - 1)[2:]) # ... | [
"0.70245016",
"0.6837331",
"0.65712476",
"0.6568325",
"0.6497333",
"0.6471789",
"0.6447051",
"0.6431503",
"0.6422565",
"0.6368894",
"0.6367631",
"0.63026714",
"0.62990963",
"0.6229507",
"0.620456",
"0.61642796",
"0.61545974",
"0.6154187",
"0.6134292",
"0.60946274",
"0.6058780... | 0.8176775 | 0 |
Gets concept target values for an array, i.e. next life value, current life value, number live neighbors | def get_concept_target(a):
curr_life = a[4]
num_live = numpy.sum(a)-curr_life
nl_g1 = 0
nl_g2 = 0
nl_g3 = 0
if (num_live > 1):
nl_g1 = 1
if (num_live > 2):
nl_g2 = 1
if (num_live > 3):
nl_g3 = 1
if (num_live > 3 or num_live < 2):
next_life = 0
elif num_live == 3:
next_life ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def narration_target(self):",
"def get_targets(self, states, j):\n a = self.get_optimal_action(states, j)\n a = np.expand_dims(a, axis=1)*1\n return {'gt_action': a}",
"def get_targets(self):\n\t\treturn self.prDoc['inputs']['data'][0]['targets']",
"def make_target(self, state_index, traj):\n\n ... | [
"0.59355456",
"0.58669674",
"0.5836947",
"0.5732367",
"0.566638",
"0.5532835",
"0.5528128",
"0.550536",
"0.5441657",
"0.5401287",
"0.5375301",
"0.5360174",
"0.5360174",
"0.5349574",
"0.52805483",
"0.523364",
"0.5230511",
"0.5207085",
"0.51966673",
"0.5144492",
"0.5144058",
... | 0.7112624 | 0 |
Attempts to retrieve the crash_id from a data dictionary | def get_crash_id(data: dict) -> int:
try:
return data["event"]["data"]["new"]["crash_id"]
except (TypeError, KeyError):
raise_critical_error(
message="Unable to parse request body to identify a crash_id",
data=data
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_city_id_from_db(crash_id: int) -> Optional[int]:\n if not str(crash_id).isdigit():\n print(\"It's bad\")\n return None\n\n get_city_id_query = \"\"\"\n query getCityId($crash_id:Int!){\n atd_txdot_crashes(where: {\n crash_id: {_eq:$crash_id}\n ... | [
"0.6272437",
"0.59513015",
"0.55179",
"0.54812336",
"0.53696215",
"0.5354128",
"0.53469145",
"0.52892274",
"0.525855",
"0.5231635",
"0.5222822",
"0.5222562",
"0.5200039",
"0.5149051",
"0.5127858",
"0.5088431",
"0.50883",
"0.50799894",
"0.5075199",
"0.50506073",
"0.5049268",
... | 0.8355854 | 0 |
Returns the city id of the record in question | def get_city_id(data: dict) -> Optional[int]:
try:
return data["event"]["data"]["new"]["city_id"]
except (TypeError, KeyError):
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_city_id(cls, city, state):\n city_instance = cls.query.filter_by(name=city, state=state).first()\n if city_instance:\n return city_instance.id\n\n city_instance = cls(name=city, state=state)\n try:\n db.session.add(city_instance)\n db.session.com... | [
"0.75250643",
"0.70947176",
"0.70381284",
"0.6898604",
"0.6898604",
"0.6812364",
"0.6685977",
"0.6669821",
"0.6669821",
"0.6669821",
"0.6669821",
"0.6669821",
"0.66373014",
"0.6633529",
"0.66121835",
"0.6608844",
"0.656693",
"0.656693",
"0.6549308",
"0.6533387",
"0.6527506",
... | 0.7371334 | 1 |
Returns the original city id of the record in question | def get_original_city_id(data: dict) -> Optional[int]:
try:
return data["event"]["data"]["new"]["original_city_id"]
except (TypeError, KeyError):
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_city_id(cls, city, state):\n city_instance = cls.query.filter_by(name=city, state=state).first()\n if city_instance:\n return city_instance.id\n\n city_instance = cls(name=city, state=state)\n try:\n db.session.add(city_instance)\n db.session.com... | [
"0.6964615",
"0.66592705",
"0.6169417",
"0.6157738",
"0.60501194",
"0.6029745",
"0.60122174",
"0.60122174",
"0.5994775",
"0.5994775",
"0.5994775",
"0.5994775",
"0.5994775",
"0.594946",
"0.5866604",
"0.5851254",
"0.57407475",
"0.5719268",
"0.5703641",
"0.57028884",
"0.56992984... | 0.75089175 | 0 |
Attempts to find the jurisdiction of a crash by it's ID | def is_crash_in_jurisdictions(crash_id: int) -> bool:
if not str(crash_id).isdigit():
return False
find_crash_jurisdictions = """
query findCrashJurisdictions($crash_id:Int!) {
find_crash_jurisdictions(args: {given_crash_id: $crash_id}) {
id
}
}
"""
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_crash_in_jurisdiction(crash_id: int) -> str:\n if not str(crash_id).isdigit():\n return \"N\"\n\n find_jurisdiction_query = \"\"\"\n query($crash_id:Int) {\n find_crash_in_jurisdiction(args: {jurisdiction_id: 5, given_crash_id: $crash_id}) {\n crash_id\n ... | [
"0.6507495",
"0.55955935",
"0.55866814",
"0.54629683",
"0.5459501",
"0.5459319",
"0.51034653",
"0.510335",
"0.5093428",
"0.50861627",
"0.50335515",
"0.50307775",
"0.5009739",
"0.50014627",
"0.4972644",
"0.495175",
"0.49425152",
"0.49007264",
"0.48689076",
"0.4845339",
"0.4821... | 0.6285635 | 1 |
Attempts to find the jurisdiction of a crash by it's ID | def is_crash_in_jurisdiction(crash_id: int) -> str:
if not str(crash_id).isdigit():
return "N"
find_jurisdiction_query = """
query($crash_id:Int) {
find_crash_in_jurisdiction(args: {jurisdiction_id: 5, given_crash_id: $crash_id}) {
crash_id
austin_ful... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_crash_in_jurisdictions(crash_id: int) -> bool:\n if not str(crash_id).isdigit():\n return False\n\n find_crash_jurisdictions = \"\"\"\n query findCrashJurisdictions($crash_id:Int!) {\n find_crash_jurisdictions(args: {given_crash_id: $crash_id}) {\n id\n }\n ... | [
"0.62852407",
"0.5597144",
"0.55872697",
"0.5461747",
"0.5458556",
"0.5457154",
"0.5104035",
"0.5101891",
"0.5091695",
"0.50856304",
"0.50348383",
"0.5034417",
"0.5008962",
"0.50002253",
"0.4971581",
"0.49519747",
"0.49415794",
"0.48994198",
"0.48683766",
"0.48447788",
"0.481... | 0.65068835 | 0 |
Concatenate the labels and predictions. If normalization was performed on the labels, undo the normalization. | def _finalize_labels_and_prediction(self):
y_pred = torch.cat(self.y_pred, dim=0)
y_true = torch.cat(self.y_true, dim=0)
if (self.mean is not None) and (self.std is not None):
# To compensate for the imbalance between labels during training,
# we normalize the ground tru... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def consolidate_predictions(self, examples_raw, examples, preds):\n assert len(examples_raw) == len(examples)\n assert len(examples_raw) == len(preds)\n\n ret = []\n for i, (sentence, labels) in enumerate(examples_raw):\n _, _, mask,_ = examples[i]\n labels_ = [l f... | [
"0.6221581",
"0.6194209",
"0.60707176",
"0.60045135",
"0.59993315",
"0.5892911",
"0.5884708",
"0.5791044",
"0.5764986",
"0.57386476",
"0.56580555",
"0.56315595",
"0.55635166",
"0.5531881",
"0.55164355",
"0.55140215",
"0.55046463",
"0.5495391",
"0.5449793",
"0.54393893",
"0.54... | 0.7226459 | 0 |
Proxy function for a3.str5_cmyk | def str5_cmyk(cmyk):
result = a3.str5_cmyk(cmyk)
if result is None:
return ''
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intern(string): # real signature unknown; restored from __doc__\n return \"\"",
"def c(k):\n if isinstance(k, str):\n return k.lower() if ord(k) % 2 == 0 else k.upper()\n return k",
"def _GetKeyString(self):",
"def _GetKeyString(self):",
"def __le__(self, *args):\n return _libsbm... | [
"0.56533873",
"0.5508936",
"0.5494697",
"0.5494697",
"0.5325098",
"0.52597857",
"0.52154547",
"0.5180345",
"0.5079391",
"0.5076965",
"0.50710034",
"0.5046079",
"0.50234175",
"0.50144464",
"0.5010689",
"0.49747807",
"0.4974715",
"0.49191678",
"0.48957407",
"0.4875642",
"0.4865... | 0.7502337 | 0 |
Proxy function for a3.str5_hsv | def str5_hsv(hsv):
result = a3.str5_hsv(hsv)
if result is None:
return ''
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def applyHSV(img):\n\treturn applyColorMap(img, \"hsv\")",
"def hsv(img):\n\tif img is None:\n\t\tprint \"Img is None\"\n\t\tsys.exit()\n\tif len(img.shape) > 2:\n\t\treturn cv2.cvtColor(img, cv2.COLOR_BGR2HSV)\n\treturn None",
"def rgb2hsv(t):\n r,g,b = t\n r /= 255.0\n g /= 255.0\n b /= 255.0\n ... | [
"0.68916756",
"0.64323556",
"0.6351842",
"0.6342069",
"0.6278692",
"0.6187963",
"0.6183965",
"0.61620563",
"0.61368906",
"0.6113743",
"0.6085936",
"0.6053684",
"0.602697",
"0.5963562",
"0.59115314",
"0.58982813",
"0.5862156",
"0.5861341",
"0.5852343",
"0.58294475",
"0.5817756... | 0.80301946 | 0 |
Register the slider with this parent widget | def on_slider(self, instance, value):
self.slider.bind(value=self.update_proxy)
self.bind(pos=self.hack_position)
self.slider.bind(pos=self.hack_position) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slider(self, parent, variable, low, high, label):\n widget = Scale(parent, orient='horizontal',\n from_=low, to=high, # range of slider\n # tickmarks on the slider \"axis\":\n tickinterval=(high-low)/5.0,\n # the steps of the counter above the slider:\n reso... | [
"0.6726716",
"0.6464478",
"0.6321544",
"0.620911",
"0.6139864",
"0.61175656",
"0.6081543",
"0.6059349",
"0.5923887",
"0.58818233",
"0.5880173",
"0.584921",
"0.5826456",
"0.58105385",
"0.5807407",
"0.5802929",
"0.57598364",
"0.5745984",
"0.5733525",
"0.5701902",
"0.5675679",
... | 0.64797753 | 1 |
Call back to hsv sliders | def on_hsv_slide(self,h,s,v):
if not self.active:
return
hue = h / 100.0
sat = s / 100.0
val = v / 100.0
self.hsv = colormodel.HSV(hue, sat, val)
temp = a3.hsv_to_rgb(self.hsv)
assert (temp == None or type(temp) == colormodel.RGB), 'hsv_to_rgb does not... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slider_action(self, sender):\n self.r = self.rslider.value\n self.g = self.gslider.value\n self.b = self.bslider.value\n self.preview.background_color = self.rgb\n self.colorlabel.text = self.hexcode",
"def ct_slider_value_changed(self):\n for (x, slider) in enumerat... | [
"0.6486781",
"0.63806134",
"0.63726234",
"0.625302",
"0.5907185",
"0.5888957",
"0.5856775",
"0.5827766",
"0.5827567",
"0.580906",
"0.57934964",
"0.5773385",
"0.5756233",
"0.57184124",
"0.57120323",
"0.5695729",
"0.56683296",
"0.564698",
"0.5633634",
"0.5592048",
"0.55850995",... | 0.6754454 | 0 |
Format and return lines from the output of dmesg. | def human_dmesg(source=None, max_lines=20):
formatted_dmesg = []
# Reversing the array shows the newest lines first, to stay consistent
# with how other logs are presented.
try:
dmesg_data = exec_process(['dmesg', '-T'], True).split('\n')
dmesg_data.reverse()
for line in dmesg_data:
if not l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_dmesg_log(host=None):\r\n if host:\r\n ret_out = host.run('dmesg').stdout\r\n return ret_out\r\n else:\r\n ret_out = utils.run('dmesg').stdout\r\n return ret_out",
"def read_linelog():",
"def dumpDmesg(self):\n pass",
"def read_syslog():\n lines = []\n with... | [
"0.6757594",
"0.59532964",
"0.59326035",
"0.56777763",
"0.54108447",
"0.5383906",
"0.53356045",
"0.53201014",
"0.52892894",
"0.5279133",
"0.5222678",
"0.5219982",
"0.5216076",
"0.5173431",
"0.51427615",
"0.5130245",
"0.51280516",
"0.5125033",
"0.5106825",
"0.509392",
"0.50909... | 0.6822441 | 0 |
A static method to merge two lexemes | def merge_lexemes(source: str, target: str, login: _Login | None = None, summary: str | None = None, is_bot: bool = False, **kwargs: Any) -> dict:
params = {
'action': 'wblmergelexemes',
'fromid': source,
'toid': target,
'format': 'json'
}
if summary:
para... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stemset_combiner(stempool1, stempool2):\n return stempool1.stemset | stempool2.stemset",
"def sentence_encoding_rnn_phi(t1, t2):\n return (t1.leaves(), t2.leaves())",
"def __radd__(self, other):\n return Token(\n other + self.text, self.position - len(other), self.category)",
"def... | [
"0.5477292",
"0.54750645",
"0.54190856",
"0.5407232",
"0.540251",
"0.536537",
"0.526485",
"0.5264185",
"0.5249599",
"0.523565",
"0.5216812",
"0.52129334",
"0.52117616",
"0.5202586",
"0.51841414",
"0.51818204",
"0.51625794",
"0.5160106",
"0.515256",
"0.5100521",
"0.50957334",
... | 0.5588235 | 0 |
A method which allows for retrieval of a list of Wikidata entities. The method generates a list of tuples where the first value in the tuple is the entity's ID, whereas the second is the new instance of a subclass of BaseEntity containing all the data of the entity. This is most useful for mass retrieval of entities. | def generate_entity_instances(entities: str | list[str], allow_anonymous: bool = True, **kwargs: Any) -> list[tuple[str, BaseEntity]]:
from wikibaseintegrator.entities.baseentity import BaseEntity
if isinstance(entities, str):
entities = [entities]
assert isinstance(entities, list)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_datastore(entity):\n if not entity:\n return None\n if isinstance(entity, list):\n entity = entity.pop()\n return [entity['title'],entity['author'],entity['date'],entity['recipe']]",
"def get_entities(self, clean=False):\n return list(self.iter_entities(clean=clean))",
... | [
"0.64230967",
"0.61319405",
"0.6031639",
"0.5971305",
"0.59133303",
"0.5893585",
"0.5877375",
"0.58596236",
"0.58466774",
"0.580628",
"0.5791746",
"0.57809865",
"0.5752515",
"0.57504046",
"0.57445014",
"0.57344115",
"0.5728816",
"0.57220846",
"0.5711131",
"0.56942236",
"0.565... | 0.6743911 | 0 |
Return a user agent string suitable for interacting with the Wikibase instance. | def get_user_agent(user_agent: str | None) -> str:
from wikibaseintegrator import __version__
wbi_user_agent = f"WikibaseIntegrator/{__version__}"
if user_agent is None:
return_user_agent = wbi_user_agent
else:
return_user_agent = user_agent + ' ' + wbi_user_agent
return r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_agent(self):\n version = '{0}.{1}.{2}'.format(sys.version_info[0], sys.version_info[1], sys.version_info[2])\n return \"PAYNL/SDK/{0} Python/{1} ({2})\".format(self.client_version, version, sys.hexversion)",
"def user_agent(self) -> str:\n return self.root_hartree.user_agent",
"de... | [
"0.7373288",
"0.7214154",
"0.71819866",
"0.71819866",
"0.7149229",
"0.7119391",
"0.702122",
"0.70164865",
"0.69798416",
"0.6925093",
"0.68710935",
"0.6868542",
"0.6849086",
"0.6776181",
"0.6752655",
"0.66153026",
"0.6526037",
"0.64982563",
"0.6452998",
"0.6432067",
"0.6342217... | 0.7788731 | 0 |
Displays 2D crosssections of a 3D image along all 3 axis | def show_brain(img, cut_coords=None,
figsize=(10,5), cmap="nipy_spectral",
draw_cross = True,
return_fig = False
):
if(isinstance(img, str) and os.path.isfile(img)):
img_arr = load_nifti(img)
elif(isinstance(img, nibabel.Nifti1Image)):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_current_pair_by_3d_slice(iS,iT):\n import matplotlib.pyplot as plt\n import easyreg.viewers as viewers\n fig, ax = plt.subplots(2,3)\n plt.setp(plt.gcf(), 'facecolor', 'white')\n plt.style.use('bmh')\n\n ivsx = viewers.ImageViewer3D_Sliced(ax[0][0], iS, 0, 'source X', True)\n ivsy = v... | [
"0.6118277",
"0.60820824",
"0.6006694",
"0.5964072",
"0.59441346",
"0.5893757",
"0.5872753",
"0.58612025",
"0.5786242",
"0.5712049",
"0.56787944",
"0.5658226",
"0.5636408",
"0.5630997",
"0.5592465",
"0.55571723",
"0.55545217",
"0.5547363",
"0.55383724",
"0.5521879",
"0.550305... | 0.6111827 | 1 |
This function is modified from django.forms.models.model_to_dict. It can also return uneditable fields when SETTINGS.OMIT_UN_EDITABLE_FIELDS = False. | def model_to_dict(instance, fields=None, exclude=None):
opts = instance._meta
data = {}
omit = getattr(SETTINGS, 'OMIT_UN_EDITABLE_FIELDS', False)
for f in chain(opts.concrete_fields, opts.private_fields, opts.many_to_many):
if omit and not getattr(f, 'editable', False):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_readonly_fields(self, request, obj=None):\n return [field.name for field in self.model._meta.fields]",
"def get_readonly_fields(self, request, obj=None):\n if self.readonly_model:\n return fields_for_model(model=self.model)\n if obj is None:\n return list(self.a... | [
"0.6307178",
"0.6280546",
"0.6266776",
"0.6190274",
"0.6138479",
"0.60863304",
"0.60863304",
"0.60848",
"0.6051414",
"0.604039",
"0.6031091",
"0.60262895",
"0.6009271",
"0.6008673",
"0.5987545",
"0.5934254",
"0.5926652",
"0.5916412",
"0.5908221",
"0.58884656",
"0.5886619",
... | 0.72209966 | 0 |
The quadrant in the cartesian plane this point is located in. | def quadrant(self) -> Quadrant:
if self.x > 0:
if self.y > 0:
return Quadrant.I
if self.y < 0:
return Quadrant.IV
if self.x < 0:
if self.y > 0:
return Quadrant.II
if self.y < 0:
return Quadra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _determine_quadrant(self, row, column) -> QuadrantEnum:\n if row < 4 and column < 5:\n return QuadrantEnum.TOP_LEFT\n elif row < 4 and column >= 5:\n return QuadrantEnum.TOP_RIGHT\n elif row >= 4 and column < 5:\n return QuadrantEnum.BOTTOM_LEFT\n el... | [
"0.6771368",
"0.65648866",
"0.6534175",
"0.6522615",
"0.6497287",
"0.6482107",
"0.6441157",
"0.6324514",
"0.62548697",
"0.614596",
"0.6116718",
"0.6105604",
"0.60872346",
"0.60645896",
"0.6024275",
"0.6012685",
"0.59936947",
"0.59838605",
"0.59789324",
"0.59648126",
"0.592141... | 0.78478485 | 0 |
A tuple of this point's x and y coordinates. | def xy(self) -> Tuple[float, float]:
return (self.x, self.y) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coordinates(self) -> Tuple[int, int]:\n return self.x, self.y",
"def xy(self) -> Tuple[int, int]:\n return self._x, self._y",
"def get_point(self):\n return self._x, self._y",
"def coordinates(self) -> Tuple[float, float, float, float, float]:\n return (self.x, self.y, self.x ... | [
"0.8953007",
"0.8937962",
"0.86783415",
"0.86111736",
"0.8321993",
"0.82544005",
"0.82386565",
"0.82255226",
"0.8197248",
"0.80881447",
"0.8072225",
"0.79811084",
"0.7958825",
"0.7913098",
"0.79067475",
"0.79028577",
"0.7887499",
"0.7886007",
"0.7886007",
"0.78790206",
"0.787... | 0.90129477 | 0 |
An iterator over x and y coordinates. | def __iter__(self) -> Iterable[Tuple[float, float]]:
return iter([self.x, self.y]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n pt = (self.x, self.y)\n for i in pt:\n yield i",
"def iter_coordinates(self):\n for coord in self.position:\n yield coord",
"def __iter__(self):\n yield self._x\n yield self._y",
"def __iter__(self):\n yield self.x\n ... | [
"0.8114274",
"0.7996599",
"0.76811117",
"0.7629678",
"0.74141836",
"0.7341875",
"0.727359",
"0.7255214",
"0.724903",
"0.7178277",
"0.7174249",
"0.704348",
"0.70082766",
"0.69353855",
"0.6815294",
"0.68150526",
"0.66570723",
"0.65559846",
"0.65280896",
"0.6511601",
"0.6490005"... | 0.80211693 | 1 |
Raise each coordinate by `exponent` and return a new Point. | def __pow__(self, exponent: float) -> PointType:
return Point(self.x ** exponent, self.y ** exponent) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ipow__(self, exponent: float) -> PointType:\n self.x **= exponent\n self.y **= exponent\n return self",
"def __pow__(self, exponent):\n return type(self)(self.parent(),\n self._simplify(pow(self._express, exponent)))",
"def __pow__(self, exponent):\n ... | [
"0.7288927",
"0.61586154",
"0.61224526",
"0.6076266",
"0.60731536",
"0.60344225",
"0.60247",
"0.5891363",
"0.58524084",
"0.5728584",
"0.57192135",
"0.5697429",
"0.56703067",
"0.562234",
"0.5572597",
"0.5537855",
"0.5530972",
"0.55304945",
"0.5511318",
"0.5456827",
"0.5404782"... | 0.73620385 | 0 |
Raise each coordinate by `exponent` inplace and return self. | def __ipow__(self, exponent: float) -> PointType:
self.x **= exponent
self.y **= exponent
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __pow__(self, exponent):\n return type(self)(self.parent(),\n self._simplify(pow(self._express, exponent)))",
"def __pow__(self, exponent: int):\n\t\tif exponent < 0:\n\t\t\traise ValueError(\"Negative powers not supported\")\n\t\telif exponent == 0:\n\t\t\treturn SquareMatrix... | [
"0.68471605",
"0.68286675",
"0.6560746",
"0.63714254",
"0.6354218",
"0.63479114",
"0.6300082",
"0.6216885",
"0.6170165",
"0.60661626",
"0.5901398",
"0.58412004",
"0.58182156",
"0.57910985",
"0.5763578",
"0.5707981",
"0.56934494",
"0.5692054",
"0.5682847",
"0.5680657",
"0.5677... | 0.6919949 | 0 |
Apply absolute value to each coordinate and return a new Point. | def __abs__(self) -> PointType:
return Point(abs(self.x), abs(self.y)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_absolute(self, points):\r\n\r\n # remember if we got a list\r\n is_list = isinstance(points, list)\r\n\r\n points = ensure_numeric(points, num.float)\r\n if len(points.shape) == 1:\r\n # One point has been passed\r\n msg = 'Single point must have two elemen... | [
"0.6606349",
"0.6376209",
"0.6323174",
"0.61907077",
"0.616326",
"0.61606514",
"0.61422604",
"0.61412853",
"0.606106",
"0.6055513",
"0.605538",
"0.6054866",
"0.6054316",
"0.6041184",
"0.6007135",
"0.59953696",
"0.59925735",
"0.59842604",
"0.59756476",
"0.59686637",
"0.5933870... | 0.6905627 | 0 |
Inverts each coordinate and return a new Point. | def __invert__(self) -> PointType:
return Point(~self.x, ~self.y) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __invert__(self):\n \n return Vector(-self.y, self.x)",
"def inverse(self):\n def inv(v):\n v[0], v[1] = v[1] , v[0]\n for v in [self.point1 , self.pointN , self.unitv, self.normalv]:\n inv(v)\n\n self.points = numpy.roll(self.points,1,axis=1)\n ... | [
"0.6987597",
"0.6770105",
"0.6633013",
"0.6607589",
"0.6598548",
"0.6497842",
"0.6492611",
"0.643507",
"0.6412205",
"0.6395882",
"0.6278318",
"0.62737286",
"0.6256399",
"0.62236995",
"0.6181065",
"0.617367",
"0.6169034",
"0.6162642",
"0.61406845",
"0.6122141",
"0.6090737",
... | 0.7646539 | 0 |
Return the floating point squared distance between self and other. If other is not given, the squared distance from self to the origin is returned. | def distance_squared(self, other: PointOrIterable = None) -> float:
return sum((((other or Point()) - self) ** 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 distance(self, other: PointOrIterable = None) -> float:\n return (self.distance_squared(other or Poin... | [
"0.80755734",
"0.80645823",
"0.7802913",
"0.78016543",
"0.76762885",
"0.7650648",
"0.7602126",
"0.7595",
"0.75585",
"0.7540435",
"0.7521282",
"0.7496888",
"0.7477617",
"0.74663025",
"0.74459094",
"0.7387185",
"0.73853767",
"0.7372873",
"0.7359835",
"0.73340523",
"0.7304411",
... | 0.8365737 | 0 |
Return a floating point value indicating the winding direction of the points [self, b, c]. If ccw 0, counter clockwise winding If ccw == 0, the three points are colinear | def ccw(self, b: PointOrIterable, c: PointOrIterable) -> float:
try:
return ((b.x - self.x) * (c.y - self.y)) - ((c.x - self.x) * (b.y - self.y))
except AttributeError:
pass
return ((b[0] - self.x) * (c[1] - self.y)) - ((c[0] - self.x) * (b[1] - self.y)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wind_direction(self):\n names = ['anc_wind_direction']\n return self.sensor.get_with_fallback('wind_direction', names)",
"def wind_direction(self):\n return self.flow_field.wind_direction",
"def ccw(p1, p2, p3):\n return (p2[0] - p1[0])*(p3[1] - p1[1]) - (p2[1] - p1[1])*(p3[0] - p1[... | [
"0.62705654",
"0.623689",
"0.6155503",
"0.60985595",
"0.60472417",
"0.60310966",
"0.5945787",
"0.5914404",
"0.5833745",
"0.58321136",
"0.5825404",
"0.5813546",
"0.5805641",
"0.57567066",
"0.56856924",
"0.56779724",
"0.56537074",
"0.56489015",
"0.56035715",
"0.56031066",
"0.55... | 0.6929871 | 0 |
Return True if the angle [self, b, c] has counter clockwise winding, else False. Raises the exception `ColinearPoints` if the points compose a line. | def is_ccw(self, b: PointOrIterable, c: PointOrIterable) -> bool:
result = self.ccw(b, c)
if result == 0:
raise ColinearPoints(self, b, c)
return result > 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_colinear(self, b: PointType, c: PointType) -> bool:\n return self.ccw(b, c) == 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_ccw(points):\n points = np.asanyarray(points, dtype=np.float64)\n\n if (len(points.shape) != 2 or\n ... | [
"0.7609235",
"0.7557099",
"0.6990511",
"0.68427503",
"0.683419",
"0.68226945",
"0.6582589",
"0.64759666",
"0.64759666",
"0.64698136",
"0.6272435",
"0.6197709",
"0.6191934",
"0.61795664",
"0.61134416",
"0.60998017",
"0.6020702",
"0.59578556",
"0.59384805",
"0.58934057",
"0.587... | 0.7955458 | 0 |
Return a new Point midway between `self` and `other`. If other is not given, the midpoint between self and the origin is returned. | def midpoint(self, other: PointType = None) -> PointType:
return (self + (other or Point())) / 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mid_point(a: Point, b: Point) -> Point:\n return Point((a.x + b.x) / 2, (a.y + b.y) / 2)",
"def halfway(self, target):\n mx = (self.x + target.x) / 2\n my = (self.y + target.y) / 2\n return Point(mx, my)",
"def halfway(self, target):\r\n mx = (self.x + target.x)/2\r\n ... | [
"0.6676469",
"0.60114807",
"0.6004466",
"0.5985635",
"0.5985635",
"0.5985635",
"0.59546316",
"0.5879427",
"0.5844241",
"0.5816637",
"0.580738",
"0.58004814",
"0.5790193",
"0.57144624",
"0.5713127",
"0.571122",
"0.56574553",
"0.56470776",
"0.5636528",
"0.5634694",
"0.5630058",... | 0.8038037 | 0 |
True if self is bounded by the points [p, q], else False The bounds are checked by less than or equal to (<=) so self is considered between if it resides on any of the lines constructed using [p,q]. | def between(self, p: PointType, q: PointType) -> bool:
i = min(p.x, q.x) <= self.x <= max(p.x, q.x)
j = min(p.y, q.y) <= self.y <= max(p.y, q.y)
return i and j | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inside(self, p: PointType, q: PointType) -> bool:\n\n # XXX re-implement with ccw and a list of points instead of a pair\n\n i = min(p.x, q.x) < self.x < max(p.x, q.x)\n j = min(p.y, q.y) < self.y < max(p.y, q.y)\n\n return i and j",
"def onSegment(self, p, q, r):\n if ((q.... | [
"0.76864725",
"0.72723484",
"0.7039567",
"0.70286196",
"0.6840898",
"0.67668295",
"0.6696259",
"0.6675997",
"0.6499764",
"0.6421155",
"0.6416931",
"0.6390172",
"0.63788533",
"0.63346475",
"0.6312514",
"0.6312514",
"0.6284577",
"0.62795115",
"0.6248119",
"0.62449133",
"0.62267... | 0.80105644 | 0 |
True if self is bounded by the points (p, q), else False The bounds are checked by less than (<) so self is considered inside if it does not reside on any of the lines constructed using (p,q). | def inside(self, p: PointType, q: PointType) -> bool:
# XXX re-implement with ccw and a list of points instead of a pair
i = min(p.x, q.x) < self.x < max(p.x, q.x)
j = min(p.y, q.y) < self.y < max(p.y, q.y)
return i and j | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def between(self, p: PointType, q: PointType) -> bool:\n\n i = min(p.x, q.x) <= self.x <= max(p.x, q.x)\n j = min(p.y, q.y) <= self.y <= max(p.y, q.y)\n\n return i and j",
"def onSegment(self, p, q, r):\n if ((q.x <= max(p.x, r.x)) and (q.x >= min(p.x, r.x)) and\n (q.y ... | [
"0.79599667",
"0.737079",
"0.711591",
"0.70875436",
"0.6964512",
"0.6917188",
"0.68929106",
"0.68929106",
"0.6871995",
"0.68415177",
"0.6788423",
"0.67268765",
"0.67224866",
"0.6712168",
"0.6707262",
"0.66991687",
"0.66991687",
"0.66832346",
"0.6665249",
"0.6620001",
"0.65715... | 0.8203387 | 0 |
Get local plan with defined lookahead distance | def get_local_plan(self, ind):
size = len(self.global_plan.poses)
if ind < 0 or ind >= size:
raise ValueError("ind must be between 0 and %d"%size)
start = self.global_plan.poses[ind].pose
local_path = Path()
found_ind = None
for i in range(ind, size):
candidate = self.global_pla... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lookahead_point(self):\n lookahead_target_dist = self.lookahead_dist #+ (1 + self.curr_v)\n\n if self.path_point_idx == len(self.current_path) - 1 or self.path_point_idx == -1:\n #End of path, no more lookahead\n return self.path_point\n\n prev_pt = self.current_p... | [
"0.5957022",
"0.59043604",
"0.5696798",
"0.55463475",
"0.5463718",
"0.5410066",
"0.5407258",
"0.5370748",
"0.5359951",
"0.52572113",
"0.521189",
"0.52114105",
"0.5210574",
"0.520301",
"0.5192764",
"0.5162559",
"0.5125558",
"0.50986946",
"0.5083363",
"0.50627804",
"0.5048645",... | 0.6283821 | 0 |
Reset local planner variables | def reset(self):
self.robot_path_ind = 0
self.goal_path_ind = None
self.global_plan = Path() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset():\n\n global optimizer_data\n global optimizer_len\n\n optimizer_data = []\n optimizer_len = 0\n return",
"def cleanup_and_reset(self):\n self.mem.set(self.mem.META_PLAN, None)\n self.mem.set(self.mem.META_GOALS, None)\n self.mem.set(self.mem.META_CURR_GOAL, None)",... | [
"0.73573047",
"0.72122705",
"0.7178374",
"0.6857298",
"0.6857298",
"0.6857298",
"0.68345904",
"0.67704684",
"0.6718428",
"0.66984993",
"0.669352",
"0.669352",
"0.66802955",
"0.6661716",
"0.6655433",
"0.66490394",
"0.6638487",
"0.66238254",
"0.6584989",
"0.6580846",
"0.6580699... | 0.7329392 | 1 |
Calculate nearest index from local plan | def calc_nearest_ind(self, robot_pose):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(self) -> None:\n self._nearest_point = kd.Tree(self._points).nearest_point",
"def nearest_sparse(self, query):\n self.best_dist = float(\"inf\")\n self.best_element = None\n self._register_best_element = self._register_best_element_single \n self._nearest_sparse_recur... | [
"0.666966",
"0.6518415",
"0.6329833",
"0.62365556",
"0.6211519",
"0.6202459",
"0.61500686",
"0.6134303",
"0.6106491",
"0.6095605",
"0.6073815",
"0.60622567",
"0.60303104",
"0.59884435",
"0.5978137",
"0.59692085",
"0.59623927",
"0.595972",
"0.5958901",
"0.59389544",
"0.5936738... | 0.6538584 | 1 |
Initialise the HyperStream class. This starts the logger, loads the config files, connects to the main mongodb, and initialises the managers (channels, plates, workflows). | def __init__(self, loglevel=logging.INFO, file_logger=True, console_logger=True, mqtt_logger=None,
config_filename="hyperstream_config.json"):
self.config_filename = config_filename
self._session = None
self.parameters = dict(
loglevel=loglevel,
file_log... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize( self, logger, loop, netconf_ip, netconf_port, statistics,\n xml_to_json_translator):\n self.init_stream_handler(logger, loop, \n netconf_ip, netconf_port, statistics, xml_to_json_translator)",
"def initialize(self, logger, loop, netconf_ip, netconf_port, stati... | [
"0.67473614",
"0.670801",
"0.6669442",
"0.66132694",
"0.6499854",
"0.64482814",
"0.64375705",
"0.6405556",
"0.6398037",
"0.6321428",
"0.6306508",
"0.6279179",
"0.6277945",
"0.6263203",
"0.62060374",
"0.62049055",
"0.61645144",
"0.61528885",
"0.61439127",
"0.6142933",
"0.61402... | 0.78285134 | 0 |
Entry point. Using the "with" syntax starts a new session | def __enter__(self):
self.new_session()
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def session(self):",
"def session(project, engine_sessionmaker, connection):\n _, Session = engine_sessionmaker\n\n try:\n session = Session(bind=connection)\n yield session\n finally:\n session.close()",
"def __enter__(self):\r\n if not self._session:\r\n self.r... | [
"0.7039566",
"0.6990874",
"0.67499155",
"0.6730254",
"0.67289436",
"0.6700694",
"0.6683485",
"0.65724987",
"0.6554034",
"0.6518529",
"0.6489163",
"0.64856803",
"0.6430929",
"0.6397401",
"0.6395417",
"0.6392703",
"0.63916653",
"0.63534707",
"0.63483596",
"0.63387537",
"0.63288... | 0.749841 | 0 |
Cleanup operations. Closes the session and flushes and closes the loggers | def _cleanup(self):
if self.current_session is not None:
self.current_session.close()
self.current_session = None
for handler in list(self.logger.root_logger.handlers):
self.logger.root_logger.removeHandler(handler)
handler.flush()
handler.clo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_up(self):\n self.session.close()",
"def cleanup(self):\n async def close_session():\n await self.logi.close()\n\n self.loop.run_until_complete(close_session())\n\n self.loop.close()\n self.logi = None\n if os.path.isfile(CACHE_FILE):\n os.... | [
"0.8010654",
"0.76645267",
"0.75910866",
"0.75116664",
"0.7349199",
"0.7326595",
"0.73215795",
"0.7284442",
"0.7192665",
"0.7167402",
"0.71294385",
"0.7050958",
"0.7023023",
"0.7016426",
"0.69936794",
"0.69187576",
"0.6898732",
"0.6898154",
"0.6891282",
"0.6827511",
"0.681629... | 0.80990434 | 0 |
Get the current session | def current_session(self):
return self._session | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_session(self):\n if self.session is not None:\n return self.session\n else:\n return None",
"def get_session(self):\n return self.session",
"def session(self):\n return self.session_store.get_session()",
"def session(self):\n return sel... | [
"0.8996255",
"0.85965174",
"0.82989895",
"0.82989895",
"0.82958096",
"0.8282755",
"0.8281556",
"0.82587373",
"0.8178331",
"0.80580115",
"0.79930717",
"0.7990043",
"0.79854894",
"0.7956763",
"0.78924745",
"0.7880293",
"0.78327733",
"0.780845",
"0.78052527",
"0.78052527",
"0.77... | 0.8756857 | 1 |
Set the current session | def current_session(self, session):
if self._session is None:
self._session = session
else:
if session is None or self._session.session_id != session.session_id:
self._session.active = False
self._session = session | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_session(session):\n\n global session_\n session_ = session\n import observatory.api.server.api as api\n\n api.session_ = session",
"def setSession( self, name, value, REQUEST=None, cookie=None ):\n SetSessionValue( self, name, value, REQUEST, cookie )",
"def fusion_api_set_active_ses... | [
"0.73562306",
"0.7294437",
"0.7265423",
"0.7152156",
"0.7137305",
"0.69370335",
"0.68532306",
"0.68211675",
"0.67735296",
"0.67608225",
"0.67585516",
"0.6742993",
"0.66266817",
"0.6609575",
"0.65909326",
"0.6488937",
"0.6426722",
"0.6381807",
"0.63759553",
"0.63736165",
"0.63... | 0.7321693 | 1 |
Clears all stored sessions, optionally excluding active sessions | def clear_sessions(self, inactive_only=True, clear_history=False):
Session.clear_sessions(self, inactive_only, clear_history) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_sessions():\n call_command(\"clearsessions\")",
"def clear_session(self):\n self.mongo_database.cache.delete_many({\"session_id\": self.session_id})",
"def clear_session(self):\n self.session_mgr.clear_session()",
"def clearSessionWithoutLoggingOut(request):\n for key in list(re... | [
"0.8116094",
"0.7734233",
"0.75402987",
"0.7404016",
"0.717296",
"0.7071539",
"0.6903001",
"0.681045",
"0.671897",
"0.66833776",
"0.66807574",
"0.66768897",
"0.6660443",
"0.66087145",
"0.6586084",
"0.65702164",
"0.6561426",
"0.65318245",
"0.6481722",
"0.64585",
"0.6429566",
... | 0.7810983 | 1 |
Add the workflow to the workflow manager | def add_workflow(self, workflow):
self.workflow_manager.add_workflow(workflow) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_workflow(workflow):\n\n launchpad = LaunchPad.auto_load()\n launchpad.add_wf(workflow)",
"def add_workflow(workflow):\n\n launchpad = LaunchPad.auto_load()\n launchpad.add_wf(workflow)",
"def add_workflow(self, workflow):\n self._data_dict[self.KEY_BI_WORKFLOWS].appen... | [
"0.82768464",
"0.82768464",
"0.7846967",
"0.69754046",
"0.67232186",
"0.6609379",
"0.66010517",
"0.6353788",
"0.63196826",
"0.62862545",
"0.62820166",
"0.6208596",
"0.606798",
"0.6051274",
"0.5934013",
"0.5899704",
"0.5891364",
"0.58334327",
"0.5800309",
"0.5752983",
"0.57394... | 0.89757365 | 0 |
Function to populate factory functions for the tools and factors for ease of access. | def populate_tools_and_factors(self):
for tool_channel in self.channel_manager.tool_channels:
if tool_channel.channel_id == "tools":
# These are the core tools
setattr(self, "tools", ToolContainer())
setattr(self, "factors", FactorContainer())
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_factory_function(tool_func):\n base = tool_function.__bases__[0]\n if base == Tool:\n def tool_factory_function(sources, alignment_node=None, **parameters):\n \"\"\"\n F... | [
"0.7297803",
"0.6938939",
"0.68173605",
"0.65987945",
"0.6445594",
"0.64262986",
"0.63660765",
"0.6365673",
"0.6329075",
"0.60519093",
"0.6003902",
"0.594429",
"0.5937257",
"0.5937257",
"0.59068316",
"0.58427525",
"0.58331877",
"0.57943475",
"0.5717975",
"0.57174146",
"0.5658... | 0.7389015 | 0 |
Load a model based on its name model.name and the checkpoint iteration step | def load_model_by_name(model, global_step, device=None, path="/scratch/users/zucks626/ADNI/IPMI/checkpoints/"):
# path = "/scratch/users/zucks626/ADNI/ae_cls/checkpoints/"
file_path = path + model.name + "/" + 'model-{:05d}.pt'.format(global_step)
state = torch.load(file_path, map_location=device)
m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_model(self, checkpoint):\n print(f'Load parameters from {checkpoint}')\n epoch = re.match(r\"[0-9]*\", os.path.basename(checkpoint)).group(0)\n self.epoch_i = int(epoch)\n self.model.load_state_dict(torch.load(checkpoint))",
"def maybe_load_model(name, split_num, checkpoint_d... | [
"0.78126186",
"0.75728905",
"0.75673294",
"0.7478123",
"0.74248904",
"0.7383905",
"0.7324118",
"0.7305647",
"0.7303674",
"0.73004097",
"0.7277768",
"0.7242201",
"0.7198431",
"0.71938014",
"0.71598846",
"0.712388",
"0.7121004",
"0.7102762",
"0.7091739",
"0.70794976",
"0.707811... | 0.81570524 | 0 |
Computes a embedding given wide feature indices and values If wide_ftrs_sp_val is specified, users should keep consistency between wide_ftrs_sp_idx and wide_ftrs_sp_val the value of wide_ftrs_sp_idx[i] should be wide_ftrs_sp_val[i]. | def __init__(self,
num_wide_sp: int,
wide_ftrs_sp_idx: tf.Tensor,
sp_emb_size: int,
wide_ftrs_sp_val: tf.Tensor = None,
padding_idx: int = 0,
initializer=tf.contrib.layers.xavier_initializer()):
wide_ftrs_sp_id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_embedding_score_per_record(self, wide_ftrs_idx_with_value_per_record):\n\n # Split idx and val back\n wide_ftrs_sp_idx, wide_ftrs_sp_val = tf.split(wide_ftrs_idx_with_value_per_record, 2, axis=-1)\n wide_ftrs_sp_idx = tf.cast(wide_ftrs_sp_idx, dtype=tf.int64)\n\n # Transfor... | [
"0.75221336",
"0.5563098",
"0.5548879",
"0.55042124",
"0.5398143",
"0.5337651",
"0.5324334",
"0.5312726",
"0.5289014",
"0.5243177",
"0.51948035",
"0.51796144",
"0.5149877",
"0.51468027",
"0.51436365",
"0.51356083",
"0.5126982",
"0.51263756",
"0.5117215",
"0.51115566",
"0.5104... | 0.7290438 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.