query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
penalizes the l2 distance to the goal (almost linearly) and a small penalty for torques coming from actions | def _reward(self, a):
xrel = self._body_coord()[0] - self.goal
dist = np.sum(xrel ** 2)
return (
- self.cx * dist / (np.sqrt(dist) + 1) - self.cu * np.sum(a ** 2)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def penalty(self):\n return 0",
"def h(self,pos_0,pos_1,n):\r\n \r\n cost=((pos_0-self.goal[0])**2+(pos_1-self.goal[1])**2)**(1/2) #+ ( (n - floor(atan2((self.goal[1] - self.start[1]), (self.goal[0] - self.start[0])))) / 30)\r\n \r\n return cost",
"def heuristi... | [
"0.61494523",
"0.6131153",
"0.6119918",
"0.60916823",
"0.6055764",
"0.6055536",
"0.5966627",
"0.58956623",
"0.5894354",
"0.58891404",
"0.5873126",
"0.5863123",
"0.585692",
"0.582269",
"0.58090496",
"0.57949734",
"0.57556975",
"0.57531273",
"0.57396716",
"0.570395",
"0.5684955... | 0.56220204 | 26 |
computes diag(v1) dot M dot diag(v2). returns np.ndarray with same dimensions as M | def v1Mv2(v1, M, v2):
return v1[:, None] * M * v2[None, :] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vec_dot(v1,v2):\r\n \r\n return np.dot(v1,v2)",
"def diag(v, k=0):\n\n if not use_origin_backend(v):\n if not isinstance(v, dparray):\n pass\n else:\n return dpnp_diag(v, k)\n\n return call_origin(numpy.diag, v, k)",
"def vdot(a, b):\n return np.vdot(a.rav... | [
"0.6502854",
"0.6264067",
"0.6235242",
"0.6111132",
"0.60820174",
"0.6053548",
"0.6019043",
"0.60024",
"0.59885395",
"0.59714615",
"0.5968381",
"0.596071",
"0.5959117",
"0.59306157",
"0.5902412",
"0.5900423",
"0.58945966",
"0.58917797",
"0.58533454",
"0.58418703",
"0.58413756... | 0.64991665 | 1 |
Calculate the great circle distance between two points on the earth (specified in decimal degrees) using the haversince formula. | def calculate_distance_between_coordinates(coordinate1, coordinate2):
# convert decimal degrees to radians
lon1, lat1, lon2, lat2 = map(radians, [coordinate1[0], coordinate1[1], coordinate2[0], coordinate2[1]])
# haversine formula
dlon = lon2 - lon1
dlat = lat2 - lat1
a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def great_circle(lat_1, long_1, lat_2, long_2):\n long_1 = m.radians(long_1)\n lat_1 = m.radians(lat_1)\n long_2 = m.radians(long_2)\n lat_2 = m.radians(lat_2)\n\n d = 2 * 6367.45 * m.asin(\n m.sqrt(haversine(lat_2 - lat_1)\n + m.cos(lat_1)*m.cos(lat_2) *\n haversine(long... | [
"0.78193885",
"0.7504675",
"0.73117673",
"0.7213777",
"0.71165466",
"0.7028012",
"0.69869894",
"0.6976003",
"0.6975644",
"0.69554234",
"0.69376063",
"0.69251305",
"0.68931514",
"0.68912673",
"0.68764615",
"0.6870195",
"0.68657935",
"0.68600315",
"0.68593353",
"0.68081456",
"0... | 0.0 | -1 |
Return windows of indices into the flattened data. data[index_matrix[i]] returns the flattened window around the ith element. | def create_index_matrix(data_shape, window_shape):
n_data = np.prod(data_shape)
n_window = np.prod(window_shape)
box = np.indices(window_shape)
index_matrix = np.zeros((n_data, n_window), dtype=np.int32)
shifts = np.unravel_index(np.arange(n_data), data_shape)
offset = (np.array(window_shape)-1)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_flatten_indices(actual_index, num_samples, skip_coef=1, window_size=5):\n n_pre_zeros = 0\n window_indices = []\n n_post_zeros = 0\n for i in range(window_size * 2 + 1):\n if (actual_index - window_size*skip_coef) + i*skip_coef >= 0 and (actual_index - window_size*ski... | [
"0.6340699",
"0.5813027",
"0.5748229",
"0.56743836",
"0.55570626",
"0.55411845",
"0.5432381",
"0.5309236",
"0.5209544",
"0.52076346",
"0.52067953",
"0.52067953",
"0.51609695",
"0.51609695",
"0.5154295",
"0.5130914",
"0.5128103",
"0.50972",
"0.5071069",
"0.49966234",
"0.499414... | 0.6024071 | 1 |
Decorate tensorflow op graph building function with name_scope. Name defaults to function name. | def scope_op(name=None):
def decorator(function):
@functools.wraps(function)
def wrapper(*args, **kwargs):
with tf.name_scope(name or function.__name__):
return function(*args, **kwargs)
return wrapper
return decorator | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def function_name_scope(function):\n @wraps(function)\n def wrapper(*args, **kwargs):\n with tf.name_scope(function.__name__):\n return function(*args, **kwargs)\n return wrapper",
"def build(self, **kwargs):\n if not self.built:\n with tf.name_scope(self.name):\n ... | [
"0.6776843",
"0.6052667",
"0.6024638",
"0.6017519",
"0.5850662",
"0.582437",
"0.578642",
"0.57745945",
"0.5770974",
"0.57384944",
"0.57371694",
"0.57050693",
"0.56976104",
"0.5680395",
"0.5660873",
"0.56570977",
"0.5645926",
"0.56300974",
"0.55482644",
"0.55344635",
"0.551495... | 0.78752005 | 0 |
Pad tensor by wrapping around at the borders. | def pad(x, system_shape, pad_size):
res = unpad(tf.tile(x, (1,)+(3,)*len(pad_size)),
tuple(s-p for s, p in zip(system_shape, pad_size)))
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad(tensor):\n paddings = tf.constant([[0, 0], [0, 10], [0, 0]])\n out = tf.pad(tensor, paddings, \"CONSTANT\", constant_values=0)\n return out",
"def wrap_pad(input, size):\n M1 = tf.concat([input[:, :, -size[1]:, :], input, input[:, :, 0:size[1], :]], 2)\n M1 = tf.concat([M1[:, -size[0]:, :,... | [
"0.7407109",
"0.72784704",
"0.7240538",
"0.71440405",
"0.71000195",
"0.7090418",
"0.7018738",
"0.70085424",
"0.6888799",
"0.6858602",
"0.6802423",
"0.67736495",
"0.6768315",
"0.6739989",
"0.6722971",
"0.66809046",
"0.66500527",
"0.6607904",
"0.6547321",
"0.6516811",
"0.651234... | 0.6800257 | 11 |
Gather windows of tensor around centers. Uses wrapped padding. | def gather_windows(x, centers, system_shape, window_shape):
window_size = np.prod(window_shape)
batch_size = tf.shape(x)[0]
index_matrix = tf.constant(create_index_matrix(system_shape, window_shape))
window_range = tf.range(batch_size, dtype=tf.int32)[:, None] * \
tf.ones(window_size, dtype=tf.i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_windows(x, centers, updates, mask, system_shape, window_shape):\n window_size = np.prod(window_shape)\n batch_size = tf.shape(x)[0]\n index_matrix = tf.constant(create_index_matrix(system_shape, window_shape))\n window_range = tf.range(batch_size, dtype=tf.int32)[:, None] * \\\n tf.on... | [
"0.62628543",
"0.6066326",
"0.58352035",
"0.56969947",
"0.5685777",
"0.5637248",
"0.55407983",
"0.553049",
"0.54852927",
"0.54782593",
"0.5473007",
"0.5462575",
"0.5458505",
"0.5457785",
"0.5445776",
"0.5361355",
"0.5351152",
"0.5341841",
"0.53008586",
"0.5300423",
"0.5274436... | 0.670488 | 0 |
Retrieve values of one or more nodes, returning as a flat dict. If you wish to perform some iteration over a representational hierarchy, use get_node_tree_values() instead. This is a convenience function for users who do not want to worry about node binding types or attributes and want to avoid the complexity of creati... | def get_node_values(self, node_names, nostate=False, noconfig=False,
strip=None):
return self._get_nodes(node_names, nostate=nostate,
noconfig=noconfig, flat=True,
values_only=True, strip=strip) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_nodes(self, uri):\n node = self.get(uri)\n\n _nodes = {}\n for k, v in node.items():\n if isinstance(v, dict):\n _nodes[k] = v\n\n return _nodes",
"def get_nodes_dict(self):\n return self._nodes_dict.copy()",
"def get_tree(self) -> dict:\n ... | [
"0.65162987",
"0.64842397",
"0.622741",
"0.6227282",
"0.6058203",
"0.6034385",
"0.60253924",
"0.60017234",
"0.59756917",
"0.5971337",
"0.5971337",
"0.5944662",
"0.5852683",
"0.5804935",
"0.5787721",
"0.57389414",
"0.5735163",
"0.5730506",
"0.57078916",
"0.5705613",
"0.5700515... | 0.6173875 | 4 |
Close the connection to the given Symphony appliance. | def close(self):
self._close()
self._closed = True
self._auth_error = self._AUTH_ERROR_MESSAGES[0]
self.login_info = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_connection(self):\n self.session.close()",
"def closeConnection(self):\n print(\"closing connection...\")\n self.s.close()\n quit()",
"def close_connection(self):\n\t\tself.session.close()",
"def sx_close_sdk_connection(handle): \n rc = sx_api_close(handle) \n sx_... | [
"0.6305688",
"0.62818617",
"0.6264187",
"0.62350076",
"0.6089671",
"0.6085774",
"0.60632676",
"0.6014593",
"0.59948784",
"0.5965196",
"0.59603965",
"0.59587735",
"0.59587735",
"0.5953831",
"0.59412336",
"0.58943903",
"0.58721703",
"0.58693767",
"0.5852582",
"0.5844935",
"0.58... | 0.0 | -1 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
cm2 = np.vstack((cm, cm.sum(0, keepdims=True)))
cm2 = np.hstack((cm2, cm2.sum(1, keepdims=True)))
cm3 = cm2.copy();
cm3[:,-1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.8194862",
"0.80949175",
"0.8029915",
"0.8019153",
"0.79941195",
"0.7991258",
"0.7980955",
"0.7976606",
"0.79610753",
"0.79590565",
"0.79378676",
"0.7934962",
"0.7934504",
"0.79313844",
"0.7926313",
"0.7924577",
"0.79241234",
"0.7923211",
"0.7923023",
"0.7921931",
"0.791787... | 0.0 | -1 |
Tests conversion from a ProductModel instance to a dict. | def test_conversion_to_dict():
model_definition = {
'language': {'type': 'fixed', 'default': 'english'},
'a': {'type': 'fixed', 'persisted': True},
'b.c': {'type': 'fixed', 'persisted': True},
'b.d.e': {'type': 'text', 'persisted': True},
'b.d.f': {'type': 'numeric', 'persist... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_after_todict(self):\n my_model = BaseModel()\n new_model = BaseModel()\n test_dict = my_model.to_dict()\n self.assertIsInstance(my_model, BaseModel)\n self.assertEqual(type(my_model).__name__, \"BaseModel\")\n self.assertEqual(test_dict['__class__'], \"BaseModel\"... | [
"0.69077003",
"0.6868457",
"0.68538004",
"0.6642659",
"0.66204894",
"0.6545897",
"0.6503946",
"0.63067096",
"0.6296218",
"0.6277278",
"0.6251176",
"0.6238148",
"0.61626965",
"0.61544114",
"0.6154392",
"0.6132345",
"0.6128953",
"0.6077414",
"0.60404193",
"0.6033105",
"0.599797... | 0.6674117 | 3 |
Tests conversion from a dict to a ProductModel instance. | def test_conversion_from_dict():
model_definition = {
'language': {'type': 'fixed', 'default': 'english'},
'a': {'type': 'fixed', 'persisted': True},
'b.c': {'type': 'fixed', 'persisted': True},
'b.d.e': {'type': 'text', 'persisted': True},
'b.d.f': {'type': 'numeric', 'persi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_from_dict(self):\n b1 = BaseModel()\n b1.name = \"Holberton\"\n b1.my_number = 89\n my_model_json = b1.to_dict()\n b2 = BaseModel(**my_model_json)\n self.assertEqual(b1.my_number, b2.my_number)\n self.assertEqual(b1.id, b2.id)\n self.assertEqu... | [
"0.6527579",
"0.64977103",
"0.62672186",
"0.610359",
"0.60274994",
"0.6020002",
"0.5937814",
"0.59310555",
"0.5926014",
"0.5909174",
"0.5909174",
"0.5909174",
"0.5909174",
"0.5909174",
"0.5909174",
"0.59031826",
"0.5890253",
"0.58854175",
"0.58797616",
"0.5858172",
"0.5854472... | 0.6796946 | 0 |
Test creating a category | def test_create_category(self):
payload = {
'name': 'Houses',
}
res = self.client.post(CATEGORY_URL, payload)
self.assertEqual(res.status_code, status.HTTP_201_CREATED)
category = Category.objects.get(id=res.data['id'])
serializer = CategorySerializer(category... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_category(self):\n pass",
"def test_create_category(self):\n res = self.client().post('/categories/', data=self.category)\n self.assertEqual(res.status_code, 201)\n self.assertIn('Stews', str(res.data))",
"def test_add_category(self):\n self.signup('Bo', 'Theo'... | [
"0.9343295",
"0.8552518",
"0.8478462",
"0.83282495",
"0.8315106",
"0.8146321",
"0.80606836",
"0.80593735",
"0.7993019",
"0.7855543",
"0.78443205",
"0.77430016",
"0.7732725",
"0.7699715",
"0.766738",
"0.75508666",
"0.7495234",
"0.7481776",
"0.74599594",
"0.7453341",
"0.7443559... | 0.81414086 | 6 |
Test creating a category with invalid details | def test_create_category_with_invalid_details_fails(self):
res = self.client.post(CATEGORY_URL, {})
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(
res.data['errors']['name'][0],
'This field is required.') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_category(self):\n pass",
"def test_cannot_create_with_invalid_category(self):\n serializer = ServiceSerializer(\n data = dict(name = \"service1\", category = 10),\n context = dict(project = self.project)\n )\n self.assertFalse(serializer.is_valid(... | [
"0.82101303",
"0.8041852",
"0.791494",
"0.78192854",
"0.7700955",
"0.76209366",
"0.7575074",
"0.7443271",
"0.74368286",
"0.7422457",
"0.7414787",
"0.74138415",
"0.73887557",
"0.73368895",
"0.7318645",
"0.7282309",
"0.72419256",
"0.722112",
"0.71900594",
"0.71621287",
"0.71399... | 0.87169325 | 0 |
Test create category with existing same name fails | def test_create_category_with_existing_name(self):
sample_category()
res = self.client.post(CATEGORY_URL, {"name": "place"})
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(
res.data['errors']['name'][0],
'This field must be unique.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_category(self):\n pass",
"def test_add_same_category(self):\n response = self.client.post('/api/v1/categories',\n data=json.dumps(category[0]),\n content_type='application/json',\n ... | [
"0.86326134",
"0.81314254",
"0.79928046",
"0.785919",
"0.78289926",
"0.77278626",
"0.7714236",
"0.7689189",
"0.76465833",
"0.7560281",
"0.7554323",
"0.7551021",
"0.7518037",
"0.74838006",
"0.7428445",
"0.7390729",
"0.73875856",
"0.73158264",
"0.7306888",
"0.72817504",
"0.7277... | 0.83984613 | 1 |
Test updating a favorite thing with put | def test_update_category(self):
category = sample_category()
url = category_details_url(category.id)
self.client.put(url, {"name": "school"})
category.refresh_from_db()
self.assertEqual(category.name, 'school') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update(self, init_db, favorite):\n params = {\n \"title\": \"Category\",\n \"description\": fake.alphanumeric(100),\n }\n favorite.update(**params)\n assert favorite.title == params['title']\n assert favorite.description == params['description']",
... | [
"0.76762974",
"0.69766474",
"0.6795703",
"0.6789508",
"0.67558914",
"0.66835445",
"0.6680429",
"0.6680045",
"0.666597",
"0.66503185",
"0.66410255",
"0.6604145",
"0.6601007",
"0.6593801",
"0.6533169",
"0.6530562",
"0.6519915",
"0.6517103",
"0.6507051",
"0.6496531",
"0.6489638"... | 0.0 | -1 |
Test updating a category to existing name fails | def test_update_category_to_existing_name(self):
sample_category()
category = sample_category(name='House')
url = category_details_url(category.id)
res = self.client.put(url, {"name": "place"})
category.refresh_from_db()
self.assertEqual(res.status_code, status.HTTP_400_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_category(self):\n pass",
"def test_update(self, init_db, category):\n category_name = fake.alphanumeric()\n category.update(name=category_name)\n assert category.name == category_name",
"def test_update_category(self):\n category = sample_category()\n u... | [
"0.8705725",
"0.86055994",
"0.8067761",
"0.79751843",
"0.7777514",
"0.7758227",
"0.7564963",
"0.7562341",
"0.7552205",
"0.7283096",
"0.72652644",
"0.72646534",
"0.7263289",
"0.72263676",
"0.7210747",
"0.7179932",
"0.7075194",
"0.7023446",
"0.7023264",
"0.69821405",
"0.6903937... | 0.86579794 | 1 |
Initializes to count the number of null lists in a specific feature path. When required_paths is also passed, rows which are null for all of the required paths will not be counted as missing. | def __init__(self,
path: types.FeaturePath,
required_paths: Optional[Iterable[types.FeaturePath]] = None):
self._path = path
if required_paths:
self._required_paths = tuple(sorted(required_paths))
else:
self._required_paths = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_null(self):\n null = 0\n for x in range(0, self.tot_col):\n for y in range(1, self.tot_rows + 1):\n if self.file_list[y][x].lower() == 'null':\n null += 1\n print('Total number of null fields: ' + str(null))\n results.append('Total n... | [
"0.57643074",
"0.5636303",
"0.56160426",
"0.5423167",
"0.53524774",
"0.5331745",
"0.5315419",
"0.5221362",
"0.5192976",
"0.5125796",
"0.5100069",
"0.5041495",
"0.5023727",
"0.49956",
"0.49956",
"0.49719247",
"0.49719247",
"0.49719247",
"0.49719247",
"0.49430317",
"0.4916951",... | 0.57114744 | 1 |
Returns the count of missing values for this stats generator. | def extract_output(self, accumulator: int) -> int:
return accumulator | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def missing_values(self):\n missing_values = self.data.isna().sum()\n if missing_values:\n fracture = missing_values / self.data.count()\n return f\"N={missing_values},{round(fracture, 2)}%\"\n else:\n return \"no missing values\"",
"def get_missing(self):\n ... | [
"0.7426406",
"0.73884034",
"0.7072214",
"0.7021839",
"0.6985721",
"0.6931459",
"0.68706846",
"0.6811899",
"0.66869324",
"0.6537255",
"0.6537255",
"0.6530134",
"0.6367661",
"0.63586634",
"0.63222903",
"0.63145953",
"0.62954384",
"0.6267708",
"0.62417835",
"0.61460364",
"0.6140... | 0.0 | -1 |
r""" Calculates the sum over all dimensions, except the first (batch dimension), and excluding the last n_dims. This function will ignore the first dimension and it will not aggregate over the last n_dims dimensions. | def sum_over_all_but_batch_and_last_n(
tensor: torch.Tensor, n_dims: int
) -> torch.Tensor:
if tensor.dim() == n_dims + 1:
return tensor
else:
dims = list(range(1, tensor.dim() - n_dims))
return tensor.sum(dim=dims) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_except_batch(x, num_dims=1):\n return x.reshape(*x.shape[:num_dims], -1).sum(-1)",
"def dim_zero_sum(x: Tensor) ->Tensor:\n return torch.sum(x, dim=0)",
"def sum(self, axis=None, keepdims=False):\n return F.Sum.apply(self, axis, keepdims)",
"def sum_to_0d(x):\n assert_equal(x.... | [
"0.7724387",
"0.63933766",
"0.623022",
"0.617324",
"0.6025804",
"0.59841615",
"0.5975488",
"0.59079736",
"0.58502185",
"0.58405554",
"0.5831169",
"0.5810228",
"0.5778869",
"0.5778869",
"0.5761769",
"0.57385844",
"0.57123697",
"0.57123697",
"0.56297374",
"0.561928",
"0.5616455... | 0.798387 | 0 |
Returns an User (ndb.Model) entity that the username points to. Raises an error if an entity is not found. | def check_user_exists(username):
user = User.query(User.name == username.title()).get()
if not user:
raise endpoints.NotFoundException(
'User {} does not exist!'.format(username))
else:
return user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user(username):\n if custom_user_model:\n return get_user_model().objects.get_by_natural_key(username)\n else:\n return get_user_model().objects.get(username=username)",
"def get(self, username):\n return User.find_by_username_or_email(username)",
"def get_user(username):\n ... | [
"0.74744946",
"0.7447991",
"0.7441669",
"0.74183327",
"0.74178565",
"0.7414877",
"0.73988956",
"0.73629385",
"0.7296302",
"0.7227076",
"0.7220234",
"0.7170327",
"0.7116797",
"0.71012014",
"0.7094964",
"0.70818806",
"0.70427954",
"0.7037425",
"0.696084",
"0.6957107",
"0.694782... | 0.6353699 | 71 |
Returns an Player (ndb.Model) entity for a given username and game. First verify username and game entity are valid, raises error if not. Then returns the Player entity for the given user in the game. Raises an error if a Player is not found. | def get_player_by_game(username, game):
# check to make sure User exists
if not check_user_exists(username):
raise endpoints.NotFoundException(
'{} does not exist!'.format(username))
# check to see if game is a valid Game entity
if not isinstance(game, Game):
raise endpoint... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_game(username):\n user = User.objects.get(username=username)\n if user.two_player_game_id != None:\n return TwoPlayerGame.objects.get(\n game_id=user.two_player_game_id), \"two\"\n if user.four_player_game_id != None:\n return FourPlayerGame.objects.get(\n game_... | [
"0.65232056",
"0.63248277",
"0.6170685",
"0.60794777",
"0.59741324",
"0.59616375",
"0.5943671",
"0.5908297",
"0.5905852",
"0.5870364",
"0.5857468",
"0.5836295",
"0.5746015",
"0.5728419",
"0.57253647",
"0.5602715",
"0.55801475",
"0.5562985",
"0.55489415",
"0.55399925",
"0.5517... | 0.8235693 | 0 |
Adds various cachedisabling headers to all responses returned by the application | def app_nocache(app):
@app.after_request
def add_header(r):
r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
r.headers["Pragma"] = "no-cache"
r.headers["Expires"] = "0"
r.headers['Cache-Control'] = 'public, max-age=0'
return r | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_header(response):\n\n # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control\n response.cache_control.no_store = True\n return response",
"def add_header(response):\n\n # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control\n response.cache_control.no_... | [
"0.7553019",
"0.7553019",
"0.7549143",
"0.75454265",
"0.7496148",
"0.74355614",
"0.7409956",
"0.740559",
"0.7390607",
"0.7339881",
"0.7339881",
"0.7303281",
"0.7303281",
"0.7303281",
"0.7303281",
"0.7303281",
"0.7303281",
"0.7303281",
"0.7303281",
"0.7303281",
"0.7303281",
... | 0.6854888 | 55 |
Test filtering hits and miss datasets. | def test_filter_exists(self):
datasets = [{"exists": True, "name": "DATASET1"}, {"exists": False, "name": "DATASET2"}]
hits = filter_exists("HIT", datasets)
misses = filter_exists("MISS", datasets)
all = filter_exists("ALL", datasets)
nothing = filter_exists("NONE", datasets)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_fetch_filtered_dataset_call_misses(self):\n pool = asynctest.CoroutineMock()\n pool.acquire().__aenter__.return_value = Connection() # db_response is []\n assembly_id = 'GRCh38'\n position = (10, 20, None, None, None, None)\n chromosome = 1\n reference = 'A... | [
"0.6526705",
"0.63991475",
"0.6067365",
"0.60468185",
"0.5980538",
"0.59720397",
"0.59475845",
"0.589787",
"0.5843083",
"0.58304274",
"0.5800998",
"0.57543606",
"0.573433",
"0.57284266",
"0.5726334",
"0.5716319",
"0.5710886",
"0.57061344",
"0.57022065",
"0.56984323",
"0.56940... | 0.730566 | 0 |
Test transform misses record. | def test_transform_misses(self):
response = {"referenceBases": '', "alternateBases": '', "variantType": "",
"frequency": 0, "callCount": 0, "sampleCount": 0, "variantCount": 0,
"start": 0, "end": 0, "info": {"accessType": "PUBLIC"}}
record = Record("PUBLIC")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_transforms_match(self, transform: Mapping) -> None:\n xform_id = transform.get(TraceKeys.ID, \"\")\n if xform_id == id(self):\n return\n # TraceKeys.NONE to skip the id check\n if xform_id == TraceKeys.NONE:\n return\n xform_name = transform.get(Tr... | [
"0.6604709",
"0.6437916",
"0.6375894",
"0.6232821",
"0.5919303",
"0.590823",
"0.58788997",
"0.58498996",
"0.58181363",
"0.57857037",
"0.57830256",
"0.57796776",
"0.57594526",
"0.5697106",
"0.56866306",
"0.5685778",
"0.56558555",
"0.5641226",
"0.56247234",
"0.5612856",
"0.5603... | 0.6836742 | 0 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
if normalize:
cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
print("Normalized confusion matrix")
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.81922984",
"0.80933887",
"0.80272716",
"0.8016492",
"0.79913706",
"0.79885876",
"0.79777396",
"0.79729784",
"0.7958926",
"0.7954523",
"0.79347897",
"0.7931899",
"0.7931772",
"0.7928666",
"0.7923684",
"0.7921764",
"0.79213995",
"0.7920191",
"0.792016",
"0.7919876",
"0.79153... | 0.7811767 | 99 |
Returns an iterator over the ngrams given a list of tokens | def n_grams(tokens, n=1):
shiftToken = lambda i: (el for j,el in enumerate(tokens) if j>=i)
shiftedTokens = (shiftToken(i) for i in range(n))
tupleNGrams = zip(*shiftedTokens)
return tupleNGrams | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_ngrams(tokens, n=2):\n ngrams = zip(*(islice(group, idx, None) for idx, group in enumerate(tee(tokens, n))))\n return ngrams",
"def generate_ngrams(tokens, ngram_size, *, include_terminator = False):\n \n if ngram_size <= 0:\n raise Exception(\"ngram size must be positive\")\n\n i... | [
"0.73350906",
"0.732948",
"0.71909267",
"0.7100118",
"0.7063269",
"0.69512093",
"0.68591905",
"0.6789865",
"0.67402244",
"0.6720318",
"0.6680123",
"0.6668854",
"0.6627547",
"0.6622774",
"0.6584314",
"0.65706635",
"0.6560498",
"0.6546228",
"0.64868057",
"0.6476503",
"0.6459065... | 0.68247813 | 7 |
Returns an itirator over all ngrams for n in range(ngramRange) given a list of tokens. | def range_ngrams(tokens, ngramRange=(1,2)):
return chain(*(n_grams(tokens, i) for i in range(*ngramRange))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ngramize(items: List[str], ngram_range=(1, 1)) -> Generator[List[str], Any, None]:\n\n ngrams = []\n ranges = [(0, i) for i in range(ngram_range[0], ngram_range[1] + 1)]\n for r in ranges:\n ngrams += list(zip(*[items[j:] for j in range(*r)]))\n\n formatted_ngrams = [' '.join(item) for item ... | [
"0.77018356",
"0.7479281",
"0.74121964",
"0.74022996",
"0.7253089",
"0.7199664",
"0.7115451",
"0.70956486",
"0.708296",
"0.70244306",
"0.6999506",
"0.6986396",
"0.6947342",
"0.6940619",
"0.6927285",
"0.6926673",
"0.6888308",
"0.68828356",
"0.6871958",
"0.682038",
"0.6817774",... | 0.8547429 | 0 |
Initialize an Evaluation object. | def __init__(self):
self._summary = {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(\r\n self,\r\n generator,\r\n mode,\r\n tensorboard=None,\r\n verbose=1,\r\n **kwargs\r\n ):\r\n self.generator = generator\r\n\r\n if mode == 'recall':\r\n self.evaluate = eval_recall\r\n elif mode == 'accuracy':\r\n ... | [
"0.673257",
"0.6675408",
"0.6673282",
"0.63719517",
"0.63487226",
"0.6341479",
"0.621565",
"0.61684275",
"0.6149013",
"0.61229223",
"0.6117673",
"0.60776865",
"0.60776865",
"0.60722077",
"0.6053143",
"0.6053143",
"0.60521984",
"0.60372925",
"0.60231334",
"0.59643507",
"0.5964... | 0.0 | -1 |
Sets up this window with a simulator, a display and optionally a control widget. | def __init__(self, simulator, display, control=None, **kwargs):
super(ZasimMainWindow, self).__init__(**kwargs)
self.setAttribute(Qt.WA_DeleteOnClose)
self.simulator = simulator
self.display = display
self.control = control
central_widget = QWidget(self)
if se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _display_setup(self):\r\n display_file = \"{}/display.json\".format(self.settings_dir)\r\n with open(display_file) as json_file:\r\n win_settings = json.load(json_file)\r\n self.win = visual.Window(**win_settings)\r\n framerate = self.win.fps()\r\n self.frame_durat... | [
"0.68346995",
"0.6504775",
"0.6488538",
"0.64603406",
"0.6286316",
"0.6179651",
"0.61078423",
"0.6093484",
"0.60897326",
"0.6019644",
"0.6019345",
"0.6001433",
"0.599808",
"0.59722495",
"0.59695345",
"0.59521645",
"0.5940673",
"0.59181553",
"0.5897244",
"0.5888673",
"0.588575... | 0.76192385 | 0 |
Get the authenticated userid for this request. When using HTTPSRPHMACAuth, this requires calculating the expected digest response using the user's nonce and password verifier, and comparing it to the response returned in the Authorization header. | def authenticated_userid(self, request):
params = self._get_auth_params(request)
if params is None:
return None
if not self._authenticate(request, params):
return None
username = params["username"]
if self.groupfinder is not None:
if self.group... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unauthenticated_userid(self, request):\n authorization = request.headers.get('Authorization')\n if authorization is None:\n return None\n token_object = find_token_for_authorization(authorization)\n if token_object is None:\n raise httpexceptions.HTTPUnauthoriz... | [
"0.7036967",
"0.70048946",
"0.67695534",
"0.67280394",
"0.6551004",
"0.6241438",
"0.6140925",
"0.6096623",
"0.60860455",
"0.60304624",
"0.6013703",
"0.5983581",
"0.59092814",
"0.5870384",
"0.58188313",
"0.58152586",
"0.5813406",
"0.5809295",
"0.5772613",
"0.57415456",
"0.5730... | 0.6754592 | 3 |
Get the unauthenticated userid for this request. When using HTTPSRPHMACAuth, this involves looking in the HTTP Authorization header to find the reported username. | def unauthenticated_userid(self, request):
params = self._get_auth_params(request)
if params is None:
return None
return params.get("username") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unauthenticated_userid(self, request):\n authorization = request.headers.get('Authorization')\n if authorization is None:\n return None\n token_object = find_token_for_authorization(authorization)\n if token_object is None:\n raise httpexceptions.HTTPUnauthoriz... | [
"0.86458576",
"0.86111814",
"0.82587343",
"0.81629455",
"0.7881346",
"0.71495134",
"0.70761484",
"0.6976793",
"0.6847131",
"0.6801054",
"0.6793066",
"0.67122",
"0.6617604",
"0.6589437",
"0.6586149",
"0.6583202",
"0.65430385",
"0.65210736",
"0.6506743",
"0.6506743",
"0.6495544... | 0.8799287 | 0 |
Obtain the password verifier data to use for the given user. This method returns a tuple (algorithm, salt, verifier) giving the necessary information to verify the user's password. If no information is available for the user then a tuple of Nones is returned. | def _get_verifier(self, username):
# If we have a get_verifier callback, use it directly.
if self.get_verifier is not None:
verifier = self.get_verifier(username)
if verifier is not None and verifier[0] is not None:
return verifier
# Otherwise, we need t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_verified_password(self):\n raise NotImplementedError('get_verified_password')",
"def get_verified_password(self):\n return self.controller.dbfilter.db.get('passwd/user-password-again')",
"def check_password() -> tuple:\n user_data: dict = request.get_json()\n uid: str = user_data.ge... | [
"0.6216303",
"0.61528856",
"0.59387445",
"0.5666319",
"0.548512",
"0.54241",
"0.5317666",
"0.5284316",
"0.52637374",
"0.52235824",
"0.5173144",
"0.5169702",
"0.51583606",
"0.51457644",
"0.5130701",
"0.511049",
"0.5103841",
"0.50647473",
"0.5032563",
"0.5018214",
"0.50169563",... | 0.72366863 | 0 |
Creates a dictionarylike object representing the filesystem structure starting at the given root directory. | def get_fs_dict (
initial_root, create_item=None, dict_cls=dict,
dirname_filter=None, filename_filter=None,
include_root=False, toplevel_files=True, prune_empty=False, file_key=None,
):
# TODO(could-do): max_depth=N
fsdict = dict_cls()
get_file_key = ( lambda x: x ) if file_key is None else file... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, dirname, defmode='r'):\n self.name = dirname\n self.defmode = defmode\n\n self.items = []\n\n for i in os.listdir(dirname):\n if os.path.isdir(os.path.join(dirname, i)):\n self.items.append(Tree(os.path.join(dirname, i), defmode))\n\n ... | [
"0.6521569",
"0.65162444",
"0.6484279",
"0.64037526",
"0.6266439",
"0.62654215",
"0.6254696",
"0.6253443",
"0.62238693",
"0.6207021",
"0.6196134",
"0.6184652",
"0.6175318",
"0.6164307",
"0.6069025",
"0.6048882",
"0.6022305",
"0.60057586",
"0.60057586",
"0.60057586",
"0.600575... | 0.7043223 | 0 |
Get a random element from the set. | def getRandom(self) -> int:
if self.data:
return self.data[random.randrange(len(self.data))]
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getRandom(self):\n return self.nums[random.randint(0, len(self.nums) - 1)]\n\n # Your RandomizedSet object will be instantiated and called as such:\n # obj = RandomizedSet()\n # param_1 = obj.insert(val)\n # param_2 = obj.remove(val)\n # param_3 = obj.getRandom()",
"... | [
"0.77060276",
"0.738916",
"0.7296881",
"0.72187954",
"0.6871744",
"0.68453854",
"0.68330806",
"0.67740154",
"0.67226046",
"0.6703282",
"0.6665089",
"0.66356236",
"0.66217655",
"0.6612035",
"0.66000897",
"0.6567767",
"0.6477719",
"0.6462421",
"0.64428514",
"0.64162946",
"0.640... | 0.0 | -1 |
Function that return the api key for the cleverbot api. | def get_clever_key(self):
key = self.bot_data_file["apiKeys"]["cleverbot"]
if self.check_empty_key(key):
return key
else:
print("ERROR GETTING THE CLEVERBOT KEY (get yours from https://www.cleverbot.com/api/)- ABORTING")
quit(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_api_key(self):\r\n url = '{0}/{1}'.format(self.get_url(), 'api_key')\r\n\r\n return http.Request('GET', url), parsers.parse_json",
"def _get_api_key():\n cfg = read_config()\n cfg = cfg['notifier']['telegram_bot']\n return cfg.get('api_key')",
"def api_key(self) -> pu... | [
"0.811822",
"0.8109484",
"0.79165703",
"0.79165703",
"0.79165703",
"0.79165703",
"0.7915356",
"0.78725505",
"0.78210324",
"0.7732284",
"0.77136934",
"0.77110773",
"0.7637436",
"0.7619761",
"0.75656086",
"0.75656086",
"0.75261956",
"0.7480597",
"0.74262774",
"0.7424998",
"0.73... | 0.7482254 | 17 |
Function that return the api key for the hypixel api. | def get_hypixel_key(self):
key = self.bot_data_file["apiKeys"]["hypixel"]
if self.check_empty_key(key):
return key
else:
print("ERROR GETTING THE HYPIXEL KEY (get yours from https://api.hypixel.net/) - ABORTING")
quit(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_api_key(self):\r\n url = '{0}/{1}'.format(self.get_url(), 'api_key')\r\n\r\n return http.Request('GET', url), parsers.parse_json",
"def api_key(self):\n # type () -> str\n return self._api_key",
"def api_key(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"api_... | [
"0.7882624",
"0.7581468",
"0.7505369",
"0.7505369",
"0.7505369",
"0.7505369",
"0.74702185",
"0.7435706",
"0.74057823",
"0.7401957",
"0.73333293",
"0.73333293",
"0.7320179",
"0.7299802",
"0.72601944",
"0.7181773",
"0.7115222",
"0.711507",
"0.71141195",
"0.70895034",
"0.7085272... | 0.7944425 | 0 |
Apply the sigmoid function to a given vector z | def sigmoid(z):
return 1/(1 + numpy.exp(z)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid(z):\r\n \r\n return vSigmoid(z);",
"def sigmoid(z): \n return 1/(1 + np.e**(-z))",
"def sigmoid(z):\r\n \r\n return 1.0 / (1.0+np.exp(-z))",
"def sigmoid(z):\n return 1 / (1 + np.exp(-1 * z))",
"def sigmoid(z):\n\treturn 1.0/(1.0+np.exp(-z))",
"def sigmoid(self, z):\n ... | [
"0.87852424",
"0.87203354",
"0.86295617",
"0.8579101",
"0.8548155",
"0.85432875",
"0.85228527",
"0.8521811",
"0.8492998",
"0.84773827",
"0.84757036",
"0.8422963",
"0.8413242",
"0.840143",
"0.83995837",
"0.8386571",
"0.8381562",
"0.8380191",
"0.834812",
"0.8343984",
"0.8340798... | 0.8448596 | 11 |
Apply the derivative of the sigmoid function to a given vector z | def sigmoid_prime(z):
sig_z = sigmoid(z)
return sig_z * (1 - sig_z) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid_derivative(z):\n s = 1./(1. + np.exp(-z))\n ds = s * (1 - s)\n return ds",
"def sigmoid_gradient(z):\n #derivative of sigmoid\n return z * (1 - z)",
"def deriv_sigmoid(self,z):\n return np.exp(-z) / ( (1 + np.exp(-z)) ** 2 )",
"def diff_sigmoid(z):\r\n diff_z = np.multipl... | [
"0.845679",
"0.8382699",
"0.82087004",
"0.81125015",
"0.80461526",
"0.8024078",
"0.7924393",
"0.791048",
"0.79070383",
"0.7734504",
"0.77253765",
"0.7725097",
"0.7677215",
"0.7675911",
"0.76673025",
"0.7663973",
"0.7629547",
"0.761612",
"0.7605165",
"0.7603668",
"0.76017916",... | 0.6418672 | 92 |
Construct all the parameters from its relationships with body size and temperature, using the normalizing constants and scaling exponent w | def construct_param_dict(params,K_RC,K_CP,m_P):
###scaling constants
w=params['w']
pd=params['pd'] # in 3D and 0.21 in 2D
pv=params['pv']
Er=params['Er'] ;Ek=params['Ek']
ER=params['ER'];EC=params['EC'];EP=params['EP'];
Eq1=params['Eq1'];Eq2=params['Eq2']
#capture success function
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_parameters(self):\n # Create the weights and biases\n for i in range(1, len(self.layer_dimensions)):\n # Initialization from He et al.\n mu = 0\n var = 2 / self.layer_dimensions[i]\n sigma = np.sqrt(var)\n weight_shape = (self.layer_dime... | [
"0.63872725",
"0.6359708",
"0.63504016",
"0.6349889",
"0.62771535",
"0.6260182",
"0.62050694",
"0.61629844",
"0.61521065",
"0.61232364",
"0.60978574",
"0.60809964",
"0.60663754",
"0.6043746",
"0.6043204",
"0.60430783",
"0.60391027",
"0.60364896",
"0.603379",
"0.60298866",
"0.... | 0.56011987 | 71 |
Returns the (x, y) position of the IR tracker in the camera reference plane. | def locate_tracker(self, debug):
# tmp_image =
# tmp_image = cv2.GaussianBlur(self.frame, (11, 11), 0) # Experiment with this
hsv = cv2.cvtColor(self.frame, cv2.COLOR_BGR2HSV) # Convert to HSV Color Space. This is temporary for testing using colored objects)
mask = cv2.inRange(hsv, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pos(self):\n current_angles = self.chain.get_current_values()\n current_xyz, current_rpy = self._solver.forward_solve(current_angles)\n return current_xyz, current_rpy",
"def get_linear_track_pos(self):\r\n return self._arm.get_linear_track_pos()",
"def current_probe_positio... | [
"0.6636195",
"0.652415",
"0.65058815",
"0.6493314",
"0.64832383",
"0.6479564",
"0.6456116",
"0.6453457",
"0.64308065",
"0.6426223",
"0.6411724",
"0.63737077",
"0.6317715",
"0.63049656",
"0.62969553",
"0.6257294",
"0.6256818",
"0.6250686",
"0.62020564",
"0.62020564",
"0.619684... | 0.0 | -1 |
Split a string on separator, ignoring ones escaped by backslashes. | def split_escaped(string, separator):
result = []
current = ''
escaped = False
for char in string:
if not escaped:
if char == '\\':
escaped = True
continue
elif char == separator:
result.append(current)
curr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def safe_split(string, sep=','):\n regex = re.escape(sep) + r'\\s*(?![^\\[\\]]*\\])(?![^()]*\\))'\n return re.split(regex, string)",
"def split_escaped_delim (delimiter, string, count=0):\n assert len(delimiter) == 1\n\n split_expression = re.compile(r\"\"\"(?<!\\\\)%s\"\"\" % (delimiter))\n\n res... | [
"0.7253181",
"0.71445125",
"0.7137215",
"0.7121397",
"0.7037666",
"0.6960564",
"0.68714076",
"0.6836655",
"0.67315274",
"0.6703915",
"0.6701192",
"0.6682179",
"0.66377485",
"0.6558326",
"0.6476721",
"0.6373009",
"0.6294557",
"0.6292038",
"0.6199906",
"0.61823356",
"0.6165287"... | 0.8195037 | 0 |
X coordinate of the cartesian position. | def x(self):
return self._x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_x(self):\n return self.coords[0]",
"def get_pos_x(self):\n return self.__pos_x",
"def Getxcoord(self):\n return self.x_coord",
"def _get_x(self):\n return self.position.x",
"def x(self):\n return self.coords[0]",
"def get_x(self):\n return self.posX",
"... | [
"0.80998755",
"0.8040294",
"0.803745",
"0.80215025",
"0.8018538",
"0.80019146",
"0.7985554",
"0.7981068",
"0.786164",
"0.78604984",
"0.78149635",
"0.7766205",
"0.7683169",
"0.76169026",
"0.7551751",
"0.75131196",
"0.74211395",
"0.73938507",
"0.7351592",
"0.73244274",
"0.73244... | 0.6679089 | 63 |
Y coordinate of the cartesian position. | def y(self):
return self._y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def y(self):\n return self.coords[1]",
"def get_y(self):\n return self.coords[1]",
"def y(self):\n return self._coords[1]",
"def getY(self):\n return self.position.getY()",
"def _get_y(self):\n return self.position.y",
"def y_coord(self):\n\n return self.y0 + np.... | [
"0.82681483",
"0.82525843",
"0.82442576",
"0.8238144",
"0.82361335",
"0.8225148",
"0.820561",
"0.8087116",
"0.8035207",
"0.80289924",
"0.8012774",
"0.79748297",
"0.7971425",
"0.7960988",
"0.7960988",
"0.7952861",
"0.79017615",
"0.78972137",
"0.7876323",
"0.78546315",
"0.78546... | 0.7362171 | 56 |
Test that User has attr first_name, and it's an empty string | def test_first_name_attr(self):
user = User()
self.assertTrue(hasattr(user, "first_name"))
self.assertEqual(user.first_name, "") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_first_name_is_optional(self):\n self.updated_data['first_name'] = ''\n self.update_user()\n self.assertEqual(self.user.first_name, self.updated_data['first_name'])",
"def test_last_name_attr(self):\n user = User()\n self.assertTrue(hasattr(user, \"last_name\"))\n ... | [
"0.7791351",
"0.77021265",
"0.76935613",
"0.75390244",
"0.7298847",
"0.7283681",
"0.7144283",
"0.71056646",
"0.70899546",
"0.7047616",
"0.70143366",
"0.7010477",
"0.695369",
"0.69226205",
"0.68944967",
"0.68793935",
"0.6868432",
"0.6830701",
"0.67952096",
"0.67564285",
"0.671... | 0.84504926 | 0 |
Return the API Youtube object. | def get_youtube_handler():
options = {}
home = os.path.expanduser("~")
default_credentials = os.path.join(home, ".youtube-upload-credentials.json")
#client_secrets = options.client_secrets or os.path.join(home, ".client_secrets.json")
#credentials = options.credentials_file or default_credentials
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def youtube(self):\n return self._youtube",
"def get_youtube_client(self):\n # Disable OAuthlib's HTTPS verification when running locally.\n # *DO NOT* leave this option enabled in production.\n # copied from Youtube Data API\n os.environ[\"OAUTHLIB_INSECURE_TRANSPORT\"] = \"1\... | [
"0.7800044",
"0.7103913",
"0.7006781",
"0.6539203",
"0.6526153",
"0.6515458",
"0.62943244",
"0.6238135",
"0.6226493",
"0.6218725",
"0.6180336",
"0.61586845",
"0.6125841",
"0.6111459",
"0.60653925",
"0.6030153",
"0.590494",
"0.5866446",
"0.58460426",
"0.5816294",
"0.5787223",
... | 0.63300043 | 6 |
This function takes a text file and creates 2 lists. | def FillBox(file):
with open(file,'r') as f:
info = f.readline().split()
box_list = []
id = 1
I_list =[]
for i in range(0,len(info)):
box_list.append(box(float(info[i]),id,0,[]))
id+=1
for line in f:
words = line.split()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_list_file(path_file):\n with open(path_file,'r') as f_in:\n lines = f_in.readlines()\n lines = [x for x in lines if not (x.strip() == '' or x.strip()[0] == '#')]\n left_file_list = []\n right_file_list = []\n gt_file_list = []\n conf_file_list = []\n for l in lines:\n to... | [
"0.67911035",
"0.66548043",
"0.64961046",
"0.6493165",
"0.64600074",
"0.64349306",
"0.6410033",
"0.63810414",
"0.6363333",
"0.6291014",
"0.6283217",
"0.62821156",
"0.6279652",
"0.6277509",
"0.6257828",
"0.6207706",
"0.6198657",
"0.6173826",
"0.61607474",
"0.6135674",
"0.61335... | 0.0 | -1 |
Sets the _date of this DayResult. | def _date(self, _date: datetime):
if _date is None:
raise ValueError("Invalid value for `_date`, must not be `None`") # noqa: E501
self.__date = _date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_date(self, date):\n self.date = date\n return",
"def set_date(self, date):\n self.date = date",
"def date(self, date):\n self._date = date",
"def date(self, date):\n\n self._date = date",
"def date(self, date):\n\n self._date = date",
"def date(self, date... | [
"0.8185898",
"0.8131151",
"0.7920227",
"0.7893277",
"0.7893277",
"0.7893277",
"0.7893277",
"0.7893277",
"0.777507",
"0.777507",
"0.777153",
"0.76911235",
"0.7654553",
"0.73064077",
"0.72493833",
"0.71411484",
"0.71303713",
"0.71067226",
"0.7089747",
"0.7034327",
"0.70337856",... | 0.7484449 | 13 |
Gets the close of this DayResult. | def close(self) -> float:
return self._close | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_closed(self, ):\n return self.get_parameter('close')",
"def _cur_close(self):\n open = self._data['open'][self._offset]\n rel_close = self._data['close'][self._offset]\n return open * (1.0 + rel_close)",
"def last_close(self):\n return self.data.last('1D').close.iat[0... | [
"0.70047885",
"0.6986404",
"0.69569314",
"0.6932321",
"0.6813832",
"0.6720651",
"0.6325208",
"0.6018458",
"0.59866065",
"0.593251",
"0.59102976",
"0.5899073",
"0.5899073",
"0.5886629",
"0.5814446",
"0.57874507",
"0.5785539",
"0.5784856",
"0.5756914",
"0.5729316",
"0.57240146"... | 0.69106793 | 4 |
Gets the sma of this DayResult. | def sma(self) -> float:
return self._sma | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_smma(data):\n if data is None:\n raise EmptyDataError('[!] Invalid data value')\n\n result = TA.SMMA(data)\n if result is None:\n raise IndicatorException\n return result",
"def get_ssma(data):\n if data is None:\n raise EmptyDataError('... | [
"0.6705078",
"0.6702005",
"0.63130915",
"0.604633",
"0.60253215",
"0.5814726",
"0.57309335",
"0.55183524",
"0.5501305",
"0.54923886",
"0.5349451",
"0.53133947",
"0.5306182",
"0.5286874",
"0.52662396",
"0.52632236",
"0.52127385",
"0.519259",
"0.51896226",
"0.51849455",
"0.5179... | 0.68374413 | 0 |
Gets the ema of this DayResult. | def ema(self) -> float:
return self._ema | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_ema(self):\n emaFactor = self.settings['emaFactor']\n stepFactor = emaFactor ** self.vars['dt']\n if self.vars['step'] == 0:\n ema = float('NaN')\n elif self.vars['step'] == 1:\n ema = self.vars['speed_trace'][1]\n else:\n ema = stepFacto... | [
"0.6840555",
"0.6328568",
"0.6284632",
"0.627982",
"0.62528276",
"0.61535186",
"0.60896593",
"0.60843945",
"0.60232496",
"0.60146594",
"0.59870666",
"0.59870666",
"0.5979842",
"0.59694964",
"0.5923869",
"0.5825421",
"0.5755103",
"0.5740356",
"0.5740356",
"0.5708852",
"0.57063... | 0.7366966 | 0 |
Gets the bb_bottom of this DayResult. | def bb_bottom(self) -> float:
return self._bb_bottom | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bottom(self):\n return self.__b",
"def bottom(self):\n return self._bottom",
"def bottom(self):\n\n return self._bottom",
"def bottom(self):\n # type: () -> float\n return self._bottom",
"def bottom(self):\n return self.top + self.height",
"def bottom(self):\... | [
"0.7806876",
"0.76377356",
"0.7617096",
"0.7505211",
"0.7393419",
"0.7244565",
"0.7244565",
"0.715929",
"0.7107881",
"0.68817294",
"0.68652534",
"0.68652534",
"0.68652534",
"0.68274355",
"0.6763851",
"0.6640081",
"0.663842",
"0.6610873",
"0.66095287",
"0.6604838",
"0.6604838"... | 0.84198266 | 0 |
Gets the rsi of this DayResult. | def rsi(self) -> float:
return self._rsi | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rsi(date):\n\n # print(float(r_json['Technical Analysis: RSI'][date]['RSI']))\n return float(r_json['Technical Analysis: RSI'][date]['RSI'])",
"def get_rsi(data):\n if data is None:\n raise EmptyDataError('[!] Invalid data value')\n\n result = TA.RSI(data)\n if result is... | [
"0.6533008",
"0.6491186",
"0.64453936",
"0.5878729",
"0.5777096",
"0.57620794",
"0.55363625",
"0.5494498",
"0.54942125",
"0.54648906",
"0.5421359",
"0.5398907",
"0.5377694",
"0.53757167",
"0.5293823",
"0.52934027",
"0.52746415",
"0.52619094",
"0.5248207",
"0.5237654",
"0.5224... | 0.7123576 | 0 |
Gets the cci of this DayResult. | def cci(self) -> float:
return self._cci | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eci(self):\n return self.__eci",
"def get_cci(data):\n if data is None:\n raise EmptyDataError('[!] Invalid data value')\n\n result = TA.CCI(data)\n if result is None:\n raise IndicatorException\n return result",
"def Crc(self):\n return self.... | [
"0.6295567",
"0.60494006",
"0.6025518",
"0.59071356",
"0.58969074",
"0.5879198",
"0.5815264",
"0.5726353",
"0.57141125",
"0.5699751",
"0.56982195",
"0.56803477",
"0.5542666",
"0.5533924",
"0.5509144",
"0.55022794",
"0.5486937",
"0.54697",
"0.5457986",
"0.5443288",
"0.5432931"... | 0.6942836 | 0 |
Sets the holding of this DayResult. | def holding(self, holding: float):
if holding is None:
raise ValueError("Invalid value for `holding`, must not be `None`") # noqa: E501
self._holding = holding | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_result(self, result):\n if self.done():\n raise ResultAlreadySet(self)\n self._is_done = True\n self._result = result",
"def _set_result(self, value):\n self._result = value\n self._state = FINISHED_STATE",
"def set_result(self, result):\n self._resu... | [
"0.56218916",
"0.5390519",
"0.53825665",
"0.53475934",
"0.53475934",
"0.5294301",
"0.5291957",
"0.5291957",
"0.52891624",
"0.5277973",
"0.5272773",
"0.5232683",
"0.52119017",
"0.52119017",
"0.5198507",
"0.51296836",
"0.5100267",
"0.50429964",
"0.50369173",
"0.50276613",
"0.50... | 0.5145805 | 15 |
Gets the cash of this DayResult. | def cash(self) -> float:
return self._cash | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cash(self):\r\n return self.cash",
"def getCash(self) -> int:\n return self.state[CASH]",
"def available_cash(self):\n return self._cash",
"def cash_sum(self, room):\n self.cash = room.price\n return self.cash",
"def cash_balance(self):\n cash_transaction =... | [
"0.7749279",
"0.7357067",
"0.67757225",
"0.6665068",
"0.6497363",
"0.61889416",
"0.6069715",
"0.60297805",
"0.5995536",
"0.58673155",
"0.5860459",
"0.5763532",
"0.5738253",
"0.5658459",
"0.5455791",
"0.5452864",
"0.5421678",
"0.5414225",
"0.54129237",
"0.53891695",
"0.5388189... | 0.74906373 | 1 |
Sets the cash of this DayResult. | def cash(self, cash: float):
if cash is None:
raise ValueError("Invalid value for `cash`, must not be `None`") # noqa: E501
self._cash = cash | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_cash(self, cash):\n portfolio = self.get_portfolio_object()\n if portfolio is not None:\n portfolio.cash += cash\n portfolio.initial_cash += cash",
"def cash(self) -> float:\n return self._cash",
"def cash_sum(self, room):\n self.cash = room.price\n ... | [
"0.7091743",
"0.62326807",
"0.61899394",
"0.5963316",
"0.589987",
"0.57699627",
"0.563683",
"0.5482396",
"0.5458104",
"0.54136056",
"0.52196425",
"0.5144976",
"0.514445",
"0.5111715",
"0.5092481",
"0.5036379",
"0.5026525",
"0.5023056",
"0.4954834",
"0.4869902",
"0.48422784",
... | 0.66653264 | 1 |
Gets the value of this DayResult. | def value(self) -> float:
return self._value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getValue(self):\n \n return self._value",
"def getValue(self):\n return self.value",
"def getValue(self):\n return self.value",
"def value(self, day='today'):\n assert day == 'today' or isinstance(day, date), 'Error! You have to pass a datetime.date istance to the d... | [
"0.675377",
"0.6725964",
"0.668124",
"0.66299087",
"0.6615667",
"0.65515864",
"0.65515864",
"0.65515864",
"0.65227",
"0.64704686",
"0.64704686",
"0.64704686",
"0.64558023",
"0.643882",
"0.643882",
"0.643882",
"0.6432335",
"0.64294297",
"0.64294297",
"0.64216006",
"0.64216006"... | 0.0 | -1 |
Sets the value of this DayResult. | def value(self, value: float):
if value is None:
raise ValueError("Invalid value for `value`, must not be `None`") # noqa: E501
self._value = value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_Day(self, value):\n super(GetTimestampFromDateParametersInputSet, self)._set_input('Day', value)",
"def setDay(self, *args):\n return _libsbml.Date_setDay(self, *args)",
"def day(self, day):\n\n self._day = day",
"def day(self, day):\n\n self._day = day",
"def SetResultV... | [
"0.63637984",
"0.63153356",
"0.6208888",
"0.6208888",
"0.61087126",
"0.6082854",
"0.60736036",
"0.6015619",
"0.5882843",
"0.58578676",
"0.5810654",
"0.57990205",
"0.57990205",
"0.5792254",
"0.5792254",
"0.5790793",
"0.5789273",
"0.5759768",
"0.5739839",
"0.5724052",
"0.572209... | 0.0 | -1 |
Finds haversin distance (distance along great circle) in miles between two points. Points are defined by latitude and longitude. Radius of the Earth is assumed to be the midpoint between radius at the equator and radius at the pole. | def haversin(lat1, lon1, lat2, lon2):
r = 3956.545
# Conver to radians
lat1 = np.pi/180*lat1
lon1 = np.pi/180*lon1
lat2 = np.pi/180*lat2
lon2 = np.pi/180*lon2
d = 2*r*np.arcsin(np.sqrt(\
np.sin((lat2-lat1)/2)**2 + \
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_distance(point1, point2):\n import math\n\n def convert_to_radians(degrees):\n return degrees * math.pi / 180\n\n radius_earth = 6.371E3 # km\n phi1 = convert_to_radians(point1[0])\n phi2 = convert_to_radians(point2[0])\n\n delta_phi = convert_to_radians(point1[0] - point2[0]... | [
"0.7588945",
"0.7577696",
"0.7546375",
"0.75156325",
"0.7466122",
"0.7366003",
"0.7353541",
"0.7352228",
"0.7332006",
"0.732501",
"0.73147154",
"0.7281115",
"0.72754496",
"0.72611326",
"0.7260919",
"0.72574294",
"0.72478116",
"0.72352916",
"0.7215604",
"0.7200017",
"0.7196837... | 0.7114394 | 33 |
Return the maximal timeUUID for the timestamp immediately preceding the timestamp of the timeUUID ``u`` | def uuid_for_prev_dt(u):
t60 = time60_from_uuid(u)
return max_uuid_from_time60(t60 - 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uuid_for_next_dt(u):\n t60 = time60_from_uuid(u)\n return min_uuid_from_time60(t60 + 1)",
"def time(self, u):\n return self._ll_tree.get_time(u)",
"def timeasc(self, u=NULL):\n nodes = self.preorder(u)\n is_virtual_root = u == self.virtual_root\n time = self.tree_sequence.... | [
"0.6875454",
"0.5700998",
"0.5295624",
"0.5286404",
"0.5175484",
"0.51728743",
"0.51459426",
"0.5110911",
"0.5067966",
"0.5053651",
"0.49741986",
"0.49545303",
"0.49466422",
"0.4941383",
"0.4926041",
"0.4910391",
"0.49034923",
"0.49031386",
"0.48703253",
"0.48479232",
"0.4830... | 0.78562325 | 0 |
Mutates a population. Selects the best n individuals (based on the selectionRate) to mutate (maybe they'll give us even better individuals!). After mutating an individual, it checks if we have an individual that is similar to the mutated one, if so, then try to mutate again, otherwise, we simply calculate its fitness a... | def mutatePopulation(self, population):
for i in range(int(math.ceil(self.selectionRate * len(population)))):
mutatedIndiv = self.mutateIndividual(population[i])
while self.isIndividualInPopulation(mutatedIndiv, population) == True:
mutatedIndiv = self.mutateIndividual(population[i])
self.calcIndividualF... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fitness_proportionate_selection(random, population, args):\r\n num_selected = args.setdefault('num_selected', 1)\r\n len_pop = len(population)\r\n psum = [i for i in range(len_pop)]\r\n pop_max_fit = (max(population)).fitness\r\n pop_min_fit = (min(population)).fitness\r\n \r\n # If we're ... | [
"0.69687045",
"0.6867652",
"0.68638057",
"0.6850501",
"0.6847528",
"0.6783619",
"0.6715495",
"0.6658223",
"0.6632159",
"0.6594578",
"0.65939194",
"0.6568971",
"0.6538658",
"0.6468645",
"0.64661646",
"0.6450038",
"0.64373183",
"0.6428205",
"0.64249825",
"0.64058185",
"0.639774... | 0.7991917 | 0 |
Checks if an individual is in a population. | def isIndividualInPopulation(self, individual, population):
for i in population:
if i == individual:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, population):\n return self.chromosome_list == population.chromosome_list",
"def test_create_population():\n pop = Population()\n assert len(pop.population) == POPULATION_SIZE\n assert isinstance(pop.population[0], Individual)",
"def test_if_households(self, pop_size, cell_numbe... | [
"0.63011485",
"0.5875469",
"0.5873875",
"0.5841512",
"0.5733281",
"0.5730178",
"0.5723089",
"0.5708155",
"0.57066196",
"0.5702802",
"0.567919",
"0.5665297",
"0.56181157",
"0.5569913",
"0.55618745",
"0.55400103",
"0.5518681",
"0.5490887",
"0.5469354",
"0.54638547",
"0.5458895"... | 0.8702243 | 0 |
Applies a directional scaling to a set of vectors. An example usage for this is to flatten a mesh against a single plane. Direction MUST be normalised prior to this call. | def apply_direction_scale( vectors, direction, scale ):
"""
scaling is defined as:
[p'][1 + (k - 1)n.x^2, (k - 1)n.x n.y^2, (k - 1)n.x n.z ]
S(n,k) = [q'][(k - 1)n.x n.y, 1 + (k - 1)n.y, (k - 1)n.y n.z ]
[r'][(k - 1)n.x n.z, (k - 1)n.y n.z, 1 + (k - 1)n.z^2 ]
where:
v' ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_scale( vectors, scale ):\n # create a scaling matrix\n matrix = numpy.array([\n [ scale[ 0 ], 0.0, 0.0 ],\n [ 0.0, scale[ 1 ], 0.0 ],\n [ 0.0, 0.0, scale[ 2 ] ]\n ])\n return numpy.dot( vectors, matrix )",
"def scale_vectors(vectors, f):\n return [scale_vector(ve... | [
"0.6662197",
"0.6507097",
"0.61409515",
"0.608848",
"0.5960277",
"0.59000295",
"0.5844457",
"0.5774308",
"0.566719",
"0.5564189",
"0.545749",
"0.5408552",
"0.5405568",
"0.5393711",
"0.5342308",
"0.5331461",
"0.53202534",
"0.53033173",
"0.5275942",
"0.52735925",
"0.5238962",
... | 0.72134334 | 0 |
Applies a 3 dimensional scale to a set of vectors. | def apply_scale( vectors, scale ):
# create a scaling matrix
matrix = numpy.array([
[ scale[ 0 ], 0.0, 0.0 ],
[ 0.0, scale[ 1 ], 0.0 ],
[ 0.0, 0.0, scale[ 2 ] ]
])
return numpy.dot( vectors, matrix ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale_vectors(vectors, f):\n return [scale_vector(vector, f) for vector in vectors]",
"def apply_scale( vertices, scale=1.0 ):\n checkVerticesValidity( vertices )\n if type(scale) != float:\n raise ValueError\n \n for i in range(len(vertices)):\n v = vertices[i]\n tmpv = [... | [
"0.71041596",
"0.6487279",
"0.6485424",
"0.64662945",
"0.6345029",
"0.6303627",
"0.6060879",
"0.6046138",
"0.6014817",
"0.59162086",
"0.59115326",
"0.5910346",
"0.58851117",
"0.5880268",
"0.58379424",
"0.58329576",
"0.58122903",
"0.5797459",
"0.57912207",
"0.5773743",
"0.5767... | 0.74894387 | 0 |
Sanitize a given string for use in LaTeX | def sanitize(s):
s = s.replace("_", "\\_")
return s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitizeTex(texstring):\n\n newstring = (\n texstring.replace(r\"\\\\%\", r\"\\%\")\n .replace(r\"\\\\\", r\"\\tabularnewline\")\n .replace(\"\\$\", \"$\")\n .replace(\"\\_\", \"_\")\n .replace(\"ug/L\", \"\\si[per-mode=symbol]{\\micro\\gram\\per\\liter}\")\n .repla... | [
"0.79070896",
"0.7341153",
"0.7003761",
"0.6971657",
"0.68508697",
"0.68284774",
"0.6824936",
"0.68216455",
"0.68206507",
"0.68178976",
"0.67470694",
"0.6732892",
"0.6716535",
"0.67127985",
"0.6710152",
"0.670698",
"0.6703582",
"0.6703582",
"0.67018497",
"0.6690541",
"0.66677... | 0.6288298 | 66 |
Call after self.Q has converged to, on an infinite loop, get the current state and perform the action in that state with highest qvalue. | def execute_best_actions(self):
while True:
print("In execute_best_actions")
s = self.get_state_num()
qvals = self.Q[s]
# Get action with largest qval
best_action = np.argmax(qvals)
# We don't actually update with rewards,
# but... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _transition_q_learning(self):\n if self.state.as_tuple() not in self.qstore.q:\n self.enum.enumerate_state(self.state, self.qstore.q)\n\n action_values = self.qstore.q[self.state.as_tuple()]\n # epsilon greedy choice\n if np.random.random() < self.epsilon:\n ac... | [
"0.7055279",
"0.6744102",
"0.671204",
"0.67064065",
"0.6705401",
"0.668007",
"0.6544516",
"0.6539079",
"0.6539079",
"0.6531268",
"0.6530377",
"0.65045273",
"0.64821327",
"0.64717346",
"0.64598113",
"0.6458333",
"0.64546317",
"0.6418523",
"0.6402537",
"0.63667685",
"0.6363638"... | 0.67206407 | 2 |
Get a dictionary containing the total score for ``obj`` and the number of votes it's received. Thus, it can be used to calculate the best rated objects in a very simplified scale. This isn't a very good rating function right now, because an object that has got a lot of up and downvotes is a reflection of its popularity... | def get_score(self, obj):
content_type = ContentType.objects.get_for_model(obj)
result = self.filter(content_type=content_type,
object_id=obj._get_pk_val()).aggregate(
score=Sum('vote'),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_score(self, obj):\n ctype = ContentType.objects.get_for_model(obj)\n result = self.filter(object_id=obj._get_pk_val(),\n content_type=ctype).extra(\n select={\n 'score': 'COALESCE(SUM(vote), 0)',\n 'num_votes': 'COALESCE(COU... | [
"0.81031865",
"0.79285175",
"0.6855811",
"0.67928356",
"0.6763918",
"0.6228135",
"0.61716664",
"0.59057057",
"0.5784851",
"0.5742161",
"0.5692605",
"0.5655364",
"0.5652737",
"0.56520414",
"0.5641303",
"0.5590621",
"0.5585837",
"0.5560485",
"0.5549761",
"0.55324996",
"0.551647... | 0.80732733 | 1 |
Get the top N scored objects for a given model. Yields (object, score) tuples. | def get_top(self, model, limit=10, inverted=False):
content_type= ContentType.objects.get_for_model(model)
#Get a queryset of all the objects of the model. Get their scores
results = self.filter(content_type=content_type).values('object_id').annotate(score=Sum('vote'))
if inverted:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_top(self, Model, limit=10, reversed=False):\n ctype = ContentType.objects.get_for_model(Model)\n query = \"\"\"\n SELECT object_id, SUM(vote) as %s\n FROM %s\n WHERE content_type_id = %%s\n GROUP BY object_id\"\"\" % (\n connection.ops.quote_name('score'... | [
"0.6620148",
"0.6568486",
"0.6029523",
"0.5966627",
"0.5958777",
"0.588728",
"0.57843107",
"0.57750875",
"0.5712884",
"0.5682572",
"0.5677662",
"0.5639743",
"0.5635089",
"0.5624442",
"0.5623601",
"0.55735147",
"0.5531635",
"0.5519599",
"0.55086815",
"0.5506289",
"0.5492053",
... | 0.7162024 | 0 |
Get the bottom (i.e. most negative) N scored objects for a given model. Yields (object, score) tuples. | def get_bottom(self, model, limit):
return self.get_top(model=model, limit=limit, reversed=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_top(self, model, limit=10, inverted=False):\n content_type= ContentType.objects.get_for_model(model)\n\n #Get a queryset of all the objects of the model. Get their scores\n results = self.filter(content_type=content_type).values('object_id').annotate(score=Sum('vote'))\n if inve... | [
"0.6854979",
"0.6772459",
"0.6659615",
"0.5919356",
"0.5495765",
"0.5441017",
"0.5422967",
"0.5374533",
"0.533833",
"0.5326259",
"0.52904046",
"0.52887124",
"0.5285204",
"0.5284337",
"0.52065706",
"0.5205698",
"0.5190723",
"0.5187864",
"0.5182705",
"0.5175455",
"0.51667124",
... | 0.541528 | 7 |
Returns a single randomly selected tweet. | def choose_tweet(pos_tweets):
tweet = choice(pos_tweets)
return tweet | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handler(event, context):\n send_tweet(random.choice(potential_tweets))",
"def handler(event, context):\n send_tweet(random.choice(potential_tweets))",
"def handler(event,context):\n send_tweet(random.choice(potential_tweets))",
"def mock_tweet():\n count = random.randint(70, 140)\n return ... | [
"0.69579417",
"0.69579417",
"0.69258714",
"0.6577981",
"0.63306475",
"0.6282631",
"0.6218992",
"0.6208195",
"0.6181834",
"0.6129136",
"0.61065483",
"0.60549045",
"0.6049556",
"0.60462",
"0.6039426",
"0.6018565",
"0.5995151",
"0.59862554",
"0.59862554",
"0.59862554",
"0.597905... | 0.7728843 | 0 |
Return number of unmerged commits. | def unmerged_total(self):
return int(self.git.rev_list('--count', '{}..{}'.format(self.base_branch, self.topic_branch))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_git_commiter_count(path):\n process = subprocess.Popen(['git', 'shortlog', '-sn'], cwd=path, stdout=subprocess.PIPE)\n stdout, _ = process.communicate()\n committers = stdout.decode(\"ISO-8859-1\")\n return len(committers.split('\\n'))",
"def get_commit_count():\n if COMMIT_COUNT is None:\... | [
"0.6773051",
"0.6740454",
"0.6568362",
"0.6104326",
"0.60325164",
"0.59609437",
"0.5774543",
"0.56423247",
"0.56212234",
"0.56212234",
"0.5621026",
"0.53949195",
"0.5394291",
"0.539106",
"0.5321197",
"0.5314997",
"0.5308237",
"0.5281387",
"0.52706915",
"0.52404267",
"0.522989... | 0.75320995 | 0 |
Get the timestamp of the current datetime (UTC+0). | def now_timestamp(unit: TimeUnit = TimeUnit.SECONDS) -> float:
return TimeHelper.to_timestamp(TimeHelper.now(), unit) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def utcnow_ts():\r\n return calendar.timegm(utcnow().timetuple())",
"def get_current_timestamp():\n return int(round(time.time() * 1e3))",
"def current_timestamp(self) -> time:\n\n return time.time()",
"def get_utc_now_timestamp() -> int:\n return int(datetime.datetime.now(datetime.timezo... | [
"0.8128896",
"0.7950068",
"0.79068804",
"0.7879169",
"0.7803992",
"0.779588",
"0.762444",
"0.7621025",
"0.7606697",
"0.75824934",
"0.75821215",
"0.75002515",
"0.74046713",
"0.73762214",
"0.7365892",
"0.73491395",
"0.73374605",
"0.7330938",
"0.7327624",
"0.73222387",
"0.729858... | 0.7030237 | 46 |
Get a datetime (UTC+0) from a given timestamp. | def from_timestamp(timestamp: float, unit: TimeUnit = TimeUnit.SECONDS) -> datetime:
timestamp_in_sec: float = timestamp / (1000 ** int(unit))
return datetime.fromtimestamp(timestamp_in_sec, tz=timezone.utc) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fromtimestamp(cls, timestamp):\n return datetime.datetime.utcfromtimestamp(timestamp)",
"def from_timestamp(timestamp: float, tz_info: tzinfo = UTC) -> datetime:\n utc_dt = datetime.fromtimestamp(timestamp, tz=UTC)\n return convert_timezone(utc_dt, tz_info)",
"def _timestamp_to_datetime(timest... | [
"0.794051",
"0.7511175",
"0.74730664",
"0.74206144",
"0.73750776",
"0.7223302",
"0.7184576",
"0.7102429",
"0.7044664",
"0.6915108",
"0.68710554",
"0.6802214",
"0.67751104",
"0.67445123",
"0.67129403",
"0.6673835",
"0.6572541",
"0.65684503",
"0.65646917",
"0.6556415",
"0.65375... | 0.70273954 | 9 |
Convert a datetime to a timestamp. | def to_timestamp(date_time: datetime, unit: TimeUnit = TimeUnit.SECONDS) -> float:
return date_time.replace(tzinfo=timezone.utc).timestamp() * (1000 ** int(unit)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _datetime_to_timestamp(self, dt):\n return time.mktime(dt.timetuple())",
"def datetime_to_timestamp(value):\n if not isinstance(value, datetime.datetime):\n raise ValueError(\n 'Expecting datetime object, got %s instead' % type(value).__name__)\n if value.tzinfo is not None:\n raise Val... | [
"0.78914905",
"0.7560773",
"0.74864686",
"0.74651605",
"0.7394036",
"0.7391953",
"0.73898655",
"0.73102313",
"0.71485525",
"0.7114895",
"0.702918",
"0.70137656",
"0.7007949",
"0.6956953",
"0.69367707",
"0.68967223",
"0.6878627",
"0.6839798",
"0.68312806",
"0.6759354",
"0.6743... | 0.69854754 | 13 |
Make a friendly filename for the image using the group key. | def make_filename(key, extension):
key = unicode(key.strip())
return '{}.{}'.format(slugify(key), extension) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_image_name(self, image):\n return image.replace('shub://', '').replace('/', '-') + '.simg'",
"def generate_container_name(file_group):\n file_group = file_group.lower()\n # Check for any chars that aren't 'a-z', '0-9' or '-'\n valid_chars = r'^[a-z0-9][-a-z0-9]*$'\n # Replace any ... | [
"0.73010015",
"0.72769046",
"0.6884829",
"0.68747765",
"0.68047935",
"0.67867476",
"0.6779212",
"0.66346717",
"0.6630774",
"0.66114205",
"0.6602075",
"0.6564071",
"0.65483004",
"0.65046066",
"0.6477566",
"0.6474544",
"0.6470609",
"0.64491904",
"0.6440801",
"0.6429668",
"0.639... | 0.65414995 | 13 |
Makes all time series equal in length with no zeroes | def equalise_ts(station_list):
s_y={}
s_y_size = 5000 #large number for first pass
for s in station_list:
s_data = np.loadtxt('station_fuelType/'+s+"_P98",delimiter=',')
s_y[s] = s_data[:,1]
while float(s_y[s][0]) == 0.0:
s_y[s]=s_y[s][1:len(s_y[s])]
if len(s_y[s]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zero_pad(time_series, NFFT):\r\n\r\n n_dims = len(time_series.shape)\r\n n_time_points = time_series.shape[-1]\r\n\r\n if n_dims>1:\r\n n_channels = time_series.shape[:-1]\r\n shape_out = n_channels + (NFFT,)\r\n else:\r\n shape_out = NFFT\r\n # zero pad if time_series is to... | [
"0.64330965",
"0.6358601",
"0.62545437",
"0.61888236",
"0.592304",
"0.5854874",
"0.58504313",
"0.58008087",
"0.57790095",
"0.57634085",
"0.5755235",
"0.566739",
"0.5647303",
"0.561315",
"0.56029075",
"0.55807287",
"0.55233836",
"0.54727113",
"0.5463944",
"0.5463054",
"0.54624... | 0.5254565 | 33 |
Compute the area of a geospatial value. Returns FloatingValue The area of `self` | def area(self) -> ir.FloatingValue:
return ops.GeoArea(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area(self) -> float:\n raise NotImplementedError",
"def area(self):\n if isinstance(self.crs, GeographicalCRS):\n major_axis = self.crs.ellipsoid.a\n minor_axis = self.crs.ellipsoid.b\n\n area = 0.0\n if major_axis == minor_axis: # Sphere\n ... | [
"0.78390014",
"0.7787656",
"0.7762487",
"0.771008",
"0.7676024",
"0.7494311",
"0.73737156",
"0.73681015",
"0.7305198",
"0.7286801",
"0.72227156",
"0.71913487",
"0.7185521",
"0.71353227",
"0.71084666",
"0.70956665",
"0.7095528",
"0.7091121",
"0.7076087",
"0.70625275",
"0.70147... | 0.89519435 | 0 |
Check if the geometry contains the `right`. | def contains(self, right: GeoSpatialValue) -> ir.BooleanValue:
return ops.GeoContains(self, right).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contains_properly(self, right: GeoSpatialValue) -> ir.BooleanValue:\n return ops.GeoContainsProperly(self, right).to_expr()",
"def has_right(self):\n return self.right != None",
"def has_right(self):\n return self.__right != None",
"def _has_right(self, index):\r\n return self... | [
"0.74359876",
"0.72793853",
"0.7162032",
"0.71313685",
"0.7104263",
"0.7080955",
"0.7043116",
"0.6947427",
"0.6821204",
"0.68029386",
"0.67226464",
"0.66499645",
"0.6534325",
"0.6515708",
"0.6388527",
"0.6320226",
"0.6316371",
"0.63119715",
"0.6262486",
"0.62425137",
"0.62395... | 0.7121149 | 4 |
Check if the first geometry is covered by the second one. | def covered_by(self, right: GeoSpatialValue) -> ir.BooleanValue:
return ops.GeoCoveredBy(self, right).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_intersection(obj1, obj2):\n (x1, y1, w1, h1) = obj1.get_box()\n (x2, y2, w2, h2) = obj2.get_box()\n if x2 + w2 - 1 < x1 or x2 >= x1 + w1:\n return False\n if y2 + h2 - 1 < y1 or y2 >= y1 + h1:\n return False\n \n return True",
"def doBoundingBoxesIntersect(self, other):\... | [
"0.71286327",
"0.6942842",
"0.67161864",
"0.6662393",
"0.6647419",
"0.6625198",
"0.66251576",
"0.65791607",
"0.65653855",
"0.6551699",
"0.6545251",
"0.6545058",
"0.6539811",
"0.6536719",
"0.650972",
"0.65061027",
"0.6498796",
"0.6488622",
"0.64678764",
"0.6434204",
"0.6415926... | 0.0 | -1 |
Check if `self` is entirely within `distance` from `right`. | def d_fully_within(
self,
right: GeoSpatialValue,
distance: ir.FloatingValue,
) -> ir.BooleanValue:
return ops.GeoDFullyWithin(self, right, distance).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def d_within(\n self,\n right: GeoSpatialValue,\n distance: ir.FloatingValue,\n ) -> ir.BooleanValue:\n return ops.GeoDWithin(self, right, distance).to_expr()",
"def within_distance(self, point, distance):\n return all(distance >= seg.shortest_distance_to(point)\n ... | [
"0.7167458",
"0.66897726",
"0.65852267",
"0.6398431",
"0.631626",
"0.6159795",
"0.6069909",
"0.60572755",
"0.5953424",
"0.59026295",
"0.5893493",
"0.5875279",
"0.57910955",
"0.5758687",
"0.5736612",
"0.57315516",
"0.57160324",
"0.5710056",
"0.57049614",
"0.57049614",
"0.56849... | 0.7242819 | 0 |
Check if `self` is partially within `distance` from `right`. | def d_within(
self,
right: GeoSpatialValue,
distance: ir.FloatingValue,
) -> ir.BooleanValue:
return ops.GeoDWithin(self, right, distance).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def d_fully_within(\n self,\n right: GeoSpatialValue,\n distance: ir.FloatingValue,\n ) -> ir.BooleanValue:\n return ops.GeoDFullyWithin(self, right, distance).to_expr()",
"def within_distance(self, point, distance):\n return all(distance >= seg.shortest_distance_to(point)\n... | [
"0.7420986",
"0.6674265",
"0.6413584",
"0.61454713",
"0.6127788",
"0.5950731",
"0.59127736",
"0.5828475",
"0.5825035",
"0.5794298",
"0.57647914",
"0.56845057",
"0.5664932",
"0.5646242",
"0.56445026",
"0.5642126",
"0.5579724",
"0.5579724",
"0.5560193",
"0.55255526",
"0.5500712... | 0.7225795 | 1 |
Check if the geometries are equal. | def geo_equals(self, right: GeoSpatialValue) -> ir.BooleanValue:
return ops.GeoEquals(self, right).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_equality(self):\n\n s3 = space(curvature=1/5)\n for k in (0, -1, 1, 1.75, 0.325, 1/7, -1.75, -0.325, -1/7):\n s1 = space(fake_curvature=k)\n s2 = space(fake_curvature=k)\n self.assertTrue(s1 == s2)\n self.assertTrue(hash(s1) == hash(s2))\n ... | [
"0.66375434",
"0.65882397",
"0.6416813",
"0.6374062",
"0.6363448",
"0.635945",
"0.6321523",
"0.62795717",
"0.6271236",
"0.6188196",
"0.61446154",
"0.6116885",
"0.6116209",
"0.610441",
"0.60991853",
"0.60832536",
"0.6053294",
"0.604458",
"0.6042769",
"0.6042236",
"0.60419905",... | 0.0 | -1 |
Get the type of a geometry. Returns StringValue String representing the type of `self`. | def geometry_type(self) -> ir.StringValue:
return ops.GeoGeometryType(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_geometry_type(self):\n return self.geometry_type",
"def get_geometry_type(self):\n return self._geometry_type",
"def geom_type(self):\n return _property_op(arctern.ST_GeometryType, self)",
"def geom_type(self): # -> str:\n ...",
"def GetObjectTypeString(type):\n ... | [
"0.76413125",
"0.758172",
"0.7331979",
"0.711782",
"0.69186944",
"0.6886925",
"0.6850519",
"0.6850519",
"0.68425244",
"0.68053585",
"0.67596257",
"0.6710633",
"0.6700815",
"0.6681921",
"0.6681921",
"0.6681921",
"0.66299194",
"0.6629663",
"0.6625415",
"0.6621467",
"0.65781057"... | 0.82591885 | 0 |
Check if two geometries are equal and have the same point ordering. Returns true if the two geometries are equal and the coordinates are in the same order. | def ordering_equals(self, right: GeoSpatialValue) -> ir.BooleanValue:
return ops.GeoOrderingEquals(self, right).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_coordinates(a: tuple, b: tuple) -> bool:\n return all(np.array(a) < np.array(b))",
"def proj_is_same(p1, p2):\n if has_gdal:\n # this is more robust, but gdal is a pain\n s1 = osr.SpatialReference()\n s1.ImportFromProj4(p1.srs)\n s2 = osr.SpatialReference()\n ... | [
"0.7220397",
"0.71463054",
"0.6850719",
"0.6790405",
"0.67355716",
"0.6695321",
"0.66638625",
"0.66298896",
"0.6626457",
"0.66249317",
"0.66158235",
"0.6571864",
"0.65682805",
"0.65573114",
"0.6546626",
"0.6546626",
"0.6533778",
"0.6521973",
"0.64543235",
"0.6434683",
"0.6373... | 0.60856986 | 55 |
Compute the distance between two geospatial expressions. | def distance(self, right: GeoSpatialValue) -> ir.FloatingValue:
return ops.GeoDistance(self, right).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(a, b):\n return vincenty((float(a.longitude), float(a.latitude)),\n (float(b.longitude), float(b.latitude))).km",
"def distance(self, a, b):\n \n # -----------------------------\n # Your code\n '''R = 3963 # radius of Earth (miles)\n lat1, lo... | [
"0.67492944",
"0.67315775",
"0.6720346",
"0.66882116",
"0.66505593",
"0.6646785",
"0.66209525",
"0.6602943",
"0.6596843",
"0.65880513",
"0.6574677",
"0.6560092",
"0.6550573",
"0.6542965",
"0.6534998",
"0.65274507",
"0.6516017",
"0.64990103",
"0.6498941",
"0.648396",
"0.647728... | 0.6739062 | 1 |
Compute the length of a geospatial expression. Returns FloatingValue Length of `self` | def length(self) -> ir.FloatingValue:
return ops.GeoLength(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length(self):\n return _property_op(arctern.ST_Length, self)",
"def getLength(self):\n return self.geometry.length",
"def length(self) -> float:\n n = self.geodesic.extrinsicDimension()\n third = 1.0/3.0\n def distance(x,y):\n cp0 = x[:n]\n cp1 = sel... | [
"0.759075",
"0.75095755",
"0.7373766",
"0.73544824",
"0.7261306",
"0.7236807",
"0.7201984",
"0.70979667",
"0.70661324",
"0.7026694",
"0.6963566",
"0.6913003",
"0.68597555",
"0.684015",
"0.6811498",
"0.67878556",
"0.677738",
"0.6695058",
"0.66927135",
"0.6674483",
"0.6637787",... | 0.8851043 | 0 |
Returns the 2dimensional max distance between two geometries in projected units. If `self` and `right` are the same geometry the function will return the distance between the two vertices most far from each other in that geometry. | def max_distance(self, right: GeoSpatialValue) -> ir.FloatingValue:
return ops.GeoMaxDistance(self, right).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calcDistance(self, left, right):\n\n return math.fabs(right-left)",
"def distance(self, right: GeoSpatialValue) -> ir.FloatingValue:\n return ops.GeoDistance(self, right).to_expr()",
"def distance_to(self, other: Geometry[Scalar]) -> Scalar:\n return (self._distance_to_point(other)\n ... | [
"0.7138382",
"0.69984686",
"0.62663174",
"0.6188633",
"0.61593235",
"0.61498183",
"0.61449254",
"0.6134089",
"0.6068625",
"0.6057324",
"0.6041501",
"0.60340476",
"0.6026349",
"0.60073996",
"0.5995334",
"0.59545815",
"0.5942099",
"0.5938405",
"0.59302366",
"0.5925812",
"0.5921... | 0.7459676 | 0 |
Return the X coordinate of `self`, or NULL if not available. Input must be a point. Returns FloatingValue X coordinate of `self` | def x(self) -> ir.FloatingValue:
return ops.GeoX(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def x(self):\n return _libsbml.Point_x(self)",
"def x(self):\n if self._x is None:\n self.compute_coordinates()\n return self._x",
"def _get_x(self):\n return self.position.x",
"def get_x(self):\n return self.coords[0]",
"def get_x_position(self):\n retu... | [
"0.7814623",
"0.78104514",
"0.7591496",
"0.7546243",
"0.75261414",
"0.7450409",
"0.7361697",
"0.7337589",
"0.7337589",
"0.7246292",
"0.7211677",
"0.7160209",
"0.7126991",
"0.7117762",
"0.7105483",
"0.70794123",
"0.6926576",
"0.69061804",
"0.68926066",
"0.68602324",
"0.6833039... | 0.7151541 | 12 |
Return the Y coordinate of `self`, or NULL if not available. Input must be a point. Returns FloatingValue Y coordinate of `self` | def y(self) -> ir.FloatingValue:
return ops.GeoY(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def y(self):\n return _libsbml.Point_y(self)",
"def getY(self):\n y = self.getAttribute('y')\n kind = self.getKind()\n self._y = y if kind == 'pie' else None\n return self._y",
"def y(self):\n if self._y is None:\n self.compute_coordinates()\n return ... | [
"0.7559136",
"0.7464621",
"0.74579424",
"0.74516743",
"0.7447463",
"0.74445784",
"0.74270296",
"0.74270296",
"0.7409005",
"0.73963886",
"0.73947215",
"0.7389522",
"0.73710334",
"0.7309924",
"0.7270492",
"0.7249949",
"0.7202446",
"0.7196194",
"0.71444803",
"0.71249986",
"0.705... | 0.6994527 | 23 |
Return the X minima of a geometry. Returns FloatingValue X minima | def x_min(self) -> ir.FloatingValue:
return ops.GeoXMin(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def x_min(self):\n return self.get_min_value(self.X_INDEX)",
"def getMinX(self):\n return self.minx",
"def MinX(*args, **kwargs):\n return _gdi_.DC_MinX(*args, **kwargs)",
"def argminX( self ):\n min = 1e30\n minX = None\n for i in range( 0, self.GetN() ):\n p = ( ... | [
"0.6936281",
"0.68577117",
"0.6676654",
"0.65368813",
"0.65021634",
"0.64860624",
"0.64765996",
"0.6459425",
"0.6271408",
"0.62344307",
"0.62138295",
"0.62108153",
"0.6197507",
"0.6180147",
"0.6161268",
"0.60633",
"0.6042033",
"0.59815675",
"0.59366107",
"0.58715415",
"0.5848... | 0.75810975 | 0 |
Return the X maxima of a geometry. Returns FloatingValue X maxima | def x_max(self) -> ir.FloatingValue:
return ops.GeoXMax(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def x_max(self):\n return self.get_max_value(self.X_INDEX)",
"def xminmax ( self ) :\n return self.xvar.minmax()",
"def getMaxX(self):\n return self.maxx",
"def maxx(self):\n return self.__maxx",
"def MaxX(*args, **kwargs):\n return _gdi_.DC_MaxX(*args, **kwargs)",
"def... | [
"0.70034647",
"0.6844462",
"0.68119204",
"0.6744491",
"0.66253954",
"0.65137553",
"0.6445284",
"0.63773924",
"0.6355037",
"0.6352898",
"0.634081",
"0.6320554",
"0.6241515",
"0.61676",
"0.60805666",
"0.60124505",
"0.59927404",
"0.59921575",
"0.5976097",
"0.5970284",
"0.5966874... | 0.774601 | 0 |
Return the Y minima of a geometry. Returns FloatingValue Y minima | def y_min(self) -> ir.FloatingValue:
return ops.GeoYMin(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yminmax ( self ) :\n return self.yvar.minmax()",
"def argminY( self ):\n min = 1e30\n for i in range( 0, self.GetN() ):\n p = ( ROOT.Double(), ROOT.Double() )\n self.GetPoint( i, p[0], p[1] )\n if p[1] < min: min = p[1]\n return min",
"def getMinY(self):\n ... | [
"0.66017616",
"0.6561854",
"0.6507894",
"0.6417266",
"0.6388026",
"0.6362979",
"0.6347971",
"0.6301745",
"0.6212872",
"0.6202674",
"0.615909",
"0.61345196",
"0.61152333",
"0.61130464",
"0.6020709",
"0.5908351",
"0.579901",
"0.57950985",
"0.57829785",
"0.5726",
"0.5721702",
... | 0.7229437 | 0 |
Return the first point of a `LINESTRING` geometry as a `POINT`. Return `NULL` if the input parameter is not a `LINESTRING` Returns PointValue Start point | def start_point(self) -> PointValue:
return ops.GeoStartPoint(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_point_from_linestring(geom_row, X=0, behaviour='last'):\n\n lat = None\n lng = None\n try:\n X = round(X)\n except Exception as e:\n raise TypeError(\"Please enter a number for the index of the point within the linestring (X)\")\n\n if behaviour in ['last', 'ignore']:\n ... | [
"0.6900281",
"0.6412776",
"0.6308229",
"0.6055818",
"0.6031474",
"0.5971331",
"0.5921453",
"0.5892484",
"0.5889433",
"0.58782244",
"0.5713872",
"0.5669867",
"0.565784",
"0.5622244",
"0.56021214",
"0.5563299",
"0.55588895",
"0.5468982",
"0.5464776",
"0.54572684",
"0.5446547",
... | 0.66960007 | 1 |
Return the last point of a `LINESTRING` geometry as a `POINT`. Return `NULL` if the input parameter is not a `LINESTRING` Returns PointValue End point | def end_point(self) -> PointValue:
return ops.GeoEndPoint(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_point_from_linestring(geom_row, X=0, behaviour='last'):\n\n lat = None\n lng = None\n try:\n X = round(X)\n except Exception as e:\n raise TypeError(\"Please enter a number for the index of the point within the linestring (X)\")\n\n if behaviour in ['last', 'ignore']:\n ... | [
"0.6676908",
"0.5809005",
"0.5783823",
"0.56184757",
"0.55974036",
"0.55868995",
"0.55476713",
"0.55083495",
"0.54330933",
"0.5421323",
"0.5405748",
"0.5357882",
"0.5356936",
"0.5310009",
"0.53001106",
"0.5296828",
"0.52810085",
"0.5279905",
"0.5247025",
"0.52342033",
"0.5233... | 0.6394568 | 1 |
Check if the first geometry is completely inside of the second. | def within(self, right: GeoSpatialValue) -> ir.BooleanValue:
return ops.GeoWithin(self, right).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_intersection(obj1, obj2):\n (x1, y1, w1, h1) = obj1.get_box()\n (x2, y2, w2, h2) = obj2.get_box()\n if x2 + w2 - 1 < x1 or x2 >= x1 + w1:\n return False\n if y2 + h2 - 1 < y1 or y2 >= y1 + h1:\n return False\n \n return True",
"def doBoundingBoxesIntersect(self, other):\... | [
"0.74680316",
"0.7408429",
"0.70452654",
"0.69574714",
"0.6937502",
"0.6915073",
"0.6837254",
"0.67717266",
"0.6763551",
"0.67628014",
"0.6729661",
"0.6718734",
"0.66913474",
"0.6684846",
"0.6656848",
"0.66410434",
"0.6634701",
"0.6622003",
"0.6588898",
"0.6587663",
"0.656007... | 0.0 | -1 |
Return the Courses that the given user is an instructor for. Returns a QuerySet. | def faculty_courses_for_user(user):
return Course.objects.filter(faculty_group__in=user.groups.all()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_enrollments_for_courses_in_program(user, program):\n course_keys = [\n CourseKey.from_string(key)\n for key in course_run_keys_for_program(program)\n ]\n return CourseEnrollment.objects.filter(\n user=user,\n course_id__in=course_keys,\n mode__in=[CourseMode.VERI... | [
"0.6672383",
"0.64765507",
"0.63457346",
"0.62248945",
"0.5967342",
"0.5896697",
"0.58316165",
"0.5775987",
"0.5749575",
"0.5679381",
"0.5674233",
"0.56352746",
"0.5620008",
"0.56027764",
"0.55914146",
"0.55296856",
"0.5508865",
"0.5476848",
"0.5475611",
"0.53797096",
"0.5378... | 0.7003235 | 0 |
Return True if the given user is a faculty member on any courses. | def is_faculty(user):
return Affil.objects.filter(user=user).exists() or \
faculty_courses_for_user(user).exists() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_faculty():\n return _is_member('uw_faculty')",
"def is_member(user: User) -> bool:\n if not user:\n raise TypeError('user should not be None')\n return user.name.startswith('L')",
"def registered_for_course(course, user):\r\n if user is None:\r\n return False\r\n if user.is_... | [
"0.8120491",
"0.68026584",
"0.67830014",
"0.672673",
"0.66688967",
"0.6633363",
"0.65973413",
"0.65743434",
"0.65683174",
"0.65278286",
"0.65211505",
"0.65073335",
"0.6498223",
"0.64772063",
"0.6369451",
"0.6323724",
"0.6298432",
"0.6294453",
"0.627507",
"0.62634844",
"0.6256... | 0.8662211 | 0 |
Creates an email with no attachement. | def generate_withno_attachement(sender, recipient, subject, body):
# Basic Email formatting
message = email.message.EmailMessage()
message["From"] = sender
message["To"] = recipient
message["Subject"] = subject
message.set_content(body)
return message | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_email(\n to_field=\"to_user@test1.com\",\n from_field=\"from_user@test2.com\",\n subject=\"This is a test email\",\n body=\"Almost empty text message\",\n attachment=None,\n maintype=None,\n subtype=None,\n):\n msg = EmailMessage()\n\n msg['To'] = to_field\n msg['From'] = ... | [
"0.6983128",
"0.65120506",
"0.62612367",
"0.622603",
"0.61640054",
"0.6127693",
"0.59721655",
"0.5970866",
"0.5969491",
"0.5878382",
"0.5856451",
"0.58348465",
"0.5808649",
"0.57627016",
"0.5760926",
"0.5755286",
"0.57515126",
"0.5740511",
"0.5706194",
"0.5683221",
"0.5677282... | 0.8021318 | 0 |
Convert bytes to str as utf8. sequence values (and keys) will also be converted. | def bytes2str(data):
# pylint: disable=multiple-statements
if isinstance(data, bytes): return data.decode('utf-8')
if isinstance(data, dict): return dict(map(bytes2str, data.items()))
if isinstance(data, tuple): return map(bytes2str, data)
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bytes2str(val):\n if isinstance(val, bytes):\n return str(val, \"utf8\")\n else:\n return val",
"def bytes_to_str(s, encoding='utf-8'):\n if isinstance(s, bytes):\n return s.decode(encoding)\n return s",
"def _bytes_bytearray_to_str(s):\n if isinstance(s, (bytes, bytearr... | [
"0.7663456",
"0.74210477",
"0.7398085",
"0.7320397",
"0.730462",
"0.730462",
"0.7271459",
"0.71937394",
"0.7163248",
"0.7121813",
"0.7071599",
"0.70502776",
"0.70056546",
"0.6998172",
"0.689905",
"0.68760955",
"0.6803896",
"0.6796925",
"0.6780959",
"0.67653143",
"0.6710184",
... | 0.73248 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.