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 |
|---|---|---|---|---|---|---|
Unstack input tensor along 0th dimension | def unstack_batch(tensor_dict):
# # extract tensor from tuple. TODO: figure out where box tuple comes from?
for key in tensor_dict.keys():
if key == "gt_boxes":
tensor_dict["gt_boxes"] = tensor_dict["gt_boxes"][0]
unbatched_tensor_dict = {key: tf.unstack(tensor) for key, tensor in tensor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unstack1():\n x = np.arange(1, 25).reshape((4, 2, 3)).astype(np.float32)\n axis = -1\n x_tensor = paddle.to_tensor(x)\n out_list = paddle.unstack(x_tensor, axis=axis)\n length = len(out_list)\n for i in range(length):\n ept = x[:, :, i]\n npt.assert_allclose(out_list[i].num... | [
"0.74479556",
"0.7431098",
"0.7425012",
"0.71386355",
"0.7128114",
"0.69700605",
"0.69700605",
"0.69650245",
"0.6950998",
"0.6823663",
"0.68219626",
"0.6805298",
"0.67483246",
"0.67483246",
"0.67008394",
"0.66980016",
"0.6672495",
"0.6668245",
"0.66277343",
"0.6616315",
"0.65... | 0.6462905 | 30 |
Get a random element from the collection. | def getRandom(self):
return self.data[rnd.randrange(self.len)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_element(self) -> 'PFElement':\n return random.choice(list(iter(self)))",
"def _rand_elem(self, iterable):\n\n lst = list(iterable)\n idx = self._rand_int(0, len(lst))\n return lst[idx]",
"def getRandom(self):\n random_index = randint(0, len(self.list_val)-1)\n ... | [
"0.7651958",
"0.7149041",
"0.70814615",
"0.7044879",
"0.70404017",
"0.7034526",
"0.6959262",
"0.69563407",
"0.68719393",
"0.68376184",
"0.6797525",
"0.670551",
"0.6697882",
"0.6692588",
"0.6692588",
"0.6692588",
"0.6692588",
"0.66815263",
"0.66744214",
"0.6673934",
"0.6651395... | 0.65798575 | 25 |
Attach a lot of summaries to a Tensor (for TensorBoard visualization). | def variable_summaries(self, var):
with tf.name_scope('summaries'):
# 计算参数的均值,并使用tf.summary.scaler记录
mean = tf.reduce_mean(var)
tf.summary.scalar('mean', mean)
# 计算参数的标准差
with tf.name_scope('stddev'):
stddev = tf.sqrt(tf.reduce_mean(tf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_summary(self):\n for k, v in self.metrics.items():\n tf.summary.scalar(k, v)\n \n self.summary_op = tf.summary.merge_all()",
"def build_summaries(self):\n\n # Loss summary.\n tf.summary.scalar('loss', self.loss)\n\n merged = tf.summary.merge_all()\n self.summary_op = merged\n ... | [
"0.7071791",
"0.6970259",
"0.6970259",
"0.6800256",
"0.67872906",
"0.67407334",
"0.66669947",
"0.66576326",
"0.66193783",
"0.66085786",
"0.6595776",
"0.65836215",
"0.6581151",
"0.655297",
"0.6500364",
"0.6459978",
"0.64145213",
"0.6294558",
"0.62718755",
"0.62713677",
"0.6265... | 0.0 | -1 |
Scans for MIB files and populates an internal MIB>path mapping. | def find_mibs(raw_mibs_dirs, recursive=True):
files_scanned = 0
for raw_mibs_dir in raw_mibs_dirs:
for _file in _get_files(raw_mibs_dir, recursive):
files_scanned += 1
# making sure we don't start parsing some epic file
if os.path.getsize(_file) > '1048576':
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map(self, clean=False):\n self.files = {}\n curs = DatabaseManager.Instance().cursor\n if clean:\n curs.execute(\"DELETE FROM DestinationsFilesList WHERE `destinationName`=%s;\", (self.name, ))\n DatabaseManager.Instance().connector.commit()\n for root, directo... | [
"0.5871498",
"0.57725954",
"0.5574301",
"0.5554905",
"0.55441815",
"0.55269986",
"0.5487833",
"0.5455734",
"0.5440368",
"0.53786397",
"0.53573704",
"0.5344451",
"0.53140754",
"0.5294058",
"0.5263012",
"0.52183646",
"0.5202049",
"0.5186435",
"0.51749223",
"0.51683885",
"0.5164... | 0.6579575 | 0 |
Simulate the message we get when the error message is 'Authentication failed' but our authentication information is set up correctly. | def test_remote_authentication_failed_becomes_remote_initiated_server_error(self):
msg=self.sample_data("error_authentication_failed.xml")
error = ErrorParser().process_all(msg)
assert isinstance(error, RemoteInitiatedServerError)
eq_(BibliothecaAPI.SERVICE_NAME, error.service_name)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_authentication_error(self):\n resp = self.client.post(\n reverse(self.provider.id + \"_callback\"),\n data={\"error\": \"misc\", \"state\": \"testingstate123\"},\n )\n assert reverse(\"apple_finish_callback\") in resp.url\n # Follow the redirect\n r... | [
"0.74976647",
"0.72589785",
"0.7122555",
"0.7025229",
"0.69659656",
"0.68978405",
"0.68366987",
"0.6811286",
"0.6786908",
"0.67557895",
"0.6743041",
"0.6736152",
"0.6735449",
"0.66927165",
"0.66748",
"0.6521961",
"0.6512663",
"0.6505866",
"0.6490914",
"0.647563",
"0.6467338",... | 0.72130436 | 2 |
This function calculates the (insample) root mean squared error per iteration / after each weight update. The mean squared error can also be written as the cost J. | def RMSE(X, y, w):
n = X.shape[0]
f = X @ w
J = np.sqrt(np.sum(np.power((y - f), 2)) / n)
return J | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_weighted_error_rate(self):\n eps = self.weights[None, :] * self.indications\n return np.sum(eps, axis=1)",
"def mean_squared_error(y_true, y_pred, *, sample_weight=..., multioutput=..., squared=...):\n ...",
"def root_mean_square_error(y, y_pred, w):\n return np.sqrt(np.average(((y_... | [
"0.62648",
"0.616447",
"0.6159204",
"0.6082192",
"0.60329413",
"0.6009283",
"0.6009283",
"0.60078764",
"0.59961987",
"0.59412205",
"0.59333307",
"0.59104115",
"0.58540326",
"0.58400446",
"0.58362883",
"0.5828263",
"0.5816338",
"0.57980466",
"0.5785152",
"0.57680833",
"0.57508... | 0.5635224 | 33 |
The length of the valid data. | def length(self):
return self._length | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length(self):\n return len(self.data)",
"def length(self):\n return len(self.data)",
"def length(self):\n return len(self.data)",
"def length(self) -> int:\n return len(self.data)",
"def length(self):\n return len(self._data) if self._data else 0",
"def getLen(s... | [
"0.8653232",
"0.8653232",
"0.8653232",
"0.86165905",
"0.86017907",
"0.8457972",
"0.84575844",
"0.8311651",
"0.826856",
"0.826856",
"0.826856",
"0.8267182",
"0.8267182",
"0.82635176",
"0.82078433",
"0.8154572",
"0.8136523",
"0.8136523",
"0.81325954",
"0.81325954",
"0.81325954"... | 0.7802985 | 60 |
Get token from headers. | def getToken(request):
try:
token = request.META['HTTP_AUTHORIZATION'].split()[1]
except:
token = ""
return token | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_token(headers):\n bearer = headers.get('Authorization')\n if bearer:\n try:\n token_type, token = bearer.rsplit(' ', 1)\n except ValueError:\n raise TokenError('Wrong bearer string: %s', bearer)\n\n if token_type != 'Bearer':\n ... | [
"0.81423813",
"0.78079265",
"0.7729729",
"0.7681089",
"0.76468134",
"0.7562041",
"0.75074726",
"0.7497982",
"0.74665135",
"0.7465459",
"0.7415708",
"0.72177076",
"0.7180334",
"0.71304893",
"0.708986",
"0.70539254",
"0.7000456",
"0.6955858",
"0.6931232",
"0.69272333",
"0.69263... | 0.7129869 | 14 |
Check if user is super user. | def isSuperUser(token):
try:
decoded = jwt.decode(token, SECRET_KEY, algorithms=['HS256'])
if decoded['is_superuser'] == True:
return True
except:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isSuper(self):\n user = self.getSession()\n return self.pipe.auth.isSuper(user)",
"def is_superuser(self):\n return self.is_admin",
"def user_is_admin_or_superadmin(userobj):\n if userobj.is_superuser:\n return True\n else:\n return user_is_admin(userobj)",
"def i... | [
"0.8345067",
"0.7660509",
"0.7553286",
"0.7493648",
"0.74759424",
"0.7438602",
"0.7397464",
"0.7257184",
"0.7149185",
"0.7070042",
"0.70212674",
"0.6959832",
"0.68361425",
"0.6804893",
"0.6743156",
"0.6742876",
"0.6697537",
"0.6681163",
"0.6676914",
"0.65940934",
"0.65407413"... | 0.71699256 | 8 |
Extract EPSG number from file name. | def get_proj(fname):
fname = fname.split('_') # fname -> list
i = fname.index('epsg')
return fname[i+1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_proj(fname):\r\n\r\n fname = fname.split('_') # fname -> list\r\n i = fname.index('epsg')\r\n return fname[i+1]",
"def _epsg(self):\n info = self._info['coordinateSystem']['wkt'].rsplit('\"EPSG\",', 1)[-1]\n return int(re.findall(r\"\\d+\", info)[0])",
"def get_version_filename(... | [
"0.6372664",
"0.6207401",
"0.6057196",
"0.58825594",
"0.5815876",
"0.573625",
"0.5667595",
"0.5655963",
"0.563819",
"0.5617702",
"0.56169164",
"0.56163996",
"0.56144077",
"0.561111",
"0.56032217",
"0.55929625",
"0.5588135",
"0.55825263",
"0.5574977",
"0.55183697",
"0.54996",
... | 0.6380313 | 0 |
Set up from parent main window | def setup(self, workflow_controller, run_number, sample_log_name, num_sec_skip):
# Get workflow controller
self._myWorkflowController = workflow_controller
if run_number != self._myRunNumber:
new_graph = True
self._myRunNumber = run_number
self._logName = samp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _prep_window(self, parent=None):\n self.toolkit.app.initialize()\n if not self.initialized:\n self.setup(parent)\n self.resize_to_initial()\n self.update_minimum_size()\n self.update_maximum_size()",
"def __init__(self, parent=None):\n self._wi... | [
"0.775388",
"0.7526228",
"0.7522106",
"0.74188995",
"0.71708536",
"0.7115086",
"0.7115086",
"0.7115086",
"0.7115086",
"0.7115086",
"0.71085507",
"0.6952963",
"0.69400233",
"0.69354576",
"0.68943524",
"0.6806673",
"0.67986745",
"0.6798663",
"0.67929906",
"0.6777778",
"0.675423... | 0.0 | -1 |
| Object containing the details of the customer | def customer(self):
return self.__customer | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def customer(self):\n return Customer(self._dict.get('customer'))",
"def getCustomer(self):\n return self.base.get(\"customer\", [])",
"def add_customer_details(self):\n\n customer = self.invoice.customer\n addr = customer.get_billing_address()\n\n self.fontSize(FONT_S, bold=... | [
"0.7931326",
"0.7625496",
"0.74142975",
"0.7325266",
"0.7325266",
"0.72168016",
"0.7142404",
"0.70902115",
"0.70636487",
"0.70532024",
"0.70209074",
"0.69731915",
"0.6919475",
"0.68922555",
"0.6834874",
"0.6736054",
"0.66435784",
"0.6643331",
"0.66124773",
"0.66079795",
"0.65... | 0.76902 | 1 |
Convert from sparse gensim format to dense list of numbers | def vec2dense(vec, num_terms):
return list(gensim.matutils.corpus2dense([vec], num_terms=num_terms).T[0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_sparse(self):\n from divisi2.sparse import SparseVector\n return SparseVector(self, self.labels)",
"def _sparse2seq(self, key):\n seq = []\n for (d,v) in key:\n seq.append(d)\n seq.append(v)\n return seq",
"def to_sparse(self):\n if self.re... | [
"0.661641",
"0.64728504",
"0.6274302",
"0.61996746",
"0.6190139",
"0.61748755",
"0.60829073",
"0.6071056",
"0.6038952",
"0.5956165",
"0.58123845",
"0.5774624",
"0.5740731",
"0.57289165",
"0.572637",
"0.572015",
"0.571714",
"0.571687",
"0.5697401",
"0.5682308",
"0.5679311",
... | 0.6382906 | 2 |
Average uniqueness of the labels from the indicator matrix | def getAvgUniqueness(indM):
c = indM.sum(axis=1) # Concurrency
u = indM.div(c, axis=0) # Uniqueness
avgU = u[u > 0].mean() # Average uniqueness
return avgU | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_average_of_unique_labels(labels, values):\n labels = np.unique(labels, return_inverse=True)[1]\n unique_labels = np.unique(labels)\n mat = coo_matrix((np.ones_like(labels), (labels, np.arange(len(labels)))))\n mean_values = np.asarray(mat.dot(np.asarray(values).reshape(len(labels), -1))/mat.sum... | [
"0.7273065",
"0.6342399",
"0.62653077",
"0.61195475",
"0.6009027",
"0.5992311",
"0.59719723",
"0.59684473",
"0.59620726",
"0.59610766",
"0.5949561",
"0.5883647",
"0.58636016",
"0.58456254",
"0.58368313",
"0.5822207",
"0.5776531",
"0.5751692",
"0.5746142",
"0.5723832",
"0.5722... | 0.67795837 | 1 |
Return custom metrics. Printed with a delay of 1 prediction because the labels are returned in the feedback step. | def metrics(self):
if self.mse.shape[0]>1:
raise ValueError('Metrics can only handle single observations.')
if self.N==1:
pred = float('nan')
err = float('nan')
y_true = float('nan')
else:
pred = int(self._predictions[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metrics(outputs, labels, threshold):\n\n #convert the torch tensors to numpy\n y_pred = outputs.numpy()\n y_true = labels.numpy()\n \n #Predict 0/1 for each class based on threshold\n y_pred[y_pred > threshold] = 1\n y_pred[y_pred <= threshold] = 0\n \n #Calculate various metrics, fo... | [
"0.6694992",
"0.6525512",
"0.6342744",
"0.6323607",
"0.6295523",
"0.6291606",
"0.62560034",
"0.6211206",
"0.6147163",
"0.6127949",
"0.60935336",
"0.6070444",
"0.604476",
"0.6032009",
"0.60301346",
"0.6020207",
"0.60200965",
"0.6017226",
"0.6014496",
"0.60144067",
"0.6008699",... | 0.6303753 | 4 |
Return a string representation of the SilentSubstitutionProblem. | def __str__(self):
return f"""
SilentSubstitutionProblem:
Calibration: {self.calibration.shape},
Calibration Wavelengths: {self.calibration_wavelengths},
Primary Resolutions: {self.primary_resolutions},
Primary Colors: {self.primary_colors},
Observer: {self.observer},... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_problem(self) -> None:\n self._assert_problem_is_valid()\n print(f\"{'*'*60}\\n{' Silent Substitution Problem ':*^60s}\\n{'*'*60}\")\n print(f\"Device: {self.name}\")\n print(f\"Observer: {self.observer}\")\n print(f\"Ignoring: {self._ignore}\")\n print(f\"Silenc... | [
"0.6642478",
"0.6407018",
"0.6258476",
"0.5944283",
"0.5919121",
"0.5903521",
"0.59015155",
"0.5867006",
"0.58075964",
"0.5792745",
"0.57868177",
"0.5745731",
"0.57328004",
"0.572846",
"0.5721923",
"0.5681579",
"0.5678764",
"0.5674856",
"0.56683564",
"0.56629544",
"0.565457",... | 0.74001384 | 0 |
Set new input bounds for the primaries. | def bounds(self, new_bounds: devices.PrimaryBounds) -> None:
self._assert_bounds_are_valid(new_bounds)
self._bounds = list(new_bounds) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_bounds(self, new_bounds):\n\n # Update the internal object stored dict\n self.pbounds.update(new_bounds)\n\n # Loop through the all bounds and reset the min-max bound matrix\n for row, key in enumerate(self.pbounds.keys()):\n\n # Reset all entries, even if the same.\n... | [
"0.6861492",
"0.6169343",
"0.6169343",
"0.59426403",
"0.59112674",
"0.58969676",
"0.58638734",
"0.57524407",
"0.57228893",
"0.5700792",
"0.5699661",
"0.56500846",
"0.5645842",
"0.5614993",
"0.55965084",
"0.5595616",
"0.55871564",
"0.55871105",
"0.5543805",
"0.5526561",
"0.551... | 0.6340056 | 1 |
Set the silence property. | def silence(self, receptors_to_silence: Sequence[str]) -> None:
self._assert_receptor_input_is_valid(receptors_to_silence)
self._silence = [
r
for r in self.observer.photoreceptors
if r in receptors_to_silence
] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setSilent(self) -> None:\n ...",
"def silence(self):\n return self._replace(velocity=0.)",
"def silence(self):\n return 'Fine. Be that way!'",
"def set_silent(self, **kw):\n self._set_attr(silent=True, **kw)",
"def silence(self) -> list[str]:\n if self._silence is Non... | [
"0.7081476",
"0.70386994",
"0.6819705",
"0.6742329",
"0.65270907",
"0.6462345",
"0.6340266",
"0.63247114",
"0.63160545",
"0.61064124",
"0.6029206",
"0.6016768",
"0.60084975",
"0.5994978",
"0.5931604",
"0.587416",
"0.5818313",
"0.57959247",
"0.57557565",
"0.5749765",
"0.574708... | 0.57936263 | 18 |
getting expiration date from FORTS code | def get_maturity_from_code(code):
call_month_codes = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L']
put_month_codes = ['M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X']
mat_date_month = "00"
if code[-2] in call_month_codes:
# retrieving month code
mat_date... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_code_expiry():\n return now() + EXPIRE_CODE_DELTA",
"def get_code_expiry():\n return now() + EXPIRE_CODE_DELTA",
"def get_expiry():\n\n return get_or_append_details('expiry', \"Please enter your expiry date, two digits for the month and two digits for the year\")",
"def expiration_date(self)... | [
"0.74227756",
"0.74227756",
"0.74130446",
"0.73506254",
"0.7232941",
"0.7217484",
"0.70819294",
"0.6950929",
"0.68239146",
"0.6822021",
"0.67329025",
"0.6657159",
"0.6648514",
"0.6642687",
"0.66051257",
"0.65935963",
"0.6563249",
"0.65525645",
"0.65218604",
"0.6505916",
"0.64... | 0.0 | -1 |
Generate a decent default output filename for a given extensio. | def GenerateOutputFilename(extension):
# used for resolv.conf
if '.' in extension:
filename = extension
else:
output_base = 'namebench_%s' % datetime.datetime.strftime(datetime.datetime.now(),
'%Y-%m-%d %H%M')
output_base = output_base.rep... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_name(product, ext='json'):\n return f\"./output/{product}_{datetime.now().strftime('%Y-%m-%d_%H%M%S')}_transformed_{version}.{ext}\"",
"def _generate_output_name(extension):\n output_name = 'TDG_{:%Y-%m-%d_%H-%M-%S}.{}'.format(datetime.now(), extension)\n return output_name",
"def _gen_fname(... | [
"0.7484344",
"0.72538424",
"0.7139489",
"0.71028596",
"0.6952809",
"0.690816",
"0.6853547",
"0.68370783",
"0.6796737",
"0.6777636",
"0.6732944",
"0.67198557",
"0.6706356",
"0.66923857",
"0.6685107",
"0.66786087",
"0.66786087",
"0.6656327",
"0.66523474",
"0.6644909",
"0.661284... | 0.74914867 | 0 |
Distance between two coordinate pairs (in km) | def DistanceBetweenCoordinates(lat1, lon1, lat2, lon2):
lat1_r = math.radians(lat1)
lat2_r = math.radians(lat2)
lon_diff = math.radians(lon2 - lon1)
x = math.sin(lat1_r) * math.sin(lat2_r) + math.cos(lat1_r) * math.cos(lat2_r) * math.cos(lon_diff)
return math.degrees(math.acos(x)) * 60 * 1.852 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculateDistanceBetweenPoints(lat1,lon1,lat2,lon2):\n\treturn Geodesic.WGS84.Inverse(lat1,lon1, lat2, lon2)['s12']",
"def distance(a, b):\n return vincenty((float(a.longitude), float(a.latitude)),\n (float(b.longitude), float(b.latitude))).km",
"def distance_in_meters(coord1, coord2)... | [
"0.79895526",
"0.7906143",
"0.78414136",
"0.77900165",
"0.77708143",
"0.774916",
"0.7734973",
"0.77311283",
"0.76749134",
"0.7667429",
"0.76665336",
"0.7632355",
"0.76249593",
"0.76242703",
"0.76140815",
"0.7609438",
"0.760406",
"0.75914115",
"0.7591319",
"0.75877714",
"0.757... | 0.0 | -1 |
Return the JSON inside of the given JSON file. | def read_json(filepath):
if (filepath in _json_cache):
return _json_cache[filepath]
with open(filepath, 'r', encoding='utf-8') as fileinfo:
data = json.load(fileinfo)
_json_cache[filepath] = data
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_json(filename) :\n result = json.load(open(filename,'r'))\n return result",
"def read_json(json_file):\n with open(json_file) as f:\n content = json.load(f)\n return(content)",
"def read_json(file):\n with open(file, \"r\") as fid:\n return json.load(fid)",
"def get_jso... | [
"0.8107754",
"0.8082863",
"0.804047",
"0.80178547",
"0.79300034",
"0.79289615",
"0.78995484",
"0.78995484",
"0.78495026",
"0.7844279",
"0.7834323",
"0.7779444",
"0.7775475",
"0.7761664",
"0.775484",
"0.7744213",
"0.7699459",
"0.76951844",
"0.76831645",
"0.76777494",
"0.765970... | 0.0 | -1 |
Return a value based on how much x is between low and high. 0 if x == low, 1 if x == high, linear interpolation between. | def inv_lerp(x, low, high):
return (x - low) / (high - low) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_bound(value, in_low, in_high, out_low, out_high):\n result = None\n\n if value <= in_low:\n result = out_low\n else:\n if value >= in_high:\n result = out_high\n else:\n # http://stackoverflow.com/a/5650012/574981\n result = out_low + (\n ... | [
"0.7112073",
"0.6704662",
"0.65892744",
"0.6449347",
"0.6439949",
"0.6305286",
"0.621372",
"0.6211239",
"0.62076014",
"0.60880274",
"0.60784864",
"0.6062635",
"0.604387",
"0.6041528",
"0.6037606",
"0.60132366",
"0.6003469",
"0.5996361",
"0.5976305",
"0.5947131",
"0.5914784",
... | 0.68979526 | 1 |
Return a new Aligner object. | def __init__(self, image):
self.image = image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_aligner(allow_target_gaps=False, allow_target_mismatches=False):\n a = Align.PairwiseAligner()\n a.mismatch = -np.inf\n a.mismatch_score = -np.inf\n\n # Don't allow for gaps or mismatches with the target sequence\n if not allow_target_gaps:\n a.target_gap_score = -np.inf\n\n # Do ... | [
"0.6668261",
"0.64671654",
"0.6445427",
"0.6355851",
"0.5613677",
"0.5476986",
"0.5400568",
"0.53556585",
"0.5266582",
"0.5184053",
"0.5170089",
"0.5121102",
"0.5073959",
"0.5042241",
"0.5034145",
"0.49763435",
"0.4949613",
"0.48938078",
"0.48766184",
"0.48386192",
"0.4829154... | 0.0 | -1 |
Set ID of the task. Should be called from the main process. | def set_id(self, id_=None):
if id_ is None:
self.id = id(self)
else:
self.id = id_ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def task_id(self, task_id):\n self._task_id = task_id",
"def task_id(self, task_id):\n\n self._task_id = task_id",
"def _set_id(self):\n raise NotImplementedError()",
"def set_task1(self, task_id):\n self._set_task(self.controller.CURRENT, task_id)",
"def _set_id(self, value):\n... | [
"0.773409",
"0.75120604",
"0.7442351",
"0.71503556",
"0.7131475",
"0.7063591",
"0.7032",
"0.6883851",
"0.685464",
"0.6829359",
"0.67697495",
"0.6743148",
"0.67209303",
"0.6676415",
"0.65885246",
"0.65812665",
"0.6570905",
"0.6569487",
"0.6552",
"0.65501845",
"0.65463877",
"... | 0.68857175 | 7 |
Test for type of object | def test_type(self):
self.assertEqual(type(self.base1), BaseModel)
self.assertEqual(type(self.base2), BaseModel) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_type(self, obj):\n return isinstance(obj, self.type_)",
"def is_object_type(self):\n raise exceptions.NotImplementedError()",
"def is_type(obj):\n return type(obj) is type or type(obj) is types.ClassType",
"def is_type(obj: Any) -> bool:\n return type(obj).__name__ == \"type\""... | [
"0.82425654",
"0.7646364",
"0.7560182",
"0.7552964",
"0.75118846",
"0.7357962",
"0.7356674",
"0.73501533",
"0.7335767",
"0.7299956",
"0.729664",
"0.7242246",
"0.72355866",
"0.7119527",
"0.7119527",
"0.7116918",
"0.70470446",
"0.70408994",
"0.7020877",
"0.7006294",
"0.6996055"... | 0.0 | -1 |
Initialize this FeatureMemory object This class must be used with numpy ndarray and matrix classes for shared memory purposes. | def __init__(self, id_vector, bg_clip_ids, feature_mat, kernel_mat,
rw_lock=None):
assert isinstance(id_vector, (ndarray, ArrayProxy)), \
"ID vector not given as a numpy.ndarray!"
assert isinstance(bg_clip_ids, (set, frozenset)), \
"Background ID vector not a set... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n\n self.check_nans = False\n self.debug_force_memmap = False\n\n # Implementations must initialise the dtype so that feature arrays can be created with correct type:\n self.dtype = None",
"def __init__(self, *args):\n _snap.TMem_swiginit(self, _snap.new_TMe... | [
"0.7821421",
"0.66899383",
"0.66001254",
"0.65588886",
"0.65413624",
"0.64672863",
"0.64530706",
"0.64250904",
"0.6369885",
"0.6363286",
"0.6348547",
"0.63447255",
"0.6332951",
"0.63085",
"0.6269457",
"0.62655324",
"0.62418234",
"0.6220151",
"0.6213929",
"0.6207227",
"0.61558... | 0.0 | -1 |
Return the tuple of all "safe" noncallable elements of the given class. A "safe" noncallable is one that does not belong to the set ``__leave_alone_properties``. It is known that overwriting these noncallables interferes with the functioning of Proxy objects. | def all_safe_properties(obj):
return tuple(set(all_properties(obj)).difference(__leave_alone_properties)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _values(cls):\n assert inspect.isclass(cls)\n vals = tuple(val for val in _public_attributes(cls)\n if not inspect.isclass(val))\n return vals",
"def all_safe_methods(obj):\n return tuple(set(all_methods(obj)).difference(__leave_alone_methods))",
"def all_safe_methods(obj):\n ... | [
"0.6434489",
"0.6068872",
"0.6068872",
"0.59918654",
"0.59918654",
"0.55692524",
"0.5424576",
"0.5402131",
"0.53334445",
"0.52602345",
"0.5253981",
"0.5192158",
"0.51716614",
"0.5167765",
"0.5160638",
"0.5157595",
"0.5133452",
"0.5127053",
"0.5107574",
"0.50921136",
"0.506682... | 0.60131586 | 3 |
api to request to join community | def community_request(current_user, user_id):
community = Community(community_id=user_id, user_id=current_user.id)
community.save()
return response('success', 'Successfully joined community', 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_join_community_auto_accept(self):\n url = '/api/v1/communities/2/join_community/'\n\n response = self.client.post(url, HTTP_AUTHORIZATION=self.auth('user4'))\n self.assertEquals(status.HTTP_201_CREATED, response.status_code)\n\n self.assertEqual(16, Member.objects.all().count()... | [
"0.67613053",
"0.6691757",
"0.6652918",
"0.62077725",
"0.6012729",
"0.60066235",
"0.59752303",
"0.5973037",
"0.5931357",
"0.5871518",
"0.5858346",
"0.58392483",
"0.5827692",
"0.5822301",
"0.58083034",
"0.5793882",
"0.57426447",
"0.570795",
"0.5703619",
"0.5646488",
"0.564032"... | 0.7882974 | 0 |
Get the version number of win10 | def get_win10_release_id():
registry = registry_operator.RegistryTools()
key = registry.open(path=r'SOFTWARE\Microsoft\Windows NT\CurrentVersion')
version = registry.get_value(key, 'ReleaseId')
assert version, r'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ReleaseId not exists'
return version[0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getwindowsversion(): # real signature unknown; restored from __doc__\n pass",
"def get_version():\n click.echo(get_current_version_number())",
"def version():\n return uname().version",
"def version():\n return uname().version",
"def version_number() -> int:\n return 0",
"def version()... | [
"0.7362856",
"0.6980712",
"0.67748123",
"0.67748123",
"0.6734243",
"0.6699288",
"0.6614807",
"0.659892",
"0.659182",
"0.6581908",
"0.65805143",
"0.6577341",
"0.65371495",
"0.65238696",
"0.65174645",
"0.6486767",
"0.64791614",
"0.64568704",
"0.644823",
"0.6420311",
"0.6412044"... | 0.7824323 | 0 |
Test Invalid response Exception | def test_invalid_json():
with pytest.raises(ExxRequestException):
with requests_mock.mock() as m:
m.get('https://api.exx.com/data/v1/markets', text='<head></html>')
client.get_markets() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_response(self):\r\n self.assertRaises(ValueError, unpack_answ, {ERROR: 'Bad Request'})",
"def test_no_response(self):\n self.assertRaises(ValueError, parse_server_answer, {ERROR: 'Bad Request'})",
"def assert_invalid_responses(response) -> None:\n assert invalid_resp_title in respo... | [
"0.7760837",
"0.7754411",
"0.7600917",
"0.7536108",
"0.74345213",
"0.74275285",
"0.73367673",
"0.73128635",
"0.7288063",
"0.72366625",
"0.7206077",
"0.717904",
"0.71780545",
"0.7154639",
"0.71294945",
"0.71105593",
"0.7103114",
"0.70990044",
"0.70967895",
"0.70836234",
"0.707... | 0.6875794 | 53 |
Get a DatabaseManager for the test database. | def get_test_db():
defaults = get_defaults()
test_defaults = {k: v for k, v in defaults.items() if 'test' in k}
key_list = list(test_defaults.keys())
key_list.sort()
db = None
for k in key_list:
test_name = test_defaults[k]
m = re.match('(\w+)://.*?/([\w.]+)', test_name)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db(self):\n return DbManager(self)",
"def get_db(db_label):\n defaults = get_defaults()\n db_name = defaults[db_label]\n m = re.match('(\\w+)://.*?/([\\w.]+)', db_name)\n if m is None:\n logger.error(\"Poorly formed db name: %s\" % db_name)\n return\n sqltype = m.groups()[... | [
"0.7369642",
"0.69996846",
"0.6994584",
"0.6812342",
"0.6622032",
"0.65329444",
"0.6506723",
"0.64118767",
"0.6395297",
"0.6390974",
"0.6352239",
"0.63277787",
"0.63056314",
"0.6260258",
"0.62182677",
"0.61909264",
"0.6170282",
"0.6156474",
"0.6148891",
"0.6130372",
"0.612411... | 0.70309603 | 1 |
Convert a MAC address to a readable/printable string | def mac_addr(address):
return ':'.join('%02x' % compat_ord(b) for b in address) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mac_ntoa(mac):\n return '%.2x:%.2x:%.2x:%.2x:%.2x:%.2x' % tuple(map(ord, list(mac)))",
"def _mac_addr(address):\n return ':'.join('%02x' % ord(b) for b in address)",
"def mac_addr(address):\n\tprint(':'.join('%02x' % compat_ord(b) for b in address))\n\treturn ':'.join('%s' % format(compat_ord(b), '0>8... | [
"0.8274901",
"0.7819506",
"0.78023726",
"0.7799624",
"0.7393615",
"0.72612065",
"0.7243841",
"0.7214834",
"0.71748555",
"0.7040925",
"0.69946724",
"0.6982126",
"0.6982003",
"0.6913715",
"0.67323697",
"0.671812",
"0.6642322",
"0.6640873",
"0.6632942",
"0.66163164",
"0.65952176... | 0.7411498 | 6 |
Load data from JSON file. | def load_json(path: Path) -> Any:
with path.open() as f:
return json.load(f) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_data_from_json(self, filename):\n with open(filename, 'r') as f:\n self.data = json.load(f, object_pairs_hook=OrderedDict)",
"def load_json(self, filename):\n with open(filename, 'r', encoding='utf-8') as f:\n data_dict = json.load(f)\n return data_dict",
"def... | [
"0.8308445",
"0.807338",
"0.79950386",
"0.7992568",
"0.79430985",
"0.7904193",
"0.78673565",
"0.7813986",
"0.7804568",
"0.7783261",
"0.77693176",
"0.76967275",
"0.76305026",
"0.76305026",
"0.760471",
"0.7601194",
"0.7601087",
"0.7582864",
"0.7580324",
"0.75647575",
"0.7526202... | 0.0 | -1 |
Returns whether or not a value is within the linked list. Boolean output | def includes(self, value):
current = self.head
while current:
if current.value == value:
return True
current = current.next
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contains(self, value):\n if not self.head:\n return False\n # get a reference to the node we're currently at; update this as we traverse the list\n current = self.head\n # check to see if we're at a valid node\n while current:\n # return True if the curr... | [
"0.7472828",
"0.7119401",
"0.7118545",
"0.708651",
"0.708651",
"0.7054339",
"0.70459336",
"0.69478726",
"0.68837184",
"0.66803145",
"0.65851516",
"0.64791054",
"0.6479094",
"0.64761746",
"0.6424989",
"0.62902904",
"0.6266378",
"0.6253001",
"0.6250592",
"0.6236796",
"0.6222343... | 0.6956325 | 7 |
Takes in any value as an argument and adds a new node with that value to the top of the stack with an O(1) Time performance. | def push(self, item):
if self.top == None:
self.top = Node(item)
else:
new_node = Node(item)
new_node.next = self.top
self.top = new_node | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push(self, value): ################# <-\n self.top = Node(value, next=self.top)",
"def push(self, value): ################# <-\n self.top = Node(value, next=self.top)",
"def push(self, value): ################# <-\n self.top = Node(value, next=self.top)",
"def push(self, value):\n ... | [
"0.8339699",
"0.8339699",
"0.8339699",
"0.7922126",
"0.78938985",
"0.78582406",
"0.7836101",
"0.77921057",
"0.772359",
"0.7689909",
"0.76273793",
"0.7528882",
"0.7455275",
"0.74385244",
"0.74265873",
"0.7425777",
"0.7369265",
"0.7353475",
"0.72942626",
"0.72428656",
"0.722931... | 0.71114296 | 32 |
Takes no arguments, removes the node from the top of the stack, and returns the node's value. | def pop(self):
if not self.top:
raise AttributeError("Can't pop item from an empty stack")
popped_node = self.top
self.top = self.top.next
popped_node.next = None
return popped_node.value
# try:
# popped_node = self.top
# self.top = sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop(self):\n removed_node = self.top\n self.top = self.top._next\n self._size -= 1\n return removed_node.val",
"def pop(self) -> Any:\r\n if self.is_empty():\r\n raise IndexError(\"pop from empty stack\")\r\n else:\r\n # \"remove\" element by ha... | [
"0.76831937",
"0.76625884",
"0.75652075",
"0.749806",
"0.749806",
"0.749806",
"0.7353562",
"0.72979385",
"0.7272651",
"0.71174383",
"0.70911777",
"0.70156974",
"0.7000661",
"0.6975122",
"0.6884601",
"0.68828636",
"0.6863503",
"0.68533903",
"0.6847185",
"0.68371546",
"0.678794... | 0.7891126 | 0 |
Takes any value as an argument and adds a new node with that value to the back of the queue with an O(1) Time Performance. | def enqueue(self, item):
if self.rear == None:
self.front = Node(item)
self.rear = self.front
else:
self.rear.next = Node(item)
self.rear = self.rear.next | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append(self, value: Any) -> None:\n new_node = Node(value)\n try: # Assume queue is not empty\n new_node.next = self._tail\n self._tail.prev = new_node\n except AttributeError: # Queue is empty\n self._head = new_node\n... | [
"0.78796256",
"0.78417724",
"0.764486",
"0.76387554",
"0.76387554",
"0.7624837",
"0.7600804",
"0.7550658",
"0.7538901",
"0.7530308",
"0.752903",
"0.7527952",
"0.74844676",
"0.74524486",
"0.74524486",
"0.74524486",
"0.74115556",
"0.736019",
"0.7291573",
"0.7202817",
"0.7200240... | 0.64713365 | 72 |
Takes no arguments, remove the node from the front of the queue, and returns the node's value. | def dequeue(self):
if not self.front:
raise AttributeError("Can't dequeue from an empty queue")
removed = self.front
self.front = self.front.next
return removed.value
# try:
# removed = self.front
# self.front = self.front.next
# r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop_front(self):\n if self.is_empty():\n return None\n val = self.head.value\n # Update head and size\n self.head = self.head.next_node\n self.size -= 1\n # If the only node was removed, also need to update tail\n if self.is_empty():\n self... | [
"0.8008523",
"0.77565885",
"0.77047235",
"0.7664694",
"0.7625208",
"0.7618795",
"0.74478966",
"0.7371742",
"0.73064166",
"0.7298094",
"0.7192344",
"0.7133304",
"0.71327436",
"0.7132293",
"0.7057849",
"0.70551276",
"0.7020103",
"0.7011846",
"0.69877464",
"0.6983709",
"0.696017... | 0.77411765 | 2 |
Takes no arguments and returns the value of the node located in the front of the queue, without removing it from the queue. | def peek(self):
if not self.front:
raise AttributeError("Can't peek from an empty queue")
return self.front.value
# try:
# return self.front.value
# except AttributeError:
# return "Can't peek front from an empty queue" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def front(queue):\n if empty_queue(queue):\n raise IndexError(\"Queue is empty!\")\n else:\n return queue.front.value",
"def front(self):\n return self.queue[0] if not self.empty() else None",
"def getFront(self):\n\t\tfront = self.queue[self.front]\n\t\treturn front\n\t\tpass",
"d... | [
"0.8375962",
"0.7756607",
"0.77459747",
"0.756601",
"0.75049525",
"0.7501166",
"0.7475511",
"0.7470694",
"0.7435067",
"0.7433579",
"0.74131066",
"0.74131066",
"0.7406768",
"0.74032086",
"0.7380017",
"0.7354833",
"0.7344678",
"0.73238754",
"0.72918385",
"0.7220124",
"0.7192659... | 0.7513554 | 4 |
Takes no arguments and returns a boolean indicating whether or not the queue is empty. | def is_empty(self):
return not bool(self.front) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self):\n return len(self.the_queue) == 0",
"def empty(self) -> bool: \n if(self.queue is not None and len(self.queue) > 0):\n print(\"len > 0\" )\n return False\n else:\n print(\"len = 0\" )\n return True",
"def is_empty(self):\n ... | [
"0.89681554",
"0.89518225",
"0.8911007",
"0.8911007",
"0.8902901",
"0.8865907",
"0.88423675",
"0.8737752",
"0.8706407",
"0.869394",
"0.8685373",
"0.86684704",
"0.86607975",
"0.8623539",
"0.8606862",
"0.8595146",
"0.85701936",
"0.85701936",
"0.85370207",
"0.8479665",
"0.842437... | 0.0 | -1 |
Converts the request and attributes into an artifacts dict. | def _prepare_artifacts(self, attributes):
artifacts = {
'method': self.req['method'],
'host': self.req['host'],
'port': self.req['port'],
'resource': util.parse_normalized_url(self.req['url'])['resource'],
}
artifact_keys = ['ts', 'nonce', 'hash', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def artifacts(self) -> dict:\n return {}",
"def extract_request(self, attrs):\n try:\n _base = self.attributes()\n _new_dict = {}\n for key in attrs:\n if key in _base:\n _new_dict[key] = attrs[key]\n return _new_dict\n ... | [
"0.6526723",
"0.64661485",
"0.64320594",
"0.62466973",
"0.62114155",
"0.6182319",
"0.60741055",
"0.60363775",
"0.59306526",
"0.57450354",
"0.56808764",
"0.5678414",
"0.56561816",
"0.5586539",
"0.55783206",
"0.5552464",
"0.555214",
"0.55184704",
"0.54812026",
"0.5472196",
"0.5... | 0.79652137 | 0 |
Normalizes url by removing bewit parameter. | def normalize_url_without_bewit(url, bewit):
bewit_pos = url.find('bewit=')
# Chop off the last character before 'bewit=' which is either a ? or a &
bewit_pos -= 1
bewit_end = bewit_pos + len("bewit=" + bewit) + 1
o_url = ''.join([url[0:bewit_pos], url[bewit_end:]])
return o_url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_url(self, url):\n pass",
"def _clean_url(self, url):\n return \"\".join(url.split(\"?\")[:1])",
"def scrub_url(self, url):\n return self.__url_scrubber(url)",
"def sanitizeUrl(url):\n return url.split('?')[0]",
"def clean_url(url):\n return url[:url.find('?')]",
"def ... | [
"0.8078606",
"0.77948445",
"0.7317319",
"0.7091677",
"0.7031276",
"0.70165306",
"0.69773334",
"0.68960845",
"0.683041",
"0.6827484",
"0.6818049",
"0.66940236",
"0.6692805",
"0.66492736",
"0.65864533",
"0.6569428",
"0.65656096",
"0.65546286",
"0.65487045",
"0.6532414",
"0.6489... | 0.80675757 | 1 |
Gradient of the sigmoid function | def sigmoid_grad(x):
sig = sigmoid(x)
return np.multiply(sig, 1 - sig) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid_gradient(z):\n #derivative of sigmoid\n return z * (1 - z)",
"def gradient(cls, x):\n y = Sigmoid.apply(x)\n return np.multiply(y, 1 - y)",
"def sigmoid_grad(self, X):\n var=self.sigmoid(X)\n return var*(1-var)",
"def grad_sigmoid(self):\n grad = self.sigmoid(... | [
"0.8551342",
"0.8390682",
"0.8298052",
"0.8282312",
"0.8242257",
"0.8235969",
"0.81944615",
"0.81859523",
"0.79697925",
"0.784512",
"0.78179556",
"0.7715229",
"0.76634157",
"0.7634516",
"0.7625993",
"0.7574006",
"0.7486019",
"0.7474829",
"0.744489",
"0.7409682",
"0.7376286",
... | 0.8494483 | 1 |
Accepts pram json file path or pram json as string | def __init__(self, json_str: object = None, json_file_path: object = None) -> None:
self.data = None
if json_str is None and json_file_path is None:
# raise Exception("Invalid file path or json string. Please provide valid file path for json data or provide json string")
print("N... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pose_json(json_path: str):\n raise NotImplementedError",
"def read_json():\n json_path = Path.home() / Path(\"pdf2notion.json\")\n if json_path.exists():\n try:\n with open(json_path) as f:\n json_data = json.load(f)\n return json_data\n exc... | [
"0.63149226",
"0.6212465",
"0.6177979",
"0.61227703",
"0.60692227",
"0.606337",
"0.6029618",
"0.60261625",
"0.6003403",
"0.59925866",
"0.5952168",
"0.5944886",
"0.5908452",
"0.5905644",
"0.58931774",
"0.586608",
"0.5855455",
"0.5816033",
"0.5810899",
"0.5781612",
"0.57686716"... | 0.0 | -1 |
Return a string representation of this sample | def toString(self):# -> str
return "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s" \
%(str(self.sampleString),\
self.GT,\
str(self.altReads),\
str(self.refReads),\
str(self.GQ),\
self.PL,\
str(self.DP),\
str(self.missing... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n string = 'input dim: {} \\noutput dim: {} \\n'.format(\n self.dim_inputs, self.dim_outputs\n )\n string += 'sequence length: {} \\n'.format(\n self.tensors[0].shape[1]\n )\n key = 'train' if self.train else 'test'\n string += '{}_... | [
"0.7555769",
"0.74908566",
"0.74065864",
"0.7342964",
"0.7240717",
"0.7228967",
"0.72144914",
"0.7202382",
"0.71959615",
"0.7189387",
"0.7158673",
"0.7150896",
"0.7128567",
"0.7117453",
"0.70842415",
"0.70778614",
"0.70778614",
"0.70778614",
"0.70778614",
"0.70778614",
"0.707... | 0.74924743 | 1 |
Return Nodal Fluxes as a DataFrame. | def df_nodal_flux(self):
df_q = pd.DataFrame(index=self.masking_domain)
df_q["q"] = self.sdb.getNodalValues()
df_q.dropna(subset=["q"], inplace=True)
return df_q.join(self.doc.c.mesh.df.nodes()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def WFD(self) -> pd.DataFrame:\n return self.fdist",
"def SweepFrame(*args, **kwargs):\n underride(kwargs, dtype=float)\n return pd.DataFrame(*args, **kwargs)",
"def to_dataframe(self):\n return df_util.to_dataframe(requests.get(self.__url).json())",
"def as_dataframe(self) -> \"pd.DataFr... | [
"0.60676503",
"0.5945104",
"0.5939798",
"0.593673",
"0.58295983",
"0.58066106",
"0.5791495",
"0.5776705",
"0.5753614",
"0.5743327",
"0.57147175",
"0.57103455",
"0.5708856",
"0.5684062",
"0.5673782",
"0.5670308",
"0.56580204",
"0.5636693",
"0.5634482",
"0.5632516",
"0.5630655"... | 0.7160031 | 0 |
Return Nodal Fluxes as a GeoDataFrame. | def gdf_nodal_flux(self):
import geopandas as gpd
return self.df_nodal_flux()[["q"]].join(self.doc.c.mesh.gdf.nodes()).set_geometry("element_shape") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def df_nodal_flux(self):\n df_q = pd.DataFrame(index=self.masking_domain)\n df_q[\"q\"] = self.sdb.getNodalValues()\n df_q.dropna(subset=[\"q\"], inplace=True)\n return df_q.join(self.doc.c.mesh.df.nodes())",
"def gdf(self) -> gpd.GeoDataFrame:\n path = str(get_path(\"geojson/F... | [
"0.7166943",
"0.6557297",
"0.6476656",
"0.63841313",
"0.62390846",
"0.616241",
"0.6077305",
"0.59608585",
"0.5890338",
"0.58580256",
"0.5857999",
"0.5796365",
"0.57298875",
"0.57207286",
"0.571764",
"0.5666421",
"0.5662517",
"0.5658272",
"0.5608441",
"0.55780196",
"0.5565749"... | 0.6755464 | 1 |
Make a local DateTime object timezone aware with pytz.timezone | def make_tz_aware(local_dt):
aware_dt = timezone('US/Eastern').localize(local_dt)
return aware_dt | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_make_timezone_aware(datetime_object, timezone_string=None):\n if timezone_string:\n # make the date timezone aware using the given timezone_string\n timezone_object = pytz_timezone_object(timezone_string)\n timezone_aware_datetime_object = timezone_object.localize(datetime_object)\... | [
"0.71477807",
"0.70585006",
"0.7037683",
"0.69803715",
"0.6953209",
"0.68772674",
"0.6870371",
"0.6831815",
"0.68280196",
"0.6823656",
"0.6799838",
"0.6790992",
"0.6774305",
"0.67628056",
"0.67479926",
"0.67325217",
"0.66681933",
"0.6653556",
"0.6643445",
"0.66305494",
"0.662... | 0.76121867 | 0 |
From jeffjeffjeffrey with modified lower_bound | def calc_fuel_given_ore(ore, recipes):
upper_bound = None
lower_bound = 469536 # assume ore needed for 1 fuel is good lower bound
while lower_bound + 1 != upper_bound:
if upper_bound is None:
guess = lower_bound * 2
else:
guess = (upper_bound + lower_bound) // 2
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lower_bound(self) -> float:\n ...",
"def get_lower_bound(self):\n return self._lower_bound",
"def get_lower_bound(self):\n return self._lower_bound",
"def _bound(x, min_value, max_value):\n return np.maximum(min_value, np.minimum(x, max_value))",
"def _get_observation_lower_bound(se... | [
"0.8609187",
"0.8044172",
"0.8044172",
"0.74542254",
"0.7370522",
"0.72577",
"0.7127707",
"0.70376176",
"0.6969548",
"0.695645",
"0.6824971",
"0.68184334",
"0.6698165",
"0.6673827",
"0.6643529",
"0.6561016",
"0.6524637",
"0.65129113",
"0.6508991",
"0.6459045",
"0.6445581",
... | 0.0 | -1 |
Compute softmax values for each sets of scores in x. | def softmax(x):
e_x = np.exp(x - np.max(x))
return e_x / e_x.sum(axis=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(self, scores):\n\n\n # for each sample, for each class ,caclulate\n # np.exp(scores) : still (n_samples, n_classes)\n\n # axis = 1\n # a00, a01, a02 as a sinlge one to perfrom np_sum\n # which is the same sample \n # sum_exp : still (n_samples, 1)\n\n # ... | [
"0.7796294",
"0.7760558",
"0.7759004",
"0.77567077",
"0.76577055",
"0.76577055",
"0.76577055",
"0.76577055",
"0.7585655",
"0.743143",
"0.7407772",
"0.73941606",
"0.7358175",
"0.73174125",
"0.72689486",
"0.72623265",
"0.72614294",
"0.7256868",
"0.723019",
"0.7214918",
"0.72017... | 0.7133715 | 27 |
Creates About HTML page | def create_about():
meta_desc = (
'Expected values and probability per lap of step-up banners'
' in Final Fantasy Brave Exvius (FFBE)')
template_vars = {
'title' : 'About - ' + sitesettings.SITE_NAME,
'siteurl' : sitesettings.SITE_URL,
'sitename' : sitesettings.SITE_NAME,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def about():\n return render_template('about.html', title='About')",
"def about():\n\n return render_template('about_page.html', title='About')",
"def about():\n\n\treturn render_template(\"about.html\")",
"def about():\n return render_template('about.html', title='About')",
"def about():\n\n ... | [
"0.840048",
"0.83930737",
"0.8370619",
"0.82939833",
"0.8286711",
"0.8259359",
"0.8205112",
"0.8190554",
"0.81728363",
"0.8170028",
"0.8160674",
"0.81592256",
"0.814658",
"0.814658",
"0.814658",
"0.814658",
"0.814658",
"0.814658",
"0.814658",
"0.814658",
"0.814658",
"0.8145... | 0.86164767 | 0 |
Creates Home HTML page | def create_home():
meta_desc = (
'Expected values and probability per lap of step-up'
' banners in Final Fantasy Brave Exvius (FFBE)')
template_vars = {
'title' : sitesettings.SITE_NAME,
'siteurl' : sitesettings.SITE_URL,
'sitename' : sitesettings.SITE_NAME,
'meta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def homepage():\n return render_template('home/index.html', \n title=\"Bem vindo!\")",
"def homepage():\n\treturn render_template(\"home/a_homepage.html\", title=\"Welcome\")",
"def home():\n return render_template('homepage.html')",
"def homepage():\n return render_templa... | [
"0.84207344",
"0.8391805",
"0.8364716",
"0.8364346",
"0.8354891",
"0.83515704",
"0.8343415",
"0.8343415",
"0.8317153",
"0.8311937",
"0.82957554",
"0.82950824",
"0.82682717",
"0.82682717",
"0.82624716",
"0.8238007",
"0.8236771",
"0.8236771",
"0.8236771",
"0.8236771",
"0.823677... | 0.82702035 | 12 |
Test that clumerge() raises the expected exceptions. | def test_clumerge_exceptions(prng: Generator):
# Data item does not contain required field `unknown`
nd = 3
npts = prng.integers(10, high=101)
ds = {
"points": prng.random((npts, nd)),
"clusters": prng.integers(1, high=6, size=npts),
}
with pytest.raises(
ValueError,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testMergeRejectsUnequalNodes():\n\n n1 = DummyNode(x=1, y=2, z=4)\n n2 = DummyNode(x=1, y=3, z=3)\n\n with pytest.raises(TypeError):\n n1.merge_with(n2)",
"def test_branch_exceptions(self):\r\n # create bare repo that we can mess with and attempt an import\r\n bare_repo = os.pat... | [
"0.6438822",
"0.62703574",
"0.6257399",
"0.62523043",
"0.6149452",
"0.6106618",
"0.6099427",
"0.60930115",
"0.6089401",
"0.600332",
"0.59698546",
"0.59333026",
"0.5914592",
"0.59046453",
"0.589663",
"0.586996",
"0.585381",
"0.5852274",
"0.58307874",
"0.5814364",
"0.5810109",
... | 0.7366609 | 0 |
Initialize grid and predator and prey starting positions | def __init__(self, gridsize = (11,11), startPrey = (0,0), startPredator = (5,5)):
self.predator = startPredator;
self.prey = startPrey;
self.gridsize = gridsize; | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_grid(self):\n self.pts = np.array(\n np.meshgrid(\n np.arange(self.net_dim[0]) + 1,\n np.arange(self.net_dim[1]) + 1\n )\n ).reshape(2, np.prod(self.net_dim)).T\n if self.topo == \"hexagonal\":\n self.pts[:, 0] = self.pts[... | [
"0.7403591",
"0.70456475",
"0.6952987",
"0.6890594",
"0.68691653",
"0.6853789",
"0.6825715",
"0.6825125",
"0.6735819",
"0.66812545",
"0.6645796",
"0.66451037",
"0.6611989",
"0.66102266",
"0.65127444",
"0.6504324",
"0.6462781",
"0.64610267",
"0.6436974",
"0.6428062",
"0.641614... | 0.79017943 | 0 |
Plots value of Pearson coeff on plot. | def corrfunc(x, y, **kws):
r, _ = stats.pearsonr(x, y)
ax = plt.gca()
ax.annotate(r"$\rho$ = {:.2f}".format(r),xy=(.5, .9), xycoords=ax.transAxes) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot(self):\n\t\tself.plotOfCos1().plot()",
"def plot_polynomial(self):\n plt.scatter(self.x_values, self.y_values)\n plt.title(f\"Graph of polynomial between {np.floor(min(self.x_values))} and {np.ceil(max(self.x_values))}\")\n plt.xlabel('x-axis')\n plt.ylabel('y-axis')\n ... | [
"0.6474159",
"0.6255685",
"0.6245896",
"0.61915064",
"0.6155003",
"0.60515016",
"0.5969315",
"0.5917106",
"0.58849865",
"0.587837",
"0.5864154",
"0.5841361",
"0.58188134",
"0.57817656",
"0.57594377",
"0.5698859",
"0.5687883",
"0.5681984",
"0.5680379",
"0.5664035",
"0.56600916... | 0.6049057 | 6 |
Plots pairwise scatterplot and histograms using seaborn. | def seaborn_pairwise(data, columns=None, output_name=None, output_dir='./', normalized=None, mass_frac=[]):
##GREG: can probably revert this function back to NOT include the mass fraction, etc calculations
# and let it be more general. We will want to check that our filename saving in new folder works.
# I... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pair_scatter(df, **kwargs):\n\n grid = sns.pairplot(df, **kwargs)\n return grid.fig",
"def plotPairplot(data_clust, save=False, *args):\n warnings.filterwarnings(\"ignore\") #Ignore warnings\n #Init\n sns.pairplot(data_clust, hue=\"Clusters\")\n if save == True:\n ... | [
"0.6790604",
"0.6469649",
"0.6413993",
"0.63871604",
"0.62896156",
"0.6223026",
"0.6112273",
"0.60900366",
"0.5933722",
"0.59121144",
"0.59007895",
"0.5895926",
"0.5863182",
"0.58368844",
"0.5818153",
"0.58056873",
"0.57466906",
"0.5719305",
"0.5705256",
"0.5697683",
"0.56958... | 0.65095675 | 1 |
Check token list for nonmatching parenthesis (this will simplify further transformation to search condition) | def _checkParentheses(tokens):
parentheses_counter = 0
for token in tokens:
if token.type == _Token.OPENING_PARENTHESIS:
parentheses_counter += 1
elif token.type == _Token.CLOSING_PARENTHESIS:
parentheses_counter -= 1
if parentheses_counter < 0:
raise ParserError("Unmatching closing parenthesis", tok... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match_paranthesis(expression):\n stack=ArrayStack()\n for s in expression:\n if s == '(':\n stack.push(s)\n if s == ')':\n if stack.is_empty():\n return False\n else:\n stack.pop()\n return stack.is_empty()",
"def no_parant... | [
"0.6732199",
"0.6610627",
"0.64043295",
"0.6058804",
"0.60368747",
"0.598353",
"0.59802985",
"0.59035414",
"0.5835196",
"0.5793248",
"0.5782553",
"0.57647145",
"0.5753878",
"0.57286835",
"0.5696039",
"0.5677912",
"0.56652933",
"0.56638277",
"0.56554735",
"0.56454426",
"0.5642... | 0.63888025 | 3 |
Check if the profile exist. | def profile_checking(ipydir, profile):
try:
profile = ProfileDir.find_profile_dir_by_name(ipydir, profile)
return True
except ProfileDirError:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile_exists(profile):\n if os.path.isfile(AWS_CREDENTIALS_FILE):\n boto.config.load_credential_file(AWS_CREDENTIALS_FILE)\n if boto.config.get(profile, 'region'):\n return True\n else:\n return False\n return False",
"def test_instance_profile_exists(self) ... | [
"0.8031023",
"0.7803401",
"0.77900934",
"0.77900934",
"0.6976083",
"0.66206914",
"0.6551856",
"0.64893496",
"0.6471747",
"0.64599395",
"0.63870186",
"0.63174564",
"0.6312017",
"0.62799686",
"0.6260085",
"0.62127393",
"0.6207783",
"0.6168983",
"0.6158869",
"0.6138863",
"0.6124... | 0.7220914 | 4 |
Return a list of file paths specific to a profile. Suppose you'll symlink all files in the 'profile/startup' directory. | def profile_files(profile):
flist = os.listdir(osp.join(profile, 'startup'))
profile_path = osp.join(osp.abspath('.'), profile)
return [osp.join(profile_path, 'startup', x) for x in flist] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config_symlink(ipydir, profile):\n fexist = []\n for fpath in profile_files(profile):\n filename = osp.basename(fpath)\n dest_file = osp.join(ipydir, 'profile_' + profile, 'startup',\n filename)\n if osp.islink(dest_file) or osp.isfile(dest_file):\n ... | [
"0.6861318",
"0.6770157",
"0.66690826",
"0.6662082",
"0.6612794",
"0.6579149",
"0.63691145",
"0.63256013",
"0.62959576",
"0.62896425",
"0.60509413",
"0.60296184",
"0.59753925",
"0.5939635",
"0.593416",
"0.5919787",
"0.5792229",
"0.579204",
"0.5781933",
"0.5764063",
"0.5742355... | 0.862834 | 0 |
t unix timestamp or None | def print_time(t=None):
if t is None:
t = time.time()
return "%d (%s)" % (t, time.ctime(t)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unix_timestamp():\n return int(time.time())",
"def timestamp(self, t):\n if isinstance(t, datetime):\n t = time.mktime(t.timetuple())\n return t - 631065600",
"def _make_timestamp(self):\r\n\t\tlogger.debug(\"Get a timestamp\")\r\n\t\treturn time.mktime(datetime.today().timetupl... | [
"0.7514501",
"0.73880863",
"0.7233987",
"0.70461345",
"0.70188457",
"0.7016715",
"0.6980704",
"0.6947744",
"0.69295806",
"0.69134873",
"0.6900092",
"0.68996835",
"0.68986887",
"0.68168247",
"0.6758599",
"0.673747",
"0.66907257",
"0.6647337",
"0.66137683",
"0.6605467",
"0.6566... | 0.0 | -1 |
Fill sequence_list with data. | def fill_sequence_list(self):
data = Data()
sequence_list = self.ui.sequence_list
model = QStandardItemModel(sequence_list)
sequences = data.get_sequence_list()
if len(sequences) > 0:
for sequence in sequences:
note = ""
if sequence[4]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_sequence(self, sequence_list):\n self.sequence_fragment_list = []\n for res_name in sequence_list:\n self.sequence_fragment_list.append((res_name, None))",
"def __init__(self, sequence):\n self._seq = sequence # Copy of the given data.\n # Reference to the underlyi... | [
"0.64999545",
"0.6046435",
"0.588356",
"0.5844543",
"0.57555395",
"0.5630048",
"0.5610253",
"0.5605583",
"0.55814004",
"0.55609125",
"0.55528826",
"0.55425036",
"0.5528633",
"0.54926485",
"0.54833907",
"0.5481184",
"0.54554564",
"0.5442292",
"0.5440747",
"0.5431209",
"0.54200... | 0.74764013 | 0 |
Initializes the weight matrix of the Softmax classifier. Note that it has shape (C, D) where C is the number of classes and D is the feature size. | def init_weights(self, dims):
self.W = np.random.normal(size=dims) * 0.0001 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(self, num_features):\n for each_label in self.valid_labels:\n self.weights[each_label] = np.zeros(num_features)",
"def initialize_weights(self):\n # compute lmda.\n self.lmda = float(self.c)/float(self.N)\n # bias term. This should not get a regularization ... | [
"0.6991155",
"0.6727196",
"0.67208725",
"0.6635066",
"0.6632182",
"0.66165185",
"0.66165185",
"0.66165185",
"0.6583814",
"0.65573215",
"0.6549503",
"0.6514011",
"0.65097296",
"0.650536",
"0.644608",
"0.6441606",
"0.6406409",
"0.63970894",
"0.63658506",
"0.63658506",
"0.636547... | 0.67171085 | 3 |
Returns the tornado application, which owns this API. | def tornado_app(self):
return self._tornado_app | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_app(self):\n app.init_options()\n return app.NBViewer().tornado_application",
"def app(self):\r\n return self._app",
"def app(self):\n return self._app",
"def app(self):\n return self.__app",
"def app(self):\n if self._application is None:\n self._applic... | [
"0.82271",
"0.75303274",
"0.7432945",
"0.73336905",
"0.7265643",
"0.72604805",
"0.7226876",
"0.7226876",
"0.7175644",
"0.7159435",
"0.6904401",
"0.68407863",
"0.67400736",
"0.67318076",
"0.673061",
"0.669776",
"0.6682935",
"0.6641529",
"0.66103876",
"0.657321",
"0.64963424",
... | 0.87451833 | 0 |
Build a dense representer that applies the same dense weights to each element in the input sequence. | def build_dense_representer(embedding_size, representation_size, apply_noise, num_hidden=2, hidden_size=None,
l2_normalize=False, noise_before=True, noise_after=True, single_stddev=False, **_):
if hidden_size is None:
hidden_size = embedding_size
model = Sequential(name='rep... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_dense(self):\n rep = self.rep\n\n if rep.fmt == 'dense':\n return self\n\n return self.from_rep(rep.to_dfm_or_ddm())",
"def todense(self):\n d = np.zeros(self.shape)\n for index,value in zip(self.index, self.value):\n d[index] = value\n retur... | [
"0.6251753",
"0.6092227",
"0.55514824",
"0.5488381",
"0.54217595",
"0.5421737",
"0.53899974",
"0.5324493",
"0.53033155",
"0.52949244",
"0.52157754",
"0.51900506",
"0.51798475",
"0.51552093",
"0.512715",
"0.5110828",
"0.50984883",
"0.50895107",
"0.5080247",
"0.50593185",
"0.50... | 0.6400247 | 0 |
Test a GET / and check a 200 status | def test_get_main_page_without_logged_in_user(self):
response = self.testapp.get('/')
self.assertEqual(response.status_int, 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_response_200_on_get(self):\n pass",
"def test_get(self):\n self.assertEqual(200, self.response.status_code)",
"def test_get(self):\n self.assertEqual(200, self.response.status_code)",
"def test_get(self):\n self.assertEqual(200, self.resp.status_code)",
"def test_get(se... | [
"0.84242207",
"0.8341295",
"0.8341295",
"0.8144911",
"0.8144911",
"0.8091201",
"0.80674887",
"0.7938558",
"0.7938558",
"0.7938558",
"0.7938558",
"0.7938558",
"0.7893259",
"0.7893259",
"0.7857553",
"0.7850991",
"0.7850991",
"0.7850991",
"0.7850991",
"0.7850991",
"0.7850991",
... | 0.0 | -1 |
Test a GET / and check a 200 status | def test_get_main_page_with_registered_user(self):
self.mock_authenticated_user(user_email='test_user2@test.com',
google_user_id=2,
user_is_admin=0)
# Add a user to the datastore -- a registered user is one in the datastore:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_response_200_on_get(self):\n pass",
"def test_get(self):\n self.assertEqual(200, self.response.status_code)",
"def test_get(self):\n self.assertEqual(200, self.response.status_code)",
"def test_get(self):\n self.assertEqual(200, self.resp.status_code)",
"def test_get(se... | [
"0.84242207",
"0.8341295",
"0.8341295",
"0.8144911",
"0.8144911",
"0.8091201",
"0.80674887",
"0.7938558",
"0.7938558",
"0.7938558",
"0.7938558",
"0.7938558",
"0.7893259",
"0.7893259",
"0.7857553",
"0.7850991",
"0.7850991",
"0.7850991",
"0.7850991",
"0.7850991",
"0.7850991",
... | 0.0 | -1 |
LSHIFT an attribute of this query. | def lshift(self, attr):
return self.set_child_and_return(shifter.lshift(self.statement, attr)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rshift(self, attr):\n return self.set_child_and_return(shifter.rshift(self.statement, attr))",
"def lshift(self, value):\n return self.clone().lshift_(value)",
"def __lshift__(self, other):\n for c in self.__table__.columns:\n self.__setattr__(c.name, other.__getattribute__(... | [
"0.72143215",
"0.67306894",
"0.64151895",
"0.6337502",
"0.61789393",
"0.607188",
"0.60101014",
"0.5836488",
"0.5814514",
"0.57248634",
"0.55769956",
"0.5566112",
"0.5529796",
"0.5523514",
"0.54727995",
"0.54705065",
"0.546831",
"0.5435185",
"0.54295266",
"0.5402672",
"0.53692... | 0.8145605 | 0 |
RSHIFT an attribute of this query. | def rshift(self, attr):
return self.set_child_and_return(shifter.rshift(self.statement, attr)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lshift(self, attr):\n return self.set_child_and_return(shifter.lshift(self.statement, attr))",
"def rshift(self, value):\n return self.clone().rshift_(value)",
"def __rshift__(self, other: Any) -> ColumnOperators:\n return self.operate(rshift, other)",
"def __rshift__(self, other):\n... | [
"0.7116247",
"0.6788453",
"0.64649063",
"0.6208217",
"0.6176364",
"0.59764093",
"0.58911824",
"0.5845119",
"0.5828118",
"0.5753853",
"0.57297087",
"0.5688807",
"0.5660079",
"0.56435466",
"0.5593801",
"0.5593801",
"0.5584336",
"0.55622804",
"0.55046487",
"0.5457518",
"0.544742... | 0.8151545 | 0 |
Get a dictionary for the focused instrument parameters including virtual detectors' positions | def get_focused_instrument_parameters(self, num_banks):
# check input
datatypeutility.check_int_variable('Number of banks', num_banks, (1, 28))
edit_instrument_param_dict = dict()
try:
edit_instrument_param_dict['L1'] = self._focus_instrument_dict['L1']
edit_ins... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parameters(self):\n #print \"in instrument.parameter()\"\n return self._params",
"def parameters(self):\n return {\"W\": self.W,\n \"T\": self.T,\n \"P\": self.P}",
"def get_params_info(cls):\n return dict(\n config='laygo configuration dictionar... | [
"0.6329854",
"0.6210716",
"0.61709917",
"0.61519235",
"0.6131829",
"0.6104645",
"0.6084531",
"0.604398",
"0.6023968",
"0.60159487",
"0.6015726",
"0.60114723",
"0.6002658",
"0.5994768",
"0.5989295",
"0.5939505",
"0.5921527",
"0.58854675",
"0.5824716",
"0.5811473",
"0.5806904",... | 0.70196253 | 0 |
Set the name of the event workspace. This operation might be called before the workspace is created. | def event_workspace_name(self, value):
# Check
datatypeutility.check_string_variable('Input event workspace', value)
# Set
self._eventWorkspace = value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set(self, name):\n self.rpc.call(MsfRpcMethod.DbSetWorkspace, [name])",
"def event_workspace_name(self):\n return self._eventWorkspace",
"def set_name(self, newname=\"\"):\n self.name = newname",
"def set_name(self, name):\n\t\tself.name_ = name",
"def set_name(self, name):\n ... | [
"0.7208446",
"0.65416723",
"0.65168005",
"0.64614135",
"0.6451643",
"0.6451643",
"0.6451643",
"0.6451643",
"0.6451643",
"0.6445513",
"0.6445513",
"0.64446104",
"0.6432965",
"0.642001",
"0.642001",
"0.6404516",
"0.6404516",
"0.63988376",
"0.6389758",
"0.63666975",
"0.636499",
... | 0.797735 | 0 |
Constructor. By default, the builtin data module is used. Users may explicitly set constants for single statepoints via the set_constants command. | def __init__(self, \
model="IFBA", \
enrichment=4.0, \
burnup=0.0 ):
# Set characteristics used to define the group constants
# within the data module.
self.model = model
self.enrichment = enrichment
self.bu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n raise NotImplementedError('cannot create independent state')",
"def __init__(self):\n self.__dataset = None",
"def __init__(self):\n self.state_dim = 12\n self.measurement_dim = 6",
"def __init__(self):\n super().__init__()\n self.dataFilename = None... | [
"0.6659865",
"0.64618653",
"0.643072",
"0.63322675",
"0.63251144",
"0.6304854",
"0.6298028",
"0.629687",
"0.62951493",
"0.6270966",
"0.62569416",
"0.62510556",
"0.62134874",
"0.6206846",
"0.6165445",
"0.6157145",
"0.6095087",
"0.6093438",
"0.60484904",
"0.60291153",
"0.602323... | 0.0 | -1 |
Name of the Space instance. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def space(self) -> str:\n\n return self._space.NAME",
"def name(cls):\n return cls._NAME",
"def getname(self):\n if self.instance is not None:\n return '%s_%s' % (self.name,self.instance)\n else:\n return self.name",
"def name(cls):\n return cls.NAME",... | [
"0.8284684",
"0.752535",
"0.74856275",
"0.74206257",
"0.74206257",
"0.7305949",
"0.7305949",
"0.7305949",
"0.7305949",
"0.7305949",
"0.7305949",
"0.7305949",
"0.7305949",
"0.7305949",
"0.7305949",
"0.7268205",
"0.7268205",
"0.7268205",
"0.7268205",
"0.7268205",
"0.7268205",
... | 0.0 | -1 |
Sets the learning rate to the initial LR decayed by 0.2 every steep step | def adjust_learning_rate(epoch, opt, optimizer):
steps = np.sum(epoch >= np.asarray(opt.lr_decay_epochs))
if steps > 0:
new_lr = opt.learning_rate * (opt.lr_decay_rate ** steps)
optimizer.set_learning_rate(new_lr) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_learning_rate(self):\n\n if (self.FLAGS.learning_rate_decay is \"exponential\"):\n self.learning_rate = tf.train.exponential_decay(\n self.FLAGS.learning_rate,\n self.global_step,\n self.... | [
"0.79089844",
"0.7856753",
"0.7856753",
"0.76767546",
"0.75567615",
"0.75240135",
"0.75000376",
"0.7454447",
"0.7426672",
"0.74171114",
"0.7404257",
"0.7401694",
"0.7386987",
"0.73657304",
"0.7329806",
"0.73260325",
"0.73156565",
"0.7304068",
"0.73000455",
"0.7264402",
"0.725... | 0.7126283 | 42 |
Function to plot lag plots for a specific value | def plot_lag_plots(data, col, lags=None):
if lags is None:
return
if len(lags) % 2 != 0:
raise ValueError(f'Expected no of elements in lags to be even. Found {len(lags)}')
fig, axes = plt.subplots(len(lags)//2, 2, figsize=(10, 4))
plt.subplots_adjust(hspace=0.4, wspace=0.4, top=2.5)
for i in range(len(lags... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_lag_plot(series_name, lag = 1):\n plt.figure(figsize = (8,5))\n plt.title('Lag Plot of the Trade Value of Imports')\n plt.xlim(min(series_name), max(series_name))\n plt.ylim(min(series_name), max(series_name))\n lag_plot(series_name, lag = lag)\n plt.show()",
"def lag_plot(series: Se... | [
"0.7898144",
"0.78656435",
"0.6252253",
"0.6117661",
"0.605089",
"0.59836143",
"0.59235615",
"0.5867383",
"0.5861968",
"0.5829686",
"0.5672881",
"0.566757",
"0.56294227",
"0.5609881",
"0.55767477",
"0.55595285",
"0.55501455",
"0.55316097",
"0.5524337",
"0.5512382",
"0.5493142... | 0.7277837 | 2 |
Return a FormSet for the given form class. | def formset_factory(form, formset=BaseFormSet, extra=1, can_order=False,
can_delete=False, max_num=None, validate_max=False,
min_num=None, validate_min=False, absolute_max=None,
can_delete_extra=True):
if min_num is None:
min_num = DEFAULT_MIN_NUM
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_formset(self, formset_class=None):\n if formset_class is None:\n formset_class = self.get_formset_class()\n return formset_class(**self.get_formset_kwargs())",
"def get_form_class(self):\n\t\treturn formset_factory(super(FormsetMixin, self).get_form_class(), **self.get_formset_kw... | [
"0.85970396",
"0.7866576",
"0.7426121",
"0.72943974",
"0.7277612",
"0.720305",
"0.6733694",
"0.6637113",
"0.65846926",
"0.6566057",
"0.6466867",
"0.6389999",
"0.6384271",
"0.6358693",
"0.6280156",
"0.6251765",
"0.62437785",
"0.61231875",
"0.6096596",
"0.6071969",
"0.6018419",... | 0.6003961 | 21 |
Plot the magnetic equilibrium, applying all settings given to this MeqPlot object. This means any overlays will be plotted. | def assemblePlot(self):
self.clearPlot()
self.axes = self.figure.add_subplot(111)
# Reset handles
self._fluxOverlayHandles = []
self._magneticAxisHandle = None
self._orbitHandles = []
self._separatrixOverlayHandle = None
self._wallCrossSectionOverlayHandl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_canvas(self, figsize=(8, 7)):\n\n # An elongated figure for the 1D example\n if self.simulation == '1D_chain':\n self.fig = plt.figure(figsize=(8, 3))\n else:\n self.fig = plt.figure(figsize=figsize)\n\n self.ax = self.fig.add_subplot(111)\n\n # Ass... | [
"0.6534599",
"0.65014035",
"0.6499873",
"0.6469854",
"0.6321945",
"0.6269594",
"0.62664",
"0.6262117",
"0.62536985",
"0.62088484",
"0.61998063",
"0.6176359",
"0.6130131",
"0.6071842",
"0.60701305",
"0.6069796",
"0.6069459",
"0.6053794",
"0.6040277",
"0.5988034",
"0.5983106",
... | 0.6169876 | 12 |
Plot the magnetic axis | def plotMagneticAxis(self, plotstyle='rs', linewidth=3):
self.removeMagneticAxis()
l = self.axes.plot(self.magneticfield.maxis[0], self.magneticfield.maxis[1], plotstyle, linewidth=linewidth)
self._magneticAxisHandle = l.pop(0)
self.overlayMagneticAxis = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_coupling_mag(self, ax=None):\n\n f = self.freq.f / self.freq.unit_mult\n\n if ax is None:\n fig, ax = plt.subplots()\n ax.plot(f, self.coupling())\n ax.set(xlim=[f.min(), f.max()])\n ax.set(xlabel='Frequency ({0})'.format(self.freq.units))\n ax.set(ylab... | [
"0.6613014",
"0.63643825",
"0.6249949",
"0.6203088",
"0.619868",
"0.6179514",
"0.61093473",
"0.60765445",
"0.60637563",
"0.6045284",
"0.60180974",
"0.59978473",
"0.59949535",
"0.59584975",
"0.595633",
"0.593613",
"0.5926078",
"0.5925793",
"0.59055287",
"0.58966446",
"0.58938"... | 0.67734605 | 0 |
Converts dense matrix into sparse matrix in (row, column, value) form | def makesparse(matrix):
n = matrix[0].size
elements = []
for i in range(n):
for j in range(n):
if matrix[i][j] != 0 :
temp = MatrixElement(i, j, matrix[i][j])
elements.append(temp)
return SparseMatrix(n, elements) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_sparse(self):\n from divisi2.sparse import SparseMatrix\n return SparseMatrix(self, self.row_labels, self.col_labels)",
"def _dict_to_sparse(matrix_dict):\n return scipy.sparse.coo_matrix(\n (matrix_dict['data'], (matrix_dict['row'], matrix_dict['col'])),\n shape=matrix_dict... | [
"0.7729954",
"0.7219044",
"0.7198435",
"0.7108752",
"0.71075773",
"0.7029618",
"0.7018173",
"0.69259113",
"0.6907381",
"0.6885401",
"0.68827206",
"0.68753374",
"0.6849547",
"0.68257874",
"0.6818609",
"0.6818511",
"0.6776344",
"0.67091703",
"0.666339",
"0.6641254",
"0.66249794... | 0.78737754 | 0 |
Applies the sparse Matrix to some vector V | def apply(self, v):
u = np.zeros(self.Dimension, dtype=complex)
for me in self.Elements:
for index in range(v.Elements.size):
if index == me.j:
u[me.i] += me.val * v.Elements[index]
u = Vector(u)
return u | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sparse_matlab(i, j, v, m, n):\n return csr_matrix((v, (i, j)), shape=(m, n))",
"def smat(v):\n \n k = len(v)\n n = TriLengthToSquare(k)\n \n A = np.zeros([n,n])\n A[np.triu_indices(n)] = v\n A[np.triu_indices(n,1)] *= 2 / np.sqrt(2)\n return (A + A.T) / 2",
"def to_s_matrix(w,v):... | [
"0.7243322",
"0.6464093",
"0.620535",
"0.611436",
"0.60631967",
"0.60213464",
"0.6007619",
"0.5933094",
"0.59190243",
"0.5886714",
"0.58005184",
"0.57948005",
"0.5764423",
"0.57447135",
"0.5710347",
"0.5669755",
"0.5668261",
"0.565708",
"0.5645803",
"0.56430554",
"0.56418973"... | 0.62396616 | 2 |
distance between 2 points sqrt((xx)^2 + (yy)^2) | def distance(p1, p2):
return sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_distance(x1, y1, x2, y2):\n return math.sqrt((x1 - x2) ** 2 + (y1 * 2.38 - y2 * 2.38) ** 2)",
"def distance(xy1, xy2):\n x_dist = xy2[0] - xy1[0]\n y_dist = xy2[1] - xy1[1]\n dist = np.sqrt(x_dist ** 2 + y_dist ** 2)\n return dist",
"def distance(pt1, pt2):\n\tx1, y1 = pt1\n\tx2, y2 = pt... | [
"0.7863442",
"0.78251433",
"0.7759952",
"0.76943046",
"0.7649585",
"0.7636665",
"0.7593452",
"0.7566145",
"0.7559949",
"0.7540149",
"0.75245386",
"0.75197744",
"0.75047773",
"0.75025153",
"0.74921966",
"0.7481076",
"0.74580574",
"0.7437439",
"0.743456",
"0.74234927",
"0.74214... | 0.72676647 | 50 |
With a conversation_id and text message, get a response from the COPILOT host configured | def send_message(self, **kwargs):
payload = dict(self.payload)
payload['message']['content'] = str(kwargs['message'])
payload['conversation_id'] = str(kwargs['conversation_id'])
r = requests.post(COPILOT_POST, json=payload, headers=self.headers).json()['results']
response ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_response(message_dict):\n c.master_command(bot_token, user_token, discuss_bot_id, discussion_chat_id,\n message_dict)",
"def sent_text(self, message = \"\"):\n\t\tresponse = self.conversation.message(workspace_id = self.workspace_id, message_input = {'text' : message}, context =... | [
"0.58486754",
"0.56217",
"0.55456626",
"0.54067016",
"0.5369348",
"0.5291855",
"0.52844197",
"0.5234504",
"0.52250034",
"0.5180558",
"0.51770693",
"0.51532304",
"0.5131178",
"0.5127209",
"0.51143533",
"0.510903",
"0.50899273",
"0.50852585",
"0.5063193",
"0.5041188",
"0.503282... | 0.6368956 | 0 |
Sets the _from of this V1ImageSource. From is a reference to an ImageStreamTag, ImageStreamImage, or DockerImage to copy source from. | def _from(self, _from):
self.__from = _from | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _from(self, _from):\n if _from is None:\n raise ValueError(\"Invalid value for `_from`, must not be `None`\") # noqa: E501\n\n self.__from = _from",
"def set_from(self, a_from):\n if isinstance(a_from, (str, )):\n self.set_parameter('from', a_from)\n if isin... | [
"0.6940491",
"0.62017626",
"0.5943258",
"0.5941505",
"0.5903539",
"0.5903539",
"0.58316666",
"0.5828838",
"0.54561615",
"0.5397365",
"0.5378187",
"0.5335934",
"0.53047496",
"0.5282486",
"0.5263778",
"0.5236944",
"0.5193923",
"0.5193923",
"0.5193923",
"0.5187118",
"0.5184625",... | 0.6427776 | 2 |
Gets the paths of this V1ImageSource. Paths is a list of source and destination paths to copy from the image. | def paths(self):
return self._paths | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_image_paths(self):\n return self.image_paths",
"def get_image_paths(self):\n return self.image_paths",
"def paths(self):\r\n return self._paths",
"def get_paths(self):\n return self.paths",
"def GetPaths(self):\n return self.paths",
"def paths(self):\n rc... | [
"0.7435019",
"0.7435019",
"0.69991875",
"0.6875141",
"0.6835491",
"0.6834172",
"0.6785093",
"0.6577964",
"0.65334487",
"0.6409041",
"0.64080864",
"0.6330697",
"0.62979364",
"0.62523186",
"0.6233008",
"0.6194083",
"0.61599445",
"0.6132015",
"0.6128815",
"0.6126821",
"0.6108589... | 0.70434743 | 2 |
Gets the pull_secret of this V1ImageSource. PullSecret is a reference to a secret to be used to pull the image from a registry If the image is pulled from the OpenShift registry, this field does not need to be set. | def pull_secret(self):
return self._pull_secret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_pull_secret(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"image_pull_secret\")",
"def pull_secret(self, pull_secret):\n\n self._pull_secret = pull_secret",
"def pull_secret(self, pull_secret):\n\n self._pull_secret = pull_secret",
"def get_pull(self, pull_nu... | [
"0.71736926",
"0.64188623",
"0.64188623",
"0.61607295",
"0.5852253",
"0.57484335",
"0.57484335",
"0.57484335",
"0.57484335",
"0.57484335",
"0.57484335",
"0.57484335",
"0.57484335",
"0.57484335",
"0.57484335",
"0.57484335",
"0.57484335",
"0.57484335",
"0.57484335",
"0.57484335",... | 0.731515 | 1 |
Returns true if both objects are equal | def __eq__(self, other):
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.7961088",
"0.7961088",
"0.79433626",
"0.79303336",
"0.7926563",
"0.7897525",
"0.78826123",
"0.78826123",
"0.78806067",
"0.7872423",
"0.7868354",
"0.78668815",
"0.7825702",
"0.7819993",
"0.78162885",
"0.78078854",
"0.78068... | 0.79670393 | 38 |
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.8455985",
"0.83913255",
"0.81440157",
"0.8140831",
"0.8132328",
"0.80937284",
"0.809181",
"0.809181",
"0.809181",
"0.808509",
"0.808509",
"0.8076134",
"0.8076134",
"0.8065528"
] | 0.0 | -1 |
Creates an instance of this model from a dictionary | def from_dictionary(cls,
dictionary):
if dictionary is None:
return None
# Extract variables from the dictionary
name = dictionary.get('Name')
cover_page_setting = dictionary.get('CoverPageSetting')
add_list_of_signatures_on_last_page_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dictionary(cls,\n dictionary):\n if dictionary is None:\n return None\n\n # Extract variables from the dictionary\n id = dictionary.get('id')\n name = dictionary.get('name')\n mtype = dictionary.get('type')\n usage_bytes = diction... | [
"0.83180064",
"0.81692255",
"0.81692255",
"0.81188524",
"0.8089153",
"0.7978471",
"0.7949498",
"0.7922631",
"0.78985846",
"0.7894865",
"0.78879577",
"0.78826904",
"0.78814775",
"0.78771174",
"0.78584737",
"0.78399473",
"0.7803621",
"0.7803621",
"0.7803621",
"0.7803621",
"0.78... | 0.0 | -1 |
Check that given stores are different. This is a workaround for tha fact that simplekv stores normally do not implemenent some sane equality check. | def assert_stores_different(store1, store2, prefix):
if callable(store1):
store1 = store1()
if callable(store2):
store2 = store2()
key = "{prefix}/.test_store_difference.{uuid}".format(
prefix=prefix, uuid=uuid.uuid4().hex
)
try:
store2.put(key, b"")
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_items_from_different_stores_do_not_mingle():\n\n my_store = InMemoryStore[Person]()\n carl = my_store.add(Person(\"Carl\", age=22))\n carl.age = 23\n\n other_store = InMemoryStore[Person]()\n with pytest.raises(NotFromStoreException):\n other_store.save(carl)\n\n my_store.save(car... | [
"0.7282838",
"0.6993059",
"0.6964808",
"0.67503077",
"0.66942114",
"0.6497844",
"0.64946914",
"0.64114225",
"0.63678074",
"0.63449174",
"0.63402706",
"0.6314058",
"0.63130313",
"0.6289078",
"0.62671465",
"0.62157905",
"0.61769634",
"0.61366534",
"0.6121969",
"0.61159015",
"0.... | 0.79931563 | 0 |
Prove that the conversions to miles from kilometers works as expected. | def test_kilometers_to_miles(self) -> None:
kilometers = 5
metric = "kilometers"
self.assertEqual("3.11", f"{to_miles(metric, kilometers):.2f}")
kilometers = 0
metric = "kilometers"
self.assertEqual(0, to_miles(metric, kilometers)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_miles(self):\n miles = location_util.vincenty(COORDINATES_PARIS,\n COORDINATES_NEW_YORK,\n miles=True)\n self.assertEqual(round(miles, 2), DISTANCE_MILES)",
"def test_get_miles() -> None:\n miles = location_... | [
"0.8174022",
"0.8087568",
"0.80284566",
"0.7882435",
"0.7737644",
"0.76399803",
"0.7512742",
"0.7307431",
"0.72487247",
"0.7213019",
"0.71466225",
"0.69627124",
"0.6897218",
"0.6886637",
"0.68793875",
"0.6857676",
"0.6789314",
"0.67599124",
"0.66880554",
"0.6616253",
"0.65785... | 0.81039965 | 1 |
Prove that the conversions to miles from meters works as expected. | def test_meters_to_miles(self) -> None:
meters = 5000
metric = "meters"
self.assertEqual("3.11", f"{to_miles(metric, meters):.2f}")
meters = 0
metric = "meters"
self.assertEqual(0, to_miles(metric, meters)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_miles(self):\n miles = location_util.vincenty(COORDINATES_PARIS,\n COORDINATES_NEW_YORK,\n miles=True)\n self.assertEqual(round(miles, 2), DISTANCE_MILES)",
"def test_get_miles() -> None:\n miles = location_... | [
"0.82653594",
"0.80872905",
"0.74252063",
"0.72831047",
"0.7231163",
"0.7069318",
"0.70393026",
"0.70384675",
"0.6852367",
"0.6803067",
"0.6780292",
"0.67801523",
"0.6735596",
"0.67350054",
"0.66489965",
"0.656042",
"0.65471256",
"0.65158594",
"0.6456659",
"0.63706595",
"0.63... | 0.79137313 | 2 |
return true if the three points are in a line | def in_line(pi, pj, pk):
# compute cross product
dxc = pk.x - pi.x;
dyc = pk.y - pi.y;
dxl = pj.x - pi.x;
dyl = pj.y - pi.y;
cross = dxc * dyl - dyc * dxl;
return True if cross == 0 else False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_on_line(point_a, point_b, point_c):\r\n return (point_b[0] - point_a[0]) * (point_c[1] - point_a[1]) - (point_b[1] - point_a[1]) * (point_c[0] - point_a[0])",
"def isOnLine(self, point):\n if((point < self.start and point < self.end) or (\n point > self.start and point > self.end)):\n... | [
"0.8008733",
"0.7730922",
"0.74547976",
"0.73230636",
"0.7285209",
"0.71945214",
"0.7176564",
"0.71510875",
"0.707536",
"0.7064484",
"0.7020179",
"0.69581413",
"0.694313",
"0.69076496",
"0.6890829",
"0.6877801",
"0.68639046",
"0.68639046",
"0.6818368",
"0.6794876",
"0.6784059... | 0.7031084 | 10 |
Depopulate created model instances from test database. | def tearDown(self):
for model in MODELS:
for obj in model.objects.all():
obj.delete() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDownClass(cls):\n del cls.my_model.name\n del cls.my_model.my_number\n del cls.my_model_json\n del cls.my_new_model\n del cls.my_model",
"def tearDown(self):\n\n User.objects.all().delete()\n Movie.objects.all().delete()\n Vote.objects.all().delete(... | [
"0.758136",
"0.7500397",
"0.7425634",
"0.74160856",
"0.7365948",
"0.7365948",
"0.73622197",
"0.736108",
"0.736108",
"0.736108",
"0.736108",
"0.736108",
"0.736108",
"0.736108",
"0.736108",
"0.736108",
"0.73534256",
"0.73534256",
"0.73534256",
"0.73534256",
"0.73534256",
"0.7... | 0.7730523 | 1 |
This tests the interestingpapers view ensuring that templates are loaded correctly. This view uses a user with superuser permissions so does not test the permission levels for this view. | def test_interesting_papers_list(self):
test_response = self.client.get('/papers/interesting')
self.assertEqual(test_response.status_code, 200)
self.assertTrue('publication_list' in test_response.context)
self.assertTemplateUsed(test_response, 'paper-list.html')
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_page_view_permission(self):\n \n adminonlypage = create_page_in_admin(self.testproject,\"adminonlypage\",\n permission_lvl=Page.ADMIN_ONLY) \n registeredonlypage = create_page_in_admin(self.testproject,\"registeredonlypage\",\n ... | [
"0.6832036",
"0.68127364",
"0.6588426",
"0.6494909",
"0.62418115",
"0.6237851",
"0.62155795",
"0.61925304",
"0.6186986",
"0.6172822",
"0.6134453",
"0.61182284",
"0.6093548",
"0.6081169",
"0.60538304",
"0.60377485",
"0.6026566",
"0.6023218",
"0.6001635",
"0.59946483",
"0.59896... | 0.6212353 | 7 |
This tests the paperedit view, ensuring that templates are loaded correctly. This view uses a user with superuser permissions so does not test the permission levels for this view. | def test_publication_view_edit(self):
test_response = self.client.get('/papers/14-3-3-proteins-a-number-of-functions-for-a-numbered-protein/edit/')
self.assertEqual(test_response.status_code, 200)
self.assertTrue('publication' in test_response.context)
self.assertTemplat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_commentary_view_edit(self):\n \n test_response = self.client.get('/papers/commentary/1/edit')\n self.assertEqual(test_response.status_code, 200)\n self.assertTrue('commentary' in test_response.context) \n self.assertTemplateUsed(test_response, 'base.html')\n ... | [
"0.66442543",
"0.6544082",
"0.65439016",
"0.6511935",
"0.6367015",
"0.633626",
"0.6318786",
"0.630313",
"0.62360007",
"0.62089336",
"0.6202265",
"0.6192673",
"0.61917275",
"0.61622",
"0.61395234",
"0.6129105",
"0.604815",
"0.60466224",
"0.6038391",
"0.6018163",
"0.60102975",
... | 0.70989627 | 0 |
This tests the paperdelete view, ensuring that templates are loaded correctly. This view uses a user with superuser permissions so does not test the permission levels for this view. | def test_publication_view_delete(self):
test_response = self.client.get('/papers/14-3-3-proteins-a-number-of-functions-for-a-numbered-protein/delete/')
self.assertEqual(test_response.status_code, 200)
self.assertTrue('publication' in test_response.context)
self.assertTem... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_commentary_view_delete(self):\n \n test_response = self.client.get('/papers/commentary/1/delete')\n self.assertEqual(test_response.status_code, 200)\n self.assertTrue('object' in test_response.context) \n self.assertTemplateUsed(test_response, 'base.html')\n ... | [
"0.7682522",
"0.7178068",
"0.7134608",
"0.6900322",
"0.688068",
"0.67493707",
"0.6711513",
"0.669943",
"0.66897756",
"0.6649206",
"0.65975463",
"0.65892994",
"0.65785265",
"0.65309584",
"0.6514532",
"0.6490004",
"0.6480152",
"0.6477764",
"0.64733154",
"0.64664114",
"0.6465322... | 0.7492348 | 1 |
Depopulate created model instances from test database. | def tearDown(self):
for model in MODELS:
for obj in model.objects.all():
obj.delete() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDownClass(cls):\n del cls.my_model.name\n del cls.my_model.my_number\n del cls.my_model_json\n del cls.my_new_model\n del cls.my_model",
"def tearDown(self):\n\n User.objects.all().delete()\n Movie.objects.all().delete()\n Vote.objects.all().delete(... | [
"0.758136",
"0.7500397",
"0.7425634",
"0.74160856",
"0.7365948",
"0.7365948",
"0.73622197",
"0.736108",
"0.736108",
"0.736108",
"0.736108",
"0.736108",
"0.736108",
"0.736108",
"0.736108",
"0.736108",
"0.73534256",
"0.73534256",
"0.73534256",
"0.73534256",
"0.73534256",
"0.7... | 0.7730523 | 2 |
This tests the commentarynew view, ensuring that templates are loaded correctly. This view uses a user with superuser permissions so does not test the permission levels for this view. | def test_commentary_view_create(self):
test_response = self.client.get('/papers/commentary/new')
self.assertEqual(test_response.status_code, 200)
self.assertTemplateUsed(test_response, 'base.html')
self.assertTemplateUsed(test_response, 'commentary-form.html') ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_profile_route_uses_right_templates(self):\n self.add_testuser()\n response = self.client.get(\"/profile/testuser/\")\n self.assertTemplateUsed(response, \"layout.html\")",
"def test_commentary_view(self):\n test_response = self.client.get('/papers/commentary/1')\n self... | [
"0.679294",
"0.6665954",
"0.6585879",
"0.6523216",
"0.6512105",
"0.6505873",
"0.64778113",
"0.64214075",
"0.64111245",
"0.63895273",
"0.6324886",
"0.6293418",
"0.62776166",
"0.62763447",
"0.62307525",
"0.62134814",
"0.62074256",
"0.6199537",
"0.6096931",
"0.60879636",
"0.6084... | 0.7508853 | 0 |
This tests the commentaryedit view, ensuring that templates are loaded correctly. This view uses a user with superuser permissions so does not test the permission levels for this view. | def test_commentary_view_edit(self):
test_response = self.client.get('/papers/commentary/1/edit')
self.assertEqual(test_response.status_code, 200)
self.assertTrue('commentary' in test_response.context)
self.assertTemplateUsed(test_response, 'base.html')
self.asse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_render_user_with_can_edit_reviewrequest(self) -> None:\n self.assertTrue(self.action.should_render(\n context=self._create_request_context(user=self.create_user())))",
"def test_should_render_with_superuser_in_read_only(self) -> None:\n self.request.user = User.objects.ge... | [
"0.67066795",
"0.66197884",
"0.6609125",
"0.6596131",
"0.653988",
"0.647336",
"0.64663714",
"0.6458923",
"0.64401823",
"0.6437847",
"0.6382889",
"0.6372696",
"0.6356236",
"0.6337172",
"0.63254774",
"0.6318",
"0.6290618",
"0.62858534",
"0.62845945",
"0.6282802",
"0.62639505",
... | 0.7767911 | 0 |
This tests the commentarydelete view, ensuring that templates are loaded correctly. This view uses a user with superuser permissions so does not test the permission levels for this view. | def test_commentary_view_delete(self):
test_response = self.client.get('/papers/commentary/1/delete')
self.assertEqual(test_response.status_code, 200)
self.assertTrue('object' in test_response.context)
self.assertTemplateUsed(test_response, 'base.html')
self.asse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_permission(self):\r\n self.assertFalse(self.creator_admin.has_delete_permission(self.request))",
"def test_delete_but_no_view_permission(client):\n user = user_with_permissions(\"polls.delete_poll\")\n\n url = reverse(\"admin:index\")\n client.force_login(user)\n\n response = c... | [
"0.72494507",
"0.71877366",
"0.7066156",
"0.6988958",
"0.6913904",
"0.6863925",
"0.68577117",
"0.6855996",
"0.6792017",
"0.6751739",
"0.6742535",
"0.67331016",
"0.67301214",
"0.66970336",
"0.6664086",
"0.66266763",
"0.65978837",
"0.6597047",
"0.6591526",
"0.6584399",
"0.65843... | 0.83912665 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.