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 |
|---|---|---|---|---|---|---|
finds cells which do not have a number in them and fills them with 0s | def find_empty_cells(self, inverse=False):
if inverse:
black, white = 255, 0
else:
black, white = 0, 255
# create empty ndarray
cells = np.ones(shape=(self.sudoku_size, self.sudoku_size))
for i in range(self.sudoku_size):
for j in range(self.sudoku_size):
if np.sum((self.list_of_number_pictur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_empty_cells(gr):\n l = list()\n for i in range(0,9):\n for j in range(0,9):\n if(gr[i][j] == 0):\n l.append([i, j])\n return l",
"def empty_cells(state):\n cells = []\n\n for i, row in enumerate(state):\n for j, col in enumerate(row):\n i... | [
"0.63726395",
"0.6156172",
"0.61479706",
"0.61292577",
"0.6080935",
"0.60792893",
"0.60428655",
"0.60391116",
"0.6028602",
"0.6009772",
"0.60081273",
"0.6008114",
"0.6000084",
"0.5971383",
"0.5959276",
"0.5937954",
"0.5937192",
"0.5928519",
"0.5919331",
"0.5910109",
"0.590783... | 0.5961797 | 14 |
Return value at path, return None if not found. | def index(self, path):
try:
indices = [int(x) if x.isdigit() else x for x in split(r'[\/\[\]]+', path[1:])]
return reduce(lambda x, y: x[y], indices, self.document)
except:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_value(metadata, path):\n if not path:\n return metadata\n\n return_data = metadata\n for element in (_slash_replace.sub('', s) for s in _dot_split.split(path)):\n if not element in return_data:\n log.debug(\"No value at path %s (missing index: %s)\", path, element)\n ... | [
"0.7250427",
"0.69153553",
"0.68373066",
"0.67195123",
"0.6691132",
"0.66349036",
"0.6580087",
"0.6579546",
"0.6558514",
"0.6533422",
"0.65330327",
"0.64275295",
"0.64191973",
"0.6399985",
"0.63409203",
"0.6318846",
"0.63126427",
"0.6260088",
"0.62437546",
"0.62154764",
"0.62... | 0.0 | -1 |
Get Request for Explorer. Get a single item in JSON | def get(self, osti_id: str) -> Union[ExplorerGetJSONResponseModel, None]:
payload = {"osti_id": osti_id}
r = requests.get(
url=self.config.endpoint,
auth=(self.config.username, self.config.password),
params=payload,
)
if r.status_code == 200:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self):\r\n return http.Request('GET', self.get_url()), parsers.parse_json",
"def get(self):\r\n return http.Request('GET', self.get_url()), parsers.parse_json",
"def get(self, data):\n ret = self._rest_call({}, 'GET')\n return json.loads(ret[2])",
"def _get(self, p... | [
"0.7052999",
"0.7052999",
"0.67389077",
"0.67362016",
"0.6731834",
"0.6696304",
"0.6655173",
"0.6623547",
"0.6524602",
"0.65163726",
"0.6470075",
"0.6462346",
"0.6453569",
"0.64444405",
"0.6406486",
"0.6406486",
"0.6390398",
"0.6385318",
"0.6377052",
"0.6376083",
"0.63747215"... | 0.63386786 | 24 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, Setting):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Initializes the weights by randomly sampling from a normal distribution with mean equal to zero and standard deviation equal to 1 / sqrt( of features). | def init_weights(self):
self.w = np.random.randn(self.D) / np.sqrt(self.D) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _random_weight_initialization(self, mean=0, stddev=1):\n self.slp_weights = np.random.normal(mean, stddev, size=(self.n_rbfs, self.n_targets))",
"def initialize_weights(self, n_features, random=True):\n\t\tif random:\n\t\t\tlimit = 1 / math.sqrt(n_features)\n\t\t\tself.weights = np.random.uniform(-lim... | [
"0.8206421",
"0.8137111",
"0.8037959",
"0.7763505",
"0.7710391",
"0.77081496",
"0.7557243",
"0.75509477",
"0.75509477",
"0.75440735",
"0.7520179",
"0.7481814",
"0.7457216",
"0.74463165",
"0.74086434",
"0.7379182",
"0.7333214",
"0.73051447",
"0.7290358",
"0.72875553",
"0.72875... | 0.80543685 | 2 |
Makes predictions Y by taking the dot product of input matrix X and weight vector w. | def make_predictions(self):
self.Y = self.X.dot(self.w) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict(X, w):\n X = np.append(X, np.ones((X.shape[0], 1)), axis=1)\n return np.dot(X, w)",
"def predict(X, w):\n \n return np.sign(np.dot(X, w))",
"def predict(self, X):\n return np.dot(X, self.__W.T)",
"def predict(self, X):\n W, b = self.W, self.b\n H = W.dot(X) + b ... | [
"0.8115988",
"0.77387285",
"0.74467486",
"0.72198176",
"0.7165027",
"0.7144741",
"0.7129969",
"0.70550495",
"0.7031619",
"0.6894089",
"0.6816237",
"0.68108976",
"0.68079615",
"0.6779354",
"0.67640775",
"0.6710545",
"0.6676375",
"0.665121",
"0.6650674",
"0.6650674",
"0.6650674... | 0.77609986 | 1 |
Plots the MSE (mean squared error) against iteration i. | def plot_errors(self):
plt.title("Prediction Error")
plt.plot(self.errors)
plt.ylabel("MSE (Mean Squared Error)")
plt.xlabel("Iteration")
plt.show() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _plot_rmse(self, val=False):\n _, ax = plt.subplots()\n ax.plot(self.global_rmse, linewidth=3, color='blue', label='Train RMSE')\n ax.set_title('RMSE vs. Number of Iterations')\n if val is not None:\n ax.plot(self.validation_rmse, linewidth=3, color='green', label='Valida... | [
"0.6699449",
"0.64437956",
"0.64284956",
"0.6400301",
"0.6389228",
"0.6380105",
"0.62787455",
"0.6214237",
"0.6197307",
"0.6140836",
"0.61023796",
"0.60987705",
"0.6081839",
"0.6072457",
"0.6059889",
"0.6037648",
"0.6034095",
"0.60320795",
"0.6029691",
"0.60098356",
"0.600621... | 0.71222043 | 0 |
Plots the targets T and predictions Y to visualize how good of a fit the model is. | def plot_predictions(self):
plt.title("Targets vs. Predictions")
plt.plot(self.T, label="Targets")
plt.plot(self.Y, label="Predictions")
plt.xlabel("Sample number")
plt.legend()
plt.show() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_predictions(y, yhat, title=\"Predictions vs Actual\", output_dir=None):\n\n fig = plt.figure(figsize=(15, 6))\n plt.xlabel('Time')\n plt.ylabel('PM10')\n plt.plot(y, label=\"actual\", figure=fig)\n plt.plot(yhat, label=\"predicted\", figure=fig)\n plt.title(title)\n fig.legend()\n\n ... | [
"0.71288985",
"0.7022675",
"0.7022675",
"0.6916337",
"0.6903036",
"0.6785239",
"0.67822427",
"0.6778142",
"0.67175186",
"0.66345143",
"0.66085094",
"0.66011584",
"0.65973383",
"0.65588045",
"0.6524681",
"0.64693683",
"0.6453688",
"0.6418408",
"0.6358882",
"0.63386923",
"0.632... | 0.80066246 | 0 |
test for duplicate email that already exist | def test_duplicate_email(self):
self.signup('Bo', 'Theo', 'Bo_theo5@example.com', 'Bo1995', 'Bo1995')
rv = self.signup('Bo', 'Theo', 'Bo_theo5@example.com', 'Bo1995', 'Bo1995')
self.assertIn(b'Sorry email already exist', rv.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_duplicate_email(self, email):\r\n request = self.req_factory.post('unused_url', data={\r\n 'new_email': email,\r\n 'password': 'test',\r\n })\r\n request.user = self.user\r\n self.assertFailedRequest(self.run_request(request), 'An account with this e-mail... | [
"0.8520692",
"0.78172445",
"0.78001285",
"0.7586905",
"0.74832606",
"0.72556895",
"0.7247618",
"0.71431816",
"0.70517397",
"0.7045468",
"0.70230013",
"0.6963588",
"0.6950911",
"0.69429374",
"0.69126046",
"0.6910905",
"0.68894863",
"0.6877273",
"0.6871106",
"0.6843638",
"0.683... | 0.831117 | 1 |
test for blank email | def test_blank_email(self):
rv = self.signup('Bo', 'Theo', '', 'Bo1995', 'Bo1995')
self.assertIn(b'Field must be between 6 and 30 characters long.', rv.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_clean_email_empty(self):\n\n raw_email = 'from=<>'\n result = clean_email(raw_email)\n self.assertEqual(result, '')",
"def test_skip_blank_emails(self):\n appt_date = datetime.date.today() + datetime.timedelta(days=7) # Default for email\n confirmed = self.create_confi... | [
"0.793213",
"0.75402564",
"0.75373924",
"0.73284185",
"0.7121124",
"0.706746",
"0.69907707",
"0.6937362",
"0.6878537",
"0.68614763",
"0.68533576",
"0.6843392",
"0.6794039",
"0.6767636",
"0.6730046",
"0.6708045",
"0.6699845",
"0.6691075",
"0.6687847",
"0.6673682",
"0.66578287"... | 0.79435104 | 0 |
test for blank first_name and last_ame | def test_blank_names(self):
rv = self.signup('', '', 'Bo_theo5@example.com', 'Bo1995', 'Bo1995')
self.assertIn(b'This field is required.', rv.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_01_validate_first_name_presence(self):\n try:\n self.record.full_clean()\n except ValidationError as e:\n self.assertTrue('This field cannot be blank.' in e.message_dict['first_name'])",
"def test_02_validate_last_name_presence(self):\n try:\n self.r... | [
"0.7164647",
"0.71258825",
"0.69051296",
"0.6836216",
"0.6655211",
"0.65461046",
"0.6503236",
"0.64804214",
"0.6441869",
"0.6430374",
"0.6417529",
"0.6414938",
"0.6414938",
"0.6395941",
"0.6386296",
"0.6382556",
"0.6371046",
"0.6370312",
"0.63230515",
"0.62889475",
"0.6276469... | 0.68947196 | 3 |
test for invalid email | def test_invalid_email(self):
rv = self.login('Bo_wrong@example.com', 'Bo1995')
self.assertIn(b'Invalid email! Please try again', rv.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_email_when_logging_in(self):\n pass",
"def test_is_invalid_email(self):\n self.assertFalse(is_valid_email('helloworld'))",
"def validate_email(self):\n # source: https://docs.python.org/2/howto/regex.html\n if not re.match(r\"[^@.]+@[A-Za-z]+\\.[a-z]+\", self.email)... | [
"0.80961514",
"0.8060491",
"0.802942",
"0.7910311",
"0.78691256",
"0.7751596",
"0.7713357",
"0.76986647",
"0.7659364",
"0.7657982",
"0.7638226",
"0.76197886",
"0.76058674",
"0.75874066",
"0.7577577",
"0.7549308",
"0.7544363",
"0.7537233",
"0.75114775",
"0.75047326",
"0.748531... | 0.80034435 | 3 |
test for invalid password | def test_invalid_password(self):
self.signup('Bo', 'Theo', 'Bo_theo5@example.com', 'Bo1995', 'Bo1995')
rv = self.login('Bo_theo5@example.com', 'Bo1905')
self.assertIn(b'Invalid password! Please try again', rv.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_password(self):\n pass",
"def test_valid_password(self):\n pass_field = Field(\"\".join(['x' * (int(self.app.config['MAX_PWD_LEN']))]))\n\n valid_password(None, pass_field)",
"def test_invalid_password(self):\n user = User(email=\"test@email.com\", password=\"testpa... | [
"0.8746274",
"0.83141726",
"0.8168117",
"0.81389505",
"0.8132192",
"0.81094533",
"0.80931276",
"0.8022347",
"0.7933623",
"0.7916816",
"0.7883706",
"0.7880168",
"0.78460336",
"0.78292894",
"0.7802343",
"0.7798979",
"0.7792504",
"0.77844435",
"0.7779021",
"0.777288",
"0.7765288... | 0.8162587 | 3 |
test dashboard recipe with category recipe | def test_dashboard_recipe_created_with_category(self):
self.signup('Bo', 'Theo', 'Bo_theo5@example.com', 'Bo1995', 'Bo1995')
self.login('Bo_theo5@example.com', 'Bo1995')
self.dashboard()
self.category('JunkFood')
self.dashboard()
rv = self.recipe_dashboard()
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_recipe_category(self):\n self.signup('Bo', 'Theo', 'Bo_theo5@example.com', 'Bo1995', 'Bo1995')\n self.login('Bo_theo5@example.com', 'Bo1995')\n self.dashboard()\n self.category('JunkFood')\n self.dashboard()\n self.recipe_dashboard()\n rv = self.crea... | [
"0.7822975",
"0.7757862",
"0.7314199",
"0.7276371",
"0.70722616",
"0.7053338",
"0.7044831",
"0.70071536",
"0.69365686",
"0.6932263",
"0.6929715",
"0.6921721",
"0.69130933",
"0.68927675",
"0.68803036",
"0.68663967",
"0.6674692",
"0.66442806",
"0.6633183",
"0.6617582",
"0.65394... | 0.84122765 | 0 |
test for dashboard recipe without category recipe | def test_dashboard_without_recipe(self):
self.signup('Bo', 'Theo', 'Bo_theo5@example.com', 'Bo1995', 'Bo1995')
self.login('Bo_theo5@example.com', 'Bo1995')
self.dashboard()
self.category('JunkFood')
self.dashboard()
rv = self.recipe_dashboard()
self.assertIn(b'Ple... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dashboard_recipe_created_with_category(self):\n self.signup('Bo', 'Theo', 'Bo_theo5@example.com', 'Bo1995', 'Bo1995')\n self.login('Bo_theo5@example.com', 'Bo1995')\n self.dashboard()\n self.category('JunkFood')\n self.dashboard()\n rv = self.recipe_dashboard()\n ... | [
"0.75654453",
"0.6910229",
"0.68697506",
"0.6653582",
"0.66049826",
"0.6560348",
"0.655163",
"0.6536286",
"0.65180236",
"0.6514202",
"0.64542925",
"0.64387083",
"0.63663656",
"0.62480897",
"0.62143815",
"0.61774415",
"0.61774415",
"0.6094549",
"0.6079499",
"0.60059655",
"0.59... | 0.8175236 | 0 |
test for successful creation of recipe category | def test_create_recipe_category(self):
self.signup('Bo', 'Theo', 'Bo_theo5@example.com', 'Bo1995', 'Bo1995')
self.login('Bo_theo5@example.com', 'Bo1995')
self.dashboard()
self.category('JunkFood')
self.dashboard()
self.recipe_dashboard()
rv = self.create_recipe('c... | {
"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_dashboard_recipe_created_with_category(self):\n ... | [
"0.8027599",
"0.77608436",
"0.76497436",
"0.7619055",
"0.72271216",
"0.7176794",
"0.7154521",
"0.70466155",
"0.70134395",
"0.6934381",
"0.6912234",
"0.68598396",
"0.68370193",
"0.6822153",
"0.6820968",
"0.6819011",
"0.6805929",
"0.67831135",
"0.67807174",
"0.677267",
"0.67215... | 0.8226859 | 0 |
test for update of recipe category | def test_edit_recipe_category(self):
self.signup('Bo', 'Theo', 'Bo_theo5@example.com', 'Bo1995', 'Bo1995')
self.login('Bo_theo5@example.com', 'Bo1995')
self.dashboard()
self.category('JunkFood')
self.dashboard()
self.recipe_dashboard()
self.create_recipe('cakes', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_category(self):\n pass",
"def test_update_category(self):\n self.update_success(self.test_data['pants'], self.test_data['shirts'])",
"def test_update(self, init_db, category):\n category_name = fake.alphanumeric()\n category.update(name=category_name)\n assert... | [
"0.8158721",
"0.7643306",
"0.7123698",
"0.70540303",
"0.7014836",
"0.69931114",
"0.6957027",
"0.68744606",
"0.6839674",
"0.6718492",
"0.6710114",
"0.6635176",
"0.6559174",
"0.6558751",
"0.6525768",
"0.6523184",
"0.650304",
"0.64996177",
"0.64944625",
"0.64774287",
"0.64733493... | 0.7533367 | 2 |
Wraps hidden states in new Tensors, to detach them from their history. | def repackage_hidden(h):
if args.algo == "lstm":
if isinstance(h, torch.Tensor):
return h.detach()
else:
return tuple(repackage_hidden(v) for v in h)
hidden = []
for i in range(args.nlayers):
if isinstance(h[i], torch.Tensor):
hidden.append(h[i].de... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detach_hidden(hidden: Any) -> Any:\n return apply_to_tensor(hidden, Tensor.detach)",
"def reset_hidden(self, hidden, reset_flags):\n # detach it from history (pytorch mechanics)\n if self.rnn_type in ['lstm', 'mylstm']:\n h = Variable(hidden[0].data)\n c = Variable(hidd... | [
"0.6896774",
"0.6564761",
"0.6440056",
"0.63181335",
"0.62956357",
"0.61828166",
"0.61425817",
"0.6120289",
"0.6029193",
"0.60253143",
"0.6020807",
"0.5987143",
"0.5969475",
"0.5969475",
"0.5932672",
"0.5932672",
"0.591887",
"0.5889544",
"0.5871412",
"0.58630824",
"0.5850156"... | 0.61264986 | 7 |
Turns five scores into a rating by averaging the middle three of the five scores and assigning this average to a written rating. | def scores_to_rating(score1, score2, score3, score4, score5):
# STEP 1 convert scores to numbers
score1 = convert_to_numeric(score1)
score2 = convert_to_numeric(score2)
score3 = convert_to_numeric(score3)
score4 = convert_to_numeric(score4)
score5 = convert_to_numeric(score5)
# STEP 2 and S... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average_rating(self):\n return ( self.rating_1 + self.rating_2 + self.rating_3) / 3",
"def average_rating(self):\n return ( self.rating_1 + self.rating_2 + self.rating_3 + self.rating_4 + self.rating_5 + self.rating_6 + self.rating_7) / 7",
"def get_mean_score(rating_scores):\n return sum(ra... | [
"0.71468383",
"0.6909938",
"0.66101897",
"0.6277055",
"0.6094669",
"0.6076635",
"0.6049103",
"0.5916455",
"0.5827148",
"0.58212835",
"0.5819062",
"0.58114624",
"0.57186407",
"0.57173955",
"0.56540513",
"0.5638739",
"0.5629601",
"0.55961293",
"0.55776036",
"0.5577129",
"0.5546... | 0.7628218 | 0 |
freeze the previous and current weight. | def freeze_neuron(self,optimizer):
n_neurons = self.num_hiddens
params = []
for i in range(n_neurons):
params.append(
# input2hidden
{'params': self.input2hidden_layers[str(i)].parameters(), 'lr': 0},
)
params.append(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_weights(self):\n\t\tpass",
"def update_weights(self):\n self._weights = self._weights + self.update_weights_value\n self.weights_clipping()",
"def update_weights(self):\n self._weights = self._weights + self.update_weights_value",
"def Freeze(self):\r\n\r\n self._freeze... | [
"0.67689806",
"0.6768005",
"0.67198884",
"0.6635312",
"0.6534424",
"0.65279686",
"0.64761174",
"0.6464944",
"0.64327234",
"0.63930553",
"0.63765204",
"0.6366644",
"0.63134867",
"0.62976086",
"0.62915075",
"0.6254888",
"0.62541234",
"0.62418956",
"0.61982346",
"0.6172241",
"0.... | 0.0 | -1 |
get will return a list of all products | def test_products_get(mocker, data):
mocker.patch("sps.request.fetch", autospec=True)
request.fetch.return_value = data
assert products.get(None, "fake-file-name", False, False)
request.fetch.assert_called_with("https://scc.suse.com/api/package_search/products") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_products(self):\n\t\tpass",
"def get(self):\n return Products().get_all_products()",
"def get_all_products():\n data = order_obj.get_all_products()\n return data",
"def get(self):\n return Product.query.all()",
"def get_products(self):\n con = dbcon()\n cur = c... | [
"0.8258138",
"0.81401634",
"0.79317343",
"0.78062356",
"0.76594794",
"0.7652819",
"0.76209927",
"0.75724685",
"0.75199157",
"0.7347051",
"0.7288251",
"0.72833693",
"0.7281274",
"0.72678334",
"0.71137",
"0.70882106",
"0.708112",
"0.7080987",
"0.7071082",
"0.70555055",
"0.70522... | 0.0 | -1 |
Returns a maximally entangled state. The given spaces must be HilbertAtom spaces (i.e. not tensor products). The spaces must also be of equal dimension (call it `D`). The returned state is | def max_entangled(h1, h2):
for h in (h1, h2):
h.assert_ket_space()
field = h1.base_field
d = h1.dim()
if h2.dim() != d:
raise HilbertError('spaces must be of the same dimension')
return (h1.H * h2).eye().transpose(h1) / field.sqrt(d) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_space_dimension(cls) -> int:\n return 1",
"def state_space(self):\n sys = StateSpace(dqdt=nonlinear_model, signature='t,q,u,p', verbose=False)\n return sys",
"def _max_weight_state(states: Iterable[TensorProductState]) -> Union[None, TensorProductState]:\n mapping = dict() # ... | [
"0.51663864",
"0.5096434",
"0.5064923",
"0.49919802",
"0.49382934",
"0.4925195",
"0.48966813",
"0.47672504",
"0.4743034",
"0.47056496",
"0.46984318",
"0.469135",
"0.46437708",
"0.46369094",
"0.4621391",
"0.46200022",
"0.46174002",
"0.4610263",
"0.4607738",
"0.46027708",
"0.45... | 0.44197795 | 45 |
Add a new transition to the memory, remove the first ones if there is no more room in the memory. | def _add_to_memory(self, state, action, next_state, reward, done):
if len(self.memory) >= self.size_max_memory:
self.memory.pop(0)
self.memory += [Transition(state, action, next_state, reward, done)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_replay_memory(self, transition: Tuple[np.array, int, int,\r\n np.array, bool]) -> None:\r\n self.replay_memory.append(transition)",
"def remember(self, transition):\n # reduce eligibility for old memories\n for memory in self.sho... | [
"0.7557175",
"0.7386448",
"0.70723975",
"0.7009456",
"0.6851717",
"0.68513954",
"0.68026644",
"0.6749611",
"0.6680475",
"0.6632752",
"0.6624485",
"0.6624485",
"0.655598",
"0.6471579",
"0.6406849",
"0.6399585",
"0.6365509",
"0.6293414",
"0.60984117",
"0.606268",
"0.6060668",
... | 0.77939284 | 0 |
Get the number of models contained in the PDB file. Returns | def get_model_count(self):
return len(self._model_start_i) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_number_of_models():\n return 8",
"def count_models(self):\n return len(self.model_list)",
"def _get_model_length(self):\n n_models = len(self._model_start_i)\n length = None\n for model_i in range(len(self._model_start_i)):\n model_start = self._model_start_i[m... | [
"0.6827757",
"0.6786805",
"0.6521126",
"0.6243012",
"0.62162024",
"0.6145209",
"0.6107898",
"0.60880184",
"0.60823494",
"0.60389304",
"0.6033817",
"0.59642136",
"0.59473014",
"0.58895856",
"0.58670217",
"0.5811897",
"0.5809268",
"0.5804541",
"0.5790217",
"0.57797617",
"0.5776... | 0.6999309 | 0 |
Sets the random seeds for all environments, based on a given seed. Each individual environment will still get its own seed, by incrementing the given seed. | def seed(self, seed: Optional[int] = None) -> Sequence[Union[None, int]]:
if seed is None:
# To ensure that subprocesses have different seeds,
# we still populate the seed variable when no argument is passed
seed = int(np.random.randint(0, np.iinfo(np.uint32).max, dtype=np.ui... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_all_random_seeds(self, random_seed):\n np.random.seed(random_seed)\n tf.random.set_seed(random_seed)",
"def seed_all_rng(seed=None):\n if seed is None:\n seed = (\n os.getpid()\n + int(datetime.now().strftime(\"%S%f\"))\n + int.from_bytes(os.urando... | [
"0.8180946",
"0.7856673",
"0.779249",
"0.7751769",
"0.7742478",
"0.7736761",
"0.7729523",
"0.77267474",
"0.765753",
"0.7639829",
"0.76300997",
"0.75300545",
"0.7529922",
"0.7500334",
"0.7500334",
"0.748487",
"0.74829423",
"0.74800587",
"0.74742174",
"0.74742174",
"0.7473593",... | 0.7555021 | 11 |
Tests whether a point is contained in the segment. | def contains(self, other: Point, tol: float = EQ_TOL_ABS) -> npt.NDArray[np.bool_]:
if other.shape[0] == 0:
return np.empty((0,), dtype=bool)
result = self._line.contains(other)
m = self.normalized_array
arr = matmul(m, m, transpose_b=True)
b = arr[..., 0]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contains(self, point):\n if in_range(point[0], self.xrange) and in_range(point[0], self.yrange) and in_range(point[0], self.zrange):\n return True\n return False",
"def contains(self, point):\n return super().contains((point[0] - self.x, point[1] - self.y))",
"def contains_p... | [
"0.81069815",
"0.8073129",
"0.80332524",
"0.79496086",
"0.79160327",
"0.78620756",
"0.78566045",
"0.78566045",
"0.7852195",
"0.78340423",
"0.7808293",
"0.77261764",
"0.7713173",
"0.76948094",
"0.76184356",
"0.7610241",
"0.75742066",
"0.7545242",
"0.7468881",
"0.745716",
"0.74... | 0.0 | -1 |
The midpoint of the segment. | def midpoint(self) -> Point:
l = self._line.meet(infty_hyperplane(self.dim))
return harmonic_set(*self.vertices, l) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMidPoint(self):\n return p.Point((self.start.normalVector + self.end.normalVector)/2.0)",
"def midpoint(self) -> Tuple[int, int]:\n minx, miny, maxx, maxy = self.substrates.bounds\n return ((minx + maxx) // 2, (miny + maxy) // 2)",
"def midpoint(self) -> Tuple[int, int]:\n pa... | [
"0.80252147",
"0.79132915",
"0.7746046",
"0.7493742",
"0.7405012",
"0.73630893",
"0.7121782",
"0.7003171",
"0.6992378",
"0.6927774",
"0.6893486",
"0.68819183",
"0.6857029",
"0.6796819",
"0.6753695",
"0.67513657",
"0.672917",
"0.66955143",
"0.6622848",
"0.6616999",
"0.6616999"... | 0.75145304 | 3 |
The area of the polygon. | def area(self) -> npt.NDArray[np.float_]:
points = self._normalized_projection()
a = sum(det(points[..., [0, i, i + 1], :]) for i in range(1, points.shape[-2] - 1))
return 1 / 2 * np.abs(a) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area(self):\n if len(self.exterior) < 3:\n raise Exception(\"Cannot compute the polygon's area because it contains less than three points.\")\n poly = self.to_shapely_polygon()\n return poly.area",
"def area(self):\n return self._ned_shape.area",
"def area(self):\n ... | [
"0.9036996",
"0.85643196",
"0.82111084",
"0.81985486",
"0.8161597",
"0.8160006",
"0.8139862",
"0.8116614",
"0.810214",
"0.8098854",
"0.8090949",
"0.8044125",
"0.80408674",
"0.8017539",
"0.80040157",
"0.799865",
"0.79553443",
"0.79461986",
"0.7932823",
"0.7930008",
"0.79043615... | 0.7567002 | 62 |
The faces of the polyhedron. | def faces(self) -> Polygon:
return Polygon(self.array, copy=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def faces(self):\n\n if self._faces is None:\n if self._vertices is None:\n return None\n self.triangulate()\n return self._faces",
"def faces(self):\r\n return self._faces",
"def faces(self):\n return map(Face, self._top_exp.faces())",
"def ge... | [
"0.8650459",
"0.82542264",
"0.77669656",
"0.761808",
"0.73729026",
"0.71911454",
"0.69764477",
"0.68992466",
"0.68542445",
"0.6698211",
"0.66543907",
"0.66245604",
"0.659592",
"0.65862507",
"0.6576304",
"0.6522048",
"0.6486375",
"0.6440285",
"0.6348518",
"0.6322836",
"0.62862... | 0.7033727 | 6 |
The surface area of the polyhedron. | def area(self) -> npt.NDArray[np.float_]:
return np.sum(self.faces.area) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def surfaceArea(self):\n surfaceArea = self.sideLength**2 * 6\n return surfaceArea",
"def getSurfaceArea(self) -> float:\n return self.area()",
"def surface_area(self):\n return self._surface_area",
"def surface_area(self) -> float:\n return 4 * np.pi * self.radius**2",
"... | [
"0.8717533",
"0.8561512",
"0.85515696",
"0.842793",
"0.83856726",
"0.7909904",
"0.78701943",
"0.7752461",
"0.7746548",
"0.7686134",
"0.75395554",
"0.7537267",
"0.75097203",
"0.7502898",
"0.7502898",
"0.7502898",
"0.7481229",
"0.7481229",
"0.7481229",
"0.7481229",
"0.746008",
... | 0.77816993 | 7 |
Constructor function for creating BenchmarkObj object from a pandas dataframe. With input arguments, it could set as a timings or speedups or scaledtimings object. Additionally, the dataframe could be copied so that source dataframe stays unaffected. | def bench(df, dtype='t', copy=False, multivar=False, multiindex=False):
map_dtype = {'t': 'timings', 's': 'speedups', 'st': 'scaled_timings'}
if dtype in map_dtype:
dt = map_dtype[dtype]
elif dtype in map_dtype.values():
dt = dtype
else:
raise TypeError('data type ' + '"' + str(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self):\n\n return BenchmarkObj(self.__df_timings.copy(), dtype=self.dtype, multivar=self.multivar, multiindex=self.multiindex)",
"def from_dataframe(cls, dataframe):\n return cls(dataframe)",
"def __init__(self, df):\n self.original_data = df\n self.preprocessed_data = pd.D... | [
"0.69575036",
"0.6625356",
"0.65494853",
"0.6509197",
"0.6227086",
"0.62136436",
"0.6208356",
"0.6207723",
"0.61838317",
"0.61720437",
"0.6132606",
"0.6117069",
"0.6109423",
"0.60490936",
"0.60477877",
"0.60477877",
"0.60437393",
"0.6029517",
"0.6012638",
"0.59550345",
"0.591... | 0.6950665 | 1 |
Checks if dataframe index is a continuous timeseries (no missing rows) | def check_timeseries_continuity(df: pd.DataFrame, freq: str = 'D') -> None:
diffs = pd.date_range(
start=df.index[0], end=df.index[-1], freq=freq).difference(df.index)
if len(diffs) > 0:
raise DiscontinuousTimeseriesError(str(diffs)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_continuous(series: List) -> bool:\n\n if series.dtype in [\n np.int16,\n np.int32,\n np.int64,\n np.float16,\n np.float32,\n np.float64,\n int,\n float,\n ]:\n if (\n len(series.as... | [
"0.70867014",
"0.66608113",
"0.6477521",
"0.60506576",
"0.5895165",
"0.5888661",
"0.57872593",
"0.5764547",
"0.5737515",
"0.57333606",
"0.5723766",
"0.56538343",
"0.5586843",
"0.55521744",
"0.55435634",
"0.55306184",
"0.55193645",
"0.54841316",
"0.54790884",
"0.5461055",
"0.5... | 0.7072183 | 1 |
Removes all the game data from this storage. | def clear_data(self):
self.game_list.clear()
self.game_scores.clear() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear(self):\n for key in self.__data.keys():\n del self.__data[key]",
"def clear(self):\n try:\n self._load(False)\n except KeyError:\n return\n\n for i in xrange(self.size):\n try:\n del self.db[i]\n except Ke... | [
"0.7408821",
"0.7327266",
"0.729114",
"0.72555643",
"0.7198833",
"0.6955354",
"0.69491935",
"0.6886124",
"0.6861816",
"0.68273056",
"0.6820706",
"0.67681086",
"0.6752173",
"0.6747286",
"0.6737661",
"0.66941464",
"0.66506135",
"0.66256064",
"0.66052365",
"0.6572765",
"0.655571... | 0.8002333 | 0 |
Validates that the old_password field is correct. | def clean_old_password(self):
old_password = self.cleaned_data["old_password"]
if not self.user.check_password(old_password):
raise forms.ValidationError(
self.error_messages['password_incorrect'],
code='password_incorrect',
)
return old_pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def old_password_check(form, field):\n old_password = field.data\n password = current_user.password\n r = pwd_context.verify(old_password, current_user.password)\n if not r:\n raise validators.ValidationError('old password is wrong')",
"def clean_old_password(self):\n old_password = sel... | [
"0.8684133",
"0.8576101",
"0.85629606",
"0.78576267",
"0.77336985",
"0.7635723",
"0.74040973",
"0.73703295",
"0.7367065",
"0.7359515",
"0.7343908",
"0.7336761",
"0.7203955",
"0.7108969",
"0.7074801",
"0.70349973",
"0.70289755",
"0.70226836",
"0.70217204",
"0.70020443",
"0.700... | 0.8644744 | 1 |
Compare this instance to other object. | def __eq__(self, other: object) -> bool:
if not isinstance(other, self.__class__):
return NotImplemented
return (
self.name,
self.submit_at,
self.subreddit,
self.title,
self.body_template,
) == (
other.name,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n pass",
"def __eq__(self, other):\n pass",
"def __eq__(self, other):\n raise NotImplementedError",
"def __eq__(self, other):\n raise NotImplementedError",
"def __eq__(self, other):\n raise NotImplementedError",
"def __eq__(self, other):\n ... | [
"0.7689451",
"0.7689451",
"0.7616263",
"0.7616263",
"0.7616263",
"0.76085365",
"0.76085365",
"0.76085365",
"0.76085365",
"0.76085365",
"0.76085365",
"0.76085365",
"0.76085365",
"0.76085365",
"0.76085365",
"0.76085365",
"0.76085365",
"0.76085365",
"0.76085365",
"0.76085365",
"... | 0.0 | -1 |
Return string representation of this instance. | def __str__(self):
return "/r/{subreddit} Post at {datetime}: {title}".format(
subreddit=self.subreddit,
datetime=self.submit_at,
title=self.title,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_string(self):\n return self.__repr__()",
"def to_string(self):\r\n return self.__str__()",
"def serialize(self):\n\n return str(self)",
"def serialize(self):\n\n\t\treturn str(self)",
"def __str__ (self) :\n\n return self.as_string()",
"def to_str(self):\n return... | [
"0.8921974",
"0.88495785",
"0.8841875",
"0.88072455",
"0.8753415",
"0.86494976",
"0.86494976",
"0.86494976",
"0.86494976",
"0.86494976",
"0.86494976",
"0.86494976",
"0.86494976",
"0.86494976",
"0.86494976",
"0.86494976",
"0.86494976",
"0.86494976",
"0.86494976",
"0.86494976",
... | 0.0 | -1 |
Color image loaded by OpenCV is in BGR mode, but Matplotlib displays in RGB mode. cv2.imread(path, style) 1 cv2.IMREAD_COLOR 0 cv2.IMREAD_GRAYSCALE 1 cv2.IMREAD_UNCHANGED | def readImg(filename, h1, h2, w1, w2):
img = cv2.imread(filename, 1)
# plt.figure()
# plt.imshow(img)
img = img[h1:h2, w1:w2]
return img | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matplotlib_image(image):\n if image.ndim == 2:\n rgb = cv2.cvtColor(image, cv2.COLOR_GRAY2RGB)\n else:\n rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n return rgb",
"def plot_cv_img(input_image): \n # change color channels order for matplotlib \n plt.imshow(cv2.cvtColor(inp... | [
"0.73868626",
"0.7204907",
"0.6997231",
"0.6996092",
"0.69411916",
"0.6417158",
"0.64054394",
"0.63842803",
"0.63263005",
"0.63235897",
"0.6294076",
"0.62909806",
"0.62706244",
"0.6242752",
"0.62225825",
"0.62062436",
"0.62005734",
"0.619365",
"0.6164832",
"0.6159785",
"0.614... | 0.0 | -1 |
Repeats value (ragged or dense) along its first dimension. Each value[i, ...] is repeated `multiplier` times. The function is XLA compatible, if the `value` is a dense tensor. | def static_repeat(value: Value, multiplier: int) -> Value:
if value.shape.rank == 0:
raise ValueError(f'`value` must have rank>1, got rank={value.shape.rank}')
value = tf.expand_dims(value, 1)
dims = [1, int(multiplier)] + [1] * (value.shape.rank - 2)
result = tf.tile(value, dims)
if is_ragged_tensor(res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repeat(x, repeats, axis=None):\r\n return RepeatOp(axis=axis)(x, repeats)",
"def repeat_elements(x, rep, axis):\n x_shape = x.get_shape().as_list()\n if x_shape[axis] is None:\n raise ValueError('Axis ' + str(axis) + ' of input tensor '\n 'should have a defined dimensi... | [
"0.6342648",
"0.6185792",
"0.61435354",
"0.60482347",
"0.5970393",
"0.5934632",
"0.58559555",
"0.5800895",
"0.5769826",
"0.57477707",
"0.56690073",
"0.56339943",
"0.56024176",
"0.5583735",
"0.5515491",
"0.5511944",
"0.5510806",
"0.5478019",
"0.5474191",
"0.5474191",
"0.545681... | 0.78125626 | 0 |
Get the contours in the frame | def getContours(frame):
contours, _ = cv2.findContours(frame, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
return contours | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_contours(self):\n depth_image = capture_images((self.w,self.h))\n\n thresh = threshold_depth_image(depth_image, min_depth=config.min_depth, max_depth=config.max_depth, threshold=config.min_depth, kernel=self.kernel)\n\n # extract contours\n im2, contours, hierarchy = cv2.findCon... | [
"0.77595735",
"0.7702236",
"0.7621594",
"0.7472923",
"0.7374639",
"0.7217612",
"0.7215271",
"0.7203923",
"0.7141883",
"0.7091772",
"0.69664115",
"0.6808934",
"0.6758312",
"0.67490184",
"0.67461926",
"0.6744434",
"0.6722383",
"0.67131466",
"0.66536206",
"0.66512144",
"0.661937... | 0.83451533 | 0 |
Threshold the image to make it black and white. values above binarizationThreshold are made white and the rest is black | def thresholdImage(frame, binarizationThreshold=30):
return cv2.threshold(frame, binarizationThreshold, 255, cv2.THRESH_BINARY)[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binarize(self, image, threshold):\n\n bin_img = image.copy()\n [h, w] = bin_img.shape\n opt_threshold = threshold\n print(opt_threshold)\n for row in range(h):\n for col in range(w):\n if bin_img[row, col] > opt_threshold: #greater than threshld whit... | [
"0.8005133",
"0.7427568",
"0.73054326",
"0.725321",
"0.7057772",
"0.7057425",
"0.7044611",
"0.6889189",
"0.6870023",
"0.6857068",
"0.67749256",
"0.6743126",
"0.6734468",
"0.6731722",
"0.67070717",
"0.66193604",
"0.6579413",
"0.657627",
"0.6566455",
"0.6564137",
"0.6546083",
... | 0.7035701 | 7 |
A univariate Gaussian probability distribution object | def __init__(self, mean, var, bounds=None):
self.mean = mean
self.var = var
self.sigma = self.norm_var()
self.invvar = self.invert_var()
self.dist = ND(self.mean, self.sigma) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _gaussian_distribution(self, x: ndarray, mu: float, sigma: float) -> ndarray:\n return 1 / (np.sqrt(2 * np.pi) * sigma) * np.exp(\n -np.power(\n (x - mu) / sigma, 2) / 2)",
"def _multivariate_gaussian(self, x, mu_k, sigma_k):\n return multivariate_normal.pdf(x, mu_k, s... | [
"0.7599584",
"0.73305386",
"0.7276595",
"0.7033141",
"0.70169735",
"0.6975694",
"0.69461286",
"0.69031364",
"0.6871958",
"0.68168503",
"0.68014854",
"0.6796103",
"0.6773079",
"0.6763797",
"0.6718354",
"0.6708506",
"0.66973376",
"0.6678683",
"0.66293347",
"0.66055405",
"0.6601... | 0.0 | -1 |
Function to sample univariate Gaussian probability distribution | def sample(self, n_samps):
# print('gauss trying to sample '+str(n_samps)+' from '+str(self.dist))
# xs = np.array([self.sample_one() for n in range(n_samps)])
xs = np.array(self.dist.sample(n_samps))
# print('gauss sampled '+str(n_samps)+' from '+str(self.dist))
return xs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_GP_prior(x_test, mean_func, cov_func, kernel_params, \n\t\t\t\t\tseed=42, n_samples=5):\n m = mean_func(x_test)\n k = cov_func(x_test, x_test, *kernel_params)\n prng = np.random.RandomState(int(seed))\n sample = prng.multivariate_normal(m, k, n_samples)\n return sample",
"def _gaussian_... | [
"0.74168885",
"0.7328228",
"0.7278028",
"0.7131023",
"0.71071017",
"0.70745105",
"0.7035968",
"0.6930592",
"0.6888211",
"0.6884055",
"0.68398243",
"0.68281704",
"0.6826284",
"0.6824985",
"0.68206567",
"0.6811245",
"0.6773766",
"0.67054766",
"0.6684998",
"0.6680014",
"0.667176... | 0.62617695 | 62 |
Accessor for record type. | def type(self) -> str:
return self._type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_type(self) -> str:\n return self.row_dict['type']",
"def type(self):\n return self._field.type",
"def getType(self,):\n\t\treturn self.type;",
"def get_type(self):\n return self.type",
"def get_type(self):\n return self.type",
"def type(self):\n return self._get... | [
"0.7555445",
"0.7527476",
"0.7372745",
"0.7338866",
"0.7338866",
"0.7319925",
"0.73178977",
"0.7293725",
"0.7287712",
"0.72783047",
"0.7271131",
"0.7271131",
"0.72300184",
"0.72152144",
"0.71788603",
"0.714634",
"0.714634",
"0.714634",
"0.714634",
"0.714634",
"0.714634",
"0... | 0.0 | -1 |
Accessor for record value. | def value(self) -> str:
return self._value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_value(self):\n \n return self._value",
"def _get_value(self):\n return self.__value",
"def GetValue(self):\n return self._value",
"def GetValue(self):\n return self._value",
"def getValue(self):\n return self.value",
"def get_value(self):\n ... | [
"0.75952435",
"0.7573534",
"0.7567276",
"0.7567276",
"0.7564931",
"0.7541365",
"0.75400335",
"0.75400335",
"0.75400335",
"0.7524662",
"0.7524662",
"0.7522739",
"0.7504027",
"0.74974006",
"0.7482358",
"0.7482358",
"0.7478053",
"0.7478053",
"0.7478053",
"0.74737424",
"0.7456231... | 0.0 | -1 |
Accessor for record value. | def value(self, val: str) -> None:
self._value = val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_value(self):\n \n return self._value",
"def _get_value(self):\n return self.__value",
"def GetValue(self):\n return self._value",
"def GetValue(self):\n return self._value",
"def getValue(self):\n return self.value",
"def get_value(self):\n ... | [
"0.75952435",
"0.7573534",
"0.7567276",
"0.7567276",
"0.7564931",
"0.7541365",
"0.75400335",
"0.75400335",
"0.75400335",
"0.7524662",
"0.7524662",
"0.7522739",
"0.7504027",
"0.74974006",
"0.7482358",
"0.7482358",
"0.7478053",
"0.7478053",
"0.7478053",
"0.74737424",
"0.7456231... | 0.0 | -1 |
Equivalence operator. Two instances are equivalent when their attributes are. | def __eq__(self, other: 'StorageRecord') -> bool:
return self.type == other.type and self.id == other.id and self.value == other.value and self.tags == other.tags | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def equivalent(self, other):\n return id(self) == id(other)",
"def __eq__(self, other):\n try:\n return (self.tag == other.tag and self.attributes == other.attributes)\n except:\n return False",
"def __eq__(self, other):\n \n if not tools.data_are_equal(... | [
"0.7490892",
"0.72484446",
"0.715749",
"0.69810164",
"0.69802374",
"0.692489",
"0.6914896",
"0.69102025",
"0.6885109",
"0.68548596",
"0.68283504",
"0.6821871",
"0.68206215",
"0.681415",
"0.6813039",
"0.67832834",
"0.6774857",
"0.6774641",
"0.6774641",
"0.6764047",
"0.6761317"... | 0.0 | -1 |
Returns the current set filename. | def get_filename(file_extension=False) -> str:
if file_extension == False:
return filename[0:filename.find(".json")]
else:
return filename | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_filename(self):\n if self.char_limit is not None:\n return '{}/{}.{}.n{}.maf'.format(self.out_dir, self.chrom,\n self.taxon, self.file_num)\n else:\n return '{}/{}.{}.maf'.format(self.out_dir, self.chrom, self.taxon)",
"d... | [
"0.7564289",
"0.7409148",
"0.726724",
"0.7264385",
"0.7259101",
"0.7172738",
"0.71626824",
"0.71600306",
"0.71441203",
"0.71306145",
"0.70598114",
"0.7016888",
"0.7008849",
"0.7008665",
"0.7007863",
"0.7000229",
"0.69475347",
"0.6945717",
"0.69426167",
"0.69202435",
"0.692024... | 0.0 | -1 |
return the maximum value stored in the tree | def find_maximum_value(self):
if self.root:
self.max_val = self.root.value
else:
return 'No tree found'
def inner(root):
if root.left:
inner(root.left)
if root.right:
inner(root.right)
if self.max_val < root.value:
self.max_val = root.value
inner... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maximum_value(self):\n if not self.root:\n return \"the tree is empty!\"\n\n max_val = self.root.value\n\n def _max_value(node):\n nonlocal max_val\n if not node:\n return\n if node.value > max_val:\n max_val = node.... | [
"0.8843753",
"0.850498",
"0.8443442",
"0.83881867",
"0.83374673",
"0.8300176",
"0.82924294",
"0.8255915",
"0.8146306",
"0.8058392",
"0.805719",
"0.8055715",
"0.8002083",
"0.79592854",
"0.7948281",
"0.7896493",
"0.7803562",
"0.7775334",
"0.7722488",
"0.76877975",
"0.7684765",
... | 0.88988835 | 0 |
Parse all the possible Enumeration Types from the schema, returns a dictionary Type Name > List of values | def readEnumTypes(self):
types = {}
for m in re.finditer("TYPE (\w*) = ENUMERATION OF\s*\(([\,\w\_\s]*)\);\s*END_TYPE;", self.data, re.DOTALL):
typename, types_enum_string = m.groups()
typestring = re.sub('\s', '', types_enum_string)
types[typename] = typestring.spli... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_enums(self):\n for root in self.roots:\n for enums in root.iter('enums'):\n enums_group = enums.attrib.get('group', '')\n group_type = enums.attrib.get('type', '')\n\n for enum in enums.iter('enum'):\n value_str = enum.at... | [
"0.6866107",
"0.6350353",
"0.62388116",
"0.6126131",
"0.6117766",
"0.6062081",
"0.604587",
"0.6021753",
"0.60068",
"0.6004199",
"0.5946266",
"0.5922331",
"0.5841857",
"0.57894695",
"0.5783337",
"0.5777079",
"0.5760632",
"0.5752068",
"0.5664462",
"0.56457156",
"0.5619253",
"... | 0.768173 | 0 |
Return the action uuid from output. | def get_action_id(output):
return output['Action queued with id'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"action_id\")",
"def action_id(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"action_id\")",
"def uuid(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"uuid\")",
"def action_type(self) -> pul... | [
"0.79577607",
"0.6828272",
"0.6466682",
"0.64294404",
"0.6386072",
"0.62857836",
"0.62763304",
"0.6266875",
"0.6266875",
"0.6219564",
"0.62109226",
"0.61813354",
"0.6156722",
"0.61085105",
"0.61085105",
"0.61085105",
"0.60928494",
"0.6086722",
"0.6067283",
"0.60463136",
"0.60... | 0.82459366 | 0 |
Mapping for the InfluenceGraph.multiplexes field. | def multiplexes(self) -> Tuple[Multiplex, ...]:
return tuple(self.influence_graph.multiplexes) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __parse_multiplex(self):\n\n if not ('multiplex' in self.config_dic):\n\n logger.error(\"No required 'multiplex' field found in config file: {}\".format(self.config_path))\n sys.exit(1)\n\n config_multiplex_dic = self.config_dic['multiplex']\n multiplex_count = len(co... | [
"0.54784393",
"0.54529357",
"0.5122609",
"0.4952921",
"0.4836266",
"0.48342285",
"0.48275906",
"0.48179042",
"0.47364172",
"0.47357532",
"0.4703327",
"0.46854454",
"0.4666884",
"0.46579835",
"0.46389708",
"0.46158803",
"0.45854965",
"0.4577214",
"0.45758864",
"0.4557947",
"0.... | 0.7152598 | 0 |
Mapping for the InfluenceGraph.all_states method. | def all_states(self) -> Tuple[State, ...]:
return self.influence_graph.all_states() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_states(self):\n return self._states",
"def all_states(self):\n return self._states",
"def get_list_of_states(self):\n return self.states",
"def get_states(self):\n raise NotImplementedError()",
"def states(self):\n knownstates = set(self.keys())\n for p... | [
"0.7705228",
"0.7605072",
"0.74034256",
"0.72694063",
"0.70043343",
"0.69950384",
"0.6982001",
"0.698167",
"0.6929857",
"0.6920982",
"0.69018567",
"0.6844043",
"0.68203706",
"0.6793806",
"0.6761897",
"0.6751488",
"0.67335546",
"0.6693756",
"0.6626814",
"0.6617217",
"0.6598686... | 0.79061246 | 0 |
Find and return a transition in the model for the given gene and multiplexes. Raise an AttributeError if there is no multiplex in the graph with the given name. | def find_transition(self, gene: Gene, multiplexes: Tuple[Multiplex, ...]) -> Transition:
multiplexes = tuple(multiplex for multiplex in multiplexes if gene in multiplex.genes)
for transition in self.transitions:
if transition.gene == gene and set(transition.multiplexes) == set(multiplexes):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_multiplex_by_name(self, multiplex_name: str) -> Multiplex:\n return self.influence_graph.find_multiplex_by_name(multiplex_name)",
"def find_gene_by_name(self, gene_name: str) -> Gene:\n return self.influence_graph.find_gene_by_name(gene_name)",
"def transition(self, transition):\n ... | [
"0.62077457",
"0.5469396",
"0.5352404",
"0.5090823",
"0.5024471",
"0.49935275",
"0.4845515",
"0.48441333",
"0.48180386",
"0.46912792",
"0.46405032",
"0.4630828",
"0.4627256",
"0.46211383",
"0.45971215",
"0.45871398",
"0.45633692",
"0.45232296",
"0.45201772",
"0.45044738",
"0.... | 0.7724833 | 0 |
Fetches the DataLoader object for each type in types from data_dir. | def fetch_dataloader(types, data_dir, params):
dataloaders = {}
for split in ['train', 'val', 'test']:
if split in types:
path = os.path.join(data_dir, "{}_signs".format(split))
# use the train_transformer if training data, else use eval_transformer without random flip
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_dataloader(types, dataset_dir, params):\n\n dataloaders = {}\n samplers = {}\n\n for split in ['train', 'val', 'test']:\n if split in types:\n path = os.path.join(dataset_dir, \"{}\".format(split))\n\n # Use the train_transformer if training data, else use eval_trans... | [
"0.7628377",
"0.6985222",
"0.6829625",
"0.6811214",
"0.6752641",
"0.6674151",
"0.6666698",
"0.6626962",
"0.6609424",
"0.65914035",
"0.650442",
"0.645624",
"0.64486384",
"0.6421723",
"0.6416939",
"0.64039534",
"0.636915",
"0.6348583",
"0.6340944",
"0.63406587",
"0.63213974",
... | 0.7392654 | 1 |
Get a key value pair in config.json | def get_config(key):
with open('config.json', 'r') as f:
configs = json.load(f)
return configs[str(key)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(key: str) -> Any:\n _check_key(key)\n config = _read_config()\n return config.get(key, DEFAULT_CONFIG.get(key))",
"def get(self, key):\n return self.config.get(key)",
"def get_config(self, key):\n return self.data[key]",
"def getconfig(self, key):\n return self.config[ke... | [
"0.76327014",
"0.75347805",
"0.737547",
"0.72544414",
"0.72504604",
"0.717579",
"0.70418227",
"0.70366937",
"0.7036429",
"0.6978676",
"0.6905255",
"0.6874002",
"0.6835701",
"0.6726159",
"0.67222387",
"0.670336",
"0.66736174",
"0.6653473",
"0.66451764",
"0.66347194",
"0.658072... | 0.8137568 | 0 |
returns True, if cloud session is configured | def is_configured(self):
return self._session is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_configured(self):\n return True",
"def is_configured(self):\n pass",
"def isup(self):\n if self.cloudserver:\n # print self.cloudserver.status\n if self.cloudserver.status in (\"ACTIVE\",):\n return True\n \n return False",
"def c... | [
"0.7057582",
"0.6851403",
"0.64025086",
"0.634969",
"0.6338264",
"0.62948275",
"0.6290418",
"0.62790346",
"0.62163687",
"0.6201801",
"0.6199716",
"0.61925626",
"0.6179936",
"0.61759615",
"0.6159926",
"0.6142829",
"0.61372834",
"0.6120192",
"0.6116553",
"0.6108382",
"0.6106423... | 0.74981076 | 0 |
Assert that nothing exists at path in Dropbox. | def remote_assert_empty(path):
path = normpath(path)
try:
remote = get_remote(path)
except ValueError: # Nothing exists at path, nothing to worry about.
return
raise ValueError("Something exists at %s" % remote.uri) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_empty(self):\n self.assertFalse(os.path.exists('/'))",
"def assertFileAbsent(self, root_path, path):\n full_path = os.path.join(root_path, path)\n self.assertFalse(os.path.exists(full_path))",
"def local_assert_empty(path):\n try:\n local = get_local(path)\n except Va... | [
"0.76671106",
"0.7040009",
"0.69586396",
"0.6947915",
"0.6940748",
"0.6810896",
"0.669216",
"0.6585473",
"0.6560132",
"0.65220225",
"0.6471243",
"0.6452325",
"0.643884",
"0.64366055",
"0.64345837",
"0.6342282",
"0.6322533",
"0.6321554",
"0.6318823",
"0.6269195",
"0.62457484",... | 0.7083627 | 1 |
Change edge line width of vectors on the layer model. | def change_width(self, value):
self.layer.edge_width = value
self.widthSpinBox.clearFocus()
self.setFocus() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_edge_line_width_bypass(edge_names, new_widths, network=None, base_url=DEFAULT_BASE_URL):\n\n if not isinstance(new_widths, list): new_widths = [new_widths] # TODO: It looks like this should be happening everywhere?\n for width in new_widths:\n if not isinstance(width, float) and not isinstanc... | [
"0.61762315",
"0.61618584",
"0.6141269",
"0.5982534",
"0.5859814",
"0.57972383",
"0.5612086",
"0.5568471",
"0.5556504",
"0.5491899",
"0.5453225",
"0.5451031",
"0.54445165",
"0.542872",
"0.54054356",
"0.538411",
"0.53453",
"0.53324187",
"0.53149265",
"0.5271047",
"0.5262724",
... | 0.6175613 | 1 |
Returns the first_name plus the last_name, with a space in between. | def get_full_name(self):
full_name = '%s %s' % (self.first_name, self.last_name)
return full_name.strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_name(first_name, last_name):\n return first_name + \" \" + last_name",
"def full_name(first_name, last_name):\n\t\n\treturn first_name + \" \" + last_name",
"def get_formated_name(first_name,last_name):\n\tfull_name = first_name + '' + last_name\n\treturn full_name.title()",
"def get_full_name(se... | [
"0.8314284",
"0.8202",
"0.80509627",
"0.8041887",
"0.8018895",
"0.8001242",
"0.7955795",
"0.7943886",
"0.7943886",
"0.7943886",
"0.79381335",
"0.7929936",
"0.79233223",
"0.7904302",
"0.7893432",
"0.7891567",
"0.78800964",
"0.7862739",
"0.78541714",
"0.7824917",
"0.78150547",
... | 0.7748217 | 42 |
Returns the short name for the user. | def get_short_name(self):
return self.first_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_short_name(self):\n return self.username",
"def get_short_name(self):\n return self.username",
"def get_short_name(self):\n return self.username",
"def get_short_name(self):\n # The user is identified by their email address\n return self.first_name",
"def get_shor... | [
"0.9031318",
"0.9031318",
"0.9031318",
"0.88305414",
"0.88070536",
"0.8665631",
"0.84239036",
"0.83352995",
"0.8309543",
"0.8281943",
"0.8281943",
"0.8193153",
"0.817373",
"0.81518835",
"0.81303227",
"0.80982405",
"0.8095332",
"0.807911",
"0.79685146",
"0.7966426",
"0.7963882... | 0.81819606 | 21 |
Find ngrams of Text object. Returns dictionary of ngrams. | def find_ngrams(self, n):
output = {}
for i in range(len(self.text)-n+1):
s = ' '.join(self.text[i:i+n])
# if s is not already in dictionary, set value to 0
output.setdefault(s, 0)
output[s] += 1
return output | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ngrams(text, n):\n return chain(*[ngrams_(text, i) for i in range(n + 1)])",
"def ngrams(self):\n return self.root.ngrams()",
"def calculate_ngram_frequencies(text, n):\n\n import re\n\n # Create a new dictionary\n ngram_dict = {}\n\n # Find all sentences\n sentences_list = re.find... | [
"0.7041408",
"0.6928858",
"0.6870165",
"0.68599534",
"0.6819836",
"0.66884774",
"0.66646343",
"0.665967",
"0.6647089",
"0.6637864",
"0.6533222",
"0.6436485",
"0.6407003",
"0.6387585",
"0.6365663",
"0.6361791",
"0.6349755",
"0.6349129",
"0.63445854",
"0.6318956",
"0.6292145",
... | 0.7178314 | 0 |
Initializes the simulator object. Creates a new thread and sets up the logger. | def __init__(self, id, globalData):
self.globalData = globalData
self.bSimNameSet = False
self.iSimulatorID = id
self.setupLogger()
self.db = DB(id)
self.evSimulate = threading.Event()
self.evSimulate.clear()
self.evSyncDB = threading.Event()
self.evAPI = threading.Event()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(self, simulator):\r\n self.__eventHandlers = {}\r\n self.__simulator = simulator\r\n self.__threads = {}",
"def __init__(self):\n Thread.__init__(self)\n self.start() # start the thread",
"def __init__(self ):\r\n # ------------------- basic setup ---... | [
"0.6892698",
"0.67417",
"0.6694423",
"0.66811895",
"0.65703267",
"0.6550514",
"0.6550514",
"0.64727473",
"0.6440513",
"0.6396006",
"0.6381627",
"0.62971526",
"0.6291298",
"0.62874234",
"0.625071",
"0.62303615",
"0.6164838",
"0.61301553",
"0.6125242",
"0.6125242",
"0.6112503",... | 0.0 | -1 |
Create an expression tree. In a single parameter form, token should be a leaf value (e.g., '42'), and the expression tree will have that value at an isolated node. In a threeparameter version, token should be an operator, and left and right should be existing ExpressionTree instances that become the operands for the bi... | def __init__(self, token, left=None, right=None):
super().__init__() # LinkedBinaryTree initialization
self._add_root(token) # use inherited, nonpublic method
if left is not None: # presumably three-parameter form
self._attach(self.root(), left, right) # use inherited, nonpublic ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_expression_tree(tokens):\n S = [] # we use Python list as stack\n for t in tokens:\n if t in '+-*/': # t is an operator symbol\n S.append(t) # push the operator symbol\n elif t not in '()': # consider t to be a literal\n S.append(ExpressionTree(t)) # push tr... | [
"0.7326136",
"0.730365",
"0.6930967",
"0.6450516",
"0.6013443",
"0.5913101",
"0.5912604",
"0.5888436",
"0.5865437",
"0.57848185",
"0.56637627",
"0.5544847",
"0.55394363",
"0.55347955",
"0.54924995",
"0.54537255",
"0.53816175",
"0.53763175",
"0.5335392",
"0.5334524",
"0.532081... | 0.56648976 | 10 |
Append piecewise representation of p's subtree to resulting list. | def _parenthesize_recur(self, p, result):
if self.is_leaf(p):
result.append(str(p.element())) # leaf value as a string
else:
result.append('(') # opening parenthesis
self._parenthesize_recur(self.left(p), result) # left subtree
result.append(p.element()... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_part(p):\n if p:\n if p[0] is None:\n # p describes an interior node\n plist.extend(p[3])\n elif p[2] > p[1]:\n # Only include subtrees that actually contain ter... | [
"0.632318",
"0.59144956",
"0.5841838",
"0.5809278",
"0.56775904",
"0.5660765",
"0.5636445",
"0.5472851",
"0.54489493",
"0.5406144",
"0.53900886",
"0.5367325",
"0.5367325",
"0.5367325",
"0.53340524",
"0.53282005",
"0.5281386",
"0.5279381",
"0.527667",
"0.5249167",
"0.5167452",... | 0.56607294 | 6 |
Show list of articles | Search for articles | def article_list(page_number=1):
main_page = mylookup.get_template("articles.html")
q = request.GET.get('q', '').lower()
try:
page_number = int(page_number)
except TypeError:
page_number = 1
try:
articles = load_articles()
except IOError:
dump_articles()
articles = load_articles()
articles = fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_articles():\n\n return template(\"index\", articles=get_articles())",
"def search_news(request):\n try:\n query_string = ''\n if request.GET['search_text'].strip() != '':\n query_string = '&title='+request.GET['search_text']\n response = requests.get(APIURL + '/art... | [
"0.78467387",
"0.7612171",
"0.7611769",
"0.7433846",
"0.730451",
"0.72885865",
"0.7220352",
"0.71636355",
"0.7163175",
"0.70827407",
"0.69401306",
"0.68855035",
"0.68732625",
"0.6865535",
"0.6738261",
"0.66891086",
"0.6676643",
"0.664461",
"0.66017216",
"0.658953",
"0.6586830... | 0.6771957 | 14 |
return a position representing p's left child return None if p does not have a left child | def left(self, p):
raise NotImplemented("must be implemented in the subclass") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def left_child(self, position):\n child = 2 * position + 1\n if child > len(self.table) - 1:\n return None\n return child",
"def left(self, p):\n node = self._validate(p)\n return self._make_position(node._left)",
"def leftChild(self, pos):\n return 2 * pos",
... | [
"0.8341559",
"0.80875",
"0.8087392",
"0.8087392",
"0.80351204",
"0.80300295",
"0.7999553",
"0.7994815",
"0.7994815",
"0.78049165",
"0.76175463",
"0.75111634",
"0.7484711",
"0.7479758",
"0.74521714",
"0.744069",
"0.74371326",
"0.74149203",
"0.73856115",
"0.738106",
"0.73374605... | 0.6667352 | 66 |
return a positon representing p's right child return None if p does not have a right child | def right(self, p):
raise NotImplemented("must be implemneted in the subclass") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rightChild(self, pos):\n return (2 * pos) + 1",
"def rightChild(self, pos):\n return (2 * pos) + 1",
"def right_child(self, position):\n child = 2 * position + 2\n if child > len(self.table) - 1:\n return None\n return child",
"def right_child(self, p... | [
"0.77464795",
"0.77464795",
"0.77460545",
"0.7728761",
"0.75080013",
"0.74026775",
"0.7320808",
"0.729481",
"0.72859514",
"0.7263279",
"0.7252911",
"0.70673305",
"0.70438325",
"0.69981533",
"0.6994877",
"0.69766784",
"0.6928423",
"0.6928423",
"0.691114",
"0.6895497",
"0.68789... | 0.6118157 | 67 |
override the the parent class return True if other is a position representing the same location | def __eq__(self, other):
return type(self) == type(other) and self.node is other.node | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sameLocation(self, other):\n if not isinstance(other,Point):\n return False\n return self.longitude == other.getLongitude() and self.latitude == other.getLatitude()",
"def is_same_as(self, other) -> bool:\n return self.x == other.x and self.y == other.y",
"def __eq__(self, o... | [
"0.7901687",
"0.764056",
"0.7392204",
"0.7392204",
"0.7361945",
"0.735918",
"0.7210236",
"0.7175122",
"0.71049",
"0.7103966",
"0.70583266",
"0.69996214",
"0.6995971",
"0.699182",
"0.69867027",
"0.6984702",
"0.69822925",
"0.6978406",
"0.6974881",
"0.6956476",
"0.69327956",
"... | 0.0 | -1 |
return the total number of the tree or None if tree if empty | def __len__(self):
return self._size | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size(self) -> int:\n if self.root is None: # If tree is empty\n return 0\n\n return self.size_helper(self.root)",
"def size(self) -> int:\n #binary search tree == empty\n if self.root is None:\n return 0\n\n #recursive helper count nodes\n ... | [
"0.77254856",
"0.7705645",
"0.7620382",
"0.76121736",
"0.73914915",
"0.73507965",
"0.73348933",
"0.7305137",
"0.72720695",
"0.7238484",
"0.72142154",
"0.7213181",
"0.71996206",
"0.7195913",
"0.71954966",
"0.71932757",
"0.7172126",
"0.71429473",
"0.7102446",
"0.71016663",
"0.7... | 0.0 | -1 |
return the position of p's left child or None if no left child | def left(self, p):
node = self._validate_position(p)
return self._make_position(node.left) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def left_child(self, position):\n child = 2 * position + 1\n if child > len(self.table) - 1:\n return None\n return child",
"def leftChild(self, pos):\n return 2 * pos",
"def leftChild(self, pos):\n return 2 * pos",
"def left(self, p):\n node = self._v... | [
"0.8216765",
"0.7918147",
"0.7918147",
"0.7878433",
"0.78606814",
"0.78513503",
"0.7808519",
"0.7808519",
"0.76223534",
"0.7611443",
"0.74660945",
"0.74046",
"0.7399579",
"0.73856926",
"0.7379371",
"0.72880566",
"0.7255275",
"0.72088826",
"0.7181712",
"0.7174734",
"0.71143824... | 0.7852657 | 5 |
return the position of the p's right child or None if no right child | def right(self, p):
node = self._validate_position(p)
return self._make_position(node.right) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def right_child(self, position):\n child = 2 * position + 2\n if child > len(self.table) - 1:\n return None\n return child",
"def rightChild(self, pos):\n return (2 * pos) + 1",
"def rightChild(self, pos):\n return (2 * pos) + 1",
"def right_child(self, p... | [
"0.8011586",
"0.7883068",
"0.7883068",
"0.77900934",
"0.74321336",
"0.741032",
"0.737072",
"0.73087424",
"0.7244714",
"0.7239471",
"0.71799713",
"0.708782",
"0.7058676",
"0.7040878",
"0.70253855",
"0.701672",
"0.70119274",
"0.70119274",
"0.6923766",
"0.6850868",
"0.68247455",... | 0.74010426 | 6 |
create a new left child for position p,storing element e return the position of new node Raise ValueError if position p is invalid or p already has a left child | def _add_left(self, p, e):
node = self._validate_position(p)
if node.left is not None:
raise ValueError("left child exists")
self._size += 1
node.left = self._Node(e, parent=node)
return self._make_position(node.left) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_left(self, p, e):\n node = self._validate(p)\n if node._left is not None:\n raise ValueError('Left child exists')\n self._size += 1\n node._left = self._Node(e, node) # node is its parent\n return self._make_position(node._left)",
"def _add_left(self, p, ... | [
"0.86248547",
"0.8621271",
"0.8594225",
"0.8255244",
"0.8242313",
"0.8112618",
"0.77869797",
"0.7691417",
"0.76596785",
"0.7645494",
"0.7645494",
"0.76229525",
"0.7475303",
"0.7475303",
"0.7421907",
"0.7175518",
"0.70907426",
"0.7021391",
"0.6954034",
"0.690876",
"0.68299615"... | 0.8655107 | 0 |
create a new right child for position p, storing element e return the position of new node Raise ValueError if position p is invalid or p already has a right child | def _add_right(self, p, e):
node = self._validate_position(p)
if node.right is not None:
raise ValueError("right child exists")
self._size += 1
node.right = self._Node(e, parent=node)
return self._make_position(node.right) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_right(self, p, e):\n node = self._validate(p)\n if node._right is not None:\n raise ValueError('Right child exists')\n self._size += 1\n node._right = self._Node(e, node) # node is its parent\n return self._make_position(node._right)",
"def _add_right(self, p, e):\n ... | [
"0.82712144",
"0.82210207",
"0.8038477",
"0.7647381",
"0.7639639",
"0.7388738",
"0.71994555",
"0.71863884",
"0.7140942",
"0.7140942",
"0.71368885",
"0.7134877",
"0.7111943",
"0.68617433",
"0.67871743",
"0.6743061",
"0.6701005",
"0.66493064",
"0.66259116",
"0.6614183",
"0.6587... | 0.81552035 | 2 |
attach trees t1 and t2 as left and right subtree of external p raise ValueError if the position is not left | def _attach(self, p, t1, t2):
node = self._validate_position(p)
if not self.is_leaf(p):
raise ValueError("position must be external p")
if not type(self) is type(t1) is type(t2):
raise ValueError("three types must be the same")
self._size += len(t1) + len(t2)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _attach(self, p, t1, t2):\n node = self._validate(p)\n if not self.is_leaf(p):\n raise ValueError('position must be leaf')\n if not type(self) is type(t1) is type(t2): # all 3 trees must be same type\n raise TypeError('Tree types must match')\n sel... | [
"0.7542174",
"0.74333155",
"0.7401941",
"0.7096536",
"0.7035624",
"0.6609745",
"0.6408334",
"0.63810813",
"0.6249827",
"0.6206014",
"0.6188339",
"0.6120194",
"0.61116314",
"0.6075521",
"0.6047413",
"0.6039132",
"0.6018451",
"0.5954787",
"0.5917243",
"0.59092426",
"0.5900075",... | 0.7449804 | 1 |
Clean the filename and determine the foldername to upload avatars to. Must be defined before the Profile class. | def get_avatar_path(instance, filename):
parts = str(filename).split(".")
return 'avatars/' + instance.username + '/' + slugify(parts[0]) + '.' + parts[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_name(instance, filename):\n filename = make_unique_filename(filename)\n return os.path.join('uploads/profile_pics', filename)",
"def profile_upload_path(instance, filename):\n return f'profile/{instance.user.id}/{filename}'",
"def avatar_directory_path(instance, filename):\n return '{0... | [
"0.66608137",
"0.6548855",
"0.65130216",
"0.64873177",
"0.6433397",
"0.62459713",
"0.6238062",
"0.62254447",
"0.6217548",
"0.615862",
"0.61409825",
"0.61234075",
"0.60284084",
"0.59834677",
"0.5970905",
"0.59553516",
"0.59524244",
"0.5918876",
"0.5912861",
"0.58966196",
"0.58... | 0.68041146 | 0 |
Return a gitlab homepage URL `url` from a the `purl` string | def build_gitlab_homepage_url(purl):
purl_data = PackageURL.from_string(purl)
namespace = purl_data.namespace
name = purl_data.name
version = purl_data.version
subpath = purl_data.subpath
if not (name and namespace):
return
url = "https://gitlab.com/{namespace}/{name}".format(name... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_github_homepage_url(purl):\n purl_data = PackageURL.from_string(purl)\n\n namespace = purl_data.namespace\n name = purl_data.name\n version = purl_data.version\n subpath = purl_data.subpath\n\n if not (name and namespace):\n return\n\n url = \"https://github.com/{namespace}/{n... | [
"0.7479557",
"0.7045626",
"0.6522426",
"0.6509705",
"0.61513877",
"0.60780674",
"0.60681015",
"0.60375303",
"0.602241",
"0.5941244",
"0.5907163",
"0.5897822",
"0.58964944",
"0.58791876",
"0.5871155",
"0.58554846",
"0.58471715",
"0.5825706",
"0.5816689",
"0.5780156",
"0.577465... | 0.8120818 | 0 |
Unroll the parameters from a vector and save them to layers. | def unroll_params(theta, layers, param_type):
i = 0
for layer in layers:
params = getattr(layer, param_type)
if params is not None:
for k in params:
vector = params[k]
# Extract and reshape the parameter to the original form
j = i + np.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_from_vector(self, vector: np.ndarray) -> None:\n nn.utils.vector_to_parameters(torch.FloatTensor(\n vector).to(self.device), self.parameters())",
"def reconstruct(self, vector):\n return self.reconstruct_vectors(vector[None, :]).flatten()",
"def setParamsFromVector(self, param... | [
"0.60446304",
"0.6043414",
"0.60391486",
"0.59241045",
"0.56253546",
"0.5597763",
"0.5588762",
"0.5568038",
"0.55241174",
"0.55086",
"0.5506805",
"0.5421854",
"0.5421635",
"0.53757167",
"0.53531384",
"0.53361344",
"0.5311251",
"0.5220607",
"0.52197045",
"0.52033097",
"0.51981... | 0.59164655 | 4 |
Calculate the distance between two vectors based on Frobenius norm. | def calculate_diff(grad_theta, grad_approx):
# np.linalg.norm apply for matric equal to Frobenius norm
numerator = np.linalg.norm(grad_theta - grad_approx)
denominator = np.linalg.norm(grad_theta) + np.linalg.norm(grad_approx)
diff = numerator / denominator
return diff | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _vector_dist(self, vec1, vec2):\r\n return sqrt(sum([(float(v1) - float(v2)) ** 2 for v1, v2 in\r\n zip(vec1, vec2)]))",
"def norm_dist(face_vectors, f_vector):\n if len(face_vectors) == 0:\n return np.empty((0))\n return np.linalg.norm(face_vectors - f_vector, axi... | [
"0.7799064",
"0.7493226",
"0.737563",
"0.71962667",
"0.7191445",
"0.7146088",
"0.7145285",
"0.7132403",
"0.7110355",
"0.71088487",
"0.7078894",
"0.70682985",
"0.7060207",
"0.7033553",
"0.7033553",
"0.7033129",
"0.6985366",
"0.69726145",
"0.6967274",
"0.6931653",
"0.6921916",
... | 0.0 | -1 |
create new level in nested dictionary, and initialise to value | def create_level(dict, path_list, value):
if len(path_list) == 0:
return
for k in path_list[:-1]:
dict = dict[k]
dict[path_list[-1]] = value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def depth_wrap(self, value):\n return DictToObj(**value) if isinstance(value, dict) else value",
"def _create_path(root, dict_type, path):\n for sub_path in path:\n if not isinstance(root.get(sub_path, None), dict):\n root[sub_path] = dict_type()\n\n root = root... | [
"0.6385926",
"0.6223456",
"0.6182254",
"0.61733925",
"0.6078054",
"0.6059316",
"0.6054513",
"0.59961647",
"0.59386396",
"0.5905996",
"0.58941096",
"0.58723",
"0.58627146",
"0.5844096",
"0.5779615",
"0.57779753",
"0.5725231",
"0.5710088",
"0.5709766",
"0.56915784",
"0.5688084"... | 0.74209857 | 0 |
Create Lex V2 Bot | def create_bot(self, resource_properties: Dict[str, Any]) -> Dict[str, Any]:
bot_id = self._create_bot(resource_properties=resource_properties)
locale_exeption = {"_exception": ""}
bot_locale_ids = []
try:
bot_locales = resource_properties[CUSTOM_ATTRIBUTES["botLocales"]]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def creator(message: types.Message):\n link = 'https://https://github.com/germanjke/StyleTransformerGANs'\n link2 = '@logisticregression'\n await message.answer(text=f'Bot created for final Deep Learning School by MIPT project .\\\n \\nLink to github repo: {link}, contac... | [
"0.58040464",
"0.57859707",
"0.5785597",
"0.5761952",
"0.5706605",
"0.56692266",
"0.5633321",
"0.5591099",
"0.5535877",
"0.5513246",
"0.54702353",
"0.54371065",
"0.53739303",
"0.53614134",
"0.53614134",
"0.53359175",
"0.53359175",
"0.5317323",
"0.52943146",
"0.52917916",
"0.5... | 0.0 | -1 |
If you don't set min/max, it should use the data's min/max. | def testDefaultDataScaling(self):
orig_scale = util.ScaleData
util.ScaleData = self.FakeScale
try:
self.AddToChart(self.chart, [2, 3, 5, 7, 11])
self.chart.auto_scale.buffer = 0
# This causes scaling to happen & calls FakeScale.
self.chart.display.Url(0, 0)
self.assertEqual(2, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, data):\n\t\t#######################################################################\n\t\t# ** START OF YOUR CODE **\n\t\t#######################################################################\n\t\tself.data_min = data.min(axis=0)\n\t\tself.data_max = data.max(axis=0)\n\t\t... | [
"0.74985325",
"0.7283065",
"0.7217832",
"0.7168993",
"0.7092426",
"0.693854",
"0.6900306",
"0.6866421",
"0.6866421",
"0.6866421",
"0.6866421",
"0.68325627",
"0.67750615",
"0.6763062",
"0.6744204",
"0.6744204",
"0.6711111",
"0.6693686",
"0.6648631",
"0.6612136",
"0.661016",
... | 0.64049447 | 33 |
max values should be filled in if they are not set explicitly. | def testImplicitMaxValue(self):
orig_scale = util.ScaleData
util.ScaleData = self.FakeScale
try:
self.AddToChart(self.chart, [0, 10])
self.chart.auto_scale.buffer = 0
self.chart.display.Url(0, 0) # This causes a call to FakeScale.
self.assertEqual(10, self.max)
self.chart.left... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setMaxValue(self, max_value):\r\n\t\tself.MaxValue = max_value",
"def setMaxValue(self, max_value):\r\n\t\tself.MaxValue = max_value",
"def set_max(self, max):\n self.set_val((self.val[0], max))",
"def set_maxVal(self, val):\n self.maxVal = val",
"def setMinMax(self):\n currentIndu... | [
"0.73064744",
"0.73064744",
"0.72859097",
"0.7137905",
"0.6957052",
"0.6929281",
"0.6803532",
"0.66621625",
"0.66191185",
"0.6597838",
"0.6595439",
"0.6595439",
"0.6564341",
"0.6564341",
"0.6564341",
"0.6490686",
"0.647374",
"0.647374",
"0.6439374",
"0.6413019",
"0.63940877",... | 0.6596179 | 10 |
Get the current goal node. | def getGoalNode(self):
return self.goalNode | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCurrentNode(self):\r\n\t\treturn self.currentNode",
"def get_node(self):\n return self.__node",
"def get_node(self):\r\n return self._node",
"def get_node(self):\n assert self._node_id is not None\n return self._get_info(self.EXPECTED)[self._node_id]",
"def node(self):\n ... | [
"0.7465489",
"0.7393672",
"0.73539066",
"0.7302251",
"0.7160864",
"0.7160864",
"0.7028858",
"0.67921257",
"0.6733798",
"0.668906",
"0.6652091",
"0.6625872",
"0.6621293",
"0.6596712",
"0.658448",
"0.65528655",
"0.65528655",
"0.65510124",
"0.65357435",
"0.6520517",
"0.650422",
... | 0.89470583 | 0 |
From a list of integers, remove all elements that occur more than once. Keep order of elements left the same as in the input. >>> remove_duplicates([1, 2, 3, 2, 4]) [1, 3, 4] | def remove_duplicates(numbers: List[int]) -> List[int]:
#[SOLUTION]
import collections
c = collections.Counter(numbers)
return [n for n in numbers if c[n] <= 1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_remove_duplicates(l):\n seen = set()\n seen_add = seen.add\n return [x for x in l if not (x in seen or seen_add(x))]",
"def remove_identical(list):\n seen = set()\n seen_add = seen.add\n return [x for x in list if not (x in seen or seen_add(x))]",
"def remove_duplicates(lst):\n ls... | [
"0.78115636",
"0.7645455",
"0.7628417",
"0.75708026",
"0.7553269",
"0.7548041",
"0.74051136",
"0.73984283",
"0.7381932",
"0.7350486",
"0.7268583",
"0.72610027",
"0.7257821",
"0.72354984",
"0.7147842",
"0.71112585",
"0.7105889",
"0.7100668",
"0.69736224",
"0.6966769",
"0.69292... | 0.7801894 | 1 |
Run a test with a fresh, empty MEDIA_ROOT temporary directory. | def fresh_media_root(**kwargs):
with TemporaryDirectory(**kwargs) as media_root:
with override_settings(MEDIA_ROOT=media_root):
yield | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_media_root():\n tmp_path = Path(tempfile.mkdtemp(prefix=\"pytest_\"))\n try:\n with override_settings(MEDIA_ROOT=tmp_path):\n yield\n finally:\n rmtree(tmp_path)",
"def setUp(self):\n self.tmp = TemporaryDirectory()",
"def tearDown(self):\n if os.path.exi... | [
"0.73528874",
"0.669238",
"0.65554833",
"0.65554833",
"0.64806205",
"0.64407784",
"0.6437306",
"0.64122176",
"0.63896406",
"0.63702404",
"0.63702404",
"0.6261549",
"0.61641157",
"0.6159798",
"0.6143134",
"0.61124456",
"0.6111665",
"0.6109124",
"0.6109124",
"0.6109124",
"0.610... | 0.6996069 | 1 |
An anonymous should not be able to fetch a list of Markdown document. | def test_api_document_fetch_list_anonymous(self):
response = self.client.get("/api/markdown-documents/")
self.assertEqual(response.status_code, 401) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_document_fetch_list_student(self):\n markdown_document = MarkdownDocumentFactory()\n\n jwt_token = StudentLtiTokenFactory(\n playlist=markdown_document.playlist,\n permissions__can_update=True,\n )\n\n response = self.client.get(\n \"/api/ma... | [
"0.68483764",
"0.6841556",
"0.6636324",
"0.5992888",
"0.59872437",
"0.5807607",
"0.5747923",
"0.57392776",
"0.5736608",
"0.55744445",
"0.5544332",
"0.5508371",
"0.5470004",
"0.5455008",
"0.5431114",
"0.5427114",
"0.54253983",
"0.5391145",
"0.5382827",
"0.53778183",
"0.5369074... | 0.8051427 | 0 |
A user with UserAccessToken should be able to filter markdown documents list by playlist. | def test_api_document_fetch_list_user_access_token_filter_playlist(self):
organization_access_admin = OrganizationAccessFactory(role=ADMINISTRATOR)
organization_access = OrganizationAccessFactory(
user=organization_access_admin.user
)
playlist_1_a = PlaylistFactory(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_video_read_list_by_playlist_user_with_no_access(self):\n user = factories.UserFactory()\n # A playlist, where the user has no access, with a video\n playlist = factories.PlaylistFactory()\n factories.VideoFactory(playlist=playlist)\n\n jwt_token = AccessToken()\n ... | [
"0.64966273",
"0.63631296",
"0.63040143",
"0.62921864",
"0.625486",
"0.6114661",
"0.6112757",
"0.6084757",
"0.6072946",
"0.5990464",
"0.59341544",
"0.5930024",
"0.59252214",
"0.58325887",
"0.57842314",
"0.5755112",
"0.5746816",
"0.57359654",
"0.5721184",
"0.5703598",
"0.57035... | 0.66299987 | 0 |
Check if the current resources are sufficient for the selected drink. Input the selected drink type. | def sufficient_resources(drink_type):
is_sufficient = True
for resource in MENU[drink_type]["ingredients"]:
if not(MENU[drink_type]["ingredients"][resource] <= resources[resource]):
print(f"Sorry there is not enough {resource}.")
is_sufficient = False
return is_suffic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_resource_sufficient(self, drink):\n for ingredient in self.resources:\n if drink.ingredients[ingredient] > self.resources[ingredient]:\n print(f\"Sorry there is not enough {ingredient}\")\n return False\n return True",
"def is_resource_sufficient(self... | [
"0.7616349",
"0.75889695",
"0.75452286",
"0.68272656",
"0.6670977",
"0.64023954",
"0.5944456",
"0.5916375",
"0.57489955",
"0.56601477",
"0.559886",
"0.5573579",
"0.5521502",
"0.551886",
"0.5477751",
"0.5469344",
"0.5435169",
"0.54207265",
"0.5383182",
"0.5372991",
"0.53543794... | 0.79713386 | 0 |
>>> sum(1, 2, 3) 4 | def sum(*args):
result = 0
for i in args:
result += i
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum(a, b):\n return a + b",
"def sum(a, b):\n return a + b",
"def sum(a,b,c):\n return (a+b+c)",
"def sum(*args):\n return reduce(lambda x, y: x + y, args)",
"def sum(a,b):\r\n c=a+b\r\n return c",
"def sum(num_1, num_2):\n return num_1 + num_2",
"def sum(num1, num2):\n retu... | [
"0.8154558",
"0.8154558",
"0.8000042",
"0.79865813",
"0.7859151",
"0.7668783",
"0.7647527",
"0.76361585",
"0.75910467",
"0.7540797",
"0.74959284",
"0.74835855",
"0.7478108",
"0.7448058",
"0.73921406",
"0.7355992",
"0.733689",
"0.7312243",
"0.7302365",
"0.7295092",
"0.7295092"... | 0.7974723 | 4 |
Get row of lowest empty cell in column | def get_row_for_col(self, col: int) -> int:
for r in (0, 1, 2, 3, 4, 5):
if self.board[7 * r + col] == 0:
return r
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next_empty_cell(self):\n for row in range(len(self.grid)):\n for col in range(len(self.grid[0])):\n if self.grid[row][col] == 0:\n return (row, col)\n return None",
"def firstEmptyCell(board):\r\n for i in range(9):\r\n for j in range(9... | [
"0.70686805",
"0.68694156",
"0.6839092",
"0.6825549",
"0.6811099",
"0.6801059",
"0.6765056",
"0.65474117",
"0.64673346",
"0.6367409",
"0.6351768",
"0.6185429",
"0.6164345",
"0.6136814",
"0.6120822",
"0.6100004",
"0.6095647",
"0.6049115",
"0.6045133",
"0.6013867",
"0.6006024",... | 0.5657273 | 56 |
Ensures events in the same timezone is kept the same. | def test_timezones(self):
a_user = User.objects.create()
user = VSBUser.objects.create(user=a_user)
today_datetime = timezone.datetime.today()
today_datetime = timezone.datetime(year=today_datetime.year, month=today_datetime.month, day=today_datetime.day)
tomorrow_late_EST = ti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_events_same_date(self):\n user = User.objects.create_user(\n 'foo', 'bar@example.com', 'secret'\n )\n d = make_aware(\n datetime.datetime(2019, 5, 3, 0, 0, 0, 0),\n get_default_timezone()\n )\n event = Event.objects.create(\n s... | [
"0.64569813",
"0.6179122",
"0.6049172",
"0.59762645",
"0.5917962",
"0.5917962",
"0.5917962",
"0.5917962",
"0.5917962",
"0.5917962",
"0.5917962",
"0.5917962",
"0.5917962",
"0.5917962",
"0.5917962",
"0.5917962",
"0.5917962",
"0.5917962",
"0.5917962",
"0.5917962",
"0.584768",
... | 0.750839 | 0 |
Ensures events in the same timezone is kept the same. | def test_adding_duplicate_course(self):
a_user = User.objects.create(first_name="2", last_name="test", username="test")
user = VSBUser.objects.create(user=a_user)
inst = Institution.objects.create(name = "UVA")
c1 = Course.objects.create(name = "CS 3240", institution= inst)
user... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_timezones(self):\n a_user = User.objects.create()\n user = VSBUser.objects.create(user=a_user)\n\n today_datetime = timezone.datetime.today()\n today_datetime = timezone.datetime(year=today_datetime.year, month=today_datetime.month, day=today_datetime.day)\n\n tomorrow_l... | [
"0.7507918",
"0.6455892",
"0.618064",
"0.6050892",
"0.59764373",
"0.59197676",
"0.59197676",
"0.59197676",
"0.59197676",
"0.59197676",
"0.59197676",
"0.59197676",
"0.59197676",
"0.59197676",
"0.59197676",
"0.59197676",
"0.59197676",
"0.59197676",
"0.59197676",
"0.59197676",
"... | 0.0 | -1 |
Convert Gripper response status into a string. | def grip_status_to_str(status):
return 'gACT:{}, gGTO:{}, gSTA:{}, gOBJ:{}, ' \
'gFLT:{}, gPR:{}, gPO:{}, gCU:{}'.format(
status.gACT,
status.gGTO,
status.gSTA,
status.gOBJ,
status.g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status_str(status):\n\n status_map = {\n 0: 'MATCH',\n 10: 'OK',\n 15: 'SKIP',\n 20: 'FAIL',\n 30: 'CRASH'\n }\n return status_map.get(status, 'UNKNOWN')",
"def parse_response_status(status: str) -> str:\n message = status\n if status == 'SUCCESS':\n message = \"Fac... | [
"0.73484504",
"0.7195751",
"0.6993703",
"0.6984708",
"0.68310195",
"0.6781132",
"0.67258435",
"0.66385025",
"0.66311485",
"0.6629265",
"0.6609995",
"0.65937823",
"0.6580734",
"0.6577525",
"0.65425885",
"0.64864516",
"0.64798313",
"0.6464424",
"0.6451959",
"0.63941294",
"0.637... | 0.73265874 | 1 |
Create Geo Distance with String | def test_add_geo_distance_with_string():
# When add a Geo Distance field
t = GeoDistance("1.0,2.0", "20mi")
# Then I see the appropriate JSON
results = {
"geo_distance": {
"distance": "20mi",
"location": {
"lat": 1.0,
"lon": 2.0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_distance(str1, str2):\r\n pass",
"def distance():\n return str(us.get_distance())",
"def edit_distance(str_1, str_2):\n return edit_distance_dp(str_1, len(str_1), str_2, len(str_2))",
"def edit_distance_dp(str1, str2):\r\n rows = len(str1) + 1\r\n cols = len(str2) + 1\r\n dp_table ... | [
"0.6896325",
"0.6722727",
"0.6401892",
"0.6091654",
"0.60439056",
"0.5994918",
"0.59728324",
"0.5927263",
"0.59133416",
"0.57946956",
"0.5726496",
"0.56893903",
"0.56400144",
"0.5611951",
"0.55960697",
"0.5591505",
"0.5589846",
"0.55890185",
"0.55776334",
"0.5561302",
"0.5536... | 0.72456956 | 0 |
Get a test request for testing a Django view This is helpful if you want to test a view as an isolated unit, i.e. not with the usual Django test client. This function returns a test request generated by ``RequestFactory``, with the ``session`` and ``user`` attributes set. | def get_test_request(url='/', data=None, method='get', session_data=None,
user=None):
method_to_call = getattr(RequestFactory(), method)
if data is None:
data = {}
if session_data is None:
session_data = {}
if user is None:
user = AnonymousUser()
request ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_request(self, post=None, request_method=\"GET\"):\n if post is None:\n post = {\"csrf_token\": \"irrelevant but required\"}\n request = testing.DummyRequest(post)\n request.client_addr = \"127.0.0.1\"\n request.session = Mock()\n request.method = request_method... | [
"0.6622834",
"0.659677",
"0.6440974",
"0.6414612",
"0.6280986",
"0.62458044",
"0.6213014",
"0.61762244",
"0.61666125",
"0.61069447",
"0.60014147",
"0.59884",
"0.5981046",
"0.5958674",
"0.59357107",
"0.59102416",
"0.58629906",
"0.5843196",
"0.5773389",
"0.57619905",
"0.5740153... | 0.7583656 | 0 |
Computes the precision for the specified values of k | def accuracy(output, target, topk=(1,)):
with torch.no_grad():
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\... | [
"0.76427615",
"0.74189496",
"0.7418079",
"0.72710466",
"0.72456723",
"0.72446615",
"0.7237539",
"0.72213703",
"0.7210107",
"0.7058935",
"0.6852219",
"0.6786084",
"0.67836976",
"0.6768417",
"0.67273885",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.... | 0.0 | -1 |
Returns True if on both positions there is the same colour or if both positions are empty. | def check_position_for_same_occupancy(self, position1, position2):
return self.board.board[position1] == self.board.board[position2] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_position_for_same_colour(self, position1, position2):\n return (not self.check_position_free(position1)) and self.check_position_for_same_occupancy(position1, position2)",
"def check_for_different_colour(self, arg1_position, arg2):\n return (not self.check_position_free(arg1_position)) an... | [
"0.83460194",
"0.7730944",
"0.70562655",
"0.67035156",
"0.6445123",
"0.6345509",
"0.6296314",
"0.6295087",
"0.626648",
"0.6233664",
"0.61863023",
"0.6185474",
"0.6169787",
"0.61568594",
"0.6152504",
"0.61418897",
"0.60918194",
"0.6085918",
"0.6074675",
"0.60164183",
"0.599831... | 0.6531611 | 4 |
Filters directions such that (draw.position) + (direction) is of different colour than the players own stone (draw.player). Requires input (directions) to be of ingoing directions only. | def select_directions_touching(self, directions):
return tuple(filter(lambda x: self.check_for_different_colour(self.draw.position.step(x), self.draw.player), directions)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_direction(frame, direction):\n return frame[frame['direction'] == direction].copy()",
"def select_directions_enclosing(self):\n directions = self.create_directions_ingoing()\n dir_touch_opponent = self.select_directions_touching(directions)\n start_pos = self.draw.position\n ... | [
"0.6099078",
"0.6073856",
"0.55939174",
"0.5401099",
"0.528419",
"0.5233864",
"0.5218914",
"0.5179804",
"0.5120998",
"0.50979483",
"0.50067955",
"0.49451372",
"0.4889852",
"0.4883184",
"0.48374364",
"0.48327506",
"0.48218718",
"0.46935263",
"0.46661687",
"0.4664544",
"0.46625... | 0.727601 | 0 |
Returns a list of directions / 2tuples such that the position of the draw creates an enclosing of the opponents stones in this directions. | def select_directions_enclosing(self):
directions = self.create_directions_ingoing()
dir_touch_opponent = self.select_directions_touching(directions)
start_pos = self.draw.position
player_id = self.draw.player
return list(filter(lambda d: self.walk_on_beam(player_id, start_pos.st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_directions():\n return [(1, 0), (0, 1), (-1, 0), (0, -1)]",
"def directions(self):\n return []",
"def create_directions_ingoing(self, pos=None):\n if pos is None:\n pos = self.draw.position\n all_directions = ((1, 0), (-1, 0), (0, 1), (0, -1), (-1, -1), (-1, 1), (1, 1... | [
"0.6730304",
"0.6691033",
"0.6373908",
"0.6240312",
"0.6225477",
"0.61888534",
"0.61880505",
"0.6180594",
"0.60789806",
"0.59737706",
"0.5963725",
"0.5924401",
"0.5924401",
"0.5924401",
"0.5924401",
"0.5924401",
"0.5924401",
"0.5924401",
"0.5874639",
"0.5838532",
"0.5809759",... | 0.66098785 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.