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 |
|---|---|---|---|---|---|---|
A sort function based on atom invariants with two levels of currying. To get the sort value for a specific key, use srt_val = sort_evaluator_atom_invariants_(gra)(idx_dct)(key) My reasoning for doing things this way is that `gra` never changes, but `idx_dct` does, so we need to be able to update the function with new i... | def sort_evaluator_atom_invariants_(gra):
def _replace_none(val):
return numpy.inf if val is None else val
def _hill_normalize_symbol(symb):
""" normalize atomic symbols to make them sort according to the hill
system
(C first, H second, others in alphabetical order)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_evaluator_tie_breaking_(gra):\n\n ngb_keys_dct = atoms_neighbor_atom_keys(gra)\n\n def _evaluator(idx_dct):\n \"\"\" Sort value evaluator based on current class indices.\n\n :param idx_dct: A dictionary mapping atom keys to class indices.\n :type idx_dct: dict\n \... | [
"0.65632385",
"0.58690524",
"0.58640504",
"0.5782884",
"0.5318834",
"0.52297586",
"0.5185493",
"0.50805277",
"0.507752",
"0.5069886",
"0.5059814",
"0.5052812",
"0.5018518",
"0.49884316",
"0.4988415",
"0.49764782",
"0.49626407",
"0.49516916",
"0.4943658",
"0.4943658",
"0.49229... | 0.637536 | 1 |
Behaves like a numpy "where" function, but specifically for use with images and image stacks. Thus, the mask can be a single layer image (i.e. a 2d array), but the true and false values can be multilayer image stacks (i.e. 3d arrays, where the first dimension is layer number, and the other two dimensions must match tho... | def stackwhere(mask, trueVal, falseVal):
if numpy.isscalar(mask):
raise ScalarMaskError("Mask is a scalar - this needs an array")
if mask.ndim != 2:
raise NotImageError("Function only works with images. Shape of mask is %s"%(mask.shape,))
inputList = [trueVal, falseVal]
nLayers... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interpretMasks(masks,shape=None):\n if isinstance(masks,np.ndarray): return masks.astype(bool)\n # make iterable\n if not isinstance( masks, (list,tuple,np.ndarray) ): masks = (masks,)\n masks = [interpretMask(mask,shape) for mask in masks]\n # put them all together\n mask = masks[0]\n for m in masks[1:... | [
"0.6720698",
"0.6656984",
"0.65075684",
"0.6454975",
"0.6447126",
"0.6286134",
"0.6211682",
"0.6135647",
"0.6135054",
"0.6092325",
"0.60488135",
"0.6035089",
"0.602819",
"0.60220677",
"0.60081536",
"0.60031384",
"0.5987173",
"0.5942535",
"0.5912286",
"0.5899735",
"0.5853444",... | 0.7597031 | 0 |
This function is almost entirely redundant, and should be replaced with numpy.bincount(). This function now uses that instead. Please use that directly, instead of this. The only difference is the treatment of null values (bincount() does not treat them in any special way, whereas this function allows a nullVal to be s... | def clumpsizes(clumps, nullVal=0):
counts = numpy.bincount(clumps.flatten())
counts[nullVal] = nullVal
return counts | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bins_from_image(path):\n _, Y = util.imread(path)\n closest_bins = util.closest_bins(Y).flatten()\n count = np.zeros(len(util.bins))\n for closest_bin in closest_bins:\n count[closest_bin] += 1\n return count",
"def clumpsizeimg(clumps, nullVal=0):\n sizes = clumpsizes(clumps, nullVa... | [
"0.6477456",
"0.61598325",
"0.59448224",
"0.5792406",
"0.5788697",
"0.5746568",
"0.5691372",
"0.56194603",
"0.5614608",
"0.5577839",
"0.54668534",
"0.54650104",
"0.54650104",
"0.5438217",
"0.54214793",
"0.53953457",
"0.5374179",
"0.53456384",
"0.53153753",
"0.5310672",
"0.529... | 0.7353158 | 0 |
Return a set of indexes into the original array, for which the value in the array is equal to val. | def getIndexes(self, val):
# Find where this value is listed.
valNdx = (self.values == val).nonzero()[0]
# If this value is not actually in those listed, then we
# must return empty indexes
if len(valNdx) == 0:
start = 0
end = 0
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findall(lo,val):\n\tu = []\n\ti = -1\n\twhile( i < len(lo)-1):\n\t\ttry:\n\t\t\ti = lo.index(val,i+1)\n\t\t\tu.append(i)\n\t\texcept:\n\t\t\ti += 1\n\treturn u",
"def find_uniques_consecutive(array):\n val = array[0]\n indices = []\n for idx, element in enumerate(array):\n if element != val:... | [
"0.6350823",
"0.6033352",
"0.6029377",
"0.59946907",
"0.59682155",
"0.5938296",
"0.5789151",
"0.5723909",
"0.5686986",
"0.5550713",
"0.55193883",
"0.5488767",
"0.5487777",
"0.54783887",
"0.54756665",
"0.54299986",
"0.5389058",
"0.5381364",
"0.53740776",
"0.5356309",
"0.535044... | 0.7262786 | 0 |
Yield successive nsized chunks from l. | def chunks(l, n):
for i in range(0, len(l), n):
yield l[i:i + n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _chunk(self, l, n):\n for i in range(0, len(l) + 1, n):\n yield l[i:i + n]",
"def chunks(self, l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def __chunks(l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def get_chunks(self, ... | [
"0.8038813",
"0.79248375",
"0.7923423",
"0.7885103",
"0.78773195",
"0.7815877",
"0.77655786",
"0.77556044",
"0.77441615",
"0.7731815",
"0.77288336",
"0.772473",
"0.77028215",
"0.76889825",
"0.76889825",
"0.7664208",
"0.76570904",
"0.7655856",
"0.7655856",
"0.76458347",
"0.764... | 0.7448925 | 86 |
As in the exact GP setting, the userdefined forward method should return the GP prior mean and covariance evaluated at input locations x. | def forward(self, x):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, x):\n mean_x = self.mean_module(x) # Compute the mean at x\n covar_x = self.covar_module(x) # Compute the covariance at x\n return MultivariateNormal(mean_x, covar_x)",
"def forward(self, x):\n mean_x = self.mean_module(x) # Compute the mean at x\n covar_x ... | [
"0.7268049",
"0.7268049",
"0.7161776",
"0.7146092",
"0.7040963",
"0.69923174",
"0.6974504",
"0.69418454",
"0.68519306",
"0.68519306",
"0.6646959",
"0.6620005",
"0.6425912",
"0.6419023",
"0.6414215",
"0.64008135",
"0.6359986",
"0.63190264",
"0.6316423",
"0.6296698",
"0.629185"... | 0.63131964 | 20 |
Returns the dataset version object with the specified version_id for the current dataset_id | def list_dataset_version(self, version_id):
assert self.dataset_id, 'dataset_id required!'
return self._datasets_request('GET', dataset_id=self.dataset_id, versions_request=True,
version_id=version_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_version(self, id):\n if id in self.loaded_vsns:\n return self.loaded_vsns[id]\n for v in self.versions:\n if v['id'] == id:\n vsn = Version.load(self.backend, self.path, v['id'], v['name'])\n self.loaded_vsns[v['id']] = vsn\n ... | [
"0.6634275",
"0.6593017",
"0.64242977",
"0.6106608",
"0.60769516",
"0.60729885",
"0.6035799",
"0.59063965",
"0.5889052",
"0.5840798",
"0.5805381",
"0.5778593",
"0.57599527",
"0.57458377",
"0.5728628",
"0.5700211",
"0.56702423",
"0.5602366",
"0.5602366",
"0.5585361",
"0.558360... | 0.6236687 | 3 |
Takes a Mixpanel People profile and returns a datetime object for the $last_seen value or datetime.min if $last_seen is not set | def _dt_from_iso(profile):
dt = datetime.datetime.min
try:
last_seen = profile["$properties"]["$last_seen"]
try:
# Try to use the MUCH faster ciso8601 library, if it's not installed use the built-in datetime library
dt = ciso8601.parse_datetime_una... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_seen_minutes(self):\n return (self.last_seen.seconds % 3600) / 60",
"def last_activity(self):\n\t\tif not self.lastseen:\n\t\t\treturn 'nooit'\n\n\t\t# this was once made by myself (Erick)\n\t\t# return self.lastseen.strftime(\"%d %B %Y, %H:%M:%S\")\n\n\t\t# this is later added by the author of t... | [
"0.5964214",
"0.5881221",
"0.5877265",
"0.58060056",
"0.5800367",
"0.5711578",
"0.564688",
"0.557517",
"0.5552749",
"0.5548245",
"0.55346704",
"0.55032235",
"0.5474667",
"0.54727954",
"0.54727954",
"0.54694116",
"0.5457139",
"0.54315126",
"0.53945136",
"0.53869355",
"0.538336... | 0.58778185 | 2 |
Return the base quantity of the line to be used for the subtotal. This function can be extended by other modules to modify this base quantity (adding for example offers 3x2 and so on). | def _calc_line_quantity(self, cr, uid, line, context=None):
return line.product_qty | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _calc_line_base_price(self, cr, uid, line, context=None):\n return line.price_unit",
"def get_total(self):\n\n subtotal = super(InternationalMelonOrder, self).get_total()\n if self.qty < 10:\n total = subtotal + 3\n\n return total",
"def line_cost(self):\r\n re... | [
"0.7170491",
"0.6790378",
"0.6618547",
"0.6488592",
"0.64720005",
"0.6456542",
"0.64519984",
"0.6374224",
"0.6352548",
"0.6341283",
"0.62961364",
"0.6276024",
"0.6254007",
"0.6173362",
"0.6168507",
"0.61067265",
"0.60816056",
"0.60749924",
"0.6049154",
"0.60138255",
"0.593514... | 0.7094024 | 1 |
Sets the success of this AddUserResponse. | def success(self, success):
if success is None:
raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501
self._success = success | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def success(self, success):\n self._success = success",
"def has_success(self, value: bool):\n self._has_success = value",
"def success(self):\n self.succeeded = True",
"def success(self):\n return self._success",
"def indicate_success(self):\n pass",
"def addSuccess(se... | [
"0.7347533",
"0.6732271",
"0.6670637",
"0.659846",
"0.6455726",
"0.6348484",
"0.6331572",
"0.6291924",
"0.61139864",
"0.6097529",
"0.6090971",
"0.59581167",
"0.5939325",
"0.58759016",
"0.5822311",
"0.5797745",
"0.57823217",
"0.5768823",
"0.5747764",
"0.5726224",
"0.57241315",... | 0.68870956 | 1 |
Sets the invite of this AddUserResponse. | def invite(self, invite):
self._invite = invite | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invite_user(session, invitee):\n session.invite_event.clear()\n key = b64encode(messaging.common.pkc_encrypt(\n session.get_channel_key(), session.get_encryption_cert(invitee))).decode()\n msg = {\n kk.typ: kk.add_user,\n kk.inviter: session.user,\n kk.invitee: invitee,\n ... | [
"0.58484644",
"0.57977664",
"0.543336",
"0.5418577",
"0.5307704",
"0.52966595",
"0.52908415",
"0.5261979",
"0.5259007",
"0.5255082",
"0.5245264",
"0.5225261",
"0.51780236",
"0.517214",
"0.516792",
"0.5167428",
"0.51581633",
"0.51581633",
"0.5125719",
"0.50482315",
"0.5008588"... | 0.7290984 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, AddUserResponse):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.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 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
plt.imshow(cm, interpolation='nearest', cmap=cmap)
plt.title(title)
plt.colorbar()
tick_marks = np.arange(len(classes))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.8194862",
"0.80949175",
"0.8029915",
"0.8019153",
"0.79941195",
"0.7991258",
"0.7980955",
"0.7976606",
"0.79610753",
"0.79590565",
"0.79378676",
"0.7934962",
"0.7934504",
"0.79313844",
"0.7926313",
"0.7924577",
"0.79241234",
"0.7923211",
"0.7923023",
"0.7921931",
"0.791787... | 0.78436774 | 54 |
Returns the name of this asset. It does not have to be globally unique. | def get_name(self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n\t\treturn self.asset.name",
"def get_name(self):\n return self._assets[0].get_name()",
"def assetName(self):\n\t\treturn self._assetName",
"def get_name(self, asset):\n return self.get_name_and_meta(asset)[0]",
"def name(self):\n return self.raw_resource[\"name\"]",
... | [
"0.88368416",
"0.87098813",
"0.86980927",
"0.81537056",
"0.73748",
"0.7307148",
"0.72069603",
"0.71628207",
"0.71422666",
"0.7140423",
"0.7132671",
"0.7107853",
"0.7107853",
"0.7099258",
"0.709134",
"0.709134",
"0.709134",
"0.70817596",
"0.7071332",
"0.7071332",
"0.7071332",
... | 0.0 | -1 |
Returns the filesystem path of this asset. | def get_path(self):
raise NotImplementedError("This asset does not support absolute paths") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path(self):\n return self.file_path()",
"def get_path(self):\n try:\n return self._file.path\n except AttributeError:\n return os.path.abspath(self._file.name)",
"def path(self):\n return self.storage.path(self.name)",
"def getPath(self):\n path = ... | [
"0.7775341",
"0.7743813",
"0.77063227",
"0.76972",
"0.75553834",
"0.754447",
"0.7414948",
"0.7414948",
"0.7414948",
"0.7414948",
"0.7404819",
"0.73313427",
"0.73265743",
"0.73218024",
"0.731966",
"0.731966",
"0.7308446",
"0.7300631",
"0.72867125",
"0.72832084",
"0.7273043",
... | 0.8134437 | 0 |
Returns the contents of this asset as a string. | def get_contents(self):
with closing(self.open()) as handle:
return handle.read() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_contents(self):\n return force_bytes(self.join_str).join(asset.get_contents() for asset in self._assets)",
"def contents(self) -> str:\n return(self._contents)",
"def contents(self) -> str:\n return pulumi.get(self, \"contents\")",
"def text(self) -> str:\n return self.loa... | [
"0.7997895",
"0.76065254",
"0.7405697",
"0.73060083",
"0.72262096",
"0.69293493",
"0.6895529",
"0.6861676",
"0.6781436",
"0.67798537",
"0.67668617",
"0.6741983",
"0.6741983",
"0.6741983",
"0.67251444",
"0.6631756",
"0.6607297",
"0.6591949",
"0.6590127",
"0.6577935",
"0.655612... | 0.69191575 | 6 |
Returns the name of this static asset. | def get_name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n\t\treturn self.asset.name",
"def assetName(self):\n\t\treturn self._assetName",
"def get_name(self):\n return self._assets[0].get_name()",
"def get_name(self, asset):\n return self.get_name_and_meta(asset)[0]",
"def name(self):\n return self.raw_resource[\"name\"]",
... | [
"0.8792987",
"0.8548125",
"0.85241765",
"0.77939516",
"0.7334299",
"0.7194273",
"0.7103713",
"0.7079433",
"0.70613277",
"0.70120585",
"0.6909553",
"0.68544364",
"0.68142456",
"0.6813276",
"0.6797265",
"0.6784841",
"0.6784841",
"0.6784841",
"0.6784841",
"0.6784841",
"0.6784841... | 0.0 | -1 |
Returns the path of this static asset. | def get_path(self):
return StaticAsset.get_static_path(self._name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assets_path(self) -> str:\n return self._assets_path",
"def get_path(self):\n raise NotImplementedError(\"This asset does not support absolute paths\")",
"def get_path_static(self):\n\n return self._path_static",
"def _path(self):\n path = REQUIRES['static_url']\n\n # a... | [
"0.8258193",
"0.82043314",
"0.8130369",
"0.81185204",
"0.75715476",
"0.753055",
"0.7483479",
"0.74327946",
"0.74272054",
"0.7284624",
"0.7284624",
"0.7206156",
"0.71987224",
"0.7190884",
"0.71671766",
"0.71449924",
"0.71449924",
"0.71449924",
"0.71449924",
"0.71405506",
"0.71... | 0.9167154 | 0 |
Returns the name of this asset. | def get_name(self):
return self._file.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n\t\treturn self.asset.name",
"def get_name(self):\n return self._assets[0].get_name()",
"def assetName(self):\n\t\treturn self._assetName",
"def get_name(self, asset):\n return self.get_name_and_meta(asset)[0]",
"def name(self):\n return self.raw_resource[\"name\"]",
... | [
"0.9104021",
"0.8910468",
"0.88929474",
"0.82623625",
"0.78062207",
"0.77111185",
"0.7517854",
"0.7508444",
"0.750551",
"0.74846256",
"0.74846256",
"0.74751496",
"0.74687195",
"0.746039",
"0.746039",
"0.746039",
"0.746039",
"0.746039",
"0.746039",
"0.746039",
"0.746039",
"0... | 0.7686967 | 6 |
Returns the path of this asset. | def get_path(self):
try:
return self._file.path
except AttributeError:
return os.path.abspath(self._file.name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_path(self):\n raise NotImplementedError(\"This asset does not support absolute paths\")",
"def assets_path(self) -> str:\n return self._assets_path",
"def get_path(self):\n return StaticAsset.get_static_path(self._name)",
"def path(self):\n return self.file_path()",
"def... | [
"0.8646309",
"0.8323301",
"0.81062824",
"0.79963243",
"0.776395",
"0.776395",
"0.776395",
"0.776395",
"0.7748458",
"0.77221406",
"0.77221406",
"0.7717903",
"0.7702664",
"0.77021796",
"0.76926374",
"0.7650192",
"0.7650192",
"0.7650192",
"0.7650192",
"0.7650192",
"0.7650192",
... | 0.7981885 | 4 |
Returns the URL of this asset. | def get_url(self):
try:
return self._file.url
except AttributeError:
raise NotImplementedError("Underlying file does not have a URL.") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_url(self):\n raise NotImplementedError(\"This asset does not have a URL\")",
"def get_url(self):\n return self.resource.url",
"def get_url(self):\n return staticfiles_storage.url(self._name)",
"def url(self):\n return self.storage.url(self.name)",
"def url(self):\n ... | [
"0.8741558",
"0.7977144",
"0.7704273",
"0.76905286",
"0.76369196",
"0.7582901",
"0.7582901",
"0.7582901",
"0.7580033",
"0.75568366",
"0.75175273",
"0.75175273",
"0.74972475",
"0.7489297",
"0.7489297",
"0.7489297",
"0.74526656",
"0.7448423",
"0.7439237",
"0.74375445",
"0.74375... | 0.7484989 | 16 |
Returns the name of this asset. | def get_name(self):
return self._assets[0].get_name() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n\t\treturn self.asset.name",
"def assetName(self):\n\t\treturn self._assetName",
"def get_name(self, asset):\n return self.get_name_and_meta(asset)[0]",
"def name(self):\n return self.raw_resource[\"name\"]",
"def name(self):\n\n return self.resource[\"metadata\"][\"na... | [
"0.9104021",
"0.88929474",
"0.82623625",
"0.78062207",
"0.77111185",
"0.7686967",
"0.7517854",
"0.7508444",
"0.750551",
"0.74846256",
"0.74846256",
"0.74751496",
"0.74687195",
"0.746039",
"0.746039",
"0.746039",
"0.746039",
"0.746039",
"0.746039",
"0.746039",
"0.746039",
"0... | 0.8910468 | 1 |
Get transaction based on global ID. The transactions created before 3.13 were using the `id` field as a graphql ID. From 3.13, the `token` is used as a graphql ID. All transactionItems created before 3.13 will use an `int` id as an identification. | def get_transaction_item(id: str) -> payment_models.TransactionItem:
_, db_id = from_global_id_or_error(
global_id=id, only_type=TransactionItem, raise_error=True
)
if db_id.isdigit():
query_params = {"id": db_id, "use_old_id": True}
else:
query_params = {"token": db_id}
inst... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transaction(self, transaction_id: str):\n return get_from_list(self.transactions, \"id\", transaction_id)",
"def get_transaction(self, transaction_id: str) -> Transaction:\n return self.session.get_transaction(\n transaction_id=transaction_id,\n account_or_account_id=self.... | [
"0.7182398",
"0.66852194",
"0.6661184",
"0.65961564",
"0.63018525",
"0.6162794",
"0.597061",
"0.5821919",
"0.5809847",
"0.5788191",
"0.5758648",
"0.57487965",
"0.5701015",
"0.5701015",
"0.56982726",
"0.5675578",
"0.5630243",
"0.5625807",
"0.56230783",
"0.5602318",
"0.5583108"... | 0.7261358 | 0 |
Return a dict with the JWT header. | def jwt_header(cert):
header = {}
header["alg"] = "RS256"
header["x5c"] = cert
return header | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_headers(self):\n return {\n 'Authorization': 'JWT {}'.format(self.token)\n }",
"def header_token(token):\n return {'Authorization': '{0} {1}'.format('JWT', token)}",
"def get_jwt_header(self):\n if self.jwt_header:\n return self.jwt_header\n self.jwt... | [
"0.78672564",
"0.76048833",
"0.75601816",
"0.75265014",
"0.75215816",
"0.7496575",
"0.7466042",
"0.717248",
"0.69983655",
"0.69623685",
"0.69099456",
"0.69099456",
"0.6902243",
"0.689437",
"0.68754226",
"0.6841986",
"0.68239945",
"0.6799475",
"0.6796957",
"0.6766815",
"0.6740... | 0.7222181 | 7 |
Return a serialized webpadlock JWT with indicated claims. | def create_jwt(key, cert, systeminfo, metadata, requestdata):
claims = {}
claims["iat"] = int(time.time())
claims["systeminfo"] = systeminfo
claims["metadata"] = metadata
claims["requestdata"] = requestdata
logging.debug("Claims:{}".format(json_encode(claims)))
token = jwt.JWT(header=json... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_jwt(self, audience: List[str], additional_claims=None) -> str:\n iat = time.time()\n exp = iat + self.lifetime\n payload = additional_claims or {}\n payload.update({'iss': self.credentials[\"client_email\"],\n 'sub': self.credentials[\"client_email\"],\... | [
"0.68677706",
"0.67910427",
"0.672376",
"0.6498315",
"0.6493711",
"0.6462371",
"0.64327574",
"0.6417863",
"0.6397847",
"0.6331286",
"0.6330385",
"0.6328132",
"0.6311513",
"0.6298532",
"0.6286201",
"0.628251",
"0.6252226",
"0.6200429",
"0.6192745",
"0.61757296",
"0.61696976",
... | 0.63573235 | 9 |
Performs spatial binning on the image | def bin_spatial(img, size=(32, 32)):
color1 = cv2.resize(img[:, :, 0], size).ravel()
color2 = cv2.resize(img[:, :, 1], size).ravel()
color3 = cv2.resize(img[:, :, 2], size).ravel()
return np.hstack((color1, color2, color3)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binarize(self, image):\n\n [rows, columns] = np.shape(image)\n bin_img = np.zeros((rows, columns), dtype=int)\n print(\"############## Using to binarize an image ##############\")\n hist = self.compute_histogram(image)\n threshold = self.find_optimal_threshold(hist)\n ... | [
"0.69352764",
"0.67242974",
"0.66985327",
"0.6591239",
"0.65750676",
"0.6558917",
"0.648409",
"0.64626867",
"0.6425198",
"0.62866664",
"0.62821645",
"0.6242868",
"0.621549",
"0.6211732",
"0.61565405",
"0.61213773",
"0.608945",
"0.6088147",
"0.6065089",
"0.60457504",
"0.601457... | 0.65748274 | 5 |
Draw rectangular coloured boxes onto an image. | def draw_boxes(img, bboxes, color=(0, 0, 255), thick=6):
# make a copy of the image
imcopy = np.copy(img)
# draw each bounding box on your image copy using cv2.rectangle()
# Iterate through the bounding boxes
for bbox in bboxes:
# Draw a rectangle given bbox coordinates
cv2.rectangle... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_box(image, boxes, box_color=(255, 255, 255)):\r\n for box in boxes:\r\n cv2.rectangle(image,\r\n (box[0], box[1]),\r\n (box[2], box[3]), box_color)",
"def draw_box(image, boxes, box_color=(255, 255, 255)):\r\n for box in boxes:\r... | [
"0.8174154",
"0.8163013",
"0.79130167",
"0.7851427",
"0.7782174",
"0.7781999",
"0.7730505",
"0.76477087",
"0.7533017",
"0.7439384",
"0.7408217",
"0.7371097",
"0.73204786",
"0.7278721",
"0.7231273",
"0.7228998",
"0.72134227",
"0.72033316",
"0.71726686",
"0.7159462",
"0.7147471... | 0.77926165 | 4 |
Remove falsepositive detections by replacing pixel values with 0 if fall below threshold | def apply_threshold(heatmap, threshold):
# Zero out pixels below the threshold
heatmap[heatmap <= threshold] = 0
# Return thresholded map
return heatmap | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_negative_pixels(spectra, verbose = True):\n cuenta=0\n\n output=copy.deepcopy(spectra) \n for fibre in range(len(spectra)):\n vector_ = spectra[fibre] \n stats_=basic_statistics(vector_, return_data=True, verbose=False)\n #rss.low_cut.append(stats_[1])\n if ... | [
"0.67948526",
"0.6484627",
"0.6470356",
"0.63842785",
"0.6322157",
"0.6281308",
"0.62614936",
"0.6259919",
"0.6245503",
"0.61781514",
"0.6142475",
"0.60975796",
"0.60947573",
"0.606705",
"0.60414135",
"0.6041099",
"0.60358024",
"0.6028124",
"0.5985563",
"0.5962509",
"0.594914... | 0.6552138 | 3 |
Draw bounding box around detected cars in image. | def draw_labeled_bboxes(img, labels):
# Iterate through all detected cards
for car_number in range(1, labels[1] + 1):
# Find pixels with each car_number label value
nonzero = (labels[0] == car_number).nonzero()
# Identify x and y values of those pixels
nonzeroy = np.array(nonzero... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_boxes_cars(img, vehicles_instance):\n\n for car_number in range(1, vehicles_instance.number_of_found_cars+1):\n # Find pixels with each car_number label value\n nonzero = (vehicles_instance.binary_map == car_number).nonzero()\n\n # Identify x and y values of those pixels\n n... | [
"0.7903878",
"0.7662961",
"0.7660024",
"0.7120174",
"0.7074927",
"0.6869783",
"0.68175775",
"0.6774906",
"0.67253506",
"0.67119396",
"0.66968006",
"0.66665673",
"0.66656303",
"0.66420275",
"0.6626208",
"0.6620684",
"0.66203547",
"0.6616798",
"0.658893",
"0.6588098",
"0.658493... | 0.7412568 | 3 |
Remove falsepositive detections by replacing pixel values with 0 if fall below threshold | def apply_threshold(heatmap, threshold):
# Zero out pixels below the threshold
heatmap[heatmap <= threshold] = 0
# Return thresholded map
return heatmap | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_negative_pixels(spectra, verbose = True):\n cuenta=0\n\n output=copy.deepcopy(spectra) \n for fibre in range(len(spectra)):\n vector_ = spectra[fibre] \n stats_=basic_statistics(vector_, return_data=True, verbose=False)\n #rss.low_cut.append(stats_[1])\n if ... | [
"0.6795012",
"0.64846975",
"0.64702564",
"0.6384712",
"0.6322283",
"0.6281199",
"0.62616825",
"0.6258485",
"0.62447816",
"0.6179284",
"0.6141829",
"0.6096656",
"0.6094723",
"0.6066307",
"0.60423833",
"0.604138",
"0.60367715",
"0.60282224",
"0.59844124",
"0.5962889",
"0.594859... | 0.6552291 | 2 |
Draw bounding box around detected cars in image. | def draw_labeled_bboxes(img, labels):
# Iterate through all detected cars
for car_number in range(1, labels[1] + 1):
# Find pixels with each car_number label value
nonzero = (labels[0] == car_number).nonzero()
# Identify x and y values of those pixels
nonzeroy = np.array(nonzero[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_boxes_cars(img, vehicles_instance):\n\n for car_number in range(1, vehicles_instance.number_of_found_cars+1):\n # Find pixels with each car_number label value\n nonzero = (vehicles_instance.binary_map == car_number).nonzero()\n\n # Identify x and y values of those pixels\n n... | [
"0.7903878",
"0.7662961",
"0.7412568",
"0.7120174",
"0.7074927",
"0.6869783",
"0.68175775",
"0.6774906",
"0.67253506",
"0.67119396",
"0.66968006",
"0.66665673",
"0.66656303",
"0.66420275",
"0.6626208",
"0.6620684",
"0.66203547",
"0.6616798",
"0.658893",
"0.6588098",
"0.658493... | 0.7660024 | 2 |
Initializes the BoEW model and the centers of the entropy | def init(self, data, mask, labels):
self.nbof.initialize_dictionary(self.emb.get_value())
S = self.encode(data, mask)
self.entropy_loss.init_centers(S, labels) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(self):\r\n constant_init(self.sampling_offsets, 0.)\r\n thetas = torch.arange(\r\n self.num_heads,\r\n dtype=torch.float32) * (2.0 * math.pi / self.num_heads)\r\n grid_init = torch.stack([thetas.cos(), thetas.sin()], -1)\r\n grid_init = (grid_init ... | [
"0.65069497",
"0.6476305",
"0.6429061",
"0.6371071",
"0.631411",
"0.6288959",
"0.6226542",
"0.6213154",
"0.6134072",
"0.6134072",
"0.6134072",
"0.61204386",
"0.6119046",
"0.61001116",
"0.60997087",
"0.60775656",
"0.60630065",
"0.6043297",
"0.6042457",
"0.60399723",
"0.6005389... | 0.6910232 | 0 |
(list, object) > int Return the index of the first occurence of value in lst, or return 1 if value is not in lst. >>>linear_search([2, 5, 1, 3], 5) 1 >>>linear_search([2, 4, 2], 2) 0 >>>linear_search([], 5) 1 | def linear_search(lst, value):
i = 0
while i != len(lst) and lst[i] != value:
i = i + 1
if i == len(lst):
return -1
else:
return i | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linear_search(list, target):\n for i in range (0, len(list)):\n if list[i] == target:\n return i\n\n\n return None",
"def linear_search(self, num_lst, key):\r\n # Running time: O(n)\r\n for i in range(len(num_lst)):\r\n if num_lst[i] == key:\r\n ... | [
"0.80147535",
"0.78874797",
"0.77700174",
"0.77680653",
"0.7680366",
"0.7632612",
"0.7601844",
"0.75094604",
"0.7483358",
"0.7414145",
"0.73233014",
"0.72711563",
"0.71523625",
"0.70863545",
"0.7082964",
"0.69862443",
"0.6962535",
"0.69247067",
"0.69242406",
"0.6910896",
"0.6... | 0.81928027 | 0 |
(list, object) > int Return the index of the first occurence of value in lst, or return 1 if value is not in lst. >>>reverse_linear_search([2, 5, 1, 3], 5) 1 >>>reverse_linear_search([2, 4, 2], 2) 2 >>>reverse_linear_search([], 5) 1 | def reverse_linear_search(lst, value):
i = len(lst) - 1
while i != -1 and lst[i] != value:
i = i + 1
if i == -1:
return -1
else:
return i | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linear_search(lst, value):\n i = 0\n while i != len(lst) and lst[i] != value:\n i = i + 1\n if i == len(lst):\n return -1\n else:\n return i",
"def linear_search(list, target):\n for i in range (0, len(list)):\n if list[i] == target:\n return i\n\n\n r... | [
"0.8214037",
"0.7811881",
"0.7678202",
"0.761455",
"0.75719315",
"0.7471751",
"0.74088854",
"0.73942846",
"0.7364708",
"0.7263918",
"0.7109118",
"0.7105341",
"0.68528813",
"0.68333226",
"0.6781125",
"0.67782277",
"0.676876",
"0.67368174",
"0.66790384",
"0.66738766",
"0.664886... | 0.8084179 | 1 |
takes in a list of words (i.e. strings without whitespacing and line breaks) and returns an encoding mapping dictionary where the key is the word and the value is its encoded integer form. | def word_indexer(word_lst):
unique_words = list(set(word_lst))
word_index = {}
for i in range(len(unique_words)):
word_index[unique_words[i].lower()] = i + 4
word_index['<PAD>'] = 0
word_index['<START>'] = 1
word_index['<UNK>'] = 2
word_index['<UNUSED>'] = 3
return word_index | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def words2ints(list_of_strings):\n wordlist = set([])\n for strings in list_of_strings:\n wordlist.update(strings.split())\n w2i = {k: str(v) for v, k in enumerate(wordlist)}\n return w2i",
"def get_encoding_dict(self) -> Dict[str, int]:\n return {k.lower():v for v,k in enumerate(self.v... | [
"0.71335065",
"0.70546436",
"0.65713084",
"0.6417946",
"0.63300884",
"0.62952995",
"0.6162101",
"0.60165703",
"0.5970169",
"0.5933417",
"0.5882145",
"0.5871599",
"0.5848844",
"0.5838343",
"0.5832272",
"0.5813039",
"0.5807773",
"0.57929736",
"0.5771663",
"0.5763371",
"0.571272... | 0.54935 | 35 |
Testing that long file names are restricted. | def test_too_long_filename(assert_errors, filename, default_options):
visitor = WrongModuleNameVisitor(default_options, filename=filename)
visitor.run()
assert_errors(visitor, [TooLongNameViolation]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_trim_too_long_filename(self):\n filename = 'filename'\n extension = '.jpg'\n long_filename = '{}{}'.format(filename * 10, extension)\n\n trimmed_filename = trim_long_filename(long_filename)\n \n self.assertEqual(len(trimmed_filename), FILENAME_MAX_LEN)\n se... | [
"0.75923806",
"0.70382094",
"0.69962835",
"0.69591105",
"0.65800804",
"0.65469855",
"0.6501338",
"0.64421874",
"0.6316836",
"0.624896",
"0.61712444",
"0.6104817",
"0.609867",
"0.6089928",
"0.6018896",
"0.59760225",
"0.5911514",
"0.5858581",
"0.58457077",
"0.58258003",
"0.5816... | 0.70991254 | 1 |
Block the indynode port on a random set of nodes. If the caller requests more nodes than are defined in the genesis file, all nodes will be blocked in random order. State file "block_node_port_random" located in the chaos temp dir (see get_chaos_temp_dir for details) is shared with the following functions block_node_po... | def block_node_port_random(genesis_file: str, count: Union[str,int],
ssh_config_file: str = DEFAULT_CHAOS_SSH_CONFIG_FILE) -> bool:
# TODO: Use the traffic shaper tool Kelly is using.
# http://www.uponmyshoulder.com/blog/2013/simulating-bad-network-conditions-on-linux/
selected = get_random_nodes(genesi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unblock_node_port_random(genesis_file: str,\n transactions: Union[str,int] = None,\n pause_before_synced_check: Union[str,int] = None, best_effort: bool = True,\n did: str = DEFAULT_CHAOS_DID, seed: str = DEFAULT_CHAOS_SEED,\n wallet_name: str = DEFAULT_CHAOS_WALLET_NAME,\n wallet_key: str = DEF... | [
"0.6147834",
"0.5529674",
"0.534016",
"0.5319452",
"0.5303682",
"0.52873224",
"0.5225756",
"0.5204829",
"0.5086431",
"0.501167",
"0.50058776",
"0.5004662",
"0.49958426",
"0.4992787",
"0.4979683",
"0.49729177",
"0.49382117",
"0.49229327",
"0.48967922",
"0.48953432",
"0.4892544... | 0.7204151 | 0 |
Tokenize and encode the text into vectors, then stick inside dataframe | def tokenize_and_encode_pandas(dataframe,stopindex=1e9,max_length=128):
encoded_tweets = []
token_type_ids = []
attention_mask = []
labels_6_types = []
labels_4_types = []
interaction_types = []
counter = 0
for i in range(len(dataframe)):
try:
#tokenized_parent= ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenize_and_explode(args, df):\n df['token'] = df.word.apply(args.tokenizer.tokenize)\n df = df.explode('token', ignore_index=True)\n df['token2word'] = df['token'].apply(\n args.tokenizer.convert_tokens_to_string).str.strip().str.lower()\n df = convert_token_to_idx(df, args.tokenizer)\n ... | [
"0.74359465",
"0.6870086",
"0.67845875",
"0.6613198",
"0.65740705",
"0.6543908",
"0.6414587",
"0.63192683",
"0.6283554",
"0.62768084",
"0.62644124",
"0.62475985",
"0.6224836",
"0.61795366",
"0.6168591",
"0.6140506",
"0.6135231",
"0.6081744",
"0.6077482",
"0.6071361",
"0.59910... | 0.6076772 | 19 |
Returns the stop loss price. The actual stop loss price is calculated from the piven stop. The stop can be set in abosult (default) or in relative values to the price. Please note that the stop must be positive for BUY orders and negative for SELL orders. | def get_stop_loss_price(price, stop, relative_stop=False):
if relative_stop:
sl_price = price - stop
else:
sl_price = abs(stop)
return sl_price | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_stop_loss_price(market_price: float, order_price: float, stop_loss_price: float, side: str):\n if side == 'LONG':\n if not stop_loss_price:\n stop_loss_price = order_price - (order_price / 100) * CONF.stop_loss_in_percent\n if market_price - (market_price / 100) * CONF.sto... | [
"0.7588659",
"0.67977715",
"0.66036975",
"0.64967895",
"0.6380181",
"0.6181023",
"0.61807066",
"0.6105024",
"0.5836369",
"0.58130264",
"0.5792011",
"0.575868",
"0.57421464",
"0.57282007",
"0.5661087",
"0.5573668",
"0.5565466",
"0.55639017",
"0.5516268",
"0.5503601",
"0.547843... | 0.8425858 | 0 |
Returns the risk per unit as difference of the current price minus the stop loss price. | def get_risk_per_unit(price, sl_price):
return abs(price - sl_price) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_stop_loss_price(price, stop, relative_stop=False):\n if relative_stop:\n sl_price = price - stop\n else:\n sl_price = abs(stop)\n return sl_price",
"def price_diff(self):\n try:\n return(self.price_close - self.price_open)\n except:\n return",
... | [
"0.69525164",
"0.6895973",
"0.6526148",
"0.6493237",
"0.6306785",
"0.6159353",
"0.6158534",
"0.6129895",
"0.6122254",
"0.6116348",
"0.61020094",
"0.6072795",
"0.5979309",
"0.59288216",
"0.5919011",
"0.58988154",
"0.58616847",
"0.58564967",
"0.5855779",
"0.5827925",
"0.5827925... | 0.7527504 | 0 |
sets the Sprite to dead | def set_dead(self):
assert self.health < 0, "Health is not less than 0, Sprite should not be dead"
self.is_alive = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kill(self):\n self.is_dead = True\n self.color = (255, 0, 0)# Turn RED when dead",
"def set_dead(self):\n self.is_alive = False\n print(self.name, \"has been slayed: My evil comrades will avenge my death!\")",
"def just_died(self):\r\n self.dead = True",
"def set_dead(s... | [
"0.7112419",
"0.69177926",
"0.6857524",
"0.67910445",
"0.6723487",
"0.6723487",
"0.6627412",
"0.64838713",
"0.62620175",
"0.6245759",
"0.6223373",
"0.61635333",
"0.6123344",
"0.60842526",
"0.6034199",
"0.6013487",
"0.59938955",
"0.5978125",
"0.5934977",
"0.5918953",
"0.587451... | 0.8538984 | 0 |
Tear down ZMQ socket. | def clean_up(self):
self.stop_full()
self.ctrl_sock.close()
self.context.term() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shutdown(self):\n self.connected = False\n self.protocol.send_message(self.sock, '__!shutdown__')\n data = self.protocol.recover_message(self.sock)\n self.sock.close()\n self.sock = None",
"def stopzmq(self):\n\n self.context.destroy()",
"def shutdown(self):\r\n ... | [
"0.73503745",
"0.73096895",
"0.7231803",
"0.71864796",
"0.71188074",
"0.711665",
"0.7075718",
"0.7047037",
"0.69911534",
"0.6938244",
"0.69138473",
"0.68389595",
"0.675465",
"0.67459685",
"0.6742707",
"0.6741266",
"0.67081887",
"0.6693308",
"0.667428",
"0.66438633",
"0.661772... | 0.6124287 | 76 |
Controller for the app home page. GET requests can be launched from either HydroShare or the Tethys Portal. Requests can contain URL query parameters describing a resource or aggregation. | def home(request):
context = {
"resource_id": request.GET.get("resource_id"),
"aggregation_id": request.GET.get("aggregation_path"),
"geoserver_url": app.get_custom_setting("geoserver_url"),
"hydroserver_url": app.get_custom_setting("hydroserver_url"),
"max_layers": app.get_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home(context, request):\n return {}",
"def home():\n payload = manager.get_payload()\n return render_template('index.html', payload=payload)",
"def index():\n response.view_title = myconf.get('app.name') + ' Home Page'\n return dict(message='')",
"def home(self, *args, **kwargs):\n ... | [
"0.6815008",
"0.66603345",
"0.66419333",
"0.6555703",
"0.6526086",
"0.64835405",
"0.64466995",
"0.6422764",
"0.6388012",
"0.6381053",
"0.6381053",
"0.6381053",
"0.63683623",
"0.635375",
"0.63486767",
"0.6245074",
"0.6225435",
"0.62205166",
"0.6215791",
"0.61986035",
"0.619708... | 0.72442335 | 0 |
r"""The constructor of the SGD class | def __init__(self, iterations: int, circuit: BasicCircuit, learning_rate: float):
super().__init__(iterations, circuit)
self._learning_rate = learning_rate | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, shape, rate, state0, state1, variables, nStates):\n self.shape = shape\n self.rate = rate\n self.state0 = state0\n self.state1 = state1\n self.variables = variables\n self.bivariateGradInd = getBivariateFeatGradientIndex.getBivariateFeatGradientIndex(sta... | [
"0.7010604",
"0.6957143",
"0.6895721",
"0.6827326",
"0.6762734",
"0.67172724",
"0.66993105",
"0.66695994",
"0.6608632",
"0.66043055",
"0.66025925",
"0.6585092",
"0.65232074",
"0.6521873",
"0.6513582",
"0.64843017",
"0.6483895",
"0.6478602",
"0.6470497",
"0.6469032",
"0.646704... | 0.0 | -1 |
Mockable method to get a connection to the SNS service. | def _get_connection(self):
return boto3.client('sns', region_name=self.region) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connection():\n return _MockConnection()",
"def test_get_connection_established(self):\n module = MagicMock()\n connection = slxos.get_connection(module)\n self.assertEqual(connection, module.slxos_connection)",
"def test_get_connection_settings(self, connection_mock): # pylint: di... | [
"0.6760185",
"0.67045295",
"0.6263524",
"0.6212023",
"0.6189095",
"0.60578346",
"0.6047458",
"0.5938434",
"0.59329337",
"0.5796696",
"0.5764401",
"0.5668841",
"0.5666508",
"0.56389004",
"0.549957",
"0.549739",
"0.54761285",
"0.5447085",
"0.54465145",
"0.5419874",
"0.5394882",... | 0.65635824 | 2 |
Load user by ID. | def load_user(user_id):
return User.get_by_id(int(user_id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_user(id):\n return User.get_by_id(int(id))",
"def load_user(id):\n\treturn User.query.get(int(id))",
"def load_user(id):\n return User.query.get(int(id))",
"def load_user(id):\n return User.query.get(int(id))",
"def load_user(id):\n return User.query.get(int(id))",
"def load_user(id)... | [
"0.8996386",
"0.8917922",
"0.8851071",
"0.8851071",
"0.8851071",
"0.8851071",
"0.8824558",
"0.8784457",
"0.8637541",
"0.8552219",
"0.8500475",
"0.8500475",
"0.8500475",
"0.8500475",
"0.8500475",
"0.8500475",
"0.8487927",
"0.84707946",
"0.8445067",
"0.84212524",
"0.83829105",
... | 0.8620829 | 11 |
Display or edit the current user profile. | def user_profile():
user = current_user
user_is_valid = True
if not user.active:
flash('This user account is under review. Please update your profile '
+ ' and contact the organizing team to access all functions of '
+ 'this platform.', 'warning')
form = UserForm(obj... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def viewprofile():\n user = current_user\n form = UserUpdateForm(obj=user)\n form.populate_obj(user)\n if form.validate_on_submit():\n form.populate_obj(user)\n\n db.session.commit()\n\n flash('You have successfully edited your profile!')\n return render_template('user/user.html... | [
"0.8453015",
"0.806588",
"0.80351865",
"0.78897697",
"0.77928376",
"0.75748926",
"0.7514304",
"0.74695206",
"0.74329185",
"0.7361205",
"0.7361173",
"0.73514605",
"0.73473984",
"0.72933596",
"0.7281994",
"0.72523165",
"0.72478575",
"0.71817636",
"0.716739",
"0.7163399",
"0.711... | 0.740216 | 9 |
Convert a string to kebabcase. | def to_kebabcase(class_name: str) -> str:
return _to_kebabcase(class_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kebabize(string):\n kebab = \"\"\n for letter in string:\n if letter.isdigit():\n continue\n elif letter.isupper():\n kebab+=(\"-\" + letter.lower())\n else:\n kebab+=letter\n return kebab if kebab[0] != \"-\" else kebab[1:]",
"def kebab_case(val... | [
"0.79788256",
"0.7572289",
"0.6794973",
"0.6585272",
"0.6455724",
"0.63580495",
"0.63474697",
"0.62911844",
"0.628673",
"0.6252043",
"0.62008524",
"0.6179952",
"0.61788523",
"0.6151217",
"0.6129791",
"0.6110715",
"0.6102956",
"0.61010796",
"0.607655",
"0.6066681",
"0.6041014"... | 0.6744712 | 3 |
Calculate the distance in kilometres between two points on the earth (specified in decimal degrees) | def calculateDistance(lat1, lon1, lat2, lon2):
# convert decimal degrees to radians
lat1, lon1, lat2, lon2 = map(radians, [lat1, lon1, lat2, lon2])
# haversine formula
dlat = lat2 - lat1
dlon = lon2 - lon1
a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
c = 2 * asin(sqrt(a))
r = 637... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(lon1, lat1, lon2, lat2):\n # convert decimal degrees to radians \n lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])\n # haversine formula \n dlon = lon2 - lon1 \n dlat = lat2 - lat1 \n a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2\n c = 2 * asin(sqrt(a... | [
"0.76750636",
"0.7674425",
"0.7627555",
"0.76152205",
"0.7613395",
"0.7590489",
"0.75863576",
"0.7550474",
"0.7550474",
"0.7550474",
"0.7550474",
"0.7550474",
"0.7550237",
"0.75406015",
"0.75199986",
"0.7507763",
"0.7505633",
"0.7503883",
"0.75034183",
"0.74893993",
"0.748668... | 0.714709 | 46 |
This function will delete all leaves from a tree, but if the root is the only node given it will not delete itself | def delete_leaves(self):
if not (self.left or self.right):
return True
if self.left:
delete = self.left.delete_leaves()
if delete is True:
self.left = None
if self.right:
delete = self.right.delete_leaves()
if delete is ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_leaves_2(self, root):\n if not (root.left or root.right):\n print(\"delete\")\n print(root.data)\n print(\"---------\")\n root = None\n return\n\n if root.left:\n self.delete_leaves_2(root.left)\n\n if root.right:\n ... | [
"0.7738134",
"0.7038441",
"0.69730145",
"0.6909312",
"0.67814344",
"0.6652899",
"0.6622158",
"0.6617548",
"0.6545824",
"0.65398854",
"0.6500479",
"0.6480772",
"0.6457277",
"0.6427982",
"0.6424044",
"0.642038",
"0.6365937",
"0.63100755",
"0.6280858",
"0.62718207",
"0.6258822",... | 0.74955225 | 1 |
Return RGBA values for ``color`` property. | def color(self):
return rgba(self.value_of_css_property('color')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def color_to_rgba(color: object) -> tuple:\n\n return (color.red(), color.green(), color.blue(), color.alpha())",
"def color(self):\n return self._rgba",
"def color(self):\n return self._rgba",
"def get_four_byte_color(color: Color) -> RGBA:\r\n\r\n if len(color) == 4:\r\n return c... | [
"0.7343431",
"0.7000932",
"0.7000932",
"0.6592825",
"0.6573416",
"0.6468877",
"0.64364314",
"0.6287578",
"0.6286597",
"0.62671024",
"0.6190924",
"0.6190924",
"0.6190372",
"0.6141411",
"0.61247754",
"0.6122992",
"0.6105318",
"0.6056282",
"0.601959",
"0.60136694",
"0.6011293",
... | 0.6914371 | 3 |
Return RGBA values for ``backgroundcolor`` property. | def background_color(self):
return rgba(self.value_of_css_property('background-color')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_el_colors(self, el):\n\n def _format_rgb_str(rgb_str):\n \"\"\"convert str 'rgb(255, 255, 255)' to list [255, 255, 255]\"\"\"\n return [int(c) for c in re.sub('[^0-9,]', '', rgb_str).split(',')]\n\n # get all possible background colors, considering transparencies of el\n... | [
"0.6764329",
"0.6697507",
"0.65333664",
"0.64372325",
"0.6402738",
"0.63212687",
"0.6299003",
"0.62782323",
"0.6239178",
"0.62080777",
"0.61114246",
"0.6085414",
"0.6034118",
"0.60286945",
"0.598664",
"0.59860194",
"0.5890674",
"0.5873231",
"0.5873231",
"0.5871509",
"0.577434... | 0.7491768 | 0 |
The element's ``value`` attribute. | def value(self):
return self.element.get_attribute('value') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value(self):\n\n return self.element().get_attribute('value') if self.exists() else ''",
"def read_value(self):\n return self.load_attr(\"value\")",
"def value(self):\n return self.raw.get_attribute(\"value\")",
"def value(self):\n return self.get_attribute(\"value\", str(self.chi... | [
"0.8537093",
"0.7993024",
"0.7862474",
"0.7829206",
"0.7814218",
"0.7814218",
"0.77572465",
"0.77572465",
"0.77572465",
"0.77569956",
"0.7735882",
"0.7735882",
"0.7731189",
"0.77214456",
"0.77138174",
"0.77138174",
"0.77138174",
"0.77106285",
"0.77030873",
"0.77030873",
"0.77... | 0.8882436 | 0 |
The element's selection state. | def value(self):
return self.element.is_selected() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_selected(self):\n return self._element_call(lambda: self.el.is_selected)",
"def GetSelection(self):\n \n return self.selected",
"def GetSelection(self):\r\n\r\n return self.selection",
"def getSelection(self):\n return self.selection",
"def selected(self):\n ... | [
"0.7492136",
"0.7212147",
"0.7201546",
"0.719847",
"0.7133201",
"0.7104456",
"0.70993894",
"0.7040215",
"0.7040215",
"0.68924564",
"0.6817247",
"0.6758086",
"0.6746569",
"0.67323345",
"0.6729183",
"0.67091006",
"0.6504068",
"0.6461723",
"0.64256346",
"0.6399943",
"0.6328602",... | 0.6459935 | 18 |
The element's selected value. | def value(self):
return self.element.get_attribute('value') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def selected_value(self):\n option = self.selected_option\n return option.value if option else None",
"def value(self):\n return self.element.is_selected()",
"def get_selected_text(self):\r\n return self.selectedText()",
"def current_val(self):\n try:\n return se... | [
"0.8485434",
"0.7745355",
"0.75646305",
"0.75018054",
"0.7435818",
"0.741141",
"0.7403814",
"0.7288268",
"0.72312486",
"0.7175368",
"0.71701187",
"0.716595",
"0.70813894",
"0.70185167",
"0.69993067",
"0.69622207",
"0.6950321",
"0.6948763",
"0.69426227",
"0.69234335",
"0.68780... | 0.7231325 | 10 |
Set the element's value to `value`. | def __set__(self, page, value):
element = self.get(page)
element.value = value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_value(self, value):\n self.value = value",
"def set_value(self, value):\n self.value = value",
"def set_value(self, value):\n self.value = value",
"def set_value(self, value):\n self.value = str(value)",
"def setValue(self, value):\n self._value = value",
"def s... | [
"0.8011748",
"0.8011748",
"0.8011748",
"0.77181935",
"0.77106756",
"0.76598567",
"0.76474065",
"0.7572529",
"0.7572529",
"0.75661904",
"0.7513297",
"0.7513297",
"0.7513297",
"0.7513297",
"0.7513297",
"0.7513297",
"0.7489302",
"0.74786955",
"0.7458836",
"0.74275374",
"0.733012... | 0.740264 | 20 |
Return the current state of the switch. | def state(self) -> bool:
return self.get_state(self.entity_ids["switch"]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_state(self):\n return self._current_state",
"def get_state(self):\n return self.controller.get_state()",
"def get_current_state(self):\n return self.game.get_current_state()",
"def _get_switch_state(self):\n if self.entity_description.value_fn is not None:\n ... | [
"0.7425279",
"0.739453",
"0.7389475",
"0.73426807",
"0.72858995",
"0.7284404",
"0.7284404",
"0.7283007",
"0.7248187",
"0.72135603",
"0.7213438",
"0.7166461",
"0.7131392",
"0.7085297",
"0.7083024",
"0.7065791",
"0.7061634",
"0.70615196",
"0.7058502",
"0.7056262",
"0.70368433",... | 0.73506117 | 3 |
Turn the switch off if no one is home. | def _on_switch_activate(
self, entity: Union[str, dict], attribute: str, old: str, new: str, kwargs: dict
) -> None:
self.log("No one home; not allowing switch to activate")
self.toggle(state="off") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_off(self, **kwargs) -> None:\n _LOGGER.debug(\n \"SynoDSMSurveillanceHomeModeToggle.turn_off(%s)\",\n self._api.information.serial,\n )\n self._api.surveillance_station.set_home_mode(False)",
"def turn_off(self, **kwargs):\n self.vacuum.stop()\n s... | [
"0.7589429",
"0.7459149",
"0.742201",
"0.7397898",
"0.7355061",
"0.7350044",
"0.7348074",
"0.73114276",
"0.7298673",
"0.72864807",
"0.72778493",
"0.72699744",
"0.7264079",
"0.7247986",
"0.72374797",
"0.7232648",
"0.7230164",
"0.72077096",
"0.7186795",
"0.71534324",
"0.7101328... | 0.0 | -1 |
An async iterator object yielding elements from ``subject`` | def aiter(subject: AnyIterable[T]) -> AsyncIterator[T]:
if isinstance(subject, AsyncIterable):
return subject.__aiter__()
else:
return _aiter_sync(subject).__aiter__() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def borrow(iterator: AsyncIterator[T]) -> AsyncGenerator[T, None]:\n async for item in iterator:\n yield item",
"def __iter__(self):\n items = self._fetch()\n for item in items:\n yield item",
"async def _aiter_sync(iterable: Iterable[T]) -> AsyncIterator[T]:\n for i... | [
"0.6790663",
"0.66644114",
"0.65314794",
"0.65033853",
"0.64963",
"0.632815",
"0.6262574",
"0.6222994",
"0.6210711",
"0.6210294",
"0.61790127",
"0.61499745",
"0.61499023",
"0.6124081",
"0.6079985",
"0.60372174",
"0.60367197",
"0.6030758",
"0.6016303",
"0.6006711",
"0.6004539"... | 0.7413828 | 0 |
Borrow an async iterator for iteration, preventing it from being closed | async def borrow(iterator: AsyncIterator[T]) -> AsyncGenerator[T, None]:
async for item in iterator:
yield item | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iterate(itr: AnyIterable) -> AsyncIterator[T]:\n if isinstance(itr, AsyncIterator):\n return itr\n\n async def gen():\n for i in itr:\n yield i\n\n return gen()",
"async def _aiter_sync(iterable: Iterable[T]) -> AsyncIterator[T]:\n for item in iterable:\n yield ite... | [
"0.7423922",
"0.70553017",
"0.6690503",
"0.66565377",
"0.65138143",
"0.64905953",
"0.637422",
"0.63242024",
"0.6289853",
"0.6289547",
"0.62873447",
"0.62873447",
"0.62828374",
"0.6124208",
"0.61166036",
"0.6076068",
"0.6065881",
"0.6060809",
"0.6055403",
"0.60457146",
"0.6039... | 0.7927861 | 0 |
Method to verify an email so SES mocking works | def _setup_ses(self):
print("\n ** Setting up SES mocking")
ses = boto3.client('ses', region_name="us-east-1")
ses.verify_domain_identity(Domain='donatemates.com')
#response = ses.verify_email_address(EmailAddress='hello@donatemates.com') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sendEmailVerification(self, testUser):\n with mail.record_messages() as outbox:\n testUser.send_email_verification()\n assert len(outbox) == 1\n msg = outbox[0]\n assert \"jjones@yahoo.com\" in msg.recipients\n assert msg.subject == 'Ask Your P... | [
"0.739667",
"0.7334669",
"0.7332078",
"0.73241776",
"0.728366",
"0.72539854",
"0.7246461",
"0.71617275",
"0.7135525",
"0.70760447",
"0.70270294",
"0.70027554",
"0.69734",
"0.69734",
"0.69720846",
"0.6950871",
"0.69423187",
"0.6939461",
"0.6938088",
"0.692822",
"0.691937",
"... | 0.6295932 | 89 |
Get the current location | def getCurr(self):
if self.currLoc < 0 or self.currLoc > len(self.history):
raise ValueError("History is empty or invalid")
return self.history[self.currLoc] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_location(self):\n return self.enu_2_local()",
"def get_current_location(self):\n return self._current_loc",
"def get_current_location():\n global current_location\n return current_location",
"def get_location(self):\n\t\treturn self.location",
"def get_location(self):\n ... | [
"0.8999848",
"0.8908268",
"0.8904931",
"0.8403391",
"0.8247378",
"0.8191025",
"0.8039015",
"0.7899433",
"0.78865606",
"0.7886449",
"0.78854406",
"0.78854406",
"0.78854406",
"0.78854406",
"0.78854406",
"0.78854406",
"0.78854406",
"0.78854406",
"0.78854406",
"0.78854406",
"0.78... | 0.0 | -1 |
Adds discounted sum of rewards to all time steps of all trajectories | def add_disc_sum_rew(trajectories, gamma):
for trajectory in trajectories:
if gamma < 0.999: # don't scale for gamma ~= 1
rewards = trajectory['rewards'] * (1 - gamma)
else:
rewards = trajectory['rewards']
disc_sum_rew = discount(rewards, gamma)
trajectory['d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discount_rewards(rewards):\r\n discounted_r = np.zeros_like(rewards)\r\n running_add = 0\r\n for t in reversed(range(0, len(rewards))): \r\n running_add = running_add * reward_discount + rewards[t]\r\n discounted_r[t] = running_add\r\n return discounted_r",
"def _accumu... | [
"0.72980314",
"0.7011921",
"0.6728515",
"0.6725814",
"0.6645948",
"0.6636978",
"0.6636169",
"0.6597911",
"0.659226",
"0.6587674",
"0.6561878",
"0.65603536",
"0.6530804",
"0.6519008",
"0.6513319",
"0.65098304",
"0.6502283",
"0.64437884",
"0.6427616",
"0.64253783",
"0.6417393",... | 0.6673 | 4 |
Return whether `self` and `other` have any points in common. | def overlaps(self, other):
return self.start <= other.end and self.end >= other.start | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_same_as(self, other) -> bool:\n return self.x == other.x and self.y == other.y",
"def accurate_collision(self, other) -> bool:\r\n if self.collide:\r\n if self.bbox_intersect(other):\r\n offset = round(self.x - other.x), \\\r\n round(self.y -... | [
"0.7825174",
"0.76833695",
"0.7580746",
"0.7556123",
"0.75286084",
"0.7451894",
"0.73591477",
"0.7334849",
"0.73082703",
"0.7301225",
"0.72702116",
"0.7269273",
"0.7268638",
"0.726756",
"0.72435606",
"0.723262",
"0.72258854",
"0.7195468",
"0.7180176",
"0.7180176",
"0.7154824"... | 0.658957 | 73 |
Sets Up the enviroment for tests | def setUp(self):
if os.path.exists('file.json'):
os.remove("file.json") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n test_env_setup()",
"def SetupEnvironment(self):\n pass",
"def _setup_env(self):\n\n os.environ['GIT_NAME'] = statiki.GIT_NAME\n os.environ['GIT_EMAIL'] = statiki.GIT_EMAIL\n os.environ['GH_TOKEN'] = 'this-is-a-bogus-token:password'\n os.environ['TRAVIS_R... | [
"0.85351247",
"0.78182745",
"0.7802924",
"0.7689726",
"0.75783986",
"0.746788",
"0.74650806",
"0.74650806",
"0.7427789",
"0.73961335",
"0.7386016",
"0.73278296",
"0.73071355",
"0.7287702",
"0.7244582",
"0.7220791",
"0.72136295",
"0.72036475",
"0.71536547",
"0.71528083",
"0.71... | 0.0 | -1 |
Returns if the full word is present in the trie. | def search(self, word):
currNode = self.root
for c in word:
if c not in currNode.children:
return False
currNode = currNode.children[c]
return currNode.isEnd | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_full_word(self, word):\n node = self.root\n for i in range(len(word)):\n current_letter = word[i]\n current_index = self.to_index(current_letter)\n if node.children[current_index] and node.is_word:\n node = node.children[current_index]\n ... | [
"0.7807935",
"0.7679797",
"0.76143914",
"0.75132805",
"0.7503906",
"0.74466634",
"0.7430512",
"0.7427556",
"0.74151844",
"0.73966503",
"0.7375712",
"0.73736566",
"0.7363391",
"0.7352787",
"0.7313642",
"0.73038906",
"0.72797626",
"0.72610366",
"0.7257191",
"0.72474784",
"0.723... | 0.68957543 | 53 |
Do parse the text in variable "text" according to the spec, and return a LIST containing FOUR strings 1. The parsed text. 2. The unigrams 3. The bigrams 4. The trigrams | def sanitize(text):
# Convert text to lowercase
text = text.lower()
# Replace all whitespace with a single space
text = re.sub(r'\s+',' ',text)
# Remove all links (e.g. [abc](xyz)def --> [abc]def)
text = re.sub(r'(\[.*\])(\(.*\))', r'\1', text)
# Remove URLs
text = re.sub(r'((htt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _tokenize(self, text: str) -> List[str]:\n return self.bpe.tokenize(text)",
"def _tokenize(self, text: str) -> List[str]:\n text = text.lower().strip()\n return self.bpe.tokenize(text)",
"def process_text(text):\n text = text.translate(translator)\n tokens = word_tokenize(text)\n... | [
"0.70316917",
"0.7010744",
"0.69598025",
"0.6818925",
"0.68183374",
"0.68043786",
"0.67967427",
"0.67943615",
"0.6727975",
"0.67147166",
"0.67120373",
"0.6688268",
"0.66686535",
"0.6656668",
"0.6649772",
"0.6615907",
"0.66131544",
"0.65962064",
"0.65878534",
"0.6578828",
"0.6... | 0.62288094 | 70 |
Remove unnecessary whitespace characters. | def remove_unnecessary_whitespace(css):
log.debug("Removing all unnecessary white spaces.")
def pseudoclasscolon(css):
"""Prevent 'p :link' from becoming 'p:link'.
Translates 'p :link' into 'p ___PSEUDOCLASSCOLON___link'.
This is translated back again later.
"""
regex =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_space():\n pass",
"def _removeWhitespaces(self, s):\n return s.translate({ord(c): None for c in string.whitespace})",
"def removeSingleChars(self) -> None:\n self.text = re.sub('\\s[^\\n\\s]\\s', ' ', self.text)",
"def del_whitespace(selfs, text):\n\t\treturn text.replace(' ', '')... | [
"0.811015",
"0.78902733",
"0.7846514",
"0.77336586",
"0.7649676",
"0.7641509",
"0.7615021",
"0.7595822",
"0.753145",
"0.75186414",
"0.7485342",
"0.74354094",
"0.73485297",
"0.7325334",
"0.72944283",
"0.72389734",
"0.7198461",
"0.71800834",
"0.71791077",
"0.71765256",
"0.71656... | 0.65357095 | 77 |
Replace `0(px, em, %, etc)` with `0`. | def condense_zero_units(css):
log.debug("Condensing all zeroes on values.")
return re.sub(r"([\s:])(0)(px|em|%|in|q|ch|cm|mm|pc|pt|ex|rem|s|ms|"
r"deg|grad|rad|turn|vw|vh|vmin|vmax|fr)", r"\1\2", css) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zero(x):\n # TODO: get dtype from Expr and Matrix:\n return x * 0",
"def zero(*_, **__) -> None:\n return",
"def fix_es_stats(s):\n s = wrap(s)\n if s.count == 0:\n return stats.zero\n return s",
"def zero(self):\n raise NotImplementedError(\"Not implemented yet.\")",
"d... | [
"0.6159681",
"0.606637",
"0.5959578",
"0.57966924",
"0.57475215",
"0.57071227",
"0.56552404",
"0.5608328",
"0.5598456",
"0.55829495",
"0.5396934",
"0.5340621",
"0.5340621",
"0.53323025",
"0.5300266",
"0.5281759",
"0.5265279",
"0.52234364",
"0.51997703",
"0.51923627",
"0.51829... | 0.7871755 | 0 |
Condense multiple adjacent whitespace characters into one. | def condense_whitespace(css):
log.debug("Condensing all unnecessary white spaces.")
return re.sub(r"\s+", " ", css) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_text_from_multiple_consecutive_whitespaces(text):\n multi_space_regex = re.compile(r\"\\s+\", re.IGNORECASE)\n return re.sub(multi_space_regex, ' ', text)",
"def normalize_whitespace(text):\n return NORMALIZE_WHITESPACE_REGEX.sub(' ', text)",
"def clean_whitespaces(text):\n length = len(t... | [
"0.709651",
"0.7021509",
"0.69756943",
"0.6746559",
"0.6728323",
"0.6689235",
"0.6653626",
"0.661164",
"0.6529664",
"0.6511655",
"0.6509662",
"0.65025824",
"0.64974004",
"0.648043",
"0.6471447",
"0.6406778",
"0.636897",
"0.6345566",
"0.63374776",
"0.630923",
"0.6294746",
"0... | 0.6960958 | 3 |
Condense HTML, but be safe first if it have textareas or pre tags. >>> condense_html_whitespace(' test ') ' test ' | def condense_html_whitespace(html): # first space between tags, then empty new lines and in-between.
log.debug("Removing unnecessary HTML White Spaces and Empty New Lines.")
is_ok = "<textarea" not in html.lower() and "<pre" not in html.lower()
html = re.sub(r'>\s+<', '> <', html) if is_ok else html
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_preserved_whitespace_in_pre_and_textarea(self):\n self.assertSoupEquals(\"<pre> </pre>\")\n self.assertSoupEquals(\"<textarea> woo </textarea>\")",
"def condense_whitespace(css):\n log.debug(\"Condensing all unnecessary white spaces.\")\n return re.sub(r\"\\s+\", \" \", css)",
"... | [
"0.6709578",
"0.6664654",
"0.6474388",
"0.6415928",
"0.64103574",
"0.6337937",
"0.6247472",
"0.62273794",
"0.61873335",
"0.6185256",
"0.6170899",
"0.61478996",
"0.6132767",
"0.6128495",
"0.6090021",
"0.60508275",
"0.599904",
"0.5965065",
"0.5957782",
"0.5951342",
"0.5949908",... | 0.8579536 | 0 |
Clean unneeded optional html tags. >>> clean_unneeded_html_tags('abc') 'abc' | def clean_unneeded_html_tags(html):
log.debug("Removing unnecessary optional HTML tags.")
for tag_to_remove in ("""</area> </base> <body> </body> </br> </col>
</colgroup> </dd> </dt> <head> </head> </hr> <html> </html> </img>
</input> </li> </link> </meta> </option> </param>
</td> </tfo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_html(unclean, tags=[]):\n # We make this noop for non-string, non-collection inputs so this function can be used with higher-order\n # functions, such as rapply (recursively applies a function to collections)\n if not isinstance(unclean, basestring) and not is_iterable(unclean) and unclean is no... | [
"0.76264864",
"0.7439271",
"0.7104023",
"0.70323694",
"0.6904914",
"0.68577784",
"0.6840776",
"0.68305963",
"0.6822214",
"0.6777962",
"0.6777962",
"0.6776273",
"0.67667854",
"0.6766784",
"0.67644423",
"0.67492545",
"0.6730782",
"0.66954434",
"0.66949177",
"0.668354",
"0.66661... | 0.85766023 | 0 |
Remove all HTML quotes on attibutes if possible. >>> unquote_html_attributes('') '' | def unquote_html_attributes(html): # data-foo=0> might cause errors on IE, we leave 1 space data-foo=0 >
log.debug("Removing unnecessary Quotes on attributes of HTML tags.")
# cache all regular expressions on variables before we enter the for loop.
any_tag = re.compile(r"<\w.*?>", re.I | re.MULTILINE | re.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def html_attrs(attrs):\n html = \"\"\n for a in attrs.items():\n if a[1]:\n html = html + \"%s=\\\"%s\\\" \"%(a)\n return html",
"def _xml_escape_attr(attr, skip_single_quote=True):\r\n escaped = (attr\r\n .replace('&', '&')\r\n .replace('\"', '"')\r\n ... | [
"0.6834157",
"0.65469414",
"0.6360739",
"0.6360739",
"0.6221861",
"0.6202286",
"0.6147309",
"0.5974788",
"0.5944254",
"0.5893904",
"0.5878157",
"0.5868223",
"0.58245707",
"0.5800898",
"0.57944995",
"0.5741967",
"0.5706109",
"0.56919146",
"0.5669748",
"0.56483173",
"0.5645899"... | 0.8049605 | 0 |
Build and return a Logging Logger. | def make_logger(name=str(os.getpid())):
if not sys.platform.startswith("win") and sys.stderr.isatty():
def add_color_emit_ansi(fn):
"""Add methods we need to the class."""
def new(*args):
"""Method overload."""
if len(args) == 2:
ne... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_logger(self):\n pass",
"def build_logger(self, parent_module):\n self._loggers[parent_module] = logger = logging.getLogger(parent_module)\n return logger",
"def create_logger() -> logging.Logger:\n pass # TODO: Replace with implementation!",
"def setup_build_log(log_filepat... | [
"0.7619966",
"0.72986776",
"0.6943124",
"0.69192964",
"0.6870574",
"0.6861588",
"0.68368435",
"0.6786689",
"0.672065",
"0.6631001",
"0.6630045",
"0.6552274",
"0.65391856",
"0.65369767",
"0.6530277",
"0.65150803",
"0.6508992",
"0.6497881",
"0.64779365",
"0.6449279",
"0.6421664... | 0.0 | -1 |
Create an empty 2D array of slots (rows x cols) | def _get_initial_slots(self, rows, cols) -> list:
slots = []
for x in range(rows):
row = []
for y in range(cols):
slot = Slot(x=x, y=y, mine=False, available=True, flag=False)
row.append(slot)
slots.append(row)
return slots | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_empty_grid(width, height):\n return [[None] * width for _ in range(height)]",
"def create_grid(self):\n return [[0] * self.width for _ in range(self.height)]",
"def create_grid(grid):\r\n for i in range (4):\r\n grid.append ([])\r\n for j in range (4):\r\n grid[... | [
"0.7419658",
"0.7208141",
"0.71461105",
"0.68261063",
"0.67881125",
"0.6773614",
"0.67628646",
"0.67551386",
"0.6750213",
"0.6698214",
"0.6635329",
"0.6597467",
"0.6586316",
"0.65503603",
"0.64893615",
"0.64575297",
"0.6432654",
"0.6425134",
"0.64015836",
"0.6381707",
"0.6379... | 0.70884836 | 3 |
Name of current protocol. | def name(self) -> 'Literal["Dynamic Reverse Address Resolution Protocol", "Inverse Address Resolution Protocol", "Reverse Address Resolution Protocol", "Address Resolution Protocol"]': # pylint: disable=line-too-long
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def protocol(self) -> str:\n return __name__",
"def protocol(self) -> str:\n return pulumi.get(self, \"protocol\")",
"def protocol_name(self):\n self._protocol_name = 'kerberos'\n return self._protocol_name",
"def getProtocol(self) -> str:\n ...",
"def layer_protocol_name... | [
"0.8527097",
"0.8032896",
"0.8025242",
"0.7800471",
"0.7785212",
"0.7730119",
"0.76614213",
"0.76614213",
"0.75701255",
"0.75649047",
"0.75599545",
"0.7478808",
"0.7466269",
"0.7439446",
"0.7334409",
"0.7231231",
"0.71754944",
"0.715286",
"0.70239735",
"0.70239735",
"0.702397... | 0.6736922 | 38 |
Reshape a given 2D image and place in a (1, y, x, 1) tensor to be fed into the network. | def reshape(input):
input = input / 255
input = trans.resize(input, (args.size, args.size))
input = np.reshape(input, input.shape + (1,))
input = np.reshape(input, (1,) + input.shape)
return input | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _reshape_function(image, label):\n# image = tf.expand_dims(image, axis=0)\n image = tf.expand_dims(image, axis=-1)\n return image, label",
"def img_reshape(self, input_img):\n _img = np.transpose(input_img, (1, 2, 0)) \n _img = np.flipud(_img)\n _img = np.reshape(_img, (1, img... | [
"0.7265519",
"0.70425546",
"0.7039703",
"0.6564403",
"0.6510719",
"0.64666486",
"0.642996",
"0.63887775",
"0.6357704",
"0.6340021",
"0.63005817",
"0.62822044",
"0.61977595",
"0.60359854",
"0.59971726",
"0.59963024",
"0.5976915",
"0.5967312",
"0.5955305",
"0.59480506",
"0.5934... | 0.6121514 | 13 |
Function transforms an image to a tensor. | def get_image_live_image(imga):
img = tf.image.resize_with_pad(np.expand_dims(imga, axis=0), 192, 192)
input_image = tf.cast(img, dtype=tf.int32)
return input_image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_image_to_tensor(image):\n # image = image.astype(np.float32)\n return transform(image)\n # return transform(image)",
"def tensor_to_image(img):\n t = transforms.ToPILImage()\n return t(img)",
"def pil_to_tensor(img):\n img = ToTensor()(img)\n return img",
"def image_to_tensor... | [
"0.8440971",
"0.79305965",
"0.7838948",
"0.76782733",
"0.7615845",
"0.7555468",
"0.75046813",
"0.75046813",
"0.75046813",
"0.7364811",
"0.73475415",
"0.7340281",
"0.71797585",
"0.7092936",
"0.7070492",
"0.70616376",
"0.7018551",
"0.70125717",
"0.70036125",
"0.69673836",
"0.69... | 0.0 | -1 |
Plots a timeseries for Antarctic SIC. | def plot_seaice_timeseries(anomlous = False, temporal_resolution = 'monthly', spatial_resolution = 1, detrend = False, imagefolder = 'images/timeseries/SIC/',seaice_source='nsidc'):
output_folder = 'processed_data/SIC/'
if seaice_source == 'ecmwf':
output_folder = 'processed_data/ERA5/SIC/'
if anom... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_sic_sic_timeseries(anomlous = False, temporal_resolution = 'monthly', spatial_resolution = 1, detrend = False, imagefolder = 'images/timeseries/SIC/'):\n output_folder = 'processed_data/'\n\n\n if anomlous:\n temp_decomp = 'anomalous'\n else:\n temp_decomp = 'raw'\n\n if detrend:... | [
"0.6817868",
"0.6572904",
"0.63554436",
"0.6310377",
"0.61520904",
"0.6032453",
"0.6024002",
"0.59372973",
"0.593286",
"0.5828594",
"0.5809771",
"0.5808131",
"0.5805799",
"0.5799026",
"0.579603",
"0.57950896",
"0.5768596",
"0.57651645",
"0.57079095",
"0.5706063",
"0.5652826",... | 0.6553492 | 2 |
Plots a timeseries for Antarctic SIC. | def plot_seaice_trend(anomlous = False, temporal_resolution = 'monthly', spatial_resolution = 1, detrend = False, imagefolder = 'images/trends/SIC/',seaice_source='nsidc'):
output_folder = 'processed_data/SIC/'
if seaice_source == 'ecmwf':
output_folder = 'processed_data/ERA5/SIC/'
if anomlous:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_sic_sic_timeseries(anomlous = False, temporal_resolution = 'monthly', spatial_resolution = 1, detrend = False, imagefolder = 'images/timeseries/SIC/'):\n output_folder = 'processed_data/'\n\n\n if anomlous:\n temp_decomp = 'anomalous'\n else:\n temp_decomp = 'raw'\n\n if detrend:... | [
"0.6817868",
"0.6572904",
"0.6553492",
"0.63554436",
"0.6310377",
"0.61520904",
"0.6032453",
"0.6024002",
"0.59372973",
"0.593286",
"0.5828594",
"0.5809771",
"0.5808131",
"0.5805799",
"0.5799026",
"0.579603",
"0.57950896",
"0.5768596",
"0.57651645",
"0.57079095",
"0.5706063",... | 0.51914823 | 82 |
Plots a timeseries for Antarctic SIC. | def plot_subplot_trend(anomlous = False, temporal_resolution = 'monthly', spatial_resolution = 1, detrend = False, imagefolder = 'images/subplots/',seaice_source='nsidc'):
output_folder = 'processed_data/SIC/'
if seaice_source == 'ecmwf':
output_folder = 'processed_data/ERA5/SIC/'
if anomlous:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_sic_sic_timeseries(anomlous = False, temporal_resolution = 'monthly', spatial_resolution = 1, detrend = False, imagefolder = 'images/timeseries/SIC/'):\n output_folder = 'processed_data/'\n\n\n if anomlous:\n temp_decomp = 'anomalous'\n else:\n temp_decomp = 'raw'\n\n if detrend:... | [
"0.6820432",
"0.65726423",
"0.65552765",
"0.63550174",
"0.6309702",
"0.6154358",
"0.60319966",
"0.6026846",
"0.59366006",
"0.59329635",
"0.58288926",
"0.58092815",
"0.5807514",
"0.580555",
"0.5802145",
"0.5797562",
"0.5795911",
"0.5768449",
"0.5766363",
"0.5707909",
"0.570605... | 0.0 | -1 |
Plots a timeseries for Antarctic SIC. | def plot_seaice_predict(anomlous = False, temporal_resolution = 'monthly', spatial_resolution = 1, detrend = False, imagefolder = 'images/timeseries/prediction/',seaice_source='nsidc'):
output_folder = 'processed_data/SIC/'
if seaice_source == 'ecmwf':
output_folder = 'processed_data/ERA5/SIC/'
if ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_sic_sic_timeseries(anomlous = False, temporal_resolution = 'monthly', spatial_resolution = 1, detrend = False, imagefolder = 'images/timeseries/SIC/'):\n output_folder = 'processed_data/'\n\n\n if anomlous:\n temp_decomp = 'anomalous'\n else:\n temp_decomp = 'raw'\n\n if detrend:... | [
"0.6817868",
"0.6572904",
"0.6553492",
"0.63554436",
"0.6310377",
"0.61520904",
"0.6032453",
"0.6024002",
"0.59372973",
"0.593286",
"0.5828594",
"0.5809771",
"0.5808131",
"0.5805799",
"0.5799026",
"0.579603",
"0.57950896",
"0.5768596",
"0.57651645",
"0.57079095",
"0.5706063",... | 0.0 | -1 |
Plots a timeseries for Antarctic SIC. | def plot_seaice_predict_components(anomlous = False, temporal_resolution = 'monthly', spatial_resolution = 1, detrend = False, imagefolder = 'images/timeseries/prediction/',seaice_source='nsidc'):
output_folder = 'processed_data/SIC/'
if seaice_source == 'ecmwf':
output_folder = 'processed_data/ERA5/SIC... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_sic_sic_timeseries(anomlous = False, temporal_resolution = 'monthly', spatial_resolution = 1, detrend = False, imagefolder = 'images/timeseries/SIC/'):\n output_folder = 'processed_data/'\n\n\n if anomlous:\n temp_decomp = 'anomalous'\n else:\n temp_decomp = 'raw'\n\n if detrend:... | [
"0.6820432",
"0.65726423",
"0.65552765",
"0.63550174",
"0.6309702",
"0.6154358",
"0.60319966",
"0.6026846",
"0.59366006",
"0.59329635",
"0.58288926",
"0.58092815",
"0.5807514",
"0.580555",
"0.5802145",
"0.5797562",
"0.5795911",
"0.5768449",
"0.5766363",
"0.5707909",
"0.570605... | 0.0 | -1 |
Plots a timeseries for Antarctic SIC. | def plot_seaice_predict_components_scatter(anomlous = False, temporal_resolution = 'monthly', spatial_resolution = 1, detrend = False, imagefolder = 'images/timeseries/prediction/',seaice_source='nsidc'):
output_folder = 'processed_data/SIC/'
if seaice_source == 'ecmwf':
output_folder = 'processed_data/... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_sic_sic_timeseries(anomlous = False, temporal_resolution = 'monthly', spatial_resolution = 1, detrend = False, imagefolder = 'images/timeseries/SIC/'):\n output_folder = 'processed_data/'\n\n\n if anomlous:\n temp_decomp = 'anomalous'\n else:\n temp_decomp = 'raw'\n\n if detrend:... | [
"0.6819347",
"0.65710515",
"0.65543264",
"0.6356096",
"0.63084286",
"0.61532164",
"0.6031372",
"0.60253704",
"0.5937236",
"0.59325427",
"0.58305955",
"0.58102274",
"0.5808334",
"0.58062196",
"0.5798156",
"0.5796319",
"0.57950705",
"0.57665443",
"0.5766517",
"0.5706904",
"0.57... | 0.0 | -1 |
Get an ordered dict of directory paths containing dark current calibration files, where the key is the dark cal identifier (YYYYDOY) and the value is the path. | def get_dark_cal_dirs(dark_cals_dir=MICA_FILES['dark_cals_dir'].abs):
dark_cal_ids = sorted([fn for fn in os.listdir(dark_cals_dir)
if re.match(r'[12]\d{6}$', fn)])
dark_cal_dirs = [os.path.join(dark_cals_dir, id_)
for id_ in dark_cal_ids]
return OrderedDict(z... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dark_cal_ids(dark_cals_dir=MICA_FILES['dark_cals_dir'].abs):\n dark_cal_ids = sorted([fn for fn in os.listdir(dark_cals_dir)\n if re.match(r'[12]\\d{6}$', fn)])\n dates = [CxoTime(d[:4] + ':' + d[4:]).date for d in dark_cal_ids]\n return OrderedDict(zip(dates, dark_cal_id... | [
"0.62558806",
"0.60070544",
"0.58899605",
"0.5813672",
"0.57399374",
"0.57208073",
"0.5712752",
"0.5651725",
"0.5559428",
"0.55593914",
"0.5556869",
"0.55414504",
"0.5514612",
"0.5430913",
"0.54267204",
"0.541934",
"0.5397161",
"0.53577554",
"0.53424096",
"0.53318363",
"0.530... | 0.7018663 | 0 |
Return the dark calibration image (e/s) nearest to ``date``. If ``select`` is ``'before'`` (default) then use the first calibration which occurs before ``date``. Other valid options are ``'after'`` and ``'nearest'``. | def get_dark_cal_image(date, select='before', t_ccd_ref=None, aca_image=False,
allow_negative=False):
dark, props = _get_dark_cal_image_props(date, select=select, t_ccd_ref=t_ccd_ref,
aca_image=aca_image,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dark_cal_props(date, select='before', include_image=False, t_ccd_ref=None,\n aca_image=False, allow_negative=False):\n dark, props = _get_dark_cal_image_props(date, select=select, t_ccd_ref=None,\n aca_image=aca_image,\n ... | [
"0.58799547",
"0.5722023",
"0.49422285",
"0.46758384",
"0.46570864",
"0.4583507",
"0.458061",
"0.44770852",
"0.44705704",
"0.4403666",
"0.4399198",
"0.4333679",
"0.42270485",
"0.417775",
"0.41431338",
"0.41220558",
"0.41072258",
"0.4090168",
"0.40882835",
"0.40761203",
"0.407... | 0.6527846 | 0 |
Returns the number of obstacles (wriggler segments or walls) between coord_a and coord_b. This function assumes that coord_b is larger (in either/both x and y) than coord_a. | def get_num_obstacles(coord_a, coord_b):
obstacle_count = 0
for x in range(coord_a.x, coord_b.x + 1):
for y in range(coord_a.y, coord_b.y + 1):
coord = Coordinate(x, y)
if coord in self.wall_coords or coord in state:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bbox_overlap(bbox_a, bbox_b):\n ymin_a, xmin_a, ymax_a, xmax_a = bbox_a\n ymin_b, xmin_b, ymax_b, xmax_b = bbox_b\n\n x_intersection = min(xmax_a, xmax_b) - max(xmin_a, xmin_b) + 1\n y_intersection = min(ymax_a, ymax_b) - max(ymin_a, ymin_b) + 1\n\n if x_intersection <= 0 or y_intersection <= 0:... | [
"0.62917095",
"0.60936224",
"0.60043025",
"0.5988464",
"0.58776444",
"0.5850409",
"0.5784879",
"0.5774823",
"0.5738438",
"0.57220614",
"0.57084537",
"0.56547207",
"0.56243306",
"0.5573225",
"0.5563858",
"0.5550752",
"0.55072314",
"0.5496901",
"0.54795235",
"0.5465251",
"0.546... | 0.85308814 | 0 |
Create a new PriorityQueueSet. | def __init__(self, items=[]):
self.set = dict((item, True) for item in items)
self.heap = self.set.keys()
heapq.heapify(self.heap) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def priority_queue():\n from src.priorityq import PriorityQueue\n priority_queue = PriorityQueue()\n return priority_queue",
"def _create_priorities(self, pri):\n heaps = self.priorities\n heaps[pri] = MinBinaryHeap()",
"def __init__(self, items=None):\n\n if items is None:\n ... | [
"0.7134021",
"0.6275945",
"0.6069411",
"0.60066664",
"0.5981591",
"0.58784217",
"0.5865251",
"0.58134234",
"0.5739527",
"0.5725476",
"0.5628518",
"0.5597218",
"0.55957186",
"0.559547",
"0.5575486",
"0.54900676",
"0.5489366",
"0.5457516",
"0.545611",
"0.54452866",
"0.5440044",... | 0.6152141 | 2 |
Send a 'All Sound Off' (CC 120) 'Control Change' message. | def send_all_sound_off(self, ch=None):
self.send_control_change(ALL_SOUND_OFF, 0, ch=ch) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rc_off(self):\n # reset control values\n channels = [1500] * 8\n controlout = OverrideRCIn(channels=channels)\n self.contolp.publish(controlout)\n self.rate.sleep()\n # send twice to make sure\n controlout = OverrideRCIn(channels=channels)\n self.contolp.... | [
"0.68942034",
"0.63717324",
"0.5994578",
"0.5983568",
"0.59612274",
"0.5924691",
"0.59178627",
"0.5865668",
"0.58500373",
"0.57875276",
"0.5765379",
"0.57151586",
"0.5711716",
"0.5624923",
"0.5618899",
"0.561093",
"0.56093395",
"0.5571727",
"0.55690706",
"0.55646753",
"0.5562... | 0.6580973 | 1 |
Send a NonRegistered Parameter Number (NRPN) Change via a series of CC messages. | def send_nrpn(self, param=0, value=0, ch=None):
if isinstance(param, int):
param_msb = (param >> 7)
param_lsb = param
else:
param_msb, param_lsb = param
if param_msb is not None:
self.send_control_change(NRPN_MSB, param_msb, ch=ch)
if par... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_rpn(self, param=0, value=0, ch=None):\n if isinstance(param, int):\n param_msb = (param >> 7)\n param_lsb = param\n else:\n param_msb, param_lsb = param\n\n if param_msb is not None:\n self.send_control_change(RPN_MSB, param_msb, ch=ch)\n\n ... | [
"0.6351314",
"0.5700504",
"0.5700504",
"0.55458874",
"0.54992497",
"0.54193175",
"0.53884417",
"0.51412296",
"0.51029164",
"0.50938696",
"0.5051171",
"0.5025745",
"0.4984015",
"0.49642015",
"0.49642015",
"0.49416745",
"0.4908166",
"0.49075457",
"0.48967203",
"0.4894368",
"0.4... | 0.6765165 | 0 |
Orders the color component indices in descending order by underlying component color value | def _get_color_dominance_indices(self, color):
# create a dict where the
# key is the component color value and the
# value is a list of indices that hav the component color value
value_map = defaultdict(list)
# populate the dictionary
for c in range(len(color)):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sorted_pixels(self):\n # (but make sure you have lots of memory before you do that on huge images).\n # [::-1] reverses order\n return sorted(self.get_colors(), key=lambda x: x[0])[::-1]",
"def sortColors(self, nums):\n prev = None\n for i in range(len(nums)):\n ... | [
"0.67431885",
"0.6474925",
"0.62527984",
"0.6250628",
"0.6169669",
"0.6103025",
"0.6046734",
"0.60437804",
"0.60375226",
"0.60310733",
"0.60188407",
"0.6017721",
"0.60154283",
"0.59975743",
"0.5991896",
"0.59789574",
"0.59648335",
"0.59597754",
"0.5951042",
"0.59493214",
"0.5... | 0.6674672 | 1 |
Prepends row filled with 1s to the vector, so that constant of a polynomial is evaluated easily. | def adjust(x):
return numpy.insert(x, 0, 1, axis=1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_vector_of_ones(X):\n m, n = X.shape\n vector_of_ones = np.ones([m, 1])\n X_with_ones = np.hstack([vector_of_ones, X])\n return X_with_ones",
"def fill_row(row, x):\n row.append(x)\n return row",
"def retrun_1(x):\n ret = np.ones(len(x))\n return ret",
"def vector_of_on... | [
"0.5815133",
"0.57305646",
"0.5589816",
"0.55664223",
"0.5542874",
"0.5508532",
"0.5501604",
"0.54895675",
"0.54751706",
"0.5470629",
"0.54549193",
"0.5318969",
"0.53118986",
"0.52793866",
"0.5256106",
"0.52550113",
"0.5253568",
"0.5252945",
"0.52382654",
"0.5175236",
"0.5158... | 0.5919822 | 0 |
Load all training state from a checkpoint file. | def load_checkpoint(self, filename, load_optim=True):
extra_state, optim_history, last_optim_state = \
utils.load_model_state(filename, self.get_model())
if last_optim_state is not None:
# rebuild optimizer after loading model, since params may have changed
#self.opt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_states(self, checkpoint):\n raise NotImplementedError()",
"def load_checkpoint(self, file):\n \"\"\"Load \"\"\"\n chkpnt = torch.load(file)\n self.load_state_dict(chkpnt['model_state_dict'])",
"def load_checkpoint(self, checkpoint_path, continue_from_epoch=True):\n p... | [
"0.81087583",
"0.8033849",
"0.76982284",
"0.7683451",
"0.7641029",
"0.75412816",
"0.7523152",
"0.7492258",
"0.7458825",
"0.7449599",
"0.742927",
"0.7413832",
"0.73941296",
"0.7337311",
"0.7228205",
"0.7194399",
"0.71928823",
"0.71897525",
"0.7132528",
"0.71298045",
"0.71225",... | 0.0 | -1 |
Adjust the learning rate based on the validation loss. | def lr_step(self, epoch, val_loss=None):
return self.lr_scheduler.step(epoch, val_loss) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_learning_rate(self, validation_loss=None):\n if validation_loss is None:\n for scheduler in self.schedulers:\n scheduler.step()\n else:\n for scheduler in self.schedulers:\n scheduler.step(validation_loss)\n self.lr = self.optimize... | [
"0.81608015",
"0.78845364",
"0.783218",
"0.78144497",
"0.7798104",
"0.7737746",
"0.7734006",
"0.7721605",
"0.77102494",
"0.77072096",
"0.7696294",
"0.7635987",
"0.7611377",
"0.7608403",
"0.7596307",
"0.7583568",
"0.75835013",
"0.7574952",
"0.7574137",
"0.7572539",
"0.7567046"... | 0.0 | -1 |
Update the learning rate after each update. | def lr_step_update(self, num_updates):
return self.lr_scheduler.step_update(num_updates) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_learning_rate(self):\r\n self.scheduler.step(self.clock.epoch)",
"def update_learning_rate(self):\n self.scheduler.step()\n lr = self.optimizer.param_groups[0]['lr']\n print('learning rate = %.7f' % lr)",
"def _update_learning_rate(self):\r\n\r\n self.n_steps += 1\... | [
"0.8525054",
"0.8246478",
"0.81739384",
"0.80492413",
"0.7949033",
"0.7949033",
"0.78992677",
"0.7889223",
"0.78623694",
"0.7703854",
"0.7637969",
"0.76320887",
"0.7508339",
"0.7478694",
"0.73086154",
"0.72947234",
"0.7267212",
"0.7239035",
"0.7234639",
"0.72077906",
"0.71868... | 0.0 | -1 |
Get the current learning rate. | def get_lr(self):
return self.optimizer.get_lr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_learning_rate(self):\n config = self.config\n cur_lr = Train_model_pipeline.adjust_learning_rate(\n self.optimizer,\n self.epoch,\n config[\"training\"][\"learning_rate\"],\n decay=config[\"training\"][\"lr_decay_rate\"],\n step=config[\"... | [
"0.8338021",
"0.8257183",
"0.80368876",
"0.76718974",
"0.7653609",
"0.7651945",
"0.76396656",
"0.76396656",
"0.74942815",
"0.7460383",
"0.7419125",
"0.7365561",
"0.70984983",
"0.7093192",
"0.7053641",
"0.70433134",
"0.70149547",
"0.6989301",
"0.6985221",
"0.69212395",
"0.6913... | 0.72476804 | 13 |
Get the model replica. | def get_model(self):
return self.model.module if isinstance(self.model, DDP) else self.model | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_model(self):\n # just return the first model, since all replicas are the same\n return self.call_async(0, '_async_get_model').gen()",
"def replica(self) -> str:\n return pulumi.get(self, \"replica\")",
"def replication(self):\n return self._replication",
"def get_replica_r... | [
"0.7617357",
"0.73569465",
"0.67730093",
"0.6352435",
"0.6313035",
"0.62045354",
"0.61533475",
"0.6142902",
"0.61184347",
"0.608644",
"0.6046989",
"0.59879506",
"0.5909336",
"0.58587736",
"0.5845681",
"0.5845681",
"0.5845681",
"0.5845681",
"0.5845681",
"0.5746368",
"0.5732964... | 0.5272043 | 87 |
Assumes myList is sorted. Returns closest value to myNumber. If two numbers are equally close, return the smallest number. | def takeclosest(takecloselist, takecloseint):
pos = bisect_left(takecloselist, takecloseint)
if pos == 0:
return takecloselist[0]
if pos == len(takecloselist):
return takecloselist[-1]
before = takecloselist[pos - 1]
after = takecloselist[pos]
if after - takecloseint < takeclosei... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def takeClosest(myList, myNumber):\r\n pos = bisect_left(myList, myNumber)\r\n if pos == 0:\r\n return myList[0]\r\n if pos == len(myList):\r\n return myList[-1]\r\n before = myList[pos - 1]\r\n after = myList[pos]\r\n if after - myNumber < myNumber - before:\r\n return after\... | [
"0.8772953",
"0.85214555",
"0.7693506",
"0.76566553",
"0.7288913",
"0.7015257",
"0.673282",
"0.6697672",
"0.6637932",
"0.66083807",
"0.6563489",
"0.6558982",
"0.6478829",
"0.6458925",
"0.6438972",
"0.6436921",
"0.64131486",
"0.6386327",
"0.63682765",
"0.635415",
"0.63351136",... | 0.6680794 | 8 |
Returns a Region object using this requester | def region(self, region: str) -> Region:
return Region(self, region) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getregion(self, *args, **kwargs):\n return _image.image_getregion(self, *args, **kwargs)",
"def get_object(cls, api_token, name):\n region = cls(token=api_token, name=name)\n region.load()\n return region",
"def region(self):\n if self._region is None:\n cache_... | [
"0.70377505",
"0.68898964",
"0.68013906",
"0.679581",
"0.67889696",
"0.6713321",
"0.668206",
"0.6653147",
"0.6601819",
"0.6601819",
"0.658026",
"0.6512799",
"0.6509858",
"0.64659095",
"0.6462052",
"0.6436159",
"0.6377639",
"0.6300289",
"0.6293586",
"0.62053776",
"0.62053776",... | 0.69211996 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.