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 |
|---|---|---|---|---|---|---|
Here we make sure that the variational_expectations gives the same result as logp if the latent function has no uncertainty. | def test_var_exp(self):
with self.test_context() as session:
test_setups, F, feed = self.prepare()
for test_setup in test_setups:
l = test_setup.likelihood
y = test_setup.Y
l.compile()
r1 = session.run(l.logp(F, y), feed_dic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MvNormalLogp():\n cov = pt.matrix(\"cov\")\n cov.tag.test_value = floatX(np.eye(3))\n delta = pt.matrix(\"delta\")\n delta.tag.test_value = floatX(np.zeros((2, 3)))\n\n cholesky = Cholesky(lower=True, on_error=\"nan\")\n\n n, k = delta.shape\n n, k = f(n), f(k)\n chol_cov = cholesky(cov... | [
"0.6345779",
"0.63086545",
"0.6226823",
"0.62114143",
"0.6107472",
"0.5968832",
"0.59399563",
"0.59043485",
"0.5896922",
"0.5892136",
"0.58435327",
"0.58298254",
"0.5828605",
"0.57787687",
"0.5742076",
"0.57280934",
"0.571894",
"0.5713231",
"0.5713231",
"0.5713231",
"0.571323... | 0.75908834 | 0 |
SoftMax assumes the class is given as a label (not, e.g., onehot encoded), and hence just uses the first column of Y. To prevent silent errors, there is a tf assertion that ensures Y only has one dimension. This test checks that this assert works as intended. | def test_softmax_y_shape_assert(session_tf):
F, Y, feed = _prepare(dimF=5, dimY=2)
l = gpflow.likelihoods.SoftMax(5)
l.compile()
try:
session_tf.run(l.logp(F, Y), feed_dict=feed)
except tf.errors.InvalidArgumentError as e:
assert "assertion failed" in e.message | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_softmax(self):\n activation_name = 'Softmax'\n args = {}\n\n activation = activation_factory.create(activation_name, **args)\n self.assertEqual(activation._get_name(), activation_name)\n\n x = torch.empty(10, 2)\n y = activation(x)\n assert_array_equal(y, t... | [
"0.660308",
"0.6543498",
"0.6429497",
"0.63353556",
"0.63341177",
"0.63341177",
"0.6327993",
"0.62569237",
"0.6248691",
"0.62324095",
"0.62258637",
"0.6218934",
"0.61596775",
"0.6145021",
"0.6144675",
"0.6115845",
"0.61103374",
"0.6093086",
"0.60901946",
"0.60888225",
"0.6085... | 0.6929215 | 0 |
This test is based on the observation that for symmetric inputs the class predictions must have equal probability. | def testSymmetric(self):
with self.test_context() as session:
nClasses = 5
nPoints = 10
tolerance = 1e-4
epsilon = 1e-3
F = tf.placeholder(settings.float_type)
F_data = np.ones((nPoints, nClasses))
feed = {F: F_data}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision_score(y_true, y_pred):\n return ((y_true == 1) * (y_pred == 1)).sum() / (y_pred == 1).sum()",
"def test(self, samples):\n prediction_errors = np.zeros(len(samples), int)\n predictions = np.zeros(len(samples), int)\n class_predictions = np.zeros(self.class_count)\n \n ... | [
"0.6411165",
"0.6401764",
"0.6343314",
"0.6331978",
"0.6311628",
"0.62828445",
"0.628076",
"0.625104",
"0.62279147",
"0.62254727",
"0.62064314",
"0.6204081",
"0.61830467",
"0.61780626",
"0.6162933",
"0.61626613",
"0.616172",
"0.61531955",
"0.6128566",
"0.61269164",
"0.6120333... | 0.657835 | 0 |
Checks that eps K1 changes when epsilon changes. This used to not happen and had to be manually changed. | def testEpsK1Changes(self):
with self.test_context() as session:
initial_eps = 1e-3
num_classes = 5
rm = gpflow.likelihoods.RobustMax(num_classes, initial_eps)
expected_eps_k1 = initial_eps / (num_classes - 1.)
actual_eps_k1 = session.run(rm._eps_K1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def epsilon():\n return _EPSILON",
"def update_epsilon(self):\n\t\tif self.epsilon > self.epsilon_min:\n\t\t\tself.epsilon *= self.epsilon_decay",
"def test_pk1x(self):\n assert_allclose(pkolmogorov1x(0.06, 30), 0.2248113)",
"def test_pk1x(self):\n self.assertFloatEqual(pkolmogorov1x(0.06, 30)... | [
"0.637501",
"0.6295013",
"0.61520755",
"0.6145946",
"0.60850954",
"0.6059371",
"0.602075",
"0.5998082",
"0.5970382",
"0.59418136",
"0.59127927",
"0.5874061",
"0.5870049",
"0.5818003",
"0.58130467",
"0.58036387",
"0.5781205",
"0.57574016",
"0.5718404",
"0.5693706",
"0.568116",... | 0.7944699 | 0 |
Test the greedy strategy of the AI. | def test_greedy_strategy():
tiles = Tiles(800, 100)
board = Board(800, 100, tiles)
player = Player('Alfred', board, 'black')
ai = AI(board, player)
for i in range(board.count//2 + 1, board.count - 1):
board.add_tile(i, board.count//2 - 1, 'black')
assert ai.greedy_strategy()[0] == (board... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_search():\n\tgamma = 0.7\n\talpha = 0.3\n\tepsilon = 1\n\texploration_rate_decay = 0.87\n\n\tmax_tries = 10\n\tbest_score = -1000\n\tscores = {}\n\n\tfor attempt in range(max_tries):\n\n\t\tagent = Q_Agent(epsilon=1, alpha=alpha, gamma=gamma, exploration_rate_decay=exploration_rate_decay)\n\t\t_, reward... | [
"0.6798782",
"0.6684525",
"0.65187615",
"0.6489029",
"0.6461873",
"0.6419363",
"0.6415253",
"0.63369465",
"0.63027513",
"0.62475175",
"0.621523",
"0.6203142",
"0.6196968",
"0.61912376",
"0.6172915",
"0.6132329",
"0.60979116",
"0.6081965",
"0.6079719",
"0.60595506",
"0.6049344... | 0.73987424 | 0 |
Test the occupy corner strategy of the AI. | def test_occupy_corner():
tiles = Tiles(800, 100)
board = Board(800, 100, tiles)
player = Player('Alfred', board, 'black')
ai = AI(board, player)
assert ai.occupy_corner() is False
for i in range(1, board.count//2 - 1):
board.add_tile(i, i, 'black')
assert ai.occupy_corner()[0] == (0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def special_corner() -> None:\r\n if example[1, 1] == 0: # NW\r\n if conflict_space[0, 0] == conflict_space[0, 2] and conflict_space[2, 0] == conflict_space[0, 0] \\\r\n and conflict_space[0, 0] != 0:\r\n example[0, 0] = 0\r\n safeboard[0, 0] = 0\r\n progr... | [
"0.65151787",
"0.65082204",
"0.63480455",
"0.63095576",
"0.62575513",
"0.6107052",
"0.6095903",
"0.60577667",
"0.59931815",
"0.59799135",
"0.59322566",
"0.58727574",
"0.5858593",
"0.58471787",
"0.5840591",
"0.58227587",
"0.58138734",
"0.5780879",
"0.5743356",
"0.57380074",
"0... | 0.7918589 | 0 |
Test the priority of occupy corner strategy and greedy strategy. | def test_prioritize():
tiles = Tiles(800, 100)
board = Board(800, 100, tiles)
player = Player('Alfred', board, 'black')
ai = AI(board, player)
board.add_tile(board.count//2 - 1, 0, 'white')
for i in range(1, board.count - 1):
if board.tiles_list[board.count//2 - 1][i] is None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_occupy_corner():\n tiles = Tiles(800, 100)\n board = Board(800, 100, tiles)\n player = Player('Alfred', board, 'black')\n ai = AI(board, player)\n assert ai.occupy_corner() is False\n for i in range(1, board.count//2 - 1):\n board.add_tile(i, i, 'black')\n assert ai.occupy_corn... | [
"0.6115253",
"0.60298157",
"0.595338",
"0.58664453",
"0.5839089",
"0.582531",
"0.56715935",
"0.56415856",
"0.56048363",
"0.5567287",
"0.5537749",
"0.55048853",
"0.5472626",
"0.545068",
"0.5434593",
"0.5433324",
"0.5416526",
"0.53941494",
"0.53813297",
"0.5346625",
"0.53424406... | 0.6064991 | 1 |
Converts degrees to radians | def degrees_to_radians(degrees):
return degrees * math.pi / 180 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toRadians(self,degrees):\n rad = degrees * (math.pi/180.0)\n return rad",
"def degree_to_radians(degree):\n return degree * pi / 180",
"def deg2rad(a):",
"def deg_to_rad(degrees):\n degrees = Decimal(unicode(degrees))\n radians = degrees * TWO_PI / 360\n radians = radians % (TWO... | [
"0.83647555",
"0.8277707",
"0.81987983",
"0.80436754",
"0.79974955",
"0.797372",
"0.7962433",
"0.79483896",
"0.7918682",
"0.790586",
"0.7825071",
"0.7820938",
"0.77913433",
"0.7727845",
"0.76600176",
"0.7560419",
"0.75328255",
"0.75065935",
"0.7459013",
"0.7456517",
"0.735530... | 0.831199 | 1 |
Should retrieve position by id. | async def test_retrieve_position_by_id(self):
position = {
'id': '46214692',
'type': 'POSITION_TYPE_BUY',
'symbol': 'GBPUSD',
'magic': 1000,
'time': '2020-04-15T02:45:06.521Z',
'updateTime': '2020-04-15T02:45:06.521Z',
'openPric... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_position(self, position):",
"def get_index_by_id(self, id):\r\n for i in range(len(self.vertices)):\r\n if self.vertices[i].id == id:\r\n return i\r\n raise ValueError('Reverse look up of id failed.')",
"def find_by_id(self, id_):\n return self.by_id.get(i... | [
"0.6972265",
"0.6535462",
"0.6511969",
"0.6433299",
"0.6380093",
"0.6380093",
"0.6380093",
"0.6380093",
"0.6380093",
"0.6380093",
"0.6380093",
"0.6380093",
"0.6380093",
"0.6380093",
"0.6380093",
"0.6371616",
"0.63689494",
"0.6361208",
"0.6355607",
"0.6280296",
"0.6266355",
... | 0.69218725 | 1 |
Should retrieve history orders by ticket. | async def test_retrieve_history_orders_by_ticket(self):
history_orders = {
'historyOrders': [{
'clientId': 'TE_GBPUSD_7hyINWqAlE',
'currentPrice': 1.261,
'currentVolume': 0,
'doneTime': '2020-04-15T02:45:06.521Z',
'id': ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def history_orders(self, **params):\n return self._get('historyOrders', signed=True, params=params)",
"def get_order_history(self):\n return self.__call__('orders', 'getorderhistory')",
"def history_orders(self, **params):\n return self._get('option/historyOrders', signed=True, params=para... | [
"0.68895435",
"0.6615441",
"0.65775883",
"0.6308406",
"0.6252444",
"0.6227374",
"0.6198417",
"0.6158536",
"0.6035728",
"0.600984",
"0.59876347",
"0.5975466",
"0.5951857",
"0.59504896",
"0.5862536",
"0.58474076",
"0.58351463",
"0.582963",
"0.5794965",
"0.57782364",
"0.5771252"... | 0.76520425 | 0 |
Should retrieve history orders by position. | async def test_retrieve_history_orders_by_position(self):
history_orders = {
'historyOrders': [{
'clientId': 'TE_GBPUSD_7hyINWqAlE',
'currentPrice': 1.261,
'currentVolume': 0,
'doneTime': '2020-04-15T02:45:06.521Z',
'id'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_order_history(self):\n return self.__call__('orders', 'getorderhistory')",
"def history_orders(self, **params):\n return self._get('historyOrders', signed=True, params=params)",
"def getOrderHistory(self):\n return self.__orderhistory",
"def orders_history(self): \n ... | [
"0.70613164",
"0.7055775",
"0.6878547",
"0.68756676",
"0.67671275",
"0.64887697",
"0.63660794",
"0.61929816",
"0.6189842",
"0.61831975",
"0.60542715",
"0.58967555",
"0.5887322",
"0.58838814",
"0.58633524",
"0.5859558",
"0.585158",
"0.58322316",
"0.58209765",
"0.5819109",
"0.5... | 0.7436685 | 0 |
Should retrieve history orders by time range. | async def test_retrieve_history_orders_by_time_range(self):
history_orders = {
'historyOrders': [{
'clientId': 'TE_GBPUSD_7hyINWqAlE',
'currentPrice': 1.261,
'currentVolume': 0,
'doneTime': '2020-04-15T02:45:06.521Z',
'i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def history_orders(self, **params):\n return self._get('historyOrders', signed=True, params=params)",
"def query_history(self, req: HistoryRequest) -> List[BarData]:\n history = []\n\n start_time = generate_datetime3(req.start)\n end_time = generate_datetime3(req.end)\n\n mt5_r... | [
"0.6563036",
"0.6318715",
"0.6306542",
"0.6296289",
"0.62920004",
"0.6222286",
"0.61986375",
"0.6187328",
"0.617412",
"0.61191016",
"0.6068333",
"0.60420847",
"0.6002579",
"0.5983796",
"0.5964583",
"0.5963244",
"0.58497477",
"0.5845422",
"0.58372945",
"0.5819493",
"0.5816789"... | 0.7670137 | 0 |
Should retrieve history deals by ticket. | async def test_retrieve_history_deals_by_ticket(self):
deals = {
'deals': [{
'clientId': 'TE_GBPUSD_7hyINWqAlE',
'commission': -0.25,
'entryType': 'DEAL_ENTRY_IN',
'id': '33230099',
'magic': 1000,
'platfo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_retrieve_history_orders_by_ticket(self):\n history_orders = {\n 'historyOrders': [{\n 'clientId': 'TE_GBPUSD_7hyINWqAlE',\n 'currentPrice': 1.261,\n 'currentVolume': 0,\n 'doneTime': '2020-04-15T02:45:06.521Z',\n ... | [
"0.640978",
"0.59098035",
"0.5806389",
"0.58019525",
"0.56850594",
"0.5665967",
"0.56497484",
"0.5600169",
"0.55646515",
"0.5530082",
"0.5521894",
"0.5511783",
"0.5500163",
"0.5495374",
"0.5488358",
"0.5487127",
"0.54843986",
"0.5477874",
"0.5453377",
"0.5393643",
"0.53888416... | 0.7153134 | 0 |
Should retrieve history deals by position. | async def test_retrieve_history_deals_by_position(self):
deals = {
'deals': [{
'clientId': 'TE_GBPUSD_7hyINWqAlE',
'commission': -0.25,
'entryType': 'DEAL_ENTRY_IN',
'id': '33230099',
'magic': 1000,
'plat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def openPositionHistory(self):\n dt_only, tm_only = self.getDatetimeSplit()\n\n # GET OPEN POSITIONS\n open_positions_found = self.open_positions_history.find_one(\n {\"Date\": dt_only, \"Trader\": self.user[\"Name\"], \"Asset_Type\": self.asset_type, \"Account_ID\": self.account_id... | [
"0.6217579",
"0.6215",
"0.59939057",
"0.5699108",
"0.56706095",
"0.5670342",
"0.5654143",
"0.5611743",
"0.55914974",
"0.556619",
"0.5501191",
"0.5475096",
"0.54381",
"0.542282",
"0.5411796",
"0.5395307",
"0.5319046",
"0.53184795",
"0.5308113",
"0.5293302",
"0.52825713",
"0.... | 0.6966567 | 0 |
Should retrieve history deals by time range. | async def test_retrieve_history_deals_by_time_range(self):
deals = {
'deals': [{
'clientId': 'TE_GBPUSD_7hyINWqAlE',
'commission': -0.25,
'entryType': 'DEAL_ENTRY_IN',
'id': '33230099',
'magic': 1000,
'pl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_retrieve_history_orders_by_time_range(self):\n history_orders = {\n 'historyOrders': [{\n 'clientId': 'TE_GBPUSD_7hyINWqAlE',\n 'currentPrice': 1.261,\n 'currentVolume': 0,\n 'doneTime': '2020-04-15T02:45:06.521Z',\n ... | [
"0.67015177",
"0.64921016",
"0.61083573",
"0.6081186",
"0.60756993",
"0.59755176",
"0.5887691",
"0.5887691",
"0.58774865",
"0.58574224",
"0.5842329",
"0.5786964",
"0.5767866",
"0.5749971",
"0.57059956",
"0.56516933",
"0.5647718",
"0.5642691",
"0.5639693",
"0.56313",
"0.562511... | 0.7231706 | 0 |
Should create market buy order. | async def test_create_market_buy_order(self):
trade_result = {
'error': 10009,
'description': 'TRADE_RETCODE_DONE',
'orderId': 46870472
}
client.trade = AsyncMock(return_value=trade_result)
actual = await api.create_market_buy_order('GBPUSD', 0.07, 0.9... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_buy_order(self):\n\n user = self.set_auth_token_header()\n\n # set account buying power\n account = user.account\n account.available_bp = 1000\n account.save()\n\n data = {\n 'stock': 'GOOG',\n 'quantity': 15,\n 'price': 1.25,\n ... | [
"0.70877606",
"0.6757239",
"0.6658958",
"0.6636849",
"0.66247195",
"0.65020454",
"0.64100194",
"0.6376812",
"0.63338476",
"0.63303095",
"0.63294417",
"0.6320912",
"0.62989116",
"0.6277116",
"0.62681705",
"0.6249756",
"0.6245821",
"0.6236718",
"0.6221848",
"0.6203652",
"0.6200... | 0.7437475 | 0 |
Should create market buy order with relative SL/TP. | async def test_create_market_buy_order_with_relative_sl_tp(self):
trade_result = {
'error': 10009,
'description': 'TRADE_RETCODE_DONE',
'orderId': 46870472
}
client.trade = AsyncMock(return_value=trade_result)
actual = await api.create_market_buy_order... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_buy():\n i = 1\n while i <= CONF.trade_trials:\n buy_price = calculate_buy_price(get_current_price())\n order_size = calculate_buy_order_size(buy_price)\n if order_size is None:\n return None\n order = create_buy_order(buy_price, order_size)\n if order is ... | [
"0.65603817",
"0.6553637",
"0.65477574",
"0.64789724",
"0.64459926",
"0.63720036",
"0.63407904",
"0.6336699",
"0.6315964",
"0.62669873",
"0.62386125",
"0.6137784",
"0.60840356",
"0.60785216",
"0.60593677",
"0.6051105",
"0.6041088",
"0.6036246",
"0.60187614",
"0.6002146",
"0.6... | 0.7582716 | 0 |
Should create market sell order. | async def test_create_market_sell_order(self):
trade_result = {
'error': 10009,
'description': 'TRADE_RETCODE_DONE',
'orderId': 46870472
}
client.trade = AsyncMock(return_value=trade_result)
actual = await api.create_market_sell_order('GBPUSD', 0.07, 0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sell_order(self):\n\n user = self.set_auth_token_header()\n\n # create stock shares\n shares_data = {\n 'account': user.account,\n 'quantity': 15,\n 'total_value': 18.75,\n 'stock': Stock.objects.get(code='GOOG')\n }\n StockSha... | [
"0.7068008",
"0.7000044",
"0.6864859",
"0.6863436",
"0.682368",
"0.6712586",
"0.66141903",
"0.66066027",
"0.66000926",
"0.6578752",
"0.65568084",
"0.65430164",
"0.6420616",
"0.640372",
"0.6368696",
"0.6353988",
"0.6336104",
"0.63300925",
"0.6303567",
"0.6290725",
"0.6244863",... | 0.762105 | 0 |
Should create limit buy order. | async def test_create_limit_buy_order(self):
trade_result = {
'error': 10009,
'description': 'TRADE_RETCODE_DONE',
'orderId': 46870472
}
client.trade = AsyncMock(return_value=trade_result)
actual = await api.create_limit_buy_order('GBPUSD', 0.07, 1.0, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def new_limit_order(side):\n symbol = App.config[\"symbol\"]\n now_ts = now_timestamp()\n\n #\n # Find limit price (from signal, last kline and adjustment parameters)\n #\n last_kline = App.analyzer.get_last_kline(symbol)\n last_close_price = to_decimal(last_kline[4]) # Close price of k... | [
"0.731649",
"0.7156456",
"0.69854903",
"0.697059",
"0.69598156",
"0.6914562",
"0.6877126",
"0.67756426",
"0.67519784",
"0.66474164",
"0.6547826",
"0.6382411",
"0.6368707",
"0.63301915",
"0.6285489",
"0.623207",
"0.6220374",
"0.6218258",
"0.61826026",
"0.61722577",
"0.61368996... | 0.76753867 | 0 |
Should create limit sell order. | async def test_create_limit_sell_order(self):
trade_result = {
'error': 10009,
'description': 'TRADE_RETCODE_DONE',
'orderId': 46870472
}
client.trade = AsyncMock(return_value=trade_result)
actual = await api.create_limit_sell_order('GBPUSD', 0.07, 1.0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def limit_sell(self, symbol: Symbol, price: str, quantity: str,\n receive_window: Optional[int]):\n\n return self.new_order(symbol,\n OrderSide.SELL,\n OrderType.LIMIT,\n quantity,\n ... | [
"0.7127128",
"0.70926243",
"0.7090281",
"0.7016707",
"0.6956725",
"0.680467",
"0.6781313",
"0.6768573",
"0.674776",
"0.6712054",
"0.66184676",
"0.6574998",
"0.6555947",
"0.6492553",
"0.64077497",
"0.63661444",
"0.63359165",
"0.6320064",
"0.6310815",
"0.6280748",
"0.61536795",... | 0.7457807 | 0 |
Should create stop buy order. | async def test_create_stop_buy_order(self):
trade_result = {
'error': 10009,
'description': 'TRADE_RETCODE_DONE',
'orderId': 46870472
}
client.trade = AsyncMock(return_value=trade_result)
actual = await api.create_stop_buy_order('GBPUSD', 0.07, 1.0, 0.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_create_stop_sell_order(self):\n trade_result = {\n 'error': 10009,\n 'description': 'TRADE_RETCODE_DONE',\n 'orderId': 46870472\n }\n client.trade = AsyncMock(return_value=trade_result)\n actual = await api.create_stop_sell_order('GBPUSD',... | [
"0.73170865",
"0.7085005",
"0.6901136",
"0.68934613",
"0.66456115",
"0.6510608",
"0.6318515",
"0.6093152",
"0.6093152",
"0.6093152",
"0.6093152",
"0.6087688",
"0.6070329",
"0.6067557",
"0.6065952",
"0.6040094",
"0.60106504",
"0.6006713",
"0.5968999",
"0.59672755",
"0.5932873"... | 0.76835877 | 0 |
Should create stop sell order. | async def test_create_stop_sell_order(self):
trade_result = {
'error': 10009,
'description': 'TRADE_RETCODE_DONE',
'orderId': 46870472
}
client.trade = AsyncMock(return_value=trade_result)
actual = await api.create_stop_sell_order('GBPUSD', 0.07, 1.0, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_stop(self, price_stop):\n if self.price_stop is not None:\n return(order(self.symbol, -self.volume, style=StopOrder(self.price_stop))) # , exchange=self.order_master.style.exchange\n else:\n return(None)",
"async def test_create_stop_limit_sell_order(self):\n ... | [
"0.74166846",
"0.736544",
"0.7279909",
"0.6987097",
"0.69419765",
"0.6869466",
"0.67229897",
"0.6620698",
"0.64032954",
"0.63958335",
"0.6361713",
"0.6350819",
"0.6281235",
"0.6281235",
"0.6281235",
"0.6281235",
"0.6266616",
"0.62253815",
"0.62194103",
"0.62182146",
"0.614731... | 0.7811382 | 0 |
Should create stop limit buy order. | async def test_create_stop_limit_buy_order(self):
trade_result = {
'error': 10009,
'description': 'TRADE_RETCODE_DONE',
'orderId': 46870472
}
client.trade = AsyncMock(return_value=trade_result)
actual = await api.create_stop_limit_buy_order('GBPUSD', 0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_create_stop_limit_sell_order(self):\n trade_result = {\n 'error': 10009,\n 'description': 'TRADE_RETCODE_DONE',\n 'orderId': 46870472\n }\n client.trade = AsyncMock(return_value=trade_result)\n actual = await api.create_stop_limit_sell_ord... | [
"0.731738",
"0.6910245",
"0.670688",
"0.6676739",
"0.66655964",
"0.6592762",
"0.64702207",
"0.6436317",
"0.63776",
"0.6375291",
"0.6293813",
"0.62472874",
"0.6179874",
"0.6124796",
"0.5963579",
"0.59249353",
"0.590677",
"0.5900283",
"0.5875793",
"0.5871842",
"0.5849287",
"0... | 0.76346844 | 0 |
Should create stop limit sell order. | async def test_create_stop_limit_sell_order(self):
trade_result = {
'error': 10009,
'description': 'TRADE_RETCODE_DONE',
'orderId': 46870472
}
client.trade = AsyncMock(return_value=trade_result)
actual = await api.create_stop_limit_sell_order('GBPUSD',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_create_stop_limit_buy_order(self):\n trade_result = {\n 'error': 10009,\n 'description': 'TRADE_RETCODE_DONE',\n 'orderId': 46870472\n }\n client.trade = AsyncMock(return_value=trade_result)\n actual = await api.create_stop_limit_buy_order... | [
"0.7135461",
"0.7041468",
"0.68907833",
"0.6788986",
"0.67215097",
"0.6706598",
"0.6695607",
"0.66889995",
"0.6686074",
"0.6677089",
"0.66649234",
"0.6646176",
"0.66058606",
"0.64351207",
"0.6185693",
"0.6159284",
"0.61155164",
"0.6077244",
"0.6018654",
"0.5958964",
"0.594722... | 0.7623836 | 0 |
Should retrieve symbol specification. | async def test_retrieve_symbol_specification(self):
specification = {
'symbol': 'AUDNZD',
'tickSize': 0.00001,
'minVolume': 0.01,
'maxVolume': 100,
'volumeStep': 0.01
}
client.get_symbol_specification = AsyncMock(return_value=specificat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def specification(self, symbol: str) -> MetatraderSymbolSpecification:\n return self._specificationsBySymbol[symbol] if (symbol in self._specificationsBySymbol) else None",
"def get_symbol(self):\n return self.symbol",
"def symbol(self): \n return self.__symbol",
"def symbol(self, **kw):... | [
"0.7434125",
"0.6561847",
"0.6413712",
"0.6362397",
"0.6333584",
"0.63075924",
"0.6235075",
"0.62048894",
"0.6152594",
"0.6090475",
"0.60072565",
"0.5999678",
"0.59589535",
"0.5952791",
"0.58985406",
"0.5892314",
"0.58911157",
"0.58510077",
"0.5841966",
"0.5813681",
"0.580497... | 0.67747104 | 1 |
Should retrieve symbol price. | async def test_retrieve_symbol_price(self):
price = {
'symbol': 'AUDNZD',
'bid': 1.05297,
'ask': 1.05309,
'profitTickValue': 0.59731,
'lossTickValue': 0.59736
}
client.get_symbol_price = AsyncMock(return_value=price)
actual = aw... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def price(self, symbol: str) -> MetatraderSymbolPrice:\n return self._pricesBySymbol[symbol] if (symbol in self._pricesBySymbol) else None",
"def get_price(self):\r\n return self.price",
"def get_price(self):\n return self.price",
"def get_price(self):\n return self.price",
"def... | [
"0.75368005",
"0.73012334",
"0.7115474",
"0.7115474",
"0.7115474",
"0.7078819",
"0.69804615",
"0.69518405",
"0.69493777",
"0.69130397",
"0.68909276",
"0.6816392",
"0.6809522",
"0.6762182",
"0.67370355",
"0.67281",
"0.67200774",
"0.67200774",
"0.66975373",
"0.66926223",
"0.669... | 0.7374473 | 1 |
Should retrieve latest tick. | async def test_retrieve_latest_tick(self):
tick = {
'symbol': 'AUDNZD',
'time': '2020-04-07T03:45:00.000Z',
'brokerTime': '2020-04-07 06:45:00.000',
'bid': 1.05297,
'ask': 1.05309,
'last': 0.5298,
'volume': 0.13,
'si... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_tick_time(self):\n return self.last_tick_",
"def lastTick():",
"def get_tick():\n return _tick",
"def tick(self):\n prev_last_tick = self.last_tick_\n self.last_tick_ = timeit.default_timer()\n latest_tick_period = self.last_tick_ - prev_last_tick\n return latest_tick_period",
"d... | [
"0.7536248",
"0.75105405",
"0.73860157",
"0.69554013",
"0.68300563",
"0.6726091",
"0.6692549",
"0.6692549",
"0.6688755",
"0.6688755",
"0.66822636",
"0.6675168",
"0.6639117",
"0.6577419",
"0.6553388",
"0.6528821",
"0.64310515",
"0.6421152",
"0.6396056",
"0.6377871",
"0.6338216... | 0.752766 | 1 |
Should retrieve latest order book. | async def test_retrieve_latest_order_book(self):
book = {
'symbol': 'AUDNZD',
'time': '2020-04-07T03:45:00.000Z',
'brokerTime': '2020-04-07 06:45:00.000',
'book': [
{
'type': 'BOOK_TYPE_SELL',
'price': 1.0530... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_book(self):\n print('%s get_book request made.' % self.sym)\n start_time = time()\n\n self.clear_book()\n path = ('https://api.pro.coinbase.com/products/%s/book' % self.sym)\n book = requests.get(path, params={'level': 3}).json()\n\n elapsed = time() - start_time\... | [
"0.7019187",
"0.6989451",
"0.66248345",
"0.6462165",
"0.63951343",
"0.6389977",
"0.6233529",
"0.622424",
"0.62150633",
"0.61572623",
"0.61523026",
"0.6126804",
"0.6067528",
"0.59505653",
"0.59329677",
"0.5911733",
"0.59049094",
"0.5890971",
"0.5889683",
"0.5884506",
"0.587661... | 0.7634072 | 0 |
Apply random errors using ErrorClass.calculate_errors | def apply_errors(star_name, arr, arr_err, nn):
if nn > 0:
errors = error_propagation.ErrorClass(
error_tables = "error_tables_ba.dat",
temperature_table = "bastars_temp.dat",
element_set = "element_set.dat")
error_diff = errors.calculate_errors(star_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _random_error(self):\n return self._random_magnitude_error()[1]",
"def ApplyXErrors( ErrorNum,array,type,L,CorrLen):\n\n if type == 1:\n #run across every element in the array\n for i in range(len(array[:,0,0])):\n for j in range(2):\n for k in range(len(... | [
"0.69266886",
"0.63187754",
"0.6242822",
"0.6162732",
"0.61335415",
"0.60576856",
"0.5999335",
"0.59705704",
"0.59265476",
"0.58717495",
"0.5827276",
"0.58240587",
"0.5812734",
"0.57936156",
"0.5792657",
"0.5751712",
"0.5747125",
"0.57215565",
"0.5706507",
"0.5699136",
"0.564... | 0.65482324 | 1 |
Calculate best dilution for this model and data if processed_models is None, then model is taken to be a label otherwise model is taken as a model | def calculate_dilution(data, model, processed_models = None, lower = 0,
upper = 1):
if processed_models is not None:
# Assign label
label = model
with open(processed_models, "r") as fread:
# Read header
fread.readline()
# Find mod... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pick_model(self):\n self.x = self.train[self.use_columns]\n try:\n self.x = pd.get_dummies(self.x)\n except:\n pass # if no categorical features\n self.final_columns = self.x.columns\n print(self.x.columns)\n self.scaler = StandardScaler()\n ... | [
"0.618105",
"0.60084873",
"0.5939573",
"0.59353083",
"0.5928722",
"0.5912158",
"0.5895022",
"0.58932126",
"0.58654296",
"0.5860362",
"0.5819073",
"0.5813044",
"0.5780176",
"0.5744621",
"0.57129735",
"0.5712857",
"0.56953317",
"0.56850785",
"0.56804615",
"0.5679748",
"0.566831... | 0.6224283 | 0 |
Calculate a distance between model and data | def get_distance(model, data):
# L square
len_shape = len(data.shape)
if len_shape == 2:
dist = np.mean((model - data) ** 2, axis = 1)
elif len_shape == 1:
dist = np.mean((model - data) ** 2)
else:
raise NotImplementedError
return dist | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(source, DM, model='NE2001'):\n\n d=SkyModel(dmmodel=model)\n return d.distance(source, DM)",
"def distances(self):",
"def compute_distance(df):\n pass",
"def _distance_from_weights(self, data):\n input_data = array(data)\n weights_flat = self._weights.reshape(-1, self._wei... | [
"0.69364744",
"0.68946296",
"0.66980374",
"0.6695127",
"0.6654621",
"0.66436875",
"0.66295797",
"0.6623063",
"0.6600599",
"0.6528186",
"0.65217257",
"0.64846206",
"0.64806867",
"0.6435056",
"0.6425515",
"0.6420461",
"0.64041615",
"0.6389073",
"0.6377416",
"0.6376596",
"0.6375... | 0.7727246 | 0 |
Create a BruttoFace object. | def make_bruttoface(space_boundary, other_space, BaseFace=None, doc=None):
if not doc:
doc = App.activeDocument()
obj = doc.addObject("Part::FeaturePython",
"BruttoFace" + space_boundary.Name)
BruttoFace(obj)
obj.Space = space_boundary.Space
obj.Space2 = other_space... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def face_maker(size=180, color='0x9C661F'):\n face = GOval(size, size-20)\n face.filled = True\n face.fill_color = color\n return face",
"def create_barco(x0, y0,largo_1,largo_2,alto):\n # Defining the location and colors of each vertex of the shape\n vertices = [\n # positions ... | [
"0.5883901",
"0.5454941",
"0.5237078",
"0.5148723",
"0.51030356",
"0.5092698",
"0.5048993",
"0.5010923",
"0.50089675",
"0.4977704",
"0.49771523",
"0.49760854",
"0.49623144",
"0.49411914",
"0.49115613",
"0.48771563",
"0.48561475",
"0.4828216",
"0.48011893",
"0.47725344",
"0.47... | 0.683499 | 0 |
Tests storing the computer as a backend when a string is given. | def test_computer_string(self):
# Computer to use for the network
comp = "1q-qvm"
# Get a network with the computer
qnn = self.get_test_network(comp)
# Checks
self.assertEqual(type(qnn.computer), QuantumComputer) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detect_backend():\n try:\n from termpixels.unix import UnixBackend\n return UnixBackend()\n except:\n try:\n from termpixels.win32_vt import Win32VtBackend\n return Win32VtBackend()\n except Exception as e:\n raise e\n from termpixel... | [
"0.57164264",
"0.5707183",
"0.56878567",
"0.5675458",
"0.56187004",
"0.56135654",
"0.56102943",
"0.5585062",
"0.5534557",
"0.5499115",
"0.5479529",
"0.5477499",
"0.5416549",
"0.537858",
"0.53718406",
"0.5367258",
"0.5360502",
"0.5343497",
"0.53367317",
"0.531885",
"0.5313926"... | 0.724093 | 0 |
Tests compiling a network for all data points. | def test_compile(self):
# Get a network
qnn = self.get_test_network("1q-qvm")
# Compile a data point
executable = qnn.compile(index=0, shots=1000)
# Checks
self.assertEqual(type(executable), Program) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_build_basic(self):\n # Get the components for a network\n data = array([[0, 1], [1, 0]])\n cdata = CData(data)\n encoder = BinaryEncoding(cdata)\n layer = ProductAnsatz(2)\n measure = Measurement(2, [0])\n\n # Make the network\n qnn = Network([encode... | [
"0.66633743",
"0.6566716",
"0.6272501",
"0.6222111",
"0.6213091",
"0.6183196",
"0.61585057",
"0.6082805",
"0.60824347",
"0.6062175",
"0.605731",
"0.6040624",
"0.60064554",
"0.5997789",
"0.5963531",
"0.5943924",
"0.5893658",
"0.5862603",
"0.5856819",
"0.58512366",
"0.58249307"... | 0.67458415 | 0 |
Tests propagating a data point through a network. | def test_propagate(self):
# Get network components
data = array([[0], [1]])
cdata = LabeledCData(data, labels=array([0, 1]))
encoder = BinaryEncoding(cdata)
unitary = ProductAnsatz(1)
measure = Measurement(1, [0])
qnn = Network([encoder, unitary, measure], "1q-qvm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test(self):\n self.output = self.net.forward(Variable(self.source, volatile=True))\n self.loss = self.loss_function(self.output,\n Variable(self.target, volatile=True))",
"def test_nn_point(test_data):\n xp, yp, z = test_data\n\n tri = Delaunay(list(z... | [
"0.62134844",
"0.6150821",
"0.60055745",
"0.5939932",
"0.59384876",
"0.56438386",
"0.559932",
"0.55849236",
"0.5576066",
"0.5561534",
"0.5560037",
"0.5556109",
"0.55470914",
"0.5541417",
"0.55181414",
"0.55108744",
"0.549368",
"0.5476166",
"0.5473057",
"0.545297",
"0.5427677"... | 0.70431745 | 0 |
Tests propagating a data point through a network with specified angles for the ansatz. | def test_propagate_with_angles(self):
# Get network components
data = array([[0], [1]])
cdata = LabeledCData(data, labels=array([0, 1]))
encoder = BinaryEncoding(cdata)
ansatz = ProductAnsatz(1)
measure = Measurement(1, [0])
# Make the network
qnn = Netwo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_atan(doctest):",
"def test_propagate(self):\n # Get network components\n data = array([[0], [1]])\n cdata = LabeledCData(data, labels=array([0, 1]))\n encoder = BinaryEncoding(cdata)\n unitary = ProductAnsatz(1)\n measure = Measurement(1, [0])\n qnn = Net... | [
"0.56445473",
"0.55271894",
"0.54707813",
"0.5373868",
"0.5333861",
"0.52366066",
"0.52366066",
"0.5206598",
"0.5200638",
"0.5184357",
"0.51707965",
"0.5112568",
"0.5111476",
"0.5078119",
"0.5047718",
"0.50446355",
"0.50095594",
"0.4984",
"0.49781966",
"0.49661884",
"0.496059... | 0.74632263 | 0 |
Tests that Network.cost returns a correct value for a given Network.. | def test_cost(self):
# Get components for the network
data = array([[1, 0], [0, 1]])
cdata = LabeledCData(data, labels=array([0, 1]))
encoder = BinaryEncoding(cdata)
ansatz = ProductAnsatz(2)
measure = Measurement(2, [0, 1])
# Define a basic predictor (function w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_cost(self):\n self.assertAlmostEqual(m2.cost(params), 57.629, 2)",
"def test_check_cost():",
"def get_expected_cost(self):",
"def test_cost(self):\n self.assertTrue(\n int(self.ospf.parse_state(\n pattern='cost',\n cmd_key='sh_ospf_ints')) == 10... | [
"0.7985523",
"0.77682334",
"0.75637066",
"0.7291797",
"0.67985773",
"0.67753947",
"0.6630822",
"0.65983564",
"0.6410034",
"0.6388091",
"0.6359496",
"0.63467854",
"0.63123804",
"0.622913",
"0.61886173",
"0.6156762",
"0.61326885",
"0.6111124",
"0.6110583",
"0.60942775",
"0.6087... | 0.8224584 | 0 |
List all survivors, or create a new survivor | def survivor_list(request):
if request.method == 'GET':
survivor = Survivor.objects.all()
serializer = SurvivorSerializer(survivor, many=True)
return Response(serializer.data)
elif request.method == 'POST':
data = request.data
serializer = SurvivorSerializer(data=data)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def survivors_selection(self):\n q = 5\n new_population = []\n for i in range(self._population_size):\n batch = []\n for j in range(q):\n r = random.randint(0, (self._child2population_ratio + 1) * self._population_size - 1)\n if r < self._pop... | [
"0.6047744",
"0.5833767",
"0.5707058",
"0.52945215",
"0.51899284",
"0.50966704",
"0.509625",
"0.50652957",
"0.50050104",
"0.49475464",
"0.49038467",
"0.48937002",
"0.4848155",
"0.48105952",
"0.4806016",
"0.47691327",
"0.47157866",
"0.46279135",
"0.460328",
"0.45824134",
"0.45... | 0.67371863 | 0 |
Retrieve the reports about the survivors | def survivor_reports(request):
if request.method == 'GET':
data = {}
total_survivors = infected = non_infected = water = food = medication = ammunition = pointslost = 0
for i in Survivor.objects.all():
total_survivors += 1
if i.infected is False:
non_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def survivor_list(request):\n if request.method == 'GET':\n survivor = Survivor.objects.all()\n serializer = SurvivorSerializer(survivor, many=True)\n return Response(serializer.data)\n\n elif request.method == 'POST':\n data = request.data\n serializer = SurvivorSerializer... | [
"0.64039767",
"0.52879775",
"0.52349675",
"0.5222229",
"0.50948393",
"0.50417954",
"0.49045265",
"0.4896115",
"0.4888435",
"0.4876418",
"0.48751056",
"0.4866736",
"0.48401412",
"0.48326138",
"0.4827695",
"0.48220506",
"0.48173687",
"0.4813493",
"0.4812425",
"0.48014873",
"0.4... | 0.57989 | 1 |
Flag one survivor as infected, starting from his id If gets a 3 flags, the boolean infected turns True | def survivor_flag_as_infected(request, pk):
try:
survivor = Survivor.objects.get(pk=pk)
except Survivor.DoesNotExist:
return Response(status=status.HTTP_404_NOT_FOUND)
def repeated_id_verify(list_id, id_to_verify):
if len(list_id) == 0:
list_id.append(id_to_verify)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def susceptibleToInfected(self):\n\n #create a mask to sieve those uninfected out\n infected = self.space == 1\n\n # add extra boundaries\n expan1 = np.hstack((infected,np.zeros((self.space.shape[0],1))))\n expan1 = np.vstack((expan1,np.zeros((1,expan1.shape[1]))))\n expan... | [
"0.5729731",
"0.5475922",
"0.5403246",
"0.5403246",
"0.53945506",
"0.537619",
"0.5232073",
"0.51747864",
"0.5092342",
"0.50760186",
"0.504291",
"0.5026953",
"0.49728096",
"0.49728096",
"0.49378684",
"0.49008673",
"0.49008673",
"0.48780578",
"0.4868155",
"0.48538458",
"0.47935... | 0.6582376 | 0 |
Find the first matching pattern. If found, return the (pattern, match) tuple. If not, return (None,None). The "patterns" arugment is an itterable of compiled regular expressions, but see the compile_filename_patterns() function also in this module for a way to make this far more general. | def first_match(s,patterns):
for p in patterns:
m=p.match(s)
if m:
return p,m
return None,None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_pattern(path, patterns):\n regular_expression = get_regular_expression(path)\n results = get_patterns_that_match(regular_expression, patterns)\n if(len(results) > 1):\n best_matching_pattern = check_best_matching_pattern(results)\n elif(len(results) == 1):\n best_matching_pattern... | [
"0.7661646",
"0.70605063",
"0.70605063",
"0.68765163",
"0.6851975",
"0.6649738",
"0.66038585",
"0.65500325",
"0.6306797",
"0.61663103",
"0.608153",
"0.6032241",
"0.60253245",
"0.58597547",
"0.58580685",
"0.58383",
"0.5830523",
"0.5826616",
"0.58250314",
"0.5764014",
"0.572956... | 0.74253815 | 1 |
Given a sequence of filespecs, regular expressions (prefixed with | def compile_filename_patterns(pattern_list):
pats=list(pattern_list)
for i in range(len(pats)):
if isinstance(pats[i],str):
if pats[i].startswith('re:'):
pats[i]=pats[i][3:]
else:
pats[i]=fnmatch.translate(pats[i])
pats[i]=re.compile(pats[i])
return pats | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def define_regex(module_names=modules, doc_types=types, exts=exts):\n letters = ''\n module_codes = ''\n file_exts = ''\n # Populate code letter String\n for letter in doc_types:\n letters += letter\n # Populate extension string\n for ext in exts:\n if ext != exts[-1]:\n ... | [
"0.71197474",
"0.68211526",
"0.67286575",
"0.6570874",
"0.6324177",
"0.6219185",
"0.6172562",
"0.60759985",
"0.6072155",
"0.60571134",
"0.60549074",
"0.6040451",
"0.6011584",
"0.6004662",
"0.5995841",
"0.59865993",
"0.590637",
"0.5892927",
"0.58764476",
"0.58748144",
"0.58466... | 0.6938739 | 1 |
Return the given value quotted and escaped as necessary for a Unix shell to interpret it as a single value. >>> print(shellify(None)) '' >>> print(shellify(123)) 123 >>> print(shellify(123.456)) 123.456 >>> print(shellify("This 'is' a test of a (messy) string.")) 'This '"'"'is'"'"' a test of a (messy) string.' >>> prin... | def shellify(val):
if val==None:
s=''
elif not isinstance(val,str):
s=str(val)
else:
return shlex.quote(val)
return shlex.quote(s) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shellquote(s):\n return '\"' + s.replace(\"'\", \"'\\\\''\") + '\"'",
"def shellquote(arg):\n if re.match('^[-_.:/=a-zA-Z0-9]*$', arg):\n return arg\n else:\n return \"'%s'\" % arg.replace(\"'\", r\"'\\''\")",
"def safe_quoted_string(value):\n validate_safe_string(value)\n retu... | [
"0.678123",
"0.626433",
"0.60558116",
"0.59754604",
"0.59356564",
"0.58462584",
"0.58405036",
"0.5734539",
"0.5723475",
"0.5722032",
"0.5713721",
"0.5705607",
"0.55365175",
"0.55189615",
"0.55113024",
"0.5491121",
"0.5485869",
"0.5461267",
"0.546071",
"0.545485",
"0.5454431",... | 0.80899566 | 0 |
Return the full path to a reasonable guess at what might be a temp direcory on this system, creating it if necessary using the given permissions. If no permissions are given, we'll base the perms on the current umask. | def findMainTempDir(self,perms=None):
# Let the environment tell us where our temp directory is, or ought
# to be, or just use /tmp if the enrionment lets us down.
d=os.path.abspath(
os.environ.get('TMPDIR',
os.environ.get('TEMP',
os.environ.get('TMP',os.path.join(os.sep,'tmp'))
)))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeTempDir(self,perms=0o700,keep=False):\n\n os.mkdirs(self.temp,perms)\n if not keep:\n atexit.register(rmdirs,self.temp)\n return self.temp",
"def mkpath(filepath, permissions=0o777):\n # Converting string of octal to integer, if string is given.\n if isinstance(permissions, str):\n ... | [
"0.7395015",
"0.6511989",
"0.64046353",
"0.63026357",
"0.6241267",
"0.6235619",
"0.6218086",
"0.621564",
"0.6205158",
"0.6174176",
"0.6152373",
"0.6147776",
"0.61250246",
"0.6057777",
"0.6037398",
"0.6010159",
"0.5997801",
"0.5974937",
"0.5930352",
"0.5921469",
"0.5908104",
... | 0.7647492 | 0 |
Open (and likely create, but at least truncate) a temp file for this program, and return the open (for reading and writing) file object. See the our "temp" attribute for the name of the file. Remove this file at program termination unless the "keep" argument is False. | def makeTempFile(self,perms=0o600,keep=False):
fd=os.open(self.temp,os.O_RDWR|os.O_CREAT|os.O_EXCL|os.O_TRUNC,perms)
f=os.fdopen(fd,'w+')
if not keep:
atexit.register(os.remove,self.temp)
return f | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _tempfile(self):\n fd, path = tempfile.mkstemp(dir = os.path.join(self.root, \"temporary\"))\n try:\n return os.fdopen(fd, \"wb\"), path\n except:\n os.unlink(path)\n os.close(fd)\n raise",
"def get_temp_file(self, delete: bool = False, close: ... | [
"0.730706",
"0.71789485",
"0.7171766",
"0.7116647",
"0.7103804",
"0.7004909",
"0.68693656",
"0.67680734",
"0.6700995",
"0.66891897",
"0.6667137",
"0.66546816",
"0.6549893",
"0.65425813",
"0.6429935",
"0.6396331",
"0.6364834",
"0.63327926",
"0.62944597",
"0.622789",
"0.6147061... | 0.7262446 | 1 |
Read a single keystroke from stdin. The user needn't press Enter. This function returns the character as soon has it is typed. The character is not echoed to the screen unless the "echo" argument is True. If "prompt" is some true value, write that string to standard output before getting the input character, and then a... | def getch(prompt=None,echo=False):
import termios
import sys, tty
def _getch():
fd = sys.stdin.fileno()
old_settings=termios.tcgetattr(fd)
try:
tty.setraw(fd)
ch = sys.stdin.read(1)
finally:
termios.tcsetattr(fd,termios.TCSADRAIN,old_settings)
return ch
if prompt:
sys... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _readchar() -> str: # pragma: no cover\n if not sys.stdin.isatty():\n return sys.stdin.read(1)\n fd = sys.stdin.fileno()\n old_settings = termios.tcgetattr(fd)\n new_settings = termios.tcgetattr(fd)\n new_settings[3] = new_settings[3] & ~termios.ECHO & ~termios.ICANON\n termios.tcseta... | [
"0.77868146",
"0.73885345",
"0.7350035",
"0.7337249",
"0.71966887",
"0.7189868",
"0.7188419",
"0.7171872",
"0.7167737",
"0.71561223",
"0.7092389",
"0.7068087",
"0.699326",
"0.69010335",
"0.686335",
"0.686335",
"0.6807284",
"0.68045723",
"0.6782203",
"0.66546583",
"0.66406864"... | 0.7759609 | 1 |
Add an RSS stream to the database. | def add_rss(url): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_stream_to_event(self,stream):\n assert isinstance(stream,Stream)",
"def stream_rss(request):\n return render_rss(\n request=request,\n annotations=_annotations(request),\n rss_url=request.route_url(\"stream_rss\"),\n html_url=request.route_url(\"stream\"),\n t... | [
"0.6260001",
"0.6144652",
"0.6125523",
"0.5858657",
"0.5840685",
"0.57590574",
"0.5725735",
"0.5718138",
"0.5705641",
"0.56647897",
"0.5556319",
"0.55296487",
"0.5528949",
"0.54938614",
"0.5457899",
"0.5425088",
"0.5425088",
"0.54172",
"0.53760153",
"0.5350889",
"0.534414",
... | 0.6963874 | 0 |
Changes the discord rank of a user, removes other rank roles and adds the new one. Visitor, Friend, Developer, or Moderator. | async def _changerank(self, ctx, user: discord.Member, *, level):
level = level.lower()
if level == 'visitor':
await self.remove_roles(user, ctx)
await self.usual_rank(user)
embed = Config(self.bot).embed()
embed.description = f"{user.mention}'s level ha... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def addrank(self, ctx, *, rank: str):\n\t\twith open(\"cogs/utils/servers.json\") as f:\n\t\t\tdata = json.load(f)\n\t\trole = discord.utils.find(lambda m: rank.lower() in m.name.lower(), ctx.guild.roles)\n\t\tif str(ctx.guild.id) not in data:\n\t\t\tdata[str(ctx.guild.id)] = {}\n\t\tif \"ranks\" not in data... | [
"0.6607524",
"0.65099216",
"0.6308934",
"0.62961143",
"0.6277005",
"0.62504905",
"0.6209321",
"0.6129517",
"0.6105035",
"0.61030424",
"0.6075361",
"0.59878814",
"0.5924122",
"0.59208214",
"0.5849043",
"0.5800253",
"0.5798725",
"0.5767154",
"0.5752141",
"0.56187654",
"0.560772... | 0.6637097 | 0 |
test that mode=transit raises exception when no departure or arrival time is set | def test_directions_mode_transit_invalid_request():
with pytest.raises(errors.InvalidRequest):
api.directions(u"Warsaw, Poland", u"Katowice, Poland", mode="transit") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_time_requirement(self):\n test_string = \"AlanTimeZT\"\n test_passes = False\n try:\n self.parser.extract_zt(test_string)\n test_passes = False\n except:\n test_passes = True\n self.assertTrue(test_passes)",
"def test_general_subset_inv... | [
"0.60363495",
"0.5958047",
"0.593826",
"0.58818704",
"0.5816295",
"0.5786427",
"0.577987",
"0.5746784",
"0.5733762",
"0.57309484",
"0.5725224",
"0.5706705",
"0.5662128",
"0.56511134",
"0.56200486",
"0.5605286",
"0.5604178",
"0.5592913",
"0.5580447",
"0.5554178",
"0.55470216",... | 0.72899556 | 0 |
Tests that the .encryptObjectFromFile() method raises JSONDecodeError when the provided .json file cannot be deserialized | def test_deserialization_error():
tree = MerkleTree()
with pytest.raises(json.JSONDecodeError):
tree.encryptObjectFromFile(
os.path.join(os.path.dirname(__file__),
'objects/bad.json')
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_verifies_token_file_contains_json(self):\n\n with open(self.sample_token_file, 'w',\n encoding=\"utf8\", errors=\"surrogateescape\") as stf_h:\n stf_h.write(\"Bad JSON\")\n\n with self.assertRaises(json.decoder.JSONDecodeError):\n badgr = BadgrLite(toke... | [
"0.7053105",
"0.6973795",
"0.68038374",
"0.6642882",
"0.65716976",
"0.64442104",
"0.6368154",
"0.6363753",
"0.6362064",
"0.6352872",
"0.6333818",
"0.6273547",
"0.6236949",
"0.62142515",
"0.6126871",
"0.6095234",
"0.6092837",
"0.60804796",
"0.60559297",
"0.6006438",
"0.5987523... | 0.78461015 | 0 |
Tests that the .encryptFilePerObject() method raises WrongJSONFormat when the deserialized object loaded from the provided file is not a list | def test_WronJSONFormat():
tree = MerkleTree()
with pytest.raises(WrongJSONFormat):
tree.encryptFilePerObject(
os.path.join(os.path.dirname(__file__),
'objects/sample.json')
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_deserialization_error():\n\n tree = MerkleTree()\n\n with pytest.raises(json.JSONDecodeError):\n tree.encryptObjectFromFile(\n os.path.join(os.path.dirname(__file__),\n 'objects/bad.json')\n )",
"def test_loads_a_non_object_json_file(self):\n from test.re... | [
"0.6645634",
"0.65002906",
"0.6411831",
"0.6390896",
"0.6340511",
"0.62319356",
"0.62246954",
"0.62020457",
"0.61660516",
"0.61303204",
"0.6009355",
"0.59483296",
"0.5914293",
"0.5904851",
"0.5879136",
"0.58547336",
"0.58218294",
"0.58134645",
"0.57877237",
"0.5778768",
"0.57... | 0.70540744 | 0 |
sort on one specific quantile or on weighted value of all quants | def sort(self, quant=None):
if quant is None: # sort bei weight
self.__sortlist = [key for key, values in sorted(self.__quantile.items(), key=lambda items: sum((10^quantille * count for quantille, count in enumerate(items[1].values()))))]
elif isinstance(quant, int):
self.__sortl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sortAndReturnQuantiles(values):\n \n values.sort()\n N = len(values)\n return (values[0], values[N/4], values[N/2], values[(3*N)/4], values[N-1])",
"def quantile(xs: List[float], p: float) -> float:\n p_index = int(p * len(xs))\n return sorted(xs)[p_index]",
"def quantiles(x, qlist=[2.5, ... | [
"0.65836",
"0.63719434",
"0.62195444",
"0.613708",
"0.60903734",
"0.60849154",
"0.60336405",
"0.6032706",
"0.6016141",
"0.60125804",
"0.60125804",
"0.60125804",
"0.59731907",
"0.596046",
"0.59544873",
"0.59407675",
"0.59395736",
"0.59302515",
"0.5869384",
"0.5869122",
"0.5869... | 0.7503818 | 0 |
Get the client objects used to communicate with Pachyderm. | def get_clients(self):
return (self._clients['pps'], self._clients['pfs']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clients(self):\n return self._clients",
"def getClientInterfaces(self):\n return self.clients",
"def clients(self, r):\r\n return r.clients",
"def clients(self):\n return MappingProxyType(self._server.clients\n if self._server else {})",
"def c... | [
"0.7539814",
"0.7335434",
"0.7301496",
"0.72446215",
"0.7137294",
"0.70884526",
"0.70884526",
"0.7002127",
"0.6970729",
"0.6902289",
"0.6878692",
"0.6820654",
"0.67691094",
"0.6708153",
"0.6566881",
"0.65541506",
"0.6466682",
"0.6459265",
"0.6452659",
"0.6448057",
"0.6397427"... | 0.7438909 | 1 |
Set the client objects to communicate with Pachyderm. | def set_clients(self, pps, pfs):
self._clients = {
'pps': pps,
'pfs': pfs
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def client_setup(self):\n self.client = Client()",
"def setup(self):\n self.ip = self.client_address[0]\n self.port = self.client_address[1]\n self.connection = self.request #TCP socket object for the client\n self.server.clients[(self.ip, self.port)] = self\n self.serve... | [
"0.6804105",
"0.66782296",
"0.6632365",
"0.64374995",
"0.6434905",
"0.6433177",
"0.63964975",
"0.6291275",
"0.62613636",
"0.6142673",
"0.6099406",
"0.6099406",
"0.60315746",
"0.5994317",
"0.59654945",
"0.5922751",
"0.5919689",
"0.58825314",
"0.5880526",
"0.5871573",
"0.586743... | 0.6783075 | 1 |
Set up a workflow session. This creates a selfcontained set of Pachyderm constructs representing our operation. | def make_session(self):
clients = self._clients
name = 'doorstep-%s' % str(uuid.uuid4())
data_name = '%s-data' % name
processors_name = '%s-processors' % name
pipeline_definition = self.get_definition(
data_name=data_name,
processors_name=processors_nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_workflow():\n pass",
"def _setup():\n\n # Set random seeds\n tf.set_random_seed(CONFIG.seed)\n np.random.seed(CONFIG.seed)\n\n gs_env = tf.Variable(0, trainable=False, name='global_step_env')\n inc_gs = tf.assign_add(gs_env, 1)\n\n # Make the gym environment\n if CONFIG.env == 'm... | [
"0.60145074",
"0.56942314",
"0.5621316",
"0.55984986",
"0.55666786",
"0.55119085",
"0.5498689",
"0.5415112",
"0.5407308",
"0.540608",
"0.5401533",
"0.53866255",
"0.5367705",
"0.5333861",
"0.5288149",
"0.52413166",
"0.5229818",
"0.522406",
"0.5222321",
"0.5222321",
"0.5217556"... | 0.5864468 | 1 |
Wait until pipeline has completed. | async def _wait_for_pipeline(pipeline, retry_count, retry_processing_count, retry_delay):
async def _tick_callback():
sys.stdout.write('.')
sys.stdout.flush()
await asyncio.sleep(retry_delay)
# Wait for pipeline run to start
await pipeline.wait_for_run(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_until_finished(self):\n for processor in self._processors.values():\n while not processor.done:\n time.sleep(0.1)",
"def wait_till_pipeline_is_done(adf_client, run_response):\n status = \"\"\n while status != \"Succeeded\":\n pipeline_run = adf_client.pipeli... | [
"0.6673107",
"0.66079164",
"0.66027534",
"0.6579985",
"0.6443209",
"0.63427365",
"0.63101983",
"0.63101983",
"0.62721497",
"0.6269479",
"0.6242671",
"0.62388164",
"0.62318593",
"0.6193937",
"0.6184432",
"0.61708033",
"0.61708033",
"0.61708033",
"0.61708033",
"0.61708033",
"0.... | 0.73370874 | 0 |
Get an existing EventFeedChart resource's state with the given name, id, and optional extra properties used to qualify the lookup. | def get(resource_name: str,
id: pulumi.Input[str],
opts: Optional[pulumi.ResourceOptions] = None,
description: Optional[pulumi.Input[str]] = None,
end_time: Optional[pulumi.Input[int]] = None,
name: Optional[pulumi.Input[str]] = None,
program_text:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_series_by_id(self, id):\n self._build_series_cache()\n if id in self._series_cache:\n return self._series_cache[id]",
"def get_state_by_id(state_id):\n for key, value in storage.all(\"State\").items():\n if state_id == value.id:\n return jsonify(value.to_dict... | [
"0.53145844",
"0.50874305",
"0.5078806",
"0.5046663",
"0.5029745",
"0.502753",
"0.49664393",
"0.49062055",
"0.49021143",
"0.4900839",
"0.48005772",
"0.4794655",
"0.4792962",
"0.479037",
"0.47875798",
"0.47856343",
"0.47844377",
"0.47707763",
"0.4770655",
"0.46882266",
"0.4637... | 0.65315497 | 0 |
Called with TestWithMetaClass() called since it is of type TestMetaClass cls will be TestWithMetaClass | def __call__(cls, *args, **kwargs):
print('TestMetaClass.__call__()')
return cls.__new__(cls, *args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_class_started(self, cls):",
"def test_class_ended(self, cls):",
"def setUpClass(cls):\r\n pass",
"def setUpClass(cls):\n pass",
"def setUpClass(cls):\n pass",
"def setUpClass(cls):\n pass",
"def setUpClass(cls):\n pass",
"def setup_class(cls):",
"def setu... | [
"0.77200985",
"0.7207636",
"0.70986265",
"0.7084063",
"0.7084063",
"0.7084063",
"0.7084063",
"0.69656897",
"0.69656897",
"0.6903922",
"0.68956476",
"0.6878428",
"0.68453765",
"0.6807037",
"0.6797558",
"0.6791981",
"0.6723575",
"0.6722516",
"0.6719123",
"0.671609",
"0.6704182"... | 0.73947996 | 1 |
Translate an image and a mask | def augment_translate(image, mask, trans_range):
tr_x = trans_range * np.random.uniform() - trans_range / 2
tr_y = trans_range * np.random.uniform() - trans_range / 2
trans_M = np.array([[1, 0, tr_x], [0, 1, tr_y]], dtype=np.float32)
width, height, _ = image.shape
image = cv2.wa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform(self,image,masks,aug):\n # convert to PIL Image.\n PIL_convert = transforms.ToPILImage()\n image = PIL_convert(image)\n masks = PIL_convert(masks.astype(np.int32))\n # resize the image and masks\n resize = transforms.Resize(size=(512,512))\n image = re... | [
"0.6854858",
"0.66039467",
"0.6550602",
"0.6502206",
"0.6472992",
"0.6414735",
"0.63318396",
"0.62780887",
"0.6271572",
"0.6266665",
"0.62501025",
"0.6175215",
"0.61695987",
"0.61647815",
"0.614387",
"0.6128845",
"0.6110609",
"0.6106547",
"0.6062846",
"0.6043512",
"0.59899837... | 0.7364597 | 0 |
Get a mirror reflection of an image | def mirror(image):
return cv2.flip(image, 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_reflect(image, side):\n if side not in [\"r\", \"l\", \"t\", \"b\", \"rt\", \"rb\", \"lt\", \"lb\"]:\n return 1, None\n try:\n if side == \"r\":\n result = np.zeros((image.shape[0], image.shape[1] * 2 - 1))\n result[:, : image.shape[1]] = image\n result[... | [
"0.7231107",
"0.6814588",
"0.63456154",
"0.60146576",
"0.59578174",
"0.57923067",
"0.57472366",
"0.57444584",
"0.5725976",
"0.563493",
"0.5599721",
"0.55246794",
"0.55080175",
"0.54898334",
"0.5478126",
"0.5419243",
"0.5372296",
"0.5336887",
"0.5325886",
"0.532025",
"0.530748... | 0.68775094 | 1 |
Test location endpoints permissions. | def test_location_permissions(client, testdata, json_headers, users):
dummy_location = dict(
name=_LOCATION_NAME,
opening_weekdays=[
{"weekday": w, "is_open": True, "times": _DEFAULT_TIMES} for w in _WEEKDAYS
],
opening_exceptions=[],
)
tests = [
("admin",... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_resource_server_location_endpoint(self):\n endpoint = settings.RESOURCE_SERVER_LOCATION_ENDPOINT\n access_token = config.ACCESS_TOKEN\n self.assertValidGetOicJsonEndpoint(endpoint, access_token)",
"def test_get_permissions(self):\n pass",
"def test_pds_location_endpoint(sel... | [
"0.6923277",
"0.68891567",
"0.68843085",
"0.6797217",
"0.6702105",
"0.65108734",
"0.6430061",
"0.6430061",
"0.6338864",
"0.6338864",
"0.6338864",
"0.6338864",
"0.6201289",
"0.617113",
"0.6109604",
"0.6031896",
"0.5993761",
"0.5988048",
"0.5982052",
"0.5976896",
"0.59768456",
... | 0.7435097 | 0 |
This function uses Spacy, open source NLP toolkit to find the most frequent words and parts of speech and return only nouns and verbs for word cloud | def pos_text(text):
nlp = spacy.load('en')
doc = nlp(text)
# all tokens that arent stop words or punctuations
words = [token.text.encode('ascii', 'ignore') for token in doc if token.is_stop != True and token.is_punct != True]
# noun tokens that arent stop words or punctuations
final_tokens = [t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_frequent_words(words, most_frequent): \n \n # common_words = Counter(sorted(words))\n # print common_words\n common_words = Counter(sorted(words)).most_common(most_frequent)\n print (common_words )\n most_common_words = [w for w, w_count in common_words]\n return most_common_words"... | [
"0.65255314",
"0.6525463",
"0.651756",
"0.6461675",
"0.64452595",
"0.6433547",
"0.6375605",
"0.6274459",
"0.6263648",
"0.6260995",
"0.62503517",
"0.6248734",
"0.62428135",
"0.62268895",
"0.62231165",
"0.62225676",
"0.6218376",
"0.62103724",
"0.6209652",
"0.6185677",
"0.618528... | 0.74505144 | 0 |
If the user doesn't run the program with super user privileges, don't allow them to continue. | def in_sudo_mode():
if not 'SUDO_UID' in os.environ.keys():
print("Try running this program with sudo.")
exit() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root_user_check():\n\n if not os.getuid() == 0:\n print(\"This program requires ROOT privileges. Exiting.\")\n sys.exit()",
"def _validate_running_as_fvalidation_exempt_user():\n if acm.UserName() not in FValidation_settings.SUPERUSERS:\n # Ensure that tool is run as a user exempt ... | [
"0.6670983",
"0.65723825",
"0.6499906",
"0.6452622",
"0.6352309",
"0.6325752",
"0.6254052",
"0.6235908",
"0.6084818",
"0.60810155",
"0.60425794",
"0.6019258",
"0.5947516",
"0.5934224",
"0.59335923",
"0.59239435",
"0.5922291",
"0.59071594",
"0.58692557",
"0.5858642",
"0.585571... | 0.66574454 | 1 |
This function is used to find the network interface controllers on your computer. | def find_nic():
result = subprocess.run(["iw", "dev"], capture_output=True).stdout.decode()
network_interface_controllers = wlan_code.findall(result)
return network_interface_controllers | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_controllers(self):\n controllers = list()\n try:\n rc, controllers = self.request(\"storage-systems/%s/graph/xpath-filter?query=/controller/id\" % self.ssid)\n except Exception as err:\n self.module.fail_json(msg=\"Failed to retrieve controller list! Array Id [%s]... | [
"0.68883413",
"0.6738018",
"0.6649316",
"0.6577035",
"0.6575602",
"0.6553284",
"0.6216471",
"0.61373025",
"0.61211264",
"0.6096551",
"0.60582805",
"0.6027159",
"0.59864295",
"0.59562206",
"0.59321266",
"0.5862958",
"0.58492374",
"0.58359843",
"0.5785262",
"0.57458144",
"0.571... | 0.8446196 | 0 |
This function needs the network interface controller name to put it into monitor mode. | def set_monitor_mode(controller_name):
subprocess.run(["ip", "link", "set", wifi_name, "down"])
subprocess.run(["airmon-ng", "check", "kill"])
subprocess.run(["iw", wifi_name, "set", "monitor", "none"])
subprocess.run(["ip", "link", "set", wifi_name, "up"]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_monitor(w_card):\n\n # standard name for the monitor interfaces\n mon_id = \"mon{}\".format(w_card.phy)\n\n if mon_id not in pyw.winterfaces():\n # this monitor interface is not set\n # then create a new one\n m_card = pyw.devadd(w_card, mon_id, 'monitor')\n\n # remove ... | [
"0.6458825",
"0.5693039",
"0.5667205",
"0.55445117",
"0.5512209",
"0.5296089",
"0.52943724",
"0.528377",
"0.5200232",
"0.5187931",
"0.51447374",
"0.5119589",
"0.5117981",
"0.51000065",
"0.50826347",
"0.5071153",
"0.506739",
"0.5049789",
"0.50370246",
"0.50342745",
"0.502794",... | 0.7013022 | 0 |
If you have a 5Ghz network interface controller you can use this function to put monitor either 2.4Ghz or 5Ghz bands or both. | def set_band_to_monitor(choice):
if choice == "0":
subprocess.Popen(["airodump-ng", "--band", "bg", "-w", "file", "--write-interval", "1", "--output-format", "csv", wifi_name], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
elif choice == "1":
subprocess.Popen(["airodump-ng", "--band", "a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_monitor(w_card):\n\n # standard name for the monitor interfaces\n mon_id = \"mon{}\".format(w_card.phy)\n\n if mon_id not in pyw.winterfaces():\n # this monitor interface is not set\n # then create a new one\n m_card = pyw.devadd(w_card, mon_id, 'monitor')\n\n # remove ... | [
"0.57906556",
"0.5575972",
"0.5526156",
"0.5476877",
"0.5416343",
"0.53790426",
"0.53619754",
"0.5353936",
"0.5353346",
"0.53215885",
"0.5248377",
"0.52274364",
"0.5198639",
"0.51911455",
"0.5118733",
"0.51166594",
"0.5098978",
"0.50884634",
"0.5074797",
"0.50636804",
"0.5055... | 0.5658591 | 1 |
Move all .csv files in the directory to a new backup folder. | def backup_csv():
for file_name in os.listdir():
if ".csv" in file_name:
print("There shouldn't be any .csv files in your directory. We found .csv files in your directory.")
directory = os.getcwd()
try:
os.mkdir(directory + "/backup/")
except:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect_csv(source_dir, dest_dir):\n source_dir = Path(source_dir)\n dest_dir = Path(dest_dir)\n for csvfile in source_dir.rglob(\"*.csv\"):\n species = normalized_species(csvfile)\n species_dir = dest_dir / species\n species_dir.mkdir(exist_ok=True, parents=True)\n date_ti... | [
"0.67946666",
"0.6324222",
"0.6040846",
"0.59553635",
"0.56993324",
"0.5625582",
"0.56253976",
"0.5620638",
"0.55600435",
"0.54780793",
"0.5447634",
"0.53954333",
"0.5356301",
"0.53559715",
"0.53532046",
"0.53212994",
"0.5305562",
"0.52992207",
"0.52949667",
"0.5292492",
"0.5... | 0.8382469 | 0 |
Will check if there is an ESSID in the list and then send False to end the loop. | def check_for_essid(essid, lst):
check_status = True
if len(lst) == 0:
return check_status
for item in lst:
if essid in item["ESSID"]:
check_status = False
return check_status | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disconnect_from_wifi_network(SSID):\r\n Disconnect_cmd=\"./wifi disconnect \"+ SSID\r\n get_output=subprocess.Popen(Disconnect_cmd,stdin=subprocess.PIPE,stdout=subprocess.PIPE, stderr=subprocess.PIPE,shell=True)\r\n print(\"output \",get_output.stderr.readlines())\r\n for ele in get_output.stderr.r... | [
"0.60794216",
"0.598692",
"0.59509504",
"0.55803",
"0.5564747",
"0.5399427",
"0.5386113",
"0.5282249",
"0.5184512",
"0.5159538",
"0.51400703",
"0.51364076",
"0.5126732",
"0.50981957",
"0.5076813",
"0.505709",
"0.5043856",
"0.50351864",
"0.5010498",
"0.49792638",
"0.4970683",
... | 0.704996 | 0 |
Loop that shows the wireless access points. We use a try except block and we will quit the loop by pressing ctrlc. | def wifi_networks_menu():
active_wireless_networks = list()
try:
while True:
subprocess.call("clear", shell=True)
for file_name in os.listdir():
fieldnames = ['BSSID', 'First_time_seen', 'Last_time_seen', 'channel', 'Speed', 'Privacy', 'Cipher', 'Authenticatio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _wireless_autoconnect(self):\n print \"No wired connection present, attempting to autoconnect\" + \\\n \"to wireless network\"\n if self.GetWirelessInterface() is None:\n print 'Autoconnect failed because wireless interface returned None'\n return\n for x... | [
"0.5661988",
"0.56234217",
"0.55290186",
"0.5503526",
"0.5501044",
"0.5421274",
"0.5411491",
"0.5393873",
"0.53869754",
"0.5329749",
"0.5257652",
"0.522145",
"0.52115947",
"0.51861346",
"0.5172016",
"0.51498556",
"0.51216334",
"0.5116131",
"0.5101907",
"0.50852776",
"0.507667... | 0.578324 | 0 |
SET YOUR NETWORK CONTROLLER INTERFACE INTO MANAGED MODE & RESTART NETWORK MANAGER | def set_into_managed_mode(wifi_name):
subprocess.run(["ip", "link", "set", wifi_name, "down"])
subprocess.run(["iwconfig", wifi_name, "mode", "managed"])
subprocess.run(["ip", "link", "set", wifi_name, "up"])
subprocess.run(["service", "NetworkManager", "start"]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_monitor_mode(controller_name):\n subprocess.run([\"ip\", \"link\", \"set\", wifi_name, \"down\"])\n subprocess.run([\"airmon-ng\", \"check\", \"kill\"])\n subprocess.run([\"iw\", wifi_name, \"set\", \"monitor\", \"none\"])\n subprocess.run([\"ip\", \"link\", \"set\", wifi_name, \"up\"])",
"de... | [
"0.6544468",
"0.6068425",
"0.5939272",
"0.59133303",
"0.58081573",
"0.57905763",
"0.5754437",
"0.5721106",
"0.5717591",
"0.570897",
"0.5670514",
"0.5661999",
"0.5652327",
"0.56520283",
"0.5628384",
"0.56180745",
"0.5583876",
"0.55828935",
"0.554824",
"0.5541455",
"0.5528441",... | 0.62129533 | 1 |
Installing Nukestudio integration for avalon | def install(config):
# adding all events
_register_events()
log.info("Registering NukeStudio plug-ins..")
pyblish.register_host("nukestudio")
pyblish.register_plugin_path(PUBLISH_PATH)
avalon.register_plugin_path(avalon.Loader, LOAD_PATH)
avalon.register_plugin_path(avalon.Creator, CREATE_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup():\n\n # check version and download the latest version\n get_latest_codeql()\n # install vscode?\n # clone codeql libs\n # setup vscode + codeql\n # wait for user",
"def YumInstall(vm):\n vm.Install('build_tools')\n vm.InstallEpelRepo()\n vm.InstallPackages(YUM_PACKAGES)",
"def i... | [
"0.59112954",
"0.5801362",
"0.57604647",
"0.5751015",
"0.5746859",
"0.5746859",
"0.5736964",
"0.57231927",
"0.56631714",
"0.5650434",
"0.5618824",
"0.5610054",
"0.5561496",
"0.5538794",
"0.5509178",
"0.5506965",
"0.5490859",
"0.5474634",
"0.5456186",
"0.5446026",
"0.5379426",... | 0.7231068 | 0 |
Event for automatic tag creation after nukestudio start | def add_tags(event):
add_tags_from_presets() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tagger():",
"def add_tagging(self, task_instance):",
"def tags():",
"def tag(self, tag):\n self.tag = tag",
"def __init__(self, tag):\n self.tag = tag",
"def main():\n ## real SWAT tags",
"def _handle_new_tag(self, tag_name):\n log.debug(\"Handling new tag: %s\", tag_name)\n... | [
"0.6683891",
"0.6166422",
"0.6051898",
"0.6009285",
"0.6001859",
"0.5991593",
"0.5937471",
"0.5910187",
"0.5892085",
"0.58542895",
"0.5783906",
"0.5719624",
"0.57189566",
"0.5701336",
"0.56843513",
"0.56510574",
"0.56495506",
"0.56162524",
"0.56016713",
"0.55735606",
"0.55646... | 0.6628189 | 1 |
Event for launching workfiles after nukestudio start | def launch_workfiles_app(event):
from .lib import set_workfiles
set_workfiles()
# Closing the new project.
event.sender.close()
# Deregister interest as its a one-time launch.
hiero.core.events.unregisterInterest(
"kAfterNewProjectCreated", launch_workfiles_app
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_workunit(self, workunit):\r\n pass",
"def start_workunit(self, workunit):\r\n pass",
"def launch(self):",
"def startup(self) -> None:",
"def on_run(self):\n pass",
"def on_start(self):\n pass",
"def on_start(self):\n pass",
"def on_start(self):\n pass",
"... | [
"0.60503876",
"0.60503876",
"0.5960573",
"0.5944831",
"0.5931613",
"0.5873871",
"0.5873871",
"0.5873871",
"0.5873871",
"0.5873871",
"0.5873871",
"0.5873871",
"0.5873871",
"0.58425134",
"0.5789881",
"0.57546765",
"0.57524383",
"0.57465667",
"0.57390577",
"0.5734359",
"0.569908... | 0.72100705 | 0 |
Uninstalling Nukestudio integration for avalon | def uninstall():
log.info("Deregistering NukeStudio plug-ins..")
pyblish.deregister_host("nukestudio")
pyblish.deregister_plugin_path(PUBLISH_PATH)
avalon.deregister_plugin_path(avalon.Loader, LOAD_PATH)
avalon.deregister_plugin_path(avalon.Creator, CREATE_PATH) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def YumUninstall(vm):\n _Uninstall(vm)",
"def disintegrate():\n click.confirm('Do you really want to uninstall?', abort=True)\n if click.confirm('Do you want to remove installed AppImages?'):\n cfgmgr = ConfigManager()\n if os.path.exists(cfgmgr['bin']):\n print(fc(\"{y}Removing b... | [
"0.69139904",
"0.67664385",
"0.6713412",
"0.658921",
"0.6582422",
"0.65717053",
"0.6429084",
"0.64164436",
"0.64012337",
"0.63254404",
"0.63241494",
"0.62933135",
"0.62265223",
"0.6198119",
"0.6187029",
"0.61726505",
"0.6163213",
"0.61337876",
"0.6109491",
"0.60967004",
"0.60... | 0.8209004 | 0 |
confirms include, collection_id, and arbitrary query_params arguments to get_role_list are assembled correctly | def test_get_role_list_params(client):
register_api_route_fixture_file("gcs", "/roles", "role_list.json")
# no args
res = client.get_role_list()
assert res["code"] == "success"
params = get_last_request().params
assert params == {}
# collection_id
res = client.get_role_list(collection_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grant_role(self, role, principal_ids):",
"def test_list_role(self):\n pass",
"def get_roles(role):",
"def realms_include_users_include_roles(self, request, context):\n context.set_code(grpc.StatusCode.UNIMPLEMENTED)\n context.set_details('Method not implemented!')\n raise NotI... | [
"0.566126",
"0.5641907",
"0.549281",
"0.5491365",
"0.5476427",
"0.5434943",
"0.53873456",
"0.5347055",
"0.53249615",
"0.5294371",
"0.52330583",
"0.5211595",
"0.52111673",
"0.520648",
"0.51984966",
"0.51867443",
"0.5163925",
"0.5142356",
"0.5119205",
"0.50807005",
"0.5077429",... | 0.67135143 | 0 |
Constructor. address the adjusted address where the resource exists name the name of the resource size the size of the resource | def __init__(self, address: int, name: unicode, size: int):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, owner, resourceFile):\n self.checksum = Path(resourceFile).md5 # Just use the path name as a unique ID\n _Resource.__init__(self, owner, resourceFile)\n if self._idevice:\n self._idevice.userResources.append(self)",
"def __init__(__self__,\n reso... | [
"0.6703524",
"0.66375357",
"0.65862215",
"0.6464372",
"0.63966644",
"0.63885355",
"0.63847905",
"0.63403594",
"0.63277406",
"0.63110715",
"0.6306028",
"0.621923",
"0.62104845",
"0.61895126",
"0.6185376",
"0.61687636",
"0.61616343",
"0.6160726",
"0.61132133",
"0.6111263",
"0.6... | 0.6911514 | 0 |
Returns the adjusted address where the resource exists. the adjusted address where the resource exists | def getAddress(self) -> int:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAbsoluteAddress(program: ghidra.program.model.listing.Program, address: ghidra.program.model.address.Address) -> ghidra.program.model.address.Address:\n ...",
"def get_address(self):\n entity = self\n if entity.abstract_entity:\n entity = self.get_real_ancestor()\n i... | [
"0.69058967",
"0.67714584",
"0.666402",
"0.66211534",
"0.6605682",
"0.65958816",
"0.6588754",
"0.6421349",
"0.6374805",
"0.6374805",
"0.63458425",
"0.6323087",
"0.62857187",
"0.6277596",
"0.62464964",
"0.6245285",
"0.6242081",
"0.6242081",
"0.6242081",
"0.6191737",
"0.6189747... | 0.678774 | 1 |
Nondivisible subset length is the size of maximal subset of the iterable where sum of any two numbers in the subset is not evenly divisible by key | def non_divisible_subset_len(iterable, key):
# To check whether the given iterable is list or tuple
if type(iterable) == list or type(iterable) == tuple:
pass
else:
raise TypeError("Iterable should be of either list or tuple")
# To check whether all the given items in the itera... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_max_divisible_subset_length(self, nums):\n if not nums:\n return 0\n \n max_lengths = [1]\n max_length = 1\n\n for i in range(1, len(nums)):\n max_length_here = 1\n for j in range(i - 1, -1, -1):\n if nums[i] % nums[j] == 0:... | [
"0.65000314",
"0.63650805",
"0.6202835",
"0.6035759",
"0.6025423",
"0.59914047",
"0.5984323",
"0.594293",
"0.58675486",
"0.5857546",
"0.58171254",
"0.5811228",
"0.57724315",
"0.57679975",
"0.57505786",
"0.57505786",
"0.57312775",
"0.5694013",
"0.5674147",
"0.5672041",
"0.5669... | 0.85606617 | 0 |
Validate the move Move is valid as long as it is within the size of the board and the selected move has 1 on the board | def validate_move(move, player_board):
select_row = move.select_row
select_col = move.select_col
player_board_rows = player_board.shape[0]
player_board_cols = player_board.shape[1]
if select_row >= player_board_rows or select_row < 0 or \
select_col >= player_board_cols or select_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_move(self, move_from, move_to, board):\n\n pass",
"def checkValidMove(self, move):\n boardCopy = copy.deepcopy(self)\n tilesChange = False\n if move == Move.UP:\n boardCopy.moveUp()\n elif move == Move.DOWN:\n boardCopy.moveDown()\n eli... | [
"0.8155731",
"0.7684377",
"0.7618473",
"0.7616978",
"0.7614814",
"0.7602329",
"0.75932",
"0.75758666",
"0.7562776",
"0.7490464",
"0.74761945",
"0.7468638",
"0.7445464",
"0.7401881",
"0.73814255",
"0.7354089",
"0.73278487",
"0.731681",
"0.72750676",
"0.7274984",
"0.7271459",
... | 0.8327981 | 0 |
return rendered news page for particular league | def league(request,league_id=1):
#define variables
args = {}
news = []
#getting data form models
this_league = get_object_or_404(League, pk = league_id)
leagues = League.objects.all().exclude(pk = league_id).order_by('name')
teams = this_league.team_set.all().order_by('name')
#collecting all news of leagu i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def news(request,news_id):\n\n\t#define variables\n\targs = {}\n\t\n\t#getting data form models\n\tnews = get_object_or_404(News, pk = news_id)\n\tleagues = League.objects.all().order_by('name')\n\n\t#context data initialization into dictionary 'args'\n\targs['news'] = news\n\targs['leagues'] = leagues\n\n\treturn... | [
"0.68774676",
"0.67900616",
"0.6725451",
"0.6174572",
"0.5997826",
"0.5976559",
"0.57173777",
"0.5706897",
"0.5701744",
"0.56996924",
"0.5645684",
"0.56017315",
"0.55898",
"0.55257255",
"0.5511395",
"0.5507982",
"0.5497172",
"0.5494665",
"0.548458",
"0.5476713",
"0.5473583",
... | 0.7584234 | 0 |
return rendered news page for particular team | def team(request,league_id = 1,team_id = -1):
#define variables
args = {}
#getting data form models
this_team = get_object_or_404(Team, pk = team_id)
news = this_team.news_set.all().order_by('date')
this_league = get_object_or_404(League, pk = league_id)
teams = this_league.team_set.all().exclude(pk = team_id)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def teams(teamid):\n team_summary = team.TeamSummary(teamid)\n team_summary_info = team_summary.info()\n team_season_ranks = team_summary.season_ranks()\n\n team_common_roster = team.TeamCommonRoster(teamid)\n roster = team_common_roster.roster()\n coaches = team_common_roster.coaches()\n\n se... | [
"0.6563251",
"0.6435922",
"0.64206237",
"0.63224846",
"0.63104963",
"0.6176217",
"0.6175984",
"0.6127084",
"0.60202974",
"0.59195435",
"0.58956784",
"0.58947855",
"0.58543175",
"0.58379686",
"0.58256704",
"0.57962614",
"0.5699692",
"0.56968397",
"0.5681443",
"0.56651425",
"0.... | 0.7250988 | 0 |
Generate unique integer according to current timestamp | def get_unique_integer() -> int:
return int(time.time()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_unique_id():\n global unique_id_increment\n if unique_id_increment is None:\n unique_id_increment = 0\n unique_id_increment += 1\n return '%d%d' % (int(time.time()), unique_id_increment)",
"def get_unique_id():\n global unique_id_increment\n if unique_id_increment is None:\n unique_id... | [
"0.7856462",
"0.78515995",
"0.7497418",
"0.73515403",
"0.7338771",
"0.7192405",
"0.71902573",
"0.7101343",
"0.70933485",
"0.7085857",
"0.7079608",
"0.7027132",
"0.70200336",
"0.7017982",
"0.70006967",
"0.69905806",
"0.6986718",
"0.6982327",
"0.69638735",
"0.69638735",
"0.6953... | 0.8504283 | 0 |
Allows user to write study notes | def write_note():
title_note = request.form.get("title")
note = request.form.get("note")
date_string = datetime.today().strftime('%Y-%m-%d')
diary = Note(user_id=session["user_id"],title_note = title_note, note_created=date_string, note=note)
db.session.add(diary)
db.session.commit()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def note(self):\n content = sys.argv[2]\n self.record('NOTE %s' % content)\n print('Note added')",
"def add_note():\n pass",
"def note():",
"def enter_notes():\n notes = input(\"Notes (Optional): \")\n clean_scr()\n return notes",
"def notes(self, notes: str):\n self... | [
"0.7057176",
"0.67643934",
"0.665652",
"0.6586128",
"0.6442264",
"0.64218664",
"0.6266761",
"0.6193537",
"0.61804986",
"0.61759335",
"0.61683375",
"0.6127927",
"0.6110346",
"0.61034226",
"0.61034226",
"0.61034226",
"0.61034226",
"0.61034226",
"0.60408026",
"0.60310286",
"0.59... | 0.6808465 | 1 |
Allows user to edit study notes | def edit_current_note():
note_id = request.form.get("note_id")
edited_note = Note.query.get(note_id)
edited_note.title_note = request.form.get("title")
edited_note.note = request.form.get("note")
db.session.commit()
return "note edited" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_notes(entry):\n entry.notes = get_notes()\n entry.save()\n input(\"Edit successful. \")\n return entry",
"def edit_note(self):\r\n names = [note.__str__() for note in self.source.notes]\r\n \r\n selected = self.notes_list.get(tk.ACTIVE)\r\n dex = names.index(selec... | [
"0.7481409",
"0.70780516",
"0.69273406",
"0.6883732",
"0.68073225",
"0.67183787",
"0.63874334",
"0.63263977",
"0.63196224",
"0.6284791",
"0.6251205",
"0.6235056",
"0.6213606",
"0.6194762",
"0.6191227",
"0.6178484",
"0.61163044",
"0.6061758",
"0.59980875",
"0.59907037",
"0.597... | 0.71523476 | 1 |
notifies author of question when a user has commented on their question | def notify_author_comment(comment, author_email, author_username ,question, question_title, comment_author):
content = "Hello " + author_username + ","+ "\n" + "\n" + "Fellow camper, " + comment_author + " has commented on your question:" + "\n" + question_title + "\n" + question + "!" + "\n" + "\n" +"They have ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_comment_was_posted(sender, comment, target, user_data, request, **kwargs):\n if comment.user:\n if request.user.is_authenticated() and request.user.is_active:\n comment.is_public = True\n comment.save()\n notify_comment_followers(comment)\n else:\n ... | [
"0.6443654",
"0.6366563",
"0.63436764",
"0.6194349",
"0.61881745",
"0.61756885",
"0.6127502",
"0.60770917",
"0.60767037",
"0.60659873",
"0.6062416",
"0.6032633",
"0.5998679",
"0.5938301",
"0.5875801",
"0.57994074",
"0.577175",
"0.57611096",
"0.5754438",
"0.57495385",
"0.57253... | 0.640224 | 1 |
allows user to add a vote to a comment | def add_vote():
comment_id = request.form.get("comment_id")
voted_item = request.form.get("voted_item")
comment = Comment.query.get(int(comment_id))
vote_check = Vote.query.filter(Vote.comment_id == int(comment_id), Vote.user_id == session['user_id']).first()
if vote_check:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmd_comment_vote(client, args):\n comment_vote = client.comment_vote(args.comment_id, args.vote)\n generate_output({'comment_vote': comment_vote})",
"async def vote_comment(*, comment: models.Comment = Depends(resolve_comment), vote: int = Path(..., ge=-1, le=1),\n current_user: m... | [
"0.75026244",
"0.7184952",
"0.7118605",
"0.6801225",
"0.67811394",
"0.67796993",
"0.6661174",
"0.6647494",
"0.6619402",
"0.6549522",
"0.6519169",
"0.63535947",
"0.6336158",
"0.6289053",
"0.6271676",
"0.625382",
"0.62502044",
"0.62115693",
"0.6190949",
"0.6169893",
"0.613656",... | 0.79480314 | 0 |
This function returns a secret word that the player is trying to guess in the game. This function initially has a very small list of words that it can select from to make it easier for you to write and debug the main game playing program. In Part II of writing this program, you will reimplement this function to select ... | def get_word():
words = []
for line in open(LEXICON_FILE):
line = line.strip()
words.append(line)
index = random.randrange(0,len(words))
return words[index] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wordLook():\n\tf = open('hangwords.txt', 'r')\n\twordChoice = f.readlines()\n\tword = wordChoice[randint(0, 853)]\n\t# break up word into list format tp serperate the letters \n\twordList = list(word.lower())\n\t# Delete the \\n at end of string\n\twordList.pop()\n\tf.close()\n\treturn wordList",
"def choose... | [
"0.71308315",
"0.7057476",
"0.69611734",
"0.6947381",
"0.6933888",
"0.68507004",
"0.6695501",
"0.6665739",
"0.6665739",
"0.66471404",
"0.66395277",
"0.6621552",
"0.661802",
"0.65943456",
"0.6525272",
"0.65127265",
"0.6512188",
"0.6488969",
"0.6444034",
"0.6442911",
"0.6430064... | 0.72470707 | 0 |
To play the game, we first select the secret word for the player to guess and then play the game using that secret word. | def main():
secret_word = get_word()
play_game(secret_word) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n secret_word = get_word()\n print(secret_word)\n play_game(secret_word)",
"def play_game(secret_word):\n word=secret_word\n hidden='-'\n inp=''\n no_guesses = 8\n list_word=list(word)\n \n for i in range(len(word)-1):\n hidden=hidden+'-'\n hidden_word=list(hid... | [
"0.7608266",
"0.73946077",
"0.7202679",
"0.7153712",
"0.69341576",
"0.69341576",
"0.6932935",
"0.69293797",
"0.68760604",
"0.6788483",
"0.67774546",
"0.67659974",
"0.67088085",
"0.66971546",
"0.6678389",
"0.6649174",
"0.6623146",
"0.6613772",
"0.6546398",
"0.65367943",
"0.652... | 0.77939516 | 0 |
Compute the Cumulative Match Characteristic (CMC) This function assumes that gallery labels have no duplication. If there are duplications, random downsampling will be performed on gallery labels, and the computation will be repeated to get an average result. | def cmc(distmat, glabels=None, plabels=None, ds=None, repeat=None):
m, n = distmat.shape
if glabels is None and plabels is None:
glabels = np.arange(0, m)
plabels = np.arange(0, n)
if isinstance(glabels, list):
glabels = np.asarray(glabels)
if isinstance(plabels, list):
p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cumulative_cm(locations, recombination_data):\n np_locations = np.array(locations, dtype = np.uint32, copy = False)\n base_ends = recombination_data.bases\n assert np.all(np_locations <= base_ends[-1])\n end_index = np.searchsorted(base_ends, np_locations, side = \"left\")\n \n cm_ends = reco... | [
"0.5890878",
"0.5848888",
"0.58008397",
"0.5734397",
"0.57286626",
"0.5726719",
"0.569035",
"0.5667343",
"0.5574049",
"0.55343145",
"0.55291414",
"0.53503186",
"0.53503186",
"0.5342706",
"0.5333415",
"0.52657264",
"0.5221554",
"0.52170813",
"0.52044076",
"0.5181191",
"0.51798... | 0.64962184 | 0 |
Validate requested XGBoost models, and download if necessary | def validate_requested_xgb_model(xgboost_model_files, xgboost_model_hashes, model_dir):
for _, model_file in xgboost_model_files.items():
if not check_model_presence(
model_file, xgboost_model_hashes[model_file], model_dir
):
download_model(model_file, xgboost_model_hashes[mo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_models(self, savepath = None):\n \n self.gbms = []\n self.accs = []\n \n for i in range(self.train_y.shape[1]):\n \n if self.ylabels is not None:\n print('Training GBM for {}'.format(self.ylabels[i]))\n\n \n ... | [
"0.64299595",
"0.6148163",
"0.6085698",
"0.60466444",
"0.5939496",
"0.5895649",
"0.58860964",
"0.5862918",
"0.58372295",
"0.5816074",
"0.58105147",
"0.57988924",
"0.5766809",
"0.5755663",
"0.57471526",
"0.57411814",
"0.5738012",
"0.5731567",
"0.56657004",
"0.5625705",
"0.5598... | 0.834346 | 0 |
Initialize xgboost models and return them in a dict with ion types as keys. | def initialize_xgb_models(xgboost_model_files, model_dir, nthread) -> dict:
xgb.set_config(verbosity=0)
xgboost_models = {}
for ion_type in xgboost_model_files.keys():
model_file = os.path.join(model_dir, xgboost_model_files[ion_type])
logger.debug(f"Initializing model from file: `{model_fil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gnn_model_dict():\n\n from .message_passing import agnnconv, econv, gatconv, meta, nnconv, nnconv_elu, nnconv_old\n\n models = {\n \"agnnconv\" : agnnconv.AGNNConvModel,\n \"econv\" : econv.EConvModel,\n \"gatconv\" : gatconv.GATConvModel,\n \"nnconv\" ... | [
"0.61606777",
"0.5918568",
"0.5903259",
"0.58406335",
"0.5829939",
"0.5680115",
"0.5653238",
"0.56514674",
"0.55578864",
"0.5468737",
"0.5425358",
"0.54230714",
"0.53971845",
"0.5360024",
"0.535018",
"0.53333044",
"0.53205484",
"0.53167325",
"0.5307884",
"0.53022265",
"0.5300... | 0.7297598 | 0 |
Pad the encoder input sequence with pad_id up to max_len. | def pad_encoder_input(self, max_len, pad_id):
while len(self.enc_input) < max_len:
self.enc_input.append(pad_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad_encoder_input(self, max_len, pad_id):\n\t\twhile len(self.enc_input) < max_len:\n\t\t\tself.enc_input.append(pad_id)\n\t\tif self.hps.pointer_gen.value:\n\t\t\twhile len(self.enc_input_extend_vocab) < max_len:\n\t\t\t\tself.enc_input_extend_vocab.append(pad_id)",
"def pad_encoder_input(self, max_sen_len,... | [
"0.84111005",
"0.83670455",
"0.78861535",
"0.77806264",
"0.7585119",
"0.743573",
"0.7297612",
"0.7000173",
"0.69484323",
"0.67908096",
"0.67548245",
"0.67338777",
"0.6727983",
"0.66444",
"0.6637141",
"0.66080266",
"0.6583292",
"0.6533382",
"0.65153736",
"0.64641315",
"0.63768... | 0.8728963 | 0 |
Open a .psd file into a layered image. | def openLayer_PSD(file: str) -> LayeredImage:
from psdtoolsx import PSDImage
from psdtoolsx.constants import BlendMode as psdB
blendLookup = {
psdB.NORMAL: BlendType.NORMAL,
psdB.MULTIPLY: BlendType.MULTIPLY,
psdB.COLOR_BURN: BlendType.COLOURBURN,
psdB.COLOR_DODGE: BlendType.COLOURDODGE,
psdB.OVERLAY: Ble... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_layered_psd_from_images():\n\n\t\n\tdoc = open_document(FILEPATHS[0], show=False)\n\tdoc_root = doc.rootNode()\n\t\n\tdocs = []\n\tdocs.append(doc)\n\n\tall_layers = get_layers(doc)\n\tfor i in range(1, len(FILEPATHS)):\n\t\tdocx = open_document(FILEPATHS[i], show=False)\n\t\tdocs.append(docx)\n\t\tdocx_l... | [
"0.70316637",
"0.6357926",
"0.6075309",
"0.5984596",
"0.5983534",
"0.5823749",
"0.5449524",
"0.5415109",
"0.5315161",
"0.5287695",
"0.5240525",
"0.51892614",
"0.50492555",
"0.50237244",
"0.50173485",
"0.498909",
"0.4968082",
"0.49592397",
"0.49481916",
"0.4914721",
"0.4912127... | 0.7753207 | 0 |
Save a layered image as .psd. | def saveLayer_PSD(fileName: str, layeredImage: LayeredImage) -> None:
del fileName, layeredImage
Logger(FHFormatter()).logPrint("Saving PSDs is not implemented in psdtoolsx", LogType.ERROR)
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_layered_psd_from_images():\n\n\t\n\tdoc = open_document(FILEPATHS[0], show=False)\n\tdoc_root = doc.rootNode()\n\t\n\tdocs = []\n\tdocs.append(doc)\n\n\tall_layers = get_layers(doc)\n\tfor i in range(1, len(FILEPATHS)):\n\t\tdocx = open_document(FILEPATHS[i], show=False)\n\t\tdocs.append(docx)\n\t\tdocx_l... | [
"0.723336",
"0.6287",
"0.5945773",
"0.58449036",
"0.58225334",
"0.5794125",
"0.57345545",
"0.5729279",
"0.5700105",
"0.56383604",
"0.56371945",
"0.5627265",
"0.56265366",
"0.5614592",
"0.5606787",
"0.55777967",
"0.55578464",
"0.5548718",
"0.5530321",
"0.5501255",
"0.5488118",... | 0.74069333 | 0 |
Dispatch requests asynchronously and return the time taken, as well as the results. | def dispatch(method, get_data, ports):
reqs = (grequests.request(method, f'http://localhost:{port}/', json=data) for port in ports for data in get_data)
responses = grequests.map(reqs)
total_duration = sum([res.elapsed.total_seconds() for res in responses])
return total_duration, responses | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_http_speed(self):\n log.msg(\"timing retrival time for %s\"\n %self.http_url)\n def got_response(body):\n self.report['http_response_time'] = (datetime.now() - self.http_request_start_time).total_seconds()\n self.report['http_success'] = True\n ... | [
"0.6149418",
"0.6064092",
"0.58082193",
"0.5657326",
"0.5642761",
"0.562143",
"0.5620407",
"0.55891883",
"0.55891883",
"0.5576435",
"0.5576351",
"0.556694",
"0.5565386",
"0.5560861",
"0.5488374",
"0.54805803",
"0.5468408",
"0.5468408",
"0.5468408",
"0.5411158",
"0.53357565",
... | 0.6201305 | 0 |
This is a function that takes the current desired environment and applies it to this objects assigned farm. | def _update_environment(self, environment: Environment) -> None:
e_vals, f_vals = environment.values, self.farm_status.values
self._generic_update(e_vals, f_vals, 'water_temp', 'water_heater', 'water_cooler') # only works if hydroponic
self._generic_update(e_vals, f_vals, 'pH', 'ph_up', 'ph_do... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_environmentals(self):\n for k, v in utils.slurm_envs(default.SBATCH_VARS_FOR_WORKFLOW).items():\n setattr(self, k, v)",
"def environment(self, environment):\n\n self._environment = environment",
"def environment(self, environment):\n\n self._environment = environment",
... | [
"0.6536199",
"0.62345725",
"0.62345725",
"0.62345725",
"0.61675054",
"0.61066824",
"0.61066824",
"0.6029343",
"0.5896277",
"0.5889443",
"0.5833063",
"0.58280945",
"0.58220154",
"0.5818177",
"0.579179",
"0.5780626",
"0.57663465",
"0.57508075",
"0.5731225",
"0.56958807",
"0.569... | 0.64248025 | 1 |
This API returns the realtime and historical sector performances calculated from S&P500 incumbents. | def get_sector(self):
_FUNCTION_KEY = "SECTOR"
# The keys for the json output
_DATA_KEYS = ["Rank A: Real-Time Performance",
"Rank B: 1 Day Performance",
"Rank C: 5 Day Performance",
"Rank D: 1 Month Performance",
"Rank E: 3 Month Performance",
"Rank F: Ye... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sector_data() -> pd.DataFrame:\n sector_perf = SectorPerformances(\n key=cfg.API_KEY_ALPHAVANTAGE, output_format=\"pandas\"\n )\n # pylint: disable=unbalanced-tuple-unpacking\n df_sectors, _ = sector_perf.get_sector()\n return df_sectors",
"def get_sector_data() -> pd.DataFrame:\n ... | [
"0.63937575",
"0.63937575",
"0.6107021",
"0.584272",
"0.57958245",
"0.57420665",
"0.55617976",
"0.5456051",
"0.54522693",
"0.54469967",
"0.53412306",
"0.5307351",
"0.52837706",
"0.527293",
"0.5269472",
"0.51601136",
"0.51519954",
"0.5135136",
"0.511851",
"0.51100725",
"0.5098... | 0.6586169 | 0 |
Call the ESO SkyCalc CLI and save atmospheric data used by this package. Data consists of zenith transmission curves and extinctioncorrected airglow emission spectra tabulated on a 0.01nm grid covering 3001100nm. Data are saved to a FITS file data/atmosphere.fits relative to this package's installation directory. | def prepare_atmosphere(overwrite=True):
path = astropy.utils.data._find_pkg_data_path('../data/atmosphere.fits')
if not overwrite and os.path.exists(path):
print('Atmosphere file exists and overwrite is False.')
return
# Specify how SkyCalc will be called.
params = dict(
airmass=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(name, line1, line2, orbital_filename):\n #name = \"TERRA\"\n #line1 = \"1 25994U 99068A 16048.43680378 .00000258 00000-0 67198-4 0 9999\"\n #line2 = \"2 25994 98.1982 124.4247 0001352 105.3907 254.7441 14.57126067859938\"\n satellite = ephem.readtle(name, line1, line2)\n \n\n # La... | [
"0.5626336",
"0.5522988",
"0.5394692",
"0.5384439",
"0.5384439",
"0.5333407",
"0.5277568",
"0.52726984",
"0.52540714",
"0.52278405",
"0.51994836",
"0.5189382",
"0.5177408",
"0.515981",
"0.51482916",
"0.5130509",
"0.51291865",
"0.51224715",
"0.5121149",
"0.51202375",
"0.511297... | 0.71747017 | 0 |
Prepare the solar spectrum used by this package. Download the STIS reference solar spectrum and convert to the format used by this package by restricting to optical wavelengths (3001100nm) and save as a binary FITS table. This solar spectrum is documented in `Bohlin, Dickinson, & Calzetti 2001, | def prepare_solarspec(overwrite=True):
path = astropy.utils.data._find_pkg_data_path('../data/solarspec.fits')
if not overwrite and os.path.exists(path):
print('Solarspec file exists and overwrite is False.')
return
print('Downloading reference solar spectrum...')
t = astropy.table.Table... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spectrl2_data():\n # reference spectra generated with solar_utils==0.3\n kwargs = {\n 'surface_tilt': 0,\n 'relative_airmass': 1.4899535986910446,\n 'apparent_zenith': 47.912086486816406,\n 'aoi': 47.91208648681641,\n 'ground_albedo': 0.2,\n 'surface_pressure': 1... | [
"0.5891137",
"0.5842269",
"0.58357185",
"0.57103133",
"0.56977385",
"0.5544305",
"0.55162185",
"0.55162185",
"0.5462891",
"0.5440852",
"0.54205424",
"0.5405149",
"0.5385206",
"0.53745246",
"0.53483886",
"0.5335606",
"0.53354347",
"0.5330976",
"0.52825403",
"0.52512586",
"0.52... | 0.70718664 | 0 |
Check if lons, lats are the same for different fields in fieldset | def checkField(fieldset, text=True):
if text:
print "\nFieldset contains the following fields:"
for i in range(len(fieldset.fields)):
print fieldset.fields[i].name
ulon = fieldset.U.grid.lon
ulat = fieldset.U.grid.lat
udep = fieldset.U.grid.depth
vlon = fieldset.V.grid.l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_duplicate_fields_in_fieldsets(self):\n original_fieldsets = self.form.fieldsets\n test_fieldsets = (\n ('Your Name', {\n 'position': 1,\n 'fields': [('first_name', 'last_name', )],\n }),\n (None, {\n 'classes': ... | [
"0.61925644",
"0.561138",
"0.5493184",
"0.54422003",
"0.54071176",
"0.54055834",
"0.53922296",
"0.531817",
"0.52851456",
"0.5272306",
"0.5271701",
"0.5265847",
"0.5245239",
"0.52274305",
"0.5166691",
"0.5149983",
"0.51452583",
"0.5113438",
"0.5096878",
"0.50829583",
"0.503480... | 0.6427907 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.